MT6737的lens HAL层分析

news/2024/11/30 18:35:11/
lens驱动和HAL分析
一.6737的lens 搜索HAL层分析
Mcu_drv.cpp (vendor\mediatek\proprietary\hardware\mtkcam\legacy\platform\mt6735\core\featureio\drv\lens)	
根据摄像头搜索lens
MCUDrv::lensSearch( unsigned int a_u4CurrSensorDev, unsigned int a_u4CurrSensorId)//Camera_custom_msdk.cpp (vendor\mediatek\proprietary\custom\mt6735\hal\d1\camera_3a)LensCustomInit(a_u4CurrSensorDev); //得到lens列表,  //单独分析1   LensCustomGetInitFunc(&MCUDrv::m_LensInitFunc_main[0]);  //把LensCustomInit得到的数组赋值到a_pLensInitFuncmemcpy(a_pLensInitFunc, &LensInitFunc[0], sizeof(MSDK_LENS_INIT_FUNCTION_STRUCT) * MAX_NUM_OF_SUPPORT_LENS);MCUDrv::m_u4CurrLensIdx_main = 0;for (i=0; i<MAX_NUM_OF_SUPPORT_LENS; i++) //搜索每个lensif (MCUDrv::m_LensInitFunc_main[i].LensId == DUMMY_LENS_ID)  //如果某个lens的ID为DUMMY_LENS_ID,记录,这里是选择最后一个DUMMY_LENS_IDMCUDrv::m_u4CurrLensIdx_main = i;for (i=0; i<MAX_NUM_OF_SUPPORT_LENS; i++)//把当前的sensor id和数组里面的比较,如果有,就记录,并且跳槽,所以是选择匹配的第一个if ((MCUDrv::m_LensInitFunc_main[i].SensorId == a_u4CurrSensorId) && (a_u4CurrSensorId!=0xFFFF) && (a_u4CurrSensorId!=0x0))MCUDrv::m_u4CurrLensIdx_main = i;MCU_DRV_DBG("[idx]%d\n", i);break;LensCustomSetIndex(MCUDrv::m_u4CurrLensIdx_main); //记录下主摄像头的lens的IDgMainLensIdx = a_u4CurrIdx;//单独分析1//Lenslist.cpp (vendor\mediatek\proprietary\custom\mt6735\hal\d1\lens\src)GetLensInitFuncList(&LensInitFunc[0], a_u4CurrSensorDev);if(a_u4CurrSensorDev==2) //submemcpy(pLensList, &LensList_sub[0], sizeof(MSDK_LENS_INIT_FUNCTION_STRUCT)* MAX_NUM_OF_SUPPORT_LENS);else if(a_u4CurrSensorDev==4) //main 2memcpy(pLensList, &LensList_main2[0], sizeof(MSDK_LENS_INIT_FUNCTION_STRUCT)* MAX_NUM_OF_SUPPORT_LENS);else  // main or othersmemcpy(pLensList, &LensList_main[0], sizeof(MSDK_LENS_INIT_FUNCTION_STRUCT)* MAX_NUM_OF_SUPPORT_LENS);  //拷贝到pLensListMSDK_LENS_INIT_FUNCTION_STRUCT LensList_main[MAX_NUM_OF_SUPPORT_LENS] =
{{DUMMY_SENSOR_ID, DUMMY_LENS_ID, "Dummy", pDummy_getDefaultData},#if defined(SENSORDRIVE)	{OV3640_SENSOR_ID, SENSOR_DRIVE_LENS_ID, "kd_camera_hw", pSensorDrive_getDefaultData},#endif
#if defined(FM50AF){DUMMY_SENSOR_ID, FM50AF_LENS_ID, "FM50AF", pFM50AF_getDefaultData},#endif#if defined(DW9714AF){MN34152_SENSOR_ID, DW9714AF_LENS_ID, "DW9714AF", pDW9714AF_getDefaultData},{IMX219_SENSOR_ID, DW9714AF_LENS_ID, "DW9714AF", pDW9714AF_getDefaultData},#endif
}二.lens HAL层调用分析
Lens_drv.cpp (vendor\mediatek\proprietary\hardware\mtkcam\legacy\platform\mt6735\core\featureio\drv\lens)1.初始化
LensDrv::init(unsigned int a_u4CurrSensorDev )sprintf(cBuf, "/dev/%s", MCUDrv::m_LensInitFunc_main[a_u4CurrLensIdx].LensDrvName);m_fdMCU_main = open("/dev/MAINAF", O_RDWR); //打开这个节点memcpy(motorName.uMotorName, MCUDrv::m_LensInitFunc_main[a_u4CurrLensIdx].LensDrvName, 32); //得到AF的名字int err = ioctl(m_fdMCU_main,mcuIOC_S_SETDRVNAME,&motorName);   //设置AF的名字,驱动的AFIOC_S_SETDRVNAME,后面有分析2.移动马达
LensDrv::moveMCU(int a_i4FocusPos,unsigned int a_u4CurrSensorDev )a_fdMCU=m_fdMCU_main;//设置马达位置,操作/dev/MAINAF,a_i4FocusPos为知(0--1023),去的default,后面有分析err = ioctl(a_fdMCU,mcuIOC_T_MOVETO,(unsigned long)a_i4FocusPos);  3.获取马达信息
LensDrv::getMCUInfo(mcuMotorInfo *a_pMotorInfo, unsigned int a_u4CurrSensorDev )err = ioctl(a_fdMCU,mcuIOC_G_MOTORINFO, &motorInfo);。。。。。。。。其他操作。。。。。。。。。三.Main_lens公共驱动分析
Main_lens.c (kernel-3.18\drivers\misc\mediatek\lens)#define PLATFORM_DRIVER_NAME "lens_actuator_main_af"/* platform structure */
static struct platform_driver g_stAF_Driver = {.probe = AF_probe,.remove = AF_remove,.suspend = AF_suspend,.resume = AF_resume,.driver = {.name = PLATFORM_DRIVER_NAME,.owner = THIS_MODULE,}
};static struct platform_device g_stAF_device = {.name = PLATFORM_DRIVER_NAME,.id = 0,.dev = {}
};1.初始化,注册平台设备驱动
MAINAF_i2C_initplatform_device_register(&g_stAF_device) //平台驱动匹配,进入probe函数platform_driver_register(&g_stAF_Driver)2.注册I2C设备
#if I2C_CONFIG_SETTING == 2
static const struct of_device_id MAINAF_of_match[] = {{.compatible = "mediatek,CAMERA_MAIN_AF"},{},
};
#endif
static struct i2c_driver AF_i2c_driver = {.probe = AF_i2c_probe,.remove = AF_i2c_remove,.driver.name = AF_DRVNAME,
#if I2C_CONFIG_SETTING == 2.driver.of_match_table = MAINAF_of_match,
#endif.id_table = AF_i2c_id,
};AF_probei2c_add_driver(&AF_i2c_driver); //匹配进入AF_i2c_probe函数,生成节点/sys/bus/i2c/drivers/MAINAF3.I2C初始化static const struct file_operations g_stAF_fops = {.owner = THIS_MODULE,.open = AF_Open,.release = AF_Release,.unlocked_ioctl = AF_Ioctl,
#ifdef CONFIG_COMPAT.compat_ioctl = AF_Ioctl,
#endif
};AF_i2c_probeg_pstAF_I2Cclient = client; //保存client,应该和camera一样,先注册个假的地址i4RetValue = Register_AF_CharDrv();alloc_chrdev_region(&g_AF_devno, 0, 1, AF_DRVNAME) //分配设备号g_pAF_CharDrv = cdev_alloc(); //分配字符设备#define AF_DRVNAME "MAINAF"cdev_init(g_pAF_CharDrv, &g_stAF_fops); 初始化操作函数cdev_add(g_pAF_CharDrv, g_AF_devno, 1) //注册进系统,生成节点/dev/MAINAFactuator_class = class_create(THIS_MODULE, AF_DRIVER_CLASS_NAME);   //创建classvcm_device = device_create(actuator_class, NULL, g_AF_devno, NULL, AF_DRVNAME); //创建设备节点sys/bus/platform/drivers/lens_actuator_main_af4.AF_Ioctl,提供接口给上层使用
//lens的list
static stAF_DrvList g_stAF_DrvList[MAX_NUM_OF_LENS] = {#ifdef CONFIG_MTK_LENS_BU6424AF_SUPPORT{1, AFDRV_BU6424AF, BU6424AF_SetI2Cclient, BU6424AF_Ioctl, BU6424AF_Release},#endif
}switch (a_u4Command)case AFIOC_S_SETDRVNAME: //设置名字和把变量传入具体驱动i4RetValue = AF_SetMotorName((__user stAF_MotorName *)(a_u4Param));copy_from_user(&stMotorName , pstMotorName, sizeof(stAF_MotorName) //用户空间拷贝数据for (i = 0; i < MAX_NUM_OF_LENS; i++)if (strcmp(stMotorName.uMotorName, g_stAF_DrvList[i].uDrvName) == 0) //如果名字相同g_pstAF_CurDrv = &g_stAF_DrvList[i]; //设置当前设备g_pstAF_CurDrv->pAF_SetI2Cclient(g_pstAF_I2Cclient, &g_AF_SpinLock, &g_s4AF_Opened); //调用具体lens的pAF_SetI2CclientDW9714AF_SetI2Cclient //比如DW9714AF马达g_pstAF_I2Cclient = pstAF_I2Cclient;  //保存传进来的client指针,以后就可以在具体驱动中修改main_af的东西了g_pAF_SpinLock = pAF_SpinLock;g_pAF_Opened = pAF_Opened;  //open标志位default:i4RetValue = g_pstAF_CurDrv->pAF_Ioctl(a_pstFile, a_u4Command, a_u4Param); //调用具体驱动的ioctl四.具体AF驱动分析:DW9714AF为例DW9714AF.c (kernel-3.18\drivers\misc\mediatek\lens\common\dw9714af)
主要是ioctl分析
DW9714AF_Ioctlswitch (a_u4Command)case AFIOC_G_MOTORINFO: //获取一些信息,比如位置getAFInfo((__user stAF_MotorInfo *) (a_u4Param));case AFIOC_T_MOVETO:  //驱动到马达到具体位置i4RetValue = moveAF(a_u4Param); ret = s4AF_ReadReg(&InitPos); //单独分析1g_pstAF_I2Cclient->addr = AF_I2C_SLAVE_ADDR; case AFIOC_T_SETINFPOS: //设置AF的位置i4RetValue = setAFInf(a_u4Param);g_u4AF_INF = a_u4Position; /case AFIOC_T_SETMACROPOS: //设置AF最大的移动位置i4RetValue = setAFMacro(a_u4Param);g_u4AF_MACRO = a_u4Position; //单独分析1
ret = s4AF_ReadReg(&InitPos);g_pstAF_I2Cclient->addr = AF_I2C_SLAVE_ADDR;  //当前驱动的I2C地址g_pstAF_I2Cclient->addr = g_pstAF_I2Cclient->addr >> 1; i4RetValue = i2c_master_recv(g_pstAF_I2Cclient, pBuff, 2); /读写I2C

 


