drm_of.h 2.0 KB

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