Skip to content

Commit 4c30c74

Browse files
committed
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> drm/vc4: Disable the 2pixel/clock odd timings workaround for interlaced Whilst BCM2712 does fix using odd horizontal timings, it doesn't work with interlaced modes. Drop the workaround for interlaced modes and revert to the same behaviour as BCM2711. #6281 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
1 parent dc69642 commit 4c30c74

File tree

5 files changed

+35
-12
lines changed

5 files changed

+35
-12
lines changed

drivers/gpu/drm/vc4/vc4_crtc.c

+19-9
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,9 @@ static void vc4_crtc_config_pv(struct drm_crtc *crtc, struct drm_encoder *encode
378378
bool is_dsi1 = vc4_encoder->type == VC4_ENCODER_TYPE_DSI1;
379379
bool is_vec = vc4_encoder->type == VC4_ENCODER_TYPE_VEC;
380380
u32 format = is_dsi1 ? PV_CONTROL_FORMAT_DSIV_24 : PV_CONTROL_FORMAT_24;
381-
u8 ppc = pv_data->pixels_per_clock;
381+
u8 ppc = (mode->flags & DRM_MODE_FLAG_INTERLACE) ?
382+
pv_data->pixels_per_clock_int :
383+
pv_data->pixels_per_clock;
382384

383385
u16 vert_bp = mode->crtc_vtotal - mode->crtc_vsync_end;
384386
u16 vert_sync = mode->crtc_vsync_end - mode->crtc_vsync_start;
@@ -399,12 +401,6 @@ static void vc4_crtc_config_pv(struct drm_crtc *crtc, struct drm_encoder *encode
399401

400402
vc4_crtc_pixelvalve_reset(crtc);
401403

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-
*/
408404
CRTC_WRITE(PV_HORZA,
409405
VC4_SET_FIELD((mode->htotal - mode->hsync_end) * pixel_rep / ppc,
410406
PV_HORZA_HBP) |
@@ -449,6 +445,8 @@ static void vc4_crtc_config_pv(struct drm_crtc *crtc, struct drm_encoder *encode
449445
*/
450446
CRTC_WRITE(PV_V_CONTROL,
451447
PV_VCONTROL_CONTINUOUS |
448+
(vc4->gen >= VC4_GEN_6 && ppc == 1 ?
449+
PV_VCONTROL_ODD_TIMING : 0) |
452450
(is_dsi ? PV_VCONTROL_DSI : 0) |
453451
PV_VCONTROL_INTERLACE |
454452
(odd_field_first
@@ -460,6 +458,8 @@ static void vc4_crtc_config_pv(struct drm_crtc *crtc, struct drm_encoder *encode
460458
} else {
461459
CRTC_WRITE(PV_V_CONTROL,
462460
PV_VCONTROL_CONTINUOUS |
461+
(vc4->gen >= VC4_GEN_6 && ppc == 1 ?
462+
PV_VCONTROL_ODD_TIMING : 0) |
463463
(is_dsi ? PV_VCONTROL_DSI : 0));
464464
CRTC_WRITE(PV_VSYNCD_EVEN, 0);
465465
}
@@ -1217,6 +1217,7 @@ const struct vc4_pv_data bcm2835_pv0_data = {
12171217
},
12181218
.fifo_depth = 64,
12191219
.pixels_per_clock = 1,
1220+
.pixels_per_clock_int = 1,
12201221
.encoder_types = {
12211222
[PV_CONTROL_CLK_SELECT_DSI] = VC4_ENCODER_TYPE_DSI0,
12221223
[PV_CONTROL_CLK_SELECT_DPI_SMI_HDMI] = VC4_ENCODER_TYPE_DPI,
@@ -1232,6 +1233,7 @@ const struct vc4_pv_data bcm2835_pv1_data = {
12321233
},
12331234
.fifo_depth = 64,
12341235
.pixels_per_clock = 1,
1236+
.pixels_per_clock_int = 1,
12351237
.encoder_types = {
12361238
[PV_CONTROL_CLK_SELECT_DSI] = VC4_ENCODER_TYPE_DSI1,
12371239
[PV_CONTROL_CLK_SELECT_DPI_SMI_HDMI] = VC4_ENCODER_TYPE_SMI,
@@ -1247,6 +1249,7 @@ const struct vc4_pv_data bcm2835_pv2_data = {
12471249
},
12481250
.fifo_depth = 64,
12491251
.pixels_per_clock = 1,
1252+
.pixels_per_clock_int = 1,
12501253
.encoder_types = {
12511254
[PV_CONTROL_CLK_SELECT_DPI_SMI_HDMI] = VC4_ENCODER_TYPE_HDMI0,
12521255
[PV_CONTROL_CLK_SELECT_VEC] = VC4_ENCODER_TYPE_VEC,
@@ -1262,6 +1265,7 @@ const struct vc4_pv_data bcm2711_pv0_data = {
12621265
},
12631266
.fifo_depth = 64,
12641267
.pixels_per_clock = 1,
1268+
.pixels_per_clock_int = 1,
12651269
.encoder_types = {
12661270
[0] = VC4_ENCODER_TYPE_DSI0,
12671271
[1] = VC4_ENCODER_TYPE_DPI,
@@ -1277,6 +1281,7 @@ const struct vc4_pv_data bcm2711_pv1_data = {
12771281
},
12781282
.fifo_depth = 64,
12791283
.pixels_per_clock = 1,
1284+
.pixels_per_clock_int = 1,
12801285
.encoder_types = {
12811286
[0] = VC4_ENCODER_TYPE_DSI1,
12821287
[1] = VC4_ENCODER_TYPE_SMI,
@@ -1292,6 +1297,7 @@ const struct vc4_pv_data bcm2711_pv2_data = {
12921297
},
12931298
.fifo_depth = 256,
12941299
.pixels_per_clock = 2,
1300+
.pixels_per_clock_int = 2,
12951301
.encoder_types = {
12961302
[0] = VC4_ENCODER_TYPE_HDMI0,
12971303
},
@@ -1306,6 +1312,7 @@ const struct vc4_pv_data bcm2711_pv3_data = {
13061312
},
13071313
.fifo_depth = 64,
13081314
.pixels_per_clock = 1,
1315+
.pixels_per_clock_int = 1,
13091316
.encoder_types = {
13101317
[PV_CONTROL_CLK_SELECT_VEC] = VC4_ENCODER_TYPE_VEC,
13111318
},
@@ -1320,6 +1327,7 @@ const struct vc4_pv_data bcm2711_pv4_data = {
13201327
},
13211328
.fifo_depth = 64,
13221329
.pixels_per_clock = 2,
1330+
.pixels_per_clock_int = 2,
13231331
.encoder_types = {
13241332
[0] = VC4_ENCODER_TYPE_HDMI1,
13251333
},
@@ -1332,7 +1340,8 @@ const struct vc4_pv_data bcm2712_pv0_data = {
13321340
.hvs_output = 0,
13331341
},
13341342
.fifo_depth = 64,
1335-
.pixels_per_clock = 2,
1343+
.pixels_per_clock = 1,
1344+
.pixels_per_clock_int = 2,
13361345
.encoder_types = {
13371346
[0] = VC4_ENCODER_TYPE_HDMI0,
13381347
},
@@ -1345,7 +1354,8 @@ const struct vc4_pv_data bcm2712_pv1_data = {
13451354
.hvs_output = 1,
13461355
},
13471356
.fifo_depth = 64,
1348-
.pixels_per_clock = 2,
1357+
.pixels_per_clock = 1,
1358+
.pixels_per_clock_int = 2,
13491359
.encoder_types = {
13501360
[0] = VC4_ENCODER_TYPE_HDMI1,
13511361
},

drivers/gpu/drm/vc4/vc4_drv.h

+2
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,8 @@ struct vc4_pv_data {
567567

568568
/* Number of pixels output per clock period */
569569
u8 pixels_per_clock;
570+
/* Number of pixels output per clock period when in an interlaced mode */
571+
u8 pixels_per_clock_int;
570572

571573
enum vc4_encoder_type encoder_types[4];
572574
};

drivers/gpu/drm/vc4/vc4_hdmi.c

+9-3
Original file line numberDiff line numberDiff line change
@@ -1724,7 +1724,9 @@ static int vc4_hdmi_encoder_atomic_check(struct drm_encoder *encoder,
17241724
unsigned long long tmds_char_rate = mode->clock * 1000;
17251725
unsigned long long tmds_bit_rate;
17261726

1727-
if (vc4_hdmi->variant->unsupported_odd_h_timings) {
1727+
if (vc4_hdmi->variant->unsupported_odd_h_timings ||
1728+
(vc4_hdmi->variant->unsupported_int_odd_h_timings &&
1729+
(mode->flags & DRM_MODE_FLAG_INTERLACE))) {
17281730
if (mode->flags & DRM_MODE_FLAG_DBLCLK) {
17291731
/* Only try to fixup DBLCLK modes to get 480i and 576i
17301732
* working.
@@ -3380,6 +3382,7 @@ static const struct vc4_hdmi_variant bcm2711_hdmi0_variant = {
33803382
PHY_LANE_CK,
33813383
},
33823384
.unsupported_odd_h_timings = true,
3385+
.unsupported_int_odd_h_timings = true,
33833386
.external_irq_controller = true,
33843387

33853388
.init_resources = vc5_hdmi_init_resources,
@@ -3409,6 +3412,7 @@ static const struct vc4_hdmi_variant bcm2711_hdmi1_variant = {
34093412
PHY_LANE_2,
34103413
},
34113414
.unsupported_odd_h_timings = true,
3415+
.unsupported_int_odd_h_timings = true,
34123416
.external_irq_controller = true,
34133417

34143418
.init_resources = vc5_hdmi_init_resources,
@@ -3437,7 +3441,8 @@ static const struct vc4_hdmi_variant bcm2712_hdmi0_variant = {
34373441
PHY_LANE_2,
34383442
PHY_LANE_CK,
34393443
},
3440-
.unsupported_odd_h_timings = true,
3444+
.unsupported_odd_h_timings = false,
3445+
.unsupported_int_odd_h_timings = true,
34413446
.external_irq_controller = true,
34423447

34433448
.init_resources = vc5_hdmi_init_resources,
@@ -3464,7 +3469,8 @@ static const struct vc4_hdmi_variant bcm2712_hdmi1_variant = {
34643469
PHY_LANE_2,
34653470
PHY_LANE_CK,
34663471
},
3467-
.unsupported_odd_h_timings = true,
3472+
.unsupported_odd_h_timings = false,
3473+
.unsupported_int_odd_h_timings = true,
34683474
.external_irq_controller = true,
34693475

34703476
.init_resources = vc5_hdmi_init_resources,

drivers/gpu/drm/vc4/vc4_hdmi.h

+4
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ struct vc4_hdmi_variant {
4646

4747
/* The BCM2711 cannot deal with odd horizontal pixel timings */
4848
bool unsupported_odd_h_timings;
49+
/* The BCM2712 can handle odd horizontal pixel timings, but not in
50+
* interlaced modes
51+
*/
52+
bool unsupported_int_odd_h_timings;
4953

5054
/*
5155
* The BCM2711 CEC/hotplug IRQ controller is shared between the

drivers/gpu/drm/vc4/vc4_regs.h

+1
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)