Linux 4.16.11
[linux/fpc-iii.git] / include / drm / drm_of.h
blobb93c239afb608e04f2d06149833488cd66db4d88
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __DRM_OF_H__
3 #define __DRM_OF_H__
5 #include <linux/of_graph.h>
6 #if IS_ENABLED(CONFIG_OF) && IS_ENABLED(CONFIG_DRM_PANEL_BRIDGE)
7 #include <drm/drm_bridge.h>
8 #endif
10 struct component_master_ops;
11 struct component_match;
12 struct device;
13 struct drm_device;
14 struct drm_encoder;
15 struct drm_panel;
16 struct drm_bridge;
17 struct device_node;
19 #ifdef CONFIG_OF
20 uint32_t drm_of_find_possible_crtcs(struct drm_device *dev,
21 struct device_node *port);
22 void drm_of_component_match_add(struct device *master,
23 struct component_match **matchptr,
24 int (*compare)(struct device *, void *),
25 struct device_node *node);
26 int drm_of_component_probe(struct device *dev,
27 int (*compare_of)(struct device *, void *),
28 const struct component_master_ops *m_ops);
29 int drm_of_encoder_active_endpoint(struct device_node *node,
30 struct drm_encoder *encoder,
31 struct of_endpoint *endpoint);
32 int drm_of_find_panel_or_bridge(const struct device_node *np,
33 int port, int endpoint,
34 struct drm_panel **panel,
35 struct drm_bridge **bridge);
36 #else
37 static inline uint32_t drm_of_find_possible_crtcs(struct drm_device *dev,
38 struct device_node *port)
40 return 0;
43 static inline void
44 drm_of_component_match_add(struct device *master,
45 struct component_match **matchptr,
46 int (*compare)(struct device *, void *),
47 struct device_node *node)
51 static inline int
52 drm_of_component_probe(struct device *dev,
53 int (*compare_of)(struct device *, void *),
54 const struct component_master_ops *m_ops)
56 return -EINVAL;
59 static inline int drm_of_encoder_active_endpoint(struct device_node *node,
60 struct drm_encoder *encoder,
61 struct of_endpoint *endpoint)
63 return -EINVAL;
65 static inline int drm_of_find_panel_or_bridge(const struct device_node *np,
66 int port, int endpoint,
67 struct drm_panel **panel,
68 struct drm_bridge **bridge)
70 return -EINVAL;
72 #endif
75 * drm_of_panel_bridge_remove - remove panel bridge
76 * @np: device tree node containing panel bridge output ports
78 * Remove the panel bridge of a given DT node's port and endpoint number
80 * Returns zero if successful, or one of the standard error codes if it fails.
82 static inline int drm_of_panel_bridge_remove(const struct device_node *np,
83 int port, int endpoint)
85 #if IS_ENABLED(CONFIG_OF) && IS_ENABLED(CONFIG_DRM_PANEL_BRIDGE)
86 struct drm_bridge *bridge;
87 struct device_node *remote;
89 remote = of_graph_get_remote_node(np, port, endpoint);
90 if (!remote)
91 return -ENODEV;
93 bridge = of_drm_find_bridge(remote);
94 drm_panel_bridge_remove(bridge);
96 return 0;
97 #else
98 return -EINVAL;
99 #endif
102 static inline int drm_of_encoder_active_endpoint_id(struct device_node *node,
103 struct drm_encoder *encoder)
105 struct of_endpoint endpoint;
106 int ret = drm_of_encoder_active_endpoint(node, encoder,
107 &endpoint);
109 return ret ?: endpoint.id;
112 static inline int drm_of_encoder_active_port_id(struct device_node *node,
113 struct drm_encoder *encoder)
115 struct of_endpoint endpoint;
116 int ret = drm_of_encoder_active_endpoint(node, encoder,
117 &endpoint);
119 return ret ?: endpoint.port;
122 #endif /* __DRM_OF_H__ */