drm/amd/display: Limit user regamma to a valid value
authorjsg <jsg@openbsd.org>
Mon, 3 Oct 2022 11:52:57 +0000 (11:52 +0000)
committerjsg <jsg@openbsd.org>
Mon, 3 Oct 2022 11:52:57 +0000 (11:52 +0000)
From Yao Wang1
a541c011181823494c53b15020fae5c3b45f5ec2 in linux 5.15.y/5.15.71
3601d620f22e37740cf73f8278eabf9f2aa19eb7 in mainline linux

sys/dev/pci/drm/amd/display/modules/color/color_gamma.c

index ef742d9..c707c9b 100644 (file)
@@ -1597,6 +1597,7 @@ static void interpolate_user_regamma(uint32_t hw_points_num,
        struct fixed31_32 lut2;
        struct fixed31_32 delta_lut;
        struct fixed31_32 delta_index;
+       const struct fixed31_32 one = dc_fixpt_from_int(1);
 
        i = 0;
        /* fixed_pt library has problems handling too small values */
@@ -1625,6 +1626,9 @@ static void interpolate_user_regamma(uint32_t hw_points_num,
                        } else
                                hw_x = coordinates_x[i].x;
 
+                       if (dc_fixpt_le(one, hw_x))
+                               hw_x = one;
+
                        norm_x = dc_fixpt_mul(norm_factor, hw_x);
                        index = dc_fixpt_floor(norm_x);
                        if (index < 0 || index > 255)