From: Andreas Baierl <ich...@imkreisrum.de> There is some bogus code, which calculates the variable bright four times. This typo is corrected.
The code also checks for a valid input value (0-100) and calculates the correct (rounded) value for bright, contrast, saturation and hue in the needed range 0-63. Changes since v1: Use macro DIV_ROUND_CLOSEST for rounding. Check for valid parameter values (0-100). Signed-off-by: Andreas Baierl <ich...@imkreisrum.de> --- drivers/video/sunxi/disp/de_fe.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/video/sunxi/disp/de_fe.c b/drivers/video/sunxi/disp/de_fe.c index 92799a0..0ec7bc9 100644 --- a/drivers/video/sunxi/disp/de_fe.c +++ b/drivers/video/sunxi/disp/de_fe.c @@ -1382,10 +1382,10 @@ __s32 DE_SCAL_Set_CSC_Coef_Enhance(__u8 sel, __u8 in_csc_mode, __u32 i; __s32 sinv, cosv; /* sin_tab: 7 bit fractional */ - bright = bright * 64 / 100; - bright = saturation * 64 / 100; - bright = contrast * 64 / 100; - bright = hue * 64 / 100; + bright = bright < 0 ? 0 : (bright > 100 ? 63 : DIV_ROUND_CLOSEST((bright * 63), 100)); + saturation = saturation < 0 ? 0 : (saturation > 100 ? 63 : DIV_ROUND_CLOSEST((saturation * 63), 100)); + contrast = contrast < 0 ? 0 : (contrast > 100 ? 63 : DIV_ROUND_CLOSEST((contrast * 63), 100)); + hue = hue < 0 ? 0 : (hue > 100 ? 63 : DIV_ROUND_CLOSEST((hue * 63), 100)); sinv = image_enhance_tab[8 * 12 + (hue & 0x3f)]; cosv = image_enhance_tab[8 * 12 + 8 * 8 + (hue & 0x3f)]; -- 2.1.4 -- You received this message because you are subscribed to the Google Groups "linux-sunxi" group. To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.