blob: 753d08564963f6e07272613a785da74a57d7ed17 [file] [log] [blame]
Zhijun He8486e412016-09-12 15:30:51 -07001/*
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
17package android.hardware.camera.device@3.2;
18
19import 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 */
33interface ICameraDeviceCallback {
34
35 /**
36 * processCaptureResult:
37 *
38 * Send results from a completed capture to the framework.
39 * processCaptureResult() may be invoked multiple times by the HAL in
40 * response to a single capture request. This allows, for example, the
41 * metadata and low-resolution buffers to be returned in one call, and
42 * post-processed JPEG buffers in a later call, once it is available. Each
43 * call must include the frame number of the request it is returning
44 * metadata or buffers for.
45 *
46 * A component (buffer or metadata) of the complete result may only be
47 * included in one process_capture_result call. A buffer for each stream,
48 * and the result metadata, must be returned by the HAL for each request in
49 * one of the processCaptureResult calls, even in case of errors producing
50 * some of the output. A call to processCaptureResult() with neither
51 * output buffers or result metadata is not allowed.
52 *
53 * The order of returning metadata and buffers for a single result does not
54 * matter, but buffers for a given stream must be returned in FIFO order. So
55 * the buffer for request 5 for stream A must always be returned before the
56 * buffer for request 6 for stream A. This also applies to the result
57 * metadata; the metadata for request 5 must be returned before the metadata
58 * for request 6.
59 *
60 * However, different streams are independent of each other, so it is
61 * acceptable and expected that the buffer for request 5 for stream A may be
62 * returned after the buffer for request 6 for stream B is. And it is
63 * acceptable that the result metadata for request 6 for stream B is
64 * returned before the buffer for request 5 for stream A is.
65 *
66 * The HAL retains ownership of result structure, which only needs to be
67 * valid to access during this call. The framework must copy whatever it
68 * needs before this call returns.
69 *
70 * The output buffers do not need to be filled yet; the framework must wait
71 * on the stream buffer release sync fence before reading the buffer
72 * data. Therefore, this method should be called by the HAL as soon as
73 * possible, even if some or all of the output buffers are still in
74 * being filled. The HAL must include valid release sync fences into each
75 * output_buffers stream buffer entry, or -1 if that stream buffer is
76 * already filled.
77 *
78 * If the result buffer cannot be constructed for a request, the HAL must
79 * return an empty metadata buffer, but still provide the output buffers and
80 * their sync fences. In addition, notify() must be called with an
81 * ERROR_RESULT message.
82 *
83 * If an output buffer cannot be filled, its status field must be set to
84 * STATUS_ERROR. In addition, notify() must be called with a ERROR_BUFFER
85 * message.
86 *
87 * If the entire capture has failed, then this method still needs to be
88 * called to return the output buffers to the framework. All the buffer
89 * statuses must be STATUS_ERROR, and the result metadata must be an
90 * empty buffer. In addition, notify() must be called with a ERROR_REQUEST
91 * message. In this case, individual ERROR_RESULT/ERROR_BUFFER messages
92 * must not be sent.
93 *
94 * Performance requirements:
95 *
96 * This is a non-blocking call. The framework must return this call in 5ms.
97 *
98 * The pipeline latency (see S7 for definition) should be less than or equal to
99 * 4 frame intervals, and must be less than or equal to 8 frame intervals.
100 *
101 */
102 processCaptureResult(CaptureResult result);
103
104 /**
105 * notify:
106 *
107 * Asynchronous notification callback from the HAL, fired for various
108 * reasons. Only for information independent of frame capture, or that
109 * require specific timing.
110 *
111 * Multiple threads may call notify() simultaneously.
112 *
113 * Buffers delivered to the framework must not be dispatched to the
114 * application layer until a start of exposure timestamp (or input image's
115 * start of exposure timestamp for a reprocess request) has been received
116 * via a SHUTTER notify() call. It is highly recommended to dispatch this
117 * call as early as possible.
118 *
119 * ------------------------------------------------------------------------
120 * Performance requirements:
121 *
122 * This is a non-blocking call. The framework must return this call in 5ms.
123 */
124 notify(NotifyMsg msg);
125
126};