|
《CameraAF分析》3 s) t+ b2 |: n. x" |' q& L
一、AFkernel代码分析:& q0 R; k+ q- I7 M+ @1 o& a8 C8 M
涉及文件主要有:
1 ?7 D5 Y5 ^' s: E3 ^+ E( Zmediatek/config/mt6592/init.rc9 B4 D4 t( n- V* u$ A
mediatek/config/huaqin92_wet_b2a_tdd/at808p/ProjectConfig.mk
- C/ f; o8 u# emediatek/platform/mt6592/kernel/core/mt_devs.c5 U/ S- I3 }+ O1 `! i0 O
mediatek /custom/huaqin_bsp/at808p/base/kernel/lens/ov8865af/OV8865AF.c
& X+ ]( B4 t! T2 emediatek/custom/common/kernel/lens/inc/OV8865AF.h
( p1 S+ f+ m V( K3 ]% [0 G
$ C! w1 i& p6 A. v# j' g) Ta) mediatek/config/mt6592/init.rc6 X5 ?$ ]0 L) q6 F9 t
作用是来修改文件的权限和将该文件的拥有者改为system用户,添加如下部分:; A1 P" s& R W: `' A
+ ^% e% p s& ?. c$ |: A
[cpp] view plaincopyprint?0 a0 d1 k9 W7 F* h
# U$ I7 _5 o' G- W- j; S7 I4 h- K$ h
* D$ ^/ K0 v o1 D/ c
- chmod 0660 /dev/OV8865AF
- chown system camera /dev/OV8865AF
3 O1 W" u+ ^5 J+ t# ]# R
6 ~& { |; e, | ?
1 C0 R5 [1 w- a; U2 W3 N. o# I
2 T% p" ? Y( l+ M# @
5 {% ?" D/ ]2 C$ g6 ?! cb) mediatek/config/huaqin92_wet_b2a_tdd/at808p/ProjectConfig.mk( Z0 Y) o X7 L+ c
修改部分如下图:. X7 k* r: h. l9 U8 u
见附件11图片3 h$ R5 }% c" \1 k: T: i7 |" z! l
; @/ s) I5 t- ?! [
c) mediatek/platform/mt6592/kernel/core/mt_devs.c
* M9 p% P6 r! Q7 O* ]这个文件时用来注册平台设备的。 |8 {3 V6 i, c# s7 |3 V% ^
在mt_board_init函数中添加
0 U2 q& t- a+ e3 l) O3 O$ d, a! c4 ^3 Q/ D: i* g1 [
[cpp] view plaincopyprint?' b$ K9 [/ O8 O' t7 B
( ?9 v; X; ~, ?" O$ c) M# l1 l+ i0 g r& n+ `& }8 d, _( E
- 2197 #if 1 //defined(CONFIG_ACTUATOR)
- 2198 retval = platform_device_register(&actuator_dev);
- 2199 if (retval != 0){
- 2200 return retval;
- 2201 }
- 2202 retval = platform_device_register(&actuator_dev1);
- 2203 if (retval != 0){
- 2204 return retval;
- 2205 }
- 2206 #endif
2 k: R3 W# m! T8 o; [8 H* I3 u. W% F: _: [, J- d
6 s' s# ~% i* @0 v; d+ ]- T3 ?
2 W6 Q5 v8 b4 l% W1 `8 E" e& n# n$ K" S3 E d4 G1 n
V% z4 j K3 G6 G6 b
[cpp] view plaincopyprint?. l8 h; f. E* Y" A
* V, I6 N+ I1 I( C4 P' ]$ w+ t
- 1533 staticstruct platform_device actuator_dev1 = {
- 1534 .name = "lens_actuator1",
- 1535 .id = -1,
- 1536 };
! C( u1 }# C8 u) p# S7 L
( c, T+ s4 r1 S* D) x1 v
" Y# X7 w5 O& q+ |9 P0 M* @7 V, [5 j }; q S" n$ |1 H4 G
8 e/ C; L! X1 k; c; Z L5 h4 h: h! ~8 N- ^8 ]# `5 m, ^1 s0 R2 K
其中name “lens_actuator1”是用来和我们驱动文件中的name进行匹配的。
: a; }+ g, F V( l7 C$ O, ~d) mediatek/custom/huaqin_bsp/at808p/base/kernel/lens/ov8865af/OV8865AF.c
2 k% [2 o6 i' y) y% d; z重要说道驱动文件了,这个文件的头文件是:
" `! l9 d& P3 u8 z# bmediatek/custom/common/kernel/lens/inc/OV8865AF.h
# p' E v3 h. F$ `主要完成一下任务:9 @7 \2 `, E) l4 `9 p
1. module_init(OV8865AF_i2C_init);——启动方式,也就是开机启动kernel后一段加载;! f$ I f' C6 {) K+ C
2. i2c_register_board_info(LENS_I2C_BUSNUM,&kd_lens_dev, 1);;——挂载到I2C总线上;. @1 ~# g' }4 C: G, U' y0 f
3. platform_driver_register(&g_stOV8865AF_Driver);——注册平台驱动;1 A# ?. Y. A; s9 U
8 C) T. i" F' d4 l+ P P[cpp] view plaincopyprint?
9 t- l2 u1 L. _9 J* f, R) L. i+ B' s+ u
3 y' m2 f, X: F3 ~2 O
- 491 static structplatform_driver g_stOV8865AF_Driver = {
- 492 .probe = OV8865AF_probe,
- 493 .remove = OV8865AF_remove,
- 494 .suspend = OV8865AF_suspend,
- 495 .resume = OV8865AF_resume,
- 496 .driver = {
- 497 .name = "lens_actuator1",
- 498 .owner = THIS_MODULE,
- 499 }
- 500 }; % P& i; `7 o) l0 Y% d
; u1 R% O M! b8 T8 ]3 U9 h A; J' W& f* v
5 h$ j2 V/ [8 R% P
$ N* ^1 b; [% S
9 V `) C$ i- z5 \4 i+ ]0 y0 M4. 然后进入OV8865AF_probe,加载i2c驱动:
; w* F& k% e! L1 j% X
% v$ `2 k% r* c4 h$ l[cpp] view plaincopyprint?: r: Y* x+ x, G G7 q9 D
+ c" Y N9 `" Y6 u
" v/ H9 d. {9 b) `
- 469 static intOV8865AF_probe(struct platform_device *pdev)
- 470 {
- 471 returni2c_add_driver(&OV8865AF_i2c_driver);
- 472 }
- 423 struct i2c_driver OV8865AF_i2c_driver= {
- 424 .probe = OV8865AF_i2c_probe,
- 425 .remove = OV8865AF_i2c_remove,
- 426 .driver.name = OV8865AF_DRVNAME,
- 427 .id_table = OV8865AF_i2c_id,
- 428 }; 4 T ]. H( F- |' {
/ ?* _/ i# L0 G- y, X9 C* |) K
8 P: N, n' A( K' R5 U7 z7 h/ P- f' a }6 A5 _% [1 U: v* w
& E/ K2 }5 x2 S; ?& p$ r* Y+ @6 G
! x7 }4 Z) _. o1 g( y( ` C5. 再就是OV8865AF_i2c_probe,就是注册字符驱动,以此就连接到我们的&g_stOV8865AF_fops,给上层提供Ioctl接口;
P& u5 L6 n9 r$ k! y1 ]$ o
( ^* `' s9 Y. H* q6 g, o, k# c3 {1 O/ h, \7 m: T
二、AFHAL层分析:( J9 ]" V! s$ p7 o( J* J7 F3 I B
HAL层涉及的文件:
) g. D1 ]6 e; _; Ymediatek/custom/common/hal/inc/camera_custom_lens.h+ D3 f) p+ e0 z4 d/ e* [
mediatek/custom/huaqin92_wet_b2a_tdd/hal/lens/src/lenslist.cpp
: D' z5 D. ]* a9 Cmediatek/custom/huaqin_bsp/at808p/base/hal/lens/ov8865af/lens_para_OV8865AF.cpp
5 s3 e4 V' ?5 X! L$ R
9 s( z2 I4 r. sa) mediatek/custom/huaqin92_wet_b2a_tdd/hal/lens/src/lenslist.cpp
# l) ~* j8 n5 ^/ o6 M$ {1 k: e添加LensList:+ q( Z8 I+ ~( w* B) G$ A0 h
3 f: B/ ]/ X" Q$ D1 s" N1 y[cpp] view plaincopyprint?0 W% |7 k6 @+ ?, m. S+ h/ m
. `* _9 g8 n# m* {1 `% U9 O7 a. n2 W
0 ~" @' ~: L& h& {" s h( @
- 70 #if defined(OV8865AF)
- 71{OV8865_SENSOR_ID, OV8865AF_LENS_ID,"OV8865AF", pOV8865AF_getDefaultData},
- 72 #endif
2 U" T! _" |. l5 i2 q1 y. t- w; B0 U! P6 Z5 \
$ |7 H; _4 A& J- u
5 C6 w' K9 F, R" }8 [, ?0 R6 POV8865AF_LENS_ID 在camera_custom_lens.h加以定义,
9 B" J6 X, u8 [! H, |% s) j7 V
$ K1 |8 X# L# [[cpp] view plaincopyprint?9 O4 O' u) A& K- c% |8 c
. u; h! n* q1 i; L* u
7 h( j$ O! D, q. h" g9 n; L- 如:#define OV8865AF_LENS_ID 0x0009 7 Y9 R& d. D1 k" v: P* b1 |6 b
: \: z5 P" U- @" D4 }6 T
" b/ P* g5 _' L. X- L7 F. m/ Y7 o* n5 w( o9 U5 t6 W0 s& A( m
OV8865_SENSOR_ID 是kernel层定义的:
, N) Z" _9 i5 t/ i, Cmediatek/custom/common /kernel/imgsensor/inc/kd_imgsensor.h* {# L$ u9 s4 f) B0 S, [
是跟我们的camera驱动进行匹配的。% e. {2 \8 L% p) C2 [6 n+ T, |
pOV8865AF_getDefaultData是在lens_para_OV8865AF.cpp中完成的。" W' @( ]; H6 d6 q5 p
% v( T" u+ Q0 f0 @
! ^0 O% e% P; B0 a$ B1 X |
|