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

[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>

authored by

Javier Martin and committed by
Mauro Carvalho Chehab
04ee6d92 f6dd927f

+27 -2
+26 -2
drivers/media/i2c/ov7670.c
··· 230 230 int clock_speed; /* External clock speed (MHz) */ 231 231 u8 clkrc; /* Clock divider value */ 232 232 bool use_smbus; /* Use smbus I/O instead of I2C */ 233 + bool pll_bypass; 233 234 const struct ov7670_devtype *devtype; /* Device specifics */ 234 235 }; 235 236 ··· 756 755 { 757 756 struct ov7670_info *info = to_state(sd); 758 757 u32 clkrc = info->clkrc; 759 - u32 pll_factor = PLL_FACTOR; 758 + int pll_factor; 759 + 760 + if (info->pll_bypass) 761 + pll_factor = 1; 762 + else 763 + pll_factor = PLL_FACTOR; 760 764 761 765 clkrc++; 762 766 if (info->fmt->mbus_code == V4L2_MBUS_FMT_SBGGR8_1X8) ··· 777 771 { 778 772 struct ov7670_info *info = to_state(sd); 779 773 u32 clkrc; 780 - u32 pll_factor = PLL_FACTOR; 774 + int pll_factor; 781 775 int ret; 782 776 783 777 /* ··· 787 781 * pixclk = clock_speed / (clkrc + 1) * PLLfactor 788 782 * 789 783 */ 784 + if (info->pll_bypass) { 785 + pll_factor = 1; 786 + ret = ov7670_write(sd, REG_DBLV, DBLV_BYPASS); 787 + } else { 788 + pll_factor = PLL_FACTOR; 789 + ret = ov7670_write(sd, REG_DBLV, DBLV_X4); 790 + } 791 + if (ret < 0) 792 + return ret; 793 + 790 794 if (tpf->numerator == 0 || tpf->denominator == 0) { 791 795 clkrc = 0; 792 796 } else { ··· 824 808 ret = ov7670_write(sd, REG_CLKRC, info->clkrc); 825 809 if (ret < 0) 826 810 return ret; 811 + 827 812 return ov7670_write(sd, REG_DBLV, DBLV_X4); 828 813 } 829 814 ··· 1705 1688 1706 1689 if (config->clock_speed) 1707 1690 info->clock_speed = config->clock_speed; 1691 + 1692 + /* 1693 + * It should be allowed for ov7670 too when it is migrated to 1694 + * the new frame rate formula. 1695 + */ 1696 + if (config->pll_bypass && id->driver_data != MODEL_OV7670) 1697 + info->pll_bypass = true; 1708 1698 } 1709 1699 1710 1700 /* Make sure it's an ov7670 */
+1
include/media/ov7670.h
··· 15 15 int min_height; /* Filter out smaller sizes */ 16 16 int clock_speed; /* External clock speed (MHz) */ 17 17 bool use_smbus; /* Use smbus I/O instead of I2C */ 18 + bool pll_bypass; /* Choose whether to bypass the PLL */ 18 19 }; 19 20 20 21 #endif