[Arm64-baikalm] [PATCH] drm/baikal_vdu: support LVDS connected to a bridge

Alexey Sheplyakov asheplyakov на basealt.ru
Ср Авг 3 12:03:44 MSK 2022


On some boards LVDS output is NOT connected directly to a panel,
instead it's connected to a (LVDS -> display port) bridge.
Alas baikal_vdu driver does not support such devices since

a) baikal_vdu_crtc_helper_enable dereferences priv->panel
   (which is NULL if LVDS output is connected to a bridge),
   and causes a kernel panic
b) baikal_vdu_crtc_helper_mode_set_nofb miscomputes the video
   mode, since it checks for a panel (which is NULL)

With this patch I can use both HDMI and display port video outputs
on ET101 board.

Signed-off-by: Alexey Sheplyakov <asheplyakov at basealt.ru>
---
 src/kernel/drivers/gpu/drm/baikal/baikal_vdu_crtc.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/kernel/drivers/gpu/drm/baikal/baikal_vdu_crtc.c b/src/kernel/drivers/gpu/drm/baikal/baikal_vdu_crtc.c
index 9e2b3b793..37d241a27 100644
--- a/src/kernel/drivers/gpu/drm/baikal/baikal_vdu_crtc.c
+++ b/src/kernel/drivers/gpu/drm/baikal/baikal_vdu_crtc.c
@@ -174,7 +174,7 @@ static void baikal_vdu_crtc_helper_mode_set_nofb(struct drm_crtc *crtc)
 		DRM_ERROR("Cannot set desired pixel clock (%lu Hz)\n", rate);
 
 	ppl = mode->hdisplay / 16;
-	if (priv->panel && priv-> ep_count == 2) {
+	if (priv->type == VDU_TYPE_LVDS && priv-> ep_count == 2) {
 		hsw = mode->hsync_end - mode->hsync_start;
 		hfp = mode->hsync_start - mode->hdisplay - 1;
 	} else {
@@ -242,8 +242,7 @@ static void baikal_vdu_crtc_helper_enable(struct drm_crtc *crtc,
 {
 	struct baikal_vdu_private *priv = crtc->dev->dev_private;
 	struct drm_panel *panel = priv->panel;
-	struct device_node *panel_node;
-	const char *data_mapping;
+	const char *data_mapping = NULL;
 	u32 cntl, gpio;
 
 	DRM_DEV_DEBUG_DRIVER(crtc->dev->dev, "enabling pixel clock\n");
@@ -260,8 +259,10 @@ static void baikal_vdu_crtc_helper_enable(struct drm_crtc *crtc,
 	cntl |= CR1_LCE | CR1_FDW_16_WORDS;
 
 	if (priv->type == VDU_TYPE_LVDS) {
-		panel_node = panel->dev->of_node;
-		if (of_property_read_string(panel_node, "data-mapping", &data_mapping)) {
+		if (panel) {
+			of_property_read_string(panel->dev->of_node, "data-mapping", &data_mapping);
+		}
+		if (!data_mapping) {
 			cntl |= CR1_OPS_LCD18;
 		} else if (!strncmp(data_mapping, "vesa-24", 7))
 			cntl |= CR1_OPS_LCD24;
-- 
2.32.0



Подробная информация о списке рассылки Arm64-baikalm