示例#1
0
int32_t bf3905_match_id(struct msm_sensor_ctrl_t *s_ctrl)
{
	int32_t rc = 0;
	uint16_t chipid = 0;
	uint16_t chipidL , chippidM;
	chipidL = chippidM = 0;
	
	rc = msm_camera_i2c_read(
			s_ctrl->sensor_i2c_client,
			s_ctrl->sensor_id_info->sensor_id_reg_addr, &chippidM,
			MSM_CAMERA_I2C_BYTE_DATA);
	if (rc < 0) {
		pr_err("%s: %s: read id failed\n", __func__,
			s_ctrl->sensordata->sensor_name);
		return rc;
	}

	rc = msm_camera_i2c_read(
			s_ctrl->sensor_i2c_client,
			s_ctrl->sensor_id_info->sensor_id_reg_addr+1, &chipidL,
			MSM_CAMERA_I2C_BYTE_DATA);
	if (rc < 0) {
		pr_err("%s: %s: read id failed\n", __func__,
			s_ctrl->sensordata->sensor_name);
		return rc;
	}
	chipid = (chippidM << 8) | chipidL;
	printk("reg_addr:%x;bf3905_match_id: %d\n", s_ctrl->sensor_id_info->sensor_id_reg_addr,chipid);
	if (chipid != s_ctrl->sensor_id_info->sensor_id) {
		pr_err("msm_sensor_match_id chip id doesnot match\n");
		return -ENODEV;
	}
	return rc;
}
示例#2
0
static int lm3642_write_bits(uint8_t reg, uint8_t val, uint8_t mask, uint8_t shift)
{
    int rc = 0;
    uint16_t reg_val = 0;
    
    rc = msm_camera_i2c_read(&i2c_client, reg, &reg_val, MSM_CAMERA_I2C_BYTE_DATA);
	if (rc < 0) {
		pr_err("lm3642_write_bits: msm_camera_i2c_read(0x%x) failed! rc = %d\n", reg, rc);
		goto error;
	}
    CDBG("lm3642_write_bits: Before: msm_camera_i2c_read(0x%x) = 0x%x .\n", reg, reg_val);

    reg_val &= (~(mask << shift));
    reg_val |= ((val & mask) << shift);

    printk("lm3642_write_bits: Set reg_0x%x = 0x%x .\n", reg, reg_val);
    rc = msm_camera_i2c_write(&i2c_client, reg, reg_val, MSM_CAMERA_I2C_BYTE_DATA);
    if (rc < 0) {
        pr_err("lm3642_write_bits: msm_camera_i2c_write(0x%x) failed! rc = %d\n", reg, rc);
        goto error;
    }

    rc = msm_camera_i2c_read(&i2c_client, reg, &reg_val, MSM_CAMERA_I2C_BYTE_DATA);
    if (rc < 0) {
        pr_err("lm3642_write_bits: msm_camera_i2c_read(0x%x) failed! rc = %d\n", reg, rc);
        goto error;
    }
    CDBG("lm3642_write_bits: After: msm_camera_i2c_read(0x%x) = 0x%x .\n", reg, reg_val);

error:
    return rc;
}
示例#3
0
static uint16_t imx135_sensor_otp_read_merge(struct msm_sensor_ctrl_t *s_ctrl,uint16_t addr)
{
	uint16_t data_l, data_h,ouput_d;

	msm_camera_i2c_read(s_ctrl->sensor_i2c_client, addr, &data_l,MSM_CAMERA_I2C_BYTE_DATA);
	msm_camera_i2c_read(s_ctrl->sensor_i2c_client, addr+1, &data_h,MSM_CAMERA_I2C_BYTE_DATA);
	ouput_d = data_l << 8 | data_h ;
	return ouput_d;
}
int32_t fih_parse_otp_info_ar0543(struct msm_sensor_ctrl_t *s_ctrl)
{
    int32_t  rc       = 0;
    int32_t  i        = 0;
    uint16_t read_val = 0;

    for (i = 0; i < TYPE_MAX; i++) 
    {
        if (fih_check_otp_status_ar0543(s_ctrl, TYPE_32 - i) >= 0)
        {
            rc = msm_camera_i2c_read(s_ctrl->sensor_i2c_client,OTP_PID_REG,&read_val,
                 MSM_CAMERA_I2C_WORD_DATA);
            if (rc < 0)
            {
                pr_err("fih_parse_otp_info_ar0543: Read OTP_REG_PID failed, otp_type = %d !\n", (TYPE_32 - i));
                return rc;
            }

            if (read_val != 0)
            {
                printk("fih_parse_otp_info_ar0543: Start parse OTP data, otp_type = %d !\n", (TYPE_32 - i));
                goto PARSE_DATA;
            }
            else
                printk("fih_parse_otp_info_ar0543: TYPE_%d has no valid otp data.\n", (TYPE_32 - i));
        }
    }
    
    if (read_val == 0)
    {
        pr_err("fih_parse_otp_info_ar0543: ERR: All type have no valid otp data !\n");
        rc = -EFAULT;
        return rc;
    }

PARSE_DATA:

    for (i = 0; i < OTP_INFO_MAX; i++) 
    {
      rc = msm_camera_i2c_read(s_ctrl->sensor_i2c_client, (OTP_PID_REG + i*2), &read_val, MSM_CAMERA_I2C_WORD_DATA);
      if (rc < 0)
      {
          pr_err("fih_parse_otp_info_ar0543: Read REG_0x%x failed !\n", (OTP_PID_REG + i*2));
          return rc;
      }
      otp_data_ar0543[i] = read_val;
      printk("fih_parse_otp_info_ar0543: otp_data_ar0543[%d] = REG_0x%x = 0x%x. \n", i, (OTP_PID_REG + i*2), otp_data_ar0543[i]);
    }

    printk("fih_parse_otp_info_ar0543: Success.\n");
    return rc;
}
示例#5
0
int8_t hi351_get_snapshot_data(struct msm_sensor_ctrl_t *s_ctrl, struct snapshot_soc_data_cfg *snapshot_data) {
	int rc = 0;
	u16 analogGain = 0;
	u32 exposureTime = 0;
	u32 isoSpeed = 0;
	u16 Exposure1 = 0;
	u16 Exposure2 = 0;
	u16 Exposure3 = 0;
	u16 Exposure4 = 0;
	int ExposureTotal = 0;

	//ISO Speed
	rc = msm_camera_i2c_write(s_ctrl->sensor_i2c_client, 0x03, 0x20, MSM_CAMERA_I2C_BYTE_DATA);
	rc = msm_camera_i2c_read(s_ctrl->sensor_i2c_client, 0x50, &analogGain, MSM_CAMERA_I2C_BYTE_DATA);

	if (rc < 0) {
		pr_err("%s: error to get analog & digital gain \n", __func__);
		return rc;
	}
	//Exposure Time
	rc = msm_camera_i2c_write(s_ctrl->sensor_i2c_client, 0x03, 0x20, MSM_CAMERA_I2C_BYTE_DATA);
	rc = msm_camera_i2c_read(s_ctrl->sensor_i2c_client, 0x20, &Exposure1, MSM_CAMERA_I2C_BYTE_DATA);
	rc = msm_camera_i2c_read(s_ctrl->sensor_i2c_client, 0x21, &Exposure2, MSM_CAMERA_I2C_BYTE_DATA);
	rc = msm_camera_i2c_read(s_ctrl->sensor_i2c_client, 0x22, &Exposure3, MSM_CAMERA_I2C_BYTE_DATA);
	rc = msm_camera_i2c_read(s_ctrl->sensor_i2c_client, 0x23, &Exposure4, MSM_CAMERA_I2C_BYTE_DATA);

	if (rc < 0) {
		pr_err("%s: error to get exposure time \n", __func__);
		return rc;
	}

	if( analogGain <= 0x28 ){
		pr_err("[CHECK]%s : iso speed - analogGain = 0x%x ",  __func__, analogGain);
		analogGain = 0x28;  		//analogGain cannot move down than 0x28
	}
	//ISO speed
	isoSpeed = ((analogGain / 32) * 100);
	//Exposure Time
	ExposureTotal = ((Exposure1<<24)|(Exposure2<<16)|(Exposure3<<8)|Exposure4);
	if (ExposureTotal <= 0) {
		exposureTime = 600000;
	}else {
	exposureTime = ExposureTotal;
	}

	snapshot_data->iso_speed = isoSpeed;
	snapshot_data->exposure_time = exposureTime;
	pr_err("[CHECK]Camera Snapshot Data iso_speed = %d, exposure_time = %d \n", snapshot_data->iso_speed, snapshot_data->exposure_time);

	return 0;

}
示例#6
0
static int32_t imx105_match_id(struct msm_sensor_ctrl_t *s_ctrl)
{

    int32_t rc = 0;
    int32_t i;
    uint16_t chipid = 0;
    uint16_t chipver = 0;

    rc = msm_camera_i2c_read(s_ctrl->sensor_i2c_client,
                             s_ctrl->sensor_id_info->sensor_id_reg_addr,
                             &chipid, MSM_CAMERA_I2C_WORD_DATA);
    if (rc < 0) {
        pr_err("%s: %s: read id failed\n", __func__,
               s_ctrl->sensordata->sensor_name);
        return rc;
    }

    pr_info("imx105_sensor id: 0x%04x\n", chipid);
    if (chipid != 0x0105) {
        pr_err("imx105_match_id chip id doesnot match 0x%04x\n",
               chipid);
        return -ENODEV;
    }

    for (i = 4; i >= 0; i--) {
        rc = msm_camera_i2c_read(s_ctrl->sensor_i2c_client,
                                 0x34C9, &chipid,
                                 MSM_CAMERA_I2C_WORD_DATA);
        if (rc < 0)
            pr_info("imx105 select otp bank error rc:%d\n", rc);

        msm_camera_i2c_read(s_ctrl->sensor_i2c_client,
                            0x3500 + i * 8, &chipid,
                            MSM_CAMERA_I2C_WORD_DATA);

        if ((chipid >= 0x0801) && (chipid <= 0x0804)) {
            chipver = chipid & 0x000f;
            pr_info("imx105 vendor:%d from:0x%04x @ %04x", chipver,
                    chipid, 0x3500 + i * 8);
        } else if (chipid == 0x0811) {
            chipver = 1;
        } else {
            chipver = 0;
        }
        if (chipver != 0)
            break;
    }
    pr_info("%s vendor:%d from:0x%04x @ %04x", sensor_names[chipver],
            chipver, chipid, 0x3500 + i * 8);
    s_ctrl->sensordata->sensor_name = sensor_names[chipver];
    return 0;
}
示例#7
0
static int32_t mt9e013_match_id(struct msm_sensor_ctrl_t *s_ctrl)
{

	int32_t rc = 0;
	uint16_t chipid = 0;
	uint16_t chipver = 0;

	rc = msm_camera_i2c_read(s_ctrl->sensor_i2c_client,
				 s_ctrl->sensor_id_info->sensor_id_reg_addr,
				 &chipid, MSM_CAMERA_I2C_WORD_DATA);
	if (rc < 0) {
		pr_err("%s: %s: read id failed\n", __func__,
		       s_ctrl->sensordata->sensor_name);
		return rc;
	}

	CDBG("mt9e013_sensor id: 0x%04x\n", chipid);
	if (chipid != 0x4b00) {
		pr_err("mt9e013_match_id chip id doesnot match 0x%04x\n",
		       chipid);
		return -ENODEV;
	}
	msm_camera_i2c_read(s_ctrl->sensor_i2c_client,
			    0x0002, &chipver, MSM_CAMERA_I2C_WORD_DATA);
	msm_camera_i2c_read(s_ctrl->sensor_i2c_client,
			    0x301A, &chipid, MSM_CAMERA_I2C_WORD_DATA);
	msm_camera_i2c_write(s_ctrl->sensor_i2c_client,
			     0x301A, chipid | 1 << 8, MSM_CAMERA_I2C_WORD_DATA);
	msm_camera_i2c_read(s_ctrl->sensor_i2c_client,
			    0x301A, &chipid, MSM_CAMERA_I2C_WORD_DATA);
	msm_camera_i2c_read(s_ctrl->sensor_i2c_client,
			    0x3026, &chipid, MSM_CAMERA_I2C_WORD_DATA);

	vendor = chipid & 0xf;
	if ((chipver & 0xf000) == 0x1000) {	/* A8141 */
		if (vendor == SUNNY)
			vendor = SUNNY1;
		if (vendor == LITEON)
			vendor = LITEON1;
		memcpy(mt9e013_recommend_settings, mt9e013_recommend_settings2,
		       ARRAY_SIZE(mt9e013_recommend_settings));
	}
	if ((vendor == SUNNY) || (vendor == SUNNY1))
		mt9e013_read_otp_sunny(s_ctrl);
	else
		mt9e013_read_otp(s_ctrl);

	pr_info("mt9e013 gpi:%x ver:%x vendor:%d", chipid, chipver, vendor);
	s_ctrl->sensordata->sensor_name = sensor_names[vendor];
	return 0;
}
示例#8
0
static int32_t iu091_sensor_otp_read(struct msm_sensor_ctrl_t *s_ctrl)
{
    int32_t rc = 0;

    char bank = 0x00;
    int  read_offset;
    uint16_t* opt_data_uint16;
    uint16_t read_addr = OTP_READ_OUT_REGISTER_START_ADDR;

    IU091_LOG_DBG("START\n");

    for( bank = 0; bank <= OTP_READ_BANK_MAX; bank++)
    {
        rc = msm_camera_i2c_write(
                s_ctrl->sensor_i2c_client,
                OTP_READ_BANK_ADDR,
                bank,
                MSM_CAMERA_I2C_BYTE_DATA);

        if(rc < 0){
            IU091_LOG_ERR("%s: i2c_write failed\n", __func__);
            return rc;
        }

        for( read_offset = 0; read_offset < OTP_READ_BANK_DATA_SIZE ; read_offset+=sizeof(uint16_t) )
        {
            rc = msm_camera_i2c_read(
                s_ctrl->sensor_i2c_client,
                read_addr, 
                (uint16_t*)&otp_data[bank*OTP_READ_BANK_DATA_SIZE + read_offset],
                sizeof(uint16_t));

            if(rc < 0){
                IU091_LOG_ERR("%s: i2c_read failed\n", __func__);
                return rc;
            }

            IU091_LOG_DBG("bank=0x%X,read_addr=0x%X,read_offset=0x%X\n",bank,read_addr,read_offset);
            read_addr = read_addr + sizeof(uint16_t);
        }
    }
    
    
    read_addr = 0;
    opt_data_uint16 = (uint16_t*)&otp_data[0];

#if IU091_LOG_DBG_ON
    IU091_LOG_DBG("----- otp_read -----\n");
    for( bank = 0; bank <= OTP_READ_BANK_MAX; bank++)
    {
        IU091_LOG_DBG("bank 0x%02X:",bank);
        for ( read_offset = 0; read_offset < 4; read_offset++)
            IU091_LOG_DBG(" 0x%04X",opt_data_uint16[bank*4 + read_offset]);
        IU091_LOG_DBG("\n");
    }
#endif

    IU091_LOG_DBG("END\n");
    return rc;
}
int32_t hi542_sensor_match_id(struct msm_sensor_ctrl_t *s_ctrl)
{
	int32_t rc = 0;
	uint16_t chipid = 0;
	rc = msm_camera_i2c_read(
			s_ctrl->sensor_i2c_client,
			s_ctrl->sensor_id_info->sensor_id_reg_addr, &chipid,
			MSM_CAMERA_I2C_BYTE_DATA);
	if (rc < 0) {
		pr_err("%s: %s: read id failed\n", __func__,
			s_ctrl->sensordata->sensor_name);
		return rc;
	}

	printk("hi542_sensor id: 0x%x\n", chipid);
	printk("sensor_name: %s\n", s_ctrl->sensordata->sensor_name);
	printk("camera_type: %d\n", s_ctrl->sensordata->camera_type);

	if(s_ctrl->sensordata->camera_type == FRONT_CAMERA_2D)
		strcpy(cellon_msm_sensor_name[FRONT_CAMERA_2D], s_ctrl->sensordata->sensor_name);
	if(s_ctrl->sensordata->camera_type == BACK_CAMERA_2D)
		strcpy(cellon_msm_sensor_name[BACK_CAMERA_2D], s_ctrl->sensordata->sensor_name);
	
	if (chipid != s_ctrl->sensor_id_info->sensor_id) {
		pr_err("hi542_sensor_match_id chip id doesnot match\n");
		return -ENODEV;
	}
	return rc;
}
示例#10
0
static int32_t ov7736_set_gamma(struct msm_sensor_ctrl_t *s_ctrl, uint8_t unity)
{
	int32_t rc = 0;
	uint16_t readdata;
	uint8_t data;

	rc = msm_camera_i2c_read(
			s_ctrl->sensor_i2c_client,
			0x5000, &readdata,
			MSM_CAMERA_I2C_BYTE_DATA);

	if (rc < 0) {
		pr_err("%s: read gamma register failed\n", __func__);
		return rc;
	}

	data = (uint8_t)readdata;

	if (unity)
		data |= 0x40;
	else
		data &= 0xBF;

	rc = msm_camera_i2c_write(
			s_ctrl->sensor_i2c_client,
			0x5000, data,
			MSM_CAMERA_I2C_BYTE_DATA);

	if (rc < 0) {
		pr_err("%s: write gamma register failed\n", __func__);
		return rc;
	}

	return rc;
}
示例#11
0
int32_t msm_sensor_match_id(struct msm_sensor_ctrl_t *s_ctrl)
{
	int32_t rc = 0;
	uint16_t chipid = 0;
	rc = msm_camera_i2c_read(
			s_ctrl->sensor_i2c_client,
			s_ctrl->sensor_id_info->sensor_id_reg_addr, &chipid,
			MSM_CAMERA_I2C_WORD_DATA);
	if (rc < 0) {
		pr_err("%s: %s: read id failed\n", __func__,
			s_ctrl->sensordata->sensor_name);
		return rc;
	}

#ifdef CONFIG_MACH_ACER_A9
	pr_info("msm_camera_sensor name: %s, id: 0x%x\n", s_ctrl->sensor_i2c_driver->driver.name, chipid);
#else
	CDBG("msm_sensor id: %d\n", chipid);
#endif
	if (chipid != s_ctrl->sensor_id_info->sensor_id) {
		pr_err("msm_sensor_match_id chip id doesnot match\n");
		return -ENODEV;
	}
	return rc;
}
示例#12
0
int32_t msm_sensor_match_id(struct msm_sensor_ctrl_t *s_ctrl)
{
	int32_t rc = 0;
	uint16_t chipid = 0;
	pr_info("%s\n", __func__);

	rc = msm_camera_i2c_read(
			s_ctrl->sensor_i2c_client,
			s_ctrl->sensor_id_info->sensor_id_reg_addr, &chipid,
			MSM_CAMERA_I2C_WORD_DATA);
	if (rc < 0) {
		pr_warning("%s: read id failed\n", __func__);
		return rc;
	}

	pr_info("%s: msm_sensor id: 0x%x,s_ctrl->sensor_id_info->sensor_id=0x%x\n", __func__, chipid, s_ctrl->sensor_id_info->sensor_id);
	if (chipid != s_ctrl->sensor_id_info->sensor_id) {
		if (chipid == 0x174 && s_ctrl->sensor_id_info->sensor_id == 0x175){
		//Optical promise ONLY this 100 pcs have wrong. Others sensor will be OK.
			pr_info("%s: WA for Liteon module written wrong sensor ID as IMX174\n", __func__);
			return rc;
		}
		pr_info("msm_sensor_match_id chip id doesnot match\n");
		return -ENODEV;
	}
	return rc;
}
示例#13
0
static int lm3642_init( enum lm3642_pin_enable torch_pin_en, 
                         enum lm3642_pin_enable strobe_pin_en, 
                         enum lm3642_pin_enable tx_pin_en)
{
    int rc = 0;
    uint16_t reg_val = 0;

