Skip to content

Commit 62abf84

Browse files
author
Mateusz Kwiatkowski
committed
drm/vc4: Add support for horizontally caled VEC modes
Composite output uses non-square pixels. By allowing horizontally scaled modes, we can simulate a different pixel clock and thus make it possible to simulate square pixels at either 4:3 or 16:9 target aspect ratio. Signed-off-by: Mateusz Kwiatkowski <[email protected]>
1 parent fd55efb commit 62abf84

File tree

1 file changed

+35
-10
lines changed

1 file changed

+35
-10
lines changed

drivers/gpu/drm/vc4/vc4_vec.c

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -687,16 +687,42 @@ static int vc4_vec_encoder_atomic_check(struct drm_encoder *encoder,
687687
crtc_state->adjusted_mode.crtc_vtotal /= 2;
688688
}
689689

690-
if (crtc_state->adjusted_mode.crtc_htotal !=
691-
vc4_vec_tv_modes[conn_state->tv.mode].interlaced_mode->htotal ||
692-
crtc_state->adjusted_mode.crtc_hdisplay % 4 != 0 ||
693-
crtc_state->adjusted_mode.crtc_hsync_end -
694-
crtc_state->adjusted_mode.crtc_hsync_start < 1)
690+
if (crtc_state->adjusted_mode.hdisplay % 4 != 0 ||
691+
crtc_state->adjusted_mode.hsync_end -
692+
crtc_state->adjusted_mode.hsync_start < 1)
695693
return -EINVAL;
696694

697-
switch (crtc_state->adjusted_mode.crtc_htotal) {
698-
case 858:
699-
/* 525-line mode */
695+
crtc_state->adjusted_mode.htotal =
696+
vc4_vec_tv_modes[conn_state->tv.mode].interlaced_mode->htotal;
697+
crtc_state->adjusted_mode.hdisplay =
698+
DIV_ROUND_CLOSEST(crtc_state->adjusted_mode.hdisplay *
699+
crtc_state->adjusted_mode.htotal,
700+
crtc_state->mode.htotal);
701+
crtc_state->adjusted_mode.hsync_start =
702+
DIV_ROUND_CLOSEST(crtc_state->adjusted_mode.hsync_start *
703+
crtc_state->adjusted_mode.htotal,
704+
crtc_state->mode.htotal);
705+
crtc_state->adjusted_mode.hsync_end =
706+
DIV_ROUND_CLOSEST(crtc_state->adjusted_mode.hsync_end *
707+
crtc_state->adjusted_mode.htotal,
708+
crtc_state->mode.htotal);
709+
crtc_state->adjusted_mode.clock =
710+
DIV_ROUND_CLOSEST(crtc_state->adjusted_mode.clock *
711+
crtc_state->adjusted_mode.htotal,
712+
crtc_state->mode.htotal);
713+
if (crtc_state->adjusted_mode.hsync_end -
714+
crtc_state->adjusted_mode.hsync_start < 1)
715+
crtc_state->adjusted_mode.hsync_end =
716+
crtc_state->adjusted_mode.hsync_start + 1;
717+
718+
crtc_state->adjusted_mode.crtc_clock = crtc_state->adjusted_mode.clock;
719+
crtc_state->adjusted_mode.crtc_hdisplay = crtc_state->adjusted_mode.hdisplay;
720+
crtc_state->adjusted_mode.crtc_hsync_start = crtc_state->adjusted_mode.hsync_start;
721+
crtc_state->adjusted_mode.crtc_hsync_end = crtc_state->adjusted_mode.hsync_end;
722+
crtc_state->adjusted_mode.crtc_htotal = crtc_state->adjusted_mode.htotal;
723+
724+
switch (vc4_vec_tv_modes[conn_state->tv.mode].interlaced_mode->vtotal) {
725+
case 525:
700726
if (crtc_state->adjusted_mode.crtc_vdisplay < 1 ||
701727
crtc_state->adjusted_mode.crtc_vdisplay > 253 ||
702728
crtc_state->adjusted_mode.crtc_vsync_start -
@@ -724,8 +750,7 @@ static int vc4_vec_encoder_atomic_check(struct drm_encoder *encoder,
724750

725751
break;
726752

727-
case 864:
728-
/* 625-line mode */
753+
case 625:
729754
if (crtc_state->adjusted_mode.crtc_vdisplay < 1 ||
730755
crtc_state->adjusted_mode.crtc_vdisplay > 305 ||
731756
crtc_state->adjusted_mode.crtc_vsync_start -

0 commit comments

Comments
 (0)