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