http://www.ppmy.cn/news/749223.html

相关文章

[MT6737] MTK 编译环境搭建

Hardware: MTK6737 Android: 6.0(API 23) Kernel: Linux 3.4.67 安装编译环境并编译 安装编译环境依赖包bootloader 和 kernel 编译Android 编译打包硬件参数 MTK6737Check SDK Version编译中碰到的问题 clang 问题STATIC_LIBRARIES SHARED_LIBRARIES 类型的问题烧录 安装编译环…

MT6737 datasheet资料介绍

MT6737 datasheet/规格书&#xff1a; MT6737 LTE Smartphone Application Processor Technical Brief 资料介绍 MT6737处理器概述&#xff1a; MT6737是一个集成了蓝牙、fm、wlan和gps模块的高度集成的基带平台&#xff0c;整合了调制解调器、应用程序处理和连接子系统以启…

MT6737芯片技术资料集锦下载

MT6737这款处理器现在还有人在做 1.MT6737_memory_QVL Discrete eMMC&#xff1a; 2. 6737_PCB_Design_Guidelines-English-V0_1 MT6737x_Design_Notice MT6737T_Dual_camera_Design_Notice MT6179_How_to_Configure_3G_TDD_RF_Custom_File MT6737x_MT6328_MT6169_MT6158_MT6…

