/****************************************************************************** Function : ov5648_sunny_p5v18g_otp_read_module_info Description: read module info OTP. ******************************************************************************/ static int ov5648_sunny_p5v18g_otp_read_module_info(struct msm_sensor_ctrl_t *s_ctrl, struct ov5648_sunny_p5v18g_otp_struct * otp_ptr) { //module info from group2,bank1 first if (-1 == ov5648_sunny_p5v18g_select_bank(s_ctrl, OV5648_SUNNY_P5V18G_OTP_BANK1)) { return -1; } //Module info: Bank 1:0x3d02~0x3d06 ov5648_sunny_p5v18g_cci_i2c_read(s_ctrl, 0x3d02, &(otp_ptr->product_year)); ov5648_sunny_p5v18g_cci_i2c_read(s_ctrl, 0x3d03, &(otp_ptr->product_month)); ov5648_sunny_p5v18g_cci_i2c_read(s_ctrl, 0x3d04, &(otp_ptr->product_date)); ov5648_sunny_p5v18g_cci_i2c_read(s_ctrl, 0x3d05, &(otp_ptr->camera_id)); ov5648_sunny_p5v18g_cci_i2c_read(s_ctrl, 0x3d06, &(otp_ptr->supplier_version_id)); CMR_LOGD("%s,group 2 otp_ptr.product_year:%d\n",__func__,otp_ptr->product_year); CMR_LOGD("%s,group 2 otp_ptr.product_month:%d\n",__func__,otp_ptr->product_month); CMR_LOGD("%s,group 2 otp_ptr.product_date:%d\n",__func__,otp_ptr->product_date); CMR_LOGD("%s,group 2 otp_ptr.camera_id:%d\n",__func__,otp_ptr->camera_id); CMR_LOGD("%s,group 2 otp_ptr.supplier_version_id:%d\n",__func__,otp_ptr->supplier_version_id); ov5648_sunny_p5v18g_otp_clear(s_ctrl); if (0 != otp_ptr->product_year)// year is not zero, we assume module info is correct { CMR_LOGW("%s, Module info lays in group 2\n",__func__); return 0; } //group2 fail, check group1, bank0 if (-1 == ov5648_sunny_p5v18g_select_bank(s_ctrl, OV5648_SUNNY_P5V18G_OTP_BANK0)) { return -1; } //Module info: Bank 0:0x3d05~0x3d09 ov5648_sunny_p5v18g_cci_i2c_read(s_ctrl, 0x3d05, &(otp_ptr->product_year)); ov5648_sunny_p5v18g_cci_i2c_read(s_ctrl, 0x3d06, &(otp_ptr->product_month)); ov5648_sunny_p5v18g_cci_i2c_read(s_ctrl, 0x3d07, &(otp_ptr->product_date)); ov5648_sunny_p5v18g_cci_i2c_read(s_ctrl, 0x3d08, &(otp_ptr->camera_id)); ov5648_sunny_p5v18g_cci_i2c_read(s_ctrl, 0x3d09, &(otp_ptr->supplier_version_id)); CMR_LOGD("%s,group 2 otp_ptr.product_year:%d\n",__func__,otp_ptr->product_year); CMR_LOGD("%s,group 2 otp_ptr.product_month:%d\n",__func__,otp_ptr->product_month); CMR_LOGD("%s,group 2 otp_ptr.product_date:%d\n",__func__,otp_ptr->product_date); CMR_LOGD("%s,group 2 otp_ptr.camera_id:%d\n",__func__,otp_ptr->camera_id); CMR_LOGD("%s,group 2 otp_ptr.supplier_version_id:%d\n",__func__,otp_ptr->supplier_version_id); ov5648_sunny_p5v18g_otp_clear(s_ctrl); if (0 != otp_ptr->product_year) // year is not zero, we assume module info is correct { CMR_LOGW("%s, Module info lays in group 1\n",__func__); return 0;//otp read sucess } else { CMR_LOGE("%s, Error !No Module inf found in OTP\n",__func__); return -1;//otp read fail } return 0; }
int camera_save_sensormark(void) { FILE *fp; uint32_t i = 0; uint8_t is_saving= 0; uint8_t sensor_param[SENSOR_PARAM_NUM]; int ret = CAMERA_SUCCESS; memset(&sensor_param[0], 0, SENSOR_PARAM_NUM); Sensor_GetMark(sensor_param, &is_saving); if (is_saving) { fp = fopen(SENSOR_PARA,"wb+"); if (NULL != fp) { fwrite(sensor_param, 1, SENSOR_PARAM_NUM, fp); CMR_LOGI("sensor param: %d, %d, %d, %d, %d, %d, %d, %d", sensor_param[0], sensor_param[1], sensor_param[2], sensor_param[3], sensor_param[4], sensor_param[5], sensor_param[6], sensor_param[7]); fclose(fp); } else { CMR_LOGW("can not create SENSOR_PARA"); } } return ret; }
static cmr_int cmr_sns_kill_fmove_thread(struct cmr_sensor_handle *sensor_handle) { cmr_int ret = CMR_CAMERA_SUCCESS; void *dummy; CHECK_HANDLE_VALID(sensor_handle); CMR_LOGI("E is_inited %p", (void *)sensor_handle->fmove_thread_cxt.thread_handle); if (sensor_handle->fmove_thread_cxt.thread_handle) { sensor_handle->fmove_thread_cxt.is_exit = 1; while (1 == sensor_handle->fmove_thread_cxt.is_exit) { CMR_LOGW("Wait 10 ms"); usleep(10000); } ret = pthread_join(sensor_handle->fmove_thread_cxt.thread_handle, &dummy); sensor_handle->fmove_thread_cxt.thread_handle = 0; } CMR_LOGI("X kill sensor monitor thread done!"); return ret; }
/****************************************************************************** Function : ov5648_sunny_p5v18g_otp_read_awb Description: read awb info OTP. ******************************************************************************/ static int ov5648_sunny_p5v18g_otp_read_awb(struct msm_sensor_ctrl_t *s_ctrl, struct ov5648_sunny_p5v18g_otp_struct * otp_ptr) { uint32_t rg = 0; uint32_t bg = 0; //AWB info from group2,bank1 first if (-1 == ov5648_sunny_p5v18g_select_bank(s_ctrl, OV5648_SUNNY_P5V18G_OTP_BANK1)) return -1; //AWB:Bank 1:0x3d07~0x3d0c ov5648_sunny_p5v18g_cci_i2c_read(s_ctrl, 0x3d07, &(otp_ptr->wb_rg_h)); ov5648_sunny_p5v18g_cci_i2c_read(s_ctrl, 0x3d08, &(otp_ptr->wb_rg_l)); ov5648_sunny_p5v18g_cci_i2c_read(s_ctrl, 0x3d09, &(otp_ptr->wb_bg_h)); ov5648_sunny_p5v18g_cci_i2c_read(s_ctrl, 0x3d0a, &(otp_ptr->wb_bg_l)); ov5648_sunny_p5v18g_cci_i2c_read(s_ctrl, 0x3d0b, &(otp_ptr->wb_gbgr_h)); ov5648_sunny_p5v18g_cci_i2c_read(s_ctrl, 0x3d0c, &(otp_ptr->wb_gbgr_l)); rg = (otp_ptr->wb_rg_h << 8) + otp_ptr->wb_rg_l; bg = (otp_ptr->wb_bg_h << 8) + otp_ptr->wb_bg_l; ov5648_sunny_p5v18g_otp_clear(s_ctrl); //rG and bG all not zero, so awb info is correct if ((0 != rg) && (0 != bg)) { CMR_LOGW("%s, AWB info lays in group 2\n",__func__); return 0;//otp read sucess } //one of rG and bG is not zero, so group 2 in not correct else if (((0 == rg) && ( 0 != bg )) || ((0 != rg) && ( 0 == bg ))) { CMR_LOGE("%s, Error !Group 2 AWB info not correct\n",__func__); return -1;//otp read fail } //group2 fail, check group1, bank0 if (-1 == ov5648_sunny_p5v18g_select_bank(s_ctrl, OV5648_SUNNY_P5V18G_OTP_BANK0)) return -1; //AWB : Bank 0:0x3d0a~0x3d0f ov5648_sunny_p5v18g_cci_i2c_read(s_ctrl, 0x3d0a, &(otp_ptr->wb_rg_h)); ov5648_sunny_p5v18g_cci_i2c_read(s_ctrl, 0x3d0b, &(otp_ptr->wb_rg_l)); ov5648_sunny_p5v18g_cci_i2c_read(s_ctrl, 0x3d0c, &(otp_ptr->wb_bg_h)); ov5648_sunny_p5v18g_cci_i2c_read(s_ctrl, 0x3d0d, &(otp_ptr->wb_bg_l)); ov5648_sunny_p5v18g_cci_i2c_read(s_ctrl, 0x3d0e, &(otp_ptr->wb_gbgr_h)); ov5648_sunny_p5v18g_cci_i2c_read(s_ctrl, 0x3d0f, &(otp_ptr->wb_gbgr_l)); rg = (otp_ptr->wb_rg_h << 8) + otp_ptr->wb_rg_l; bg = (otp_ptr->wb_bg_h<< 8) + otp_ptr->wb_bg_l; ov5648_sunny_p5v18g_otp_clear(s_ctrl); if ((0 != rg) && (0 != bg))//rG and bG all not zero, so awb info is correct { CMR_LOGW("%s, AWB info lays in group 1\n",__func__); return 0;//otp read sucess } else { CMR_LOGE("%s, Error! No AWB info found in OTP\n",__func__); return -1;//otp read fail } return 0; }
cmr_int cmr_sns_ioctl(struct sensor_drv_context *sensor_cxt, cmr_uint cmd, cmr_uint arg) { SENSOR_IOCTL_FUNC_PTR func_ptr; SENSOR_IOCTL_FUNC_TAB_T *func_tab_ptr; cmr_uint temp; cmr_u32 ret = CMR_CAMERA_SUCCESS; cmr_u32 sns_cmd = SENSOR_IOCTL_GET_STATUS; ret = cmr_sns_get_ioctl_cmd(&sns_cmd, cmd); if (ret) { CMR_LOGE("can't get correct command !\n"); return CMR_CAMERA_INVALID_PARAM; } if (SENSOR_IOCTL_GET_STATUS != sns_cmd) { CMR_LOGI("cmd = %d, arg = 0x%lx.\n", sns_cmd, arg); } SENSOR_DRV_CHECK_ZERO(sensor_cxt); if (!sensor_is_init_common(sensor_cxt)) { CMR_LOGE("sensor has not init.\n"); return SENSOR_OP_STATUS_ERR; } if (SENSOR_IOCTL_CUS_FUNC_1 > sns_cmd) { CMR_LOGW("can't access internal command !\n"); return SENSOR_SUCCESS; } if (PNULL == sensor_cxt->sensor_info_ptr) { CMR_LOGE("No sensor info!"); return -1; } func_tab_ptr = sensor_cxt->sensor_info_ptr->ioctl_func_tab_ptr; #ifdef __LP64__ temp = *(cmr_uint *) ((cmr_uint) func_tab_ptr + sns_cmd * S_BIT_3); #else temp = *(cmr_uint *) ((cmr_uint) func_tab_ptr + sns_cmd * S_BIT_2); #endif func_ptr = (SENSOR_IOCTL_FUNC_PTR) temp; #if (CONFIG_READOTP_METHOD != 0) if( SENSOR_ACCESS_VAL == cmd) { SENSOR_VAL_T *val = (SENSOR_VAL_T *)arg; if(val->type == SENSOR_VAL_TYPE_READ_OTP) { SENSOR_OTP_PARAM_T *param_ptr = (SENSOR_OTP_PARAM_T *)val->pval; CMR_LOGD("SENSOR_IO_READ_OTPDATA %p, %d", param_ptr, param_ptr->type); ret = ioctl(sensor_cxt->fd_sensor, SENSOR_IO_READ_OTPDATA, param_ptr); if(!ret && param_ptr->type == SENSOR_OTP_PARAM_NORMAL) { val->type = SENSOR_VAL_TYPE_PARSE_OTP; ret = func_ptr(arg); } return ret; } } #endif if (PNULL != func_ptr) { ret = func_ptr(arg); } return ret; }