]> git.karo-electronics.de Git - linux-beck.git/commitdiff
OMAPDSS: DISPC: fix 64 bit issue in 5-tap
authorTomi Valkeinen <tomi.valkeinen@ti.com>
Fri, 10 Apr 2015 09:48:36 +0000 (12:48 +0300)
committerTomi Valkeinen <tomi.valkeinen@ti.com>
Wed, 17 Jun 2015 12:44:28 +0000 (15:44 +0300)
The DISPC driver uses 64 bit arithmetic to calculate the required clock
rate for scaling. The code does not seem to work correctly, and instead
calculates with 32 bit numbers, giving wrong result.

Fix the code by typecasting values to u64 first, so that the
calculations do happen in 64 bits.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
drivers/video/fbdev/omap2/dss/dispc.c

index 4488d9367bd3ba60880dec710993d0dcc7577ef6..2db1c986e989f9f56fb62712c16a1ab9ae3a9972 100644 (file)
@@ -2166,7 +2166,7 @@ static unsigned long calc_core_clk_five_taps(unsigned long pclk,
        if (height > out_height) {
                unsigned int ppl = mgr_timings->x_res;
 
-               tmp = pclk * height * out_width;
+               tmp = (u64)pclk * height * out_width;
                do_div(tmp, 2 * out_height * ppl);
                core_clk = tmp;
 
@@ -2174,14 +2174,14 @@ static unsigned long calc_core_clk_five_taps(unsigned long pclk,
                        if (ppl == out_width)
                                return 0;
 
-                       tmp = pclk * (height - 2 * out_height) * out_width;
+                       tmp = (u64)pclk * (height - 2 * out_height) * out_width;
                        do_div(tmp, 2 * out_height * (ppl - out_width));
                        core_clk = max_t(u32, core_clk, tmp);
                }
        }
 
        if (width > out_width) {
-               tmp = pclk * width;
+               tmp = (u64)pclk * width;
                do_div(tmp, out_width);
                core_clk = max_t(u32, core_clk, tmp);