From 06612551d0ac2194c6ced9812edb8a924e3c59d0 Mon Sep 17 00:00:00 2001 From: Cosmin Tanislav Date: Wed, 1 Sep 2021 22:26:26 +0300 Subject: [PATCH] techpack: camera: sensor: implement optimization disabling --- .../cam_sensor_module/cam_cci/cam_cci_core.c | 35 ++++++++++++------- .../cam_sensor_module/cam_cci/cam_cci_dev.h | 1 + .../cam_sensor_module/cam_ois/cam_ois_core.c | 7 ++-- 3 files changed, 28 insertions(+), 15 deletions(-) diff --git a/techpack/camera/drivers/cam_sensor_module/cam_cci/cam_cci_core.c b/techpack/camera/drivers/cam_sensor_module/cam_cci/cam_cci_core.c index 847aa5cbde68..5ba37c1f7a39 100644 --- a/techpack/camera/drivers/cam_sensor_module/cam_cci/cam_cci_core.c +++ b/techpack/camera/drivers/cam_sensor_module/cam_cci/cam_cci_core.c @@ -9,6 +9,10 @@ #include "cam_req_mgr_workq.h" #include "cam_common_util.h" + +static int disable_optmz; +module_param(disable_optmz, int, 0644); + static int32_t cam_cci_convert_type_to_num_bytes( enum camera_sensor_i2c_type type) { @@ -525,22 +529,27 @@ static int32_t cam_cci_calc_cmd_len(struct cci_device *cci_dev, len = data_len + addr_len; pack_max_len = size < (cci_dev->payload_size-len) ? size : (cci_dev->payload_size-len); - for (i = 0; i < pack_max_len;) { - if (cmd->delay || ((cmd - i2c_cmd) >= (cmd_size - 1))) - break; - if (cmd->reg_addr + 1 == - (cmd+1)->reg_addr) { - len += data_len; - if (len > cci_dev->payload_size) { - len = len - data_len; + /* xiaomi add a flag to disable this optimization*/ + if ((!c_ctrl->cci_info->disable_optmz) && (!disable_optmz)) + { + CAM_DBG(CAM_CCI, "enable writing optimization for 0x%02X", c_ctrl->cci_info->sid<<1); + for (i = 0; i < pack_max_len;) { + if (cmd->delay || ((cmd - i2c_cmd) >= (cmd_size - 1))) + break; + if (cmd->reg_addr + 1 == + (cmd+1)->reg_addr) { + len += data_len; + if (len > cci_dev->payload_size) { + len = len - data_len; + break; + } + (*pack)++; + } else { break; } - (*pack)++; - } else { - break; + i += data_len; + cmd++; } - i += data_len; - cmd++; } } diff --git a/techpack/camera/drivers/cam_sensor_module/cam_cci/cam_cci_dev.h b/techpack/camera/drivers/cam_sensor_module/cam_cci/cam_cci_dev.h index 83359150fc95..e1f8be07c6e8 100644 --- a/techpack/camera/drivers/cam_sensor_module/cam_cci/cam_cci_dev.h +++ b/techpack/camera/drivers/cam_sensor_module/cam_cci/cam_cci_dev.h @@ -274,6 +274,7 @@ struct cam_sensor_cci_client { uint16_t retries; uint16_t id_map; uint16_t cci_device; + uint16_t disable_optmz; //xiaomi add the flag to disable CCI optimization }; struct cam_cci_ctrl { diff --git a/techpack/camera/drivers/cam_sensor_module/cam_ois/cam_ois_core.c b/techpack/camera/drivers/cam_sensor_module/cam_ois/cam_ois_core.c index e62e00d88d27..471403d796eb 100644 --- a/techpack/camera/drivers/cam_sensor_module/cam_ois/cam_ois_core.c +++ b/techpack/camera/drivers/cam_sensor_module/cam_ois/cam_ois_core.c @@ -338,10 +338,13 @@ static int cam_ois_slaveInfo_pkt_parser(struct cam_ois_ctrl_t *o_ctrl, o_ctrl->ois_name[OIS_NAME_LEN - 1] = '\0'; o_ctrl->io_master_info.cci_client->retries = 3; o_ctrl->io_master_info.cci_client->id_map = 0; + /* xiaomi add disable cci optmz for OIS by default */ + o_ctrl->io_master_info.cci_client->disable_optmz = 1; memcpy(&(o_ctrl->opcode), &(ois_info->opcode), sizeof(struct cam_ois_opcode)); - CAM_DBG(CAM_OIS, "Slave addr: 0x%x Freq Mode: %d", - ois_info->slave_addr, ois_info->i2c_freq_mode); + CAM_DBG(CAM_OIS, "Slave addr: 0x%x Freq Mode: %d, disable optmz %d", + ois_info->slave_addr, ois_info->i2c_freq_mode, + o_ctrl->io_master_info.cci_client->disable_optmz); } else if (o_ctrl->io_master_info.master_type == I2C_MASTER) { o_ctrl->io_master_info.client->addr = ois_info->slave_addr; CAM_DBG(CAM_OIS, "Slave addr: 0x%x", ois_info->slave_addr);