1 /* SPDX-License-Identifier: GPL-2.0 */
6 #include <linux/of_graph.h>
7 #if IS_ENABLED(CONFIG_OF) && IS_ENABLED(CONFIG_DRM_PANEL_BRIDGE)
8 #include <drm/drm_bridge.h>
11 struct component_master_ops;
12 struct component_match;
19 struct mipi_dsi_device_info;
23 * enum drm_lvds_dual_link_pixels - Pixel order of an LVDS dual-link connection
24 * @DRM_LVDS_DUAL_LINK_EVEN_ODD_PIXELS: Even pixels are expected to be generated
25 * from the first port, odd pixels from the second port
26 * @DRM_LVDS_DUAL_LINK_ODD_EVEN_PIXELS: Odd pixels are expected to be generated
27 * from the first port, even pixels from the second port
29 enum drm_lvds_dual_link_pixels {
30 DRM_LVDS_DUAL_LINK_EVEN_ODD_PIXELS = 0,
31 DRM_LVDS_DUAL_LINK_ODD_EVEN_PIXELS = 1,
35 uint32_t drm_of_crtc_port_mask(struct drm_device *dev,
36 struct device_node *port);
37 uint32_t drm_of_find_possible_crtcs(struct drm_device *dev,
38 struct device_node *port);
39 void drm_of_component_match_add(struct device *master,
40 struct component_match **matchptr,
41 int (*compare)(struct device *, void *),
42 struct device_node *node);
43 int drm_of_component_probe(struct device *dev,
44 int (*compare_of)(struct device *, void *),
45 const struct component_master_ops *m_ops);
46 int drm_of_encoder_active_endpoint(struct device_node *node,
47 struct drm_encoder *encoder,
48 struct of_endpoint *endpoint);
49 int drm_of_find_panel_or_bridge(const struct device_node *np,
50 int port, int endpoint,
51 struct drm_panel **panel,
52 struct drm_bridge **bridge);
53 int drm_of_lvds_get_dual_link_pixel_order(const struct device_node *port1,
54 const struct device_node *port2);
55 int drm_of_lvds_get_dual_link_pixel_order_sink(struct device_node *port1,
56 struct device_node *port2);
57 int drm_of_lvds_get_data_mapping(const struct device_node *port);
58 int drm_of_get_data_lanes_count(const struct device_node *endpoint,
59 const unsigned int min, const unsigned int max);
60 int drm_of_get_data_lanes_count_ep(const struct device_node *port,
61 int port_reg, int reg,
62 const unsigned int min,
63 const unsigned int max);
65 static inline uint32_t drm_of_crtc_port_mask(struct drm_device *dev,
66 struct device_node *port)
71 static inline uint32_t drm_of_find_possible_crtcs(struct drm_device *dev,
72 struct device_node *port)
78 drm_of_component_match_add(struct device *master,
79 struct component_match **matchptr,
80 int (*compare)(struct device *, void *),
81 struct device_node *node)
86 drm_of_component_probe(struct device *dev,
87 int (*compare_of)(struct device *, void *),
88 const struct component_master_ops *m_ops)
93 static inline int drm_of_encoder_active_endpoint(struct device_node *node,
94 struct drm_encoder *encoder,
95 struct of_endpoint *endpoint)
99 static inline int drm_of_find_panel_or_bridge(const struct device_node *np,
100 int port, int endpoint,
101 struct drm_panel **panel,
102 struct drm_bridge **bridge)
108 drm_of_lvds_get_dual_link_pixel_order(const struct device_node *port1,
109 const struct device_node *port2)
115 drm_of_lvds_get_dual_link_pixel_order_sink(struct device_node *port1,
116 struct device_node *port2)
122 drm_of_lvds_get_data_mapping(const struct device_node *port)
128 drm_of_get_data_lanes_count(const struct device_node *endpoint,
129 const unsigned int min, const unsigned int max)
135 drm_of_get_data_lanes_count_ep(const struct device_node *port,
136 int port_reg, int reg,
137 const unsigned int min,
138 const unsigned int max)
144 #if IS_ENABLED(CONFIG_OF) && IS_ENABLED(CONFIG_DRM_MIPI_DSI)
145 struct mipi_dsi_host *drm_of_get_dsi_bus(struct device *dev);
148 mipi_dsi_host *drm_of_get_dsi_bus(struct device *dev)
150 return ERR_PTR(-EINVAL);
152 #endif /* CONFIG_OF && CONFIG_DRM_MIPI_DSI */
155 * drm_of_panel_bridge_remove - remove panel bridge
156 * @np: device tree node containing panel bridge output ports
158 * Remove the panel bridge of a given DT node's port and endpoint number
160 * Returns zero if successful, or one of the standard error codes if it fails.
162 static inline int drm_of_panel_bridge_remove(const struct device_node *np,
163 int port, int endpoint)
165 #if IS_ENABLED(CONFIG_OF) && IS_ENABLED(CONFIG_DRM_PANEL_BRIDGE)
166 struct drm_bridge *bridge;
167 struct device_node *remote;
169 remote = of_graph_get_remote_node(np, port, endpoint);
173 bridge = of_drm_find_bridge(remote);
174 drm_panel_bridge_remove(bridge);
182 static inline int drm_of_encoder_active_endpoint_id(struct device_node *node,
183 struct drm_encoder *encoder)
185 struct of_endpoint endpoint;
186 int ret = drm_of_encoder_active_endpoint(node, encoder,
189 return ret ?: endpoint.id;
192 static inline int drm_of_encoder_active_port_id(struct device_node *node,
193 struct drm_encoder *encoder)
195 struct of_endpoint endpoint;
196 int ret = drm_of_encoder_active_endpoint(node, encoder,
199 return ret ?: endpoint.port;
202 #endif /* __DRM_OF_H__ */