mdfld_tpo_vid.c 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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. */
  27. #include "mdfld_dsi_dpi.h"
  28. static struct drm_display_mode *tpo_vid_get_config_mode(struct drm_device *dev)
  29. {
  30. struct drm_display_mode *mode;
  31. struct drm_psb_private *dev_priv = dev->dev_private;
  32. struct oaktrail_timing_info *ti = &dev_priv->gct_data.DTD;
  33. bool use_gct = false;
  34. mode = kzalloc(sizeof(*mode), GFP_KERNEL);
  35. if (!mode)
  36. return NULL;
  37. if (use_gct) {
  38. mode->hdisplay = (ti->hactive_hi << 8) | ti->hactive_lo;
  39. mode->vdisplay = (ti->vactive_hi << 8) | ti->vactive_lo;
  40. mode->hsync_start = mode->hdisplay +
  41. ((ti->hsync_offset_hi << 8) |
  42. ti->hsync_offset_lo);
  43. mode->hsync_end = mode->hsync_start +
  44. ((ti->hsync_pulse_width_hi << 8) |
  45. ti->hsync_pulse_width_lo);
  46. mode->htotal = mode->hdisplay + ((ti->hblank_hi << 8) |
  47. ti->hblank_lo);
  48. mode->vsync_start =
  49. mode->vdisplay + ((ti->vsync_offset_hi << 8) |
  50. ti->vsync_offset_lo);
  51. mode->vsync_end =
  52. mode->vsync_start + ((ti->vsync_pulse_width_hi << 8) |
  53. ti->vsync_pulse_width_lo);
  54. mode->vtotal = mode->vdisplay +
  55. ((ti->vblank_hi << 8) | ti->vblank_lo);
  56. mode->clock = ti->pixel_clock * 10;
  57. dev_dbg(dev->dev, "hdisplay is %d\n", mode->hdisplay);
  58. dev_dbg(dev->dev, "vdisplay is %d\n", mode->vdisplay);
  59. dev_dbg(dev->dev, "HSS is %d\n", mode->hsync_start);
  60. dev_dbg(dev->dev, "HSE is %d\n", mode->hsync_end);
  61. dev_dbg(dev->dev, "htotal is %d\n", mode->htotal);
  62. dev_dbg(dev->dev, "VSS is %d\n", mode->vsync_start);
  63. dev_dbg(dev->dev, "VSE is %d\n", mode->vsync_end);
  64. dev_dbg(dev->dev, "vtotal is %d\n", mode->vtotal);
  65. dev_dbg(dev->dev, "clock is %d\n", mode->clock);
  66. } else {
  67. mode->hdisplay = 864;
  68. mode->vdisplay = 480;
  69. mode->hsync_start = 873;
  70. mode->hsync_end = 876;
  71. mode->htotal = 887;
  72. mode->vsync_start = 487;
  73. mode->vsync_end = 490;
  74. mode->vtotal = 499;
  75. mode->clock = 33264;
  76. }
  77. drm_mode_set_name(mode);
  78. drm_mode_set_crtcinfo(mode, 0);
  79. mode->type |= DRM_MODE_TYPE_PREFERRED;
  80. return mode;
  81. }
  82. static int tpo_vid_get_panel_info(struct drm_device *dev,
  83. int pipe,
  84. struct panel_info *pi)
  85. {
  86. if (!dev || !pi)
  87. return -EINVAL;
  88. pi->width_mm = TPO_PANEL_WIDTH;
  89. pi->height_mm = TPO_PANEL_HEIGHT;
  90. return 0;
  91. }
  92. /*TPO DPI encoder helper funcs*/
  93. static const struct drm_encoder_helper_funcs
  94. mdfld_tpo_dpi_encoder_helper_funcs = {
  95. .dpms = mdfld_dsi_dpi_dpms,
  96. .mode_fixup = mdfld_dsi_dpi_mode_fixup,
  97. .prepare = mdfld_dsi_dpi_prepare,
  98. .mode_set = mdfld_dsi_dpi_mode_set,
  99. .commit = mdfld_dsi_dpi_commit,
  100. };
  101. /*TPO DPI encoder funcs*/
  102. static const struct drm_encoder_funcs mdfld_tpo_dpi_encoder_funcs = {
  103. .destroy = drm_encoder_cleanup,
  104. };
  105. const struct panel_funcs mdfld_tpo_vid_funcs = {
  106. .encoder_funcs = &mdfld_tpo_dpi_encoder_funcs,
  107. .encoder_helper_funcs = &mdfld_tpo_dpi_encoder_helper_funcs,
  108. .get_config_mode = &tpo_vid_get_config_mode,
  109. .get_panel_info = tpo_vid_get_panel_info,
  110. };