1*4882a593Smuzhiyun // SPDX-License-Identifier: GPL-2.0-only
2*4882a593Smuzhiyun #include <linux/component.h>
3*4882a593Smuzhiyun #include <linux/export.h>
4*4882a593Smuzhiyun #include <linux/list.h>
5*4882a593Smuzhiyun #include <linux/of_graph.h>
6*4882a593Smuzhiyun
7*4882a593Smuzhiyun #include <drm/drm_bridge.h>
8*4882a593Smuzhiyun #include <drm/drm_crtc.h>
9*4882a593Smuzhiyun #include <drm/drm_device.h>
10*4882a593Smuzhiyun #include <drm/drm_encoder.h>
11*4882a593Smuzhiyun #include <drm/drm_of.h>
12*4882a593Smuzhiyun #include <drm/drm_panel.h>
13*4882a593Smuzhiyun
14*4882a593Smuzhiyun /**
15*4882a593Smuzhiyun * DOC: overview
16*4882a593Smuzhiyun *
17*4882a593Smuzhiyun * A set of helper functions to aid DRM drivers in parsing standard DT
18*4882a593Smuzhiyun * properties.
19*4882a593Smuzhiyun */
20*4882a593Smuzhiyun
drm_release_of(struct device * dev,void * data)21*4882a593Smuzhiyun static void drm_release_of(struct device *dev, void *data)
22*4882a593Smuzhiyun {
23*4882a593Smuzhiyun of_node_put(data);
24*4882a593Smuzhiyun }
25*4882a593Smuzhiyun
26*4882a593Smuzhiyun /**
27*4882a593Smuzhiyun * drm_of_crtc_port_mask - find the mask of a registered CRTC by port OF node
28*4882a593Smuzhiyun * @dev: DRM device
29*4882a593Smuzhiyun * @port: port OF node
30*4882a593Smuzhiyun *
31*4882a593Smuzhiyun * Given a port OF node, return the possible mask of the corresponding
32*4882a593Smuzhiyun * CRTC within a device's list of CRTCs. Returns zero if not found.
33*4882a593Smuzhiyun */
drm_of_crtc_port_mask(struct drm_device * dev,struct device_node * port)34*4882a593Smuzhiyun uint32_t drm_of_crtc_port_mask(struct drm_device *dev,
35*4882a593Smuzhiyun struct device_node *port)
36*4882a593Smuzhiyun {
37*4882a593Smuzhiyun unsigned int index = 0;
38*4882a593Smuzhiyun struct drm_crtc *tmp;
39*4882a593Smuzhiyun
40*4882a593Smuzhiyun drm_for_each_crtc(tmp, dev) {
41*4882a593Smuzhiyun if (tmp->port == port)
42*4882a593Smuzhiyun return 1 << index;
43*4882a593Smuzhiyun
44*4882a593Smuzhiyun index++;
45*4882a593Smuzhiyun }
46*4882a593Smuzhiyun
47*4882a593Smuzhiyun return 0;
48*4882a593Smuzhiyun }
49*4882a593Smuzhiyun EXPORT_SYMBOL(drm_of_crtc_port_mask);
50*4882a593Smuzhiyun
51*4882a593Smuzhiyun /**
52*4882a593Smuzhiyun * drm_of_find_possible_crtcs - find the possible CRTCs for an encoder port
53*4882a593Smuzhiyun * @dev: DRM device
54*4882a593Smuzhiyun * @port: encoder port to scan for endpoints
55*4882a593Smuzhiyun *
56*4882a593Smuzhiyun * Scan all endpoints attached to a port, locate their attached CRTCs,
57*4882a593Smuzhiyun * and generate the DRM mask of CRTCs which may be attached to this
58*4882a593Smuzhiyun * encoder.
59*4882a593Smuzhiyun *
60*4882a593Smuzhiyun * See Documentation/devicetree/bindings/graph.txt for the bindings.
61*4882a593Smuzhiyun */
drm_of_find_possible_crtcs(struct drm_device * dev,struct device_node * port)62*4882a593Smuzhiyun uint32_t drm_of_find_possible_crtcs(struct drm_device *dev,
63*4882a593Smuzhiyun struct device_node *port)
64*4882a593Smuzhiyun {
65*4882a593Smuzhiyun struct device_node *remote_port, *ep;
66*4882a593Smuzhiyun uint32_t possible_crtcs = 0;
67*4882a593Smuzhiyun
68*4882a593Smuzhiyun for_each_endpoint_of_node(port, ep) {
69*4882a593Smuzhiyun remote_port = of_graph_get_remote_port(ep);
70*4882a593Smuzhiyun if (!remote_port) {
71*4882a593Smuzhiyun of_node_put(ep);
72*4882a593Smuzhiyun return 0;
73*4882a593Smuzhiyun }
74*4882a593Smuzhiyun
75*4882a593Smuzhiyun possible_crtcs |= drm_of_crtc_port_mask(dev, remote_port);
76*4882a593Smuzhiyun
77*4882a593Smuzhiyun of_node_put(remote_port);
78*4882a593Smuzhiyun }
79*4882a593Smuzhiyun
80*4882a593Smuzhiyun return possible_crtcs;
81*4882a593Smuzhiyun }
82*4882a593Smuzhiyun EXPORT_SYMBOL(drm_of_find_possible_crtcs);
83*4882a593Smuzhiyun
84*4882a593Smuzhiyun /**
85*4882a593Smuzhiyun * drm_of_component_match_add - Add a component helper OF node match rule
86*4882a593Smuzhiyun * @master: master device
87*4882a593Smuzhiyun * @matchptr: component match pointer
88*4882a593Smuzhiyun * @compare: compare function used for matching component
89*4882a593Smuzhiyun * @node: of_node
90*4882a593Smuzhiyun */
drm_of_component_match_add(struct device * master,struct component_match ** matchptr,int (* compare)(struct device *,void *),struct device_node * node)91*4882a593Smuzhiyun void drm_of_component_match_add(struct device *master,
92*4882a593Smuzhiyun struct component_match **matchptr,
93*4882a593Smuzhiyun int (*compare)(struct device *, void *),
94*4882a593Smuzhiyun struct device_node *node)
95*4882a593Smuzhiyun {
96*4882a593Smuzhiyun of_node_get(node);
97*4882a593Smuzhiyun component_match_add_release(master, matchptr, drm_release_of,
98*4882a593Smuzhiyun compare, node);
99*4882a593Smuzhiyun }
100*4882a593Smuzhiyun EXPORT_SYMBOL_GPL(drm_of_component_match_add);
101*4882a593Smuzhiyun
102*4882a593Smuzhiyun /**
103*4882a593Smuzhiyun * drm_of_component_probe - Generic probe function for a component based master
104*4882a593Smuzhiyun * @dev: master device containing the OF node
105*4882a593Smuzhiyun * @compare_of: compare function used for matching components
106*4882a593Smuzhiyun * @m_ops: component master ops to be used
107*4882a593Smuzhiyun *
108*4882a593Smuzhiyun * Parse the platform device OF node and bind all the components associated
109*4882a593Smuzhiyun * with the master. Interface ports are added before the encoders in order to
110*4882a593Smuzhiyun * satisfy their .bind requirements
111*4882a593Smuzhiyun * See Documentation/devicetree/bindings/graph.txt for the bindings.
112*4882a593Smuzhiyun *
113*4882a593Smuzhiyun * Returns zero if successful, or one of the standard error codes if it fails.
114*4882a593Smuzhiyun */
drm_of_component_probe(struct device * dev,int (* compare_of)(struct device *,void *),const struct component_master_ops * m_ops)115*4882a593Smuzhiyun int drm_of_component_probe(struct device *dev,
116*4882a593Smuzhiyun int (*compare_of)(struct device *, void *),
117*4882a593Smuzhiyun const struct component_master_ops *m_ops)
118*4882a593Smuzhiyun {
119*4882a593Smuzhiyun struct device_node *ep, *port, *remote;
120*4882a593Smuzhiyun struct component_match *match = NULL;
121*4882a593Smuzhiyun int i;
122*4882a593Smuzhiyun
123*4882a593Smuzhiyun if (!dev->of_node)
124*4882a593Smuzhiyun return -EINVAL;
125*4882a593Smuzhiyun
126*4882a593Smuzhiyun /*
127*4882a593Smuzhiyun * Bind the crtc's ports first, so that drm_of_find_possible_crtcs()
128*4882a593Smuzhiyun * called from encoder's .bind callbacks works as expected
129*4882a593Smuzhiyun */
130*4882a593Smuzhiyun for (i = 0; ; i++) {
131*4882a593Smuzhiyun port = of_parse_phandle(dev->of_node, "ports", i);
132*4882a593Smuzhiyun if (!port)
133*4882a593Smuzhiyun break;
134*4882a593Smuzhiyun
135*4882a593Smuzhiyun if (of_device_is_available(port->parent))
136*4882a593Smuzhiyun drm_of_component_match_add(dev, &match, compare_of,
137*4882a593Smuzhiyun port);
138*4882a593Smuzhiyun
139*4882a593Smuzhiyun of_node_put(port);
140*4882a593Smuzhiyun }
141*4882a593Smuzhiyun
142*4882a593Smuzhiyun if (i == 0) {
143*4882a593Smuzhiyun dev_err(dev, "missing 'ports' property\n");
144*4882a593Smuzhiyun return -ENODEV;
145*4882a593Smuzhiyun }
146*4882a593Smuzhiyun
147*4882a593Smuzhiyun if (!match) {
148*4882a593Smuzhiyun dev_err(dev, "no available port\n");
149*4882a593Smuzhiyun return -ENODEV;
150*4882a593Smuzhiyun }
151*4882a593Smuzhiyun
152*4882a593Smuzhiyun /*
153*4882a593Smuzhiyun * For bound crtcs, bind the encoders attached to their remote endpoint
154*4882a593Smuzhiyun */
155*4882a593Smuzhiyun for (i = 0; ; i++) {
156*4882a593Smuzhiyun port = of_parse_phandle(dev->of_node, "ports", i);
157*4882a593Smuzhiyun if (!port)
158*4882a593Smuzhiyun break;
159*4882a593Smuzhiyun
160*4882a593Smuzhiyun if (!of_device_is_available(port->parent)) {
161*4882a593Smuzhiyun of_node_put(port);
162*4882a593Smuzhiyun continue;
163*4882a593Smuzhiyun }
164*4882a593Smuzhiyun
165*4882a593Smuzhiyun for_each_child_of_node(port, ep) {
166*4882a593Smuzhiyun remote = of_graph_get_remote_port_parent(ep);
167*4882a593Smuzhiyun if (!remote || !of_device_is_available(remote)) {
168*4882a593Smuzhiyun of_node_put(remote);
169*4882a593Smuzhiyun continue;
170*4882a593Smuzhiyun } else if (!of_device_is_available(remote->parent)) {
171*4882a593Smuzhiyun dev_warn(dev, "parent device of %pOF is not available\n",
172*4882a593Smuzhiyun remote);
173*4882a593Smuzhiyun of_node_put(remote);
174*4882a593Smuzhiyun continue;
175*4882a593Smuzhiyun }
176*4882a593Smuzhiyun
177*4882a593Smuzhiyun drm_of_component_match_add(dev, &match, compare_of,
178*4882a593Smuzhiyun remote);
179*4882a593Smuzhiyun of_node_put(remote);
180*4882a593Smuzhiyun }
181*4882a593Smuzhiyun of_node_put(port);
182*4882a593Smuzhiyun }
183*4882a593Smuzhiyun
184*4882a593Smuzhiyun return component_master_add_with_match(dev, m_ops, match);
185*4882a593Smuzhiyun }
186*4882a593Smuzhiyun EXPORT_SYMBOL(drm_of_component_probe);
187*4882a593Smuzhiyun
188*4882a593Smuzhiyun /*
189*4882a593Smuzhiyun * drm_of_encoder_active_endpoint - return the active encoder endpoint
190*4882a593Smuzhiyun * @node: device tree node containing encoder input ports
191*4882a593Smuzhiyun * @encoder: drm_encoder
192*4882a593Smuzhiyun *
193*4882a593Smuzhiyun * Given an encoder device node and a drm_encoder with a connected crtc,
194*4882a593Smuzhiyun * parse the encoder endpoint connecting to the crtc port.
195*4882a593Smuzhiyun */
drm_of_encoder_active_endpoint(struct device_node * node,struct drm_encoder * encoder,struct of_endpoint * endpoint)196*4882a593Smuzhiyun int drm_of_encoder_active_endpoint(struct device_node *node,
197*4882a593Smuzhiyun struct drm_encoder *encoder,
198*4882a593Smuzhiyun struct of_endpoint *endpoint)
199*4882a593Smuzhiyun {
200*4882a593Smuzhiyun struct device_node *ep;
201*4882a593Smuzhiyun struct drm_crtc *crtc = encoder->crtc;
202*4882a593Smuzhiyun struct device_node *port;
203*4882a593Smuzhiyun int ret;
204*4882a593Smuzhiyun
205*4882a593Smuzhiyun if (!node || !crtc)
206*4882a593Smuzhiyun return -EINVAL;
207*4882a593Smuzhiyun
208*4882a593Smuzhiyun for_each_endpoint_of_node(node, ep) {
209*4882a593Smuzhiyun port = of_graph_get_remote_port(ep);
210*4882a593Smuzhiyun of_node_put(port);
211*4882a593Smuzhiyun if (port == crtc->port) {
212*4882a593Smuzhiyun ret = of_graph_parse_endpoint(ep, endpoint);
213*4882a593Smuzhiyun of_node_put(ep);
214*4882a593Smuzhiyun return ret;
215*4882a593Smuzhiyun }
216*4882a593Smuzhiyun }
217*4882a593Smuzhiyun
218*4882a593Smuzhiyun return -EINVAL;
219*4882a593Smuzhiyun }
220*4882a593Smuzhiyun EXPORT_SYMBOL_GPL(drm_of_encoder_active_endpoint);
221*4882a593Smuzhiyun
222*4882a593Smuzhiyun /**
223*4882a593Smuzhiyun * drm_of_find_panel_or_bridge - return connected panel or bridge device
224*4882a593Smuzhiyun * @np: device tree node containing encoder output ports
225*4882a593Smuzhiyun * @port: port in the device tree node
226*4882a593Smuzhiyun * @endpoint: endpoint in the device tree node
227*4882a593Smuzhiyun * @panel: pointer to hold returned drm_panel
228*4882a593Smuzhiyun * @bridge: pointer to hold returned drm_bridge
229*4882a593Smuzhiyun *
230*4882a593Smuzhiyun * Given a DT node's port and endpoint number, find the connected node and
231*4882a593Smuzhiyun * return either the associated struct drm_panel or drm_bridge device. Either
232*4882a593Smuzhiyun * @panel or @bridge must not be NULL.
233*4882a593Smuzhiyun *
234*4882a593Smuzhiyun * Returns zero if successful, or one of the standard error codes if it fails.
235*4882a593Smuzhiyun */
drm_of_find_panel_or_bridge(const struct device_node * np,int port,int endpoint,struct drm_panel ** panel,struct drm_bridge ** bridge)236*4882a593Smuzhiyun int drm_of_find_panel_or_bridge(const struct device_node *np,
237*4882a593Smuzhiyun int port, int endpoint,
238*4882a593Smuzhiyun struct drm_panel **panel,
239*4882a593Smuzhiyun struct drm_bridge **bridge)
240*4882a593Smuzhiyun {
241*4882a593Smuzhiyun int ret = -EPROBE_DEFER;
242*4882a593Smuzhiyun struct device_node *remote;
243*4882a593Smuzhiyun
244*4882a593Smuzhiyun if (!panel && !bridge)
245*4882a593Smuzhiyun return -EINVAL;
246*4882a593Smuzhiyun if (panel)
247*4882a593Smuzhiyun *panel = NULL;
248*4882a593Smuzhiyun
249*4882a593Smuzhiyun /*
250*4882a593Smuzhiyun * of_graph_get_remote_node() produces a noisy error message if port
251*4882a593Smuzhiyun * node isn't found and the absence of the port is a legit case here,
252*4882a593Smuzhiyun * so at first we silently check whether graph presents in the
253*4882a593Smuzhiyun * device-tree node.
254*4882a593Smuzhiyun */
255*4882a593Smuzhiyun if (!of_graph_is_present(np))
256*4882a593Smuzhiyun return -ENODEV;
257*4882a593Smuzhiyun
258*4882a593Smuzhiyun remote = of_graph_get_remote_node(np, port, endpoint);
259*4882a593Smuzhiyun if (!remote)
260*4882a593Smuzhiyun return -ENODEV;
261*4882a593Smuzhiyun
262*4882a593Smuzhiyun if (panel) {
263*4882a593Smuzhiyun *panel = of_drm_find_panel(remote);
264*4882a593Smuzhiyun if (!IS_ERR(*panel))
265*4882a593Smuzhiyun ret = 0;
266*4882a593Smuzhiyun else
267*4882a593Smuzhiyun *panel = NULL;
268*4882a593Smuzhiyun }
269*4882a593Smuzhiyun
270*4882a593Smuzhiyun /* No panel found yet, check for a bridge next. */
271*4882a593Smuzhiyun if (bridge) {
272*4882a593Smuzhiyun if (ret) {
273*4882a593Smuzhiyun *bridge = of_drm_find_bridge(remote);
274*4882a593Smuzhiyun if (*bridge)
275*4882a593Smuzhiyun ret = 0;
276*4882a593Smuzhiyun } else {
277*4882a593Smuzhiyun *bridge = NULL;
278*4882a593Smuzhiyun }
279*4882a593Smuzhiyun
280*4882a593Smuzhiyun }
281*4882a593Smuzhiyun
282*4882a593Smuzhiyun of_node_put(remote);
283*4882a593Smuzhiyun return ret;
284*4882a593Smuzhiyun }
285*4882a593Smuzhiyun EXPORT_SYMBOL_GPL(drm_of_find_panel_or_bridge);
286*4882a593Smuzhiyun
287*4882a593Smuzhiyun enum drm_of_lvds_pixels {
288*4882a593Smuzhiyun DRM_OF_LVDS_EVEN = BIT(0),
289*4882a593Smuzhiyun DRM_OF_LVDS_ODD = BIT(1),
290*4882a593Smuzhiyun };
291*4882a593Smuzhiyun
drm_of_lvds_get_port_pixels_type(struct device_node * port_node)292*4882a593Smuzhiyun static int drm_of_lvds_get_port_pixels_type(struct device_node *port_node)
293*4882a593Smuzhiyun {
294*4882a593Smuzhiyun bool even_pixels =
295*4882a593Smuzhiyun of_property_read_bool(port_node, "dual-lvds-even-pixels");
296*4882a593Smuzhiyun bool odd_pixels =
297*4882a593Smuzhiyun of_property_read_bool(port_node, "dual-lvds-odd-pixels");
298*4882a593Smuzhiyun
299*4882a593Smuzhiyun return (even_pixels ? DRM_OF_LVDS_EVEN : 0) |
300*4882a593Smuzhiyun (odd_pixels ? DRM_OF_LVDS_ODD : 0);
301*4882a593Smuzhiyun }
302*4882a593Smuzhiyun
drm_of_lvds_get_remote_pixels_type(const struct device_node * port_node)303*4882a593Smuzhiyun static int drm_of_lvds_get_remote_pixels_type(
304*4882a593Smuzhiyun const struct device_node *port_node)
305*4882a593Smuzhiyun {
306*4882a593Smuzhiyun struct device_node *endpoint = NULL;
307*4882a593Smuzhiyun int pixels_type = -EPIPE;
308*4882a593Smuzhiyun
309*4882a593Smuzhiyun for_each_child_of_node(port_node, endpoint) {
310*4882a593Smuzhiyun struct device_node *remote_port;
311*4882a593Smuzhiyun int current_pt;
312*4882a593Smuzhiyun
313*4882a593Smuzhiyun if (!of_node_name_eq(endpoint, "endpoint"))
314*4882a593Smuzhiyun continue;
315*4882a593Smuzhiyun
316*4882a593Smuzhiyun remote_port = of_graph_get_remote_port(endpoint);
317*4882a593Smuzhiyun if (!remote_port) {
318*4882a593Smuzhiyun of_node_put(endpoint);
319*4882a593Smuzhiyun return -EPIPE;
320*4882a593Smuzhiyun }
321*4882a593Smuzhiyun
322*4882a593Smuzhiyun current_pt = drm_of_lvds_get_port_pixels_type(remote_port);
323*4882a593Smuzhiyun of_node_put(remote_port);
324*4882a593Smuzhiyun if (pixels_type < 0)
325*4882a593Smuzhiyun pixels_type = current_pt;
326*4882a593Smuzhiyun
327*4882a593Smuzhiyun /*
328*4882a593Smuzhiyun * Sanity check, ensure that all remote endpoints have the same
329*4882a593Smuzhiyun * pixel type. We may lift this restriction later if we need to
330*4882a593Smuzhiyun * support multiple sinks with different dual-link
331*4882a593Smuzhiyun * configurations by passing the endpoints explicitly to
332*4882a593Smuzhiyun * drm_of_lvds_get_dual_link_pixel_order().
333*4882a593Smuzhiyun */
334*4882a593Smuzhiyun if (!current_pt || pixels_type != current_pt) {
335*4882a593Smuzhiyun of_node_put(endpoint);
336*4882a593Smuzhiyun return -EINVAL;
337*4882a593Smuzhiyun }
338*4882a593Smuzhiyun }
339*4882a593Smuzhiyun
340*4882a593Smuzhiyun return pixels_type;
341*4882a593Smuzhiyun }
342*4882a593Smuzhiyun
343*4882a593Smuzhiyun /**
344*4882a593Smuzhiyun * drm_of_lvds_get_dual_link_pixel_order - Get LVDS dual-link pixel order
345*4882a593Smuzhiyun * @port1: First DT port node of the Dual-link LVDS source
346*4882a593Smuzhiyun * @port2: Second DT port node of the Dual-link LVDS source
347*4882a593Smuzhiyun *
348*4882a593Smuzhiyun * An LVDS dual-link connection is made of two links, with even pixels
349*4882a593Smuzhiyun * transitting on one link, and odd pixels on the other link. This function
350*4882a593Smuzhiyun * returns, for two ports of an LVDS dual-link source, which port shall transmit
351*4882a593Smuzhiyun * the even and odd pixels, based on the requirements of the connected sink.
352*4882a593Smuzhiyun *
353*4882a593Smuzhiyun * The pixel order is determined from the dual-lvds-even-pixels and
354*4882a593Smuzhiyun * dual-lvds-odd-pixels properties in the sink's DT port nodes. If those
355*4882a593Smuzhiyun * properties are not present, or if their usage is not valid, this function
356*4882a593Smuzhiyun * returns -EINVAL.
357*4882a593Smuzhiyun *
358*4882a593Smuzhiyun * If either port is not connected, this function returns -EPIPE.
359*4882a593Smuzhiyun *
360*4882a593Smuzhiyun * @port1 and @port2 are typically DT sibling nodes, but may have different
361*4882a593Smuzhiyun * parents when, for instance, two separate LVDS encoders carry the even and odd
362*4882a593Smuzhiyun * pixels.
363*4882a593Smuzhiyun *
364*4882a593Smuzhiyun * Return:
365*4882a593Smuzhiyun * * DRM_LVDS_DUAL_LINK_EVEN_ODD_PIXELS - @port1 carries even pixels and @port2
366*4882a593Smuzhiyun * carries odd pixels
367*4882a593Smuzhiyun * * DRM_LVDS_DUAL_LINK_ODD_EVEN_PIXELS - @port1 carries odd pixels and @port2
368*4882a593Smuzhiyun * carries even pixels
369*4882a593Smuzhiyun * * -EINVAL - @port1 and @port2 are not connected to a dual-link LVDS sink, or
370*4882a593Smuzhiyun * the sink configuration is invalid
371*4882a593Smuzhiyun * * -EPIPE - when @port1 or @port2 are not connected
372*4882a593Smuzhiyun */
drm_of_lvds_get_dual_link_pixel_order(const struct device_node * port1,const struct device_node * port2)373*4882a593Smuzhiyun int drm_of_lvds_get_dual_link_pixel_order(const struct device_node *port1,
374*4882a593Smuzhiyun const struct device_node *port2)
375*4882a593Smuzhiyun {
376*4882a593Smuzhiyun int remote_p1_pt, remote_p2_pt;
377*4882a593Smuzhiyun
378*4882a593Smuzhiyun if (!port1 || !port2)
379*4882a593Smuzhiyun return -EINVAL;
380*4882a593Smuzhiyun
381*4882a593Smuzhiyun remote_p1_pt = drm_of_lvds_get_remote_pixels_type(port1);
382*4882a593Smuzhiyun if (remote_p1_pt < 0)
383*4882a593Smuzhiyun return remote_p1_pt;
384*4882a593Smuzhiyun
385*4882a593Smuzhiyun remote_p2_pt = drm_of_lvds_get_remote_pixels_type(port2);
386*4882a593Smuzhiyun if (remote_p2_pt < 0)
387*4882a593Smuzhiyun return remote_p2_pt;
388*4882a593Smuzhiyun
389*4882a593Smuzhiyun /*
390*4882a593Smuzhiyun * A valid dual-lVDS bus is found when one remote port is marked with
391*4882a593Smuzhiyun * "dual-lvds-even-pixels", and the other remote port is marked with
392*4882a593Smuzhiyun * "dual-lvds-odd-pixels", bail out if the markers are not right.
393*4882a593Smuzhiyun */
394*4882a593Smuzhiyun if (remote_p1_pt + remote_p2_pt != DRM_OF_LVDS_EVEN + DRM_OF_LVDS_ODD)
395*4882a593Smuzhiyun return -EINVAL;
396*4882a593Smuzhiyun
397*4882a593Smuzhiyun return remote_p1_pt == DRM_OF_LVDS_EVEN ?
398*4882a593Smuzhiyun DRM_LVDS_DUAL_LINK_EVEN_ODD_PIXELS :
399*4882a593Smuzhiyun DRM_LVDS_DUAL_LINK_ODD_EVEN_PIXELS;
400*4882a593Smuzhiyun }
401*4882a593Smuzhiyun EXPORT_SYMBOL_GPL(drm_of_lvds_get_dual_link_pixel_order);
402