Skip to contentSkip to conversation

video: mode-helpers: preserve sync polarity in fb_videomode conversion

PATCH Applied Ahmad Fatoum 2 participants 3 messages Feb 13 – Feb 23 Framebuffer layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 video: mode-helpers: preserve sync polarity in fb_videomode conversion

The FB_SYNC_*_HIGH_ACT flags indicate that the respective sync signal is active high when set and active low when unset.

The DISPLAY_FLAGS_*SYNC_* flags on the other hands have separate non-zero _HIGH and _LOW flags, which fb_videomode_to_videomode() failed to account for.

This causes a DPI sync polarity mismatch for MIPI-DSI panels with negative sync polarity, which was hackily worked around by enabling the video pattern generator intermittently.

Fix by explicitly setting the LOW polarity flags, which restores DRM_MODE_FLAG_NHSYNC/NVSYNC after the fb_videomode round-trip.

Fixes 7fc6f7b5daa0 ("video: add videomode helpers")
---
 drivers/video/mode-helpers.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/video/mode-helpers.c +4 -0
index 4a1d31813e79..89abd8342bf4 100644
@@ -143,8 +143,12 @@ void fb_videomode_to_videomode(const struct fb_videomode *fbmode,
 
 	if (fbmode->sync & FB_SYNC_HOR_HIGH_ACT)
 		vm->flags |= DISPLAY_FLAGS_HSYNC_HIGH;
+	else
+		vm->flags |= DISPLAY_FLAGS_HSYNC_LOW;
 	if (fbmode->sync & FB_SYNC_VERT_HIGH_ACT)
 		vm->flags |= DISPLAY_FLAGS_VSYNC_HIGH;
+	else
+		vm->flags |= DISPLAY_FLAGS_VSYNC_LOW;
 	if (fbmode->vmode & FB_VMODE_INTERLACED)
 		vm->flags |= DISPLAY_FLAGS_INTERLACED;
 	if (fbmode->vmode & FB_VMODE_DOUBLE)
Signature · 1 line
2.47.3
#1 lore raw

PATCH 2/2 video: dw_mipi_dsi: remove VPG workaround for panel initialization

The Video Pattern Generator was being temporarily enabled during VPL_ENABLE to work around panel initialization timeouts on the Sitronix ST7703 of the Powkiddy RGB30. The root cause was a sync polarity that has been fixed in the previous commit, so this hack can now go away.

This fixes a regression for the STM32MP157C-DK2: Enabling the VPG at the point we did, caused the panel to synchronize to a wrong start offset and led to a funny effect with the barebox logo that's shown by default:

On subsequent reboots, the display output would start at different locations and so the logo would wander around and because the color format is RGB888, the hexagon inside the barebox logo b would keep switching between red, green and blue.

Fixes 5115bff30153 ("video: dw_mipi_dsi: activate pattern generator during enable as a hack")
---
 drivers/video/dw_mipi_dsi.c | 20 +-------------------
 1 file changed, 1 insertion(+), 19 deletions(-)
drivers/video/dw_mipi_dsi.c +1 -19
index 681d939e17ea..bf95b1b9f6ff 100644
@@ -906,20 +906,9 @@ static int dw_mipi_dsi_ioctl(struct vpl *vpl, unsigned int port,
 {
 	struct dw_mipi_dsi *dsi = container_of(vpl, struct dw_mipi_dsi, vpl);
 	struct drm_display_mode mode = {};
-	bool vpg_enable_hack;
-	int ret;
-
-	/*
-	 * HACK: If Video Pattern Generator is not running here, the panel
-	 * initialization on the Sitronix ST7703 (RGB30-Panel) times out...
-	 * FIXME: figure out why Linux doesn't suffer from this
-	 */
-	vpg_enable_hack = true;
 
 	switch (cmd) {
 	case VPL_ENABLE:
-		if (vpg_enable_hack)
-			dsi->vpg_mode = VPG_COLORS_V;
 		/* Switch to video mode for panel-bridge enable & panel enable */
 		dw_mipi_dsi_set_mode(dsi, MIPI_DSI_MODE_VIDEO);
 		break;
@@ -945,14 +934,7 @@ static int dw_mipi_dsi_ioctl(struct vpl *vpl, unsigned int port,
 	/* Probes should have occured by now */
 	WARN_ON(!dsi->panel_bridge);
 
-	ret = vpl_bridge_ioctl(dsi->panel_bridge, cmd, data);
-
-	if (cmd == VPL_ENABLE && vpg_enable_hack) {
-		dsi->vpg_mode = VPG_DISABLED;
-		vpg_param_set(NULL, dsi);
-	}
-
-	return ret;
+	return vpl_bridge_ioctl(dsi->panel_bridge, cmd, data);
 }
 
 static const char *vpg_modes[] = {
Signature · 1 line
2.47.3
Applied
#2 lore raw
In reply to Ahmad Fatoum
Quoted 8 lines · Ahmad Fatoum

The FB_SYNC_*_HIGH_ACT flags indicate that the respective sync signal is active high when set and active low when unset.

The DISPLAY_FLAGS_*SYNC_* flags on the other hands have separate non-zero _HIGH and _LOW flags, which fb_videomode_to_videomode() failed to account for.

[...]

Applied, thanks!

[1/2] video: mode-helpers: preserve sync polarity in fb_videomode conversion
https://git.pengutronix.de/cgit/barebox/commit/?id=f66af1ff3a20 (link may not be stable)
[2/2] video: dw_mipi_dsi: remove VPG workaround for panel initialization
https://git.pengutronix.de/cgit/barebox/commit/?id=fde027dd650e (link may not be stable)

Best regards,

Signature · 1 line
Sascha Hauer <[email protected]>