Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 152e262f authored by Kyong Hwa Bae's avatar Kyong Hwa Bae Committed by Viswanadha Raju Thotakura
Browse files

msm: camera: Fix CCI sequential write



This is a fix for 2b490d2c.
The previous change is to allow writing a register address 0x00.
To delete a condition of "if the address is 0", it removed the
multiple data writing part for sequential address. The change
introduces the issue from sequential addreess/data writing.
(Instead of making a packet :
<address_0x20><data_0xA><data_0xB><data_0xC>,
It makes seperate packets with a wrong address. The addresses
of all packets from the second are 0x0 that is not valid. :
<address_0x20><data_0xA>, <address_0x0><data_0xB>, ...)

For proper change, revert the sequential address/data writing
part. But to write the packet which address is actually 0x0,
add the seperate command of "MSM_CCI_I2C_WRITE_SEQ" and
use this condition to differentiate
between normal packet writing and sequential address writing.

Change-Id: Ibd8f7fad2629504abfee1fa66b08258e04865530
Signed-off-by: default avatarKyong Hwa Bae <kbae@codeaurora.org>
Signed-off-by: default avatarViswanadha Raju Thotakura <viswanad@codeaurora.org>
parent 4f91f3d1
Loading
Loading
Loading
Loading
+33 −18
Original line number Diff line number Diff line
@@ -213,13 +213,23 @@ static int32_t msm_cci_data_queue(struct cci_device *cci_dev,
		pr_err("%s failed line %d\n", __func__, __LINE__);
		return -EINVAL;
	}
	/* assume total size within the max queue */

	reg_addr = i2c_cmd->reg_addr;
	while (cmd_size) {
		CDBG("%s cmd_size %d addr 0x%x data 0x%x", __func__,
		CDBG("%s cmd_size %d addr 0x%x data 0x%x\n", __func__,
			cmd_size, i2c_cmd->reg_addr, i2c_cmd->reg_data);
		delay = i2c_cmd->delay;
		data[i++] = CCI_I2C_WRITE_CMD;

		/* in case of multiple command
		* MSM_CCI_I2C_WRITE : address is not continuous, so update
		*			address for a new packet.
		* MSM_CCI_I2C_WRITE_SEQ : address is continuous, need to keep
		*			the incremented address for a
		*			new packet */
		if (c_ctrl->cmd == MSM_CCI_I2C_WRITE)
			reg_addr = i2c_cmd->reg_addr;

		/* either byte or word addr */
		if (i2c_msg->addr_type == MSM_CAMERA_I2C_BYTE_ADDR)
			data[i++] = reg_addr;
@@ -228,6 +238,7 @@ static int32_t msm_cci_data_queue(struct cci_device *cci_dev,
			data[i++] = reg_addr & 0x00FF;
		}
		/* max of 10 data bytes */
		do {
			if (i2c_msg->data_type == MSM_CAMERA_I2C_BYTE_DATA) {
				data[i++] = i2c_cmd->reg_data;
				reg_addr++;
@@ -243,6 +254,9 @@ static int32_t msm_cci_data_queue(struct cci_device *cci_dev,
			}
			i2c_cmd++;
			--cmd_size;
		} while ((c_ctrl->cmd == MSM_CCI_I2C_WRITE_SEQ) &&
				(cmd_size > 0) && (i <= 10));

		data[0] |= ((i-1) << 4);
		len = ((i-1)/4) + 1;
		rc = msm_cci_validate_queue(cci_dev, len, master, queue);
@@ -867,6 +881,7 @@ static int32_t msm_cci_config(struct v4l2_subdev *sd,
		rc = msm_cci_i2c_read_bytes(sd, cci_ctrl);
		break;
	case MSM_CCI_I2C_WRITE:
	case MSM_CCI_I2C_WRITE_SEQ:
		rc = msm_cci_i2c_write(sd, cci_ctrl);
		break;
	case MSM_CCI_GPIO_WRITE:
+1 −0
Original line number Diff line number Diff line
@@ -57,6 +57,7 @@ enum msm_cci_cmd_type {
	MSM_CCI_SET_SYNC_CID,
	MSM_CCI_I2C_READ,
	MSM_CCI_I2C_WRITE,
	MSM_CCI_I2C_WRITE_SEQ,
	MSM_CCI_GPIO_WRITE,
};

+1 −1
Original line number Diff line number Diff line
@@ -159,7 +159,7 @@ int32_t msm_camera_cci_i2c_write_seq(struct msm_camera_i2c_client *client,
		reg_conf_tbl[i].reg_data = data[i];
		reg_conf_tbl[i].delay = 0;
	}
	cci_ctrl.cmd = MSM_CCI_I2C_WRITE;
	cci_ctrl.cmd = MSM_CCI_I2C_WRITE_SEQ;
	cci_ctrl.cci_info = client->cci_client;
	cci_ctrl.cfg.cci_i2c_write_cfg.reg_setting = reg_conf_tbl;
	cci_ctrl.cfg.cci_i2c_write_cfg.data_type = MSM_CAMERA_I2C_BYTE_DATA;