	/*set enable register */
    rc = msm_camera_i2c_read(&i2c_client, REG_ENABLE, &reg_val, MSM_CAMERA_I2C_BYTE_DATA);
	if (rc < 0) {
		pr_err("lm3642_init: msm_camera_i2c_read(0x%x) failed! rc = %d\n", REG_ENABLE, rc);
		goto error;
	}
    CDBG("lm3642_init: msm_camera_i2c_read(0x%x) = 0x%x .\n", REG_ENABLE, reg_val);

	reg_val &= (~EX_PIN_ENABLE_MASK);
	reg_val |= ((torch_pin_en & 0x01) << TORCH_PIN_EN_SHIFT);
	reg_val |= ((strobe_pin_en & 0x01) << STROBE_PIN_EN_SHIFT);
	reg_val |= ((tx_pin_en & 0x01) << TX_PIN_EN_SHIFT);

    rc = msm_camera_i2c_write(&i2c_client, REG_ENABLE, reg_val, MSM_CAMERA_I2C_BYTE_DATA);
    if (rc < 0) {
        pr_err("lm3642_init: msm_camera_i2c_write(0x%x) failed! rc = %d\n", REG_ENABLE, rc);
        goto error;
    }
    CDBG("lm3642_init: Set reg_0x%x = 0x%x .\n", REG_ENABLE, reg_val);

error:
    return rc;

}
示例#14
0
/*=============================================================*/
int32_t msm_sensor_adjust_frame_lines(struct msm_sensor_ctrl_t *s_ctrl,
	uint16_t res)
{
	uint16_t cur_line = 0;
	uint16_t exp_fl_lines = 0;
	if (s_ctrl->sensor_exp_gain_info) {
		if (s_ctrl->prev_gain && s_ctrl->prev_line &&
			s_ctrl->func_tbl->sensor_write_exp_gain)
			s_ctrl->func_tbl->sensor_write_exp_gain(
				s_ctrl,
				s_ctrl->prev_gain,
				s_ctrl->prev_line);

		msm_camera_i2c_read(s_ctrl->sensor_i2c_client,
			s_ctrl->sensor_exp_gain_info->coarse_int_time_addr,
			&cur_line,
			MSM_CAMERA_I2C_WORD_DATA);
		exp_fl_lines = cur_line +
			s_ctrl->sensor_exp_gain_info->vert_offset;
		if (exp_fl_lines > s_ctrl->msm_sensor_reg->
			output_settings[res].frame_length_lines)
			msm_camera_i2c_write(s_ctrl->sensor_i2c_client,
				s_ctrl->sensor_output_reg_addr->
				frame_length_lines,
				exp_fl_lines,
				MSM_CAMERA_I2C_WORD_DATA);
		CDBG("%s cur_fl_lines %d, exp_fl_lines %d\n", __func__,
			s_ctrl->msm_sensor_reg->
			output_settings[res].frame_length_lines,
			exp_fl_lines);
	}
	return 0;
}
int32_t msm_sensor_match_id(struct msm_sensor_ctrl_t *s_ctrl)
{
	int32_t rc = 0;
	uint16_t chipid = 0;
#ifdef CONFIG_PANTECH_CAMERA
    if(s_ctrl->sensor_id_info->sensor_id == 0)
        return 0;
#endif    
	rc = msm_camera_i2c_read(
			s_ctrl->sensor_i2c_client,
			s_ctrl->sensor_id_info->sensor_id_reg_addr, &chipid,
			MSM_CAMERA_I2C_WORD_DATA);
	if (rc < 0) {
		pr_err("%s: %s: read id failed\n", __func__,
			s_ctrl->sensordata->sensor_name);
		return rc;
	}

	CDBG("msm_sensor id: %d\n", chipid);
	if (chipid != s_ctrl->sensor_id_info->sensor_id) {
		pr_err("msm_sensor_match_id chip id doesnot match\n");
		return -ENODEV;
	}
	return rc;
}
/*******************************************************************************
* index: index of otp group. (0, 1, 2)
* return value:
*     0, group index is empty
*     1, group index has invalid data
*     2, group index has valid data
*******************************************************************************/
uint16_t ov5648_truly_cm8352_check_otp(struct msm_sensor_ctrl_t *s_ctrl, uint16_t index)
{
	uint16_t temp, i;
	uint16_t address;
	/* read otp into buffer */
	msm_camera_i2c_write(s_ctrl->sensor_i2c_client, 0x3d21, 0x01,
		MSM_CAMERA_I2C_BYTE_DATA);

	usleep_range(2000, 2500);
	address = 0x3d05 + index*9;
	msm_camera_i2c_read(s_ctrl->sensor_i2c_client, address, &temp,
		MSM_CAMERA_I2C_BYTE_DATA);

	/* disable otp read */
	msm_camera_i2c_write(s_ctrl->sensor_i2c_client, 0x3d21, 0x00,
		MSM_CAMERA_I2C_BYTE_DATA);

	/* clear otp buffer */
	for (i = 0; i < 32; i++) {
		msm_camera_i2c_write(s_ctrl->sensor_i2c_client, (0x3d00+i),
				0x00, MSM_CAMERA_I2C_BYTE_DATA);
	}

	if (!temp)
		return 0;
	else if ((!(temp & 0x80)) && (temp&0x7f))
		return 2;
	else
		return 1;
}
示例#17
0
int32_t imx111_sensor_set_fps(struct msm_sensor_ctrl_t *s_ctrl,
						struct fps_cfg *fps)
{
	uint16_t total_lines_per_frame;
	int32_t rc = 0;
	s_ctrl->fps_divider = fps->fps_div;

