9d815d39b56c44c4e413ca5092f9b62b058dd43d
[openwrt/openwrt.git] / target / linux / bcm27xx / patches-5.15 / 950-0579-drm-vc4-Add-support-for-composite-syncs-to-vc4_dpi.patch
1 From bbd8dd64c1083232f3da8e097207a5b539ab91c9 Mon Sep 17 00:00:00 2001
2 From: Dave Stevenson <dave.stevenson@raspberrypi.com>
3 Date: Thu, 25 Nov 2021 14:45:33 +0000
4 Subject: [PATCH] drm/vc4: Add support for composite syncs to vc4_dpi
5
6 The hardware can combine H&V syncs onto the output enable line
7 as composite syncs, so add the relevant configuration to do that.
8
9 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
10 ---
11 drivers/gpu/drm/vc4/vc4_dpi.c | 25 ++++++++++++++++---------
12 1 file changed, 16 insertions(+), 9 deletions(-)
13
14 --- a/drivers/gpu/drm/vc4/vc4_dpi.c
15 +++ b/drivers/gpu/drm/vc4/vc4_dpi.c
16 @@ -131,7 +131,7 @@ static void vc4_dpi_encoder_enable(struc
17 struct vc4_dpi *dpi = vc4_encoder->dpi;
18 struct drm_connector_list_iter conn_iter;
19 struct drm_connector *connector = NULL, *connector_scan;
20 - u32 dpi_c = DPI_ENABLE | DPI_OUTPUT_ENABLE_MODE;
21 + u32 dpi_c = DPI_ENABLE;
22 int ret;
23
24 /* Look up the connector attached to DPI so we can get the
25 @@ -192,15 +192,22 @@ static void vc4_dpi_encoder_enable(struc
26 dpi_c |= VC4_SET_FIELD(DPI_FORMAT_18BIT_666_RGB_1, DPI_FORMAT);
27 }
28
29 - if (mode->flags & DRM_MODE_FLAG_NHSYNC)
30 - dpi_c |= DPI_HSYNC_INVERT;
31 - else if (!(mode->flags & DRM_MODE_FLAG_PHSYNC))
32 - dpi_c |= DPI_HSYNC_DISABLE;
33 -
34 - if (mode->flags & DRM_MODE_FLAG_NVSYNC)
35 - dpi_c |= DPI_VSYNC_INVERT;
36 - else if (!(mode->flags & DRM_MODE_FLAG_PVSYNC))
37 - dpi_c |= DPI_VSYNC_DISABLE;
38 + if (mode->flags & DRM_MODE_FLAG_CSYNC) {
39 + if (mode->flags & DRM_MODE_FLAG_NCSYNC)
40 + dpi_c |= DPI_OUTPUT_ENABLE_INVERT;
41 + } else {
42 + dpi_c |= DPI_OUTPUT_ENABLE_MODE;
43 +
44 + if (mode->flags & DRM_MODE_FLAG_NHSYNC)
45 + dpi_c |= DPI_HSYNC_INVERT;
46 + else if (!(mode->flags & DRM_MODE_FLAG_PHSYNC))
47 + dpi_c |= DPI_HSYNC_DISABLE;
48 +
49 + if (mode->flags & DRM_MODE_FLAG_NVSYNC)
50 + dpi_c |= DPI_VSYNC_INVERT;
51 + else if (!(mode->flags & DRM_MODE_FLAG_PVSYNC))
52 + dpi_c |= DPI_VSYNC_DISABLE;
53 + }
54
55 DPI_WRITE(DPI_C, dpi_c);
56