请选择 进入手机版 | 继续访问电脑版

展锐平台camera平台端,sesor端otp

[复制链接]
唐少琼 发表于 2021-1-1 10:30:51 | 显示全部楼层 |阅读模式 打印 上一主题 下一主题
文章目次



平台端otp

焦点函数:
  1. static cmr_intsensor_drv_get_module_otp_data(struct sensor_drv_context *sensor_cxt) {    cmr_int ret = SENSOR_SUCCESS;    SENSOR_MATCH_T *sns_module = NULL;    struct xml_camera_cfg_info *camera_cfg;    struct otp_drv_lib *libOtpPtr = &otp_lib_mngr[sensor_cxt->slot_id];    struct vcm_drv_lib *libVcmPtr = &vcm_lib_mngr[sensor_cxt->slot_id];    SENSOR_DRV_CHECK_ZERO(sensor_cxt);    sns_module = (SENSOR_MATCH_T *)sensor_cxt->current_module;    SENSOR_DRV_CHECK_ZERO(sns_module);    camera_cfg = sensor_cxt->xml_info;    sensor_drv_xml_parse_vcm_info(camera_cfg);    ret = sensor_drv_vcm_load_library(camera_cfg->cfgPtr->vcm_info.af_name,                                      libVcmPtr);    if (!ret) {        sns_module->af_dev_info.af_drv_entry = libVcmPtr->vcm_info_ptr;        sns_module->af_dev_info.af_work_mode =            camera_cfg->cfgPtr->vcm_info.work_mode;    }    sensor_drv_xml_parse_otp_info(camera_cfg);    ret = sensor_drv_otp_load_library(        camera_cfg->cfgPtr->otp_info.e2p_otp.otp_name, libOtpPtr);    if (!ret) {        sns_module->otp_drv_info.otp_drv_entry = libOtpPtr->otp_info_ptr;        sns_module->otp_drv_info.eeprom_i2c_addr =            camera_cfg->cfgPtr->otp_info.e2p_otp.eeprom_i2c_addr;        sns_module->otp_drv_info.eeprom_num =            camera_cfg->cfgPtr->otp_info.e2p_otp.eeprom_num;        sns_module->otp_drv_info.eeprom_size =            camera_cfg->cfgPtr->otp_info.e2p_otp.eeprom_size;    }#if defined(CONFIG_CAMERA_SENSOR_OTP)    SENSOR_REG_TAB_INFO_T *res_info_ptr = PNULL;    res_info_ptr = sensor_ic_get_data(sensor_cxt, SENSOR_CMD_GET_RESOLUTION);    hw_Sensor_SendRegTabToSensor(sensor_cxt->hw_drv_handle, &res_info_ptr[0]);    SENSOR_LOGD("CONFIG_CAMERA_SENSOR_OTP set mode SENSOR_MODE_COMMON_INIT");#endif    sensor_af_init(sensor_cxt);    sensor_otp_module_init(sensor_cxt);    if (SENSOR_IMAGE_FORMAT_RAW == sensor_cxt->sensor_info_ptr->image_format) {        if (sns_module->otp_drv_info.otp_drv_entry) {            sensor_otp_process(sensor_cxt, OTP_READ_PARSE_DATA, 0, NULL);            sensor_otp_process(sensor_cxt, OTP_READ_SERIAL_NUM, 0, NULL);//xiongdajun add serial_num for moto camera        } else {            SENSOR_LOGI(                "otp_drv_entry not configured:mod:%p,otp_drv:%p", sns_module,                sns_module ? sns_module->otp_drv_info.otp_drv_entry : NULL);        }    }    sensor_otp_module_deinit(sensor_cxt);    sensor_af_deinit(sensor_cxt);    return 0;}
复制代码
从sensor_otp_module_init开始
1.sensor_otp_module_init

先看一下general_otp_drv.h,提供接口
  1. otp_drv_entry_t general_otp_entry = {    .otp_ops =        {            .sensor_otp_create = general_otp_drv_create,            .sensor_otp_delete = general_otp_drv_delete,            .sensor_otp_read = general_otp_drv_read,            .sensor_otp_write = general_otp_drv_write,            .sensor_otp_parse = general_otp_drv_parse,            .sensor_otp_calibration = general_otp_drv_calibration,            .sensor_otp_ioctl = general_otp_drv_ioctl, /*expand*/            .sensor_otp_read_serial_num = general_otp_read_serial_num,  //xiongdajun add serial_num for moto camera        },};
复制代码
开机时,xml中有设置otp时:先创建handle
在sns_drv_u.c中先调用:
  1. /*--------------------------OTP INTERFACE-----------------------------*/static cmr_int sensor_otp_module_init(struct sensor_drv_context *sensor_cxt) {    ATRACE_BEGIN(__FUNCTION__);    cmr_int ret = SENSOR_SUCCESS;    SENSOR_DRV_CHECK_ZERO(sensor_cxt);    SENSOR_LOGD("E");    SENSOR_MATCH_T *module = sensor_cxt->current_module;    otp_drv_init_para_t input_para = {0, NULL, 0, 0, 0, 0, 0, 0, 0};    if (module && (module->otp_drv_info.otp_drv_entry) &&        (!sensor_cxt->otp_drv_handle)) {        input_para.hw_handle = sensor_cxt->hw_drv_handle;        input_para.sensor_name = (char *)sensor_cxt->sensor_info_ptr->name;        input_para.sensor_id = sensor_cxt->slot_id;        input_para.sensor_ic_addr = sensor_cxt->i2c_addr;        input_para.eeprom_i2c_addr = module->otp_drv_info.eeprom_i2c_addr;        input_para.eeprom_num = module->otp_drv_info.eeprom_num;        input_para.eeprom_size = module->otp_drv_info.eeprom_size;        input_para.sensor_max_width =            sensor_cxt->sensor_info_ptr->source_width_max;        input_para.sensor_max_height =            sensor_cxt->sensor_info_ptr->source_height_max;        ret = module->otp_drv_info.otp_drv_entry->otp_ops.sensor_otp_create(            &input_para, &sensor_cxt->otp_drv_handle);    } else {        SENSOR_LOGI("otp driver is not configured");    }    SENSOR_LOGV("X");    ATRACE_END();    return ret;}
复制代码
接着在general_otp_drv.c中
  1. static cmr_int general_otp_drv_create(otp_drv_init_para_t *input_para,                                      cmr_handle *otp_drv_handle) {    return sensor_otp_drv_create(input_para, otp_drv_handle);}
复制代码
接着调用到otp_common.c中的
  1. cmr_int sensor_otp_drv_create(otp_drv_init_para_t *input_para,                              cmr_handle *sns_otp_drv_handle) {    cmr_int ret = OTP_CAMERA_SUCCESS;    CHECK_PTR(input_para);    CHECK_PTR((void *)sns_otp_drv_handle);    OTP_LOGV("In");    otp_drv_cxt_t *otp_cxt = malloc(sizeof(otp_drv_cxt_t));    if (!otp_cxt) {        OTP_LOGE("otp handle create failed!");        return OTP_CAMERA_FAIL;    }    memset(otp_cxt, 0, sizeof(otp_drv_cxt_t));    if (input_para->sensor_name)        memcpy(otp_cxt->dev_name, input_para->sensor_name, SENSOR_NAME_LEN);    otp_cxt->compat_convert_data = malloc(sizeof(struct sensor_otp_cust_info));    if (NULL == otp_cxt->compat_convert_data) {        OTP_LOGE("malloc otp_cxt->compat_convert_data failed");        free(otp_cxt);        return OTP_CAMERA_FAIL;    }    cmr_bzero(otp_cxt->compat_convert_data,              sizeof(struct sensor_otp_cust_info));    otp_cxt->otp_raw_data.buffer = NULL;    otp_cxt->otp_data = NULL;    otp_cxt->hw_handle = input_para->hw_handle;    otp_cxt->sensor_id = input_para->sensor_id;    otp_cxt->sensor_ic_addr = input_para->sensor_ic_addr;    otp_cxt->eeprom_i2c_addr = input_para->eeprom_i2c_addr;    otp_cxt->eeprom_num = input_para->eeprom_num;    otp_cxt->eeprom_size = input_para->eeprom_size;    otp_cxt->otp_module_info.sensor_max_width = input_para->sensor_max_width;    otp_cxt->otp_module_info.sensor_max_height = input_para->sensor_max_height;    OTP_LOGI("X:sensor_id:%d, sensor_name:%s, eeprom_i2c_address:0x%x, "             "eeprom_size:%d bytes, eeprom_num:%d",             otp_cxt->sensor_id, otp_cxt->dev_name, otp_cxt->eeprom_i2c_addr,             otp_cxt->eeprom_size, otp_cxt->eeprom_num);    *sns_otp_drv_handle = otp_cxt;    return ret;}
复制代码
信息从xml中解析拿到
日志输出:
  1. sensor_otp_drv_create: X:sensor_id:0, sensor_name:s5kgm1st, eeprom_i2c_address:0xb1, eeprom_size:8192 bytes, eeprom_num:3
复制代码
2.sensor_otp_process

接着开始读数据:
sensor_otp_process(sensor_cxt, OTP_READ_PARSE_DATA, 0, NULL);
sns_drv_u.c中:
  1.         case OTP_READ_PARSE_DATA:            module->otp_drv_info.otp_drv_entry->otp_ops.sensor_otp_read(                sensor_cxt->otp_drv_handle, NULL);            ret = module->otp_drv_info.otp_drv_entry->otp_ops.sensor_otp_parse(                sensor_cxt->otp_drv_handle, data);            if (ret == SENSOR_SUCCESS) {                ret = module->otp_drv_info.otp_drv_entry->otp_ops                          .sensor_otp_calibration(sensor_cxt->otp_drv_handle);            } else {                SENSOR_LOGE("otp prase failed");                return ret;            }            break;
复制代码
可以看出,先读,然后解析,乐成之后calibration校准,对应调用general中的
2.1general_otp_drv_read(cmr_handle otp_drv_handle, void *param)

  1. /*malloc buffer and read otp raw data from eeprom or bin file*/static cmr_int general_otp_drv_read(cmr_handle otp_drv_handle, void *param) {    cmr_int ret = OTP_CAMERA_SUCCESS;    CHECK_PTR(otp_drv_handle);    OTP_LOGV("E");    otp_drv_cxt_t *otp_cxt = (otp_drv_cxt_t *)otp_drv_handle;    char otp_read_bin_path[255] = "otp_read_bin_path";    char otp_dump_name[255] = "otp_dump_name";    char value1[255];    char value2[255];    char value3[255];    FILE *fp = NULL;    cmr_u32 read_size = 0;    cmr_u16 calib_version = 0;    if (!otp_cxt->otp_raw_data.buffer) {        otp_cxt->otp_raw_data.buffer =            sensor_otp_get_raw_buffer(otp_cxt->eeprom_size, otp_cxt->sensor_id);        if (!otp_cxt->otp_raw_data.buffer) {            OTP_LOGE("malloc otp raw buffer failed");            ret = OTP_CAMERA_FAIL;            goto exit;        }        otp_cxt->otp_raw_data.num_bytes = otp_cxt->eeprom_size;        if (!otp_cxt->otp_data) {            otp_cxt->otp_data =                (otp_format_data_t *)sensor_otp_get_formatted_buffer(                    sizeof(otp_format_data_t), otp_cxt->sensor_id);            if (!otp_cxt->otp_data) {                OTP_LOGE("malloc otp section info buffer failed");                ret = OTP_CAMERA_FAIL;                goto exit;            }        }    }    property_get("debug.read.otp.open.camera", value1, "0");    if (atoi(value1) == 0) {        if (sensor_otp_get_buffer_state(otp_cxt->sensor_id)) {            OTP_LOGD("otp raw data has been read before, is still in memory, "                     "will not be read again");            goto exit;        }    }    property_get("persist.vendor.read.otp.from.bin", value2, "0");    if (atoi(value2) == 1) {        /* read otp from bin file */        snprintf(otp_read_bin_path, sizeof(otp_read_bin_path), "%s%s%d_otp.bin",                 "/data/vendor/cameraserver/", "id", otp_cxt->sensor_id);        OTP_LOGD("otp_data_read_path:%s", otp_read_bin_path);        if (-1 == access(otp_read_bin_path, 0)) {            OTP_LOGE("otp bin file don't exist");            ret = OTP_CAMERA_FAIL;            goto exit;        }        fp = fopen(otp_read_bin_path, "rb");        if (!fp) {            OTP_LOGE("fp is null, open otp bin failed");            ret = OTP_CAMERA_FAIL;            goto exit;        }        read_size =            fread(otp_cxt->otp_raw_data.buffer, 1, otp_cxt->eeprom_size, fp);        if (read_size != otp_cxt->eeprom_size) {            OTP_LOGE("read otp bin error, read_size is %d, otp size is %d",                     read_size, otp_cxt->eeprom_size);            ret = OTP_CAMERA_FAIL;        } else {            OTP_LOGD("read otp raw data from bin file successfully, size %d",                     otp_cxt->eeprom_size);        }        fclose(fp);        fp = NULL;    } else {        if ((otp_cxt->eeprom_num == DUAL_CAM_ONE_EEPROM) &&            (otp_cxt->sensor_id == 2 || otp_cxt->sensor_id == 3)) {//双摄            /* slave copy otp raw data from master */            otp_cxt->otp_raw_data.buffer = sensor_otp_copy_raw_buffer(                otp_cxt->eeprom_size, otp_cxt->sensor_id - 2,                otp_cxt->sensor_id);            OTP_LOGD("copy otp raw data from master");            sensor_otp_set_buffer_state(otp_cxt->sensor_id, 0);        } else {            /* read otp from eeprom */            otp_cxt->otp_raw_data.buffer[0] = 0;            otp_cxt->otp_raw_data.buffer[1] = 0;            OTP_LOGD("i2c addr:0x%x", otp_cxt->eeprom_i2c_addr);#ifdef CONFIG_CAMERA_SENSOR_OTP            /* read otp from sensor */            if (!strcmp(otp_cxt->dev_name, "hi846_gj_1_2lane")) {                hi846_sensor_otp_read(otp_drv_handle);                OTP_LOGD(                    "read otp raw data from sensor %s successfully, size %d",                    otp_cxt->dev_name, otp_cxt->eeprom_size);            } else#endif            {                ret = hw_sensor_read_i2c(                    otp_cxt->hw_handle, otp_cxt->eeprom_i2c_addr >> 1,                    otp_cxt->otp_raw_data.buffer,                    otp_cxt->eeprom_size eeprom_size);                }            }            if (!strcmp(otp_cxt->dev_name, "ov8856_shine") &&                otp_cxt->sensor_id == 2) {                /* sharkl3 Android 10.0 new ov8856 module, DUAL_CAM_ONE_EEPROM,                 * slave copy raw data from master */                calib_version = (otp_cxt->otp_raw_data.buffer[4] otp_raw_data.buffer[5];                if (calib_version == 0xffff || calib_version == 0x0000) {                    otp_cxt->otp_raw_data.buffer =                        sensor_otp_copy_raw_buffer(otp_cxt->eeprom_size, 0, 2);                    OTP_LOGD("ov8856_shine copy otp raw data from master");                    sensor_otp_set_buffer_state(otp_cxt->sensor_id, 0);                }            }        }    }exit:    if (OTP_CAMERA_SUCCESS == ret) {        property_get("debug.camera.save.otp.raw.data", value3, "0");        if (atoi(value3) == 1) {            /* dump otp to bin file */            snprintf(otp_dump_name, sizeof(otp_dump_name), "%s_%s%d",                     otp_cxt->dev_name, "id", otp_cxt->sensor_id);            if (sensor_otp_dump_raw_data(otp_cxt->otp_raw_data.buffer,                                         otp_cxt->eeprom_size, otp_dump_name))                OTP_LOGE("dump otp bin file failed");        }    }    OTP_LOGV("X");    return ret;}
复制代码
大抵为:先判断是否已经读过了,如果已经读过,从buff中获取:
  1. /*get buffer state*/cmr_u32 sensor_otp_get_buffer_state(cmr_u32 sensor_id) {    cmr_u32 in_memory = 0;    if (otp_raw_buffer[sensor_id] != NULL) {        in_memory = *((cmr_u32 *)otp_raw_buffer[sensor_id]);    }    OTP_LOGI("get buffer flag(0:not in memory,1:in memory):%d", in_memory);    return in_memory;}
复制代码
读取时:
  1. ret = hw_sensor_read_i2c(                    otp_cxt->hw_handle, otp_cxt->eeprom_i2c_addr >> 1,                    otp_cxt->otp_raw_data.buffer,                    otp_cxt->eeprom_size otp_module_info);    char value[255] = {0};    _general_otp_parse_map_version(otp_drv_handle);//    if (module_info->otp_version == VER_ERROR) {        OTP_LOGI("otp version error! will not start parse!");        ret = OTP_CAMERA_FAIL;        return ret;    }    property_get("debug.parse.otp.open.camera", value, "0");    if (atoi(value) == 0) {        if (sensor_otp_get_buffer_state(otp_cxt->sensor_id)) {            OTP_LOGD("otp data has been parsed before, is still in memory, "                     "will not be parsed again");            return ret;        }    }    if (module_info->otp_version == OTP_1_1) {        _general_otp_parse_module_data_1v1(otp_drv_handle);        if (otp_cxt->sensor_id < 6) {            _general_otp_parse_af_1v1(otp_drv_handle);            _general_otp_parse_awb_1v1(otp_drv_handle);            _general_otp_parse_lsc_1v1(otp_drv_handle);            _general_otp_parse_pdaf_1v1(otp_drv_handle);            _general_otp_parse_xtalk_4in1_1v1(otp_drv_handle);            _general_otp_parse_dpc_4in1_1v1(otp_drv_handle);            _general_otp_parse_spw_1v1(otp_drv_handle);            _general_otp_parse_bokeh_1v1(otp_drv_handle);            _general_otp_parse_wt_1v1(otp_drv_handle);            _general_otp_parse_motoinfo_1v1(otp_drv_handle);//xiongdajun add serial_num for moto camera        } else {            OTP_LOGE("illegal sensor id");            goto exit;        }    } else if (module_info->otp_version == OTP_1_0) {        _general_otp_parse_module_data_1v0(otp_drv_handle);        if (otp_cxt->sensor_id == 0 || otp_cxt->sensor_id == 1) {            _general_otp_parse_master_af_1v0(otp_drv_handle);            _general_otp_parse_master_awb_1v0(otp_drv_handle);            _general_otp_parse_master_lsc_1v0(otp_drv_handle);            _general_otp_parse_master_pdaf(otp_drv_handle);            _general_otp_parse_master_ae_1v0(otp_drv_handle);            _general_otp_parse_master_dualcam_1v0(otp_drv_handle);        } else if (otp_cxt->sensor_id == 2 || otp_cxt->sensor_id == 3 ||                   otp_cxt->sensor_id == 4 || otp_cxt->sensor_id == 5) {            _general_otp_parse_slave_af_1v0(otp_drv_handle);            _general_otp_parse_slave_awb_1v0(otp_drv_handle);            _general_otp_parse_slave_lsc_1v0(otp_drv_handle);            _general_otp_parse_slave_ae_1v0(otp_drv_handle);        } else {            OTP_LOGE("illegal sensor id");            goto exit;        }    } else {        if (otp_cxt->sensor_id == 0 || otp_cxt->sensor_id == 1) {            _general_otp_parse_module_data_0v4(otp_drv_handle, 0x0000);            if (otp_cxt->eeprom_num == DUAL_CAM_ONE_EEPROM ||                otp_cxt->eeprom_num == DUAL_CAM_TWO_EEPROM) {                _general_otp_get_master_addr_0v4(otp_drv_handle);                _general_otp_parse_master_af_0v4(otp_drv_handle);                _general_otp_parse_master_awb_0v4(otp_drv_handle);                _general_otp_parse_master_lsc_0v4(otp_drv_handle);                _general_otp_parse_master_pdaf(otp_drv_handle);                _general_otp_parse_master_ae_0v4(otp_drv_handle);                _general_otp_parse_master_dualcam_0v4(otp_drv_handle);            } else { // eeprom_num == SINGLE_CAM_ONE_EEPROM                _general_otp_get_single_addr_0v4(otp_drv_handle);                _general_otp_parse_master_af_0v4(otp_drv_handle);                _general_otp_parse_master_awb_0v4(otp_drv_handle);                _general_otp_parse_master_lsc_0v4(otp_drv_handle);                _general_otp_parse_master_pdaf(otp_drv_handle);            }        } else if (otp_cxt->sensor_id == 2 || otp_cxt->sensor_id == 3) {            if (otp_cxt->eeprom_num == DUAL_CAM_TWO_EEPROM) {                _general_otp_parse_module_data_0v4(otp_drv_handle, 0x0000);            } else if (otp_cxt->eeprom_num == DUAL_CAM_ONE_EEPROM) {                /* 0x1a00: dual_slave otp start address, mostly for                 * ov8858+ov2680 sbs module */                _general_otp_parse_module_data_0v4(otp_drv_handle, 0x1a00);            } else {                OTP_LOGE("slave sensor_id must be dualcam!");            }            _general_otp_get_slave_addr_0v4(otp_drv_handle);            _general_otp_parse_slave_af_0v4(otp_drv_handle);            _general_otp_parse_slave_awb_0v4(otp_drv_handle);            _general_otp_parse_slave_lsc_0v4(otp_drv_handle);            _general_otp_parse_slave_ae_0v4(otp_drv_handle);        } else {            OTP_LOGE("illegal sensor id");            goto exit;        }    }    /*set buffer_state to 1, means otp data saved in memory*/    sensor_otp_set_buffer_state(otp_cxt->sensor_id, 1);exit:    OTP_LOGV("X");    return ret;}
复制代码
先是根据 _general_otp_parse_map_version(otp_drv_handle);
判断平台端otp的版本,来选择相应的数据解析流程
重点看这就够了,设置状态,下次就不消重新读取了。
  1.     /*set buffer_state to 1, means otp data saved in memory*/    sensor_otp_set_buffer_state(otp_cxt->sensor_id, 1);
复制代码
2.3 general_otp_drv_calibration(cmr_handle otp_drv_handle)

  1. static cmr_int general_otp_drv_calibration(cmr_handle otp_drv_handle) {    cmr_int ret = OTP_CAMERA_SUCCESS;    CHECK_PTR(otp_drv_handle);    OTP_LOGV("E");    otp_drv_cxt_t *otp_cxt = (otp_drv_cxt_t *)otp_drv_handle;    OTP_LOGV("X");    return ret;}
复制代码
sensor端

平台端这里没有实现,但sensor端,自己实现,这里随便找一个为例:
在.h文件中,sensor端多了如下:
  1. otp_drv_entry_t gc5035_common_drv_entry = {        .otp_cfg =                {                        .cali_items =                                {                                        .is_self_cal = TRUE, /*TRUE: OC calibration on,FALSE: OC calibration off*/                                        .is_awbc = TRUE,  /* TRUE: support awb calibration, FALSE: Not support awb calibration */                                        .is_awbc_self_cal= TRUE,/*TRUE: Sensor side calibration, FALSE: ISP Side calibration*/                                        .is_lsc = FALSE,   /* TRUE: support lsc calibration, FALSE: Not support lsc calibration */                                        .is_lsc_self_cal= FALSE, /*TRUE: Sensor side calibration, FALSE: ISP Side calibration*/                                        .is_pdafc = FALSE, /* TRUE: support pdaf calibration, FALSE: Not support pdaf calibration */                                        .is_pdaf_self_cal= FALSE, /*TRUE: Sensor side calibration, FALSE: ISP Side calibration*/                                        .is_afc = FALSE,                                        .is_af_self_cal = FALSE,                                        .is_dul_camc = FALSE, /* TRUE: support dual camera  calibration, FALSE: Not support dual camera  calibration */                                },                        .base_info_cfg =                                {                                        /*decompression on otp driver or isp*/                                        .is_lsc_drv_decompression = FALSE,                                        /*otp data compressed format,                                        should confirm with module fae*/                                        .compress_flag = GAIN_ORIGIN_BITS,                                        /*the width of the stream the sensor can output*/                                        .image_width = 2592,                                        /*the height of the stream the sensor can output*/                                        .image_height = 1944,                                        .gain_width = GAIN_WIDTH,                                        .gain_height = GAIN_HEIGHT,                                },                },};
复制代码
通过is_self_cal等来控制
  1. static cmr_int gc5035_common_otp_drv_calibration(cmr_handle otp_drv_handle) {        cmr_int ret = OTP_CAMERA_SUCCESS;        CHECK_PTR(otp_drv_handle);        OTP_LOGI("in");        otp_drv_cxt_t *otp_cxt = (otp_drv_cxt_t *)otp_drv_handle;        otp_calib_items_t *cali_items = &(gc5035_common_drv_entry.otp_cfg.cali_items);        if (cali_items) {                if (cali_items->is_pdafc && cali_items->is_pdaf_self_cal) {                        gc5035_common_pdaf_calibration(otp_drv_handle);                }                /* calibration at sensor or isp */                if (cali_items->is_awbc && cali_items->is_awbc_self_cal) {                        gc5035_common_awb_calibration(otp_drv_handle);                }                if (cali_items->is_lsc && cali_items->is_lsc_self_cal) {                        gc5035_common_lsc_calibration(otp_drv_handle);                }        }        /* If there are other items that need calibration, please add to here */        OTP_LOGI("out");        return ret;}
复制代码
gc5035_common_awb_calibration就是根据详细规则自己实现了
别的,sensor端,在读取时,start read otp data one time背面,也是根据详细的规则自己实现。
  1. /*============================================================================== * Description: * read otp data from sensor to buffer * please modify this function acording your spec *============================================================================*/static cmr_int gc5035_common_otp_drv_read(cmr_handle otp_drv_handle, void *p_params){        cmr_int ret = OTP_CAMERA_SUCCESS;        CHECK_PTR(otp_drv_handle);        char value[255];        OTP_LOGI("in");        cmr_u8 *buffer = NULL;        otp_drv_cxt_t *otp_cxt = (otp_drv_cxt_t *)otp_drv_handle;        otp_params_t *otp_raw_data = &(otp_cxt->otp_raw_data);        otp_params_t *p_data = (otp_params_t *)p_params;        if (!otp_raw_data->buffer) {                /*when mobile power on , it will init*/                otp_raw_data->buffer = sensor_otp_get_raw_buffer(OTP_LEN, otp_cxt->sensor_id);                if (NULL == otp_raw_data->buffer) {                        OTP_LOGE("malloc otp raw buffer failed\n");                        ret = OTP_CAMERA_FAIL;                        goto exit;                }                 otp_raw_data->num_bytes = OTP_LEN;                gc5035_common_buffer_init(otp_drv_handle);        }        if (sensor_otp_get_buffer_state(otp_cxt->sensor_id)) {                OTP_LOGI("otp raw data has read before,return directly");                if (p_data) {                        p_data->buffer = otp_raw_data->buffer;                        p_data->num_bytes = otp_raw_data->num_bytes;                }                goto exit;        } else {                /* start read otp data one time */                /* TODO */                gc5035_common_otp_enable(otp_drv_handle, otp_open);                gc5035_common_read_otp_group(otp_drv_handle, OTP_START_ADDR, otp_raw_data->buffer, OTP_LEN);                gc5035_common_otp_enable(otp_drv_handle, otp_close);                /* END */                for(int i = 0; i < OTP_LEN; i++)                {                        OTP_LOGI("otp address, value: p1:[0x%x,0x%x]",OTP_START_ADDR+i*8,otp_raw_data->buffer[i]);                }                /*                if (OTP_CAMERA_SUCCESS == ret) {                        property_get("debug.camera.save.otp.raw.data", value, "0");                        if (atoi(value) == 1) {                                if (sensor_otp_dump_raw_data(otp_raw_data->buffer, OTP_LEN,                                                                                        otp_cxt->dev_name))                                        OTP_LOGE("dump failed");                        }                }*/        }exit:    OTP_LOGI("out");    return ret;}
复制代码
大抵流程分为:就分为上述三步,根据详细规则来。
1.gc5035_common_otp_enable
这里大部门是选页,初始化操纵这些
2.gc5035_common_read_otp_group
一次性将烧录的数据全部读出来
3.gc5035_common_otp_enable
Disable OTP相关操纵
sensor端时,读取地点这些,就在.h文件中设置即可
  1. /* I2C slave address setting */#define OTP_I2C_ADDR (0x6e >> 1)#define SENSOR_I2C_ADDR (0x6e >> 1)/* OTP space setting */#define OTP_START_ADDR 0x1f10#define OTP_END_ADDR 0x1ff8#define OTP_LEN   30
复制代码
来源:https://blog.csdn.net/weixin_47000196/article/details/111741762
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则


专注素材教程免费分享
全国免费热线电话

18768367769

周一至周日9:00-23:00

反馈建议

27428564@qq.com 在线QQ咨询

扫描二维码关注我们

Powered by Discuz! X3.4© 2001-2013 Comsenz Inc.( 蜀ICP备2021001884号-1 )