msm: camera: Add I2C continuous write support in CCI
Provide functionality to use burst/seq write in
CCI module.
Change-Id: I633400fbaef4c97357696f7899501c60c277b253
Signed-off-by: Karthik Anantha Ram <kartanan@codeaurora.org>
diff --git a/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor_utils/cam_sensor_util.c b/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor_utils/cam_sensor_util.c
index 878ce73..ee836eb 100644
--- a/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor_utils/cam_sensor_util.c
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/cam_sensor_utils/cam_sensor_util.c
@@ -196,6 +196,49 @@
return rc;
}
+static int32_t cam_sensor_handle_continuous_write(
+ struct cam_cmd_i2c_continuous_wr *cam_cmd_i2c_continuous_wr,
+ struct i2c_settings_array *i2c_reg_settings,
+ uint16_t *cmd_length_in_bytes, int32_t *offset,
+ struct list_head **list)
+{
+ struct i2c_settings_list *i2c_list;
+ int32_t rc = 0, cnt;
+
+ i2c_list = cam_sensor_get_i2c_ptr(i2c_reg_settings,
+ cam_cmd_i2c_continuous_wr->header.count);
+ if (i2c_list == NULL ||
+ i2c_list->i2c_settings.reg_setting == NULL) {
+ CAM_ERR(CAM_SENSOR, "Failed in allocating i2c_list");
+ return -ENOMEM;
+ }
+
+ *cmd_length_in_bytes = (sizeof(struct i2c_rdwr_header) +
+ sizeof(cam_cmd_i2c_continuous_wr->reg_addr) +
+ sizeof(struct cam_cmd_read) *
+ (cam_cmd_i2c_continuous_wr->header.count));
+ i2c_list->op_code = cam_cmd_i2c_continuous_wr->header.op_code;
+ i2c_list->i2c_settings.addr_type =
+ cam_cmd_i2c_continuous_wr->header.addr_type;
+
+ for (cnt = 0; cnt < (cam_cmd_i2c_continuous_wr->header.count);
+ cnt++) {
+ i2c_list->i2c_settings.reg_setting[cnt].reg_addr =
+ cam_cmd_i2c_continuous_wr->
+ reg_addr;
+ i2c_list->i2c_settings.
+ reg_setting[cnt].reg_data =
+ cam_cmd_i2c_continuous_wr->
+ data_read[cnt].reg_data;
+ i2c_list->i2c_settings.
+ reg_setting[cnt].data_mask = 0;
+ }
+ (*offset) += cnt;
+ *list = &(i2c_list->list);
+
+ return rc;
+}
+
/**
* Name : cam_sensor_i2c_pkt_parser
* Description : Parse CSL CCI packet and apply register settings
@@ -260,7 +303,29 @@
&cmd_length_in_bytes, &j, &list);
if (rc < 0) {
CAM_ERR(CAM_SENSOR,
- "Failed in random read %d", rc);
+ "Failed in random write %d", rc);
+ return rc;
+ }
+
+ cmd_buf += cmd_length_in_bytes /
+ sizeof(uint32_t);
+ byte_cnt += cmd_length_in_bytes;
+ break;
+ }
+ case CAMERA_SENSOR_CMD_TYPE_I2C_CONT_WR: {
+ uint16_t cmd_length_in_bytes = 0;
+ struct cam_cmd_i2c_continuous_wr
+ *cam_cmd_i2c_continuous_wr =
+ (struct cam_cmd_i2c_continuous_wr *)
+ cmd_buf;
+
+ rc = cam_sensor_handle_continuous_write(
+ cam_cmd_i2c_continuous_wr,
+ i2c_reg_settings,
+ &cmd_length_in_bytes, &j, &list);
+ if (rc < 0) {
+ CAM_ERR(CAM_SENSOR,
+ "Failed in continuous write %d", rc);
return rc;
}