来源:http://blog.csdn.net/m0_37256698/article/details/70139272
需要修改的文件如下(以hi546为例):
./kernel/arch/arm/boot/dts/qcom/msm8909-camera-sensor-skua.dtsi
添加eeprom到设备树
添加eeprom信息
./kernel/drivers/media/platform/msm/camera_v2/sensor/eeprom/msm_eeprom.c
根据板子的camera name进行OTP校准
custom_hynix_hi546_otp_read函数如下:
static int custom_hynix_hi546_otp_read(struct msm_eeprom_ctrl_t *e_ctrl,
struct msm_eeprom_memory_map_t *emap, uint8_t *memptr) {
int m = 0;
int k = 0;
uint32_t addr = 0;
int rc =0;
// add for compatible code form the camera lens id --qiaodeli
int flag = 0;
#define HI546_MODULE_INFO_GROUP_SIZE 17
#define HI546_MODULE_INFO_OFFSET 1
#define HI546_MODULE_INFO_LEN_OFFSET 6
int group_size = HI546_MODULE_INFO_GROUP_SIZE;
int module_offset = HI546_MODULE_INFO_OFFSET;
int len_offset = HI546_MODULE_INFO_LEN_OFFSET;
// add end
pr_err("%s: hi546 otp read init -- qiaodeli\n", __func__);
//initial sensor
for (m = 0; m < sizeof(init_hi546_reg_array0) / (sizeof(init_hi546_reg_array0[0])); m++){
rc = e_ctrl->i2c_client.i2c_func_tbl->i2c_write(&(e_ctrl->i2c_client),
init_hi546_reg_array0[m].reg_addr, init_hi546_reg_array0[m].reg_data, MSM_CAMERA_I2C_WORD_DATA);
if (rc < 0) {
pr_err("%s: hi546 init failed\n", __func__);
return rc;
}
}
mdelay(100);
// set to otp mode
for (m = 0; m < sizeof(init_hi546_otp_array) / sizeof(init_hi546_otp_array[0]); m++){
rc = e_ctrl->i2c_client.i2c_func_tbl->i2c_write(&(e_ctrl->i2c_client),
init_hi546_otp_array[m].reg_addr, init_hi546_otp_array[m].reg_data, MSM_CAMERA_I2C_BYTE_DATA);
mdelay(init_hi546_otp_array[m].delay);
if (rc < 0) {
pr_err("%s: hi546 to otp mode failed\n", __func__);
return rc;
}
}
for (addr = emap->mem.addr, k = 0; k < (emap->mem.valid_size); addr++, k++) {
rc = e_ctrl->i2c_client.i2c_func_tbl->i2c_write(&(e_ctrl->i2c_client), 0x10A, (addr>>8)&0xff, MSM_CAMERA_I2C_BYTE_DATA);
rc |= e_ctrl->i2c_client.i2c_func_tbl->i2c_write(&(e_ctrl->i2c_client), 0x10B, addr & 0xff, MSM_CAMERA_I2C_BYTE_DATA);
rc |= e_ctrl->i2c_client.i2c_func_tbl->i2c_write(&(e_ctrl->i2c_client), 0x102, 1, MSM_CAMERA_I2C_BYTE_DATA);
rc |= e_ctrl->i2c_client.addr_type = MSM_CAMERA_I2C_WORD_DATA;
rc |= e_ctrl->i2c_client.i2c_func_tbl->i2c_write(&(e_ctrl->i2c_client), 0xF12, 1, MSM_CAMERA_I2C_BYTE_DATA);
rc |= e_ctrl->i2c_client.i2c_func_tbl->i2c_read_seq(&(e_ctrl->i2c_client), 0x108, memptr, 1);
rc |= e_ctrl->i2c_client.i2c_func_tbl->i2c_write(&(e_ctrl->i2c_client), 0xF12, 0, MSM_CAMERA_I2C_BYTE_DATA);
//pr_err("hi546 custom:addr:[0x%04x] value: (0x%x)\n", addr, *memptr);
memptr++; // must
if (rc < 0) {
pr_err("%s: hi546 read failed\n", __func__);
return rc;
}
}
// add for compatible code form the camera lens id --qiaodeli
flag = e_ctrl->cal_data.mapdata[module_offset - 1];
if (flag== 0x01)
group = 1;
else if (flag == 0x13)
group = 2;
else if (flag == 0x37)
group = 3;
else {
pr_err("%s:%d invalid group=%d", __func__, __LINE__, group);
}
pr_err("dongyunfei: group=%d\n", group);
module_len_id = *((unsigned char *)e_ctrl->cal_data.mapdata + module_offset +
(group-1)*group_size + len_offset);
pr_err("dongyunfei: module_len_id=%d\n", module_len_id);
// add end
//set to normol mode
for (m = 0; m < sizeof(hi546_otp_to_norm_mode_array)/sizeof(hi546_otp_to_norm_mode_array[0]); m++){
rc = e_ctrl->i2c_client.i2c_func_tbl->i2c_write(&(e_ctrl->i2c_client),
hi546_otp_to_norm_mode_array[m].reg_addr, hi546_otp_to_norm_mode_array[m].reg_data, 1);
if (rc < 0) {
pr_err("%s: to normal failed\n", __func__);
return rc;
}
}
return rc;
}
以上三个数组在新添加的hi546.h文件里
./kernel/drivers/media/platform/msm/camera_v2/sensor/eeprom/hi546.h
这个文件是需要添加的,可以找模组厂商要,也可以自己看datesheet写,最好找模组厂商要,自己写不一定能写全,以上kenel部分就已经结束了,下面是vendor部分。
./vendor/qcom/proprietary/mm-camera/mm-camera2/media-controller/modules/sensors/eeprom_libs/
需要在这个文件夹里添加一个hi546_sunrise文件夹,文件夹内容如下:
Android.mk是用来编译生成hi546_sunrise_sunrise.so库的,而hi546_sunrise_sunrise.c文件里是用来校验checkSum和调整rgb_gain的
./vendor/qcom/proprietary/common/config/device-vendor.mk
最后在这个文件里添加一个目标库就可以了
以上一个完整的OTP校准就已经全部完成了!