Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

media: mt9p031: Read back the real clock rate

The real and requested clock can differ and because it is used to
calculate PLL values, the real clock rate should be read.

Signed-off-by: Enrico Scholz <enrico.scholz@sigma-chemnitz.de>
Signed-off-by: Stefan Riedmueller <s.riedmueller@phytec.de>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>

authored by

Enrico Scholz and committed by
Mauro Carvalho Chehab
b9c18096 10aacfec

+6 -3
+6 -3
drivers/media/i2c/mt9p031.c
··· 229 229 230 230 struct i2c_client *client = v4l2_get_subdevdata(&mt9p031->subdev); 231 231 struct mt9p031_platform_data *pdata = mt9p031->pdata; 232 + unsigned long ext_freq; 232 233 int ret; 233 234 234 235 mt9p031->clk = devm_clk_get(&client->dev, NULL); ··· 240 239 if (ret < 0) 241 240 return ret; 242 241 242 + ext_freq = clk_get_rate(mt9p031->clk); 243 + 243 244 /* If the external clock frequency is out of bounds for the PLL use the 244 245 * pixel clock divider only and disable the PLL. 245 246 */ 246 - if (pdata->ext_freq > limits.ext_clock_max) { 247 + if (ext_freq > limits.ext_clock_max) { 247 248 unsigned int div; 248 249 249 - div = DIV_ROUND_UP(pdata->ext_freq, pdata->target_freq); 250 + div = DIV_ROUND_UP(ext_freq, pdata->target_freq); 250 251 div = roundup_pow_of_two(div) / 2; 251 252 252 253 mt9p031->clk_div = min_t(unsigned int, div, 64); ··· 257 254 return 0; 258 255 } 259 256 260 - mt9p031->pll.ext_clock = pdata->ext_freq; 257 + mt9p031->pll.ext_clock = ext_freq; 261 258 mt9p031->pll.pix_clock = pdata->target_freq; 262 259 mt9p031->use_pll = true; 263 260