hdmi_omap4_panel.c 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. /*
  2. * hdmi_omap4_panel.c
  3. *
  4. * HDMI library support functions for TI OMAP4 processors.
  5. *
  6. * Copyright (C) 2010-2011 Texas Instruments Incorporated - http://www.ti.com/
  7. * Authors: Mythri P k <mythripk@ti.com>
  8. *
  9. * This program is free software; you can redistribute it and/or modify it
  10. * under the terms of the GNU General Public License version 2 as published by
  11. * the Free Software Foundation.
  12. *
  13. * This program is distributed in the hope that it will be useful, but WITHOUT
  14. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  15. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  16. * more details.
  17. *
  18. * You should have received a copy of the GNU General Public License along with
  19. * this program. If not, see <http://www.gnu.org/licenses/>.
  20. */
  21. #include <linux/kernel.h>
  22. #include <linux/err.h>
  23. #include <linux/io.h>
  24. #include <linux/mutex.h>
  25. #include <linux/module.h>
  26. #include <plat/display.h>
  27. #include "dss.h"
  28. static struct {
  29. struct mutex hdmi_lock;
  30. } hdmi;
  31. static int hdmi_panel_probe(struct omap_dss_device *dssdev)
  32. {
  33. DSSDBG("ENTER hdmi_panel_probe\n");
  34. dssdev->panel.config = OMAP_DSS_LCD_TFT |
  35. OMAP_DSS_LCD_IVS | OMAP_DSS_LCD_IHS;
  36. /*
  37. * Initialize the timings to 640 * 480
  38. * This is only for framebuffer update not for TV timing setting
  39. * Setting TV timing will be done only on enable
  40. */
  41. dssdev->panel.timings.x_res = 640;
  42. dssdev->panel.timings.y_res = 480;
  43. DSSDBG("hdmi_panel_probe x_res= %d y_res = %d\n",
  44. dssdev->panel.timings.x_res,
  45. dssdev->panel.timings.y_res);
  46. return 0;
  47. }
  48. static void hdmi_panel_remove(struct omap_dss_device *dssdev)
  49. {
  50. }
  51. static int hdmi_panel_enable(struct omap_dss_device *dssdev)
  52. {
  53. int r = 0;
  54. DSSDBG("ENTER hdmi_panel_enable\n");
  55. mutex_lock(&hdmi.hdmi_lock);
  56. if (dssdev->state != OMAP_DSS_DISPLAY_DISABLED) {
  57. r = -EINVAL;
  58. goto err;
  59. }
  60. r = omapdss_hdmi_display_enable(dssdev);
  61. if (r) {
  62. DSSERR("failed to power on\n");
  63. goto err;
  64. }
  65. dssdev->state = OMAP_DSS_DISPLAY_ACTIVE;
  66. err:
  67. mutex_unlock(&hdmi.hdmi_lock);
  68. return r;
  69. }
  70. static void hdmi_panel_disable(struct omap_dss_device *dssdev)
  71. {
  72. mutex_lock(&hdmi.hdmi_lock);
  73. if (dssdev->state == OMAP_DSS_DISPLAY_ACTIVE)
  74. omapdss_hdmi_display_disable(dssdev);
  75. dssdev->state = OMAP_DSS_DISPLAY_DISABLED;
  76. mutex_unlock(&hdmi.hdmi_lock);
  77. }
  78. static int hdmi_panel_suspend(struct omap_dss_device *dssdev)
  79. {
  80. int r = 0;
  81. mutex_lock(&hdmi.hdmi_lock);
  82. if (dssdev->state != OMAP_DSS_DISPLAY_ACTIVE) {
  83. r = -EINVAL;
  84. goto err;
  85. }
  86. dssdev->state = OMAP_DSS_DISPLAY_SUSPENDED;
  87. omapdss_hdmi_display_disable(dssdev);
  88. err:
  89. mutex_unlock(&hdmi.hdmi_lock);
  90. return r;
  91. }
  92. static int hdmi_panel_resume(struct omap_dss_device *dssdev)
  93. {
  94. int r = 0;
  95. mutex_lock(&hdmi.hdmi_lock);
  96. if (dssdev->state != OMAP_DSS_DISPLAY_SUSPENDED) {
  97. r = -EINVAL;
  98. goto err;
  99. }
  100. r = omapdss_hdmi_display_enable(dssdev);
  101. if (r) {
  102. DSSERR("failed to power on\n");
  103. goto err;
  104. }
  105. dssdev->state = OMAP_DSS_DISPLAY_ACTIVE;
  106. err:
  107. mutex_unlock(&hdmi.hdmi_lock);
  108. return r;
  109. }
  110. static void hdmi_get_timings(struct omap_dss_device *dssdev,
  111. struct omap_video_timings *timings)
  112. {
  113. mutex_lock(&hdmi.hdmi_lock);
  114. *timings = dssdev->panel.timings;
  115. mutex_unlock(&hdmi.hdmi_lock);
  116. }
  117. static void hdmi_set_timings(struct omap_dss_device *dssdev,
  118. struct omap_video_timings *timings)
  119. {
  120. DSSDBG("hdmi_set_timings\n");
  121. mutex_lock(&hdmi.hdmi_lock);
  122. dssdev->panel.timings = *timings;
  123. if (dssdev->state == OMAP_DSS_DISPLAY_ACTIVE) {
  124. /* turn the hdmi off and on to get new timings to use */
  125. omapdss_hdmi_display_disable(dssdev);
  126. omapdss_hdmi_display_set_timing(dssdev);
  127. }
  128. mutex_unlock(&hdmi.hdmi_lock);
  129. }
  130. static int hdmi_check_timings(struct omap_dss_device *dssdev,
  131. struct omap_video_timings *timings)
  132. {
  133. int r = 0;
  134. DSSDBG("hdmi_check_timings\n");
  135. mutex_lock(&hdmi.hdmi_lock);
  136. r = omapdss_hdmi_display_check_timing(dssdev, timings);
  137. if (r) {
  138. DSSERR("Timing cannot be applied\n");
  139. goto err;
  140. }
  141. err:
  142. mutex_unlock(&hdmi.hdmi_lock);
  143. return r;
  144. }
  145. static struct omap_dss_driver hdmi_driver = {
  146. .probe = hdmi_panel_probe,
  147. .remove = hdmi_panel_remove,
  148. .enable = hdmi_panel_enable,
  149. .disable = hdmi_panel_disable,
  150. .suspend = hdmi_panel_suspend,
  151. .resume = hdmi_panel_resume,
  152. .get_timings = hdmi_get_timings,
  153. .set_timings = hdmi_set_timings,
  154. .check_timings = hdmi_check_timings,
  155. .driver = {
  156. .name = "hdmi_panel",
  157. .owner = THIS_MODULE,
  158. },
  159. };
  160. int hdmi_panel_init(void)
  161. {
  162. mutex_init(&hdmi.hdmi_lock);
  163. omap_dss_register_driver(&hdmi_driver);
  164. return 0;
  165. }
  166. void hdmi_panel_exit(void)
  167. {
  168. omap_dss_unregister_driver(&hdmi_driver);
  169. }