bcm27xx: import latest patches from the RPi foundation
[openwrt/staging/ynezz.git] / target / linux / bcm27xx / patches-5.4 / 950-0860-drm-vc4-FKMS-Block-modes-with-odd-horizontal-timing-.patch
1 From aa791f2cb6777e8ca99102009b631afdeea1c59d Mon Sep 17 00:00:00 2001
2 From: Dave Stevenson <dave.stevenson@raspberrypi.com>
3 Date: Fri, 3 Jul 2020 16:06:55 +0100
4 Subject: [PATCH] drm/vc4: FKMS Block modes with odd horizontal
5 timing values on Pi4
6
7 Pi4 HDMI pipeline is 2 pixels/clock and can not produce timings
8 that have odd values for active pixels, front porch, sync width,
9 or back porch.
10 Detect these modes and block them within fkms.
11
12 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
13 ---
14 drivers/gpu/drm/vc4/vc4_firmware_kms.c | 21 +++++++++++++++++++++
15 1 file changed, 21 insertions(+)
16
17 --- a/drivers/gpu/drm/vc4/vc4_firmware_kms.c
18 +++ b/drivers/gpu/drm/vc4/vc4_firmware_kms.c
19 @@ -44,6 +44,7 @@ struct get_display_cfg {
20
21 struct vc4_fkms {
22 struct get_display_cfg cfg;
23 + bool bcm2711;
24 };
25
26 #define PLANES_PER_CRTC 3
27 @@ -1097,6 +1098,17 @@ vc4_crtc_mode_valid(struct drm_crtc *crt
28 break;
29 }
30
31 + /* Pi4 can't generate odd horizontal timings on HDMI, so reject modes
32 + * that would set them.
33 + */
34 + if (fkms->bcm2711 &&
35 + (vc4_crtc->display_number == 2 || vc4_crtc->display_number == 7) &&
36 + ((mode->hdisplay | /* active */
37 + (mode->hsync_start - mode->hdisplay) | /* front porch */
38 + (mode->hsync_end - mode->hsync_start) | /* sync pulse */
39 + (mode->htotal - mode->hsync_end)) & 1)) /* back porch */
40 + return MODE_H_ILLEGAL;
41 +
42 return MODE_OK;
43 }
44
45 @@ -1282,6 +1294,8 @@ static const struct drm_crtc_helper_func
46
47 static const struct of_device_id vc4_firmware_kms_dt_match[] = {
48 { .compatible = "raspberrypi,rpi-firmware-kms" },
49 + { .compatible = "raspberrypi,rpi-firmware-kms-2711",
50 + .data = (void *)1 },
51 {}
52 };
53
54 @@ -1815,6 +1829,7 @@ static int vc4_fkms_bind(struct device *
55 struct drm_device *drm = dev_get_drvdata(master);
56 struct vc4_dev *vc4 = to_vc4_dev(drm);
57 struct device_node *firmware_node;
58 + const struct of_device_id *match;
59 struct vc4_crtc **crtc_list;
60 u32 num_displays, display_num;
61 struct vc4_fkms *fkms;
62 @@ -1827,6 +1842,12 @@ static int vc4_fkms_bind(struct device *
63 if (!fkms)
64 return -ENOMEM;
65
66 + match = of_match_device(vc4_firmware_kms_dt_match, dev);
67 + if (!match)
68 + return -ENODEV;
69 + if (match->data)
70 + fkms->bcm2711 = true;
71 +
72 /* firmware kms doesn't have precise a scanoutpos implementation, so
73 * we can't do the precise vblank timestamp mode.
74 */