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平台上的