Skip to content

Commit fc47f79

Browse files
popcornmixmdiewa
authored andcommitted
drm/vc4: crtc: Support odd horizontal timings on BCM2712
BCM2711 runs pixelvalve at two pixels per clock cycle which results in an unfortunate limitation that odd horizontal timings are not possible. This is apparent on the standard DMT mode of 1366x768@60 which cannot be driven with correct timing. BCM2712 defaults to the same behaviour, but has a mode to support odd timings. While internally it still runs at two pixels per clock, setting the PV_VCONTROL_ODD_TIMING bit makes it appear externally to behave as it is one pixel per clock. Switching to this mode fixes 1366x768@60 mode, and other custom resultions with odd horizontal timings. Signed-off-by: Dom Cobley <popcornmix@gmail.com> (cherry picked from commit 06e5f82e61aca21050d66887b44fd7e3bff13591 rpi-6.6.y) Signed-off-by: Juerg Haefliger <juerg.haefliger@canonical.com>
1 parent 20dbe88 commit fc47f79

File tree

3 files changed

+7
-10
lines changed

3 files changed

+7
-10
lines changed

drivers/gpu/drm/vc4/vc4_crtc.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -399,12 +399,6 @@ static void vc4_crtc_config_pv(struct drm_crtc *crtc, struct drm_encoder *encode
399399

400400
vc4_crtc_pixelvalve_reset(crtc);
401401

402-
/*
403-
* NOTE: The BCM2712 has a H_OTE (Horizontal Odd Timing Enable)
404-
* bit that, when set, will allow to specify the timings in
405-
* pixels instead of cycles, thus allowing to specify odd
406-
* timings.
407-
*/
408402
CRTC_WRITE(PV_HORZA,
409403
VC4_SET_FIELD((mode->htotal - mode->hsync_end) * pixel_rep / ppc,
410404
PV_HORZA_HBP) |
@@ -449,6 +443,7 @@ static void vc4_crtc_config_pv(struct drm_crtc *crtc, struct drm_encoder *encode
449443
*/
450444
CRTC_WRITE(PV_V_CONTROL,
451445
PV_VCONTROL_CONTINUOUS |
446+
(vc4->gen >= VC4_GEN_6 ? PV_VCONTROL_ODD_TIMING : 0) |
452447
(is_dsi ? PV_VCONTROL_DSI : 0) |
453448
PV_VCONTROL_INTERLACE |
454449
(odd_field_first
@@ -460,6 +455,7 @@ static void vc4_crtc_config_pv(struct drm_crtc *crtc, struct drm_encoder *encode
460455
} else {
461456
CRTC_WRITE(PV_V_CONTROL,
462457
PV_VCONTROL_CONTINUOUS |
458+
(vc4->gen >= VC4_GEN_6 ? PV_VCONTROL_ODD_TIMING : 0) |
463459
(is_dsi ? PV_VCONTROL_DSI : 0));
464460
CRTC_WRITE(PV_VSYNCD_EVEN, 0);
465461
}
@@ -1332,7 +1328,7 @@ const struct vc4_pv_data bcm2712_pv0_data = {
13321328
.hvs_output = 0,
13331329
},
13341330
.fifo_depth = 64,
1335-
.pixels_per_clock = 2,
1331+
.pixels_per_clock = 1,
13361332
.encoder_types = {
13371333
[0] = VC4_ENCODER_TYPE_HDMI0,
13381334
},
@@ -1345,7 +1341,7 @@ const struct vc4_pv_data bcm2712_pv1_data = {
13451341
.hvs_output = 1,
13461342
},
13471343
.fifo_depth = 64,
1348-
.pixels_per_clock = 2,
1344+
.pixels_per_clock = 1,
13491345
.encoder_types = {
13501346
[0] = VC4_ENCODER_TYPE_HDMI1,
13511347
},

drivers/gpu/drm/vc4/vc4_hdmi.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3917,7 +3917,7 @@ static const struct vc4_hdmi_variant bcm2712_hdmi0_variant = {
39173917
PHY_LANE_2,
39183918
PHY_LANE_CK,
39193919
},
3920-
.unsupported_odd_h_timings = true,
3920+
.unsupported_odd_h_timings = false,
39213921
.external_irq_controller = true,
39223922

39233923
.init_resources = vc5_hdmi_init_resources,
@@ -3944,7 +3944,7 @@ static const struct vc4_hdmi_variant bcm2712_hdmi1_variant = {
39443944
PHY_LANE_2,
39453945
PHY_LANE_CK,
39463946
},
3947-
.unsupported_odd_h_timings = true,
3947+
.unsupported_odd_h_timings = false,
39483948
.external_irq_controller = true,
39493949

39503950
.init_resources = vc5_hdmi_init_resources,

drivers/gpu/drm/vc4/vc4_regs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@
155155
# define PV_CONTROL_EN BIT(0)
156156

157157
#define PV_V_CONTROL 0x04
158+
# define PV_VCONTROL_ODD_TIMING BIT(29)
158159
# define PV_VCONTROL_ODD_DELAY_MASK VC4_MASK(22, 6)
159160
# define PV_VCONTROL_ODD_DELAY_SHIFT 6
160161
# define PV_VCONTROL_ODD_FIRST BIT(5)

0 commit comments

Comments
 (0)