Zhijun He | 8486e41 | 2016-09-12 15:30:51 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2016 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package android.hardware.camera.device@3.2; |
| 18 | |
| 19 | import android.hardware.camera.common@1.0::types; |
| 20 | |
| 21 | /** |
| 22 | * |
| 23 | * Callback methods for the HAL to call into the framework. |
| 24 | * |
| 25 | * These methods are used to return metadata and image buffers for a completed |
| 26 | * or failed captures, and to notify the framework of asynchronous events such |
| 27 | * as errors. |
| 28 | * |
| 29 | * The framework must not call back into the HAL from within these callbacks, |
| 30 | * and these calls must not block for extended periods. |
| 31 | * |
| 32 | */ |
| 33 | interface ICameraDeviceCallback { |
| 34 | |
| 35 | /** |
| 36 | * processCaptureResult: |
| 37 | * |
Yin-Chia Yeh | bed3a94 | 2017-03-06 14:14:17 -0800 | [diff] [blame] | 38 | * Send results from one or more completed or partially completed captures |
| 39 | * to the framework. |
Zhijun He | 8486e41 | 2016-09-12 15:30:51 -0700 | [diff] [blame] | 40 | * processCaptureResult() may be invoked multiple times by the HAL in |
| 41 | * response to a single capture request. This allows, for example, the |
| 42 | * metadata and low-resolution buffers to be returned in one call, and |
| 43 | * post-processed JPEG buffers in a later call, once it is available. Each |
| 44 | * call must include the frame number of the request it is returning |
| 45 | * metadata or buffers for. |
| 46 | * |
| 47 | * A component (buffer or metadata) of the complete result may only be |
| 48 | * included in one process_capture_result call. A buffer for each stream, |
| 49 | * and the result metadata, must be returned by the HAL for each request in |
| 50 | * one of the processCaptureResult calls, even in case of errors producing |
| 51 | * some of the output. A call to processCaptureResult() with neither |
| 52 | * output buffers or result metadata is not allowed. |
| 53 | * |
| 54 | * The order of returning metadata and buffers for a single result does not |
| 55 | * matter, but buffers for a given stream must be returned in FIFO order. So |
| 56 | * the buffer for request 5 for stream A must always be returned before the |
| 57 | * buffer for request 6 for stream A. This also applies to the result |
| 58 | * metadata; the metadata for request 5 must be returned before the metadata |
| 59 | * for request 6. |
| 60 | * |
| 61 | * However, different streams are independent of each other, so it is |
| 62 | * acceptable and expected that the buffer for request 5 for stream A may be |
| 63 | * returned after the buffer for request 6 for stream B is. And it is |
| 64 | * acceptable that the result metadata for request 6 for stream B is |
Yin-Chia Yeh | bed3a94 | 2017-03-06 14:14:17 -0800 | [diff] [blame] | 65 | * returned before the buffer for request 5 for stream A is. If multiple |
| 66 | * capture results are included in a single call, camera framework must |
| 67 | * process results sequentially from lower index to higher index, as if |
| 68 | * these results were sent to camera framework one by one, from lower index |
| 69 | * to higher index. |
Zhijun He | 8486e41 | 2016-09-12 15:30:51 -0700 | [diff] [blame] | 70 | * |
| 71 | * The HAL retains ownership of result structure, which only needs to be |
Yin-Chia Yeh | bed3a94 | 2017-03-06 14:14:17 -0800 | [diff] [blame] | 72 | * valid to access during this call. |
Zhijun He | 8486e41 | 2016-09-12 15:30:51 -0700 | [diff] [blame] | 73 | * |
| 74 | * The output buffers do not need to be filled yet; the framework must wait |
| 75 | * on the stream buffer release sync fence before reading the buffer |
| 76 | * data. Therefore, this method should be called by the HAL as soon as |
| 77 | * possible, even if some or all of the output buffers are still in |
| 78 | * being filled. The HAL must include valid release sync fences into each |
| 79 | * output_buffers stream buffer entry, or -1 if that stream buffer is |
| 80 | * already filled. |
| 81 | * |
| 82 | * If the result buffer cannot be constructed for a request, the HAL must |
| 83 | * return an empty metadata buffer, but still provide the output buffers and |
| 84 | * their sync fences. In addition, notify() must be called with an |
| 85 | * ERROR_RESULT message. |
| 86 | * |
| 87 | * If an output buffer cannot be filled, its status field must be set to |
| 88 | * STATUS_ERROR. In addition, notify() must be called with a ERROR_BUFFER |
| 89 | * message. |
| 90 | * |
| 91 | * If the entire capture has failed, then this method still needs to be |
| 92 | * called to return the output buffers to the framework. All the buffer |
| 93 | * statuses must be STATUS_ERROR, and the result metadata must be an |
| 94 | * empty buffer. In addition, notify() must be called with a ERROR_REQUEST |
| 95 | * message. In this case, individual ERROR_RESULT/ERROR_BUFFER messages |
| 96 | * must not be sent. |
| 97 | * |
| 98 | * Performance requirements: |
| 99 | * |
Yin-Chia Yeh | bed3a94 | 2017-03-06 14:14:17 -0800 | [diff] [blame] | 100 | * This is a non-blocking call. The framework must handle each CaptureResult |
| 101 | * within 5ms. |
Zhijun He | 8486e41 | 2016-09-12 15:30:51 -0700 | [diff] [blame] | 102 | * |
| 103 | * The pipeline latency (see S7 for definition) should be less than or equal to |
| 104 | * 4 frame intervals, and must be less than or equal to 8 frame intervals. |
| 105 | * |
| 106 | */ |
Yin-Chia Yeh | bed3a94 | 2017-03-06 14:14:17 -0800 | [diff] [blame] | 107 | processCaptureResult(vec<CaptureResult> results); |
Zhijun He | 8486e41 | 2016-09-12 15:30:51 -0700 | [diff] [blame] | 108 | |
| 109 | /** |
| 110 | * notify: |
| 111 | * |
| 112 | * Asynchronous notification callback from the HAL, fired for various |
| 113 | * reasons. Only for information independent of frame capture, or that |
Yin-Chia Yeh | bed3a94 | 2017-03-06 14:14:17 -0800 | [diff] [blame] | 114 | * require specific timing. Multiple messages may be sent in one call; a |
| 115 | * message with a higher index must be considered to have occurred after a |
| 116 | * message with a lower index. |
Zhijun He | 8486e41 | 2016-09-12 15:30:51 -0700 | [diff] [blame] | 117 | * |
| 118 | * Multiple threads may call notify() simultaneously. |
| 119 | * |
| 120 | * Buffers delivered to the framework must not be dispatched to the |
| 121 | * application layer until a start of exposure timestamp (or input image's |
| 122 | * start of exposure timestamp for a reprocess request) has been received |
| 123 | * via a SHUTTER notify() call. It is highly recommended to dispatch this |
| 124 | * call as early as possible. |
| 125 | * |
| 126 | * ------------------------------------------------------------------------ |
| 127 | * Performance requirements: |
| 128 | * |
Yin-Chia Yeh | bed3a94 | 2017-03-06 14:14:17 -0800 | [diff] [blame] | 129 | * This is a non-blocking call. The framework must handle each message in 5ms. |
Zhijun He | 8486e41 | 2016-09-12 15:30:51 -0700 | [diff] [blame] | 130 | */ |
Yin-Chia Yeh | bed3a94 | 2017-03-06 14:14:17 -0800 | [diff] [blame] | 131 | notify(vec<NotifyMsg> msgs); |
Zhijun He | 8486e41 | 2016-09-12 15:30:51 -0700 | [diff] [blame] | 132 | |
| 133 | }; |