drm/amd/display: handle empty LUTs in __set_input_tf
authorJoshua Ashton <joshua@froggi.es>
Thu, 16 Nov 2023 19:58:06 +0000 (18:58 -0100)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 14 Dec 2023 20:25:24 +0000 (15:25 -0500)
Unlike degamma, blend gamma doesn't support hardcoded curve
(predefined/ROM), but we can use AMD color module to fill blend gamma
parameters when we have non-linear plane gamma TF without plane gamma
LUT. The regular degamma path doesn't hit this.

Reviewed-by: Harry Wentland <harry.wentland@amd.com>
Signed-off-by: Joshua Ashton <joshua@froggi.es>
Signed-off-by: Melissa Wen <mwen@igalia.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.c

index f55e0a6..7383995 100644 (file)
@@ -578,17 +578,21 @@ static int __set_input_tf(struct dc_transfer_func *func,
        struct dc_gamma *gamma = NULL;
        bool res;
 
-       gamma = dc_create_gamma();
-       if (!gamma)
-               return -ENOMEM;
+       if (lut_size) {
+               gamma = dc_create_gamma();
+               if (!gamma)
+                       return -ENOMEM;
 
-       gamma->type = GAMMA_CUSTOM;
-       gamma->num_entries = lut_size;
+               gamma->type = GAMMA_CUSTOM;
+               gamma->num_entries = lut_size;
 
-       __drm_lut_to_dc_gamma(lut, gamma, false);
+               __drm_lut_to_dc_gamma(lut, gamma, false);
+       }
 
-       res = mod_color_calculate_degamma_params(NULL, func, gamma, true);
-       dc_gamma_release(&gamma);
+       res = mod_color_calculate_degamma_params(NULL, func, gamma, gamma != NULL);
+
+       if (gamma)
+               dc_gamma_release(&gamma);
 
        return res ? 0 : -ENOMEM;
 }