drm: exynos: dsi: Add atomic check
authorJagan Teki <jagan@amarulasolutions.com>
Wed, 8 Mar 2023 16:39:44 +0000 (22:09 +0530)
committerInki Dae <inki.dae@samsung.com>
Tue, 28 Mar 2023 00:05:40 +0000 (09:05 +0900)
Look like an explicit fixing up of mode_flags is required for DSIM IP
present in i.MX8M Mini/Nano SoCs.

At least the LCDIF + DSIM needs active low sync polarities in order
to correlate the correct sync flags of the surrounding components in
the chain to make sure the whole pipeline can work properly.

On the other hand the i.MX 8M Mini Applications Processor Reference Manual,
Rev. 3, 11/2020 says.
"13.6.3.5.2 RGB interface
 Vsync, Hsync, and VDEN are active high signals."

i.MX 8M Mini Applications Processor Reference Manual Rev. 3, 11/2020
3.6.3.5.2 RGB interface
i.MX 8M Nano Applications Processor Reference Manual Rev. 2, 07/2022
13.6.2.7.2 RGB interface
both claim "Vsync, Hsync, and VDEN are active high signals.", the
LCDIF must generate inverted HS/VS/DE signals, i.e. active LOW.

No clear evidence about whether it can be documentation issues or
something, so added proper comments on the code.

Comments are suggested by Marek Vasut.

Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>
Reviewed-by: Marek Vasut <marex@denx.de>
Reviewed-by: Frieder Schrempf <frieder.schrempf@kontron.de>
Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
Signed-off-by: Inki Dae <inki.dae@samsung.com>
drivers/gpu/drm/exynos/exynos_drm_dsi.c

index eb33c2bcac16dbb8c4e39c13cc7e44e8bb8fceca..df4d95ae8aada344a79b25809fda0b6384c83e07 100644 (file)
@@ -263,6 +263,7 @@ enum exynos_dsi_type {
        DSIM_TYPE_EXYNOS5410,
        DSIM_TYPE_EXYNOS5422,
        DSIM_TYPE_EXYNOS5433,
+       DSIM_TYPE_IMX8MM,
        DSIM_TYPE_COUNT,
 };
 
@@ -1465,6 +1466,32 @@ static void exynos_dsi_atomic_post_disable(struct drm_bridge *bridge,
        pm_runtime_put_sync(dsi->dev);
 }
 
+static int exynos_dsi_atomic_check(struct drm_bridge *bridge,
+                                  struct drm_bridge_state *bridge_state,
+                                  struct drm_crtc_state *crtc_state,
+                                  struct drm_connector_state *conn_state)
+{
+       struct exynos_dsi *dsi = bridge_to_dsi(bridge);
+       struct drm_display_mode *adjusted_mode = &crtc_state->adjusted_mode;
+
+       /*
+        * The i.MX8M Mini/Nano glue logic between LCDIF and DSIM
+        * inverts HS/VS/DE sync signals polarity, therefore, while
+        * i.MX 8M Mini Applications Processor Reference Manual Rev. 3, 11/2020
+        * 13.6.3.5.2 RGB interface
+        * i.MX 8M Nano Applications Processor Reference Manual Rev. 2, 07/2022
+        * 13.6.2.7.2 RGB interface
+        * both claim "Vsync, Hsync, and VDEN are active high signals.", the
+        * LCDIF must generate inverted HS/VS/DE signals, i.e. active LOW.
+        */
+       if (dsi->plat_data->hw_type == DSIM_TYPE_IMX8MM) {
+               adjusted_mode->flags |= (DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC);
+               adjusted_mode->flags &= ~(DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC);
+       }
+
+       return 0;
+}
+
 static void exynos_dsi_mode_set(struct drm_bridge *bridge,
                                const struct drm_display_mode *mode,
                                const struct drm_display_mode *adjusted_mode)
@@ -1487,6 +1514,7 @@ static const struct drm_bridge_funcs exynos_dsi_bridge_funcs = {
        .atomic_duplicate_state         = drm_atomic_helper_bridge_duplicate_state,
        .atomic_destroy_state           = drm_atomic_helper_bridge_destroy_state,
        .atomic_reset                   = drm_atomic_helper_bridge_reset,
+       .atomic_check                   = exynos_dsi_atomic_check,
        .atomic_pre_enable              = exynos_dsi_atomic_pre_enable,
        .atomic_enable                  = exynos_dsi_atomic_enable,
        .atomic_disable                 = exynos_dsi_atomic_disable,