MT6737m android7.0的FM,GPS,WIFI,BT不工作

原板子使用android5.0mtk6735&#xff0c;现在需要改为android7.0MT6737M&#xff0c;直接在原板子上把MT6735替代为MT6737m&#xff0c;配置好flash&#xff0c;LCM和tp,&#xff08;把sensor全部关闭了&#xff09;&#xff0c;开机后MT6625好像是没有工作起来&#xff0c;因…

[Android6.0][MTK6737] 启动流程分析

OS:Android6.0 Hardware:MTK6737 一、启动流程概览 1. BootRom 2. Preloader 3. LK 4. Kernel 5. Android 二、Bootloader 引导 2.1 preloader 启动过程 2.1.1 preloader 的功能 preloader 中的硬件部分 2.1.2 preloader 启动代码 2.2 LK 启动过程 2.2.1 LK 中的上电情景 2.…

MTK 6737 android6.0 user版本打开root权限(adb root权限和 apk root权限)

系列文章 MTK 6735/6739/6755/6763 android8.1 user版本打开root权限(adb root权限和 apk root权限) 相比较 android8.1 而言,6.0 的要简单很多 1、首先 6.0 不需要关闭 DM-verity,只需开发 adb root 后就能成功 remount,对 system 分区 rw 操作 2、6.0 无需添加在 init…

mtk android高级工具,Android6.0 MTK6737 DCT 工具介绍 · Younix’s Studio

8种机械键盘轴体对比 本人程序员&#xff0c;要买一个写代码的键盘&#xff0c;请问红轴和茶轴怎么选&#xff1f; OS:Android6.0 Hardware:MTK6737 [TOC] MTK 的 DCT Driver Customization Tool MTK 为 GPIO、I2C 等配置制作了一个工具叫做 DCT &#xff0c; 可以直接在 UI 里…

MTK6737功能展示

MT6737核心板处理器&#xff1a; QL168&#xff08;6737&#xff09; 具备低功耗特色的四核系统单芯片&#xff0c;是一款4G LTE 主要针对移动、联通、电信版本的全网通模块&#xff0c;SMT 封装。其性能稳定&#xff0c;外形紧凑&#xff0c;性价比高&#xff0c;功能强大&am…