Android Camera Driver平台(展讯、MTK)移植适配经验

Android Camera Driver平台(展讯、MTK)移植适配经验

记录在展讯9820,MTK6739平台配置Camera驱动的经验

展讯平台

1.项目对应kernel/dts文件配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
&i2c0 {
status = "okay";
clock-frequency = <400000>;

sensor_main: sensor-main@3c {
compatible = "sprd,sensor-main";
reg = <0x3c>;
clock-names = "clk_src", "sensor_eb",
"clk_96m", "clk_76m8",
"clk_48m", "clk_26m";
clocks = <&clk_sensor0>,
<&clk_mm_ckg_gates 1>,
<&clk_twpll_96m>,
<&clk_twpll_76m8>,
<&clk_twpll_48m>,
<&ext_26m>;
vddio-supply = <&vddcamio>;
vddcama-supply = <&vddcama>;
vddcamd-supply = <&vddcamd>;
vddcammot-supply = <&vddcammot>;
reset-gpios = <&ap_gpio 37 0>;
power-down-gpios = <&ap_gpio 39 0>;
host = "dcam0";
port {
sensor_main_0: endpoint {
remote-endpoint = <&phy0_out>;
};
};
};

};

(1).compatible = “sprd,sensor-main”, 这里不需要配摄像头的I2C Device Address,
alps/kernel/drivers/misc/sprd_camera/sensor/sprd_sensor_drv.c 会读取这里的id进行处理
具体的I2C地址在sensor驱动中配置

(2).reset-gpios,power-down-gpios可通过查看机器板子的原理图来确定对应gpio的引脚修改

2.项目对应device/../../BoardConfig.mk配置

(1).配上前后置摄像头对应Camera Sensor的型号,如:
CAMERA_SENSOR_TYPE_BACK := “sp2509 c2590”
CAMERA_SENSOR_TYPE_FRONT := “gc030a”

(2).若模组厂打样时摄像头拍照方向为横屏,则TARGET_BOARD_BACK_CAMERA_ROTATION/TARGET_BOARD_FRONT_CAMERA_ROTATION设置为false,否则设置为true。

(3).配置Camera支持的分辨率

1
2
3
#select camera 2M,3M,5M,8M,13M,16M,21M
CAMERA_SUPPORT_SIZE := 2M
FRONT_CAMERA_SUPPORT_SIZE := 2M

3.vendor/sprd/../../libcamera配置和添加Camera驱动代码

(1).在vendor/sprd/../../libcamera/sensor下放置已经适配了平台的sensor_drv代码,
如果没有已经适配了平台的驱动代码,那只能按平台已有的驱动代码为模板按硬件文档进行适配修改。
注意修改时尽量按平台已有的camera驱动代码为规范。这方面可以自己修改也可以找FAE帮忙。

(2).修改vendor/sprd/../../libcamera/sensorsensor_cfg.c,配置新Camera

1
2
3
4
5
6
7
8
#ifdef OV8856
extern SENSOR_INFO_T g_ov8856_mipi_raw_info;
#endif

在对应的sensor_infor_tab添加配置,分别是camera module name/camera name/sensor info/af/otp:
#ifdef OV8856
{MODULE_SUNNY, "ov8856", &g_ov8856_mipi_raw_info, {&dw9763a_drv_entry, 0}, &ov8856_cmk_drv_entry},
#endif

MTK平台

1.kernel-4.4/drivers/misc/mediatek/imgsensor/inc/kd_imgsensor.h配置

1
2
3
#define S5K4H8_SENSOR_ID                        0x4088

#define SENSOR_DRVNAME_S5K4H8_MIPI_RAW "s5k4h8_mipi_raw"

2.项目对应kernel-4.4/arch/arm/configs/…/xxx_defconfig配置

可通过查看device目录下项目mk文件里 KERNEL_DEFCONFIG 指向的是哪个config文件
CONFIG_CUSTOM_KERNEL_IMGSENSOR=”s5k4h8_mipi_raw”

带debug标签的用于编译过程中查看调试信息

3.项目对应ProjectConfig.mk配置

1
2
3
4
CUSTOM_HAL_IMGSENSOR = s5k4h8_mipi_raw
CUSTOM_HAL_MAIN_IMGSENSOR = s5k4h8_mipi_raw
CUSTOM_KERNEL_IMGSENSOR = s5k4h8_mipi_raw
CUSTOM_KERNEL_MAIN_IMGSENSOR = s5k4h8_mipi_raw

4.kernel-4.4/drivers/misc/mediatek/imgsensor/src/xxx/xxx/imgsensor_sensor_list.c添加

1
2
3
#if defined(S5K4H8_MIPI_RAW)
{S5K4H8_SENSOR_ID, SENSOR_DRVNAME_S5K4H8_MIPI_RAW, S5K4H8_MIPI_RAW_SensorInit},
#endif

5.kernel-4.4/drivers/misc/mediatek/imgsensor/src/xxx/xxx/imgsensor_sensor_list.h添加

1
UINT32 S5K4H8_MIPI_RAW_SensorInit(PSENSOR_FUNCTION_STRUCT *pfFunc);

6.kernel-4.4/drivers/misc/mediatek/imgsensor/src/xxx/xxx 配置和添加Camera sensor驱动代码

7.kernel-4.4/drivers/misc/mediatek/imgsensor/src/xxx/xxx/imgsensor_cfg_table.c 配置上下电时序

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#if defined(S5K4H8_MIPI_RAW)
{
SENSOR_DRVNAME_S5K4H8_MIPI_RAW,
{
{SensorMCLK, Vol_High, 0},
{PDN, Vol_Low, 5},
{RST, Vol_Low, 5},
{DVDD, Vol_1200, 0},
{AVDD, Vol_2800, 0},
{DOVDD, Vol_1800, 5},
{AFVDD, Vol_2800, 0},
{PDN, Vol_High, 5},
{RST, Vol_High, 5}
},
},
#endif

8.vendor/mediatek/proprietary/custom/xxxx/hal/imgsensor/ 添加对应Camera驱动代码

9.vendor/mediatek/proprietary/custom/xxxx/hal/imgsensor_src/sensorlist.cpp添加

1
2
3
#if defined(S5K4H8_MIPI_RAW)
RAW_INFO(S5K4H8_SENSOR_ID, SENSOR_DRVNAME_S5K4H8_MIPI_RAW, S5K4H8_CAM_CALGetCalData),
#endif

10.vendor/mediatek/proprietary/custom/xxxx/hal/lens/src/lenslist.cpp添加

#if defined(DW9714AF_S5K4H8_SUNWIN_P130)
    extern PFUNC_GETLENSDEFAULT pDW9714AF_S5K4H8_SUNWIN_P130_getDefaultData;
#endif
Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×