output.c 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. /*
  2. * Copyright (C) 2012 Texas Instruments Ltd
  3. * Author: Archit Taneja <archit@ti.com>
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms of the GNU General Public License version 2 as published by
  7. * the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  12. * more details.
  13. *
  14. * You should have received a copy of the GNU General Public License along with
  15. * this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. #include <linux/kernel.h>
  18. #include <linux/module.h>
  19. #include <linux/platform_device.h>
  20. #include <linux/slab.h>
  21. #include <video/omapdss.h>
  22. #include "dss.h"
  23. static LIST_HEAD(output_list);
  24. static DEFINE_MUTEX(output_lock);
  25. int omapdss_output_set_device(struct omap_dss_output *out,
  26. struct omap_dss_device *dssdev)
  27. {
  28. int r;
  29. mutex_lock(&output_lock);
  30. if (out->device) {
  31. DSSERR("output already has device %s connected to it\n",
  32. out->device->name);
  33. r = -EINVAL;
  34. goto err;
  35. }
  36. if (out->type != dssdev->type) {
  37. DSSERR("output type and display type don't match\n");
  38. r = -EINVAL;
  39. goto err;
  40. }
  41. out->device = dssdev;
  42. dssdev->output = out;
  43. mutex_unlock(&output_lock);
  44. return 0;
  45. err:
  46. mutex_unlock(&output_lock);
  47. return r;
  48. }
  49. EXPORT_SYMBOL(omapdss_output_set_device);
  50. int omapdss_output_unset_device(struct omap_dss_output *out)
  51. {
  52. int r;
  53. mutex_lock(&output_lock);
  54. if (!out->device) {
  55. DSSERR("output doesn't have a device connected to it\n");
  56. r = -EINVAL;
  57. goto err;
  58. }
  59. if (out->device->state != OMAP_DSS_DISPLAY_DISABLED) {
  60. DSSERR("device %s is not disabled, cannot unset device\n",
  61. out->device->name);
  62. r = -EINVAL;
  63. goto err;
  64. }
  65. out->device->output = NULL;
  66. out->device = NULL;
  67. mutex_unlock(&output_lock);
  68. return 0;
  69. err:
  70. mutex_unlock(&output_lock);
  71. return r;
  72. }
  73. EXPORT_SYMBOL(omapdss_output_unset_device);
  74. void dss_register_output(struct omap_dss_output *out)
  75. {
  76. list_add_tail(&out->list, &output_list);
  77. }
  78. void dss_unregister_output(struct omap_dss_output *out)
  79. {
  80. list_del(&out->list);
  81. }
  82. struct omap_dss_output *omap_dss_get_output(enum omap_dss_output_id id)
  83. {
  84. struct omap_dss_output *out;
  85. list_for_each_entry(out, &output_list, list) {
  86. if (out->id == id)
  87. return out;
  88. }
  89. return NULL;
  90. }
  91. static const struct dss_mgr_ops *dss_mgr_ops;
  92. int dss_install_mgr_ops(const struct dss_mgr_ops *mgr_ops)
  93. {
  94. if (dss_mgr_ops)
  95. return -EBUSY;
  96. dss_mgr_ops = mgr_ops;
  97. return 0;
  98. }
  99. EXPORT_SYMBOL(dss_install_mgr_ops);
  100. void dss_uninstall_mgr_ops(void)
  101. {
  102. dss_mgr_ops = NULL;
  103. }
  104. EXPORT_SYMBOL(dss_uninstall_mgr_ops);
  105. void dss_mgr_set_timings(struct omap_overlay_manager *mgr,
  106. const struct omap_video_timings *timings)
  107. {
  108. dss_mgr_ops->set_timings(mgr, timings);
  109. }
  110. EXPORT_SYMBOL(dss_mgr_set_timings);
  111. void dss_mgr_set_lcd_config(struct omap_overlay_manager *mgr,
  112. const struct dss_lcd_mgr_config *config)
  113. {
  114. dss_mgr_ops->set_lcd_config(mgr, config);
  115. }
  116. EXPORT_SYMBOL(dss_mgr_set_lcd_config);
  117. int dss_mgr_enable(struct omap_overlay_manager *mgr)
  118. {
  119. return dss_mgr_ops->enable(mgr);
  120. }
  121. EXPORT_SYMBOL(dss_mgr_enable);
  122. void dss_mgr_disable(struct omap_overlay_manager *mgr)
  123. {
  124. dss_mgr_ops->disable(mgr);
  125. }
  126. EXPORT_SYMBOL(dss_mgr_disable);
  127. void dss_mgr_start_update(struct omap_overlay_manager *mgr)
  128. {
  129. dss_mgr_ops->start_update(mgr);
  130. }
  131. EXPORT_SYMBOL(dss_mgr_start_update);
  132. int dss_mgr_register_framedone_handler(struct omap_overlay_manager *mgr,
  133. void (*handler)(void *), void *data)
  134. {
  135. return dss_mgr_ops->register_framedone_handler(mgr, handler, data);
  136. }
  137. EXPORT_SYMBOL(dss_mgr_register_framedone_handler);
  138. void dss_mgr_unregister_framedone_handler(struct omap_overlay_manager *mgr,
  139. void (*handler)(void *), void *data)
  140. {
  141. dss_mgr_ops->unregister_framedone_handler(mgr, handler, data);
  142. }
  143. EXPORT_SYMBOL(dss_mgr_unregister_framedone_handler);