	if (s_ctrl->curr_res != MSM_SENSOR_INVALID_RES) {
		uint16_t fl_read = 0;
		total_lines_per_frame = (uint16_t)
			((s_ctrl->curr_frame_length_lines) *
			s_ctrl->fps_divider/Q10);

		rc = msm_camera_i2c_read(s_ctrl->sensor_i2c_client,
			s_ctrl->sensor_output_reg_addr->frame_length_lines,
			&fl_read, MSM_CAMERA_I2C_WORD_DATA);

		CDBG("%s: before_fl = %d, new_fl = %d", __func__, fl_read, total_lines_per_frame);

		if(fl_read < total_lines_per_frame) {
			pr_err("%s: Write new_fl (before_fl = %d, new_fl = %d)", __func__, fl_read, total_lines_per_frame);
			rc = msm_camera_i2c_write(s_ctrl->sensor_i2c_client,
				s_ctrl->sensor_output_reg_addr->frame_length_lines,
				total_lines_per_frame, MSM_CAMERA_I2C_WORD_DATA);
		}
	}
	return rc;
}
示例#18
0
int32_t hi351_match_id(struct msm_sensor_ctrl_t *s_ctrl)
{
	int32_t rc = 0;
	uint16_t chipid = 0;

	rc = msm_camera_i2c_write(
			s_ctrl->sensor_i2c_client,
			SENSOR_REG_PAGE_ADDR,
			SENSOR_REG_PAGE_0,
			MSM_CAMERA_I2C_BYTE_DATA);

	rc = msm_camera_i2c_read(
			s_ctrl->sensor_i2c_client,
			s_ctrl->sensor_id_info->sensor_id_reg_addr, &chipid,
			MSM_CAMERA_I2C_BYTE_DATA);
	if (rc < 0) {
		pr_err("%s: %s: read id failed\n", __func__,
			s_ctrl->sensordata->sensor_name);
		return rc;
	}

	CDBG("hi351_sensor id: %d\n", chipid);
	if (chipid != s_ctrl->sensor_id_info->sensor_id) {
		pr_err("hi351_match chip id doesnot match\n");
		return -ENODEV;
	}
	return rc;
}
static int32_t s5k5b3g_match_id(struct msm_sensor_ctrl_t *s_ctrl)
{
	int32_t rc = 0;
	uint16_t chipid = 0;

	/*Read sensor id*/
	rc = msm_camera_i2c_read(
			s_ctrl->sensor_i2c_client,
			s_ctrl->sensor_id_info->sensor_id_reg_addr, &chipid,
			MSM_CAMERA_I2C_WORD_DATA);
	if (rc < 0) {
		pr_err("%s: read id failed\n", __func__);
		return rc;
	}

	if (chipid != s_ctrl->sensor_id_info->sensor_id) {
		pr_err("%s: chip id %x does not match expected %x\n", __func__,
				chipid, s_ctrl->sensor_id_info->sensor_id);
		return -ENODEV;
	}

	rc = s5k5b3g_read_otp(s_ctrl);
	if (rc < 0) {
		pr_err("%s: unable to read otp data\n", __func__);
		s5k5b3g_otp_info.size = 0;
	} else {
		s5k5b3g_otp_info.otp_info = (uint8_t *)s5k5b3g_otp;
		s5k5b3g_otp_info.size = S5K5B3G_OTP_SIZE;
	}

	pr_debug("s5k5b3g: match_id success\n");
	return 0;
}
示例#20
0
static int32_t iu091_get_exif_param(struct msm_sensor_ctrl_t *s_ctrl,
                                      struct get_exif_param_inf *get_exif_param)
{
    int32_t rc = 0;
    
