高通 Camx openCamera 流程学习笔记

教育   2024-07-06 19:56   上海  

和你一起终身学习,这里是程序员Android

经典好文推荐,通过阅读本文,您将收获以下知识点:

1. open 阶段log

// connect call
06-26 12:24:01.054 1377 4534 I CameraService: CameraService::connect call (PID 5119 "com.android.camera", camera ID 0) and Camera API version 2
//FWK 调用open
06-26 12:24:01.065 1377 4534 I Camera2ClientBase: Camera 0: Opened. Client:
//HAL 开始open
06-26 12:24:01.066 954 954 I CamX : [CONFIG][HAL ] camxhal3.cpp:524 open() HalOp: Begin OPEN, logicalCameraId: 0, cameraId: 0
//perflock open camera 提频
06-26 12:24:01.066 954 954 I CHIUSECASE: [INFO ] chxperf.cpp:316 AcquirePerfLock() Acquire perflock type: 0
06-26 12:24:01.066 954 954 I CHIUSECASE: [INFO ] chxextensionmodule.cpp:892 ExtendOpen() Open Logical cameraId: 0 numPhysicalCameras: 1CameraOpen Mask = 0x1 CameraClose Mask 0x0 maxresourceCost 100
06-26 12:24:01.066 954 954 I CamX : [CONFIG][HAL ] camxhal3module.cpp:675 ProcessCameraOpen() number of Camera Opened 1
06-26 12:24:01.068 954 954 I CamX : [ INFO][HAL ] camxhal3.cpp:542 open() Open: overrideCameraClose is 0 , overrideCameraOpen is 1
//load so
06-26 12:24:01.079 954 954 V CamX : [ VERB][HAL ] camxhaldevice.cpp:169 AddLibNode() Added the lib into the list-libOpenCL.so
06-26 12:24:01.079 954 954 I CHIUSECASE: [INFO ] chxextensionmodule.cpp:1136 GetCameraIdIndex() AppId => LogicalId:0 => 0
06-26 12:24:01.079 954 954 I CamX : [ INFO][HAL ] camxhaldevice.cpp:1636 ConstructDefaultRequestSettings() Override specific tags added to construct default settings
//hal open end
06-26 12:24:01.080 954 954 I CamX : [CONFIG][HAL ] camxhal3.cpp:586 open() HalOp: End OPEN, logicalCameraId: 0, cameraId: 0

2. open 阶段trace

3.Camera3Devices 初始化并下发opensession

framework/av/service/camera/libcameraservices/device3/Camera3Devices.cpp

Camera3Devices.cpp 初始化的时候 调用 initalize–> CameraProviderManager.cpp openSession 向下传递open camera session

4.CameraProviderManger 响应OpenSession

framework/av/service/camera/libcameraservice/common/CameraProviderManager.cpp

在响应 openSession 时候会调用 ICameraDevice 的 open

5.CameraDevice.cpp Open

hardware/interface/camera/device/3.2/default/CameraDevice.cpp

Camera FWK 通过HIDL 跟Camera HAL 通信,调用camera_module open 方法

6.camera_module open

hardware/interface/camera/common/1.0/default/CameraModule.cpp

Camera FWK 通过 HIDL 调用到 camera_module open ,然后通过camera_module_t 跳转调用到camxhal3entry.cpp open

camera_module_t 会调用 camxhal3entry.cpp的入口点

7.camera_module open 对应的trace

8.camxhal3entry.cpp HAL3Open

camx/src/core/hal/camxhal3entry.cpp

camxhal3entry.cpp open 入口

camxhal3entry.cpp open 通过JumpTAbleHAL3 调用camxhal3.cpp open

9.CamxHal3.cpp open

camx/src/core/hal/camxhal3.cpp

通过 声明在 camxhal3.h 中的 JumpTableHAL3 指针 跳转到CamxHal3.cpp open 函数
camxhal3.cpp open–> 调用camxhal3module.cpp processCameraOpen方法

10.camxhal3module.cpp processCameraOpen

camx/src/core/hal/camxhal3module.cpp

通过 camxhal3.cpp open–> 调用camxhal3module.cpp processCameraOpen, 接着调用 chiextensioninterface.cpp chi_extend_open

CHI HAL entry

chi hal overrride entry

11.chiextensioninterface.cpp chi_extend_open

chi-cdk/core/chiframework/chiextensioninterface.cpp

chi_extend_open 调用chxextensionmodule.cpp ExtendOpen

12.chxextensionmodule.cpp extendopen

chi-cdk/core/chiframework/chxextensionmodule.cpp

申请perf lock open camera,进行提频率操作,并返回camera open 状态 ,这个时候processCameraOpen 执行完毕,返回到camxhal3.cpp 的open 函数继续执行。

13.camxhal3.cpp open HAlDevice create

camx/src/core/hal/camxhal3.cpp

open 调用camxhaldevice.cpp HAlDevice create 加载open 阶段的一些 静态 so

14.camxhaldevice.cpp Create —>Initialize–>loadStaticlibs–> libmap , addlibnode 加载so

camx/src/core/hal/camxhaldevice.cpp
加载静态 so


这个几个so 会影响open 阶段的启动速度,一般会添加到pinfile 中开机加载,然后返回camerahal3.cpp open 继续。

15.HalDevice create 对应的trace

16.camerahal3.cpp open callback

最后一个框里,ppHwDeviceAPI丢给上层,一路返回到

camx/src/core/hal/camxhal3.cpp

17.CameraDevice.cpp createsession

Camera FWK HAL 通过HIDL 通信

hardware/interface/camera/device/3.2/default/CameraDevice.cpp

18.CameraDevice.cpp 创建CameraDeviceSession

hardware/interface/camera/device/3.2/default/CameraDevice.cpp

经历了这么多创造出来的device对象,用于创建CameraDeviceSession

接下来的调用就和上述过程类似了,从provider又到Camx

19.CameraDeviceSession.cpp CameraDeviceSession 实现

\hardware\interfaces\camera\device\3.2\default\CameraDeviceSession.cpp

调用CameraDeviceSession.cpp init

20.camxhal3entry.cpp init

\vendor\qcom\proprietary\camx\src\core\hal\camxhal3entry.cpp

21.camxhal3.cpp init

\vendor\qcom\proprietary\camx\src\core\hal\camxhal3.cpp

22.HAL3Initialize trace

23. openCamera 总体流程图


参考文章:
https://cloud.tencent.com/developer/article/2134685

参考文献:

【腾讯文档】Camera学习知识库https://docs.qq.com/doc/DSWZ6dUlNemtUWndv

至此,本篇已结束。转载网络的文章,小编觉得很优秀,欢迎点击阅读原文,支持原创作者,如有侵权,恳请联系小编删除,欢迎您的建议与指正。同时期待您的关注,感谢您的阅读,谢谢!

点击阅读原文,为大佬点赞!

程序员Android
这是一个专注提供 Java Android 知识体系服务的公众号。 和你一起终身学习,小安愿做你成长道路上的垫脚石,不断垫高你的高度,衬托你的威仪。 风里雨里,我们一直在 Java Android 学习的路上支持你!
 最新文章