]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
drm/amd/display: Disable CRTC degamma LUT for DCN401
authorMelissa Wen <mwen@igalia.com>
Mon, 7 Jul 2025 20:52:05 +0000 (16:52 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 16 Jul 2025 20:47:43 +0000 (16:47 -0400)
In DCN401 pre-blending degamma LUT isn't affecting cursor as in previous
DCN version. As this is not the behavior close to what is expected for
CRTC degamma LUT, disable CRTC degamma LUT property in this HW.

Link: https://gitlab.freedesktop.org/drm/amd/-/issues/4176
---

When enabling HDR on KDE, it takes the first CRTC 1D LUT available and
apply a color transformation (Gamma 2.2 -> PQ). AMD driver usually
advertises a CRTC degamma LUT as the first CRTC 1D LUT, but it's
actually applied pre-blending. In previous HW version, it seems to work
fine because the 1D LUT was applied to cursor too, but DCN401 presents a
different behavior and the 1D LUT isn't affecting the hardware cursor.

To address the wrong gamma on cursor with HDR (see the link), I came up
with this patch that disables CRTC degamma LUT in this hw, since it
presents a different behavior than others. With this KDE sees CRTC
regamma LUT as the first post-blending 1D LUT available. This is
actually more consistent with AMD color pipeline. It was tested by the
reporter, since I don't have the HW available for local testing and
debugging.

Melissa
---

Reviewed-by: Harry Wentland <harry.wentland@amd.com>
Signed-off-by: Melissa Wen <mwen@igalia.com>
Signed-off-by: Ivan Lipski <ivan.lipski@amd.com>
Tested-by: Daniel Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit 340231cdceec2c45995d773a358ca3c341f151aa)
Cc: stable@vger.kernel.org
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_crtc.c

index 87058271b00cc493737e60004ce3d5548f8c89b3..2551823382f8b6c17b45fe97fe51a587ad8c427f 100644 (file)
@@ -728,7 +728,16 @@ int amdgpu_dm_crtc_init(struct amdgpu_display_manager *dm,
         * support programmable degamma anywhere.
         */
        is_dcn = dm->adev->dm.dc->caps.color.dpp.dcn_arch;
-       drm_crtc_enable_color_mgmt(&acrtc->base, is_dcn ? MAX_COLOR_LUT_ENTRIES : 0,
+       /* Dont't enable DRM CRTC degamma property for DCN401 since the
+        * pre-blending degamma LUT doesn't apply to cursor, and therefore
+        * can't work similar to a post-blending degamma LUT as in other hw
+        * versions.
+        * TODO: revisit it once KMS plane color API is merged.
+        */
+       drm_crtc_enable_color_mgmt(&acrtc->base,
+                                  (is_dcn &&
+                                   dm->adev->dm.dc->ctx->dce_version != DCN_VERSION_4_01) ?
+                                    MAX_COLOR_LUT_ENTRIES : 0,
                                   true, MAX_COLOR_LUT_ENTRIES);
 
        drm_mode_crtc_set_gamma_size(&acrtc->base, MAX_COLOR_LEGACY_LUT_ENTRIES);