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.

Assisted-by: Claude:claude-sonnet-4.5
Signed-off-by: Harry Wentland <[email protected]>
---
 .../amd/display/amdgpu_dm/amdgpu_dm_color.c   | 23 +++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)

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 c54ca5188f68..561ee9a2e749 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
@@ -1454,11 +1454,15 @@ __set_dm_plane_degamma(struct drm_plane_state 
*plane_state,
                if (ret)
                        return ret;
        } else {
+               bool is_subsampled =
+                       dc_plane_state->format >= 
SURFACE_PIXEL_FORMAT_VIDEO_BEGIN &&
+                       dc_plane_state->format < 
SURFACE_PIXEL_FORMAT_SUBSAMPLE_END;
+
                dc_plane_state->in_transfer_func.type =
                        TF_TYPE_PREDEFINED;
 
                if (!mod_color_calculate_degamma_params(color_caps,
-                   &dc_plane_state->in_transfer_func, NULL, false))
+                   &dc_plane_state->in_transfer_func, NULL, is_subsampled))
                        return -ENOMEM;
        }
        return 0;
@@ -1471,6 +1475,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;
@@ -1485,10 +1491,23 @@ __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;
+
+       /* 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 (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,
+                                               is_subsampled_format)) {
+               drm_err(drm, "Failed to calculate degamma params\n");
+               return -EINVAL;
+       }
+
        return 0;
 }
 
-- 
2.54.0

Reply via email to