    uint16_t coarse_integration_time = 0x0000; 
    uint16_t line_length_DVE046         = 0x0000; 
    uint16_t fine_integration_time   = 0x0000; 
    uint16_t analog_gain_code_global = 0x0000; 
    uint16_t digital_gain_greenr     = 0x0000; 

    rc = msm_camera_i2c_read(s_ctrl->sensor_i2c_client, 
                             0x0202, &coarse_integration_time, MSM_CAMERA_I2C_WORD_DATA);
    if(rc < 0){
        return rc;
    }

    rc = msm_camera_i2c_read(s_ctrl->sensor_i2c_client, 
                             0x0342, &line_length_DVE046, MSM_CAMERA_I2C_WORD_DATA);
    if(rc < 0){
        return rc;
    }

    rc = msm_camera_i2c_read(s_ctrl->sensor_i2c_client, 
                             0x0204, &analog_gain_code_global, MSM_CAMERA_I2C_WORD_DATA);
    if(rc < 0){
        return rc;
    }

    get_exif_param->coarse_integration_time = coarse_integration_time; 
    get_exif_param->line_length_DVE046         = line_length_DVE046;         
    get_exif_param->fine_integration_time   = fine_integration_time;   
    get_exif_param->analog_gain_code_global = analog_gain_code_global; 
    get_exif_param->digital_gain_greenr     = digital_gain_greenr;     











