1 From f61d5d294f12df46380ef1af5f55abe8e8f45500 Mon Sep 17 00:00:00 2001
2 From: Dom Cobley <popcornmix@gmail.com>
3 Date: Tue, 24 Oct 2023 16:20:42 +0100
4 Subject: [PATCH 0713/1085] drm/vc4: crtc: Support odd horizontal timings on
7 BCM2711 runs pixelvalve at two pixels per clock cycle which results
8 in an unfortunate limitation that odd horizontal timings are not
9 possible. This is apparent on the standard DMT mode of 1366x768@60
10 which cannot be driven with correct timing.
12 BCM2712 defaults to the same behaviour, but has a mode to support
13 odd timings. While internally it still runs at two pixels per clock,
14 setting the PV_VCONTROL_ODD_TIMING bit makes it appear externally
15 to behave as it is one pixel per clock.
17 Switching to this mode fixes 1366x768@60 mode, and other custom
18 resultions with odd horizontal timings.
20 Signed-off-by: Dom Cobley <popcornmix@gmail.com>
22 drivers/gpu/drm/vc4/vc4_crtc.c | 12 ++++--------
23 drivers/gpu/drm/vc4/vc4_hdmi.c | 4 ++--
24 drivers/gpu/drm/vc4/vc4_regs.h | 1 +
25 3 files changed, 7 insertions(+), 10 deletions(-)
27 --- a/drivers/gpu/drm/vc4/vc4_crtc.c
28 +++ b/drivers/gpu/drm/vc4/vc4_crtc.c
29 @@ -399,12 +399,6 @@ static void vc4_crtc_config_pv(struct dr
31 vc4_crtc_pixelvalve_reset(crtc);
34 - * NOTE: The BCM2712 has a H_OTE (Horizontal Odd Timing Enable)
35 - * bit that, when set, will allow to specify the timings in
36 - * pixels instead of cycles, thus allowing to specify odd
40 VC4_SET_FIELD((mode->htotal - mode->hsync_end) * pixel_rep / ppc,
42 @@ -449,6 +443,7 @@ static void vc4_crtc_config_pv(struct dr
44 CRTC_WRITE(PV_V_CONTROL,
45 PV_VCONTROL_CONTINUOUS |
46 + (vc4->gen >= VC4_GEN_6 ? PV_VCONTROL_ODD_TIMING : 0) |
47 (is_dsi ? PV_VCONTROL_DSI : 0) |
48 PV_VCONTROL_INTERLACE |
50 @@ -460,6 +455,7 @@ static void vc4_crtc_config_pv(struct dr
52 CRTC_WRITE(PV_V_CONTROL,
53 PV_VCONTROL_CONTINUOUS |
54 + (vc4->gen >= VC4_GEN_6 ? PV_VCONTROL_ODD_TIMING : 0) |
55 (is_dsi ? PV_VCONTROL_DSI : 0));
56 CRTC_WRITE(PV_VSYNCD_EVEN, 0);
58 @@ -1332,7 +1328,7 @@ const struct vc4_pv_data bcm2712_pv0_dat
62 - .pixels_per_clock = 2,
63 + .pixels_per_clock = 1,
65 [0] = VC4_ENCODER_TYPE_HDMI0,
67 @@ -1345,7 +1341,7 @@ const struct vc4_pv_data bcm2712_pv1_dat
71 - .pixels_per_clock = 2,
72 + .pixels_per_clock = 1,
74 [0] = VC4_ENCODER_TYPE_HDMI1,
76 --- a/drivers/gpu/drm/vc4/vc4_hdmi.c
77 +++ b/drivers/gpu/drm/vc4/vc4_hdmi.c
78 @@ -3912,7 +3912,7 @@ static const struct vc4_hdmi_variant bcm
82 - .unsupported_odd_h_timings = true,
83 + .unsupported_odd_h_timings = false,
84 .external_irq_controller = true,
86 .init_resources = vc5_hdmi_init_resources,
87 @@ -3939,7 +3939,7 @@ static const struct vc4_hdmi_variant bcm
91 - .unsupported_odd_h_timings = true,
92 + .unsupported_odd_h_timings = false,
93 .external_irq_controller = true,
95 .init_resources = vc5_hdmi_init_resources,
96 --- a/drivers/gpu/drm/vc4/vc4_regs.h
97 +++ b/drivers/gpu/drm/vc4/vc4_regs.h
99 # define PV_CONTROL_EN BIT(0)
101 #define PV_V_CONTROL 0x04
102 +# define PV_VCONTROL_ODD_TIMING BIT(29)
103 # define PV_VCONTROL_ODD_DELAY_MASK VC4_MASK(22, 6)
104 # define PV_VCONTROL_ODD_DELAY_SHIFT 6
105 # define PV_VCONTROL_ODD_FIRST BIT(5)