bcm27xx: add support for linux v5.15
[openwrt/staging/chunkeey.git] / target / linux / bcm27xx / patches-5.15 / 950-0568-drm-vc4-Enable-gamma-block-only-when-required.patch
1 From 66d8a98666f29d7f8de926963bd4965aeeb89f13 Mon Sep 17 00:00:00 2001
2 From: Dave Stevenson <dave.stevenson@raspberrypi.com>
3 Date: Mon, 8 Nov 2021 17:32:45 +0000
4 Subject: [PATCH] drm/vc4: Enable gamma block only when required.
5
6 With HVS5 the gamma block is now only reprogrammed with
7 a disable/enable. Loading the table from vc4_hvs_init_channel
8 (called from vc4_hvs_atomic_enable) appears to be at an
9 invalid point in time and so isn't applied.
10
11 Switch to enabling and disabling the gamma table instead. This
12 isn't safe if the pipeline is running, but it isn't now.
13 For HVS4 it is safe to enable and disable dynamically, so
14 adopt that approach there too.
15
16 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
17 ---
18 drivers/gpu/drm/vc4/vc4_hvs.c | 22 +++++++++++++++++-----
19 1 file changed, 17 insertions(+), 5 deletions(-)
20
21 --- a/drivers/gpu/drm/vc4/vc4_hvs.c
22 +++ b/drivers/gpu/drm/vc4/vc4_hvs.c
23 @@ -480,8 +480,12 @@ static int vc4_hvs_init_channel(struct v
24 dispbkgndx &= ~SCALER_DISPBKGND_GAMMA;
25 dispbkgndx &= ~SCALER_DISPBKGND_INTERLACE;
26
27 + if (crtc->state->gamma_lut)
28 + /* Enable gamma on if required */
29 + dispbkgndx |= SCALER_DISPBKGND_GAMMA;
30 +
31 HVS_WRITE(SCALER_DISPBKGNDX(chan), dispbkgndx |
32 - SCALER_DISPBKGND_AUTOHS | SCALER_DISPBKGND_GAMMA |
33 + SCALER_DISPBKGND_AUTOHS |
34 (interlace ? SCALER_DISPBKGND_INTERLACE : 0));
35
36 /* Reload the LUT, since the SRAMs would have been disabled if
37 @@ -718,17 +722,25 @@ void vc4_hvs_atomic_flush(struct drm_crt
38 u32 dispbkgndx = HVS_READ(SCALER_DISPBKGNDX(vc4_state->assigned_channel));
39
40 if (crtc->state->gamma_lut) {
41 - if (!vc4->hvs->hvs5)
42 + if (!vc4->hvs->hvs5) {
43 vc4_hvs_update_gamma_lut(crtc);
44 - else
45 + dispbkgndx |= SCALER_DISPBKGND_GAMMA;
46 + } else {
47 vc5_hvs_update_gamma_lut(crtc);
48 - dispbkgndx |= SCALER_DISPBKGND_GAMMA;
49 + }
50 } else {
51 /* Unsetting DISPBKGND_GAMMA skips the gamma lut step
52 * in hardware, which is the same as a linear lut that
53 * DRM expects us to use in absence of a user lut.
54 + *
55 + * Do NOT change state dynamically for hvs5 as it
56 + * inserts a delay in the pipeline that will cause
57 + * stalls if enabled/disabled whilst running. The other
58 + * should already be disabling/enabling the pipeline
59 + * when gamma changes.
60 */
61 - dispbkgndx &= ~SCALER_DISPBKGND_GAMMA;
62 + if (!vc4->hvs->hvs5)
63 + dispbkgndx &= ~SCALER_DISPBKGND_GAMMA;
64 }
65 HVS_WRITE(SCALER_DISPBKGNDX(vc4_state->assigned_channel), dispbkgndx);
66 }