forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-13 9d77db3c730780c8ef5ccd4b66403ff5675cfe4e
kernel/drivers/gpu/drm/drm_of.c
....@@ -1,13 +1,15 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 #include <linux/component.h>
23 #include <linux/export.h>
34 #include <linux/list.h>
45 #include <linux/of_graph.h>
5
-#include <drm/drmP.h>
6
+
67 #include <drm/drm_bridge.h>
78 #include <drm/drm_crtc.h>
9
+#include <drm/drm_device.h>
810 #include <drm/drm_encoder.h>
9
-#include <drm/drm_panel.h>
1011 #include <drm/drm_of.h>
12
+#include <drm/drm_panel.h>
1113
1214 /**
1315 * DOC: overview
....@@ -64,11 +66,6 @@
6466 uint32_t possible_crtcs = 0;
6567
6668 for_each_endpoint_of_node(port, ep) {
67
- if (!of_device_is_available(ep)) {
68
- of_node_put(ep);
69
- continue;
70
- }
71
-
7269 remote_port = of_graph_get_remote_port(ep);
7370 if (!remote_port) {
7471 of_node_put(ep);
....@@ -222,9 +219,11 @@
222219 }
223220 EXPORT_SYMBOL_GPL(drm_of_encoder_active_endpoint);
224221
225
-/*
222
+/**
226223 * drm_of_find_panel_or_bridge - return connected panel or bridge device
227224 * @np: device tree node containing encoder output ports
225
+ * @port: port in the device tree node
226
+ * @endpoint: endpoint in the device tree node
228227 * @panel: pointer to hold returned drm_panel
229228 * @bridge: pointer to hold returned drm_bridge
230229 *
....@@ -247,14 +246,18 @@
247246 if (panel)
248247 *panel = NULL;
249248
249
+ /*
250
+ * of_graph_get_remote_node() produces a noisy error message if port
251
+ * node isn't found and the absence of the port is a legit case here,
252
+ * so at first we silently check whether graph presents in the
253
+ * device-tree node.
254
+ */
255
+ if (!of_graph_is_present(np))
256
+ return -ENODEV;
257
+
250258 remote = of_graph_get_remote_node(np, port, endpoint);
251259 if (!remote)
252260 return -ENODEV;
253
-
254
- if (!of_device_is_available(remote)) {
255
- of_node_put(remote);
256
- return -ENODEV;
257
- }
258261
259262 if (panel) {
260263 *panel = of_drm_find_panel(remote);
....@@ -284,8 +287,6 @@
284287 enum drm_of_lvds_pixels {
285288 DRM_OF_LVDS_EVEN = BIT(0),
286289 DRM_OF_LVDS_ODD = BIT(1),
287
- DRM_OF_LVDS_LEFT = BIT(2),
288
- DRM_OF_LVDS_RIGHT = BIT(3),
289290 };
290291
291292 static int drm_of_lvds_get_port_pixels_type(struct device_node *port_node)
....@@ -294,15 +295,9 @@
294295 of_property_read_bool(port_node, "dual-lvds-even-pixels");
295296 bool odd_pixels =
296297 of_property_read_bool(port_node, "dual-lvds-odd-pixels");
297
- bool left_pixels =
298
- of_property_read_bool(port_node, "dual-lvds-left-pixels");
299
- bool right_pixels =
300
- of_property_read_bool(port_node, "dual-lvds-right-pixels");
301298
302299 return (even_pixels ? DRM_OF_LVDS_EVEN : 0) |
303
- (odd_pixels ? DRM_OF_LVDS_ODD : 0) |
304
- (left_pixels ? DRM_OF_LVDS_LEFT : 0) |
305
- (right_pixels ? DRM_OF_LVDS_RIGHT : 0);
300
+ (odd_pixels ? DRM_OF_LVDS_ODD : 0);
306301 }
307302
308303 static int drm_of_lvds_get_remote_pixels_type(
....@@ -320,7 +315,7 @@
320315
321316 remote_port = of_graph_get_remote_port(endpoint);
322317 if (!remote_port) {
323
- of_node_put(remote_port);
318
+ of_node_put(endpoint);
324319 return -EPIPE;
325320 }
326321
....@@ -336,8 +331,10 @@
336331 * configurations by passing the endpoints explicitly to
337332 * drm_of_lvds_get_dual_link_pixel_order().
338333 */
339
- if (!current_pt || pixels_type != current_pt)
334
+ if (!current_pt || pixels_type != current_pt) {
335
+ of_node_put(endpoint);
340336 return -EINVAL;
337
+ }
341338 }
342339
343340 return pixels_type;
....@@ -348,15 +345,13 @@
348345 * @port1: First DT port node of the Dual-link LVDS source
349346 * @port2: Second DT port node of the Dual-link LVDS source
350347 *
351
- * An LVDS dual-link connection is made of two links, the two link can transmit
352
- * odd pixels and even pixels independently, or the two link can also transmit
353
- * left pixels and right pixels independently. This function returns for two
354
- * ports of an LVDS dual-link source, based on the requirements of the connected
355
- * sink.
348
+ * An LVDS dual-link connection is made of two links, with even pixels
349
+ * transitting on one link, and odd pixels on the other link. This function
350
+ * returns, for two ports of an LVDS dual-link source, which port shall transmit
351
+ * the even and odd pixels, based on the requirements of the connected sink.
356352 *
357
- * The pixel order is determined from the dual-lvds-even-pixels +
358
- * dual-lvds-odd-pixels or dual-lvds-left-pixels + dual-lvds-right-pixels
359
- * properties in the sink's DT port nodes. If those
353
+ * The pixel order is determined from the dual-lvds-even-pixels and
354
+ * dual-lvds-odd-pixels properties in the sink's DT port nodes. If those
360355 * properties are not present, or if their usage is not valid, this function
361356 * returns -EINVAL.
362357 *
....@@ -371,11 +366,6 @@
371366 * carries odd pixels
372367 * * DRM_LVDS_DUAL_LINK_ODD_EVEN_PIXELS - @port1 carries odd pixels and @port2
373368 * carries even pixels
374
- * * DRM_LVDS_DUAL_LINK_LEFT_RIGHT_PIXELS - @port1 carries left pixels and
375
- * @port2 carries right pixels
376
- * * DRM_LVDS_DUAL_LINK_RIGHT_LEFT_PIXELS - @port1 carries right pixels and
377
- * @port2 carries left pixels
378
-
379369 * * -EINVAL - @port1 and @port2 are not connected to a dual-link LVDS sink, or
380370 * the sink configuration is invalid
381371 * * -EPIPE - when @port1 or @port2 are not connected
....@@ -398,21 +388,14 @@
398388
399389 /*
400390 * A valid dual-lVDS bus is found when one remote port is marked with
401
- * "dual-lvds-even-pixels" or "dual-lvds-left-pixels", and the other
402
- * remote port is marked with "dual-lvds-odd-pixels"or
403
- * "dual-lvds-right-pixels", bail out if the markers are not right.
391
+ * "dual-lvds-even-pixels", and the other remote port is marked with
392
+ * "dual-lvds-odd-pixels", bail out if the markers are not right.
404393 */
405
- if ((remote_p1_pt + remote_p2_pt != DRM_OF_LVDS_EVEN + DRM_OF_LVDS_ODD) &&
406
- (remote_p1_pt + remote_p2_pt != DRM_OF_LVDS_LEFT + DRM_OF_LVDS_RIGHT))
394
+ if (remote_p1_pt + remote_p2_pt != DRM_OF_LVDS_EVEN + DRM_OF_LVDS_ODD)
407395 return -EINVAL;
408396
409
- if (remote_p1_pt == DRM_OF_LVDS_EVEN)
410
- return DRM_LVDS_DUAL_LINK_EVEN_ODD_PIXELS;
411
- else if (remote_p1_pt == DRM_OF_LVDS_ODD)
412
- return DRM_LVDS_DUAL_LINK_ODD_EVEN_PIXELS;
413
- else if (remote_p1_pt == DRM_OF_LVDS_LEFT)
414
- return DRM_LVDS_DUAL_LINK_LEFT_RIGHT_PIXELS;
415
- else
416
- return DRM_LVDS_DUAL_LINK_RIGHT_LEFT_PIXELS;
397
+ return remote_p1_pt == DRM_OF_LVDS_EVEN ?
398
+ DRM_LVDS_DUAL_LINK_EVEN_ODD_PIXELS :
399
+ DRM_LVDS_DUAL_LINK_ODD_EVEN_PIXELS;
417400 }
418401 EXPORT_SYMBOL_GPL(drm_of_lvds_get_dual_link_pixel_order);