From: Harry Wentland <harry.wentland@amd.com>
To: <dri-devel@lists.freedesktop.org>, <amd-gfx@lists.freedesktop.org>
Cc: Harry Wentland <harry.wentland@amd.com>,
Alex Hung <alex.hung@amd.com>,
Robert Mader <robert.mader@collabora.com>
Subject: [PATCH v5 06/10] drm/amd/display: Implement fixed matrix colorop color space mapping
Date: Fri, 31 Jul 2026 14:15:17 -0400 [thread overview]
Message-ID: <20260731181521.681990-7-harry.wentland@amd.com> (raw)
In-Reply-To: <20260731181521.681990-1-harry.wentland@amd.com>
Add __set_dm_plane_colorop_fixed_matrix() which maps the fixed matrix
type enum to the appropriate dc_color_space for DC programming:
YCBCR601_FULL_RGB -> COLOR_SPACE_YCBCR601
YCBCR601_LIMITED_RGB -> COLOR_SPACE_YCBCR601_LIMITED
YCBCR709_FULL_RGB -> COLOR_SPACE_YCBCR709
YCBCR709_LIMITED_RGB -> COLOR_SPACE_YCBCR709_LIMITED
YCBCR2020_FULL_RGB_NC -> COLOR_SPACE_2020_YCBCR_FULL
YCBCR2020_LIMITED_RGB_NC -> COLOR_SPACE_2020_YCBCR_LIMITED
When the fixed matrix is bypassed, color_space is set to
COLOR_SPACE_UNKNOWN.
Update amdgpu_dm_plane_set_colorop_properties() to process the
fixed matrix colorop first (before DEGAM), matching the new pipeline
order.
Assisted-by: Claude:claude-opus-4.6
Signed-off-by: Harry Wentland <harry.wentland@amd.com>
Reviewed-by: Alex Hung <alex.hung@amd.com>
Tested-by: Robert Mader <robert.mader@collabora.com>
---
.../amd/display/amdgpu_dm/amdgpu_dm_color.c | 68 ++++++++++++++++++-
1 file changed, 67 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.c
index 357c7c5c85cf..62791077ceef 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.c
@@ -1545,6 +1545,61 @@ __set_colorop_in_tf_1d_curve(struct dc_plane_state *dc_plane_state,
}
EXPORT_IF_KUNIT(__set_colorop_in_tf_1d_curve);
+static int
+__set_dm_plane_colorop_fixed_matrix(struct drm_plane_state *plane_state,
+ struct dc_plane_state *dc_plane_state,
+ struct drm_colorop *colorop)
+{
+ struct drm_colorop *old_colorop;
+ struct drm_colorop_state *colorop_state = NULL, *new_colorop_state;
+ struct drm_atomic_commit *state = plane_state->state;
+ int i = 0;
+
+ old_colorop = colorop;
+
+ for_each_new_colorop_in_state(state, colorop, new_colorop_state, i) {
+ if (new_colorop_state->colorop == old_colorop) {
+ colorop_state = new_colorop_state;
+ break;
+ }
+ }
+
+ if (!colorop_state)
+ return -EINVAL;
+
+ if (colorop_state->bypass) {
+ dc_plane_state->color_space = COLOR_SPACE_SRGB;
+ return 0;
+ }
+
+ switch (colorop_state->fixed_matrix_type) {
+ case DRM_COLOROP_FM_YCBCR601_FULL_RGB:
+ dc_plane_state->color_space = COLOR_SPACE_YCBCR601;
+ break;
+ case DRM_COLOROP_FM_YCBCR601_LIMITED_RGB:
+ dc_plane_state->color_space = COLOR_SPACE_YCBCR601_LIMITED;
+ break;
+ case DRM_COLOROP_FM_YCBCR709_FULL_RGB:
+ dc_plane_state->color_space = COLOR_SPACE_YCBCR709;
+ break;
+ case DRM_COLOROP_FM_YCBCR709_LIMITED_RGB:
+ dc_plane_state->color_space = COLOR_SPACE_YCBCR709_LIMITED;
+ break;
+ case DRM_COLOROP_FM_YCBCR2020_NC_FULL_RGB:
+ dc_plane_state->color_space = COLOR_SPACE_2020_YCBCR_FULL;
+ break;
+ case DRM_COLOROP_FM_YCBCR2020_NC_LIMITED_RGB:
+ dc_plane_state->color_space = COLOR_SPACE_2020_YCBCR_LIMITED;
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ dc_plane_state->update_bits.full_update = 1;
+
+ return 0;
+}
+
static int
__set_dm_plane_colorop_degamma(struct drm_plane_state *plane_state,
struct dc_plane_state *dc_plane_state,
@@ -1946,10 +2001,21 @@ amdgpu_dm_plane_set_colorop_properties(struct drm_plane_state *plane_state,
bool has_3dlut = adev->dm.dc->caps.color.dpp.hw_3d_lut || adev->dm.dc->caps.color.mpc.preblend;
int ret;
- /* 1D Curve - DEGAM TF */
+ /* Fixed Matrix (YUV to RGB) */
if (!colorop)
return -EINVAL;
+ ret = __set_dm_plane_colorop_fixed_matrix(plane_state, dc_plane_state, colorop);
+ if (ret)
+ return ret;
+
+ /* 1D Curve - DEGAM TF */
+ colorop = colorop->next;
+ if (!colorop) {
+ drm_dbg(dev, "no degamma colorop found\n");
+ return -EINVAL;
+ }
+
ret = __set_dm_plane_colorop_degamma(plane_state, dc_plane_state, colorop);
if (ret)
return ret;
--
2.55.0
next prev parent reply other threads:[~2026-07-31 18:15 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-31 18:15 [PATCH v5 00/10] YUV conversion colorop with amdgpu and VKMS Harry Wentland
2026-07-31 18:15 ` [PATCH v5 01/10] drm/colorop: Add DRM_COLOROP_FIXED_MATRIX Harry Wentland
2026-07-31 18:15 ` [PATCH v5 02/10] drm/vkms: Fix limited-range YCbCr to RGB conversion scaling Harry Wentland
2026-07-31 18:15 ` [PATCH v5 03/10] drm/vkms: Add fixed matrix colorop to color pipeline Harry Wentland
2026-07-31 18:15 ` [PATCH v5 04/10] drm/vkms: Add atomic check and matrix handling for fixed matrix colorop Harry Wentland
2026-07-31 18:15 ` [PATCH v5 05/10] drm/amd/display: Add fixed matrix colorop to color pipeline Harry Wentland
2026-07-31 18:15 ` Harry Wentland [this message]
2026-07-31 18:15 ` [PATCH v5 07/10] drm/amd/display: Use GAMCOR for first TF if YUV conversion is needed Harry Wentland
2026-07-31 18:15 ` [PATCH v5 08/10] drm/amd/display: Check actual state during commit_tail Harry Wentland
2026-07-31 18:15 ` [PATCH v5 09/10] drm/amd/display: Set color_space to plane_infos Harry Wentland
2026-07-31 18:15 ` [PATCH v5 10/10] drm/amd/display: Force GAMCOR for subsampled surfaces with PQ/Gamma22/HLG Harry Wentland
2026-08-01 9:42 ` [PATCH v5 00/10] YUV conversion colorop with amdgpu and VKMS Robert Mader
2026-08-14 19:33 ` Harry Wentland
2026-08-14 20:03 ` Robert Mader
2026-08-14 20:31 ` Harry Wentland
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=20260731181521.681990-7-harry.wentland@amd.com \
--to=harry.wentland@amd.com \
--cc=alex.hung@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=robert.mader@collabora.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.