1.拷贝hal层代码到\vendor\mediatek\proprietary\custom\mt6735\hal\D1\imgsensor\目录下。
2.拷贝kernel层代码到\kernel-3.10\drivers\misc\mediatek\imgsensor\src\mt6735\目录下。
3.添加Sensor_id:\vendor\mediatek\proprietary\custom\mt6735\hal\D1\imgsensor_src\sensorlist.cpp
我的摄像头型号是ov8858这款sensor所以对应应该
//800w
#if defined(OV8858_MIPI_RAW)
RAW_INFO(OV8858_SENSOR_ID, SENSOR_DRVNAME_OV8858_MIPI_RAW,NULL),
#endif
#define OV8858_SENSOR_ID 0x8858
#define SENSOR_DRVNAME_OV8858_MIPI_RAW "ov8858mipiraw"
一般定义ID在这个文件差不多都定义了所以我们也不用去管,但是还是需要去看看
5.定义ID:\kernel-3.10\drivers\misc\mediatek\imgsensor/inc/kd_imgsensor.h和上面一样
6.绑定函数入口:\kernel-3.10\drivers\misc\mediatek\imgsensor\src\mt6735\kd_sensorlist.h
//800w
#if defined(OV8858_MIPI_RAW)
{OV8858_SENSOR_ID, SENSOR_DRVNAME_OV8858_MIPI_RAW,OV8858_MIPI_RAW_SensorInit},
#endif
if(currSensorName && (0 == strcmp(SENSOR_DRVNAME_OV8858_MIPI_RAW, currSensorName)))
{
printk("tangh SENSOR_DRVNAME_OV8858_MIPI_RAW \n ");
//First Power Pin low and Reset Pin Low
if (GPIO_CAMERA_INVALID != pinSet[pinSetIdx][IDX_PS_CMPDN]) {
if(mt_set_gpio_mode(pinSet[pinSetIdx][IDX_PS_CMPDN],pinSet[pinSetIdx][IDX_PS_CMPDN+IDX_PS_MODE])){PK_DBG("[CAMERA LENS] set gpio mode failed!! (CMPDN)\n");}
if(mt_set_gpio_dir(pinSet[pinSetIdx][IDX_PS_CMPDN],GPIO_DIR_OUT)){PK_DBG("[CAMERA LENS] set gpio dir failed!! (CMPDN)\n");}
if(mt_set_gpio_out(pinSet[pinSetIdx][IDX_PS_CMPDN],pinSet[pinSetIdx][IDX_PS_CMPDN+IDX_PS_OFF])){PK_DBG("[CAMERA LENS] set gpio failed!! (CMPDN)\n");}
}
if (GPIO_CAMERA_INVALID != pinSet[pinSetIdx][IDX_PS_CMRST]) {
if(mt_set_gpio_mode(pinSet[pinSetIdx][IDX_PS_CMRST],pinSet[pinSetIdx][IDX_PS_CMRST+IDX_PS_MODE])){PK_DBG("[CAMERA SENSOR] set gpio mode failed!! (CMRST)\n");}
if(mt_set_gpio_dir(pinSet[pinSetIdx][IDX_PS_CMRST],GPIO_DIR_OUT)){PK_DBG("[CAMERA SENSOR] set gpio dir failed!! (CMRST)\n");}
if(mt_set_gpio_out(pinSet[pinSetIdx][IDX_PS_CMRST],pinSet[pinSetIdx][IDX_PS_CMRST+IDX_PS_OFF])){PK_DBG("[CAMERA SENSOR] set gpio failed!! (CMRST)\n");}
}
//VCAM_IO
if(TRUE != hwPowerOn(CAMERA_POWER_VCAM_IO, VOL_1800, mode_name))
{
PK_DBG("[CAMERA SENSOR] Fail to enable digital power (VCAM_IO), power id = %d \n", CAMERA_POWER_VCAM_IO);
goto _kdCISModulePowerOn_exit_;
}
//VCAM_A
if(TRUE != hwPowerOn(CAMERA_POWER_VCAM_A, VOL_2800,mode_name))
{
PK_DBG("[CAMERA SENSOR] Fail to enable analog power (VCAM_A), power id = %d\n", CAMERA_POWER_VCAM_A);
goto _kdCISModulePowerOn_exit_;
}
//VCAM_D
if(TRUE != hwPowerOn(CAMERA_POWER_VCAM_D, VOL_1500,mode_name))
{
PK_DBG("[CAMERA SENSOR] Fail to enable digital power\n");
goto _kdCISModulePowerOn_exit_;
}
//AF_VCC
if(TRUE != hwPowerOn(CAMERA_POWER_VCAM_AF, VOL_2800,mode_name))
{
PK_DBG("[CAMERA SENSOR] Fail to enable analog power (VCAM_AF), power id = %d \n", CAMERA_POWER_VCAM_AF);
goto _kdCISModulePowerOn_exit_;
}
mdelay(5);
//enable active sensor
if (GPIO_CAMERA_INVALID != pinSet[pinSetIdx][IDX_PS_CMPDN]) {
if(mt_set_gpio_mode(pinSet[pinSetIdx][IDX_PS_CMPDN],pinSet[pinSetIdx][IDX_PS_CMPDN+IDX_PS_MODE])){PK_DBG("[CAMERA LENS] set gpio mode failed!! (CMPDN)\n");}
if(mt_set_gpio_dir(pinSet[pinSetIdx][IDX_PS_CMPDN],GPIO_DIR_OUT)){PK_DBG("[CAMERA LENS] set gpio dir failed!! (CMPDN)\n");}
if(mt_set_gpio_out(pinSet[pinSetIdx][IDX_PS_CMPDN],pinSet[pinSetIdx][IDX_PS_CMPDN+IDX_PS_ON])){PK_DBG("[CAMERA LENS] set gpio failed!! (CMPDN)\n");}
}
mdelay(1);
if (GPIO_CAMERA_INVALID != pinSet[pinSetIdx][IDX_PS_CMRST]) {
if(mt_set_gpio_mode(pinSet[pinSetIdx][IDX_PS_CMRST],pinSet[pinSetIdx][IDX_PS_CMRST+IDX_PS_MODE])){PK_DBG("[CAMERA SENSOR] set gpio mode failed!! (CMRST)\n");}
if(mt_set_gpio_dir(pinSet[pinSetIdx][IDX_PS_CMRST],GPIO_DIR_OUT)){PK_DBG("[CAMERA SENSOR] set gpio dir failed!! (CMRST)\n");}
if(mt_set_gpio_out(pinSet[pinSetIdx][IDX_PS_CMRST],pinSet[pinSetIdx][IDX_PS_CMRST+IDX_PS_ON])){PK_DBG("[CAMERA SENSOR] set gpio failed!! (CMRST)\n");}
}
}
VCAM_IO、VCAM_A、VCAM_D和AF_VCC都是需要按照手册来修改
8.在ProjectConfig.mk中添加sensor
CUSTOM_HAL_IMGSENSOR=ov8858_mipi_raw
CUSTOM_HAL_MAIN_IMGSENSOR=ov8858_mipi_raw
CUSTOM_KERNEL_IMGSENSOR=ov8858_mipi_raw
CUSTOM_KERNEL_MAIN_IMGSENSOR=ov8858_mipi_raw
在\kernel-3.10\arch\arm64\configs\
CONFIG_CUSTOM_KERNEL_IMGSENSOR=“ov8858_mipi_raw”
首先你可能会发现额怎么我的摄像功能不行?我的聚焦功能也没实现,闪光灯功能也没看到。运气好的话你可能也会遇到,当时找了很久都没发现问题后来请教了下大神帮我弄了下终于弄出来了但是还是云里雾里,在我的基础上也没怎么改。
我们当时直接把AF加上之后就正常,但是在ProjectConfig.mk把其它摄像头的驱动都屏蔽了,后面需要自己添加,这里有一点不明白就是添加两个兼容驱动写前和写后面的区别是什么可以互换不,如果哪位知道请评论下,感谢。
添加AF在ProjectConfig.mk:
CUSTOM_KERNEL_LENS = ad5820af fm50af dw9714af dummy_lens
在\vendor\mediatek\proprietary\custom\
现在差不多都搞定了。打开摄像头看到上下左右都反了,那我们就得看下寄存器改方向了查看了8858相关寄存器,发现修改方向的是0x3820和0x3821按照对应修改即可,.sensor_output_dataformat = SENSOR_OUTPUT_FORMAT_RAW_B这个是修改颜色的你们也应该会遇到问题,四种状态:B、Gb、R、Gr