MTK Camera process_capture_request 流程
0、前文回顾
简单看下之前的camera3.h中configureStream的原文:
The framework calls camera3_device_t->ops->configure_streams() with a list * of input/output streams to the HAL device.
framework调用camera_device方法ops调用camera3_device_ops的configure_streams方法配流,camera3_device_t-> ops-> configure_streams(),并把input stream&output stream 的列表作为参数送到Hal层。
The framework allocates gralloc buffers and calls camera3_device_t->ops->register_stream_buffers() for at least one of the * output streams listed in configure_streams. The same stream is registered * only once
注册流buffer:
framework分配gralloc buffer和在configure_streams中,调用camera_device方法ops调用camera3_device_ops的register_stream_buffers方法注册stream buffer,camera3_device_t-> ops-> register_stream_buffers()至少有一个输出流。 同一流仅注册一次。没有调用camera3_device_t-> ops-> register_stream_buffers(),并且必须为NULL。
The framework requests default settings for some number of use cases with * calls to camera3_device_t->ops->construct_default_request_settings(). This * may occur any time after step 3.
配置默认请求:
可能在步骤3之后的任何时间发生,framework通过调用camera_device方法ops调用camera3_device_ops的construct_default_request_settings方法配置默认请求,camera3_device_t-> ops-> construct_default_request_settings。
1、camera process_capture_request 流程
1.1 原文分析
The framework constructs and sends the first capture request to the HAL, with settings based on one of the sets of default settings, and with at least one output stream, which has been registered earlier by the framework. This is sent to the HAL with camera3_device_t->ops->process_capture_request(). The HAL must block the return of this call until it is ready for the next request to be sent. The buffer_handle_t provided in the camera3_stream_buffer_t array in the camera3_capture_request_t may be new and never-before-seen by the HAL on any given new request.
在使用默认设置中的一组设置和至少一个输出流(已由Framework较早注册),framework构造并向HAL发送第一个捕获请求。framework调用 camera_device方法ops调用camera3_device_ops的process_capture_request开始下发request请求,通过camera3_device_t-> ops-> process_capture_request()发送到HAL。 在准备好发送下一个request前,HAL必须返回此调用。 在camera3_capture_request_t的camera3_stream_buffer_t数组中提供的buffer_handle_t可能是新的,而且在任意给的request中,HAL层都没见这个buffer_handle_t。
1.2 结构体
1.3 代码分析
hardware/interfaces/camera/device/3.2/default/CameraDeviceSession.cpp
Return<void> CameraDeviceSession::processCaptureRequest(
const hidl_vec<CaptureRequest>& requests,
const hidl_vec<BufferCache>& cachesToRemove,
ICameraDeviceSession::processCaptureRequest_cb _hidl_cb) {
updateBufferCaches(cachesToRemove);
for (size_t i = 0; i < requests.size(); i++, numRequestProcessed++) {
s = processOneCaptureRequest(requests[i]);
}
Status CameraDeviceSession::processOneCaptureRequest(const CaptureRequest& request) {
...ATRACE_ASYNC_BEGIN("frame capture", request.frameNumber);
ATRACE_BEGIN("camera3->process_capture_request");
status_t ret = mDevice->ops->process_capture_request(mDevice, &halRequest);
ATRACE_END();...
}
下面的代码明天贴出来 //TODO
下面三个分别是构建defaultRequest配置、获取captureRequest/ResultMetaQueue、request流程
2、log
3、结语
代码熟练度还不够溜,MTK Code细节不够火候,还需继续深入。我会不定期分享,以便查漏补缺,相互学习。奥里给!!!