/************************************************************************************************* * Function : otp_lenc_update * Description : Update lens correction * Return : [bool] 0 : OTP data fail 1 : otp_lenc update success **************************************************************************************************/ bool otp_lenc_update() { BYTE lsc_flag; int i, j; BYTE temp1, temp2; BYTE lsc_data[64 * 8] ={0}; lsc_flag = get_lsc_flag(); if(lsc_flag == 0xC0 || lsc_flag == 0x80) { LOG_INF("OTP lsc data invalid\n"); return 0; } else if(lsc_flag == 0x00) { LOG_INF("OTP no lsc data\n"); return 0; } for(i=0;i<8;i++) { if(!start_read_otp(0x04+i)) { LOG_INF("OTP Start read Page %d Fail!\n", 0x04+i); return 0; } for(j=0;j<64;j++) lsc_data[i*64+j] = read_cmos_sensor(0x3B04+j); } #ifdef DEBUG_IMX135_OTP for (i=0;i<504;i++) { LOG_INF("%0x ",lsc_data[i]); if((i+1)%64==0) LOG_INF("\n"); } #endif write_cmos_sensor_8(0x0104, 0x01); for(i=0;i<504;i++) //LSC SIZE is 504 BYTES write_cmos_sensor(0x4800+i, lsc_data[i]); write_cmos_sensor_8(0x0104, 0x00); //Enable LSC temp1 = read_cmos_sensor(0x0700); temp2 = read_cmos_sensor(0x3A63); temp1 = temp1 | 0x01; temp2 = temp2 | 0x01; write_cmos_sensor_8(0x0104, 0x00); write_cmos_sensor(0x0700, temp1); write_cmos_sensor(0x3A63, temp2); write_cmos_sensor_8(0x0104, 0x00); LOG_INF("OTP Update lsc finished\n"); return 1; }
/************************************************************************************************* * Function : get_otp_date * Description : get otp date value * Parameters : [BYTE] zone : OTP PAGE index , 0x00~0x0f **************************************************************************************************/ bool get_otp_date(BYTE zone) { BYTE year = 0; BYTE month = 0; BYTE day = 0; if(!start_read_otp(zone)) { LOG_INF("Start read Page %d Fail!\n", zone); return 0; } year = read_cmos_sensor(0x3B06); month = read_cmos_sensor(0x3B07); day = read_cmos_sensor(0x3B08); LOG_INF("OTP date=%02d.%02d.%02d", year,month,day); return 1; }
int read_imx219_eeprom(u8 slv_id, u16 offset, u8* data) { int ret = 0; ret = read_cmos_sensor(slv_id,offset,data); CAM_CALDB("OTP read slv_id 0x%x offset 0x%x data 0x%x\n", slv_id,offset,*data); return ret; }
int read_imx135_otp(u8 page, u16 offset, u8* data) { if(!start_read_otp(page)) { CAM_CALERR("OTP Start read Page %d Fail!\n", page); return 0; } else { *data = read_cmos_sensor(offset); //CAM_CALDB("OTP read page 0x%x offset 0x%x data 0x%x\n", page,offset,*data); } return 1; }
/************************************************************************************************* * Function : get_light_id * Description : get otp environment light temperature value * Parameters : [BYTE] zone : OTP PAGE index , 0x00~0x0f * Return : [BYTE] 0 : OTP data fail other value : driver ID data BIT0:D65(6500K) EN BIT1:D50(5100K) EN BIT2:CWF(4000K) EN BIT3:A Light(2800K) EN **************************************************************************************************/ BYTE get_light_id(BYTE zone) { BYTE light_id = 0; if(!start_read_otp(zone)) { LOG_INF("Start read Page %d Fail!\n", zone); return 0; } light_id = read_cmos_sensor(0x3B0C); LOG_INF("OTP_Light ID: 0x%02x.\n",light_id); return light_id; }
/************************************************************************************************* * Function : get_otp_driver_id * Description : get otp driver id value * Parameters : [BYTE] zone : OTP PAGE index , 0x00~0x0f * Return : [BYTE] 0 : OTP data fail other value : driver ID data **************************************************************************************************/ BYTE get_otp_driver_id(BYTE zone) { BYTE driver_id = 0; if(!start_read_otp(zone)) { LOG_INF("Start read Page %d Fail!\n", zone); return 0; } driver_id = read_cmos_sensor(0x3B0B); LOG_INF("OTP_Driver ID: 0x%02x.\n",driver_id); return driver_id; }
/************************************************************************************************* * Function : get_otp_vcm_id * Description : get otp VCM_ID value * Parameters : [BYTE] zone : OTP PAGE index , 0x00~0x0f * Return : [BYTE] 0 : OTP data fail other value : VCM ID data **************************************************************************************************/ BYTE get_otp_vcm_id(BYTE zone) { BYTE vcm_id = 0; if(!start_read_otp(zone)) { LOG_INF("Start read Page %d Fail!\n", zone); return 0; } vcm_id = read_cmos_sensor(0x3B0A); LOG_INF("OTP_VCM ID: 0x%02x.\n",vcm_id); return vcm_id; }
/************************************************************************************************* * Function : get_otp_lens_id * Description : get otp LENS_ID value * Parameters : [BYTE] zone : OTP PAGE index , 0x00~0x0f * Return : [BYTE] 0 : OTP data fail other value : LENS ID data **************************************************************************************************/ BYTE get_otp_lens_id(BYTE zone) { BYTE lens_id = 0; if(!start_read_otp(zone)) { LOG_INF("Start read Page %d Fail!\n", zone); return 0; } lens_id = read_cmos_sensor(0x3B09); LOG_INF("OTP_Lens ID: 0x%02x.\n",lens_id); return lens_id; }
/************************************************************************************************* * Function : get_otp_module_id * Description : get otp MID value * Parameters : [BYTE] zone : OTP PAGE index , 0x00~0x0f * Return : [BYTE] 0 : OTP data fail other value : module ID data , TRULY ID is 0x0001 **************************************************************************************************/ BYTE get_otp_module_id(BYTE zone) { BYTE module_id = 0; if(!start_read_otp(zone)) { LOG_INF("OTP Start read Page %d Fail!\n", zone); return 0; } module_id = read_cmos_sensor(0x3B05); LOG_INF("OTP_Module ID: 0x%02x.\n",module_id); return module_id; }
/************************************************************************************************* * Function : get_lsc_flag * Description : get LSC WRITTEN_FLAG * Return : [BYTE], if 0x40 , this type has valid lsc data, otherwise, invalid otp data **************************************************************************************************/ BYTE get_lsc_flag() { BYTE flag = 0; if(!start_read_otp(0x0B)) { LOG_INF("Start read Page 0x0B Fail!\n"); return 0; } flag = read_cmos_sensor(0x3B43); flag = flag & 0xc0; LOG_INF("OTP Flag:0x%02x",flag ); return flag; }
/************************************************************************************************* * Function : get_otp_flag * Description : get otp WRITTEN_FLAG * Parameters : [BYTE] zone : OTP PAGE index , 0x00~0x0f * Return : [BYTE], if 0x40 , this type has valid otp data, otherwise, invalid otp data **************************************************************************************************/ BYTE get_otp_flag(BYTE zone) { BYTE flag = 0; if(!start_read_otp(zone)) { LOG_INF("Start read Page %d Fail!\n", zone); return 0; } flag = read_cmos_sensor(0x3B04); flag = flag & 0xc0; LOG_INF("OTP Flag:0x%02x\n",flag ); return flag; }
/************************************************************************************************* * Function : start_read_otp * Description : before read otp , set the reading block setting * Parameters : [BYTE] zone : OTP PAGE index , 0x00~0x0f * Return : 0, reading block setting err 1, reading block setting ok **************************************************************************************************/ bool start_read_otp(BYTE zone) { BYTE val = 0; int i; write_cmos_sensor_8(0x0104, 0x01); write_cmos_sensor(0x3B02, zone); //PAGE write_cmos_sensor(0x3B00, 0x01); write_cmos_sensor_8(0x0104, 0x00); Sleep(5); for(i=0; i<100; i++) { val = read_cmos_sensor(0x3B01); if((val & 0x01) == 0x01) break; Sleep(2); } if(i == 100) { CAM_CALERR("Read Page %d Err!\n", zone); // print log return 0; } return 1; }
static kal_uint32 return_sensor_id() { return ((read_cmos_sensor(0x300A) << 8) | read_cmos_sensor(0x300B)); }
/************************************************************************************************* * Function : get_otp_wb * Description : Get WB data * Parameters : [BYTE] zone : OTP PAGE index , 0x00~0x0f **************************************************************************************************/ bool get_otp_wb(BYTE zone) { BYTE temph = 0; BYTE templ = 0; golden_r = 0, golden_gr = 0, golden_gb = 0, golden_b = 0; current_r = 0, current_gr = 0, current_gb = 0, current_b = 0; if(!start_read_otp(zone)) { LOG_INF("Start read Page %d Fail!\n", zone); return 0; } temph = read_cmos_sensor(0x3B18); templ = read_cmos_sensor(0x3B19); golden_r = (USHORT)templ + (((USHORT)temph & 0x03) << 8); temph = read_cmos_sensor(0x3B1A); templ = read_cmos_sensor(0x3B1B); golden_gr = (USHORT)templ + (((USHORT)temph & 0x03) << 8); temph = read_cmos_sensor(0x3B1C); templ = read_cmos_sensor(0x3B1D); golden_gb = (USHORT)templ + (((USHORT)temph & 0x03) << 8); temph = read_cmos_sensor(0x3B1E); templ = read_cmos_sensor(0x3B1F); golden_b = (USHORT)templ + (((USHORT)temph & 0x03) << 8); temph = read_cmos_sensor(0x3B10); templ = read_cmos_sensor(0x3B11); current_r = (USHORT)templ + (((USHORT)temph & 0x03) << 8); temph = read_cmos_sensor(0x3B12); templ = read_cmos_sensor(0x3B13); current_gr = (USHORT)templ + (((USHORT)temph & 0x03) << 8); temph = read_cmos_sensor(0x3B14); templ = read_cmos_sensor(0x3B15); current_gb = (USHORT)templ + (((USHORT)temph & 0x03) << 8); temph = read_cmos_sensor(0x3B16); templ = read_cmos_sensor(0x3B17); current_b = (USHORT)templ + (((USHORT)temph & 0x03) << 8); return 1; }