MTK6735 camera 闪光灯Flashlight驱动调试流程学习

MTK6735 camera 闪光灯Flashlight驱动调试流程学习

一、Flash驱动涉及到的文件包含

kernel-3.10/drivers/misc/mediatek/flashlight/src/mt6735

├── constant_flashlight
│   ├── leds_strobe.c
│   └── Makefile
├── dummy_flashlight
│   ├── dummy_flashlight.c
│   └── Makefile
├── kd_flashlightlist.c
├── Makefile
├── out.txt
├── strobe_main_sid1_part2.c
├── strobe_main_sid2_part1.c
├── strobe_main_sid2_part2.c
├── strobe_part_id.c
├── strobe_sub_sid1_part2.c
├── strobe_sub_sid2_part1.c
├── strobe_sub_sid2_part2.c
└── sub_strobe.c

vendor/mediatek/proprietary/platform/mt6735/hardware/mtkcam/D2/core/featureio/drv/strobe

├── flashlight_drv.cpp
├── flashlight_drv.h
├── strobe_drv.cpp
├── strobe_global_driver.cpp
└── strobe_global_driver.h


vendor/mediatek/proprietary/platform/mt6735/hardware/mtkcam/D1/core/featureio/drv/strobe

├── flashlight_drv.cpp
├── flashlight_drv.h
├── strobe_drv.cpp
├── strobe_global_driver.cpp
└── strobe_global_driver.h


二、Flash驱动代码流程分析:

i.   kernel-3.10/drivers/misc/mediatek/flashlight/src/mt6735/ kd_flashlightlist.c

主要完成设备的注册和初始化。

1.注册一个平台设备:名为”kd_camera_flashlight”;

2.注册一个平台驱动,name和我们的devices name同名,这个名字主要用来和HAL层的name做匹配用;

3.对IOCTL的一个填充,供HAL调用;

4.做一个接口主要跟我们实际使用的Flash驱动对接,以kdFlashlightList罗列出来;

ii.  kernel-3.10/drivers/misc/mediatek/flashlight/src/mt6735/ constant_flashlight/leds_strobe.c

1.      这个文件就是我们实际性的使用的Flash驱动文件,从


/kernel-3.10/arch/arm64/configs/mtk6735_debug_defconfig:1035:CONFIG_CUSTOM_KERNEL_FLASHLIGHT=”constant_flashlight”


device/xxxxx/xxxxxx/ProjectConfig.mk:4: CUSTOM_KERNEL_MAIN_BACKUP_IMGSENSOR

 CUSTOM_KERNEL_FLASHLIGHT 

CUSTOM_KERNEL_SUB_IMGSENSOR 

CUSTOM_KERNEL_MAIN2_IMGSENSOR 

BOOT_LOGO


ProjectConfig.mk文件中CUSTOM_KERNEL_FLASHLIGHT配置获取具体使用的Flash驱动。

CUSTOM_KERNEL_FLASHLIGHT = constant_flashlight

如:

CUSTOM_HAL_FLASHLIGHT= constant_flashlight

CUSTOM_KERNEL_FLASHLIGHT = constant_flashlight

2.      该文件和kd_flashlightlist.c文件的对接函数为: 

323 MUINT32constantFlashlightInit(PFLASHLIGHT_FUNCTION_STRUCT *pfFunc)

3.      这个文件完成的任务是填充以下几个函数:

  1. FLASHLIGHT_FUNCTION_STRUCT  constantFlashlightFunc=  
  2. {  
  3.     constant_flashlight_open,  
  4.     constant_flashlight_release,  
  5.     constant_flashlight_ioctl  
  6. };  
 
 


4.      我们主要分析的是constant_flashlight_ioctl,以为这是跟HAL实际握手的接口。

vendor/mediatek/proprietary/platform/mt6735/hardware/mtkcam/D2/core/featureio/drv/strobe/flashlight_drv.cpp

这个文件完成的任务比较多,主要是一些类的实现和定义。

  1. FlashlightDrv::FlashlightDrv()  
  2. <span style=”white-space:pre”>    </span>  : StrobeDrv()  
  3.     , mUsers(0)  
  4.     , m_flashType((int)StrobeDrv::FLASHLIGHT_NONE)  
  5.   
  6.   
  7. {  
  8.     logI(”FlashlightDrv()\n”);  
  9.     m_isOn=0;  
  10.     m_duty=0;  
  11.     m_step=0;  
  12.     m_bTempInit=0;  
  13.     mDutyNum=0;  
  14.     mTurnOnTime=0;  
  15.     mOnDuty = -1;  
  16.   
  17.   
  18. }  
 
 

vendor/mediatek/proprietary/platform/mt6735/hardware/mtkcam/D2/hal/aaa/flash_mgr/flash_mgr.h:90:    

int cctFlashEnable(int senorDev, int en);

实现闪光灯模式的设置和获取、拍照/摄像预览的开启和终止、闪光灯设备的打开和关闭等等。

  1. void FlashMgr::setTorchOnOff(int en)    
  2. int  FlashMgr::setFlashMode(int mode)  
 


调用lash_mgr.cpp中的函数来给cct_feature.cpp提供接口。

  1. int FlashMgr::cctFlashEnable(int en)    
  2. {    
  3.    LogInfo(”cctFlashEnable(en=%d) line=%d”,en,__LINE__);    
  4.     if(en==1)    
  5.    {    
  6.        setFlashMode(FLASHLIGHT_FORCE_ON);    
  7.     }    
  8.    else    
  9.     {    
  10.        setFlashMode(FLASHLIGHT_FORCE_OFF);    
  11.     }    
  12.     return 0;    
  13. }    
  

vendor/mediatek/proprietary/platform/mt6735/hardware/mtkcam/D1/acdk/src/cct/if/cct_if.cpp:378:

调用flash_cct.cpp中的函数,并以IOCTL的形式进行封装,供更上一层次调用。具体的没有在继续跟下去,有兴趣的话,可以再往上分析分析。

  1. INT32 CctImp::aaaCCTFeatureControl    
  2.     case ACDK_CCT_OP_FLASH_ENABLE:    
  3.        err = FlashMgr::getInstance()->cctFlashEnable(1); //YosenFlash    
  4.         break;    
  5.     case ACDK_CCT_OP_FLASH_DISABLE:    
  6.        err = FlashMgr::getInstance()->cctFlashEnable(0); //YosenFlash  
 
 


猜你喜欢

转载自blog.csdn.net/qq_38500662/article/details/80610934