    return rc;
}
示例#21
0
static int32_t ov7736_get_exposure_time(struct msm_sensor_ctrl_t *s_ctrl,
		uint32_t *ex_time)
{
	uint32_t exposure_time = 0;
	uint16_t  reg16_19 = 0;
	uint16_t  reg8_15 = 0;
	uint16_t  reg0_7 = 0;
	int32_t rc = 0;

	rc = msm_camera_i2c_read(
			s_ctrl->sensor_i2c_client,
			0x3500, &reg16_19,
			MSM_CAMERA_I2C_BYTE_DATA);

	if (rc < 0) {
		pr_err("%s: read id failed\n", __func__);
		return rc;
	}

	rc = msm_camera_i2c_read(
			s_ctrl->sensor_i2c_client,
			0x3501, &reg8_15,
			MSM_CAMERA_I2C_BYTE_DATA);

	if (rc < 0) {
		pr_err("%s: read id failed\n", __func__);
		return rc;
	}

	rc = msm_camera_i2c_read(
			s_ctrl->sensor_i2c_client,
			0x3502, &reg0_7,
			MSM_CAMERA_I2C_BYTE_DATA);

	if (rc < 0) {
		pr_err("%s: read id failed\n", __func__);
		return rc;
	}
	exposure_time = (exposure_time | (uint8_t)(reg16_19 & 0x0F)) << 16;
	exposure_time = exposure_time | (reg8_15 << 8);
	exposure_time = exposure_time | (uint8_t) reg0_7;

	pr_debug("exposure_time %x\n", exposure_time);
	*ex_time = exposure_time;
	return rc;
}
示例#22
0
static int32_t imx135_get_exif_param(struct msm_sensor_ctrl_t *s_ctrl,
                                      struct get_exif_param_inf *get_exif_param)
{
    int32_t rc = 0;

