MTK6761 安卓平台,ov5648摄像头调试

这里写自定义目录标题


不同mtk的板子是不同路径的
1.修改设备树节点:kernel-4.9\arch\arm\boot\dts\k61v1_32.dts
根据硬件设置对应的管脚,cam0是主摄,cam1为副摄。
&pio {
camera_pins_cam0_mclk_on: camera_pins_cam0_mclk_on {
pins_cmd_dat {
pinmux = ;
};
};
camera_pins_cam0_mclk_off: camera_pins_cam0_mclk_off {
pins_cmd_dat {
pinmux = ;
};
};
camera_pins_cam1_mclk_on: camera_pins_cam1_mclk_on {
pins_cmd_dat {
pinmux = ;
};
};
camera_pins_cam1_mclk_off: camera_pins_cam1_mclk_off {
pins_cmd_dat {
pinmux = ;
};
};
camera_pins_cam2_mclk_on: camera_pins_cam2_mclk_on {
pins_cmd_dat {
pinmux = ;
};
};
camera_pins_cam2_mclk_off: camera_pins_cam2_mclk_off {
pins_cmd_dat {
pinmux = ;
};
};
camera_pins_cam0_rst0: cam0@0 {
pins_cmd_dat {
pinmux = ;
slew-rate = <1>;
output-low;
};
};
camera_pins_cam0_rst1: cam0@1 {
pins_cmd_dat {
pinmux = ;
slew-rate = <1>;
output-high;
};
};
camera_pins_cam0_pnd0: cam0@2 {
pins_cmd_dat {
pinmux = ;
slew-rate = <1>;
output-low;
};
};
camera_pins_cam0_pnd1: cam0@3 {
pins_cmd_dat {
pinmux = ;
slew-rate = <1>;
output-high;
};
};
camera_pins_cam1_rst0: cam1@0 {
pins_cmd_dat {
pinmux = ;
slew-rate = <1>;
output-low;
};
};
camera_pins_cam1_rst1: cam1@1 {
pins_cmd_dat {
pinmux = ;
slew-rate = <1>;
output-high;
};
};
camera_pins_cam1_pnd0: cam1@2 {
pins_cmd_dat {
pinmux = ;
slew-rate = <1>;
output-low;
};
};
camera_pins_cam1_pnd1: cam1@3 {
pins_cmd_dat {
pinmux = ;
slew-rate = <1>;
output-high;
};
};
camera_pins_cam2_rst0: cam2@0 {
pins_cmd_dat {
pinmux = ;
slew-rate = <1>;
output-low;
};
};
camera_pins_cam2_rst1: cam2@1 {
pins_cmd_dat {
pinmux = ;
slew-rate = <1>;
output-high;
};
};
camera_pins_cam2_pnd0: cam2@2 {
pins_cmd_dat {
pinmux = ;
slew-rate = <1>;
output-low;
};
};
camera_pins_cam2_pnd1: cam2@3 {
pins_cmd_dat {
pinmux = ;
slew-rate = <1>;
output-high;
};
};
camera_pins_cam_ldo_rear_vcamd_0: cam0@vcamd0 {
pins_cmd_dat {
pinmux = ;
slew-rate = <1>;
output-low;
};
};
camera_pins_cam_ldo_rear_vcamd_1: cam0@vcamd1 {
pins_cmd_dat {
pinmux = ;
slew-rate = <1>;
output-high;
};
};
camera_pins_cam_ldo_sub_vcamd_0: cam1@vcamd0 {
pins_cmd_dat {
pinmux = ;
slew-rate = <1>;
output-low;
};
};
camera_pins_cam_ldo_sub_vcamd_1: cam1@vcamd1 {
pins_cmd_dat {
pinmux = ;
slew-rate = <1>;
output-high;
};
};
camera_pins_cam_ldo_sub_vcama_0: cam1@vcama0 {
pins_cmd_dat {
pinmux = ;
slew-rate = <1>;
output-low;
};
};
camera_pins_cam_ldo_sub_vcama_1: cam1@vcama1 {
pins_cmd_dat {
pinmux = ;
slew-rate = <1>;
output-high;
};
};
camera_pins_cam_ldo_rear2_vcama_0: cam2@vcama0 {
pins_cmd_dat {
pinmux = ;
slew-rate = <1>;
output-low;
};
};
camera_pins_cam_ldo_rear2_vcama_1: cam2@vcama1 {
pins_cmd_dat {
pinmux = ;
slew-rate = <1>;
output-high;
};
};
camera_pins_default: camdefault {
};
};

