|
一、驱动源码包结构OV13850摄像头在MTK6592平台,驱动移植方法,拿到的驱动源码包解压后得到hal和kernel两个目录文件,源码目录结构如下所示:
3 N) H4 \ W! T, q) m6 h6 k4 s2 n9 G13850-6592-driver-10-28.7z
+ R/ }, |- s& `& h) ||--hal
' G8 W7 C+ C! J4 X" b9 }$ x| |--camera_AE_PLineTable_ov13850mipiraw.h9 N: k0 H* I% _1 Z8 P
| |--camera_calibration_cam_cal.cpp
5 P5 R( V: O2 V5 N| |--camera_flicker_para_ov13850mipiraw.cpp% J8 X, A* q) Y( D) \+ D
| |--camera_info_ov13850mipiraw.h$ F' o: V6 a! T: E% i! L
| |--camera_isp_lsc_ov13850mipiraw.h5 G2 j* W" ?, A1 {
| |--camera_isp_pca_ov13850mipiraw.h( t5 ]" v2 m: ]' {- h' Q
| |--camera_isp_regs_ov13850mipiraw.h
+ W8 P' W& k& B0 I8 W| |--camera_tsf_data_ov13850mipiraw.h7 I# \' v* H6 D0 G8 Q: m
| |--camera_tsf_para_ov13850mipiraw.h/ _+ ]8 v3 A/ v/ W
| |--camera_tuning_para_ov13850mipiraw.cpp
0 @5 ^1 v' D$ ?) [, M. f| |--config.ftbl.ov13850_mipi_raw.h
9 K1 G8 q4 a' v" l|--kernel8 q$ z/ e, T7 \5 C5 I' h
| |--ov13850mipiraw_Camera_Sensor_para.h
) L) v4 R5 _4 F4 `1 E| |--ov13850mipiraw_CameraCustomized.h5 O9 q @ X, g0 E7 }( @
| |--ov13850mipiraw_Sensor.c0 D1 @+ V7 T! \: c
| |--ov13850mipiraw_Sensor.h
4 E. W* z- f' ^
$ \ E/ d# H3 o3 j$ V( |( T 1 h) B5 K1 N. O# Q- B
二、ov13850驱动移植记录; r. t: q s- \
1、kernel
2 }# N; s" }: D- l$ D3 [) |Sensor:
: h( E+ S2 K: l8 M0 C1 r4 j- 在mediatek\custom\common\kernel\imgsensor\目录下增加ov13850_mipi_raw文件夹,把驱动源码kernel目录中所有文件copy进来。
- 修改mediatek\custom\common\kernel\imgsensor\inc\kd_imgsensor.h文件,增加ov13850 SENSOR_ID和SENSOR_DRVNAME定义
" Q# ~. }" H+ _7 ~) }3 q
! t$ I9 V9 Q7 T/ O W0 F
+ K8 U5 c( g! O9 _/ }) Y. q
- #define OV13850_SENSOR_ID 0xD850
- #define SENSOR_DRVNAME_OV13850_MIPI_RAW "ov13850mipiraw" 5 n& q4 v% T" ]' D# G. H0 }/ x8 i8 P
1 z6 J! a# ?- G6 P) r
4 H$ ^9 M: p" m8 m+ Q+ O _ e: E, ~1 n0 N% Q/ r
- 修改mediatek\custom\common\kernel\imgsensor\src\kd_sensorlist.h. q/ i( G$ u" n( z, f; k- w' x4 W) M
1 L* T9 k- ?& x3 o1 G: O% |
6 D1 O7 F( d: t0 B( T* q
增加OV13850_MIPI_RAW_SensorInit函数声明5 W1 m: T$ \. \0 Z
' L$ j! v' y, A) ]
- UINT32 OV13850_MIPI_RAW_SensorInit(PSENSOR_FUNCTION_STRUCT *pfFunc); % N; J+ }" J! r
2 Q5 H/ i7 m( J6 {; R
9 ?, i7 @4 Y# c$ }
在kdSensorList数组中增加OV13850配置
' a. q5 T) Q3 i+ L
: b) s, J8 Z& U6 g
% n) p$ f- J8 L# Q$ j- 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
- ...
- }
8 O2 A" {- e; z
( n( j4 g. R/ A. Q2 _# A' {3 q* G* k/ y
- 在mediatek\custom\wind92_wet_tdd\kernel\camera\camera\kd_camera_hw.c里,增加对OV13850的供电配置,参考OV12830和datasheet。由于OV12830和OV13850供电配置一样,所以copy12830,更改下名字即可。! D1 g+ n. P# ^4 I7 o
8 O G& }8 g- M! ?3 o5 ^. R1 A+ O4 D9 q Z X
- int kdCISModulePowerOn(CAMERA_DUAL_CAMERA_SENSOR_ENUM SensorIdx, char *currSensorName, BOOL On, char* mode_name)
- {
- //...
- else if (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");
- }
- }
- //... 9 h. ]8 T2 J" m2 `9 v- J& z4 E
* M% N4 e H5 A/ d
4 \+ G' z1 x/ o. P# Y( U
9 l, d, Y% T% d9 J
Lens: 6 g, H8 Y) C K
- 在mediatek\custom\common\kernel\lens\目录下参照ov12830af,增加ov13850af 目录和驱动源码OV13850AF.c。
- mediatek\custom\common\kernel\lens\inc\目录下参照ov12830af,增加ov13850af目录和OV13850AF.h头文件
# v0 a; k! L: C' @# A) D* Y4 H* R& c1 ^- p, s
4 K4 p( C6 ~' B# h5 b) @ 2、HAL
- {: d- |9 D* n+ XSensor:
- {$ x- y. g5 q: \- \- J- 在mediatek\custom\mt6592\hal\imgsensor\目录下增加ov13850_mipi_raw文件夹,将OV13850驱动源码包中的hal下文件,copy到该文件夹下。
- 修改mediatek\custom\common\hal\imgsensor\src\sensorlist.cpp增加OV13850的SensorList描述项。7 J+ H0 w, _3 }2 r: h
; }( R2 v+ E1 E( X" _$ ]
. x9 }/ S- L# D1 p* a" R7 T- MSDK_SENSOR_INIT_FUNCTION_STRUCT SensorList[] =
- {
- ...
- #if defined(OV13850_MIPI_RAW)
- RAW_INFO(OV13850_SENSOR_ID, SENSOR_DRVNAME_OV13850_MIPI_RAW,NULL),
- #endif
- ...
- }
4 w1 f5 w0 B+ @( X
7 f( H( {" ], t7 R1 f% G7 Z, w$ @( w
Lens: 5 C7 c5 T! m" q ~0 W0 ^
- 在mediatek\custom\common\hal\lens\下,增加ov13850af目录,参照ov12830增加lens_para_OV13850AF.cpp
- 修改mediatek\custom\out\wind92_wet_tdd\hal\lens\src\Lenslist.cpp在LensList数组项里增加OV13850AF描述项。- M: X9 z5 E2 X/ U7 I6 l! o1 J
. H1 v6 q& v) ]8 A7 N" U
7 r# |) R6 s. {- u! a! v
X4 ~' E8 f8 [' s' l- #if defined(OV13850AF)
- extern PFUNC_GETLENSDEFAULT pOV13850AF_getDefaultData;
- #endif
! i ~# F4 _: x3 M, w! L: J 0 Q5 M- w8 [, k8 Y! x$ A0 s1 d
MSDK_LENS_INIT_FUNCTION_STRUCT LensList[MAX_NUM_OF_SUPPORT_LENS] =
y6 f( W# g) U. s7 x" i* F# ?" H8 ]. G. r0 M- f# E* K1 Z
- {
- ...
- #if defined(OV13850AF)
- {OV13850_SENSOR_ID, OV13850AF_LENS_ID, "OV13850AF", pOV13850AF_getDefaultData},
- #endif
- ...
- }
, i8 u3 m( m# j: D( q7 E ^5 S + c' t7 {% n$ |
- 修改camera_custom_lens.h,增加OV13850_LENS_ID,这里根据序号累加。
$ q4 w: }5 {+ e7 ~ I) R
; R+ n, ? X P9 E4 ]4 o
, [9 R) H5 }4 X* i8 J. b r' V+ G5 D. q; k; [
- #define OV13850AF_LENS_ID 0x0008
# S0 U0 H2 t: }# \' H6 H0 ]! } 0 }# G3 U: n1 E' `$ ?1 i
3、修改ProductConfig.mk % z |- ]8 D9 X" F
- 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
4 C9 t3 U* H( j
- F6 P8 p* @, w- ?. J5 s) C$ v3 H4 j! y, A- |
4、最后要修改init.rc 更改OV13850AF设备文件的权限,否则在open的时候会失败。% Y3 |# L& U/ n# x7 {! W
|
|