    uint16_t coarse_integration_time = 0x0000; 
    uint16_t line_length_DVE046         = 0x0000; 
    uint16_t fine_integration_time   = 0x0000; 
    uint16_t analog_gain_code_global = 0x0000; 
    uint16_t digital_gain_greenr     = 0x0000; 

    rc = msm_camera_i2c_read(s_ctrl->sensor_i2c_client,
                             0x3012, &coarse_integration_time, MSM_CAMERA_I2C_WORD_DATA);
    if(rc < 0){
        return rc;
    }

    rc = msm_camera_i2c_read(s_ctrl->sensor_i2c_client,
                             0x300C, &line_length_DVE046, MSM_CAMERA_I2C_WORD_DATA);
    if(rc < 0){
        return rc;
    }

    rc = msm_camera_i2c_read(s_ctrl->sensor_i2c_client,
                             0x3028, &analog_gain_code_global, MSM_CAMERA_I2C_WORD_DATA);
    if(rc < 0){
        return rc;
    }

    get_exif_param->coarse_integration_time = coarse_integration_time; 
    get_exif_param->line_length_DVE046         = line_length_DVE046;         
    get_exif_param->fine_integration_time   = fine_integration_time;   
    get_exif_param->analog_gain_code_global = analog_gain_code_global; 
    get_exif_param->digital_gain_greenr     = digital_gain_greenr;     


    IMX135_LOG_DBG("for debug");
    IMX135_LOG_DBG("coarse_integration_time  : 0x%x",coarse_integration_time);  
    IMX135_LOG_DBG("line_length_DVE046          : 0x%x",line_length_DVE046);          
    IMX135_LOG_DBG("fine_integration_time    : 0x%x",fine_integration_time);    
    IMX135_LOG_DBG("analog_gain_code_global  : 0x%x",analog_gain_code_global);  
    IMX135_LOG_DBG("digital_gain_greenr      : 0x%x",digital_gain_greenr);      

