mdfld_tmd_vid.c 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. /*
  2. * Copyright © 2010 Intel Corporation
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice (including the next
  12. * paragraph) shall be included in all copies or substantial portions of the
  13. * Software.
  14. *
  15. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  18. * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  20. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  21. * DEALINGS IN THE SOFTWARE.
  22. *
  23. * Authors:
  24. * Jim Liu <jim.liu@intel.com>
  25. * Jackie Li<yaodong.li@intel.com>
  26. * Gideon Eaton <eaton.
  27. * Scott Rowe <scott.m.rowe@intel.com>
  28. */
  29. #include "mdfld_dsi_dpi.h"
  30. #include "mdfld_dsi_pkg_sender.h"
  31. static struct drm_display_mode *tmd_vid_get_config_mode(struct drm_device *dev)
  32. {
  33. struct drm_display_mode *mode;
  34. struct drm_psb_private *dev_priv = dev->dev_private;
  35. struct oaktrail_timing_info *ti = &dev_priv->gct_data.DTD;
  36. bool use_gct = false; /*Disable GCT for now*/
  37. mode = kzalloc(sizeof(*mode), GFP_KERNEL);
  38. if (!mode)
  39. return NULL;
  40. if (use_gct) {
  41. mode->hdisplay = (ti->hactive_hi << 8) | ti->hactive_lo;
  42. mode->vdisplay = (ti->vactive_hi << 8) | ti->vactive_lo;
  43. mode->hsync_start = mode->hdisplay + \
  44. ((ti->hsync_offset_hi << 8) | \
  45. ti->hsync_offset_lo);
  46. mode->hsync_end = mode->hsync_start + \
  47. ((ti->hsync_pulse_width_hi << 8) | \
  48. ti->hsync_pulse_width_lo);
  49. mode->htotal = mode->hdisplay + ((ti->hblank_hi << 8) | \
  50. ti->hblank_lo);
  51. mode->vsync_start = \
  52. mode->vdisplay + ((ti->vsync_offset_hi << 8) | \
  53. ti->vsync_offset_lo);
  54. mode->vsync_end = \
  55. mode->vsync_start + ((ti->vsync_pulse_width_hi << 8) | \
  56. ti->vsync_pulse_width_lo);
  57. mode->vtotal = mode->vdisplay + \
  58. ((ti->vblank_hi << 8) | ti->vblank_lo);
  59. mode->clock = ti->pixel_clock * 10;
  60. dev_dbg(dev->dev, "hdisplay is %d\n", mode->hdisplay);
  61. dev_dbg(dev->dev, "vdisplay is %d\n", mode->vdisplay);
  62. dev_dbg(dev->dev, "HSS is %d\n", mode->hsync_start);
  63. dev_dbg(dev->dev, "HSE is %d\n", mode->hsync_end);
  64. dev_dbg(dev->dev, "htotal is %d\n", mode->htotal);
  65. dev_dbg(dev->dev, "VSS is %d\n", mode->vsync_start);
  66. dev_dbg(dev->dev, "VSE is %d\n", mode->vsync_end);
  67. dev_dbg(dev->dev, "vtotal is %d\n", mode->vtotal);
  68. dev_dbg(dev->dev, "clock is %d\n", mode->clock);
  69. } else {
  70. mode->hdisplay = 480;
  71. mode->vdisplay = 854;
  72. mode->hsync_start = 487;
  73. mode->hsync_end = 490;
  74. mode->htotal = 499;
  75. mode->vsync_start = 861;
  76. mode->vsync_end = 865;
  77. mode->vtotal = 873;
  78. mode->clock = 33264;
  79. }
  80. drm_mode_set_name(mode);
  81. drm_mode_set_crtcinfo(mode, 0);
  82. mode->type |= DRM_MODE_TYPE_PREFERRED;
  83. return mode;
  84. }
  85. static int tmd_vid_get_panel_info(struct drm_device *dev,
  86. int pipe,
  87. struct panel_info *pi)
  88. {
  89. if (!dev || !pi)
  90. return -EINVAL;
  91. pi->width_mm = TMD_PANEL_WIDTH;
  92. pi->height_mm = TMD_PANEL_HEIGHT;
  93. return 0;
  94. }
  95. /* ************************************************************************* *\
  96. * FUNCTION: mdfld_init_TMD_MIPI
  97. *
  98. * DESCRIPTION: This function is called only by mrst_dsi_mode_set and
  99. * restore_display_registers. since this function does not
  100. * acquire the mutex, it is important that the calling function
  101. * does!
  102. \* ************************************************************************* */
  103. /* FIXME: make the below data u8 instead of u32; note byte order! */
  104. static u32 tmd_cmd_mcap_off[] = {0x000000b2};
  105. static u32 tmd_cmd_enable_lane_switch[] = {0x000101ef};
  106. static u32 tmd_cmd_set_lane_num[] = {0x006360ef};
  107. static u32 tmd_cmd_pushing_clock0[] = {0x00cc2fef};
  108. static u32 tmd_cmd_pushing_clock1[] = {0x00dd6eef};
  109. static u32 tmd_cmd_set_mode[] = {0x000000b3};
  110. static u32 tmd_cmd_set_sync_pulse_mode[] = {0x000961ef};
  111. static u32 tmd_cmd_set_column[] = {0x0100002a, 0x000000df};
  112. static u32 tmd_cmd_set_page[] = {0x0300002b, 0x00000055};
  113. static u32 tmd_cmd_set_video_mode[] = {0x00000153};
  114. /*no auto_bl,need add in furture*/
  115. static u32 tmd_cmd_enable_backlight[] = {0x00005ab4};
  116. static u32 tmd_cmd_set_backlight_dimming[] = {0x00000ebd};
  117. static void mdfld_dsi_tmd_drv_ic_init(struct mdfld_dsi_config *dsi_config,
  118. int pipe)
  119. {
  120. struct mdfld_dsi_pkg_sender *sender
  121. = mdfld_dsi_get_pkg_sender(dsi_config);
  122. DRM_INFO("Enter mdfld init TMD MIPI display.\n");
  123. if (!sender) {
  124. DRM_ERROR("Cannot get sender\n");
  125. return;
  126. }
  127. if (dsi_config->dvr_ic_inited)
  128. return;
  129. msleep(3);
  130. /* FIXME: make the below data u8 instead of u32; note byte order! */
  131. mdfld_dsi_send_gen_long(sender, (u8 *) tmd_cmd_mcap_off,
  132. sizeof(tmd_cmd_mcap_off), false);
  133. mdfld_dsi_send_gen_long(sender, (u8 *) tmd_cmd_enable_lane_switch,
  134. sizeof(tmd_cmd_enable_lane_switch), false);
  135. mdfld_dsi_send_gen_long(sender, (u8 *) tmd_cmd_set_lane_num,
  136. sizeof(tmd_cmd_set_lane_num), false);
  137. mdfld_dsi_send_gen_long(sender, (u8 *) tmd_cmd_pushing_clock0,
  138. sizeof(tmd_cmd_pushing_clock0), false);
  139. mdfld_dsi_send_gen_long(sender, (u8 *) tmd_cmd_pushing_clock1,
  140. sizeof(tmd_cmd_pushing_clock1), false);
  141. mdfld_dsi_send_gen_long(sender, (u8 *) tmd_cmd_set_mode,
  142. sizeof(tmd_cmd_set_mode), false);
  143. mdfld_dsi_send_gen_long(sender, (u8 *) tmd_cmd_set_sync_pulse_mode,
  144. sizeof(tmd_cmd_set_sync_pulse_mode), false);
  145. mdfld_dsi_send_mcs_long(sender, (u8 *) tmd_cmd_set_column,
  146. sizeof(tmd_cmd_set_column), false);
  147. mdfld_dsi_send_mcs_long(sender, (u8 *) tmd_cmd_set_page,
  148. sizeof(tmd_cmd_set_page), false);
  149. mdfld_dsi_send_gen_long(sender, (u8 *) tmd_cmd_set_video_mode,
  150. sizeof(tmd_cmd_set_video_mode), false);
  151. mdfld_dsi_send_gen_long(sender, (u8 *) tmd_cmd_enable_backlight,
  152. sizeof(tmd_cmd_enable_backlight), false);
  153. mdfld_dsi_send_gen_long(sender, (u8 *) tmd_cmd_set_backlight_dimming,
  154. sizeof(tmd_cmd_set_backlight_dimming), false);
  155. dsi_config->dvr_ic_inited = 1;
  156. }
  157. /*TPO DPI encoder helper funcs*/
  158. static const struct drm_encoder_helper_funcs
  159. mdfld_tpo_dpi_encoder_helper_funcs = {
  160. .dpms = mdfld_dsi_dpi_dpms,
  161. .mode_fixup = mdfld_dsi_dpi_mode_fixup,
  162. .prepare = mdfld_dsi_dpi_prepare,
  163. .mode_set = mdfld_dsi_dpi_mode_set,
  164. .commit = mdfld_dsi_dpi_commit,
  165. };
  166. /*TPO DPI encoder funcs*/
  167. static const struct drm_encoder_funcs mdfld_tpo_dpi_encoder_funcs = {
  168. .destroy = drm_encoder_cleanup,
  169. };
  170. const struct panel_funcs mdfld_tmd_vid_funcs = {
  171. .encoder_funcs = &mdfld_tpo_dpi_encoder_funcs,
  172. .encoder_helper_funcs = &mdfld_tpo_dpi_encoder_helper_funcs,
  173. .get_config_mode = &tmd_vid_get_config_mode,
  174. .get_panel_info = tmd_vid_get_panel_info,
  175. .reset = mdfld_dsi_panel_reset,
  176. .drv_ic_init = mdfld_dsi_tmd_drv_ic_init,
  177. };