Skip to content

Commit 79ec057

Browse files
prabhakarladgregkh
authored andcommitted
media: i2c: ov5640: Enable data pins on poweron for DVP mode
[ Upstream commit 576f5d4 ] During testing this sensor on iW-RainboW-G21D-Qseven platform in 8-bit DVP mode with rcar-vin bridge noticed the capture worked fine for the first run (with yavta), but for subsequent runs the bridge driver waited for the frame to be captured. Debugging further noticed the data lines were enabled/disabled in stream on/off callback and dumping the register contents 0x3017/0x3018 in ov5640_set_stream_dvp() reported the correct values, but yet frame capturing failed. To get around this issue data lines are enabled in s_power callback. (Also the sensor remains in power down mode if not streaming so power consumption shouldn't be affected) Fixes: f22996d ("media: ov5640: add support of DVP parallel interface") Signed-off-by: Lad Prabhakar <[email protected]> Reviewed-by: Biju Das <[email protected]> Tested-by: Jacopo Mondi <[email protected]> Signed-off-by: Sakari Ailus <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent b2f8546 commit 79ec057

File tree

1 file changed

+40
-33
lines changed

1 file changed

+40
-33
lines changed

drivers/media/i2c/ov5640.c

+40-33
Original file line numberDiff line numberDiff line change
@@ -274,8 +274,7 @@ static inline struct v4l2_subdev *ctrl_to_sd(struct v4l2_ctrl *ctrl)
274274
/* YUV422 UYVY VGA@30fps */
275275
static const struct reg_value ov5640_init_setting_30fps_VGA[] = {
276276
{0x3103, 0x11, 0, 0}, {0x3008, 0x82, 0, 5}, {0x3008, 0x42, 0, 0},
277-
{0x3103, 0x03, 0, 0}, {0x3017, 0x00, 0, 0}, {0x3018, 0x00, 0, 0},
278-
{0x3630, 0x36, 0, 0},
277+
{0x3103, 0x03, 0, 0}, {0x3630, 0x36, 0, 0},
279278
{0x3631, 0x0e, 0, 0}, {0x3632, 0xe2, 0, 0}, {0x3633, 0x12, 0, 0},
280279
{0x3621, 0xe0, 0, 0}, {0x3704, 0xa0, 0, 0}, {0x3703, 0x5a, 0, 0},
281280
{0x3715, 0x78, 0, 0}, {0x3717, 0x01, 0, 0}, {0x370b, 0x60, 0, 0},
@@ -1272,33 +1271,6 @@ static int ov5640_set_stream_dvp(struct ov5640_dev *sensor, bool on)
12721271
if (ret)
12731272
return ret;
12741273

1275-
/*
1276-
* enable VSYNC/HREF/PCLK DVP control lines
1277-
* & D[9:6] DVP data lines
1278-
*
1279-
* PAD OUTPUT ENABLE 01
1280-
* - 6: VSYNC output enable
1281-
* - 5: HREF output enable
1282-
* - 4: PCLK output enable
1283-
* - [3:0]: D[9:6] output enable
1284-
*/
1285-
ret = ov5640_write_reg(sensor,
1286-
OV5640_REG_PAD_OUTPUT_ENABLE01,
1287-
on ? 0x7f : 0);
1288-
if (ret)
1289-
return ret;
1290-
1291-
/*
1292-
* enable D[5:0] DVP data lines
1293-
*
1294-
* PAD OUTPUT ENABLE 02
1295-
* - [7:2]: D[5:0] output enable
1296-
*/
1297-
ret = ov5640_write_reg(sensor, OV5640_REG_PAD_OUTPUT_ENABLE02,
1298-
on ? 0xfc : 0);
1299-
if (ret)
1300-
return ret;
1301-
13021274
return ov5640_write_reg(sensor, OV5640_REG_SYS_CTRL0, on ?
13031275
OV5640_REG_SYS_CTRL0_SW_PWUP :
13041276
OV5640_REG_SYS_CTRL0_SW_PWDN);
@@ -2055,6 +2027,40 @@ static int ov5640_set_power_mipi(struct ov5640_dev *sensor, bool on)
20552027
return 0;
20562028
}
20572029

2030+
static int ov5640_set_power_dvp(struct ov5640_dev *sensor, bool on)
2031+
{
2032+
int ret;
2033+
2034+
if (!on) {
2035+
/* Reset settings to their default values. */
2036+
ov5640_write_reg(sensor, OV5640_REG_PAD_OUTPUT_ENABLE01, 0x00);
2037+
ov5640_write_reg(sensor, OV5640_REG_PAD_OUTPUT_ENABLE02, 0x00);
2038+
return 0;
2039+
}
2040+
2041+
/*
2042+
* enable VSYNC/HREF/PCLK DVP control lines
2043+
* & D[9:6] DVP data lines
2044+
*
2045+
* PAD OUTPUT ENABLE 01
2046+
* - 6: VSYNC output enable
2047+
* - 5: HREF output enable
2048+
* - 4: PCLK output enable
2049+
* - [3:0]: D[9:6] output enable
2050+
*/
2051+
ret = ov5640_write_reg(sensor, OV5640_REG_PAD_OUTPUT_ENABLE01, 0x7f);
2052+
if (ret)
2053+
return ret;
2054+
2055+
/*
2056+
* enable D[5:0] DVP data lines
2057+
*
2058+
* PAD OUTPUT ENABLE 02
2059+
* - [7:2]: D[5:0] output enable
2060+
*/
2061+
return ov5640_write_reg(sensor, OV5640_REG_PAD_OUTPUT_ENABLE02, 0xfc);
2062+
}
2063+
20582064
static int ov5640_set_power(struct ov5640_dev *sensor, bool on)
20592065
{
20602066
int ret = 0;
@@ -2069,11 +2075,12 @@ static int ov5640_set_power(struct ov5640_dev *sensor, bool on)
20692075
goto power_off;
20702076
}
20712077

2072-
if (sensor->ep.bus_type == V4L2_MBUS_CSI2_DPHY) {
2078+
if (sensor->ep.bus_type == V4L2_MBUS_CSI2_DPHY)
20732079
ret = ov5640_set_power_mipi(sensor, on);
2074-
if (ret)
2075-
goto power_off;
2076-
}
2080+
else
2081+
ret = ov5640_set_power_dvp(sensor, on);
2082+
if (ret)
2083+
goto power_off;
20772084

20782085
if (!on)
20792086
ov5640_set_power_off(sensor);

0 commit comments

Comments
 (0)