[COMMON] fimc-is2: troika: improve eeprom dump logic
authorwangdw10 <wangdw10@lenovo.com>
Fri, 10 May 2019 03:00:05 +0000 (11:00 +0800)
committerKim Gunho <gunho.kim@samsung.com>
Wed, 7 Aug 2019 13:00:10 +0000 (22:00 +0900)
1. avoid dump again when serial number same
2. fix logic error when CRC fail

Change-Id: Ib7a0ace30b46aef1ca5eb11d40d307a5198acfb4
Signed-off-by: wangdw10 <wangdw10@lenovo.com>
drivers/media/platform/exynos/fimc-is2/sensor/module_framework/eeprom/fimc-is-sensor-eeprom-12a10.c
drivers/media/platform/exynos/fimc-is2/sensor/module_framework/eeprom/fimc-is-sensor-eeprom-12a10ff.c
drivers/media/platform/exynos/fimc-is2/sensor/module_framework/eeprom/fimc-is-sensor-eeprom-12a10ff.h
drivers/media/platform/exynos/fimc-is2/sensor/module_framework/eeprom/fimc-is-sensor-eeprom-16885c.c
drivers/media/platform/exynos/fimc-is2/sensor/module_framework/eeprom/fimc-is-sensor-eeprom-16885c.h
drivers/media/platform/exynos/fimc-is2/sensor/module_framework/eeprom/fimc-is-sensor-eeprom.c

index ef3096e808fd03f5daa4aa51dd1242c1c7e2a2fc..7aefd77cbe536a622e17521697d97ea32ac1ba27 100644 (file)
@@ -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;
index 3f66cf928ad25fcf32f2e3f9f2ab752d7caf41b4..45d944e594bc48e283a51ceaa13288b490172e54 100644 (file)
@@ -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;
index cc7b26d9f6839e5a86d06600b472eabf5e538098..a11b7ee35299db2fd5c630d4e52083a9f3691549 100644 (file)
@@ -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
index d9314c334957a0e1657205a1b926b7992f62f5e1..7d70cfddd0f662465818e6a93666a631f9773a1a 100644 (file)
@@ -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);
index 8a2d2202e09f9910cc4272aa6b413f2808f66b13..264fa462d432a61c0bb3e7789555cbf92b157a94 100644 (file)
@@ -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
index 278f03b90d9860605eed7551d859de8350760692..b96356c4b1f936ce95ce37e197ed9ea1bdf23608 100644 (file)
@@ -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);