MTK Camera(OV13850) 驅動移植
一、驅動原始碼包結構
拿到的驅動原始碼包解壓後得到hal和kernel兩個目錄檔案,原始碼目錄結構如下所示
13850-6592-driver-10-28.7z
|--hal
| |--camera_AE_PLineTable_ov13850mipiraw.h
| |--camera_calibration_cam_cal.cpp
| |--camera_flicker_para_ov13850mipiraw.cpp
| |--camera_info_ov13850mipiraw.h
| |--camera_isp_lsc_ov13850mipiraw.h
| |--camera_isp_pca_ov13850mipiraw.h
| |--camera_isp_regs_ov13850mipiraw.h
| |--camera_tsf_data_ov13850mipiraw.h
| |--camera_tsf_para_ov13850mipiraw.h
| |--camera_tuning_para_ov13850mipiraw.cpp
| |--config.ftbl.ov13850_mipi_raw.h
|--kernel
| |--ov13850mipiraw_Camera_Sensor_para.h
| |--ov13850mipiraw_CameraCustomized.h
| |--ov13850mipiraw_Sensor.c
| |--ov13850mipiraw_Sensor.h
二、ov13850驅動移植記錄
1、kernelSensor:
- 在mediatek\custom\common\kernel\imgsensor\目錄下增加ov13850_mipi_raw資料夾,把驅動原始碼kernel目錄中所有檔案copy進來。
- 修改mediatek\custom\common\kernel\imgsensor\inc\kd_imgsensor.h檔案,增加ov13850 SENSOR_ID和SENSOR_DRVNAME定義
- #define OV13850_SENSOR_ID 0xD850
- #define SENSOR_DRVNAME_OV13850_MIPI_RAW "ov13850mipiraw"
- 修改mediatek\custom\common\kernel\imgsensor\src\kd_sensorlist.h
增加OV13850_MIPI_RAW_SensorInit函式宣告
- UINT32 OV13850_MIPI_RAW_SensorInit(PSENSOR_FUNCTION_STRUCT *pfFunc);
在kdSensorList陣列中增加OV13850配置
- ACDK_KD_SENSOR_INIT_FUNCTION_STRUCT kdSensorList[MAX_NUM_OF_SUPPORT_SENSOR+1] =
- {
- ...
- #if defined(OV13850_MIPI_RAW)
- {OV13850_SENSOR_ID, SENSOR_DRVNAME_OV13850_MIPI_RAW, OV13850_MIPI_RAW_SensorInit},
- #endif
- ...
- }
- 在mediatek\custom\wind92_wet_tdd\kernel\camera\camera\kd_camera_hw.c裡,增加對OV13850的供電配置,參考OV12830和datasheet。由於OV12830和OV13850供電配置一樣,所以copy12830,更改下名字即可。
- int kdCISModulePowerOn(CAMERA_DUAL_CAMERA_SENSOR_ENUM SensorIdx, char *currSensorName, BOOL On, char* mode_name)
- {
- //...
- elseif (currSensorName && (0 == strcmp(SENSOR_DRVNAME_OV13850_MIPI_RAW,currSensorName)))
- {
- printk("MYCAT kdCISModulePowerOn SENSOR_DRVNAME_OV13850_MIPI_RAW \n");
- printk("MYCAT OV13850_RAW idx:%d \n",SensorIdx);
- #ifdef __MAINSENSOR_USE_LDO_1_2V__
- if (mt_set_gpio_pull_enable(CAMERA_POWER_VCAM_D_LDO_PIN, GPIO_PULL_DISABLE)) {PK_DBG("[CAMERA SENSOR] CAMERA_POWER_VCAM_D_LDO_PIN pull failed! \n"); }
- if (mt_set_gpio_mode(CAMERA_POWER_VCAM_D_LDO_PIN, GPIO_MODE_00)){PK_DBG("[CAMERA SENSOR] CAMERA_POWER_VCAM_D_LDO_PIN mode failed! \n");}
- if (mt_set_gpio_dir(CAMERA_POWER_VCAM_D_LDO_PIN,GPIO_DIR_OUT)) {PK_DBG("[CAMERA SENSOR] CAMERA_POWER_VCAM_D_LDO_PIN dir failed! \n");}
- if (mt_set_gpio_out(CAMERA_POWER_VCAM_D_LDO_PIN,GPIO_OUT_ONE)) {PK_DBG("[CAMERA SENSOR] CAMERA_POWER_VCAM_D_LDO_PIN out failed! \n");}
- #else
- // printk("MYCAT S5KH2_RAW POWER ON LDO D\n");
- if (TRUE != hwPowerOn(CAMERA_POWER_VCAM_D, VOL_1200,mode_name))
- {
- PK_DBG("[CAMERA SENSOR] Fail to enable digital power\n");
- //return -EIO;
- goto _kdCISModulePowerOn_exit_;
- }
- #endif
- //printk("MYCAT S5KH2_RAW POWER ON LDO A\n");
- if (TRUE != hwPowerOn(CAMERA_POWER_VCAM_A, VOL_2800,mode_name))
- {
- <span style="white-space:pre"> </span> PK_DBG("[CAMERA SENSOR] Fail to enable analog power\n");
- //return -EIO;
- goto _kdCISModulePowerOn_exit_;
- }
- //printk("MYCAT S5KH2_RAW POWER ON LDO D2\n");
- if (TRUE != hwPowerOn(CAMERA_POWER_VCAM_D2, VOL_1800,mode_name))
- {
- PK_DBG("[CAMERA SENSOR] Fail to enable digital power\n");
- //return -EIO;
- goto _kdCISModulePowerOn_exit_;
- }
- //printk("MYCAT S5KH2_RAW POWER ON LDO A2\n");
- if (TRUE != hwPowerOn(CAMERA_POWER_VCAM_A2, VOL_2800,mode_name))
- {
- PK_DBG("[CAMERA SENSOR] Fail to enable analog power\n");
- //return -EIO;
- goto _kdCISModulePowerOn_exit_;
- }
- msleep(5);
- //disable inactive sensor
- if (pinSetIdx == 0 || pinSetIdx == 2)
- {//disable sub
- <span style="white-space:pre"> </span>if (GPIO_CAMERA_INVALID != pinSet[1][IDX_PS_CMRST])
- {
- if (mt_set_gpio_mode(pinSet[1][IDX_PS_CMRST],pinSet[1][IDX_PS_CMRST+IDX_PS_MODE])){PK_DBG("[CAMERA SENSOR] set gpio mode failed!! \n");}
- if (mt_set_gpio_mode(pinSet[1][IDX_PS_CMPDN],pinSet[1][IDX_PS_CMPDN+IDX_PS_MODE])){PK_DBG("[CAMERA LENS] set gpio mode failed!! \n");}
- if (mt_set_gpio_dir(pinSet[1][IDX_PS_CMRST],GPIO_DIR_OUT)){PK_DBG("[CAMERA SENSOR] set gpio dir failed!! \n");}
- if (mt_set_gpio_dir(pinSet[1][IDX_PS_CMPDN],GPIO_DIR_OUT)){PK_DBG("[CAMERA LENS] set gpio dir failed!! \n");}
- if (mt_set_gpio_out(pinSet[1][IDX_PS_CMRST],pinSet[1][IDX_PS_CMRST+IDX_PS_OFF])){PK_DBG("[CAMERA SENSOR] set gpio failed!! \n");} //low == reset sensor
- if (mt_set_gpio_out(pinSet[1][IDX_PS_CMPDN],pinSet[1][IDX_PS_CMPDN+IDX_PS_OFF])){PK_DBG("[CAMERA LENS] set gpio failed!! \n");} //high == power down lens module
- }
- }
- else
- {
- if (GPIO_CAMERA_INVALID != pinSet[0][IDX_PS_CMRST])
- {
- if (mt_set_gpio_mode(pinSet[0][IDX_PS_CMRST],pinSet[0][IDX_PS_CMRST+IDX_PS_MODE])){PK_DBG("[CAMERA SENSOR] set gpio mode failed!! \n");}
- if (mt_set_gpio_mode(pinSet[0][IDX_PS_CMPDN],pinSet[0][IDX_PS_CMPDN+IDX_PS_MODE])){PK_DBG("[CAMERA LENS] set gpio mode failed!! \n");}
- if (mt_set_gpio_dir(pinSet[0][IDX_PS_CMRST],GPIO_DIR_OUT)){PK_DBG("[CAMERA SENSOR] set gpio dir failed!! \n");}
- if (mt_set_gpio_dir(pinSet[0][IDX_PS_CMPDN],GPIO_DIR_OUT)){PK_DBG("[CAMERA LENS] set gpio dir failed!! \n");}
- if (mt_set_gpio_out(pinSet[0][IDX_PS_CMRST],pinSet[0][IDX_PS_CMRST+IDX_PS_OFF])){PK_DBG("[CAMERA SENSOR] set gpio failed!! \n");} //low == reset sensor
- if (mt_set_gpio_out(pinSet[0][IDX_PS_CMPDN],pinSet[0][IDX_PS_CMPDN+IDX_PS_OFF])){PK_DBG("[CAMERA LENS] set gpio failed!! \n");} //high == power down lens module
- }
- if (GPIO_CAMERA_INVALID != pinSet[2][IDX_PS_CMRST])
- {
- }
- }
- //PDN/STBY pin
- if (GPIO_CAMERA_INVALID != pinSet[pinSetIdx][IDX_PS_CMRST])
- {
- if (mt_set_gpio_mode(pinSet[pinSetIdx][IDX_PS_CMRST],pinSet[pinSetIdx][IDX_PS_CMRST+IDX_PS_MODE])){PK_DBG("[CAMERA SENSOR] set gpio mode failed!! \n");}
- if (mt_set_gpio_dir(pinSet[pinSetIdx][IDX_PS_CMRST],GPIO_DIR_OUT)){PK_DBG("[CAMERA SENSOR] set gpio dir failed!! \n");}
- if (mt_set_gpio_out(pinSet[pinSetIdx][IDX_PS_CMRST],pinSet[pinSetIdx][IDX_PS_CMRST+IDX_PS_OFF])){PK_DBG("[CAMERA SENSOR] set gpio failed!! \n");}
- //PDN pin
- if (mt_set_gpio_mode(pinSet[pinSetIdx][IDX_PS_CMPDN],pinSet[pinSetIdx][IDX_PS_CMPDN+IDX_PS_MODE])){PK_DBG("[CAMERA LENS] set gpio mode failed!! \n");}
- if (mt_set_gpio_dir(pinSet[pinSetIdx][IDX_PS_CMPDN],GPIO_DIR_OUT)){PK_DBG("[CAMERA LENS] set gpio dir failed!! \n");}
- if (mt_set_gpio_out(pinSet[pinSetIdx][IDX_PS_CMPDN],pinSet[pinSetIdx][IDX_PS_CMPDN+IDX_PS_OFF])){PK_DBG("[CAMERA LENS] set gpio failed!! \n");}
- msleep(1);
- if (mt_set_gpio_out(pinSet[pinSetIdx][IDX_PS_CMPDN],pinSet[pinSetIdx][IDX_PS_CMPDN+IDX_PS_ON])){PK_DBG("[CAMERA LENS] set gpio failed!! \n");}
- msleep(1);
- if (mt_set_gpio_out(pinSet[pinSetIdx][IDX_PS_CMRST],pinSet[pinSetIdx][IDX_PS_CMRST+IDX_PS_ON])){PK_DBG("[CAMERA SENSOR] set gpio failed!! \n");}
- msleep(1);
- printk("OV13850 PWN RST\n");
- }
- }
- //...
Lens:
- 在mediatek\custom\common\kernel\lens\目錄下參照ov12830af,增加ov13850af 目錄和驅動原始碼OV13850AF.c。
-
mediatek\custom\common\kernel\lens\inc\目錄下參照ov12830af,增加ov13850af目錄和OV13850AF.h標頭檔案
Sensor:
- 在mediatek\custom\mt6592\hal\imgsensor\目錄下增加ov13850_mipi_raw資料夾,將OV13850驅動原始碼包中的hal下檔案,copy到該資料夾下。
- 修改mediatek\custom\common\hal\imgsensor\src\sensorlist.cpp增加OV13850的SensorList描述項。
- MSDK_SENSOR_INIT_FUNCTION_STRUCT SensorList[] =
- {
- ...
- #if defined(OV13850_MIPI_RAW)
- RAW_INFO(OV13850_SENSOR_ID, SENSOR_DRVNAME_OV13850_MIPI_RAW,NULL),
- #endif
- ...
- }
Lens:
- 在mediatek\custom\common\hal\lens\下,增加ov13850af目錄,參照ov12830增加lens_para_OV13850AF.cpp
- 修改mediatek\custom\out\wind92_wet_tdd\hal\lens\src\Lenslist.cpp在LensList陣列項裡增加OV13850AF描述項。
MSDK_LENS_INIT_FUNCTION_STRUCT LensList[MAX_NUM_OF_SUPPORT_LENS] =
- #if defined(OV13850AF)
- extern PFUNC_GETLENSDEFAULT pOV13850AF_getDefaultData;
- #endif
- {
- ...
- #if defined(OV13850AF)
- {OV13850_SENSOR_ID, OV13850AF_LENS_ID, "OV13850AF", pOV13850AF_getDefaultData},
- #endif
- ...
- }
- 修改camera_custom_lens.h,增加OV13850_LENS_ID,這裡根據序號累加。
- #define OV13850AF_LENS_ID 0x0008
3、修改ProductConfig.mk
4、最後要修改init.rc 更改OV13850AF裝置檔案的許可權,否則在open的時候會失敗。
- CUSTOM_HAL_IMGSENSOR= ov13850_mipi_raw ov5648_mipi_raw
- CUSTOM_HAL_LENS= ov13850af dummy_lens
- CUSTOM_HAL_MAIN_IMGSENSOR= ov13850_mipi_raw
- CUSTOM_HAL_MAIN_LENS= ov13850af
- CUSTOM_KERNEL_IMGSENSOR= ov13850_mipi_raw ov5648_mipi_raw
- CUSTOM_KERNEL_LENS= ov13850af dummy_lens
- CUSTOM_KERNEL_MAIN_IMGSENSOR= ov13850_mipi_raw
- CUSTOM_KERNEL_MAIN_LENS= ov13850af