1 /* SPDX-License-Identifier: GPL-2.0 */
5 #include <linux/of_graph.h>
6 #if IS_ENABLED(CONFIG_OF) && IS_ENABLED(CONFIG_DRM_PANEL_BRIDGE)
7 #include <drm/drm_bridge.h>
10 struct component_master_ops
;
11 struct component_match
;
20 * enum drm_lvds_dual_link_pixels - Pixel order of an LVDS dual-link connection
21 * @DRM_LVDS_DUAL_LINK_EVEN_ODD_PIXELS: Even pixels are expected to be generated
22 * from the first port, odd pixels from the second port
23 * @DRM_LVDS_DUAL_LINK_ODD_EVEN_PIXELS: Odd pixels are expected to be generated
24 * from the first port, even pixels from the second port
26 enum drm_lvds_dual_link_pixels
{
27 DRM_LVDS_DUAL_LINK_EVEN_ODD_PIXELS
= 0,
28 DRM_LVDS_DUAL_LINK_ODD_EVEN_PIXELS
= 1,
32 uint32_t drm_of_crtc_port_mask(struct drm_device
*dev
,
33 struct device_node
*port
);
34 uint32_t drm_of_find_possible_crtcs(struct drm_device
*dev
,
35 struct device_node
*port
);
36 void drm_of_component_match_add(struct device
*master
,
37 struct component_match
**matchptr
,
38 int (*compare
)(struct device
*, void *),
39 struct device_node
*node
);
40 int drm_of_component_probe(struct device
*dev
,
41 int (*compare_of
)(struct device
*, void *),
42 const struct component_master_ops
*m_ops
);
43 int drm_of_encoder_active_endpoint(struct device_node
*node
,
44 struct drm_encoder
*encoder
,
45 struct of_endpoint
*endpoint
);
46 int drm_of_find_panel_or_bridge(const struct device_node
*np
,
47 int port
, int endpoint
,
48 struct drm_panel
**panel
,
49 struct drm_bridge
**bridge
);
50 int drm_of_lvds_get_dual_link_pixel_order(const struct device_node
*port1
,
51 const struct device_node
*port2
);
53 static inline uint32_t drm_of_crtc_port_mask(struct drm_device
*dev
,
54 struct device_node
*port
)
59 static inline uint32_t drm_of_find_possible_crtcs(struct drm_device
*dev
,
60 struct device_node
*port
)
66 drm_of_component_match_add(struct device
*master
,
67 struct component_match
**matchptr
,
68 int (*compare
)(struct device
*, void *),
69 struct device_node
*node
)
74 drm_of_component_probe(struct device
*dev
,
75 int (*compare_of
)(struct device
*, void *),
76 const struct component_master_ops
*m_ops
)
81 static inline int drm_of_encoder_active_endpoint(struct device_node
*node
,
82 struct drm_encoder
*encoder
,
83 struct of_endpoint
*endpoint
)
87 static inline int drm_of_find_panel_or_bridge(const struct device_node
*np
,
88 int port
, int endpoint
,
89 struct drm_panel
**panel
,
90 struct drm_bridge
**bridge
)
96 drm_of_lvds_get_dual_link_pixel_order(const struct device_node
*port1
,
97 const struct device_node
*port2
)
104 * drm_of_panel_bridge_remove - remove panel bridge
105 * @np: device tree node containing panel bridge output ports
107 * Remove the panel bridge of a given DT node's port and endpoint number
109 * Returns zero if successful, or one of the standard error codes if it fails.
111 static inline int drm_of_panel_bridge_remove(const struct device_node
*np
,
112 int port
, int endpoint
)
114 #if IS_ENABLED(CONFIG_OF) && IS_ENABLED(CONFIG_DRM_PANEL_BRIDGE)
115 struct drm_bridge
*bridge
;
116 struct device_node
*remote
;
118 remote
= of_graph_get_remote_node(np
, port
, endpoint
);
122 bridge
= of_drm_find_bridge(remote
);
123 drm_panel_bridge_remove(bridge
);
131 static inline int drm_of_encoder_active_endpoint_id(struct device_node
*node
,
132 struct drm_encoder
*encoder
)
134 struct of_endpoint endpoint
;
135 int ret
= drm_of_encoder_active_endpoint(node
, encoder
,
138 return ret
?: endpoint
.id
;
141 static inline int drm_of_encoder_active_port_id(struct device_node
*node
,
142 struct drm_encoder
*encoder
)
144 struct of_endpoint endpoint
;
145 int ret
= drm_of_encoder_active_endpoint(node
, encoder
,
148 return ret
?: endpoint
.port
;
151 #endif /* __DRM_OF_H__ */