]> www.infradead.org Git - users/hch/misc.git/commitdiff
drm/amd/display: Handle interpolation for first data point
authorMario Limonciello <mario.limonciello@amd.com>
Thu, 4 Sep 2025 18:49:35 +0000 (13:49 -0500)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 23 Sep 2025 14:26:56 +0000 (10:26 -0400)
[Why]
If the first data point for a custom brightness curve is not 0% luminance
then the first few luminance values will be ignored.

[How]
Check signal is below first data point and if so do linear interpolation to
0 instead.

Reviewed-by: Alex Hung <alex.hung@amd.com>
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
Signed-off-by: Ivan Lipski <ivan.lipski@amd.com>
Tested-by: Dan Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c

index 09427e0560559a29f291e8b99e42941f377fa77e..271ea161517822cd2b051c40cac58cc9ae53c967 100644 (file)
@@ -4828,6 +4828,16 @@ static void convert_custom_brightness(const struct amdgpu_dm_backlight_caps *cap
        if (!caps->data_points)
                return;
 
+       /*
+        * Handle the case where brightness is below the first data point
+        * Interpolate between (0,0) and (first_signal, first_lum)
+        */
+       if (brightness < caps->luminance_data[0].input_signal) {
+               lum = DIV_ROUND_CLOSEST(caps->luminance_data[0].luminance * brightness,
+                                       caps->luminance_data[0].input_signal);
+               goto scale;
+       }
+
        left = 0;
        right = caps->data_points - 1;
        while (left <= right) {