Android Q 之MTK代码分析(六)--Camera Hal3 process_capture_result

码字不易,多谢支持

MTK Camera process_capture_result 流程
《Android Q 之MTK代码分析(一)--Camera Hal3 Service》
《Android Q 之MTK代码分析(二)--Camera Hal3 Search Sensor》
《Android Q 之MTK代码分析(三)--Camera Hal3 Open/Close》
《Android Q 之MTK代码分析(四)--Camera Hal3 configure_Streams》
《Android Q 之MTK代码分析(五)--Camera Hal3 process_capture_request》
《Android Q 之MTK代码分析(六)--Camera Hal3 process_capture_result》
0、前文回顾
 简单看下之前的camera3.h中request之后,result之前的原文

The framework continues to submit requests, and call * construct_default_request_settings to get default settings buffers for * other use cases. 

<= CAMERA_DEVICE_API_VERSION_3_1:

The framework may call register_stream_buffers() at this time for * not-yet-registered streams.

framework继续提交请求,并调用Construct_default_request_settings获取默认设置缓冲区其他use cases。

API3.1->framework此时可以调用                  

register_stream_buffers()来尚未注册的流。

When the capture of a request begins (sensor starts exposing for the  capture) or processing a reprocess request begins, the HAL  calls camera3_callback_ops_t->notify() with the SHUTTER event, including  the frame number and the timestamp for start of exposure. For a reprocess  request, the timestamp must be the start of exposure of the input image  which can be looked up with android.sensor.timestamp from  camera3_capture_request_t.settings when process_capture_request() is  called. 

<= CAMERA_DEVICE_API_VERSION_3_1: 

This notify call must be made before the first call to  process_capture_result() for that frame number.

>= CAMERA_DEVICE_API_VERSION_3_2: 

