From: Alex Hung <alex.hung@amd.com>
To: Harry Wentland <harry.wentland@amd.com>,
dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org
Subject: Re: [RFC PATCH v2 7/9] drm/amd/display: Use GAMCOR for first TF if CSC is used
Date: Tue, 21 Apr 2026 15:08:57 -0600 [thread overview]
Message-ID: <92964f38-2691-4795-a064-de67301ffc6d@amd.com> (raw)
In-Reply-To: <20260330153451.99472-8-harry.wentland@amd.com>
On 3/30/26 09:34, Harry Wentland wrote:
> For subsampled formats we need to use GAMCOR instead of
> the DEGAM block. The color module can create a LUT for
> that if we set map_user_ramp to true. So do that when
> we have subsampled formats.
>
> Co-developed by Claude Sonnet 4.5.
This should be updated to "Assisted-by Claude:claude-Sonnet-4.5"
>
> Signed-off-by: Harry Wentland <harry.wentland@amd.com>
> ---
> .../amd/display/amdgpu_dm/amdgpu_dm_color.c | 34 ++++++++++++++++++-
> 1 file changed, 33 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 d5b4190e635c..6403dfe4ee10 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
> @@ -1471,6 +1471,8 @@ __set_colorop_in_tf_1d_curve(struct dc_plane_state *dc_plane_state,
> struct dc_transfer_func *tf = &dc_plane_state->in_transfer_func;
> struct drm_colorop *colorop = colorop_state->colorop;
> struct drm_device *drm = colorop->dev;
> + struct dc_color_caps *color_caps = NULL;
> + bool is_subsampled_format;
>
> if (colorop->type != DRM_COLOROP_1D_CURVE)
> return -EINVAL;
> @@ -1486,9 +1488,39 @@ __set_colorop_in_tf_1d_curve(struct dc_plane_state *dc_plane_state,
>
> drm_dbg(drm, "Degamma colorop with ID: %d\n", colorop->base.id);
>
> - tf->type = TF_TYPE_PREDEFINED;
Setting tf-type is moved to the below if-else branch, but both set
tf->type = TF_TYPE_PREDEFINED. Is this done intentionally to improve
readability or for other purposes?
> + /* Check if format requires post-scale color processing (subsampled formats) */
> + is_subsampled_format = (dc_plane_state->format >= SURFACE_PIXEL_FORMAT_VIDEO_BEGIN &&
> + dc_plane_state->format < SURFACE_PIXEL_FORMAT_SUBSAMPLE_END);
> +
> tf->tf = amdgpu_colorop_tf_to_dc_tf(colorop_state->curve_1d_type);
>
> + if (is_subsampled_format) {
> + /*
> + * For subsampled formats (P010, NV12), we need color processing
> + * to happen AFTER scaling (to expand UV channels first).
> + * Convert predefined TF to PWL so DC will use GAMCOR (post-scale)
> + * instead of PRE_DEGAM (pre-scale).
> + *
> + * IMPORTANT: We must pass map_user_ramp=true to force PWL conversion.
> + * Without it, mod_color_calculate_degamma_params() returns early for
> + * SRGB/Linear TFs without converting to TF_TYPE_DISTRIBUTED_POINTS.
> + */
> + tf->type = TF_TYPE_PREDEFINED;
> +
> + if (dc_plane_state->ctx && dc_plane_state->ctx->dc)
> + color_caps = &dc_plane_state->ctx->dc->caps.color;
> +
> + if (!mod_color_calculate_degamma_params(color_caps, tf, NULL, true)) {
> + drm_err(drm, "Failed to calculate degamma params for subsampled format\n");
> + return -EINVAL;
> + }
> +
> + /* mod_color_calculate_degamma_params sets tf->type to TF_TYPE_DISTRIBUTED_POINTS */
> + } else {
> + /* For non-subsampled formats (RGB, XR30), use predefined ROM LUT (PRE_DEGAM) */
> + tf->type = TF_TYPE_PREDEFINED;
> + }
> +
> return 0;
> }
>
next prev parent reply other threads:[~2026-04-21 21:09 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-30 15:34 [RFC PATCH v2 0/9] YUV conversion colorop with amdgpu and VKMS Harry Wentland
2026-03-30 15:34 ` [RFC PATCH v2 1/9] drm/colorop: Add DRM_COLOROP_CSC_FF Harry Wentland
2026-04-08 11:31 ` Borah, Chaitanya Kumar
2026-03-30 15:34 ` [RFC PATCH v2 2/9] drm/colorop: Add limited-range YUV-to-RGB CSC FF enum values Harry Wentland
2026-04-21 21:22 ` Alex Hung
2026-04-23 9:34 ` Borah, Chaitanya Kumar
2026-04-30 18:19 ` Harry Wentland
2026-05-05 10:17 ` Borah, Chaitanya Kumar
2026-03-30 15:34 ` [RFC PATCH v2 3/9] drm/vkms: Add CSC FF colorop to color pipeline Harry Wentland
2026-04-21 21:21 ` Alex Hung
2026-03-30 15:34 ` [RFC PATCH v2 4/9] drm/vkms: Add atomic check and matrix handling for CSC FF colorop Harry Wentland
2026-04-21 21:20 ` Alex Hung
2026-03-30 15:34 ` [RFC PATCH v2 5/9] drm/amd/display: Add CSC FF colorop to color pipeline Harry Wentland
2026-04-21 21:14 ` Alex Hung
2026-03-30 15:34 ` [RFC PATCH v2 6/9] drm/amd/display: Implement CSC FF colorop color space mapping Harry Wentland
2026-04-21 21:13 ` Alex Hung
2026-03-30 15:34 ` [RFC PATCH v2 7/9] drm/amd/display: Use GAMCOR for first TF if CSC is used Harry Wentland
2026-04-21 21:08 ` Alex Hung [this message]
2026-04-30 20:43 ` Harry Wentland
2026-04-24 14:48 ` Melissa Wen
2026-03-30 15:34 ` [RFC PATCH v2 8/9] drm/amd/display: Check actual state during commit_tail Harry Wentland
2026-04-21 21:12 ` Alex Hung
2026-05-01 16:03 ` Harry Wentland
2026-03-30 15:34 ` [RFC PATCH v2 9/9] drm/amd/display: Set color_space to plane_infos Harry Wentland
2026-04-21 21:23 ` Alex Hung
2026-04-22 21:40 ` [RFC PATCH v2 0/9] YUV conversion colorop with amdgpu and VKMS Melissa Wen
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=92964f38-2691-4795-a064-de67301ffc6d@amd.com \
--to=alex.hung@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=harry.wentland@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