summaryrefslogtreecommitdiffstats
path: root/drivers/media/i2c
diff options
context:
space:
mode:
authorSakari Ailus <sakari.ailus@linux.intel.com>2020-09-15 21:04:26 +0200
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>2020-12-07 16:03:26 +0100
commit36154b68b8d9c4a3d771c0d2c58be03927350480 (patch)
tree92659c5555c6265378e698aedf9509353bfb47f0 /drivers/media/i2c
parent594f1e93bb2c48bcc14a020448b46eed15be7ef7 (diff)
downloadlinux-36154b68b8d9c4a3d771c0d2c58be03927350480.tar.gz
linux-36154b68b8d9c4a3d771c0d2c58be03927350480.tar.bz2
linux-36154b68b8d9c4a3d771c0d2c58be03927350480.zip
media: ccs-pll: Fix VT post-PLL divisor calculation
The PLL calculator only searched even total divisor values apart from one, but this is wrong: the total divisor is odd in cases where system divisor is one. Fix this by including odd total PLL values where system divisor is one to the search. Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Diffstat (limited to 'drivers/media/i2c')
-rw-r--r--drivers/media/i2c/ccs-pll.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/drivers/media/i2c/ccs-pll.c b/drivers/media/i2c/ccs-pll.c
index 7512f0313010..4321989b9013 100644
--- a/drivers/media/i2c/ccs-pll.c
+++ b/drivers/media/i2c/ccs-pll.c
@@ -347,14 +347,16 @@ ccs_pll_calculate_vt(struct device *dev, const struct ccs_pll_limits *lim,
* into a value which is not smaller than div, the desired
* divisor.
*/
- for (vt_div = min_vt_div; vt_div <= max_vt_div;
- vt_div += 2 - (vt_div & 1)) {
- for (sys_div = min_sys_div;
- sys_div <= max_sys_div;
+ for (vt_div = min_vt_div; vt_div <= max_vt_div; vt_div++) {
+ uint16_t __max_sys_div = vt_div & 1 ? 1 : max_sys_div;
+
+ for (sys_div = min_sys_div; sys_div <= __max_sys_div;
sys_div += 2 - (sys_div & 1)) {
- uint16_t pix_div = DIV_ROUND_UP(vt_div, sys_div);
+ uint16_t pix_div;
uint16_t rounded_div;
+ pix_div = DIV_ROUND_UP(vt_div, sys_div);
+
if (pix_div < lim->vt_bk.min_pix_clk_div
|| pix_div > lim->vt_bk.max_pix_clk_div) {
dev_dbg(dev,