1. 程式人生 > 其它 >高通Camera驅動(2)-- initialize

高通Camera驅動(2)-- initialize

技術標籤:高通 Cam Hal 3androidc++

前面回顧

簡單介紹Camx架構,接下來看下initialize流程

一、initialize 流程

1.1 原文解讀


* 1. Framework calls camera_module_t->common.open(), which returns a
* hardware_device_t structure.
*
* 2. Framework inspects the hardware_device_t->version field, and instantiates
* the appropriate handler for that version of the camera hardware device. In

* case the version is CAMERA_DEVICE_API_VERSION_3_0, the device is cast to
* a camera3_device_t.
*
* 3. Framework calls camera3_device_t->ops->initialize() with the framework
* callback function pointers. This will only be called this one time after
* open(), before any other functions in the ops structure are called.

1、開啟相機:framework這塊呼叫common結構體的方法,camera_module_t-> common.open(),在hw_module_methods_t這塊的open你的方法來開啟特定 Camera,返回一個的 hardware_device_t結構。
2、檢查裝置硬體版本,併為之例項化:framework檢查hardware_device_t-> version欄位,併為該版本的相機硬體裝置例項化適當的處理程式。 如果版本為CAMERA_DEVICE_API_VERSION_3_0,則裝置將投射到的camera3_device_t。
3、初始化:在open()之後,ops結構中的任何其他函式之前,只調用一次initialize。framework使用framework回撥函式指標呼叫1camera3_device_t-> ops->camera3_device_ops的 initialize()。

1.2 官網文件

《80-pc212-1_a_chi_api_specifications_for_qualcomm_spectra_2xx_camera.pdf》簡單介紹初始化驅動的過程

1.3 程式碼分析

程式碼分析這塊直接從camxhal3entry.cpp 開始擼程式碼。Framework到HAL3的銜接在上一篇文章概述了Framework和HAL3之間概述

int open(
    const struct hw_module_t*   pHwModuleAPI,
    const char*                 pCameraIdAPI,
    struct hw_device_t**        ppHwDeviceAPI)
{
    /// @todo (CAMX-43) - Reload Jumptable from settings
    JumpTableHAL3* pHAL3 = static_cast<JumpTableHAL3*>(g_dispatchHAL3.GetJumpTable());

    CAMX_ASSERT(pHAL3);
    CAMX_ASSERT(pHAL3->open);

    return pHAL3->open(pHwModuleAPI, pCameraIdAPI, ppHwDeviceAPI);
}

//TODO:回家吃飯,小夥子明天再搞