MTK camera 闪光灯Flashlight驱动调试流程

来源:互联网 发布:java经纬度转换度分秒 编辑:程序博客网 时间:2024/05/20 07:14

Camera Flash 驱动分析

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

mediatek /custom/common/kernel/flashlight/src/kd_flashlightlist.c

mediatek /custom/huaqin_bsp/at808p/base/kernel/flashlight/constant_flashlight/leds_strobe.c

mediatek /platform/mt6592/hardware/mtkcam/core/featureio/drv/strobe/flashlight_drv.cpp

mediatek/platform/mt6592/hardware/mtkcam/core/featureio/pipe/aaa/flash_mgr/flash_mgr.cpp

mediatek/platform/mt6592/hardware/mtkcam/core/featureio/pipe/aaa/flash_mgr/flash_cct.cpp

mediatek/platform/mt6592/hardware/mtkcam/acdk/src/cct/if/cct_feature.cpp

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

i.             mediatek /custom/common/kernel/flashlight/src/kd_flashlightlist.c

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

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

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

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

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

ii.             mediatek/custom/huaqin_bsp/at808p/base/kernel/flashlight/constant_flashlight/leds_strobe.c

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

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

如:

CUSTOM_HAL_FLASHLIGHT= constant_flashlight

CUSTOM_KERNEL_FLASHLIGHT = constant_flashlight

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

323 MUINT32constantFlashlightInit(PFLASHLIGHT_FUNCTION_STRUCT *pfFunc)

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

[cpp] view plaincopyprint?在CODE上查看代码片派生到我的代码片
  1. 315FLASHLIGHT_FUNCTION_STRUCT constantFlashlightFunc=  
  2. 316{   
  3. 317     constant_flashlight_open,  
  4. 318     constant_flashlight_release,  
  5. 319     constant_flashlight_ioctl  
  6. 320 };  

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

 

iii.             mediatek/platform/mt6592/hardware/mtkcam/core/featureio/drv/strobe/flashlight_drv.cpp

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

[cpp] view plaincopyprint?在CODE上查看代码片派生到我的代码片
  1. 825 intFlashlightDrv::setFlashlightModeConf(unsigned long a_strobeMode)  
  2. 897 intFlashlightDrv::setCaptureFlashlightConf(unsigned long a_strobeWidth)  
  3. 952 intFlashlightDrv::setCaptureDelay(unsigned int value)  
  4. 1021 intFlashlightDrv::getDuty(int* duty)  
  5. 1090 intFlashlightDrv::lowPowerDetectEnd(int* isLowPower)  

主要是为flash_mgr.cpp提供接口。

                      

iv.             mediatek/platform/mt6592/hardware/mtkcam/core/featureio/pipe/aaa/flash_mgr/flash_mgr.cpp

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

[cpp] view plaincopyprint?在CODE上查看代码片派生到我的代码片
  1. 1479 void FlashMgr::setTorchOnOff(int en)  
  2. 2276 intFlashMgr::setFlashMode(int mode)  

v.             mediatek/platform/mt6592/hardware/mtkcam/core/featureio/pipe/aaa/flash_mgr/flash_cct.cpp

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

[cpp] view plaincopyprint?在CODE上查看代码片派生到我的代码片
  1. 128 int FlashMgr::cctFlashEnable(int en)  
  2. 129 {  
  3. 130    LogInfo("cctFlashEnable(en=%d) line=%d",en,__LINE__);  
  4. 131     if(en==1)  
  5. 132     {  
  6. 133        setFlashMode(FLASHLIGHT_FORCE_ON);  
  7. 134     }  
  8. 135     else  
  9. 136     {  
  10. 137        setFlashMode(FLASHLIGHT_FORCE_OFF);  
  11. 138     }  
  12. 139     return 0;  
  13. 140 }  

vi.             mediatek/platform/mt6592/hardware/mtkcam/acdk/src/cct/if/cct_feature.cpp

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

[cpp] view plaincopyprint?在CODE上查看代码片派生到我的代码片
  1. MINT32 CctImp::aaaCCTFeatureControl  
  2. 361    case ACDK_CCT_OP_FLASH_ENABLE:  
  3. 362        err = FlashMgr::getInstance()->cctFlashEnable(1); //YosenFlash  
  4. 363        break;  
  5. 364    case ACDK_CCT_OP_FLASH_DISABLE:  
  6. 365        err = FlashMgr::getInstance()->cctFlashEnable(0); //YosenFlash  

 

0 0
原创粉丝点击