2.调加kenel对应的驱动文件/HAL层摄像头效果文件
\kernel-4.9\drivers\misc\mediatek\imgsensor\src\common\v1\ov5648_mipi_raw
\vendor\mediatek\proprietary\custom\mt6761\hal\imgsensor\ov5648_mipi_raw
\vendor\mediatek\proprietary\custom\mt6761\hal\imgsensor_metadata\ov5648_mipi_raw

3.修改编译宏文件:这里主摄和副摄一起设置
\device\mediateksample\k61v1_32_bsp_hdp\ProjectConfig.mk

CUSTOM_HAL_IMGSENSOR = ov5648_mipi_raw ov5648sub_mipi_raw
CUSTOM_HAL_MAIN_IMGSENSOR = ov5648_mipi_raw
CUSTOM_HAL_SUB_IMGSENSOR = ov5648sub_mipi_raw

CUSTOM_KERNEL_IMGSENSOR = ov5648_mipi_raw ov5648sub_mipi_raw
CUSTOM_KERNEL_MAIN_IMGSENSOR = ov5648_mipi_raw
CUSTOM_KERNEL_SUB_IMGSENSOR = ov5648sub_mipi_raw
修改这个
\kernel-4.9\arch\arm\configs\k61v1_32_bsp_hdp_defconfig
CONFIG_CUSTOM_KERNEL_IMGSENSOR=“ov5648_mipi_raw ov5648sub_mipi_raw”
接着
\device\mediatek\common\kernel-headers\kd_imgsensor.h
\kernel-4.9/drivers/misc/mediatek/imgsensor/inc/kd_imgsensor.h

#define SENSOR_DRVNAME_OV5648_MIPI_RAW “ov5648_mipi_raw”
#define SENSOR_DRVNAME_OV5648sub_MIPI_RAW “ov5648sub_mipi_raw”
#define OV5648MIPI_SENSOR_ID 0x5648
#define OV5648subMIPI_SENSOR_ID 0x5649
配置上电时序
\kernel-4.9\drivers\misc\mediatek\imgsensor\src\mt6761\camera_hw\imgsensor_cfg_table.c

