Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm: of: Add drm_of_lvds_get_dual_link_pixel_order_sink()

drm_of_lvds_get_dual_link_pixel_order() gets LVDS dual-link source pixel
order. Similar to it, add it's counterpart function
drm_of_lvds_get_dual_link_pixel_order_sink() to get LVDS dual-link sink
pixel order.

Suggested-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Signed-off-by: Liu Ying <victor.liu@nxp.com>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20241104032806.611890-7-victor.liu@nxp.com
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>

authored by

Liu Ying and committed by
Dmitry Baryshkov
60641029 34902c2d

+75 -12
+66 -12
drivers/gpu/drm/drm_of.c
··· 341 341 return pixels_type; 342 342 } 343 343 344 + static int __drm_of_lvds_get_dual_link_pixel_order(int p1_pt, int p2_pt) 345 + { 346 + /* 347 + * A valid dual-lVDS bus is found when one port is marked with 348 + * "dual-lvds-even-pixels", and the other port is marked with 349 + * "dual-lvds-odd-pixels", bail out if the markers are not right. 350 + */ 351 + if (p1_pt + p2_pt != DRM_OF_LVDS_EVEN + DRM_OF_LVDS_ODD) 352 + return -EINVAL; 353 + 354 + return p1_pt == DRM_OF_LVDS_EVEN ? 355 + DRM_LVDS_DUAL_LINK_EVEN_ODD_PIXELS : 356 + DRM_LVDS_DUAL_LINK_ODD_EVEN_PIXELS; 357 + } 358 + 344 359 /** 345 - * drm_of_lvds_get_dual_link_pixel_order - Get LVDS dual-link pixel order 360 + * drm_of_lvds_get_dual_link_pixel_order - Get LVDS dual-link source pixel order 346 361 * @port1: First DT port node of the Dual-link LVDS source 347 362 * @port2: Second DT port node of the Dual-link LVDS source 348 363 * ··· 402 387 if (remote_p2_pt < 0) 403 388 return remote_p2_pt; 404 389 405 - /* 406 - * A valid dual-lVDS bus is found when one remote port is marked with 407 - * "dual-lvds-even-pixels", and the other remote port is marked with 408 - * "dual-lvds-odd-pixels", bail out if the markers are not right. 409 - */ 410 - if (remote_p1_pt + remote_p2_pt != DRM_OF_LVDS_EVEN + DRM_OF_LVDS_ODD) 411 - return -EINVAL; 412 - 413 - return remote_p1_pt == DRM_OF_LVDS_EVEN ? 414 - DRM_LVDS_DUAL_LINK_EVEN_ODD_PIXELS : 415 - DRM_LVDS_DUAL_LINK_ODD_EVEN_PIXELS; 390 + return __drm_of_lvds_get_dual_link_pixel_order(remote_p1_pt, remote_p2_pt); 416 391 } 417 392 EXPORT_SYMBOL_GPL(drm_of_lvds_get_dual_link_pixel_order); 393 + 394 + /** 395 + * drm_of_lvds_get_dual_link_pixel_order_sink - Get LVDS dual-link sink pixel order 396 + * @port1: First DT port node of the Dual-link LVDS sink 397 + * @port2: Second DT port node of the Dual-link LVDS sink 398 + * 399 + * An LVDS dual-link connection is made of two links, with even pixels 400 + * transitting on one link, and odd pixels on the other link. This function 401 + * returns, for two ports of an LVDS dual-link sink, which port shall transmit 402 + * the even and odd pixels, based on the requirements of the sink. 403 + * 404 + * The pixel order is determined from the dual-lvds-even-pixels and 405 + * dual-lvds-odd-pixels properties in the sink's DT port nodes. If those 406 + * properties are not present, or if their usage is not valid, this function 407 + * returns -EINVAL. 408 + * 409 + * If either port is not connected, this function returns -EPIPE. 410 + * 411 + * @port1 and @port2 are typically DT sibling nodes, but may have different 412 + * parents when, for instance, two separate LVDS decoders receive the even and 413 + * odd pixels. 414 + * 415 + * Return: 416 + * * DRM_LVDS_DUAL_LINK_EVEN_ODD_PIXELS - @port1 receives even pixels and @port2 417 + * receives odd pixels 418 + * * DRM_LVDS_DUAL_LINK_ODD_EVEN_PIXELS - @port1 receives odd pixels and @port2 419 + * receives even pixels 420 + * * -EINVAL - @port1 or @port2 are NULL 421 + * * -EPIPE - when @port1 or @port2 are not connected 422 + */ 423 + int drm_of_lvds_get_dual_link_pixel_order_sink(struct device_node *port1, 424 + struct device_node *port2) 425 + { 426 + int sink_p1_pt, sink_p2_pt; 427 + 428 + if (!port1 || !port2) 429 + return -EINVAL; 430 + 431 + sink_p1_pt = drm_of_lvds_get_port_pixels_type(port1); 432 + if (!sink_p1_pt) 433 + return -EPIPE; 434 + 435 + sink_p2_pt = drm_of_lvds_get_port_pixels_type(port2); 436 + if (!sink_p2_pt) 437 + return -EPIPE; 438 + 439 + return __drm_of_lvds_get_dual_link_pixel_order(sink_p1_pt, sink_p2_pt); 440 + } 441 + EXPORT_SYMBOL_GPL(drm_of_lvds_get_dual_link_pixel_order_sink); 418 442 419 443 /** 420 444 * drm_of_lvds_get_data_mapping - Get LVDS data mapping
+9
include/drm/drm_of.h
··· 52 52 struct drm_bridge **bridge); 53 53 int drm_of_lvds_get_dual_link_pixel_order(const struct device_node *port1, 54 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); 55 57 int drm_of_lvds_get_data_mapping(const struct device_node *port); 56 58 int drm_of_get_data_lanes_count(const struct device_node *endpoint, 57 59 const unsigned int min, const unsigned int max); ··· 107 105 static inline int 108 106 drm_of_lvds_get_dual_link_pixel_order(const struct device_node *port1, 109 107 const struct device_node *port2) 108 + { 109 + return -EINVAL; 110 + } 111 + 112 + static inline int 113 + drm_of_lvds_get_dual_link_pixel_order_sink(struct device_node *port1, 114 + struct device_node *port2) 110 115 { 111 116 return -EINVAL; 112 117 }