高通camera驅動詳解 總綱 (一)

        想寫一份關於qualcomm 平臺 的camera driver 的文檔 ,想講清楚 camera 各個 module 和 camera sensor的各個sub module。

        無論是 camx 還是 mm-camera 結構, 無論是android O 還是 N 東西就那麼多,就不同的寫法和實現,萬變不離其宗。他強由他強,清風拂山崗。一理通百里用說的就是這個道理。目前下面的是基於mm-camera的學習。有啥不對的,歡迎指正。會持續更新。

 主進程 [email protected] 主要調用的庫有:

              camera hal庫 camera.<平臺>.so ,如:高通的camera.qcom.so 在設備 vendor/lib/hw 目錄下。

              camera 各個submodule庫。

              備註:老版的框架調用的是mm-qcamera-deamon。

大致框架有2種:

1. camx 代碼需要高通平臺權限下載後放置 vendor 目錄下 chi-cdk 同級目錄即可。camx (沒看過,待完善)對應hal,編譯生成camera.qcom.so

  chi-cdk 目錄下主要爲各個module,eeprom sensor chromatix等主要都是通過配置xml實現的功能。吐槽:修改起來很麻煩

2. mm-camera 代碼結構,主要調用的庫 libmmcamera2_mct_shimlayer.so 入口函數 mct_shimlayrt_process_module_init 注意看函數註釋:this function is the direct call from HAL to init all the modules present in backend.

mct_shimlayrt_module_sensor_init
mct_shimlayrt_module_init

 Old 2. 老版本mm-camera  主進程 mm-qcamera-deamon  main函數所在 server.c  server process 。(2和old2的區別及優點每個overview都重複描述,以後補充)

mm-camera 結構

    |- mct——應該就是camera的引擎 裏面包含了引擎、pipiline、bus、module、stream及event等定義及封裝。

    |- modules ——  這裏面就是劃分好的一些模塊代碼,各模塊大致功能如下 :

        |- sensor  ——  sensor 的驅動模塊(src模塊)

        |- iface     ——  ISP interface模塊(inter模塊)

        |- isp        —— 主要是ISP的處理,其內部又包含了衆多的模塊(inter模塊)

        |- stats    —— 一些統計算法模塊,如3A,ASD,AFD,IS,GRRO等數據統計的處理(sink模塊)

        |- pproc   —— post process處理(inter模塊)

        |- imglib   —— 主要是圖片的一些後端處理,如HDR等(sink模塊)

以上各模塊內部又包含了衆多的模塊,具體需要看代碼分析。

將camera的所有功能劃分爲不同的模塊,讓模塊自己來決定自己的事情(高內聚,低耦合),模塊需要有統一的接口和格式。模塊中有端口,通過端口把模塊連接起來,又把模塊掛在總線上。每一個端口的連接就是一個流,把這些流用pipeline來管理。每次啓動一個camera就創建一個會話,由這個會話來管理此camera的一切事物。對於每一個會話,模塊是共享的,它可以是camera的硬件資源也可以是其它資源(如一些軟件算法等資源)。

 

module_list:

  • module_sensor_init << sensor module
  • module_iface_init
  • module_isp_init
  • stats_module_init
  • pproc_module_init
  • module_imglib_init

sensor module  (正題) /mmcamera/mm-camera2/media-controller_modules/sensors

sensor模塊是衆多模塊中的一個,主要是由模組的各個硬件模塊組成,包括sensor、Flash、Af、EEprom、OIS、CSI、ir_cut、ir_led 等。這個模塊主要描述了模組硬件的一些工作原理及部分驅動相關部分。sensors目錄及子目錄下的每個module文件夾包含的都是當前目錄的功能實現。

   在前面講到的server process 或者 mct shimlayer 中提到,調用開始後會初始化各個模塊,其中就包括sensor模塊,sensor初始化入口函數即爲module_sensor_init(...)。這個函數將創建sensor模塊並返回其指針,另外將創建它的端口,填充一些功能函數等。它的主要執行流程如下:

    1.創建sensor的MCT module。  —— mct_module_create(name)

        創建完之後填充set mode、query mode、start session、stop session及set session data五個接口函數。

    2.創建module_sensro_ctrl_t結構體,此結構體包含bundle信息,用來構建前面提到的模塊樹(方便添加、遍歷等操作)。

    3.sensor模塊是source模塊,所以其numsinkports應該設置爲0。

    4.eebin相關的操作  << eebin_interface_init

    5.sensor的probe操作,用來probe有效的sensor。

    6.填入所有已probe到sensor的信息。 << sensor_init_probe

    7.填入所以sensor的其它信息(Actuator,Flash,CSID,OIS等)module_sensor_find_other_subdev

    8.初始化sensor模塊。 <<  module_sensor_subinit(初始化子模塊函數列表)

    9.創建基於CID info的端口 port_sensor_create

    10.初始化eeprom module_sensor_init_eeprom

          (1)open the eeprom sub module

         (2)load eeprom library   

         (3)powerup and parse the eeprom

         (4)read the eeprom data from kernel

        (5)format the cal data

        (6)close the eprom sub module

   11.創建chromatix的管理 module_sensor_init_chromatix

 

sub_module_init << 下列是每個子模塊

  • sensor_sub_module_init << sensor/module/sensor.c (camera sensor driver)
  • chromatix_sub_module_init
  • actuator_sub_module_init
  • eeprom_sub_module_init << eeprom/module/eeprom.c (eeprom driver)
  • led_flash_sub_module_init
  • csiphy_sub_module_init
  • csid_sub_moduLe init 
  • ois_ sub_module_init
  • external_sub_module_init
  • ir_led_sub_module_init
  • ir_cut_sub_module_init
  • laser_led_sub_module_init 

 

 

 

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章