观察下面这个结构体,设备0、设备1.对应主摄、副摄。同型号的摄像头一般配置顺序一样。
struct IMGSENSOR_HW_CFG imgsensor_custom_config[] = {
{
IMGSENSOR_SENSOR_IDX_MAIN,
IMGSENSOR_I2C_DEV_0,
{
{IMGSENSOR_HW_ID_MCLK, IMGSENSOR_HW_PIN_MCLK},
{IMGSENSOR_HW_ID_REGULATOR, IMGSENSOR_HW_PIN_AVDD},
{IMGSENSOR_HW_ID_REGULATOR, IMGSENSOR_HW_PIN_DOVDD},
{IMGSENSOR_HW_ID_GPIO, IMGSENSOR_HW_PIN_DVDD},
{IMGSENSOR_HW_ID_GPIO, IMGSENSOR_HW_PIN_PDN},
{IMGSENSOR_HW_ID_GPIO, IMGSENSOR_HW_PIN_RST},
{IMGSENSOR_HW_ID_NONE, IMGSENSOR_HW_PIN_NONE},
},
},
{
IMGSENSOR_SENSOR_IDX_SUB,
IMGSENSOR_I2C_DEV_1,
{
{IMGSENSOR_HW_ID_MCLK, IMGSENSOR_HW_PIN_MCLK},
{IMGSENSOR_HW_ID_REGULATOR, IMGSENSOR_HW_PIN_AVDD},
{IMGSENSOR_HW_ID_REGULATOR, IMGSENSOR_HW_PIN_DOVDD},
{IMGSENSOR_HW_ID_GPIO, IMGSENSOR_HW_PIN_DVDD},
{IMGSENSOR_HW_ID_GPIO, IMGSENSOR_HW_PIN_PDN},
{IMGSENSOR_HW_ID_GPIO, IMGSENSOR_HW_PIN_RST},
{IMGSENSOR_HW_ID_NONE, IMGSENSOR_HW_PIN_NONE},
},
},
上电时序,数组,一般顺序要一样
struct IMGSENSOR_HW_POWER_SEQ sensor_power_sequence[] = {

#if defined(OV5648_MIPI_RAW)
{
SENSOR_DRVNAME_OV5648_MIPI_RAW,
{
{SensorMCLK, Vol_High, 0},
{PDN, Vol_Low, 0},
{PDN, Vol_Low, 0},
{DOVDD, Vol_1800, 0},
{AVDD, Vol_2800, 1},
{DVDD, Vol_1500, 1},
{AFVDD, Vol_2800, 5},
{PDN, Vol_High, 1},
{RST, Vol_High, 10}
},
},
#endif

#if defined(OV5648sub_MIPI_RAW)
{
SENSOR_DRVNAME_OV5648sub_MIPI_RAW,
{
{SensorMCLK, Vol_High, 0},
{PDN, Vol_Low, 0},
{PDN, Vol_Low, 0},
{DOVDD, Vol_1800, 0},
{AVDD, Vol_2800, 1},
{DVDD, Vol_1500, 1},
{AFVDD, Vol_2800, 5},
{PDN, Vol_High, 1},
{RST, Vol_High, 10}
},
},
#endif
添加驱动列表
\kernel-4.9\drivers\misc\mediatek\imgsensor\src\common\v1\imgsensor_sensor_list.c
struct IMGSENSOR_INIT_FUNC_LIST kdSensorList[MAX_NUM_OF_SUPPORT_SENSOR] = {

#if defined(OV5648_MIPI_RAW)
{OV5648MIPI_SENSOR_ID,
SENSOR_DRVNAME_OV5648_MIPI_RAW,
OV5648MIPISensorInit},
#endif
#if defined(OV5648sub_MIPI_RAW)
{OV5648subMIPI_SENSOR_ID,
SENSOR_DRVNAME_OV5648sub_MIPI_RAW,
OV5648subMIPISensorInit},
#endif

\kernel-4.9\drivers\misc\mediatek\imgsensor\src\common\v1\imgsensor_sensor_list.h

UINT32 OV5648MIPISensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
UINT32 OV5648subMIPISensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);
HAL层c++引用:
\vendor\mediatek\proprietary\custom\mt6761\hal\imgsensor_src\sensorlist.cpp

#if defined(OV5648_MIPI_RAW)
RAW_INFO(OV5648MIPI_SENSOR_ID, SENSOR_DRVNAME_OV5648_MIPI_RAW, NULL),
#endif

#if defined(OV5648sub_MIPI_RAW)
RAW_INFO(OV5648subMIPI_SENSOR_ID, SENSOR_DRVNAME_OV5648sub_MIPI_RAW, NULL),
#endif

4.设置时钟:
\vendor\mediatek\proprietary\custom\mt6761\hal\imgsensor_src\cfg_setting_imgsensor.cpp
根据具体硬件设置,eMclk_1对应clk0,eMclk_2对应clk1.0为主摄,1为副摄
MINT32 getSensorMclkConnection(EDevId const eDevId)
{
switch (eDevId)
{
case eDevId_ImgSensor0://main
return eMclk_1;
case eDevId_ImgSensor1://sub
return eMclk_2;
case eDevId_ImgSensor2://3d
return eMclk_2;
case eDevId_ImgSensor3://sub2
return eMclk_2;
case eDevId_ImgSensor4://main3
return eMclk_2;
default:
break;
}
return -1;
}

当摄像头打开后出现打开黑色屏幕而且不能拍照的情况下
修改MIPI时钟线
MINT32 getMipiSensorPort(EDevId const eDevId)
{
switch (eDevId)
{
case eDevId_ImgSensor0://main
//return EMipiPort_CSI2;
return EMipiPort_CSI0;
case eDevId_ImgSensor1://sub
// return EMipiPort_CSI0;
return EMipiPort_CSI2;
case eDevId_ImgSensor2://3d
return EMipiPort_CSI2;
case eDevId_ImgSensor3://sub2
return EMipiPort_CSI0;
case eDevId_ImgSensor4://main3
return EMipiPort_CSI1;
default:
break;
}
return -1;
}
不同的设备硬件,不一样,我们这里可以逐一调试并验证。

修改旋转角度,一般为90.

SensorOrientation_T const&
getSensorOrientation()
{
static SensorOrientation_T const inst = {
.u4Degree_0 = 90, // main sensor in degree (0, 90, 180, 270)
.u4Degree_1 = 90, // sub sensor in degree (0, 90, 180, 270)
.u4Degree_2 = 90, // main2 sensor in degree (0, 90, 180, 270)
.u4Degree_3 = 90, // sub2 k in degree (0, 90, 180, 270)
.u4Degree_4 = 90, // main3 sensor in degree (0, 90, 180, 270)
};
return inst;

}

这是摄像头的移植步骤在MTK平台上的

你可能感兴趣的:(MTK6761 安卓平台,ov5648摄像头调试)