diff options
author | Javier Martin <javier.martin@vista-silicon.com> | 2013-01-29 05:23:42 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2013-02-08 11:30:48 -0500 |
commit | 04ee6d92047e1ac68d4eb615119343f4f0fc57db (patch) | |
tree | 4862760c13c38aa3c6dd96a4ab7a01bc9eb8e7c9 /drivers/media | |
parent | f6dd927f34d64014c4b196132b5cdf9f2e2a3ae5 (diff) |
[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: Jonathan Corbet <corbet@lwn.net>
Signed-off-by: Javier Martin <javier.martin@vista-silicon.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media')
-rw-r--r-- | drivers/media/i2c/ov7670.c | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/drivers/media/i2c/ov7670.c b/drivers/media/i2c/ov7670.c index dea2917a2b12..3e503396aaa4 100644 --- a/drivers/media/i2c/ov7670.c +++ b/drivers/media/i2c/ov7670.c | |||
@@ -230,6 +230,7 @@ struct ov7670_info { | |||
230 | int clock_speed; /* External clock speed (MHz) */ | 230 | int clock_speed; /* External clock speed (MHz) */ |
231 | u8 clkrc; /* Clock divider value */ | 231 | u8 clkrc; /* Clock divider value */ |
232 | bool use_smbus; /* Use smbus I/O instead of I2C */ | 232 | bool use_smbus; /* Use smbus I/O instead of I2C */ |
233 | bool pll_bypass; | ||
233 | const struct ov7670_devtype *devtype; /* Device specifics */ | 234 | const struct ov7670_devtype *devtype; /* Device specifics */ |
234 | }; | 235 | }; |
235 | 236 | ||
@@ -755,7 +756,12 @@ static void ov7675_get_framerate(struct v4l2_subdev *sd, | |||
755 | { | 756 | { |
756 | struct ov7670_info *info = to_state(sd); | 757 | struct ov7670_info *info = to_state(sd); |
757 | u32 clkrc = info->clkrc; | 758 | u32 clkrc = info->clkrc; |
758 | u32 pll_factor = PLL_FACTOR; | 759 | int pll_factor; |
760 | |||
761 | if (info->pll_bypass) | ||
762 | pll_factor = 1; | ||
763 | else | ||
764 | pll_factor = PLL_FACTOR; | ||
759 | 765 | ||
760 | clkrc++; | 766 | clkrc++; |
761 | if (info->fmt->mbus_code == V4L2_MBUS_FMT_SBGGR8_1X8) | 767 | if (info->fmt->mbus_code == V4L2_MBUS_FMT_SBGGR8_1X8) |
@@ -771,7 +777,7 @@ static int ov7675_set_framerate(struct v4l2_subdev *sd, | |||
771 | { | 777 | { |
772 | struct ov7670_info *info = to_state(sd); | 778 | struct ov7670_info *info = to_state(sd); |
773 | u32 clkrc; | 779 | u32 clkrc; |
774 | u32 pll_factor = PLL_FACTOR; | 780 | int pll_factor; |
775 | int ret; | 781 | int ret; |
776 | 782 | ||
777 | /* | 783 | /* |
@@ -781,6 +787,16 @@ static int ov7675_set_framerate(struct v4l2_subdev *sd, | |||
781 | * pixclk = clock_speed / (clkrc + 1) * PLLfactor | 787 | * pixclk = clock_speed / (clkrc + 1) * PLLfactor |
782 | * | 788 | * |
783 | */ | 789 | */ |
790 | if (info->pll_bypass) { | ||
791 | pll_factor = 1; | ||
792 | ret = ov7670_write(sd, REG_DBLV, DBLV_BYPASS); | ||
793 | } else { | ||
794 | pll_factor = PLL_FACTOR; | ||
795 | ret = ov7670_write(sd, REG_DBLV, DBLV_X4); | ||
796 | } | ||
797 | if (ret < 0) | ||
798 | return ret; | ||
799 | |||
784 | if (tpf->numerator == 0 || tpf->denominator == 0) { | 800 | if (tpf->numerator == 0 || tpf->denominator == 0) { |
785 | clkrc = 0; | 801 | clkrc = 0; |
786 | } else { | 802 | } else { |
@@ -808,6 +824,7 @@ static int ov7675_set_framerate(struct v4l2_subdev *sd, | |||
808 | ret = ov7670_write(sd, REG_CLKRC, info->clkrc); | 824 | ret = ov7670_write(sd, REG_CLKRC, info->clkrc); |
809 | if (ret < 0) | 825 | if (ret < 0) |
810 | return ret; | 826 | return ret; |
827 | |||
811 | return ov7670_write(sd, REG_DBLV, DBLV_X4); | 828 | return ov7670_write(sd, REG_DBLV, DBLV_X4); |
812 | } | 829 | } |
813 | 830 | ||
@@ -1688,6 +1705,13 @@ static int ov7670_probe(struct i2c_client *client, | |||
1688 | 1705 | ||
1689 | if (config->clock_speed) | 1706 | if (config->clock_speed) |
1690 | info->clock_speed = config->clock_speed; | 1707 | info->clock_speed = config->clock_speed; |
1708 | |||
1709 | /* | ||
1710 | * It should be allowed for ov7670 too when it is migrated to | ||
1711 | * the new frame rate formula. | ||
1712 | */ | ||
1713 | if (config->pll_bypass && id->driver_data != MODEL_OV7670) | ||
1714 | info->pll_bypass = true; | ||
1691 | } | 1715 | } |
1692 | 1716 | ||
1693 | /* Make sure it's an ov7670 */ | 1717 | /* Make sure it's an ov7670 */ |