    return rc;
}
示例#23
0
int read_sccb16(uint32_t address, struct msm_sensor_ctrl_t *s_ctrl)
{
uint16_t temp, flag;
temp= msm_camera_i2c_read(
			s_ctrl->sensor_i2c_client,
			address, &flag,
			MSM_CAMERA_I2C_BYTE_DATA);
return flag;
}
示例#24
0
static int32_t ov9740_get_line_count(struct msm_sensor_ctrl_t *s_ctrl, uint32_t *value)
{
	int32_t rc = 0;
	uint16_t reg_0202, reg_0203;

	// exposure_lines = 0x0202 bit[7:0], 0x0203 bit[7:0]
	rc = msm_camera_i2c_read(s_ctrl->sensor_i2c_client,
				0x0202, &reg_0202,
				MSM_CAMERA_I2C_BYTE_DATA);
	rc = msm_camera_i2c_read(s_ctrl->sensor_i2c_client,
				0x0203, &reg_0203,
				MSM_CAMERA_I2C_BYTE_DATA);

	*value = (uint32_t)reg_0202<<8 | (uint32_t)reg_0203;

	CDBG("%s: exposure_lines = %u\n", __func__, *value);

	return rc;
}
static int imx175_read_fuseid(struct sensor_cfg_data *cdata,
	struct msm_sensor_ctrl_t *s_ctrl)
{
	int32_t rc = 0;
	int i;
	uint16_t read_data = 0;
	uint8_t OTP[10] = {0};

	rc = msm_camera_i2c_write(s_ctrl->sensor_i2c_client, 0x3400, 0x01, MSM_CAMERA_I2C_BYTE_DATA);
	if (rc < 0)
		pr_err("%s: msm_camera_i2c_write 0x3400 failed\n", __func__);

	
	rc = msm_camera_i2c_write(s_ctrl->sensor_i2c_client, 0x3402, 0x01, MSM_CAMERA_I2C_BYTE_DATA);
	if (rc < 0)
		pr_err("%s: msm_camera_i2c_write 0x3402 failed\n", __func__);

	for (i = 0; i < 10; i++) {
		rc = msm_camera_i2c_read(s_ctrl->sensor_i2c_client, (0x3404 + i), &read_data, MSM_CAMERA_I2C_BYTE_DATA);
		if (rc < 0)
			pr_err("%s: msm_camera_i2c_read 0x%x failed\n", __func__, (0x3404 + i));

		OTP[i] = (uint8_t)(read_data&0x00FF);
		read_data = 0;
	}

	pr_info("%s: VenderID=%x,LensID=%x,SensorID=%02x%02x\n", __func__,
		OTP[0], OTP[1], OTP[2], OTP[3]);
	pr_info("%s: ModuleFuseID= %02x%02x%02x%02x%02x%02x\n", __func__,
		OTP[4], OTP[5], OTP[6], OTP[7], OTP[8], OTP[9]);

	cdata->cfg.fuse.fuse_id_word1 = 0;
	cdata->cfg.fuse.fuse_id_word2 = (OTP[0]);
	cdata->cfg.fuse.fuse_id_word3 =
		(OTP[4]<<24) |
		(OTP[5]<<16) |
		(OTP[6]<<8) |
		(OTP[7]);
	cdata->cfg.fuse.fuse_id_word4 =
		(OTP[8]<<8) |
		(OTP[9]);

	pr_info("imx175: fuse->fuse_id_word1:%d\n",
		cdata->cfg.fuse.fuse_id_word1);
	pr_info("imx175: fuse->fuse_id_word2:%d\n",
		cdata->cfg.fuse.fuse_id_word2);
	pr_info("imx175: fuse->fuse_id_word3:0x%08x\n",
		cdata->cfg.fuse.fuse_id_word3);
	pr_info("imx175: fuse->fuse_id_word4:0x%08x\n",
		cdata->cfg.fuse.fuse_id_word4);
	return 0;

}
int32_t msm_sensor_match_id(struct msm_sensor_ctrl_t *s_ctrl)
{
	int32_t rc = 0;
	uint16_t chipid = 0;
       if(s_ctrl->sensor_id_info->sensor_id_reg_addr_ext)
       	{
	rc = msm_camera_i2c_write_tbl(s_ctrl->sensor_i2c_client,
		s_ctrl->sensor_id_info->sensor_id_reg_addr_ext->conf,
		s_ctrl->sensor_id_info->sensor_id_reg_addr_ext->size,
		s_ctrl->sensor_id_info->sensor_id_reg_addr_ext->data_type);
	if (rc < 0) {
		CDBG("%s: read id first failed\n", __func__);
		return rc;
	       }
	}
	   
#if 0 
	rc = msm_camera_i2c_read(
			s_ctrl->sensor_i2c_client,
			s_ctrl->sensor_id_info->sensor_id_reg_addr, &chipid,
			MSM_CAMERA_I2C_WORD_DATA);
#else
	rc = msm_camera_i2c_read(
			s_ctrl->sensor_i2c_client,
			s_ctrl->sensor_id_info->sensor_id_reg_addr, &chipid,
			s_ctrl->msm_sensor_reg->default_data_type);
#endif
	if (rc < 0) {
		pr_err("%s: %s: read id failed\n", __func__,
			s_ctrl->sensordata->sensor_name);
		return rc;
	}

	printk("msm_sensor id: 0x%x  0x%x\n", chipid, s_ctrl->sensor_id_info->sensor_id);
	if (chipid != s_ctrl->sensor_id_info->sensor_id) {
		pr_err("msm_sensor_match_id chip id doesnot match\n");
		return -ENODEV;
	}
	return rc;
}
int jt8ev5_get_autofocus_status(struct msm_sensor_ctrl_t *s_ctrl,
                            struct msm_sensor_v4l2_ctrl_info_t *ctrl_info, int value)
{
    int iFocusStatus = 0;
   // int rc;
    uint16_t regVal = 0,temp_reg=0;
 //   unsigned int nCounter = 0;

