From: Adrian Betschart <adrian.betschart@cinemaone.ch>
To: Harry Wentland <harry.wentland@amd.com>,
Leo Li <sunpeng.li@amd.com>,
Rodrigo Siqueira <siqueira@igalia.com>,
Alex Deucher <alexander.deucher@amd.com>
Cc: "Christian König" <christian.koenig@amd.com>,
amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
linux-kernel@vger.kernel.org
Subject: [PATCH v2 3/3] drm/amd/display: size frame-packed streams by the doubled timing
Date: Mon, 7 Sep 2026 13:52:29 +0200 [thread overview]
Message-ID: <20260907115229.64477-4-adrian.betschart@cinemaone.ch> (raw)
In-Reply-To: <20260907115229.64477-1-adrian.betschart@cinemaone.ch>
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 <adrian.betschart@cinemaone.ch>
---
.../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
prev parent reply other threads:[~2026-09-07 11:53 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-07 11:52 [PATCH v2 0/3] drm/amd/display: HDMI 1.4 3D output (frame packing, top-and-bottom, side-by-side) Adrian Betschart
2026-09-07 11:52 ` [PATCH v2 1/3] drm/amd/display: support HDMI 1.4 3D modes on HDMI connectors Adrian Betschart
2026-09-07 11:52 ` [PATCH v2 2/3] drm/amd/display: send the 3D_Ext_Data byte for top-and-bottom too Adrian Betschart
2026-09-07 11:52 ` Adrian Betschart [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260907115229.64477-4-adrian.betschart@cinemaone.ch \
--to=adrian.betschart@cinemaone.ch \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=christian.koenig@amd.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=harry.wentland@amd.com \
--cc=linux-kernel@vger.kernel.org \
--cc=siqueira@igalia.com \
--cc=sunpeng.li@amd.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®