]>
Commit | Line | Data |
---|---|---|
13d365ac GKH |
1 | From 61da76beef1e4f0b6ba7be4f8d0cf0dac7ce1f55 Mon Sep 17 00:00:00 2001 |
2 | From: Jacopo Mondi <jacopo+renesas@jmondi.org> | |
3 | Date: Fri, 29 Dec 2017 07:22:26 -0500 | |
4 | Subject: media: v4l2: i2c: ov7670: Fix PLL bypass register values | |
5 | ||
6 | From: Jacopo Mondi <jacopo+renesas@jmondi.org> | |
7 | ||
8 | commit 61da76beef1e4f0b6ba7be4f8d0cf0dac7ce1f55 upstream. | |
9 | ||
10 | The following commits: | |
11 | commit f6dd927f34d6 ("[media] media: ov7670: calculate framerate properly for ov7675") | |
12 | commit 04ee6d92047e ("[media] media: ov7670: add possibility to bypass pll for ov7675") | |
13 | introduced the ability to bypass PLL multiplier and use input clock (xvclk) | |
14 | as pixel clock output frequency for ov7675 sensor. | |
15 | ||
16 | PLL is bypassed using register DBLV[7:6], according to ov7670 and ov7675 | |
17 | sensor manuals. Macros used to set DBLV register seem wrong in the | |
18 | driver, as their values do not match what reported in the datasheet. | |
19 | ||
20 | Fix by changing DBLV_* macros to use bits [7:6] and set bits [3:0] to | |
21 | default 0x0a reserved value (according to datasheets). | |
22 | ||
23 | While at there, remove a write to DBLV register in | |
24 | "ov7675_set_framerate()" that over-writes the previous one to the same | |
25 | register that takes "info->pll_bypass" flag into account instead of setting PLL | |
26 | multiplier to 4x unconditionally. | |
27 | ||
28 | And, while at there, since "info->pll_bypass" is only used in | |
29 | set/get_framerate() functions used by ov7675 only, it is not necessary | |
30 | to check for the device id at probe time to make sure that when using | |
31 | ov7670 "info->pll_bypass" is set to false. | |
32 | ||
33 | Fixes: f6dd927f34d6 ("[media] media: ov7670: calculate framerate properly for ov7675") | |
34 | ||
35 | Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org> | |
36 | Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> | |
37 | Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org> | |
38 | Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | |
39 | ||
40 | --- | |
41 | drivers/media/i2c/ov7670.c | 16 ++++++---------- | |
42 | 1 file changed, 6 insertions(+), 10 deletions(-) | |
43 | ||
44 | --- a/drivers/media/i2c/ov7670.c | |
45 | +++ b/drivers/media/i2c/ov7670.c | |
46 | @@ -155,10 +155,10 @@ MODULE_PARM_DESC(debug, "Debug level (0- | |
47 | #define REG_GFIX 0x69 /* Fix gain control */ | |
48 | ||
49 | #define REG_DBLV 0x6b /* PLL control an debugging */ | |
50 | -#define DBLV_BYPASS 0x00 /* Bypass PLL */ | |
51 | -#define DBLV_X4 0x01 /* clock x4 */ | |
52 | -#define DBLV_X6 0x10 /* clock x6 */ | |
53 | -#define DBLV_X8 0x11 /* clock x8 */ | |
54 | +#define DBLV_BYPASS 0x0a /* Bypass PLL */ | |
55 | +#define DBLV_X4 0x4a /* clock x4 */ | |
56 | +#define DBLV_X6 0x8a /* clock x6 */ | |
57 | +#define DBLV_X8 0xca /* clock x8 */ | |
58 | ||
59 | #define REG_REG76 0x76 /* OV's name */ | |
60 | #define R76_BLKPCOR 0x80 /* Black pixel correction enable */ | |
61 | @@ -833,7 +833,7 @@ static int ov7675_set_framerate(struct v | |
62 | if (ret < 0) | |
63 | return ret; | |
64 | ||
65 | - return ov7670_write(sd, REG_DBLV, DBLV_X4); | |
66 | + return 0; | |
67 | } | |
68 | ||
69 | static void ov7670_get_framerate_legacy(struct v4l2_subdev *sd, | |
70 | @@ -1578,11 +1578,7 @@ static int ov7670_probe(struct i2c_clien | |
71 | if (config->clock_speed) | |
72 | info->clock_speed = config->clock_speed; | |
73 | ||
74 | - /* | |
75 | - * It should be allowed for ov7670 too when it is migrated to | |
76 | - * the new frame rate formula. | |
77 | - */ | |
78 | - if (config->pll_bypass && id->driver_data != MODEL_OV7670) | |
79 | + if (config->pll_bypass) | |
80 | info->pll_bypass = true; | |
81 | ||
82 | if (config->pclk_hb_disable) |