A frame-packed 3D mode scans out both views and the active space between them in one frame, so the CRTC is 2205 lines tall for a 1080p mode. The stream scaling code took the source height from mode->vdisplay (1080) against the 2205-line addressable destination; with aspect scaling that keeps 1080 lines and centres them, so the first view is stretched across both eye windows and the second view is never shown. The plane viewport check clipped planes to crtc_vdisplay for the same reason.
Use drm_mode_get_hv_timing(), which returns the doubled height for stereo modes and the plain display size otherwise, in both places. Measured on a Radeon RX 7600 with a frame-packed 1920x1080p24 mode: before, a row-coded 2205-line test frame showed rows of the first view in both eyes; after, each eye receives its own view. The plane KUnit tests mocked only the CRTC-adjusted size; set the mode size they now derive it from as well. Signed-off-by: Adrian Betschart <[email protected]> --- .../drm/amd/display/amdgpu_dm/amdgpu_dm_connector.c | 11 ++++++++--- .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c | 13 +++++++++---- .../display/amdgpu_dm/tests/amdgpu_dm_plane_test.c | 12 ++++++++++++ 3 files changed, 29 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_connector.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_connector.c index aa3f47632..2d35060d7 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_connector.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_connector.c @@ -1418,9 +1418,14 @@ void amdgpu_dm_update_stream_scaling_settings(struct drm_device *dev, if (!mode) return; - /* Full screen scaling by default */ - src.width = mode->hdisplay; - src.height = mode->vdisplay; + /* + * Full screen scaling by default. A frame-packed 3D mode scans out the + * doubled timing, so the source size is the CRTC size, not vdisplay: + * with 1080 lines against a 2205-line destination the aspect fit would + * keep 1080 lines and centre them, putting the first view across both + * eye windows and none of the second. + */ + drm_mode_get_hv_timing(mode, &src.width, &src.height); dst.width = stream->timing.h_addressable; dst.height = stream->timing.v_addressable; diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c index 0a5a73472..8db656ef8 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c @@ -1407,16 +1407,21 @@ int amdgpu_dm_plane_helper_check_state(struct drm_plane_state *state, if (state->plane->type != DRM_PLANE_TYPE_CURSOR) { int viewport_width = state->crtc_w; int viewport_height = state->crtc_h; + int mode_hdisplay, mode_vdisplay; + + /* frame-packed 3D scans out the doubled timing */ + drm_mode_get_hv_timing(&new_crtc_state->mode, + &mode_hdisplay, &mode_vdisplay); if (state->crtc_x < 0) viewport_width += state->crtc_x; - else if (state->crtc_x + state->crtc_w > new_crtc_state->mode.crtc_hdisplay) - viewport_width = new_crtc_state->mode.crtc_hdisplay - state->crtc_x; + else if (state->crtc_x + state->crtc_w > mode_hdisplay) + viewport_width = mode_hdisplay - state->crtc_x; if (state->crtc_y < 0) viewport_height += state->crtc_y; - else if (state->crtc_y + state->crtc_h > new_crtc_state->mode.crtc_vdisplay) - viewport_height = new_crtc_state->mode.crtc_vdisplay - state->crtc_y; + else if (state->crtc_y + state->crtc_h > mode_vdisplay) + viewport_height = mode_vdisplay - state->crtc_y; if (viewport_width < 0 || viewport_height < 0) { DRM_DEBUG_ATOMIC("Plane completely outside of screen\n"); diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_plane_test.c b/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_plane_test.c index 1b39f41c8..80a952d47 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_plane_test.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_plane_test.c @@ -642,6 +642,8 @@ static void dm_test_helper_check_state_viewport_reject(struct kunit *test) state->crtc_y = 0; state->crtc_w = 100; state->crtc_h = 100; + new_crtc_state->mode.hdisplay = 100; + new_crtc_state->mode.vdisplay = 100; new_crtc_state->mode.crtc_hdisplay = 100; new_crtc_state->mode.crtc_vdisplay = 100; @@ -2286,6 +2288,8 @@ static void dm_test_helper_check_state_small_viewport_width(struct kunit *test) state->crtc_y = 0; state->crtc_w = 10; state->crtc_h = 100; + new_crtc_state->mode.hdisplay = 1920; + new_crtc_state->mode.vdisplay = 1080; new_crtc_state->mode.crtc_hdisplay = 1920; new_crtc_state->mode.crtc_vdisplay = 1080; @@ -2327,6 +2331,8 @@ static void dm_test_helper_check_state_small_viewport_height(struct kunit *test) state->crtc_y = -95; state->crtc_w = 100; state->crtc_h = 100; + new_crtc_state->mode.hdisplay = 1920; + new_crtc_state->mode.vdisplay = 1080; new_crtc_state->mode.crtc_hdisplay = 1920; new_crtc_state->mode.crtc_vdisplay = 1080; @@ -2369,6 +2375,8 @@ static void dm_test_helper_check_state_bottom_clipped_height(struct kunit *test) state->crtc_y = 95; state->crtc_w = 100; state->crtc_h = 100; + new_crtc_state->mode.hdisplay = 1920; + new_crtc_state->mode.vdisplay = 100; new_crtc_state->mode.crtc_hdisplay = 1920; new_crtc_state->mode.crtc_vdisplay = 100; @@ -2429,6 +2437,8 @@ static void dm_test_helper_check_state_scaling_caps(struct kunit *test) state->crtc_w = 200; state->crtc_h = 200; new_crtc_state->crtc = crtc; + new_crtc_state->mode.hdisplay = 1920; + new_crtc_state->mode.vdisplay = 1080; new_crtc_state->mode.crtc_hdisplay = 1920; new_crtc_state->mode.crtc_vdisplay = 1080; @@ -2738,6 +2748,8 @@ static struct amdgpu_device *dm_test_init_atomic_check_state(struct kunit *test, (*new_crtc_state)->crtc = crtc; (*new_crtc_state)->enable = true; + (*new_crtc_state)->mode.hdisplay = 1920; + (*new_crtc_state)->mode.vdisplay = 1080; (*new_crtc_state)->mode.crtc_hdisplay = 1920; (*new_crtc_state)->mode.crtc_vdisplay = 1080; -- 2.43.0
