Skip to content

Commit 576f5d4

Browse files
prabhakarladmchehab
authored andcommitted
media: i2c: ov5640: Enable data pins on poweron for DVP mode
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]>
1 parent b1751ae commit 576f5d4

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
@@ -276,8 +276,7 @@ static inline struct v4l2_subdev *ctrl_to_sd(struct v4l2_ctrl *ctrl)
276276
/* YUV422 UYVY VGA@30fps */
277277
static const struct reg_value ov5640_init_setting_30fps_VGA[] = {
278278
{0x3103, 0x11, 0, 0}, {0x3008, 0x82, 0, 5}, {0x3008, 0x42, 0, 0},
279-
{0x3103, 0x03, 0, 0}, {0x3017, 0x00, 0, 0}, {0x3018, 0x00, 0, 0},
280-
{0x3630, 0x36, 0, 0},
279+
{0x3103, 0x03, 0, 0}, {0x3630, 0x36, 0, 0},
281280
{0x3631, 0x0e, 0, 0}, {0x3632, 0xe2, 0, 0}, {0x3633, 0x12, 0, 0},
282281
{0x3621, 0xe0, 0, 0}, {0x3704, 0xa0, 0, 0}, {0x3703, 0x5a, 0, 0},
283282
{0x3715, 0x78, 0, 0}, {0x3717, 0x01, 0, 0}, {0x370b, 0x60, 0, 0},
@@ -1283,33 +1282,6 @@ static int ov5640_set_stream_dvp(struct ov5640_dev *sensor, bool on)
12831282
if (ret)
12841283
return ret;
12851284

1286-
/*
1287-
* enable VSYNC/HREF/PCLK DVP control lines
1288-
* & D[9:6] DVP data lines
1289-
*
1290-
* PAD OUTPUT ENABLE 01
1291-
* - 6: VSYNC output enable
1292-
* - 5: HREF output enable
1293-
* - 4: PCLK output enable
1294-
* - [3:0]: D[9:6] output enable
1295-
*/
1296-
ret = ov5640_write_reg(sensor,
1297-
OV5640_REG_PAD_OUTPUT_ENABLE01,
1298-
on ? 0x7f : 0);
1299-
if (ret)
1300-
return ret;
1301-
1302-
/*
1303-
* enable D[5:0] DVP data lines
1304-
*
1305-
* PAD OUTPUT ENABLE 02
1306-
* - [7:2]: D[5:0] output enable
1307-
*/
1308-
ret = ov5640_write_reg(sensor, OV5640_REG_PAD_OUTPUT_ENABLE02,
1309-
on ? 0xfc : 0);
1310-
if (ret)
1311-
return ret;
1312-
13131285
return ov5640_write_reg(sensor, OV5640_REG_SYS_CTRL0, on ?
13141286
OV5640_REG_SYS_CTRL0_SW_PWUP :
13151287
OV5640_REG_SYS_CTRL0_SW_PWDN);
@@ -2069,6 +2041,40 @@ static int ov5640_set_power_mipi(struct ov5640_dev *sensor, bool on)
20692041
return 0;
20702042
}
20712043

2044+
static int ov5640_set_power_dvp(struct ov5640_dev *sensor, bool on)
2045+
{
2046+
int ret;
2047+
2048+
if (!on) {
2049+
/* Reset settings to their default values. */
2050+
ov5640_write_reg(sensor, OV5640_REG_PAD_OUTPUT_ENABLE01, 0x00);
2051+
ov5640_write_reg(sensor, OV5640_REG_PAD_OUTPUT_ENABLE02, 0x00);
2052+
return 0;
2053+
}
2054+
2055+
/*
2056+
* enable VSYNC/HREF/PCLK DVP control lines
2057+
* & D[9:6] DVP data lines
2058+
*
2059+
* PAD OUTPUT ENABLE 01
2060+
* - 6: VSYNC output enable
2061+
* - 5: HREF output enable
2062+
* - 4: PCLK output enable
2063+
* - [3:0]: D[9:6] output enable
2064+
*/
2065+
ret = ov5640_write_reg(sensor, OV5640_REG_PAD_OUTPUT_ENABLE01, 0x7f);
2066+
if (ret)
2067+
return ret;
2068+
2069+
/*
2070+
* enable D[5:0] DVP data lines
2071+
*
2072+
* PAD OUTPUT ENABLE 02
2073+
* - [7:2]: D[5:0] output enable
2074+
*/
2075+
return ov5640_write_reg(sensor, OV5640_REG_PAD_OUTPUT_ENABLE02, 0xfc);
2076+
}
2077+
20722078
static int ov5640_set_power(struct ov5640_dev *sensor, bool on)
20732079
{
20742080
int ret = 0;
@@ -2083,11 +2089,12 @@ static int ov5640_set_power(struct ov5640_dev *sensor, bool on)
20832089
goto power_off;
20842090
}
20852091

2086-
if (sensor->ep.bus_type == V4L2_MBUS_CSI2_DPHY) {
2092+
if (sensor->ep.bus_type == V4L2_MBUS_CSI2_DPHY)
20872093
ret = ov5640_set_power_mipi(sensor, on);
2088-
if (ret)
2089-
goto power_off;
2090-
}
2094+
else
2095+
ret = ov5640_set_power_dvp(sensor, on);
2096+
if (ret)
2097+
goto power_off;
20912098

20922099
if (!on)
20932100
ov5640_set_power_off(sensor);

0 commit comments

Comments
 (0)