static int
imx328_match_id(
        hwsensor_intf_t* si, void * data)
{
    sensor_t* sensor = I2S(si);
    struct sensor_cfg_data *cdata = (struct sensor_cfg_data *)data;
    uint16_t sensor_id = 0;
    uint8_t modue_id = 0;

    cam_info("%s TODO.", __func__);

    misp_get_module_info(sensor->board_info->sensor_index,&sensor_id,&modue_id);

    if(sensor_id == 0x328)
    {
        cdata->data = sensor->board_info->sensor_index;
        hwsensor_writefile(sensor->board_info->sensor_index,
                           sensor->board_info->name);
    } else {
        cdata->data = SENSOR_INDEX_INVALID;
    }

    cam_info("%s TODO.  cdata->data=%d", __func__, cdata->data);

    return 0;
}
static int
    ov8865_carrera_match_id(
        hwsensor_intf_t* si, void * data)
{
    sensor_t* sensor = I2S(si);
    struct sensor_cfg_data *cdata = (struct sensor_cfg_data *)data;
    uint16_t sensor_id = 0;
    uint8_t modue_id = 0;
    char * sensor_name = "ov8865";
    cam_info("%s TODO.", __func__);

    misp_get_module_info(sensor->board_info->sensor_index,&sensor_id,&modue_id);

    if(sensor_id == 0x8865) {
        strncpy(cdata->cfg.name, sensor_name, DEVICE_NAME_SIZE);
        cdata->data = sensor->board_info->sensor_index;
        hwsensor_writefile(sensor->board_info->sensor_index,
        cdata->cfg.name);
    } else {
        cdata->data = SENSOR_INDEX_INVALID;
    }

    cam_info("%s TODO.  cdata->data=%d", __func__, cdata->data);

    return 0;
}
static int ar1335_match_id(hwsensor_intf_t* si, void * data)
{
    sensor_t* sensor = I2S(si);
    struct sensor_cfg_data *cdata = (struct sensor_cfg_data *)data;
    uint16_t sensor_id = 0;
    uint8_t modue_id = 0;
    uint8_t retry = 0;

    cam_info("%s TODO.", __func__);
    for(retry = 0;retry < 2; retry++){
    misp_get_module_info(sensor->board_info->sensor_index,&sensor_id,&modue_id);
        if(sensor_id==0){
            cam_info("%s try to read camera id again",__func__);
            continue;
        }else{
            break;
        }
    }
    if(sensor_id == 0x1335) {
        cdata->data = sensor->board_info->sensor_index;
        hwsensor_writefile(sensor->board_info->sensor_index,
                   sensor->board_info->name);
    } else {
        cdata->data = SENSOR_INDEX_INVALID;
    }

    cam_info("%s TODO.  cdata->data=%d", __func__, cdata->data);

    return 0;
}
static int
imx230_plk_match_id(
        hwsensor_intf_t* si, void * data)
{
    sensor_t* sensor = I2S(si);
    struct sensor_cfg_data *cdata = (struct sensor_cfg_data *)data;
    uint16_t sensor_id = 0;
    uint8_t module_id = 0;

    cam_info("%s TODO.", __func__);
    if (NULL == cdata ) {
        cam_err("%s with NULL data", __func__);
        return 0;
    }

    misp_get_module_info(sensor->board_info->sensor_index,&sensor_id,&module_id);

    if(sensor_id == 0x230) {
        cdata->data = sensor->board_info->sensor_index;

        if (MODULE_ID_SUNNY == module_id) {
            strncpy(cdata->cfg.name, MODULE_NAME_SUNNY, DEVICE_NAME_SIZE);
        } else if (MODULE_ID_LITEON == module_id) {
            strncpy(cdata->cfg.name, MODULE_NAME_LITEON, DEVICE_NAME_SIZE);
        } else if (MODULE_ID_LG == module_id) {
            strncpy(cdata->cfg.name, MODULE_NAME_LG, DEVICE_NAME_SIZE);
        } else {
            strncpy(cdata->cfg.name, MODULE_NAME_DEFAULT, DEVICE_NAME_SIZE);
        }
        cdata->cfg.name[DEVICE_NAME_SIZE - 1] = '\0';
        cam_info("%s module_name %s", __func__, cdata->cfg.name);
        hwsensor_writefile(sensor->board_info->sensor_index, cdata->cfg.name);
    } else {
        cdata->data = SENSOR_INDEX_INVALID;
    }

    cam_info("%s TODO.  cdata->data=%d", __func__, cdata->data);

    return 0;
}
static int
    imx278_carrera_match_id(
        hwsensor_intf_t* si, void * data)
{
    sensor_t* sensor = I2S(si);
    struct sensor_cfg_data *cdata = (struct sensor_cfg_data *)data;
    uint16_t sensor_id = 0;
    uint8_t modue_id = 0;
    char *sensor_name[4]={"imx278_sunny","imx278_liteon","imx278_lg","imx278"};

    cam_info("%s TODO.", __func__);

    misp_load_fw(NULL);
    misp_get_module_info(sensor->board_info->sensor_index,&sensor_id,&modue_id);

    if (sensor_id == 0x278) {
        cdata->data = sensor->board_info->sensor_index;
        if(modue_id == 0x01) {
            strncpy(cdata->cfg.name, sensor_name[0], DEVICE_NAME_SIZE);
        } else if (modue_id == 0x03) {
            strncpy(cdata->cfg.name, sensor_name[1], DEVICE_NAME_SIZE);
        } else if (modue_id == 0x07) {
            strncpy(cdata->cfg.name, sensor_name[2], DEVICE_NAME_SIZE);
        } else {
            strncpy(cdata->cfg.name, sensor_name[3], DEVICE_NAME_SIZE);
        }

        hwsensor_writefile(sensor->board_info->sensor_index, cdata->cfg.name);
    } else {
            cdata->data = SENSOR_INDEX_INVALID;
    }

    cam_info("%s TODO.  cdata->data=%d", __func__, cdata->data);

    return 0;
}
static ssize_t altel6045_test_pipe_store(struct device_driver *drv,
        const char *buf, size_t count)
{
    int ret = 0, test_pipe_id = -1, index = 0;
    u8 in_buf[7], out_buf[53];
    u8 sizeout = 0;
    u16 opcode = 0;
    const char *pos = buf;
    int  extisp_type = EXTISP_NULL;
    u16 sensor_id = 0;
    u8  module_id = 0;

    cam_info("%s enter %s", __func__, buf);
    extisp_type = misp_get_chipid();

    if (0 == strncmp("DBC_Begin", pos, strlen("DBC_Begin")))
    {
        misp_cmd_filter = 1;
        cam_info("%s misp set  DBC mode to on",__func__);
        return count;
    }

    if (0 == strncmp("DBC_End", pos, strlen("DBC_End")))
    {
        misp_cmd_filter = 0;
        cam_info("%s misp set  DBC mode to off",__func__);
        return count;
    }

    /* input:test_pipe=0 test_pipe=1 test_pipe=2 */
    if (0 == strncmp("test_pipe", pos, strlen("test_pipe"))) {
        while (*pos) {
            if (isdigit(*pos))
                break;
            else
                pos++;
        }
    }

    if (*pos == '0' ) {
        test_pipe_id = ALTEK6045_PIPE_0;
    } else if (*pos == '1') {
        test_pipe_id = ALTEK6045_PIPE_1;
    } else if (*pos == '2') {
        test_pipe_id = ALTEK6045_PIPE_DUAL;
    } else if (*pos == '3') {
        test_pipe_id = ALTEK6045_PIPE_3;
    } else if (*pos == '4') {
        test_pipe_id = ALTEK6045_PIPE_4;
        misp_get_module_info(1,&sensor_id,&module_id);
    } else {
        //	test_pipe_id = -1;
        cam_info("%s invalid argument", __func__);
        goto err;
    }

    set_test_result(test_pipe_id, ALTEK6045_PIPE_TESTING);

    /* start test mode */
    memset(in_buf, 0, sizeof(in_buf));
    if (test_pipe_id == ALTEK6045_PIPE_DUAL) {
        in_buf[0] = in_buf[2] = 1;
        in_buf[1] = in_buf[3] = 99;
    } else {
        if(extisp_type == EXTISP_AL6045) {
            in_buf[test_pipe_id * 2] = 1;
            in_buf[test_pipe_id * 2 + 1] = 99;
            sizeout = 33;
        } else {
            in_buf[0] = 1;
            if(test_pipe_id == ALTEK6045_PIPE_0) {
                in_buf[1]=101;
            } else if (test_pipe_id == ALTEK6045_PIPE_3) {
                /*test miniisp with sensor IMX278*/
                in_buf[1]=110;
                cam_info("%s checksum : 110  test miniisp with main sensor IMX278", __func__);
            } else if (test_pipe_id == ALTEK6045_PIPE_4) {
                /*test miniisp with sensor IMX179*/
                if (sensor_id == 0x179) {
                    in_buf[1]=112;
                    cam_info("%s checksum : 112  test miniisp with front sensor IMX179", __func__);
                } else if (sensor_id == 0x8865) {
                    in_buf[1]=113;
                    cam_info("%s checksum : 113  test miniisp with front sensor ov8865", __func__);
                } else {
                    cam_err("%s front sensor id is wrong", __func__);
                    goto err;
                }
            } else {
                in_buf[1]=100;
            }
            sizeout = 53;
        }
    }
    opcode = ISPCMD_CAMERA_SET_SENSORMODE;
    ret = misp_exec_unidir_cmd(opcode, true, false, in_buf, sizeof(in_buf));
    if (ret) {
        set_test_result(test_pipe_id, ALTEK6045_PIPE_TEST_CMD_ERR);
        cam_err("%s set test mode cmd failed ret:%d", __func__, ret);
        goto err;
    }

    msleep(1000);

    /* get test mode */
    opcode = ISPCMD_GET_BULK_CHIPTEST_REPORT;
    memset(out_buf, 0, sizeout);
    ret = misp_exec_unidir_cmd(opcode, false, false, out_buf, sizeout);
    if (ret) {
        set_test_result(test_pipe_id, ALTEK6045_PIPE_GET_CMD_ERR);
        cam_err("%s get test result cmd failed ret:%d", __func__, ret);
        goto err;
    }

    for (index = 0; index < sizeout; index++) {
        if(out_buf[index] != 1) {
            set_test_result(test_pipe_id, ALTEK6045_PIPE_TEST_BAD);
            if ((index >= MIPI_ERR_MIN) && (index <= MIPI_ERR_MAX)) {
                cam_err("%s MIPI RX checksum failed, out_buf index:%d, value:%d", __func__, index,out_buf[index]);
            } else {
                cam_err("%s ISP internal checksum failed, out_buf index:%d, value:%d", __func__, index,out_buf[index]);
            }
            goto err;
        }
    }
    set_test_result(test_pipe_id, ALTEK6045_PIPE_TEST_DONE);

err:
    msleep(100);
    return count;
}