The camera3_callback_ops_t->notify() call with the SHUTTER event should be made as early as possible since the framework will be unable to  deliver gralloc buffers to the application layer (for that frame) until  it has a valid timestamp for the start of exposure (or the input image's  start of exposure for a reprocess request).  Both partial metadata results and the gralloc buffers may be sent to the  framework at any time before or after the SHUTTER event.

在开始捕获请求时(Sensor开始暴露于 Capture)或者开始处理重处理请求时,HAL使用SHUTTER事件和包括帧号和开始曝光的时间戳,调用camera3_callback_ops_t-> notify()。 对于重新处理请求,时间戳必须是输入图像曝光的开始,当调用process_capture_request()后,查看时间戳在camera3_capture_request_t.settings中android.sensor.timestamp。

     API3.1->  对于同帧率来说,来自Hal的camera3_callback_ops的notify()方法必须在 process_capture_result()之前调用

     API3.2->  对于带有SHUTTER事件的camera3_callback_ops_t-> notify()应该尽快调用,因为framework具有有效的时间戳记以开始曝光( 或针对重新处理请求的输入图像的曝光开始)才能将为应用程序层(针对该帧)传递gralloc缓冲区。

After some pipeline delay, the HAL begins to return completed captures to  the framework with camera3_callback_ops_t->process_capture_result(). These  are returned in the same order as the requests were submitted. Multiple  requests can be in flight at once, depending on the pipeline depth of the  camera HAL device.

经过一些pipeline延迟之后,HAL开始使用camera3_callback_ops返回处理后Capture给framewrok, camera3_callback_ops_t->process_capture_result()。返回的顺序与提交请求的顺序相同。根据camera HAL设备的pipeline深度,可以同时处理多个request。1、camera process_capture_result 流程
    1.1、原文分析

After some pipeline delay, the HAL begins to return completed captures to  the framework with camera3_callback_ops_t->process_capture_result(). These  are returned in the same order as the requests were submitted. Multiple  requests can be in flight at once, depending on the pipeline depth of the  camera HAL device. 

>= CAMERA_DEVICE_API_VERSION_3_2:

 Once a buffer is returned by process_capture_result as part of the  camera3_stream_buffer_t array, and the fence specified by release_fence  has been signaled (this is a no-op for -1 fences), the ownership of that  buffer is considered to be transferred back to the framework. After that,  the HAL must no longer retain that particular buffer, and the  framework may clean up the memory for it immediately.  process_capture_result may be called multiple times for a single frame,  each time with a new disjoint piece of metadata and/or set of gralloc  buffers. The framework will accumulate these partial metadata results  into one result.  In particular, it is legal for a process_capture_result to be called  simultaneously for both a frame N and a frame N+1 as long as the  above rule holds for gralloc buffers (both input and output).

经过一些pipeline延迟之后,HAL开始使用结构体3.3camera3_callback_ops返回处理后Capture给framewrok, camera3_callback_ops_t->process_capture_result()。返回的顺序与提交请求的顺序相同。根据camera HAL设备的pipeline深度,可以同时处理多个request。

     API3.2-> 

(1)一旦process_capture_result返回buffer作为camera3_stream_buffer_t数组,release_fence指定的栅已经被触发(这是-1栅的无操作),该buffer的所有权被认为已转移回framework。之后,HAL必须不再保留该特定buffer,并且framework可以立即为其清除内存。(2)对于单个帧,  每次带有新的不相交的元数据和或一套gralloc  buffer,可以多次调用process_capture_result. (3)framework会将这些部分元数据result合并为一个result。 特别是,只要上述规则对于gralloc buffer(输入和输出)均成立,则同时为帧N和帧N + 1调用process_capture_result是合法的。

    1.2、结构体
      

 

 

typedef struct camera3_capture_result {
 
    uint32_t frame_number;
    const camera_metadata_t *result;
    uint32_t num_output_buffers;
    const camera3_stream_buffer_t *output_buffers;
    const camera3_stream_buffer_t *input_buffer;   
    uint32_t partial_result;  
    uint32_t num_physcam_metadata;
    const char **physcam_ids;
    const camera_metadata_t **physcam_metadata;
 
} camera3_capture_result_t;


1.3、代码分析
//TODO

2、log

08-26 11:30:39.054150  4145  4253 D mtkcam-AppStreamMgr: [updateResult] User 0x1 of requestNo 0, real time:0, last partial:0
08-26 11:30:39.054200  4145  4253 D mtkcam-AppStreamMgr: [updateResult] Logical Meta 0: size = 107

08-26 11:30:39.058541  4145  4219 D mtkcam-AppStreamMgr: [0-CallbackHandler::convertCallbackParcelToHidl] requestNo:0 shutter:514216159000 o:meta#:1
08-26 11:30:39.058570  4145  4219 D mtkcam-AppStreamMgr: [0-CallbackHandler::convertCallbackParcelToHidl]     OUT Meta  -
08-26 11:30:39.058587  4145  4219 D mtkcam-AppStreamMgr: [0-CallbackHandler::convertCallbackParcelToHidl]         streamId:10000001f partial#:1 App:Meta:DynamicP1_main1
08-26 11:30:39.058666  4145  4218 D mtkcam-AppStreamMgr: [0-CallbackHandler::performCallback] requestNo:0 shutter:514216159000 o:meta#:1
08-26 11:30:39.059673  4145  4223 D NormalPipe: [acceptEnqRequest] MyEnq:0: dma:0x8 pa(0xAB00000)io(0_0_4208_3120_1920_1424) mag(0x4)|dma:0x6 pa(0x1CD00000)io(0_0_4208_3120_4208_3120) mag(0x4)|dma:0xf pa(0x10F00400)io(0_0_256_1_256_1) mag(0x4)|dma:0xb pa(0x5400000)io(0_0_384_384_384_384) mag(0x4)|
08-26 11:30:39.059684  4145  4267 D isp_mgr_sl2: DIP_X_SL2H_RZ is (SL2_VRZ_COM, SL2_HRZ_COM) = (4487, 4488), (i4RzWidth, i4Width) = (1920, 4208), (i4RzHeight, i4Height) = (1424, 3120)
08-26 11:30:39.059698  4145  4218 D mtkcam-AppStreamMgr: [0-CallbackHandler::performCallback] -

这块是一个轮询的调用,后面还有很多updateResult。因为request 和result是1对多的关系。所以多个result 对应同一requestNo

3、结语
代码熟练度还不够溜,MTK Code细节不够火候,还需继续深入。我会不定期分享,以便查漏补缺,相互学习。奥里给!!!
 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值