blob: 104dd517fdbe032d4f0f5a87e96b64efbfe4b6b5 [file] [log] [blame]
Russell King7e435aa2014-06-15 11:07:12 +01001#ifndef __DRM_OF_H__
2#define __DRM_OF_H__
3
Philipp Zabel4cacf912015-02-24 11:34:01 +01004#include <linux/of_graph.h>
5
Liviu Dudaudf785aa2015-10-20 10:23:12 +01006struct component_master_ops;
Russell King97ac0e42016-10-19 11:28:27 +01007struct component_match;
Liviu Dudaudf785aa2015-10-20 10:23:12 +01008struct device;
Russell King7e435aa2014-06-15 11:07:12 +01009struct drm_device;
Philipp Zabel4cacf912015-02-24 11:34:01 +010010struct drm_encoder;
Rob Herring1f2db302017-03-22 08:26:05 -050011struct drm_panel;
12struct drm_bridge;
Russell King7e435aa2014-06-15 11:07:12 +010013struct device_node;
14
15#ifdef CONFIG_OF
Daniel Vetter91faa042017-03-22 09:36:02 +010016uint32_t drm_of_find_possible_crtcs(struct drm_device *dev,
17 struct device_node *port);
18void drm_of_component_match_add(struct device *master,
19 struct component_match **matchptr,
20 int (*compare)(struct device *, void *),
21 struct device_node *node);
22int drm_of_component_probe(struct device *dev,
23 int (*compare_of)(struct device *, void *),
24 const struct component_master_ops *m_ops);
25int drm_of_encoder_active_endpoint(struct device_node *node,
26 struct drm_encoder *encoder,
27 struct of_endpoint *endpoint);
Rob Herring1f2db302017-03-22 08:26:05 -050028int drm_of_find_panel_or_bridge(const struct device_node *np,
29 int port, int endpoint,
30 struct drm_panel **panel,
31 struct drm_bridge **bridge);
Russell King7e435aa2014-06-15 11:07:12 +010032#else
33static inline uint32_t drm_of_find_possible_crtcs(struct drm_device *dev,
34 struct device_node *port)
35{
36 return 0;
37}
Liviu Dudaudf785aa2015-10-20 10:23:12 +010038
Arnd Bergmann329f4c82016-10-26 10:57:47 +020039static inline void
40drm_of_component_match_add(struct device *master,
41 struct component_match **matchptr,
42 int (*compare)(struct device *, void *),
43 struct device_node *node)
Russell King97ac0e42016-10-19 11:28:27 +010044{
45}
46
Liviu Dudaudf785aa2015-10-20 10:23:12 +010047static inline int
48drm_of_component_probe(struct device *dev,
49 int (*compare_of)(struct device *, void *),
50 const struct component_master_ops *m_ops)
51{
52 return -EINVAL;
53}
Philipp Zabel4cacf912015-02-24 11:34:01 +010054
55static inline int drm_of_encoder_active_endpoint(struct device_node *node,
56 struct drm_encoder *encoder,
57 struct of_endpoint *endpoint)
58{
59 return -EINVAL;
60}
Rob Herring1f2db302017-03-22 08:26:05 -050061static inline int drm_of_find_panel_or_bridge(const struct device_node *np,
62 int port, int endpoint,
63 struct drm_panel **panel,
64 struct drm_bridge **bridge)
65{
66 return -EINVAL;
67}
Russell King7e435aa2014-06-15 11:07:12 +010068#endif
69
Philipp Zabel4cacf912015-02-24 11:34:01 +010070static inline int drm_of_encoder_active_endpoint_id(struct device_node *node,
71 struct drm_encoder *encoder)
72{
73 struct of_endpoint endpoint;
74 int ret = drm_of_encoder_active_endpoint(node, encoder,
75 &endpoint);
76
77 return ret ?: endpoint.id;
78}
79
80static inline int drm_of_encoder_active_port_id(struct device_node *node,
81 struct drm_encoder *encoder)
82{
83 struct of_endpoint endpoint;
84 int ret = drm_of_encoder_active_endpoint(node, encoder,
85 &endpoint);
86
87 return ret ?: endpoint.port;
88}
89
Russell King7e435aa2014-06-15 11:07:12 +010090#endif /* __DRM_OF_H__ */