配置文件:
device/mediatek/XXX/ProjectConfig.mk
添加各种需要支持的型号
例如:
CUSTOM_HAL_IMGSENSOR
CUSTOM_HAL_MAIN_IMGSENSOR
CUSTOM_HAL_MAIN_LENS
CUSTOM_KERNEL_IMGSENSOR
CUSTOM_KERNEL_LENS
CUSTOM_KERNEL_MAIN_IMGSENSOR
设置为dummy_lens即是不支持
kernel/arch/arm64/config/XXX_debug_defconfig
kernel/arch/arm64/config/XXX_defconfig
添加型号:
CONFIG_CUSTOM_KERNEL_IMGSENSOR
kernel/driver/misc/mediatek/imgsensor/inc/kd_imgsensor.h
device/mediatek/common/kernel-headers/kd_imgsensor.h
添加sensor ID的定义
#define OV5648_SENSOR_ID 0x5648
#define SENSOR_DRVNAME_OV5648_MIPI_RAW "ov5648_mipi_raw"
kernel/driver/misc/mediatek/imgsensor/src/XXX/imgsensor_sensor_list.h
UINT32 OV5648_MIPI_RAW_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
添加sensor init function declaration
kernel/driver/misc/mediatek/imgsensor/src/XXX/imgsensor_sensor_list.c
#if defined(OV5648_MIPI_RAW)
{OV5648_SENSOR_ID,
SENSOR_DRVNAME_OV5648_MIPI_RAW,
OV5648_MIPI_RAW_SensorInit},
#endif
在kdsensorlist[]中添加sensor。分别是sensor ID,Sensor name,sensor init function
vendor/mediatek/proprietary/custom/xxx/hal/imgsensor_src/sensorlist.cpp
在hal的sensorlist[]中添加new sensor
注意顺序要与kernel中保持一致
kernel/driver/misc/mediatek/imgsensor/src/xxx/camera_hw/imgsensor_cfg_table.c
该文件配置sensor的上下电
#if defined(OV5648_MIPI_RAW)
{
SENSOR_DRVNAME_OV5648_MIPI_RAW,
{
{PDN, Vol_High, 0}, //{powertype,voltage,delay time}
{PDN, Vol_Low, 0},
{DOVDD, Vol_1800, 1},
{AVDD, Vol_2800, 1},
{DVDD, Vol_1200, 1},
{RST, Vol_Low, 5},
{RST, Vol_High, 10},
{SensorMCLK, Vol_High, 1}
},
},
#endif
在kernel-4.9/drivers/misc/mediatek/imgsensor/src/mt6761/camera_hw/regulator/regulator.c文件中添加定义:
struct REGULATOR_CTRL regulator_control[REGULATOR_TYPE_MAX_NUM] = {
{"vcama"},
{"vcamd"},
{"vcamio"},
{"vcamaf"},
{"vcama_sub"},
{"vcamd_sub"},
{"vcamio_sub"},
{"vcama_main2"},
{"vcamd_main2"},
{"vcamio_main2"},
{"vcama_sub2"},
{"vcamd_sub2"},
{"vcamio_sub2"},
{"vcama_main3"},
{"vcamd_main3"},
{"vcamio_main3"}
};
然后通过regulator_init,regulator_get,regulator_set函数进行设置电压
GPIO上电逻辑(目前比较常用的):
kernel/arch/arm64/boot/dts/mediatek/XXX.dts
添加子节点:
&kd_camera_hw1 {
pinctrl-names = "default",
"cam0_rst0",
"cam0_rst1",
"cam0_pnd0",
"cam0_pnd1",
"cam1_rst0",
"cam1_rst1",
"cam1_pnd0",
"cam1_pnd1",
"cam2_rst0",
"cam2_rst1",
"cam2_pnd0",
"cam2_pnd1",
"cam0_vcamd_on",
"cam0_vcamd_off",
"cam1_vcamd_on",
"cam1_vcamd_off",
"cam1_vcama_on",
"cam1_vcama_off",
"cam2_vcama_on",
"cam2_vcama_off",
"cam0_mclk_on",
"cam0_mclk_off",
"cam1_mclk_on",
"cam1_mclk_off",
"cam2_mclk_on",
"cam2_mclk_off";
pinctrl-0 = <&camera_pins_default>;
pinctrl-1 = <&camera_pins_cam0_rst0>;
pinctrl-2 = <&camera_pins_cam0_rst1>;
pinctrl-3 = <&camera_pins_cam0_pnd0>;
pinctrl-4 = <&camera_pins_cam0_pnd1>;
pinctrl-5 = <&camera_pins_cam1_rst0>;
pinctrl-6 = <&camera_pins_cam1_rst1>;
pinctrl-7 = <&camera_pins_cam1_pnd0>;
pinctrl-8 = <&camera_pins_cam1_pnd1>;
pinctrl-9 = <&camera_pins_cam2_rst0>;
pinctrl-10 = <&camera_pins_cam2_rst1>;
pinctrl-11 = <&camera_pins_cam2_pnd0>;
pinctrl-12 = <&camera_pins_cam2_pnd1>;
pinctrl-13 = <&camera_pins_cam_ldo_rear_vcamd_1>;
pinctrl-14 = <&camera_pins_cam_ldo_rear_vcamd_0>;
pinctrl-15 = <&camera_pins_cam_ldo_sub_vcamd_1>;
pinctrl-16 = <&camera_pins_cam_ldo_sub_vcamd_0>;
pinctrl-17 = <&camera_pins_cam_ldo_sub_vcama_1>;
pinctrl-18 = <&camera_pins_cam_ldo_sub_vcama_0>;
pinctrl-19 = <&camera_pins_cam_ldo_rear2_vcama_1>;
pinctrl-20 = <&camera_pins_cam_ldo_rear2_vcama_0>;
pinctrl-21 = <&camera_pins_cam0_mclk_on>;
pinctrl-22 = <&camera_pins_cam0_mclk_off>;
pinctrl-23 = <&camera_pins_cam1_mclk_on>;
pinctrl-24 = <&camera_pins_cam1_mclk_off>;
pinctrl-25 = <&camera_pins_cam2_mclk_on>;
pinctrl-26 = <&camera_pins_cam2_mclk_off>;
status = "okay";
};这里的pinctrl-name于下面的pinctrl-0、1、2是按照顺序一一对应。
然后对每个节点进行定义:
以此为例
camera_pins_cam_ldo_rear_vcamd_0: cam0@vcamd0 {
pins_cmd_dat {
pinmux =
slew-rate = <1>; 1:output、0:input
output-low; low:低电压、high:高电压
};
};
这里就把camera的上电管脚于平台管脚相关联。
上下电一般平台已经写好了,只需要少量修改
最后添加sensor驱动:
一般根据各个接口函数在sample code基础上进行修改
kernel/driver/misc/mediatek/imgsensor/src/XXX/XXX_mipi_raw/
vendor/mediatek/proprietary/custom/XXX/hal/imgsensor/XXX_mipi_raw/
同理lens的驱动在:
kernel/driver/misc/mediatek/lens/main(sub)/XXX/
vendor/mediatek/proprietary/custom/XXX/hal/lens/