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_actuator/cam_actuator_core.c b/drivers/media/platform/msm/camera/cam_sensor_module/cam_actuator/cam_actuator_core.c
index b36fc68..bcf4133 100644
--- a/drivers/media/platform/msm/camera/cam_sensor_module/cam_actuator/cam_actuator_core.c
+++ b/drivers/media/platform/msm/camera/cam_sensor_module/cam_actuator/cam_actuator_core.c
@@ -16,6 +16,70 @@
#include "cam_sensor_util.h"
#include "cam_trace.h"
+static int32_t cam_actuator_i2c_modes_util(
+ struct camera_io_master *io_master_info,
+ struct i2c_settings_list *i2c_list)
+{
+ int32_t rc = 0;
+ uint32_t i, size;
+
+ if (i2c_list->op_code == CAM_SENSOR_I2C_WRITE_RANDOM) {
+ rc = camera_io_dev_write(io_master_info,
+ &(i2c_list->i2c_settings));
+ if (rc < 0) {
+ CAM_ERR(CAM_ACTUATOR,
+ "Failed to random write I2C settings: %d",
+ rc);
+ return rc;
+ }
+ } else if (i2c_list->op_code == CAM_SENSOR_I2C_WRITE_SEQ) {
+ rc = camera_io_dev_write_continuous(
+ io_master_info,
+ &(i2c_list->i2c_settings),
+ 0);
+ if (rc < 0) {
+ CAM_ERR(CAM_ACTUATOR,
+ "Failed to seq write I2C settings: %d",
+ rc);
+ return rc;
+ }
+ } else if (i2c_list->op_code == CAM_SENSOR_I2C_WRITE_BURST) {
+ rc = camera_io_dev_write_continuous(
+ io_master_info,
+ &(i2c_list->i2c_settings),
+ 1);
+ if (rc < 0) {
+ CAM_ERR(CAM_ACTUATOR,
+ "Failed to burst write I2C settings: %d",
+ rc);
+ return rc;
+ }
+ } else if (i2c_list->op_code == CAM_SENSOR_I2C_POLL) {
+ size = i2c_list->i2c_settings.size;
+ for (i = 0; i < size; i++) {
+ rc = camera_io_dev_poll(
+ io_master_info,
+ i2c_list->i2c_settings.
+ reg_setting[i].reg_addr,
+ i2c_list->i2c_settings.
+ reg_setting[i].reg_data,
+ i2c_list->i2c_settings.
+ reg_setting[i].data_mask,
+ i2c_list->i2c_settings.addr_type,
+ i2c_list->i2c_settings.data_type,
+ i2c_list->i2c_settings.
+ reg_setting[i].delay);
+ if (rc < 0) {
+ CAM_ERR(CAM_ACTUATOR,
+ "i2c poll apply setting Fail: %d", rc);
+ return rc;
+ }
+ }
+ }
+
+ return rc;
+}
+
int32_t cam_actuator_slaveInfo_pkt_parser(struct cam_actuator_ctrl_t *a_ctrl,
uint32_t *cmd_buf)
{
@@ -52,7 +116,6 @@
{
struct i2c_settings_list *i2c_list;
int32_t rc = 0;
- uint32_t i, size;
if (a_ctrl == NULL || i2c_set == NULL) {
CAM_ERR(CAM_ACTUATOR, "Invalid Args");
@@ -66,35 +129,14 @@
list_for_each_entry(i2c_list,
&(i2c_set->list_head), list) {
- if (i2c_list->op_code == CAM_SENSOR_I2C_WRITE_RANDOM) {
- rc = camera_io_dev_write(&(a_ctrl->io_master_info),
- &(i2c_list->i2c_settings));
- if (rc < 0) {
- CAM_ERR(CAM_ACTUATOR,
- "Failed in Applying i2c wrt settings");
- return rc;
- }
- } else if (i2c_list->op_code == CAM_SENSOR_I2C_POLL) {
- size = i2c_list->i2c_settings.size;
- for (i = 0; i < size; i++) {
- rc = camera_io_dev_poll(
- &(a_ctrl->io_master_info),
- i2c_list->i2c_settings.
- reg_setting[i].reg_addr,
- i2c_list->i2c_settings.
- reg_setting[i].reg_data,
- i2c_list->i2c_settings.
- reg_setting[i].data_mask,
- i2c_list->i2c_settings.addr_type,
- i2c_list->i2c_settings.data_type,
- i2c_list->i2c_settings.
- reg_setting[i].delay);
- if (rc < 0) {
- CAM_ERR(CAM_ACTUATOR,
- "i2c poll apply setting Fail");
- return rc;
- }
- }
+ rc = cam_actuator_i2c_modes_util(
+ &(a_ctrl->io_master_info),
+ i2c_list);
+ if (rc < 0) {
+ CAM_ERR(CAM_ACTUATOR,
+ "Failed to apply settings: %d",
+ rc);
+ return rc;
}
}