output.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright (C) 2012 Texas Instruments Incorporated - https://www.ti.com/
  4. * Author: Archit Taneja <[email protected]>
  5. */
  6. #include <linux/kernel.h>
  7. #include <linux/module.h>
  8. #include <linux/platform_device.h>
  9. #include <linux/slab.h>
  10. #include <linux/of.h>
  11. #include <linux/of_graph.h>
  12. #include <drm/drm_bridge.h>
  13. #include <drm/drm_panel.h>
  14. #include "dss.h"
  15. #include "omapdss.h"
  16. int omapdss_device_init_output(struct omap_dss_device *out,
  17. struct drm_bridge *local_bridge)
  18. {
  19. struct device_node *remote_node;
  20. int ret;
  21. remote_node = of_graph_get_remote_node(out->dev->of_node,
  22. out->of_port, 0);
  23. if (!remote_node) {
  24. dev_dbg(out->dev, "failed to find video sink\n");
  25. return 0;
  26. }
  27. out->bridge = of_drm_find_bridge(remote_node);
  28. out->panel = of_drm_find_panel(remote_node);
  29. if (IS_ERR(out->panel))
  30. out->panel = NULL;
  31. of_node_put(remote_node);
  32. if (out->panel) {
  33. struct drm_bridge *bridge;
  34. bridge = drm_panel_bridge_add(out->panel);
  35. if (IS_ERR(bridge)) {
  36. dev_err(out->dev,
  37. "unable to create panel bridge (%ld)\n",
  38. PTR_ERR(bridge));
  39. ret = PTR_ERR(bridge);
  40. goto error;
  41. }
  42. out->bridge = bridge;
  43. }
  44. if (local_bridge) {
  45. if (!out->bridge) {
  46. ret = -EPROBE_DEFER;
  47. goto error;
  48. }
  49. out->next_bridge = out->bridge;
  50. out->bridge = local_bridge;
  51. }
  52. if (!out->bridge) {
  53. ret = -EPROBE_DEFER;
  54. goto error;
  55. }
  56. return 0;
  57. error:
  58. omapdss_device_cleanup_output(out);
  59. return ret;
  60. }
  61. void omapdss_device_cleanup_output(struct omap_dss_device *out)
  62. {
  63. if (out->bridge && out->panel)
  64. drm_panel_bridge_remove(out->next_bridge ?
  65. out->next_bridge : out->bridge);
  66. }
  67. void dss_mgr_set_timings(struct omap_dss_device *dssdev,
  68. const struct videomode *vm)
  69. {
  70. omap_crtc_dss_set_timings(dssdev->dss->mgr_ops_priv,
  71. dssdev->dispc_channel, vm);
  72. }
  73. void dss_mgr_set_lcd_config(struct omap_dss_device *dssdev,
  74. const struct dss_lcd_mgr_config *config)
  75. {
  76. omap_crtc_dss_set_lcd_config(dssdev->dss->mgr_ops_priv,
  77. dssdev->dispc_channel, config);
  78. }
  79. int dss_mgr_enable(struct omap_dss_device *dssdev)
  80. {
  81. return omap_crtc_dss_enable(dssdev->dss->mgr_ops_priv,
  82. dssdev->dispc_channel);
  83. }
  84. void dss_mgr_disable(struct omap_dss_device *dssdev)
  85. {
  86. omap_crtc_dss_disable(dssdev->dss->mgr_ops_priv,
  87. dssdev->dispc_channel);
  88. }
  89. void dss_mgr_start_update(struct omap_dss_device *dssdev)
  90. {
  91. omap_crtc_dss_start_update(dssdev->dss->mgr_ops_priv,
  92. dssdev->dispc_channel);
  93. }
  94. int dss_mgr_register_framedone_handler(struct omap_dss_device *dssdev,
  95. void (*handler)(void *), void *data)
  96. {
  97. struct dss_device *dss = dssdev->dss;
  98. return omap_crtc_dss_register_framedone(dss->mgr_ops_priv,
  99. dssdev->dispc_channel,
  100. handler, data);
  101. }
  102. void dss_mgr_unregister_framedone_handler(struct omap_dss_device *dssdev,
  103. void (*handler)(void *), void *data)
  104. {
  105. struct dss_device *dss = dssdev->dss;
  106. omap_crtc_dss_unregister_framedone(dss->mgr_ops_priv,
  107. dssdev->dispc_channel,
  108. handler, data);
  109. }