XenevaOS
Loading...
Searching...
No Matches
drm_of.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: GPL-2.0 */
2#ifndef __DRM_OF_H__
3#define __DRM_OF_H__
4
5#include <linux/err.h>
6#include <linux/of_graph.h>
7#if IS_ENABLED(CONFIG_OF) && IS_ENABLED(CONFIG_DRM_PANEL_BRIDGE)
8#include <linux/of.h>
9#include <drm/drm_bridge.h>
10#endif
11
12struct component_master_ops;
13struct component_match;
14struct device;
15struct drm_device;
16struct drm_encoder;
17struct drm_panel;
18struct drm_bridge;
19struct device_node;
21struct mipi_dsi_host;
22
34
35#ifdef CONFIG_OF
36uint32_t drm_of_crtc_port_mask(struct drm_device *dev,
37 struct device_node *port);
38uint32_t drm_of_find_possible_crtcs(struct drm_device *dev,
39 struct device_node *port);
40void drm_of_component_match_add(struct device *master,
41 struct component_match **matchptr,
42 int (*compare)(struct device *, void *),
43 struct device_node *node);
44int drm_of_component_probe(struct device *dev,
45 int (*compare_of)(struct device *, void *),
46 const struct component_master_ops *m_ops);
47int drm_of_encoder_active_endpoint(struct device_node *node,
48 struct drm_encoder *encoder,
49 struct of_endpoint *endpoint);
50int drm_of_find_panel_or_bridge(const struct device_node *np,
51 int port, int endpoint,
52 struct drm_panel **panel,
53 struct drm_bridge **bridge);
54int drm_of_lvds_get_dual_link_pixel_order(const struct device_node *port1,
55 const struct device_node *port2);
56int drm_of_lvds_get_dual_link_pixel_order_sink(struct device_node *port1,
57 struct device_node *port2);
58int drm_of_lvds_get_data_mapping(const struct device_node *port);
59int drm_of_get_data_lanes_count(const struct device_node *endpoint,
60 const unsigned int min, const unsigned int max);
61int drm_of_get_data_lanes_count_ep(const struct device_node *port,
62 int port_reg, int reg,
63 const unsigned int min,
64 const unsigned int max);
65int drm_of_get_data_lanes_count_remote(const struct device_node *port,
66 int port_reg, int reg,
67 const unsigned int min,
68 const unsigned int max);
69#else
70static inline uint32_t drm_of_crtc_port_mask(struct drm_device *dev,
71 struct device_node *port)
72{
73 return 0;
74}
75
76static inline uint32_t drm_of_find_possible_crtcs(struct drm_device *dev,
77 struct device_node *port)
78{
79 return 0;
80}
81
82static inline void
83drm_of_component_match_add(struct device *master,
84 struct component_match **matchptr,
85 int (*compare)(struct device *, void *),
86 struct device_node *node)
87{
88}
89
90static inline int
91drm_of_component_probe(struct device *dev,
92 int (*compare_of)(struct device *, void *),
93 const struct component_master_ops *m_ops)
94{
95 return -EINVAL;
96}
97
98static inline int drm_of_encoder_active_endpoint(struct device_node *node,
99 struct drm_encoder *encoder,
100 struct of_endpoint *endpoint)
101{
102 return -EINVAL;
103}
104static inline int drm_of_find_panel_or_bridge(const struct device_node *np,
105 int port, int endpoint,
106 struct drm_panel **panel,
107 struct drm_bridge **bridge)
108{
109 return -EINVAL;
110}
111
112static inline int
113drm_of_lvds_get_dual_link_pixel_order(const struct device_node *port1,
114 const struct device_node *port2)
115{
116 return -EINVAL;
117}
118
119static inline int
120drm_of_lvds_get_dual_link_pixel_order_sink(struct device_node *port1,
121 struct device_node *port2)
122{
123 return -EINVAL;
124}
125
126static inline int
127drm_of_lvds_get_data_mapping(const struct device_node *port)
128{
129 return -EINVAL;
130}
131
132static inline int
133drm_of_get_data_lanes_count(const struct device_node *endpoint,
134 const unsigned int min, const unsigned int max)
135{
136 return -EINVAL;
137}
138
139static inline int
140drm_of_get_data_lanes_count_ep(const struct device_node *port,
141 int port_reg, int reg,
142 const unsigned int min,
143 const unsigned int max)
144{
145 return -EINVAL;
146}
147
148static inline int
149drm_of_get_data_lanes_count_remote(const struct device_node *port,
150 int port_reg, int reg,
151 const unsigned int min,
152 const unsigned int max)
153{
154 return -EINVAL;
155}
156#endif
157
158#if IS_ENABLED(CONFIG_OF) && IS_ENABLED(CONFIG_DRM_MIPI_DSI)
159struct mipi_dsi_host *drm_of_get_dsi_bus(struct device *dev);
160#else
161static inline struct
162mipi_dsi_host *drm_of_get_dsi_bus(struct device *dev)
163{
164 return ERR_PTR(-EINVAL);
165}
166#endif /* CONFIG_OF && CONFIG_DRM_MIPI_DSI */
167
168/*
169 * drm_of_panel_bridge_remove - remove panel bridge
170 * @np: device tree node containing panel bridge output ports
171 *
172 * Remove the panel bridge of a given DT node's port and endpoint number
173 *
174 * Returns zero if successful, or one of the standard error codes if it fails.
175 */
176static inline int drm_of_panel_bridge_remove(const struct device_node *np,
177 int port, int endpoint)
178{
179#if IS_ENABLED(CONFIG_OF) && IS_ENABLED(CONFIG_DRM_PANEL_BRIDGE)
180 struct drm_bridge *bridge;
181 struct device_node *remote;
182
183 remote = of_graph_get_remote_node(np, port, endpoint);
184 if (!remote)
185 return -ENODEV;
186
187 bridge = of_drm_find_and_get_bridge(remote);
188 drm_panel_bridge_remove(bridge);
189
190 drm_bridge_put(bridge);
191 of_node_put(remote);
192
193 return 0;
194#else
195 return -EINVAL;
196#endif
197}
198
199static inline int drm_of_encoder_active_endpoint_id(struct device_node *node,
200 struct drm_encoder *encoder)
201{
202 struct of_endpoint endpoint;
203 int ret = drm_of_encoder_active_endpoint(node, encoder,
204 &endpoint);
205
206 return ret ?: endpoint.id;
207}
208
209static inline int drm_of_encoder_active_port_id(struct device_node *node,
210 struct drm_encoder *encoder)
211{
212 struct of_endpoint endpoint;
213 int ret = drm_of_encoder_active_endpoint(node, encoder,
214 &endpoint);
215
216 return ret ?: endpoint.port;
217}
218
219#endif /* __DRM_OF_H__ */
void * endpoint
Definition main.cpp:149
#define EINVAL
Definition acclib.h:198
#define ENODEV
Definition acclib.h:197
unsigned int uint32_t
Definition acefiex.h:163
void drm_bridge_put(struct drm_bridge *bridge)
struct drm_encoder * encoder
Definition drm_encoder.h:211
drm_lvds_dual_link_pixels
Definition drm_of.h:30
@ DRM_LVDS_DUAL_LINK_EVEN_ODD_PIXELS
Definition drm_of.h:31
@ DRM_LVDS_DUAL_LINK_ODD_EVEN_PIXELS
Definition drm_of.h:32
const struct device * dev
Definition drm_print.h:519
#define ERR_PTR(err)
Definition err.h:51
struct i915_engine_class_instance master
Definition i915_drm.h:2
void int node
Definition kthread.h:31
#define min(a, b)
Definition minmax.h:24
#define max(a, b)
Definition minmax.h:28
int compare(const void *a, const void *b)
Definition search.cpp:85
Definition fs.h:255
Definition drm_bridge.h:1100
Definition drm_device.h:75
Definition drm_encoder.h:106
Definition drm_panel.h:205
Definition drm_mipi_dsi.h:161
Definition drm_mipi_dsi.h:105
Definition of_graph.h:32