media: i2c: ov5645: Keep the sensor in software power-down during init
Subsystems (2)
PATCH v2 1/1 media: i2c: ov5645: Keep the sensor in software power-down during init
On the RK3576 platform, after ov5645_global_init_setting completes and before stream on, the CSI host reports a high rate of CRC errors:
MIPI_CSI2 ERR1:0x1000000 (crc,vc: 0)
These errors occur exclusively in the window between init completion and stream on. Once preview starts and the sensor outputs valid HS data, no further CRC errors are observed.
Commit 092e8eb90a7d ("media: i2c: ov5645: Fix power sequence") reworked the power sequence to properly enter LP-11 during power-up. As part of this change, the SYSTEM_CTRL0_STOP (0x42) write on the power-up path was replaced with usleep_range(500, 1000). Since ov5645_global_init_setting[] ends with SYSTEM_CTRL0_START (0x02), the sensor core is left awake from the end of initialisation all the way to stream on, driving the data lanes while the host is not expecting any traffic. Reverting the commit resolves the CRC errors, confirming it as the triggering change.
ov5645_global_init_setting[] writes SYSTEM_CTRL0 four times: STOP at the very beginning, then START, STOP and START again near the end. Register writes are accepted over I2C while the sensor is in software power-down, so there is no reason to leave it briefly, and the three trailing writes serve no purpose. Drop them and keep the sensor in software power-down for the whole initialisation sequence. It is woken up only by ov5645_enable_streams(), once the host is ready to receive data.
This preserves the LP-11 compliance improvements from commit 092e8eb90a7d ("media: i2c: ov5645: Fix power sequence"), as the MIPI PHY stays powered and parked in LP-11, while eliminating the CRC errors on RK3576.
While at it, use the register macros for the remaining SYSTEM_CTRL0 write.
---
Changes in v2:
- Instead of appending another SYSTEM_CTRL0_STOP write, remove the three redundant SYSTEM_CTRL0 writes at the end of the init sequence, so the sensor simply stays in software power-down from the initial STOP until stream on
- Use OV5645_SYSTEM_CTRL0 / OV5645_SYSTEM_CTRL0_STOP instead of raw values for the remaining write
Link to v1: https://patchwork.linuxtv.org/project/linux-media/patch/[email protected]/
drivers/media/i2c/ov5645.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/media/i2c/ov5645.c +1 -4
@@ -115,7 +115,7 @@ static inline struct ov5645 *to_ov5645(struct v4l2_subdev *sd)static const struct reg_value ov5645_global_init_setting[] = { {0x3103 ,0x11 }, - {0x3008 ,0x42 }, + {OV5645_SYSTEM_CTRL0 ,OV5645_SYSTEM_CTRL0_STOP }, {0x3103 ,0x03 }, {0x3503 ,0x07 }, {0x3002 ,0x1c },
@@ -198,7 +198,6 @@ static const struct reg_value ov5645_global_init_setting[] = { { 0x5a00, 0x08 }, { 0x5a21, 0x00 }, { 0x5a24, 0x00 }, - { 0x3008, 0x02 }, { 0x3503, 0x00 }, { 0x5180, 0xff }, { 0x5181, 0xf2 },
@@ -347,8 +346,6 @@ static const struct reg_value ov5645_global_init_setting[] = { { 0x3a11, 0x60 }, { 0x3a1f, 0x14 }, { 0x0601, 0x02 }, - { 0x3008, 0x42 }, - { 0x3008, 0x02 }, { OV5645_IO_MIPI_CTRL00, 0x40 }, { OV5645_MIPI_CTRL00, 0x24 }, { OV5645_PAD_OUTPUT00, 0x70 }
Signature · 1 line
2.34.1
Humble ping...
thanks
xiaolei
Quoted 82 lines · Xiaolei Wang
On the RK3576 platform, after
ov5645_global_init_settingcompletes and before stream on, the CSI host reports a high rate of CRC errors:MIPI_CSI2 ERR1:0x1000000 (crc,vc: 0)These errors occur exclusively in the window between init completion and stream on. Once preview starts and the sensor outputs valid HS data, no further CRC errors are observed.
Commit
092e8eb90a7d("media: i2c: ov5645: Fix power sequence") reworked the power sequence to properly enter LP-11 during power-up. As part of this change, theSYSTEM_CTRL0_STOP(0x42) write on the power-up path was replaced withusleep_range(500, 1000). Since ov5645_global_init_setting[] ends withSYSTEM_CTRL0_START(0x02), the sensor core is left awake from the end of initialisation all the way to stream on, driving the data lanes while the host is not expecting any traffic. Reverting the commit resolves the CRC errors, confirming it as the triggering change.ov5645_global_init_setting[] writes
SYSTEM_CTRL0four times: STOP at the very beginning, then START, STOP and START again near the end. Register writes are accepted over I2C while the sensor is in software power-down, so there is no reason to leave it briefly, and the three trailing writes serve no purpose. Drop them and keep the sensor in software power-down for the whole initialisation sequence. It is woken up only byov5645_enable_streams(), once the host is ready to receive data.This preserves the LP-11 compliance improvements from commit
092e8eb90a7d("media: i2c: ov5645: Fix power sequence"), as the MIPI PHY stays powered and parked in LP-11, while eliminating the CRC errors on RK3576.While at it, use the register macros for the remaining
SYSTEM_CTRL0write.Fixes 092e8eb90a7d ("media: i2c: ov5645: Fix power sequence")Signed-off-by Xiaolei Wang <[email protected]>---
Changes in v2:
- Instead of appending anotherSYSTEM_CTRL0_STOPwrite, remove the three redundantSYSTEM_CTRL0writes at the end of the init sequence, so the sensor simply stays in software power-down from the initial STOP until stream on
- UseOV5645_SYSTEM_CTRL0/OV5645_SYSTEM_CTRL0_STOPinstead of raw values for the remaining writeLink to v1: https://patchwork.linuxtv.org/project/linux-media/patch/[email protected]/
drivers/media/i2c/ov5645.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)drivers/media/i2c/ov5645.c +1
-4@@ -115,7 +115,7 @@ static inline struct ov5645 *to_ov5645(struct v4l2_subdev *sd)static const struct reg_value ov5645_global_init_setting[] = { {0x3103 ,0x11 }, - {0x3008 ,0x42 }, + {OV5645_SYSTEM_CTRL0 ,OV5645_SYSTEM_CTRL0_STOP }, {0x3103 ,0x03 }, {0x3503 ,0x07 }, {0x3002 ,0x1c },@@ -198,7 +198,6 @@ static const struct reg_value ov5645_global_init_setting[] = { { 0x5a00, 0x08 }, { 0x5a21, 0x00 }, { 0x5a24, 0x00 }, - { 0x3008, 0x02 }, { 0x3503, 0x00 }, { 0x5180, 0xff }, { 0x5181, 0xf2 },@@ -347,8 +346,6 @@ static const struct reg_value ov5645_global_init_setting[] = { { 0x3a11, 0x60 }, { 0x3a1f, 0x14 }, { 0x0601, 0x02 }, - { 0x3008, 0x42 }, - { 0x3008, 0x02 }, { OV5645_IO_MIPI_CTRL00, 0x40 }, { OV5645_MIPI_CTRL00, 0x24 }, { OV5645_PAD_OUTPUT00, 0x70 }