drm_of.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef __DRM_OF_H__
  3. #define __DRM_OF_H__
  4. #include <linux/of_graph.h>
  5. struct component_master_ops;
  6. struct component_match;
  7. struct device;
  8. struct drm_device;
  9. struct drm_encoder;
  10. struct drm_panel;
  11. struct drm_bridge;
  12. struct device_node;
  13. #ifdef CONFIG_OF
  14. uint32_t drm_of_find_possible_crtcs(struct drm_device *dev,
  15. struct device_node *port);
  16. void drm_of_component_match_add(struct device *master,
  17. struct component_match **matchptr,
  18. int (*compare)(struct device *, void *),
  19. struct device_node *node);
  20. int drm_of_component_probe(struct device *dev,
  21. int (*compare_of)(struct device *, void *),
  22. const struct component_master_ops *m_ops);
  23. int drm_of_encoder_active_endpoint(struct device_node *node,
  24. struct drm_encoder *encoder,
  25. struct of_endpoint *endpoint);
  26. int drm_of_find_panel_or_bridge(const struct device_node *np,
  27. int port, int endpoint,
  28. struct drm_panel **panel,
  29. struct drm_bridge **bridge);
  30. #else
  31. static inline uint32_t drm_of_find_possible_crtcs(struct drm_device *dev,
  32. struct device_node *port)
  33. {
  34. return 0;
  35. }
  36. static inline void
  37. drm_of_component_match_add(struct device *master,
  38. struct component_match **matchptr,
  39. int (*compare)(struct device *, void *),
  40. struct device_node *node)
  41. {
  42. }
  43. static inline int
  44. drm_of_component_probe(struct device *dev,
  45. int (*compare_of)(struct device *, void *),
  46. const struct component_master_ops *m_ops)
  47. {
  48. return -EINVAL;
  49. }
  50. static inline int drm_of_encoder_active_endpoint(struct device_node *node,
  51. struct drm_encoder *encoder,
  52. struct of_endpoint *endpoint)
  53. {
  54. return -EINVAL;
  55. }
  56. static inline int drm_of_find_panel_or_bridge(const struct device_node *np,
  57. int port, int endpoint,
  58. struct drm_panel **panel,
  59. struct drm_bridge **bridge)
  60. {
  61. return -EINVAL;
  62. }
  63. #endif
  64. static inline int drm_of_encoder_active_endpoint_id(struct device_node *node,
  65. struct drm_encoder *encoder)
  66. {
  67. struct of_endpoint endpoint;
  68. int ret = drm_of_encoder_active_endpoint(node, encoder,
  69. &endpoint);
  70. return ret ?: endpoint.id;
  71. }
  72. static inline int drm_of_encoder_active_port_id(struct device_node *node,
  73. struct drm_encoder *encoder)
  74. {
  75. struct of_endpoint endpoint;
  76. int ret = drm_of_encoder_active_endpoint(node, encoder,
  77. &endpoint);
  78. return ret ?: endpoint.port;
  79. }
  80. #endif /* __DRM_OF_H__ */