    CDBG("fuyipeng---%s enter-----\n", __func__);

    msleep(10);

    af_count++;
   msm_camera_i2c_read(s_ctrl->sensor_i2c_client,0x2800,&regVal,1);
    pr_err("%s, t8ev5 sequence status is %x, nCounter = %d\n",__func__,regVal,af_count);
   temp_reg = regVal;
    regVal=(regVal& 0x80);
		// Return Value for AF_OK

    if (regVal == 0)
    {
    pr_err("%s,++++++++++++= t8ev5 sequence status is +++++++++%x, nCounter = %d\n",__func__,temp_reg,af_count);
    temp_reg=(temp_reg& 0x10);
    if(temp_reg !=0)
		{
                 if (af_count > 30)
    	          {
    	              iFocusStatus = 1;
    	               af_count = 0;
                      msm_camera_i2c_write(s_ctrl->sensor_i2c_client,0x27FF,0xF7,1);
         	        msleep(50);
    	           }
                  return iFocusStatus;
		}
	else
		{
                  iFocusStatus = 1;
                  af_count = 0;
         	    msleep(50);
		}
    }
    else
    {
        if (af_count > 50)
        {
            iFocusStatus = 2;
            af_count = 0;
        }
    }
    return iFocusStatus;
}
示例#28
0
int32_t hm03d5_match_id(struct msm_sensor_ctrl_t *s_ctrl)
{
    int32_t rc = 0;
    uint16_t chipid = 0;
    uint16_t id_low  = 0;
    uint16_t id_high = 0;

    rc = msm_camera_i2c_read(
             s_ctrl->sensor_i2c_client,
             s_ctrl->sensor_id_info->sensor_id_reg_addr, &id_high,
             MSM_CAMERA_I2C_BYTE_DATA);
    if (rc < 0) {
        pr_err("%s: %s: read id_high failed\n", __func__,
               s_ctrl->sensordata->sensor_name);
        return rc;
    }

    rc = msm_camera_i2c_read(
             s_ctrl->sensor_i2c_client,
             s_ctrl->sensor_id_info->sensor_id_reg_addr2, &id_low,
             MSM_CAMERA_I2C_BYTE_DATA);
    if (rc < 0) {
        pr_err("%s: %s: read id_low failed\n", __func__,
               s_ctrl->sensordata->sensor_name);
        return rc;
    }

    chipid = (id_high << 8 | id_low);

    printk("%s: id_high = 0x%x,  id_low = 0x%x:\n", __func__, id_high, id_low);
    printk("%s: read id: 0x%x expected id 0x%x:\n", __func__, chipid, s_ctrl->sensor_id_info->sensor_id);

    if (chipid != s_ctrl->sensor_id_info->sensor_id) {
        pr_err("hm03d5_match_id chip id doesnot match\n");
        return -ENODEV;
    }
    return rc;
}
/*******************************************************************************
* otp_type: otp_type should be 0x30,0x31,0x32
* return value:
*     0, OTPM have no valid data
*     1, OTPM have valid data
*******************************************************************************/
int ar0542_check_EEPROM_status(struct msm_eeprom_ctrl_t *ectrl, int otp_type)
{
  uint16_t i = 0;
  uint16_t temp = 0;
  msm_camera_i2c_write(&ectrl->i2c_client,0x301A,0x0610,
    MSM_CAMERA_I2C_WORD_DATA);
  msm_camera_i2c_write(&ectrl->i2c_client,0x3134,0xCD95,
    MSM_CAMERA_I2C_WORD_DATA);
  msm_camera_i2c_write(&ectrl->i2c_client,0x304C,(otp_type&0xff)<<8,
    MSM_CAMERA_I2C_WORD_DATA);
  msm_camera_i2c_write(&ectrl->i2c_client,0x304A,0x0200,
    MSM_CAMERA_I2C_WORD_DATA);
  msm_camera_i2c_write(&ectrl->i2c_client,0x304A,0x0010,
    MSM_CAMERA_I2C_WORD_DATA);

  do{
    msm_camera_i2c_read(&ectrl->i2c_client,0x304A,&temp,
      MSM_CAMERA_I2C_WORD_DATA);
    if(0x60 == (temp & 0x60)){
      pr_err("%s: read success\n", __func__);
      break;
    }
    usleep_range(5000, 5100);
    i++;
  }while(i < 10);

  msm_camera_i2c_read(&ectrl->i2c_client,0x3800,&temp,
    MSM_CAMERA_I2C_WORD_DATA);
       pr_err("%s: 0x3800   = 0x%d\n",__func__,temp);
  if(0==temp){
    //OTPM have no valid data
    return 0;
  }else{
    //OTPM have valid data
    return 1;
  }
}
示例#30
0
static int32_t imx135_sensor_otp_prepare_read(struct msm_sensor_ctrl_t *s_ctrl,uint16_t page)
{
    int32_t i=0;
	uint16_t check_status;
	
	msm_camera_i2c_write(s_ctrl->sensor_i2c_client, 0x3B02, page, MSM_CAMERA_I2C_BYTE_DATA);
	
	msm_camera_i2c_write(s_ctrl->sensor_i2c_client, 0x3B00, 0x01, MSM_CAMERA_I2C_BYTE_DATA);
	
	do{
		msleep(10);
		msm_camera_i2c_read(s_ctrl->sensor_i2c_client, 0x3B01, &check_status,MSM_CAMERA_I2C_BYTE_DATA);

	}while(check_status != 0x01 && i++ < 5);
	return  ((check_status == 0x01)? 0 :-1);
}