]> git.itanic.dy.fi Git - linux-stable/blobdiff - drivers/gpu/drm/amd/display/modules/color/color_gamma.c
drm/amd/display: Limit user regamma to a valid value
[linux-stable] / drivers / gpu / drm / amd / display / modules / color / color_gamma.c
index 64a38f08f49741a468b30e6f046c0cf1e6e26bab..5a51be753e87f9131fab27c9392fe024803cb857 100644 (file)
@@ -1603,6 +1603,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 */
@@ -1631,6 +1632,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)