media: tc358746: fix the pll calculating function
authorDuc-Long, Le <duclong.linux@gmail.com>
Sun, 15 Oct 2023 00:19:46 +0000 (20:19 -0400)
committerHans Verkuil <hverkuil-cisco@xs4all.nl>
Mon, 5 Feb 2024 11:57:44 +0000 (12:57 +0100)
Following formula of Pll_clk in 5.2 section, 50th page of
TC358746AXBG/748XBG/748IXBG Functional Specification Rev 1.1 document.
The formula of fout is as below:
fout = refclk * mul / (prediv * postdiv)

Remove "p" to avoid using 2 times of prediv in pll calculating function.

Signed-off-by: Duc-Long, Le <duclong.linux@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
drivers/media/i2c/tc358746.c

index 106de4271d2ef94533e5797ac30bd4dd6aa1df93..d676adc4401bb5094be17bec25e54dfc7113d251 100644 (file)
@@ -843,14 +843,14 @@ static unsigned long tc358746_find_pll_settings(struct tc358746 *tc358746,
                if (fin < 4 * HZ_PER_MHZ || fin > 40 * HZ_PER_MHZ)
                        continue;
 
-               tmp = fout * p * postdiv;
+               tmp = fout * postdiv;
                do_div(tmp, fin);
                mul = tmp;
                if (mul > 511)
                        continue;
 
                tmp = mul * fin;
-               do_div(tmp, p * postdiv);
+               do_div(tmp, postdiv);
 
                delta = abs(fout - tmp);
                if (delta < min_delta) {