提交 04ee6d92 编写于 作者: J Javier Martin 提交者: Mauro Carvalho Chehab

[media] media: ov7670: add possibility to bypass pll for ov7675

For a frame rate of 30 fps a pixclk of 24MHz is needed. For those
cases where the ov7670 has a clean 24MHz input (xvclk) the PLL
can be bypassed.
This will result in a value of clkrc of 1, which means that in practice
pixclk = xvclk (input clock)
Acked-by: NJonathan Corbet <corbet@lwn.net>
Signed-off-by: NJavier Martin <javier.martin@vista-silicon.com>
Signed-off-by: NMauro Carvalho Chehab <mchehab@redhat.com>
上级 f6dd927f
...@@ -230,6 +230,7 @@ struct ov7670_info { ...@@ -230,6 +230,7 @@ struct ov7670_info {
int clock_speed; /* External clock speed (MHz) */ int clock_speed; /* External clock speed (MHz) */
u8 clkrc; /* Clock divider value */ u8 clkrc; /* Clock divider value */
bool use_smbus; /* Use smbus I/O instead of I2C */ bool use_smbus; /* Use smbus I/O instead of I2C */
bool pll_bypass;
const struct ov7670_devtype *devtype; /* Device specifics */ const struct ov7670_devtype *devtype; /* Device specifics */
}; };
...@@ -755,7 +756,12 @@ static void ov7675_get_framerate(struct v4l2_subdev *sd, ...@@ -755,7 +756,12 @@ static void ov7675_get_framerate(struct v4l2_subdev *sd,
{ {
struct ov7670_info *info = to_state(sd); struct ov7670_info *info = to_state(sd);
u32 clkrc = info->clkrc; u32 clkrc = info->clkrc;
u32 pll_factor = PLL_FACTOR; int pll_factor;
if (info->pll_bypass)
pll_factor = 1;
else
pll_factor = PLL_FACTOR;
clkrc++; clkrc++;
if (info->fmt->mbus_code == V4L2_MBUS_FMT_SBGGR8_1X8) if (info->fmt->mbus_code == V4L2_MBUS_FMT_SBGGR8_1X8)
...@@ -771,7 +777,7 @@ static int ov7675_set_framerate(struct v4l2_subdev *sd, ...@@ -771,7 +777,7 @@ static int ov7675_set_framerate(struct v4l2_subdev *sd,
{ {
struct ov7670_info *info = to_state(sd); struct ov7670_info *info = to_state(sd);
u32 clkrc; u32 clkrc;
u32 pll_factor = PLL_FACTOR; int pll_factor;
int ret; int ret;
/* /*
...@@ -781,6 +787,16 @@ static int ov7675_set_framerate(struct v4l2_subdev *sd, ...@@ -781,6 +787,16 @@ static int ov7675_set_framerate(struct v4l2_subdev *sd,
* pixclk = clock_speed / (clkrc + 1) * PLLfactor * pixclk = clock_speed / (clkrc + 1) * PLLfactor
* *
*/ */
if (info->pll_bypass) {
pll_factor = 1;
ret = ov7670_write(sd, REG_DBLV, DBLV_BYPASS);
} else {
pll_factor = PLL_FACTOR;
ret = ov7670_write(sd, REG_DBLV, DBLV_X4);
}
if (ret < 0)
return ret;
if (tpf->numerator == 0 || tpf->denominator == 0) { if (tpf->numerator == 0 || tpf->denominator == 0) {
clkrc = 0; clkrc = 0;
} else { } else {
...@@ -808,6 +824,7 @@ static int ov7675_set_framerate(struct v4l2_subdev *sd, ...@@ -808,6 +824,7 @@ static int ov7675_set_framerate(struct v4l2_subdev *sd,
ret = ov7670_write(sd, REG_CLKRC, info->clkrc); ret = ov7670_write(sd, REG_CLKRC, info->clkrc);
if (ret < 0) if (ret < 0)
return ret; return ret;
return ov7670_write(sd, REG_DBLV, DBLV_X4); return ov7670_write(sd, REG_DBLV, DBLV_X4);
} }
...@@ -1688,6 +1705,13 @@ static int ov7670_probe(struct i2c_client *client, ...@@ -1688,6 +1705,13 @@ static int ov7670_probe(struct i2c_client *client,
if (config->clock_speed) if (config->clock_speed)
info->clock_speed = config->clock_speed; info->clock_speed = config->clock_speed;
/*
* It should be allowed for ov7670 too when it is migrated to
* the new frame rate formula.
*/
if (config->pll_bypass && id->driver_data != MODEL_OV7670)
info->pll_bypass = true;
} }
/* Make sure it's an ov7670 */ /* Make sure it's an ov7670 */
......
...@@ -15,6 +15,7 @@ struct ov7670_config { ...@@ -15,6 +15,7 @@ struct ov7670_config {
int min_height; /* Filter out smaller sizes */ int min_height; /* Filter out smaller sizes */
int clock_speed; /* External clock speed (MHz) */ int clock_speed; /* External clock speed (MHz) */
bool use_smbus; /* Use smbus I/O instead of I2C */ bool use_smbus; /* Use smbus I/O instead of I2C */
bool pll_bypass; /* Choose whether to bypass the PLL */
}; };
#endif #endif
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册