]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/tegra: rgb: Parameterize V- and H-sync polarities
authorThierry Reding <treding@nvidia.com>
Wed, 6 Sep 2023 06:50:48 +0000 (09:50 +0300)
committerRobert Foss <rfoss@kernel.org>
Wed, 20 Sep 2023 11:48:34 +0000 (13:48 +0200)
The polarities of the V- and H-sync signals are encoded as flags in the
display mode, so use the existing information to setup the signals for
the RGB interface.

Signed-off-by: Thierry Reding <treding@nvidia.com>
Cc: Thierry Reding <thierry.reding@gmail.com>
[tomi.valkeinen@ideasonboard.com: default to positive sync]
Reviewed-by: Peter Ujfalusi <peter.ujfalusi@gmail.com>
Tested-by: Maxim Schwalm <maxim.schwalm@gmail.com> # Asus TF700T
Tested-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Signed-off-by: Robert Foss <rfoss@kernel.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20230906-tc358768-v4-1-31725f008a50@ideasonboard.com
drivers/gpu/drm/tegra/rgb.c

index 79566c9ea8ff2bc38f97b55e5d40eb749deff922..fc66bbd913b24881612fec3f53d5fdf1c34669d1 100644 (file)
@@ -99,6 +99,7 @@ static void tegra_rgb_encoder_disable(struct drm_encoder *encoder)
 
 static void tegra_rgb_encoder_enable(struct drm_encoder *encoder)
 {
+       struct drm_display_mode *mode = &encoder->crtc->state->adjusted_mode;
        struct tegra_output *output = encoder_to_output(encoder);
        struct tegra_rgb *rgb = to_rgb(output);
        u32 value;
@@ -108,10 +109,19 @@ static void tegra_rgb_encoder_enable(struct drm_encoder *encoder)
        value = DE_SELECT_ACTIVE | DE_CONTROL_NORMAL;
        tegra_dc_writel(rgb->dc, value, DC_DISP_DATA_ENABLE_OPTIONS);
 
-       /* XXX: parameterize? */
+       /* configure H- and V-sync signal polarities */
        value = tegra_dc_readl(rgb->dc, DC_COM_PIN_OUTPUT_POLARITY(1));
-       value &= ~LVS_OUTPUT_POLARITY_LOW;
-       value &= ~LHS_OUTPUT_POLARITY_LOW;
+
+       if (mode->flags & DRM_MODE_FLAG_NHSYNC)
+               value |= LHS_OUTPUT_POLARITY_LOW;
+       else
+               value &= ~LHS_OUTPUT_POLARITY_LOW;
+
+       if (mode->flags & DRM_MODE_FLAG_NVSYNC)
+               value |= LVS_OUTPUT_POLARITY_LOW;
+       else
+               value &= ~LVS_OUTPUT_POLARITY_LOW;
+
        tegra_dc_writel(rgb->dc, value, DC_COM_PIN_OUTPUT_POLARITY(1));
 
        /* XXX: parameterize? */