summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Chung <nickchung@google.com>2020-08-17 20:41:22 +0800
committerNick Chung <nickchung@google.com>2020-08-19 14:48:57 +0800
commitded5cdf435b62323b24d617fb500beecbc7ed222 (patch)
tree15183678ffd2f731cd2d13d75361edae66f7bb85
parent76e5cc2342d4497536478426ece4e274c518dae3 (diff)
downloadcamera-kernel-ded5cdf435b62323b24d617fb500beecbc7ed222.tar.gz
The camera sensor power up sequence is too close(1 ms) to cause the camera gyro sensor initialization failed which is writing the first address to initialize gyro related settings. We didn’t add the delay of time to pacify the initial of gyro settings after the camera I/O powered on because this change will impact the camera launch time. It may be a reason that we can’t correctly write the first data into the gyro sensor. In most cases, this design is unlikely to go wrong and not easy to reproduce this issue. But actually we do see such corner cases in some bugs. Add a retry mechanism for gyro sensor first addr writing to avoid the initial failed issue. And we should treat the original ACQUIRE camera process as an existing and reasonable process. Bug: 163850320 Test: CTS/ITS Change-Id: I11001c81f5cf871ca9bef866ec34397112016d6b Signed-off-by: Nick Chung <nickchung@google.com>
-rw-r--r--drivers/cam_sensor_module/cam_sensor/cam_sensor_core.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/drivers/cam_sensor_module/cam_sensor/cam_sensor_core.c b/drivers/cam_sensor_module/cam_sensor/cam_sensor_core.c
index 20db229..c0b7850 100644
--- a/drivers/cam_sensor_module/cam_sensor/cam_sensor_core.c
+++ b/drivers/cam_sensor_module/cam_sensor/cam_sensor_core.c
@@ -774,6 +774,7 @@ int32_t cam_sensor_driver_cmd(struct cam_sensor_ctrl_t *s_ctrl,
void *arg)
{
int rc = 0, pkt_opcode = 0;
+ int8_t retries = 3;
struct cam_control *cmd = (struct cam_control *)arg;
struct cam_sensor_power_ctrl_t *power_info =
&s_ctrl->sensordata->power_info;
@@ -959,10 +960,26 @@ int32_t cam_sensor_driver_cmd(struct cam_sensor_ctrl_t *s_ctrl,
goto release_mutex;
}
+ s_ctrl->sensor_state = CAM_SENSOR_ACQUIRE;
+ s_ctrl->last_flush_req = 0;
+ CAM_INFO(CAM_SENSOR,
+ "CAM_ACQUIRE_DEV Success, sensor_id:0x%x,sensor_slave_addr:0x%x",
+ s_ctrl->sensordata->slave_info.sensor_id,
+ s_ctrl->sensordata->slave_info.sensor_slave_addr);
+
#if IS_ENABLED(CONFIG_CAMERA_GYRO)
if (s_ctrl->sensordata->slave_info.sensor_id == 0x363 &&
s_ctrl->custom_gyro_support) {
- rc = enable_cam_gyro();
+ /* From vendor spec, we need to add at least 10 ms delay time
+ * to pacify the first writing of gyro settings after turning
+ * the camera power on. Use the retry mechanism to fulfill this purpose.
+ */
+ while ((rc = enable_cam_gyro()) && (retries > 0)) {
+ CAM_ERR(CAM_SENSOR, "CAM_GYRO_ENABLE failure, wait and retry");
+ retries--;
+ /* TBD: Delay 1 ms for each retry */
+ usleep_range(1000, 3000);
+ }
if (rc < 0) {
CAM_ERR(CAM_SENSOR, "CAM_GYRO_ENABLE failure");
cam_sensor_power_down(s_ctrl);
@@ -971,13 +988,6 @@ int32_t cam_sensor_driver_cmd(struct cam_sensor_ctrl_t *s_ctrl,
CAM_INFO(CAM_SENSOR, "CAM_GYRO_ENABLE success");
}
#endif
-
- s_ctrl->sensor_state = CAM_SENSOR_ACQUIRE;
- s_ctrl->last_flush_req = 0;
- CAM_INFO(CAM_SENSOR,
- "CAM_ACQUIRE_DEV Success, sensor_id:0x%x,sensor_slave_addr:0x%x",
- s_ctrl->sensordata->slave_info.sensor_id,
- s_ctrl->sensordata->slave_info.sensor_slave_addr);
}
break;
case CAM_RELEASE_DEV: {