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