一、骁龙相机启动流程分析
1. 相机启动阶段关键TAG
关键字 | 解释 |
---|---|
deliverInputEvent | 点击事件 |
bindApplication | App 冷启动 创建application |
activityStart | 创建camera activity |
activityResume | camera UI界面开始显示 |
connectDevice | cameraFWK 开始链接并open sensor |
CameraHal::openSession | Camera FWK 响应 opencamera |
camera_module->open | HAL 响应 opencamera |
HAL3Open | HAL 开始准备opencamera |
constructDefaultRequestSettings | 获取Camera request setting 比如一下metadata等 |
createStream | 创建配流信息,可以查看配几路流 |
endConfigure | 配流结束 |
CameraHal::configureStreams | Camera FWK 配流阶段常用搜索关键字 |
HAL3ConfigureStreams | Camera HAL 配流阶段常用关键字 |
AdvancedCameraUsecase::Initialize | chi usecase 初始化 |
submitRequestList,setRepeatingRequests | 发起预览请求 |
CameraHal::processBatchCaptureRequests | 下发预览请求 |
HAL3ProcessCaptureRequest | camera HAL 响应第0帧预览请求 |
CSLStreamOn,KMDStreamON: DevType20 | sensor 开始streamon |
HAL3ProcessCaptureRequest : 1 | Camera HAL 响应第一次预览请求 |
Stream 0: first full buffer | Camera FWK接收到返回第一帧 |
SurfaceView[org.codeaurora.snapcam/com.android.camera.CameraLauncher]#1(BLAST Consumer)1 | Camera app 接收第一帧 |
BufferTX - SurfaceVieworg.codeaurora.snapcam/com.android.camera.CameraLauncher#529 | Surfaceflinger bufferTX 用来存储buffer 供SF 消费 |
VSYNC-sf | SF 开始绘制处理,对应的BufferTX - 1 |
prepareFrame | SF开始预处理帧 |
HwcPresentOrValidateDisplay | SF 与HWC进行通信验证显示 |
postComposition Last HWVsyncHint | post 显示合成结果 |
presentFence fence 155,waiting for presentFence 155,REThreaded::mapExternalTextureBuffer | 上屏显示(SF不太熟大致是这个时候屏幕可以显示处理) |
2. 相机启动阶段拆解
阶段 | 模块 | 关键字 | 备注 |
---|---|---|---|
S0 | system | deliverInputEvent---> ZygoteInit之前 app 开始running的地方 | 创建 camera app |
S1 | APP | app 开始running的地方--->connectDevice 开始 | Camera App 开始请求openCamera |
S2 | Camera HAL | connectDevice | HAL 处理open camera 操作 |
S3 | Camera APP、FWK | connectDevice 结束--->CameraHidlHal::constructDefaultRequestSettings-->createStream-->endConfigure start | 请求配流 |
S4 | Camera HAL | CameraHal::configureStreams | Camera HAL 响应配流 |
S5 | Camera APP | CameraHal::configureStreams 结束 -->submitRequestList、setRepeatingRequests | 请求预览 |
S6 | Camera HAL | submitRequestList、setRepeatingRequests--> first full buffer | Camera HAL 返回第一帧 |
S7 | SF | first full buffer-->上屏显示 | SF送显阶段 |
3. 相机启动阶段概览
相机启动阶段概览
4. 相机启动阶段详解
S0 :Launcher 点击Camera Icon 响应事件到Camera app 创建
S0 :Launcher 点击Camera Icon 响应事件到Camera app 创建
S1: Camera APP UI 创建 到 OpenCamera 开始
S1: Camera APP UI 创建 到 OpenCamera 开始
S2 Camera HAL 响应 opencamera
S2 : Camera HAL 响应 opencamera
S3:APP开始下发请求配流
S3:APP开始下发请求配流
对应log中创建的2路流如下:
Line 10538: 06-19 18:09:04.173 1907 3718 I CameraDeviceClient: createStream : stream size is 960 x 720Line 10543: 06-19 18:09:04.180 1907 3718 I CameraDeviceClient: createStream : stream size is 4608 x 3456
S4: Camera HAL 响应配流
S4: Camera HAL 响应配流
S5:请求预览 startpreview
S5:请求预览 startpreview
S6: Camera HAL callback 首帧请求结果
S6: Camera HAL callback 首帧请求结果
6.1 一帧callback流程
一帧数据传输通过Binder 进行
Camera HAL: HAL3ProcessCaptureResult
--->
Camera FWK: processCaptureResult
--->
Camera App: onFrameAvaillable
--->
SF: SurfaceView +1
SF: BufferTX SurfaceView +1
SF:QueueBuffer +1
一帧callback流程
S7: Surface 送显上屏阶段
- App queuebuffer 后SurfaceView +1
- Vsync-sf 到来后SF 从BufferQueue中取出app 送显帧进行消费合成
SF跟HWC通过bind通信后,调用postComposition Last HWVsyncHint ,在对应 presentFence fence 到来后,调用SF的REThreaded::mapExternalTextureBuffer 开始上屏显示(非display研发,待理清上屏显示的真正时间)
Surface 送显上屏阶段