Skip to content

Commit c0a88d6

Browse files
committed
fix ov5640
Signed-off-by: Robert Nelson <robertcnelson@gmail.com>
1 parent 92f963c commit c0a88d6

7 files changed

Lines changed: 251 additions & 1 deletion

patch.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,7 @@ drivers () {
662662
dir 'tidss'
663663
dir 'tidss_wip'
664664
dir 'led'
665+
dir 'ov5640'
665666
}
666667

667668
###
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
From 95d9e4a7491ef9334588e66577f5ab114c243891 Mon Sep 17 00:00:00 2001
2+
From: "Guoniu.zhou" <guoniu.zhou@nxp.com>
3+
Date: Fri, 25 Nov 2022 09:20:24 +0000
4+
Subject: [PATCH 1/5] media: ov5640: set correct default link frequency
5+
6+
current_link_freq field in ov5640_dev structure is link frequency,
7+
not link frequency array index, so correct it.
8+
9+
Fixes: 3c28588f35d3 ("media: ov5640: Update pixel_rate and link_freq")
10+
Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
11+
Acked-by: Jacopo Mondi <jacopo@jmondi.org>
12+
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
13+
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
14+
(cherry picked from commit d7b41196927ba2a2b5badad1a85f9087eb90b076)
15+
Signed-off-by: Nishanth Menon <nm@ti.com>
16+
---
17+
drivers/media/i2c/ov5640.c | 3 ++-
18+
1 file changed, 2 insertions(+), 1 deletion(-)
19+
20+
diff --git a/drivers/media/i2c/ov5640.c b/drivers/media/i2c/ov5640.c
21+
index 65fb13f91179..f0c55c067098 100644
22+
--- a/drivers/media/i2c/ov5640.c
23+
+++ b/drivers/media/i2c/ov5640.c
24+
@@ -3828,7 +3828,8 @@ static int ov5640_probe(struct i2c_client *client)
25+
sensor->current_mode =
26+
&ov5640_mode_data[OV5640_MODE_VGA_640_480];
27+
sensor->last_mode = sensor->current_mode;
28+
- sensor->current_link_freq = OV5640_DEFAULT_LINK_FREQ;
29+
+ sensor->current_link_freq =
30+
+ ov5640_csi2_link_freqs[OV5640_DEFAULT_LINK_FREQ];
31+
32+
sensor->ae_target = 52;
33+
34+
--
35+
2.30.2
36+
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
From c2fc6efe425f90bbb574054624eadc169b0aa9b4 Mon Sep 17 00:00:00 2001
2+
From: "Guoniu.zhou" <guoniu.zhou@nxp.com>
3+
Date: Fri, 2 Dec 2022 13:00:00 +0000
4+
Subject: [PATCH 2/5] media: ov5640: report correct frame rate to user
5+
6+
In commit 3145efcdb4d0 ("media: ov5640: Rework timings programming"),
7+
it defines max_fps field in ov5640_mode_info structure to store maximum
8+
frame rate supported by each mode. But in ov5640_try_frame_interval(), it
9+
assumes the maximum frame rate supported by all modes is 60. But actually,
10+
only VGA support it. For others, the maximum frame rate supported is 30.
11+
So correct it by taking the maximum frame rate supported by each mode as
12+
the initialization value of the local variable maxfps.
13+
14+
Signed-off-by: Guoniu.zhou <guoniu.zhou@nxp.com>
15+
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
16+
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
17+
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
18+
(cherry picked from commit f33b56d370090e9ce58761a536b174d4f656092f)
19+
Signed-off-by: Nishanth Menon <nm@ti.com>
20+
---
21+
drivers/media/i2c/ov5640.c | 22 ++++++++++++----------
22+
1 file changed, 12 insertions(+), 10 deletions(-)
23+
24+
diff --git a/drivers/media/i2c/ov5640.c b/drivers/media/i2c/ov5640.c
25+
index f0c55c067098..a9cd21c49147 100644
26+
--- a/drivers/media/i2c/ov5640.c
27+
+++ b/drivers/media/i2c/ov5640.c
28+
@@ -2647,20 +2647,20 @@ static int ov5640_set_power(struct ov5640_dev *sensor, bool on)
29+
30+
static int ov5640_try_frame_interval(struct ov5640_dev *sensor,
31+
struct v4l2_fract *fi,
32+
- u32 width, u32 height)
33+
+ const struct ov5640_mode_info *mode_info)
34+
{
35+
- const struct ov5640_mode_info *mode;
36+
+ const struct ov5640_mode_info *mode = mode_info;
37+
enum ov5640_frame_rate rate = OV5640_15_FPS;
38+
int minfps, maxfps, best_fps, fps;
39+
int i;
40+
41+
minfps = ov5640_framerates[OV5640_15_FPS];
42+
- maxfps = ov5640_framerates[OV5640_60_FPS];
43+
+ maxfps = ov5640_framerates[mode->max_fps];
44+
45+
if (fi->numerator == 0) {
46+
fi->denominator = maxfps;
47+
fi->numerator = 1;
48+
- rate = OV5640_60_FPS;
49+
+ rate = mode->max_fps;
50+
goto find_mode;
51+
}
52+
53+
@@ -2681,7 +2681,7 @@ static int ov5640_try_frame_interval(struct ov5640_dev *sensor,
54+
fi->denominator = best_fps;
55+
56+
find_mode:
57+
- mode = ov5640_find_mode(sensor, width, height, false);
58+
+ mode = ov5640_find_mode(sensor, mode->width, mode->height, false);
59+
return mode ? rate : -EINVAL;
60+
}
61+
62+
@@ -3535,6 +3535,7 @@ static int ov5640_enum_frame_interval(
63+
struct v4l2_subdev_frame_interval_enum *fie)
64+
{
65+
struct ov5640_dev *sensor = to_ov5640_dev(sd);
66+
+ const struct ov5640_mode_info *mode;
67+
struct v4l2_fract tpf;
68+
int ret;
69+
70+
@@ -3543,11 +3544,14 @@ static int ov5640_enum_frame_interval(
71+
if (fie->index >= OV5640_NUM_FRAMERATES)
72+
return -EINVAL;
73+
74+
+ mode = ov5640_find_mode(sensor, fie->width, fie->height, false);
75+
+ if (!mode)
76+
+ return -EINVAL;
77+
+
78+
tpf.numerator = 1;
79+
tpf.denominator = ov5640_framerates[fie->index];
80+
81+
- ret = ov5640_try_frame_interval(sensor, &tpf,
82+
- fie->width, fie->height);
83+
+ ret = ov5640_try_frame_interval(sensor, &tpf, mode);
84+
if (ret < 0)
85+
return -EINVAL;
86+
87+
@@ -3586,9 +3590,7 @@ static int ov5640_s_frame_interval(struct v4l2_subdev *sd,
88+
89+
mode = sensor->current_mode;
90+
91+
- frame_rate = ov5640_try_frame_interval(sensor, &fi->interval,
92+
- mode->width,
93+
- mode->height);
94+
+ frame_rate = ov5640_try_frame_interval(sensor, &fi->interval, mode);
95+
if (frame_rate < 0) {
96+
/* Always return a valid frame interval value */
97+
fi->interval = sensor->frame_interval;
98+
--
99+
2.30.2
100+
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
From 292fa1ba4ef4a158421d70f93b827c23fe286b1e Mon Sep 17 00:00:00 2001
2+
From: Nishanth Menon <nm@ti.com>
3+
Date: Wed, 7 Dec 2022 17:25:17 -0600
4+
Subject: [PATCH 3/5] media: ov5640: Honor RESETB to SMBUS time t4 in
5+
init_setting
6+
7+
OV5640 Datasheet[1] Figures 2-3 and 2-4 indicate the timing sequences
8+
that is expected during various initialization steps. Note the t4 >=
9+
20ms, delay from RESETB pull high to SCCB initialization
10+
11+
As indicated in section 2.8, the RESETB assertion can either be via
12+
external pin control OR via the register 0x3008 bit 7. The
13+
initialization sequence asserts bit7, but on deassert, we do not wait
14+
for the reset delay.
15+
16+
[1] https://cdn.sparkfun.com/datasheets/Sensors/LightImaging/OV5640_datasheet.pdf
17+
18+
Fixes: 19a81c1426c1 ("[media] add Omnivision OV5640 sensor driver")
19+
Signed-off-by: Nishanth Menon <nm@ti.com>
20+
---
21+
drivers/media/i2c/ov5640.c | 2 +-
22+
1 file changed, 1 insertion(+), 1 deletion(-)
23+
24+
diff --git a/drivers/media/i2c/ov5640.c b/drivers/media/i2c/ov5640.c
25+
index a9cd21c49147..2c52be223722 100644
26+
--- a/drivers/media/i2c/ov5640.c
27+
+++ b/drivers/media/i2c/ov5640.c
28+
@@ -475,7 +475,7 @@ static const struct v4l2_mbus_framefmt ov5640_default_fmt = {
29+
};
30+
31+
static const struct reg_value ov5640_init_setting[] = {
32+
- {0x3103, 0x11, 0, 0}, {0x3008, 0x82, 0, 5}, {0x3008, 0x42, 0, 0},
33+
+ {0x3103, 0x11, 0, 0}, {0x3008, 0x82, 0, 5}, {0x3008, 0x42, 0, 20},
34+
{0x3103, 0x03, 0, 0}, {0x3630, 0x36, 0, 0},
35+
{0x3631, 0x0e, 0, 0}, {0x3632, 0xe2, 0, 0}, {0x3633, 0x12, 0, 0},
36+
{0x3621, 0xe0, 0, 0}, {0x3704, 0xa0, 0, 0}, {0x3703, 0x5a, 0, 0},
37+
--
38+
2.30.2
39+
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
From c49224742035aa43ca4b6186a485a524f4a28bb9 Mon Sep 17 00:00:00 2001
2+
From: Nishanth Menon <nm@ti.com>
3+
Date: Wed, 7 Dec 2022 17:40:20 -0600
4+
Subject: [PATCH 4/5] media: ov5640: Honor power on time in init_setting
5+
6+
OV5640 Datasheet[1] Figures 2-3 and 2-4 indicate the timing sequences
7+
that is expected during various initialization steps. Note the power
8+
on time includes t0 + t1 + t2 >= 5ms, delay for poweron.
9+
10+
As indicated in section 2.8, the RESETB assertion can either be via
11+
external pin control OR via the register 0x3008 bit 6 (see table 7-1 in
12+
[1])
13+
14+
[1] https://cdn.sparkfun.com/datasheets/Sensors/LightImaging/OV5640_datasheet.pdf
15+
16+
Fixes: 19a81c1426c1 ("[media] add Omnivision OV5640 sensor driver")
17+
Signed-off-by: Nishanth Menon <nm@ti.com>
18+
---
19+
drivers/media/i2c/ov5640.c | 2 +-
20+
1 file changed, 1 insertion(+), 1 deletion(-)
21+
22+
diff --git a/drivers/media/i2c/ov5640.c b/drivers/media/i2c/ov5640.c
23+
index 2c52be223722..6300e4a445f6 100644
24+
--- a/drivers/media/i2c/ov5640.c
25+
+++ b/drivers/media/i2c/ov5640.c
26+
@@ -551,7 +551,7 @@ static const struct reg_value ov5640_init_setting[] = {
27+
{0x583b, 0x28, 0, 0}, {0x583c, 0x42, 0, 0}, {0x583d, 0xce, 0, 0},
28+
{0x5025, 0x00, 0, 0}, {0x3a0f, 0x30, 0, 0}, {0x3a10, 0x28, 0, 0},
29+
{0x3a1b, 0x30, 0, 0}, {0x3a1e, 0x26, 0, 0}, {0x3a11, 0x60, 0, 0},
30+
- {0x3a1f, 0x14, 0, 0}, {0x3008, 0x02, 0, 0}, {0x3c00, 0x04, 0, 300},
31+
+ {0x3a1f, 0x14, 0, 0}, {0x3008, 0x02, 0, 5}, {0x3c00, 0x04, 0, 300},
32+
};
33+
34+
static const struct reg_value ov5640_setting_low_res[] = {
35+
--
36+
2.30.2
37+
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
From ce905a154d8ad013b020b73d81c4275ab61679e3 Mon Sep 17 00:00:00 2001
2+
From: Jai Luthra <j-luthra@ti.com>
3+
Date: Thu, 8 Dec 2022 17:23:50 +0530
4+
Subject: [PATCH 5/5] media: ov5640: Handle delays when no reset_gpio set
5+
6+
Some RPi-compatible module manufacturers [1] don't expose the RESETB
7+
gpio of the sensor directly through the connector. Instead wiring ~PWDN
8+
as a proxy reset with appropriate delays.
9+
10+
In such cases, reset_gpio will not be available to the driver, but it
11+
will still be toggled when the sensor is powered on, and thus we should
12+
still honor the wait time of >= 5ms + 1ms + 20ms [2] before
13+
attempting any i/o operations over SCCB.
14+
15+
[1] https://digilent.com/reference/_media/reference/add-ons/pcam-5c/pcam_5c_sch.pdf
16+
[2] https://cdn.sparkfun.com/datasheets/Sensors/LightImaging/OV5640_datasheet.pdf
17+
18+
Signed-off-by: Jai Luthra <j-luthra@ti.com>
19+
---
20+
drivers/media/i2c/ov5640.c | 1 +
21+
1 file changed, 1 insertion(+)
22+
23+
diff --git a/drivers/media/i2c/ov5640.c b/drivers/media/i2c/ov5640.c
24+
index 6300e4a445f6..84da0f8546a5 100644
25+
--- a/drivers/media/i2c/ov5640.c
26+
+++ b/drivers/media/i2c/ov5640.c
27+
@@ -2414,6 +2414,7 @@ static int ov5640_set_power_on(struct ov5640_dev *sensor)
28+
29+
ov5640_reset(sensor);
30+
ov5640_power(sensor, true);
31+
+ usleep_range(26000, 30000);
32+
33+
ret = ov5640_init_slave_id(sensor);
34+
if (ret)
35+
--
36+
2.30.2
37+

version.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ KERNEL_REL=5.10
4545
KERNEL_TAG=${KERNEL_REL}.153
4646
kernel_rt=".153-rt76"
4747
#Kernel Build
48-
BUILD=${build_prefix}81
48+
BUILD=${build_prefix}81.1
4949

5050
#v5.X-rcX + upto SHA
5151
#prev_KERNEL_SHA=""

0 commit comments

Comments
 (0)