零、点亮新len
1. 修改device\lentek\len6737m_35_m0\ProjectConfig.mk
CUSTOM_HAL_LENS=fm50af dw9714af
CUSTOM_HAL_MAIN_LENS=fm50af dw9714af
CUSTOM_KERNEL_LENS=fm50af dw9714af
CUSTOM_KERNEL_MAIN_LENS=fm50af dw9714af
2. 修改kernel-3.18\arch\arm\configs\len6737m_35_m0_debug_defconfig、len6737m_35_m0_defconfig
CONFIG_MTK_LENS_FM50AF_SUPPORT=y
CONFIG_MTK_LENS_DW9714AF_SUPPORT=y
3. 修改alps\kernel-3.18\drivers\misc\mediatek\lens\main\inc\lens_info.h
#define AFDRV_DW9714A "DW9714A"
4. 修改alps\kernel-3.18\drivers\misc\mediatek\lens\main\inc\lens_list.h
#ifdef CONFIG_MTK_LENS_DW9714AF_SUPPORT
#define DW9714AF_SetI2Cclient DW9714AF_SetI2Cclient_Main
#define DW9714AF_Ioctl DW9714AF_Ioctl_Main
#define DW9714AF_Release DW9714AF_Release_Main
extern void DW9714AF_SetI2Cclient(struct i2c_client *pstAF_I2Cclient, spinlock_t *pAF_SpinLock, int *pAF_Opened);
extern long DW9714AF_Ioctl(struct file *a_pstFile, unsigned int a_u4Command, unsigned long a_u4Param);
extern int DW9714AF_Release(struct inode *a_pstInode, struct file *a_pstFile);
#endif
5. 修改alps\kernel-3.18\drivers\misc\mediatek\lens\main\main_lens.c
static stAF_DrvList g_stAF_DrvList[MAX_NUM_OF_LENS] = {
...
#ifdef CONFIG_MTK_LENS_DW9714AF_SUPPORT
{1, AFDRV_DW9714AF, DW9714AF_SetI2Cclient, DW9714AF_Ioctl, DW9714AF_Release},
#endif
6. 添加驱动代码,放到kernel-3.18\drivers\misc\mediatek\lens\main\common\
创建文件夹dw9714af文件夹中包含DW9714AF.c、Makefile
7.修改上电时序: kernel-3.18\drivers\misc\mediatek\imgsensor\src\mt6735m\camera_hw\kd_camera_hw.c
//POWER ON
if (On) {
if ((currSensorName && (0 == strcmp(SENSOR_DRVNAME_GC8024MIPI_RAW, currSensorName))) ||
(currSensorName && (0 == strcmp(SENSOR_DRVNAME_GC5005MIPI_RAW, currSensorName)))){
...
// AF_VCC
if (TRUE != _hwPowerOn(VCAMAF, VOL_2800)) {
PK_DBG("[CAMERA SENSOR] Fail to enable AF power (VCAM_AF), power id = %d\n", VCAMAF);
//goto _kdCISModulePowerOn_exit_;
}
}
}
====================================以下是HAL层====================================
8. 添加HAL层代码: alps\vendor\mediatek\proprietary\custom\mt6735\hal\D2\lens\lens_para_DW9714AF.cpp
9. 修改alps\vendor\mediatek\proprietary\custom\mt6735\hal\D2\lens\Android.mk
+ LOCAL_SRC_FILES += lens_para_DW9714AF.cpp
10. 修改alps\vendor\mediatek\proprietary\custom\mt6735\hal\D2\lens\lenslist.cpp
#if defined(DW9714AF)
extern PFUNC_GETLENSDEFAULT pDW9714AF_getDefaultData;
// 这里的pDW9714AF_getDefaultData要与lens_para_DW9714AF.cpp中函数名一致
#endif
MSDK_LENS_INIT_FUNCTION_STRUCT LensList_main[MAX_NUM_OF_SUPPORT_LENS] =
{
#if defined(DW9714AF)
{IMX219_SENSOR_ID, DW9714AF_LENS_ID, "DW9714AF", pDW9714AF_getDefaultData},
// 后摄imx219的AF选定为: DW9714AF
#endif
二、前摄AF - 与后摄AF基本一致,需要注意的地方:
1.alps\vendor\mediatek\proprietary\custom\mt6735\hal\D2\lens\lenslist.cpp中注意核对: LensList_sub[]
MSDK_LENS_INIT_FUNCTION_STRUCT LensList_sub[MAX_NUM_OF_SUPPORT_LENS] ={
...
#if defined(DW9718AF)
{OV8865_SENSOR_ID, DW9718AF_LENS_ID, "DW9718AF", pDW9718AF_getDefaultData},
#endif
2.dws中的i2c栏目中,默认没有前摄AF,需要配上:
CAMERA_SUB_AF I2C_CHANNEL_2 0x0c
注: a)i2c总线,查看硬件原理图,与前摄读ID一个总线
b)i2c地址,驱动中写死,这里随意写
3.由于前摄AF比较少见,需要注意上电时序中把前摄AF上电
修改kernel-3.18\drivers\misc\mediatek\imgsensor\src\mt6735m\camera_hw\kd_camera_hw.c
//POWER ON
if (On) {
if ((currSensorName && (0 == strcmp(SENSOR_DRVNAME_GC8024MIPI_RAW, currSensorName))) ||
(currSensorName && (0 == strcmp(SENSOR_DRVNAME_GC5005MIPI_RAW, currSensorName)))){
...
// AF_VCC
if (TRUE != _hwPowerOn(VCAMAF, VOL_2800)) {
PK_DBG("[CAMERA SENSOR] Fail to enable AF power (VCAM_AF), power id = %d\n", VCAMAF);
}
}
}
4.由于前摄AF比较少见,需要注意硬件电路板中AF上电引脚是否有贴限流电阻(10k),可请硬件工程师帮忙检查
比如: v618_m5501项目就没有贴该电阻,导致AF的i2c不通 (原理图上有)
三、调试 - 驱动中没有实现什么调试节点,需要自己添加log打印
根据len的
注册流程: -> 前半部分需要通过串口查看log
-> 先运行AF_SetMotorName() - 设置AF是哪个
alps\kernel-3.18\drivers\misc\mediatek\lens\main\main_lens.c (架构)
MAINAF_i2C_init() // 模块入口
platform_driver_register(&g_stAF_Driver)
AF_probe() // 平台设备与平台驱动probe
i2c_add_driver(&AF_i2c_driver)
AF_i2c_probe() // i2c设备与i2c驱动probe - 【这里需要dws中的i2c栏目中有前摄af配置】
Register_AF_CharDrv();
alloc_chrdev_region(&g_AF_devno, 0, 1, AF_DRVNAME)
g_pAF_CharDrv = cdev_alloc();
cdev_init(g_pAF_CharDrv, &g_stAF_fops); // 关键 - 注册fops
cdev_add(g_pAF_CharDrv, g_AF_devno, 1)
class_create(THIS_MODULE, AF_DRIVER_CLASS_NAME);
device_create(actuator_class, NULL, g_AF_devno, NULL, AF_DRVNAME);
static const struct file_operations g_stAF_fops = {
.unlocked_ioctl = AF_Ioctl,
AF_Ioctl(struct file *a_pstFile, unsigned int a_u4Command, unsigned long a_u4Param)
switch (a_u4Command) {
case AFIOC_S_SETDRVNAME: AF_SetMotorName((__user stAF_MotorName *) (a_u4Param)); // 【设置af是哪个 - 首先运行】
case AFIOC_S_SETPOWERDOWN: AF_PowerDown(); // power down
default: g_pstAF_CurDrv->pAF_Ioctl(a_pstFile, a_u4Command, a_u4Param); // 驱动中实现
AF_SetMotorName()中默认会打印log:
LOG_INF("Set Motor Name : %s\n", stMotorName.uMotorName);
- mtklog中的kernel_log.boot查看 - 上层传下来操作哪个AF,看是否与模组对应
运行流程: 上层通过字符设备节点进行ioctl()
alps\kernel-3.18\drivers\misc\mediatek\lens\main\main_lens.c (架构)
g_pstAF_CurDrv->pAF_Ioctl(a_pstFile, a_u4Command, a_u4Param)
alp
12. len(AF)调试日志
最新推荐文章于 2024-10-01 14:44:29 发布