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