From: wangdw10 Date: Fri, 10 May 2019 03:00:05 +0000 (+0800) Subject: [COMMON] fimc-is2: troika: improve eeprom dump logic X-Git-Tag: MMI-QSAS30.62-33-3~805 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=0a70645c47fd7b83aaedfe935f36372e42f0b259;p=GitHub%2FMotorolaMobilityLLC%2Fkernel-slsi.git [COMMON] fimc-is2: troika: improve eeprom dump logic 1. avoid dump again when serial number same 2. fix logic error when CRC fail Change-Id: Ib7a0ace30b46aef1ca5eb11d40d307a5198acfb4 Signed-off-by: wangdw10 --- diff --git a/drivers/media/platform/exynos/fimc-is2/sensor/module_framework/eeprom/fimc-is-sensor-eeprom-12a10.c b/drivers/media/platform/exynos/fimc-is2/sensor/module_framework/eeprom/fimc-is-sensor-eeprom-12a10.c index ef3096e808fd..7aefd77cbe53 100644 --- a/drivers/media/platform/exynos/fimc-is2/sensor/module_framework/eeprom/fimc-is-sensor-eeprom-12a10.c +++ b/drivers/media/platform/exynos/fimc-is2/sensor/module_framework/eeprom/fimc-is-sensor-eeprom-12a10.c @@ -58,7 +58,7 @@ int fimc_is_eeprom_12a10_check_all_crc(struct v4l2_subdev *subdev) /* All calibration data is zero set only Address section is invalid CRC */ fimc_is_eeprom_cal_data_set(eeprom->data, "all", - EEPROM_ADD_CRC_SEC, EEPROM_DATA_SIZE, 0xff); + EEPROM_ADD_CRC_FST, EEPROM_DATA_SIZE, 0xff); /*Set all cal_status to ERROR if Address cal data invalid*/ for (int i = 0; i < CAMERA_CRC_INDEX_MAX; i++) @@ -74,7 +74,7 @@ int fimc_is_eeprom_12a10_check_all_crc(struct v4l2_subdev *subdev) /* All calibration data is 0xff set but exception Address section */ fimc_is_eeprom_cal_data_set(eeprom->data, "Information - End", - EEPROM_INFO_CRC_SEC, EEPROM_ADD_CAL_SIZE, 0xff); + EEPROM_INFO_CRC_FST, EEPROM_ADD_CAL_SIZE, 0xff); sensor->cal_status[CAMERA_CRC_INDEX_MNF] = CRC_ERROR; } else { @@ -89,7 +89,7 @@ int fimc_is_eeprom_12a10_check_all_crc(struct v4l2_subdev *subdev) err("%s(): 12A10 EEPROM AWB section CRC check fail(%d)", __func__, ret); fimc_is_eeprom_cal_data_set(eeprom->data, "AWB", - EEPROM_AWB_CRC_SEC, EEPROM_AWB_CAL_SIZE, 0xff); + EEPROM_AWB_CRC_FST, EEPROM_AWB_CAL_SIZE, 0xff); sensor->cal_status[CAMERA_CRC_INDEX_AWB] = CRC_ERROR; } else { @@ -112,7 +112,7 @@ int fimc_is_eeprom_12a10_check_all_crc(struct v4l2_subdev *subdev) err("%s(): 12A10 EEPROM AF section CRC check fail(%d)", __func__, ret); fimc_is_eeprom_cal_data_set(eeprom->data, "AF", - EEPROM_AF_CRC_SEC, EEPROM_AF_CAL_SIZE, 0xff); + EEPROM_AF_CRC_FST, EEPROM_AF_CAL_SIZE, 0xff); sensor->cal_status[CAMERA_CRC_INDEX_AF] = CRC_ERROR; } else { @@ -127,7 +127,7 @@ int fimc_is_eeprom_12a10_check_all_crc(struct v4l2_subdev *subdev) err("%s(): 12A10 EEPROM LSC section CRC check fail(%d)", __func__, ret); fimc_is_eeprom_cal_data_set(eeprom->data, "LSC", - EEPROM_LSC_CRC_SEC, EEPROM_LSC_CAL_SIZE, 0xff); + EEPROM_LSC_CRC_FST, EEPROM_LSC_CAL_SIZE, 0xff); } else info("12A10 EEPROM LSC section CRC check success\n"); @@ -137,7 +137,7 @@ int fimc_is_eeprom_12a10_check_all_crc(struct v4l2_subdev *subdev) err("%s(): 12A10 EEPROM PDAF section CRC check fail(%d)", __func__, ret); fimc_is_eeprom_cal_data_set(eeprom->data, "PDAF", - EEPROM_PDAF_CRC_SEC, EEPROM_PDAF_CAL_SIZE, 0xff); + EEPROM_PDAF_CRC_FST, EEPROM_PDAF_CAL_SIZE, 0xff); sensor->cal_status[CAMERA_CRC_INDEX_PDAF] = CRC_ERROR; } else { @@ -152,7 +152,7 @@ int fimc_is_eeprom_12a10_check_all_crc(struct v4l2_subdev *subdev) err("%s(): 12A10 EEPROM AE section CRC check fail(%d)", __func__, ret); fimc_is_eeprom_cal_data_set(eeprom->data, "AE", - EEPROM_AE_CRC_SEC, EEPROM_AE_CAL_SIZE, 0xff); + EEPROM_AE_CRC_FST, EEPROM_AE_CAL_SIZE, 0xff); } else info("12A10 EEPROM AE section CRC check success\n"); @@ -162,7 +162,7 @@ int fimc_is_eeprom_12a10_check_all_crc(struct v4l2_subdev *subdev) err("%s(): EEPROM Dual section check fail(%d)", __func__, ret); fimc_is_eeprom_cal_data_set(eeprom->data, "DUAL", - EEPROM_DUAL_CRC_SEC, EEPROM_DUAL_CAL_SIZE, 0xff); + EEPROM_DUAL_CRC_FST, EEPROM_DUAL_CAL_SIZE, 0xff); sensor->cal_status[CAMERA_CRC_INDEX_DUAL] = CRC_ERROR; } else { @@ -177,7 +177,7 @@ int fimc_is_eeprom_12a10_check_all_crc(struct v4l2_subdev *subdev) err("%s(): EEPROM SFR section CRC check fail(%d)", __func__, ret); fimc_is_eeprom_cal_data_set(eeprom->data, "SFR", - EEPROM_SFR_CRC_SEC, EEPROM_SFR_CAL_SIZE, 0xff); + EEPROM_SFR_CRC_FST, EEPROM_SFR_CAL_SIZE, 0xff); } else info("12A10 EEPROM SFR section CRC check success\n"); @@ -243,9 +243,11 @@ static int fimc_is_eeprom_12a10_check_info(struct v4l2_subdev *subdev) crc_value = ((eeprom->data[EEPROM_INFO_CRC_SEC] << 8) | (eeprom->data[EEPROM_INFO_CRC_FST])); crc16 = fimc_is_sensor_eeprom_check_crc(&eeprom->data[EEPROM_INFO_CRC_CHK_START], EEPROM_INFO_CRC_CHK_SIZE); - if (crc_value != crc16) + if (crc_value != crc16) { err("Error to INFO CRC16: 0x%x, cal_buffer CRC: 0x%x", crc16, crc_value); - else + + ret = -EINVAL; + } else info("INFO CRC16: 0x%x, cal_buffer CRC: 0x%x\n", crc16, crc_value); return ret; @@ -267,9 +269,11 @@ static int fimc_is_eeprom_12a10_check_awb(struct v4l2_subdev *subdev) crc_value = ((eeprom->data[EEPROM_AWB_CRC_SEC] << 8) | (eeprom->data[EEPROM_AWB_CRC_FST])); crc16 = fimc_is_sensor_eeprom_check_crc(&eeprom->data[EEPROM_AWB_CRC_CHK_START], EEPROM_AWB_CRC_CHK_SIZE); - if (crc_value != crc16) + if (crc_value != crc16) { err("Error to AWB CRC16: 0x%x, cal_buffer CRC: 0x%x", crc16, crc_value); - else + + ret = -EINVAL; + } else info("AWB CRC16: 0x%x, cal_buffer CRC: 0x%x\n", crc16, crc_value); return ret; @@ -291,9 +295,11 @@ static int fimc_is_eeprom_12a10_check_af(struct v4l2_subdev *subdev) crc_value = ((eeprom->data[EEPROM_AF_CRC_SEC] << 8) | (eeprom->data[EEPROM_AF_CRC_FST])); crc16 = fimc_is_sensor_eeprom_check_crc(&eeprom->data[EEPROM_AF_CRC_CHK_START], EEPROM_AF_CRC_CHK_SIZE); - if (crc_value != crc16) + if (crc_value != crc16) { err("Error to AF CRC16: 0x%x, cal_buffer CRC: 0x%x", crc16, crc_value); - else + + ret = -EINVAL; + } else info("AF CRC16: %x, cal_buffer CRC: %x\n", crc16, crc_value); return ret; @@ -315,9 +321,11 @@ static int fimc_is_eeprom_12a10_check_ae(struct v4l2_subdev *subdev) crc_value = ((eeprom->data[EEPROM_AE_CRC_SEC] << 8) | (eeprom->data[EEPROM_AE_CRC_FST])); crc16 = fimc_is_sensor_eeprom_check_crc(&eeprom->data[EEPROM_AE_CRC_CHK_START], EEPROM_AE_CRC_CHK_SIZE); - if (crc_value != crc16) + if (crc_value != crc16) { err("Error to AE CRC16: 0x%x, cal_buffer CRC: 0x%x", crc16, crc_value); - else + + ret = -EINVAL; + } else info("AE CRC16: %x, cal_buffer CRC: %x\n", crc16, crc_value); return ret; @@ -339,9 +347,11 @@ static int fimc_is_eeprom_12a10_check_lsc(struct v4l2_subdev *subdev) crc_value = ((eeprom->data[EEPROM_LSC_CRC_SEC] << 8) | (eeprom->data[EEPROM_LSC_CRC_FST])); crc16 = fimc_is_sensor_eeprom_check_crc(&eeprom->data[EEPROM_LSC_CRC_CHK_START], EEPROM_LSC_CRC_CHK_SIZE); - if (crc_value != crc16) + if (crc_value != crc16) { err("Error to LSC CRC16: 0x%x, cal_buffer CRC: 0x%x", crc16, crc_value); - else + + ret = -EINVAL; + } else info("LSC CRC16: 0x%x, cal_buffer CRC: 0x%x\n", crc16, crc_value); return ret; @@ -363,9 +373,11 @@ static int fimc_is_eeprom_12a10_check_pdaf(struct v4l2_subdev *subdev) crc_value = ((eeprom->data[EEPROM_PDAF_CRC_SEC] << 8) | (eeprom->data[EEPROM_PDAF_CRC_FST])); crc16 = fimc_is_sensor_eeprom_check_crc(&eeprom->data[EEPROM_PDAF_CRC_CHK_START], EEPROM_PDAF_CRC_CHK_SIZE); - if (crc_value != crc16) + if (crc_value != crc16) { err("Error to PDAF CRC16: 0x%x, cal_buffer CRC: 0x%x", crc16, crc_value); - else + + ret = -EINVAL; + } else info("PDAF CRC16: 0x%x, cal_buffer CRC: 0x%x\n", crc16, crc_value); return ret; @@ -387,17 +399,21 @@ static int fimc_is_eeprom_12a10_check_dual(struct v4l2_subdev *subdev) crc_value = ((eeprom->data[EEPROM_DUAL_CRC_SEC] << 8) | (eeprom->data[EEPROM_DUAL_CRC_FST])); crc16 = fimc_is_sensor_eeprom_check_crc(&eeprom->data[EEPROM_DUAL_CRC_CHK_START], EEPROM_DUAL_CRC_CHK_SIZE); - if (crc_value != crc16) + if (crc_value != crc16) { err("Error to DUAL CRC16: 0x%x, cal_buffer CRC: 0x%x", crc16, crc_value); - else + + ret = -EINVAL; + } else info("DUAL CRC16: 0x%x, cal_buffer CRC: 0x%x\n", crc16, crc_value); crc_value = ((eeprom->data[EEPROM_DUAL_VER_CRC_SEC] << 8) | (eeprom->data[EEPROM_DUAL_VER_CRC_FST])); crc16 = fimc_is_sensor_eeprom_check_crc(&eeprom->data[EEPROM_DUAL_VER_CRC_CHK_START], EEPROM_DUAL_VER_CRC_CHK_SIZE); - if (crc_value != crc16) + if (crc_value != crc16) { err("Error to DUAL VER CRC16: 0x%x, cal_buffer CRC: 0x%x", crc16, crc_value); - else + + ret = -EINVAL; + } else info("DUAL VER CRC16: 0x%x, cal_buffer CRC: 0x%x\n", crc16, crc_value); return ret; @@ -419,9 +435,11 @@ static int fimc_is_eeprom_12a10_check_sfr(struct v4l2_subdev *subdev) crc_value = ((eeprom->data[EEPROM_SFR_CRC_SEC] << 8) | (eeprom->data[EEPROM_SFR_CRC_FST])); crc16 = fimc_is_sensor_eeprom_check_crc(&eeprom->data[EEPROM_SFR_CRC_CHK_START], EEPROM_SFR_CRC_CHK_SIZE); - if (crc_value != crc16) + if (crc_value != crc16) { err("Error to SFR CRC16: 0x%x, cal_buffer CRC: 0x%x", crc16, crc_value); - else + + ret = -EINVAL; + } else info("SFR CRC16: 0x%x, cal_buffer CRC: 0x%x\n", crc16, crc_value); return ret; diff --git a/drivers/media/platform/exynos/fimc-is2/sensor/module_framework/eeprom/fimc-is-sensor-eeprom-12a10ff.c b/drivers/media/platform/exynos/fimc-is2/sensor/module_framework/eeprom/fimc-is-sensor-eeprom-12a10ff.c index 3f66cf928ad2..45d944e594bc 100644 --- a/drivers/media/platform/exynos/fimc-is2/sensor/module_framework/eeprom/fimc-is-sensor-eeprom-12a10ff.c +++ b/drivers/media/platform/exynos/fimc-is2/sensor/module_framework/eeprom/fimc-is-sensor-eeprom-12a10ff.c @@ -58,7 +58,7 @@ int fimc_is_eeprom_12a10ff_check_all_crc(struct v4l2_subdev *subdev) /* All calibration data is zero set only Address section is invalid CRC */ fimc_is_eeprom_cal_data_set(eeprom->data, "all", - EEPROM_ADD_CRC_SEC, EEPROM_DATA_SIZE, 0xff); + EEPROM_ADD_CRC_FST, EEPROM_DATA_SIZE, 0xff); /*Set all cal_status to ERROR if Address cal data invalid*/ for (int i = 0; i < CAMERA_CRC_INDEX_MAX; i++) @@ -75,7 +75,7 @@ int fimc_is_eeprom_12a10ff_check_all_crc(struct v4l2_subdev *subdev) /* All calibration data is 0xff set but exception Address section */ fimc_is_eeprom_cal_data_set(eeprom->data, "Information - End", - EEPROM_INFO_CRC_SEC, EEPROM_ADD_CAL_SIZE, 0xff); + EEPROM_INFO_CRC_FST, EEPROM_ADD_CAL_SIZE, 0xff); sensor->cal_status[CAMERA_CRC_INDEX_MNF] = CRC_ERROR; @@ -91,7 +91,7 @@ int fimc_is_eeprom_12a10ff_check_all_crc(struct v4l2_subdev *subdev) err("%s(): 12A10FF EEPROM AWB section CRC check fail(%d)", __func__, ret); fimc_is_eeprom_cal_data_set(eeprom->data, "AWB", - EEPROM_AWB_CRC_SEC, EEPROM_AWB_CAL_SIZE, 0xff); + EEPROM_AWB_CRC_FST, EEPROM_AWB_CAL_SIZE, 0xff); sensor->cal_status[CAMERA_CRC_INDEX_AWB] = CRC_ERROR; @@ -115,7 +115,7 @@ int fimc_is_eeprom_12a10ff_check_all_crc(struct v4l2_subdev *subdev) err("%s(): 12A10FF EEPROM LSC section CRC check fail(%d)", __func__, ret); fimc_is_eeprom_cal_data_set(eeprom->data, "LSC", - EEPROM_LSC_CRC_SEC, EEPROM_LSC_CAL_SIZE, 0xff); + EEPROM_LSC_CRC_FST, EEPROM_LSC_CAL_SIZE, 0xff); } else info("12A10FF EEPROM LSC section CRC check success\n"); @@ -126,17 +126,11 @@ int fimc_is_eeprom_12a10ff_check_all_crc(struct v4l2_subdev *subdev) err("%s(): EEPROM SFR section CRC check fail(%d)", __func__, ret); fimc_is_eeprom_cal_data_set(eeprom->data, "SFR", - EEPROM_SFR_CRC_SEC, EEPROM_SFR_CAL_SIZE, 0xff); + EEPROM_SFR_CRC_FST, EEPROM_SFR_CAL_SIZE, 0xff); } else info("12A10FF EEPROM SFR section CRC check success\n"); - /* Write file to serial number of Information calibration data */ - ret = fimc_is_eeprom_file_write(EEPROM_SERIAL_NUM_DATA_PATH, - (void *)&eeprom->data[EEPROM_INFO_SERIAL_NUM_START], EEPROM_INFO_SERIAL_NUM_SIZE); - if (ret < 0) - err("%s(), DUAL cal file write fail(%d)", __func__, ret); - return ret; } @@ -182,9 +176,11 @@ static int fimc_is_eeprom_12a10ff_check_info(struct v4l2_subdev *subdev) crc_value = ((eeprom->data[EEPROM_INFO_CRC_SEC] << 8) | (eeprom->data[EEPROM_INFO_CRC_FST])); crc16 = fimc_is_sensor_eeprom_check_crc(&eeprom->data[EEPROM_INFO_CRC_CHK_START], EEPROM_INFO_CRC_CHK_SIZE); - if (crc_value != crc16) + if (crc_value != crc16) { err("Error to INFO CRC16: 0x%x, cal_buffer CRC: 0x%x", crc16, crc_value); - else + + ret = -EINVAL; + } else info("INFO CRC16: 0x%x, cal_buffer CRC: 0x%x\n", crc16, crc_value); return ret; @@ -206,9 +202,11 @@ static int fimc_is_eeprom_12a10ff_check_awb(struct v4l2_subdev *subdev) crc_value = ((eeprom->data[EEPROM_AWB_CRC_SEC] << 8) | (eeprom->data[EEPROM_AWB_CRC_FST])); crc16 = fimc_is_sensor_eeprom_check_crc(&eeprom->data[EEPROM_AWB_CRC_CHK_START], EEPROM_AWB_CRC_CHK_SIZE); - if (crc_value != crc16) + if (crc_value != crc16) { err("Error to AWB CRC16: 0x%x, cal_buffer CRC: 0x%x", crc16, crc_value); - else + + ret = -EINVAL; + } else info("AWB CRC16: 0x%x, cal_buffer CRC: 0x%x\n", crc16, crc_value); return ret; @@ -230,9 +228,11 @@ static int fimc_is_eeprom_12a10ff_check_lsc(struct v4l2_subdev *subdev) crc_value = ((eeprom->data[EEPROM_LSC_CRC_SEC] << 8) | (eeprom->data[EEPROM_LSC_CRC_FST])); crc16 = fimc_is_sensor_eeprom_check_crc(&eeprom->data[EEPROM_LSC_CRC_CHK_START], EEPROM_LSC_CRC_CHK_SIZE); - if (crc_value != crc16) + if (crc_value != crc16) { err("Error to LSC CRC16: 0x%x, cal_buffer CRC: 0x%x", crc16, crc_value); - else + + ret = -EINVAL; + } else info("LSC CRC16: 0x%x, cal_buffer CRC: 0x%x\n", crc16, crc_value); return ret; @@ -254,9 +254,11 @@ static int fimc_is_eeprom_12a10ff_check_sfr(struct v4l2_subdev *subdev) crc_value = ((eeprom->data[EEPROM_SFR_CRC_SEC] << 8) | (eeprom->data[EEPROM_SFR_CRC_FST])); crc16 = fimc_is_sensor_eeprom_check_crc(&eeprom->data[EEPROM_SFR_CRC_CHK_START], EEPROM_SFR_CRC_CHK_SIZE); - if (crc_value != crc16) + if (crc_value != crc16) { err("Error to SFR CRC16: 0x%x, cal_buffer CRC: 0x%x", crc16, crc_value); - else + + ret = -EINVAL; + } else info("SFR CRC16: 0x%x, cal_buffer CRC: 0x%x\n", crc16, crc_value); return ret; @@ -267,6 +269,8 @@ int fimc_is_eeprom_12a10ff_get_cal_data(struct v4l2_subdev *subdev) int ret = 0; struct fimc_is_eeprom *eeprom; struct i2c_client *client; + char serial_id[EEPROM_INFO_SERIAL_NUM_SIZE + 1]; + char serial_id_dump[EEPROM_INFO_SERIAL_NUM_SIZE + 1]; FIMC_BUG(!subdev); @@ -281,6 +285,16 @@ int fimc_is_eeprom_12a10ff_get_cal_data(struct v4l2_subdev *subdev) return ret; } + I2C_MUTEX_LOCK(eeprom->i2c_lock); + ret = fimc_is_eeprom_module_read(client, EEPROM_INFO_SERIAL_NUM_START, serial_id, EEPROM_INFO_SERIAL_NUM_SIZE); + if (ret < 0) { + err("%s(): eeprom i2c read failed(%d)\n", __func__, ret); + I2C_MUTEX_UNLOCK(eeprom->i2c_lock); + return ret; + } + I2C_MUTEX_UNLOCK(eeprom->i2c_lock); + serial_id[EEPROM_INFO_SERIAL_NUM_SIZE] = '\0'; + /* * If already read at EEPROM data in module * don't again read at EEPROM but there isn't file or @@ -288,12 +302,15 @@ int fimc_is_eeprom_12a10ff_get_cal_data(struct v4l2_subdev *subdev) */ ret = fimc_is_eeprom_file_read(EEPROM_DATA_PATH, (void *)eeprom->data, EEPROM_DATA_SIZE); if (ret) { + I2C_MUTEX_LOCK(eeprom->i2c_lock); /* I2C read to Sensor EEPROM cal data */ ret = fimc_is_eeprom_module_read(client, EEPROM_ADD_CRC_FST, eeprom->data, EEPROM_DATA_SIZE); if (ret < 0) { err("%s(): eeprom i2c read failed(%d)\n", __func__, ret); + I2C_MUTEX_UNLOCK(eeprom->i2c_lock); return ret; } + I2C_MUTEX_UNLOCK(eeprom->i2c_lock); /* CRC check to each section cal data */ ret = CALL_EEPROMOPS(eeprom, eeprom_check_all_crc, subdev); @@ -307,10 +324,44 @@ int fimc_is_eeprom_12a10ff_get_cal_data(struct v4l2_subdev *subdev) return ret; } } else { - /* CRC check to each section cal data */ - ret = CALL_EEPROMOPS(eeprom, eeprom_check_all_crc, subdev); - if (ret < 0) - err("%s(): eeprom data invalid(%d)\n", __func__, ret); + memcpy(serial_id_dump, &eeprom->data[EEPROM_INFO_SERIAL_NUM_START], + EEPROM_INFO_SERIAL_NUM_SIZE); + serial_id_dump[EEPROM_INFO_SERIAL_NUM_SIZE] = '\0'; + + if(memcmp(serial_id, serial_id_dump, EEPROM_INFO_SERIAL_NUM_SIZE)) + { + /* Read Sensor EEPROM cause change a module */ + info("%s() : Different new module, so read eeprom\n", __func__); + + I2C_MUTEX_LOCK(eeprom->i2c_lock); + /* I2C read to Sensor EEPROM cal data */ + ret = fimc_is_eeprom_module_read(client, EEPROM_ADD_CRC_FST, eeprom->data, EEPROM_DATA_SIZE); + if (ret < 0) { + err("%s(): eeprom i2c read failed(%d)\n", __func__, ret); + I2C_MUTEX_UNLOCK(eeprom->i2c_lock); + return ret; + } + I2C_MUTEX_UNLOCK(eeprom->i2c_lock); + + /* CRC check to each section cal data */ + ret = CALL_EEPROMOPS(eeprom, eeprom_check_all_crc, subdev); + if (ret < 0) + err("%s(): eeprom data invalid(%d)\n", __func__, ret); + + /* Write file to Cal data */ + ret = fimc_is_eeprom_file_write(EEPROM_DATA_PATH, (void *)eeprom->data, EEPROM_DATA_SIZE); + if (ret < 0) { + err("%s(), eeprom file write fail(%d)\n", __func__, ret); + return ret; + } + } else { + info("%s(): Same module and file dump so use file dump data\n", __func__); + + /* CRC check to each section cal data */ + ret = CALL_EEPROMOPS(eeprom, eeprom_check_all_crc, subdev); + if (ret < 0) + err("%s(): eeprom data invalid(%d)\n", __func__, ret); + } } return ret; diff --git a/drivers/media/platform/exynos/fimc-is2/sensor/module_framework/eeprom/fimc-is-sensor-eeprom-12a10ff.h b/drivers/media/platform/exynos/fimc-is2/sensor/module_framework/eeprom/fimc-is-sensor-eeprom-12a10ff.h index cc7b26d9f683..a11b7ee35299 100644 --- a/drivers/media/platform/exynos/fimc-is2/sensor/module_framework/eeprom/fimc-is-sensor-eeprom-12a10ff.h +++ b/drivers/media/platform/exynos/fimc-is2/sensor/module_framework/eeprom/fimc-is-sensor-eeprom-12a10ff.h @@ -13,7 +13,6 @@ #define FIMC_IS_EEPROM_12A10FF_H #define EEPROM_DATA_PATH "/data/vendor/camera/dump_12a10ff_eeprom_data.bin" -#define EEPROM_SERIAL_NUM_DATA_PATH "/data/vendor/camera/serial_number_12a10ff.bin" /* Total Cal data size */ #define EEPROM_DATA_SIZE SZ_8K diff --git a/drivers/media/platform/exynos/fimc-is2/sensor/module_framework/eeprom/fimc-is-sensor-eeprom-16885c.c b/drivers/media/platform/exynos/fimc-is2/sensor/module_framework/eeprom/fimc-is-sensor-eeprom-16885c.c index d9314c334957..7d70cfddd0f6 100644 --- a/drivers/media/platform/exynos/fimc-is2/sensor/module_framework/eeprom/fimc-is-sensor-eeprom-16885c.c +++ b/drivers/media/platform/exynos/fimc-is2/sensor/module_framework/eeprom/fimc-is-sensor-eeprom-16885c.c @@ -58,7 +58,7 @@ int fimc_is_eeprom_16885c_check_all_crc(struct v4l2_subdev *subdev) /* All calibration data is zero set only Address section is invalid CRC */ fimc_is_eeprom_cal_data_set(eeprom->data, "all", - EEPROM_ADD_CRC_SEC, EEPROM_DATA_SIZE, 0xff); + EEPROM_ADD_CRC_FST, EEPROM_DATA_SIZE, 0xff); /*Set all cal_status to ERROR if Address cal data invalid*/ for (int i = 0; i < CAMERA_CRC_INDEX_MAX; i++) @@ -75,7 +75,7 @@ int fimc_is_eeprom_16885c_check_all_crc(struct v4l2_subdev *subdev) /* All calibration data is 0xff set but exception Address section */ fimc_is_eeprom_cal_data_set(eeprom->data, "Information - End", - EEPROM_INFO_CRC_SEC, EEPROM_ADD_CAL_SIZE, 0xff); + EEPROM_INFO_CRC_FST, EEPROM_ADD_CAL_SIZE, 0xff); sensor->cal_status[CAMERA_CRC_INDEX_MNF] = CRC_ERROR; @@ -91,7 +91,7 @@ int fimc_is_eeprom_16885c_check_all_crc(struct v4l2_subdev *subdev) err("%s(): 16885C EEPROM AWB section CRC check fail(%d)", __func__, ret); fimc_is_eeprom_cal_data_set(eeprom->data, "AWB", - EEPROM_AWB_CRC_SEC, EEPROM_AWB_CAL_SIZE, 0xff); + EEPROM_AWB_CRC_FST, EEPROM_AWB_CAL_SIZE, 0xff); sensor->cal_status[CAMERA_CRC_INDEX_AWB] = CRC_ERROR; @@ -115,7 +115,7 @@ int fimc_is_eeprom_16885c_check_all_crc(struct v4l2_subdev *subdev) err("%s(): 16885C EEPROM LSC section CRC check fail(%d)", __func__, ret); fimc_is_eeprom_cal_data_set(eeprom->data, "LSC", - EEPROM_LSC_CRC_SEC, EEPROM_LSC_CAL_SIZE, 0xff); + EEPROM_LSC_CRC_FST, EEPROM_LSC_CAL_SIZE, 0xff); } else info("16885C EEPROM LSC section CRC check success\n"); @@ -126,17 +126,11 @@ int fimc_is_eeprom_16885c_check_all_crc(struct v4l2_subdev *subdev) err("%s(): EEPROM SFR section CRC check fail(%d)", __func__, ret); fimc_is_eeprom_cal_data_set(eeprom->data, "SFR", - EEPROM_SFR_CRC_SEC, EEPROM_SFR_CAL_SIZE, 0xff); + EEPROM_SFR_CRC_FST, EEPROM_SFR_CAL_SIZE, 0xff); } else info("16885C EEPROM SFR section CRC check success\n"); - /* Write file to serial number of Information calibration data */ - ret = fimc_is_eeprom_file_write(EEPROM_SERIAL_NUM_DATA_PATH, - (void *)&eeprom->data[EEPROM_INFO_SERIAL_NUM_START], EEPROM_INFO_SERIAL_NUM_SIZE); - if (ret < 0) - err("%s(), DUAL cal file write fail(%d)", __func__, ret); - return ret; } @@ -182,9 +176,11 @@ static int fimc_is_eeprom_16885c_check_info(struct v4l2_subdev *subdev) crc_value = ((eeprom->data[EEPROM_INFO_CRC_SEC] << 8) | (eeprom->data[EEPROM_INFO_CRC_FST])); crc16 = fimc_is_sensor_eeprom_check_crc(&eeprom->data[EEPROM_INFO_CRC_CHK_START], EEPROM_INFO_CRC_CHK_SIZE); - if (crc_value != crc16) + if (crc_value != crc16) { err("Error to INFO CRC16: 0x%x, cal_buffer CRC: 0x%x", crc16, crc_value); - else + + ret = -EINVAL; + } else info("INFO CRC16: 0x%x, cal_buffer CRC: 0x%x\n", crc16, crc_value); return ret; @@ -206,9 +202,11 @@ static int fimc_is_eeprom_16885c_check_awb(struct v4l2_subdev *subdev) crc_value = ((eeprom->data[EEPROM_AWB_CRC_SEC] << 8) | (eeprom->data[EEPROM_AWB_CRC_FST])); crc16 = fimc_is_sensor_eeprom_check_crc(&eeprom->data[EEPROM_AWB_CRC_CHK_START], EEPROM_AWB_CRC_CHK_SIZE); - if (crc_value != crc16) + if (crc_value != crc16) { err("Error to AWB CRC16: 0x%x, cal_buffer CRC: 0x%x", crc16, crc_value); - else + + ret = -EINVAL; + } else info("AWB CRC16: 0x%x, cal_buffer CRC: 0x%x\n", crc16, crc_value); return ret; @@ -230,9 +228,11 @@ static int fimc_is_eeprom_16885c_check_lsc(struct v4l2_subdev *subdev) crc_value = ((eeprom->data[EEPROM_LSC_CRC_SEC] << 8) | (eeprom->data[EEPROM_LSC_CRC_FST])); crc16 = fimc_is_sensor_eeprom_check_crc(&eeprom->data[EEPROM_LSC_CRC_CHK_START], EEPROM_LSC_CRC_CHK_SIZE); - if (crc_value != crc16) + if (crc_value != crc16) { err("Error to LSC CRC16: 0x%x, cal_buffer CRC: 0x%x", crc16, crc_value); - else + + ret = -EINVAL; + } else info("LSC CRC16: 0x%x, cal_buffer CRC: 0x%x\n", crc16, crc_value); return ret; @@ -254,9 +254,11 @@ static int fimc_is_eeprom_16885c_check_sfr(struct v4l2_subdev *subdev) crc_value = ((eeprom->data[EEPROM_SFR_CRC_SEC] << 8) | (eeprom->data[EEPROM_SFR_CRC_FST])); crc16 = fimc_is_sensor_eeprom_check_crc(&eeprom->data[EEPROM_SFR_CRC_CHK_START], EEPROM_SFR_CRC_CHK_SIZE); - if (crc_value != crc16) + if (crc_value != crc16) { err("Error to SFR CRC16: 0x%x, cal_buffer CRC: 0x%x", crc16, crc_value); - else + + ret = -EINVAL; + } else info("SFR CRC16: 0x%x, cal_buffer CRC: 0x%x\n", crc16, crc_value); return ret; @@ -288,12 +290,15 @@ int fimc_is_eeprom_16885c_get_cal_data(struct v4l2_subdev *subdev) */ ret = fimc_is_eeprom_file_read(EEPROM_DATA_PATH, (void *)eeprom->data, EEPROM_DATA_SIZE); if (ret) { + I2C_MUTEX_LOCK(eeprom->i2c_lock); /* I2C read to Sensor EEPROM cal data */ ret = fimc_is_eeprom_module_read(client, EEPROM_ADD_CRC_FST, eeprom->data, EEPROM_DATA_SIZE); if (ret < 0) { err("%s(): eeprom i2c read failed(%d)\n", __func__, ret); + I2C_MUTEX_UNLOCK(eeprom->i2c_lock); return ret; } + I2C_MUTEX_UNLOCK(eeprom->i2c_lock); /* CRC check to each section cal data */ ret = CALL_EEPROMOPS(eeprom, eeprom_check_all_crc, subdev); diff --git a/drivers/media/platform/exynos/fimc-is2/sensor/module_framework/eeprom/fimc-is-sensor-eeprom-16885c.h b/drivers/media/platform/exynos/fimc-is2/sensor/module_framework/eeprom/fimc-is-sensor-eeprom-16885c.h index 8a2d2202e09f..264fa462d432 100644 --- a/drivers/media/platform/exynos/fimc-is2/sensor/module_framework/eeprom/fimc-is-sensor-eeprom-16885c.h +++ b/drivers/media/platform/exynos/fimc-is2/sensor/module_framework/eeprom/fimc-is-sensor-eeprom-16885c.h @@ -13,7 +13,6 @@ #define FIMC_IS_EEPROM_16885C_H #define EEPROM_DATA_PATH "/data/vendor/camera/dump_16885c_eeprom_data.bin" -#define EEPROM_SERIAL_NUM_DATA_PATH "/data/vendor/camera/serial_number_16885c.bin" /* Total Cal data size */ #define EEPROM_DATA_SIZE SZ_8K diff --git a/drivers/media/platform/exynos/fimc-is2/sensor/module_framework/eeprom/fimc-is-sensor-eeprom.c b/drivers/media/platform/exynos/fimc-is2/sensor/module_framework/eeprom/fimc-is-sensor-eeprom.c index 278f03b90d98..b96356c4b1f9 100644 --- a/drivers/media/platform/exynos/fimc-is2/sensor/module_framework/eeprom/fimc-is-sensor-eeprom.c +++ b/drivers/media/platform/exynos/fimc-is2/sensor/module_framework/eeprom/fimc-is-sensor-eeprom.c @@ -27,7 +27,7 @@ void fimc_is_eeprom_cal_data_set(char *data, char *name, int i; /* value setting to (name) cal data section */ - for (i = addr; i < size; i++) + for (i = addr; i < addr + size; i++) data[i] = value; info("%s() Done: %s calibration data is %d set\n", __func__, name, value);