blob: 73726cf28ab9b7ff7fff659b89360b17f9bcf331 [file] [log] [blame]
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001/*
2 * Copyright (C) 2013 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#ifndef ANDROID_INCLUDE_CAMERA3_H
18#define ANDROID_INCLUDE_CAMERA3_H
19
Eino-Ville Talvala7effe0c2013-02-15 12:09:48 -080020#include <system/camera_metadata.h>
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -080021#include "camera_common.h"
22
23/**
Zhijun Heebdf1282015-01-16 16:44:40 -080024 * Camera device HAL 3.3 [ CAMERA_DEVICE_API_VERSION_3_3 ]
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -080025 *
Eino-Ville Talvalab5459832014-09-09 16:42:27 -070026 * This is the current recommended version of the camera device HAL.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -080027 *
Eino-Ville Talvalab5459832014-09-09 16:42:27 -070028 * Supports the android.hardware.Camera API, and as of v3.2, the
29 * android.hardware.camera2 API in LIMITED or FULL modes.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -080030 *
31 * Camera devices that support this version of the HAL must return
Zhijun Heebdf1282015-01-16 16:44:40 -080032 * CAMERA_DEVICE_API_VERSION_3_3 in camera_device_t.common.version and in
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -080033 * camera_info_t.device_version (from camera_module_t.get_camera_info).
34 *
Zhijun Heebdf1282015-01-16 16:44:40 -080035 * CAMERA_DEVICE_API_VERSION_3_3:
36 * Camera modules that may contain version 3.3 devices must implement at
37 * least version 2.2 of the camera module interface (as defined by
38 * camera_module_t.common.module_api_version).
39 *
Ruben Brunk61cf9eb2014-01-14 15:27:58 -080040 * CAMERA_DEVICE_API_VERSION_3_2:
41 * Camera modules that may contain version 3.2 devices must implement at
42 * least version 2.2 of the camera module interface (as defined by
43 * camera_module_t.common.module_api_version).
44 *
45 * <= CAMERA_DEVICE_API_VERSION_3_1:
46 * Camera modules that may contain version 3.1 (or 3.0) devices must
47 * implement at least version 2.0 of the camera module interface
48 * (as defined by camera_module_t.common.module_api_version).
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -080049 *
50 * See camera_common.h for more versioning details.
51 *
Eino-Ville Talvalaacbc4512013-03-16 16:53:28 -070052 * Documentation index:
53 * S1. Version history
54 * S2. Startup and operation sequencing
55 * S3. Operational modes
56 * S4. 3A modes and state machines
Eino-Ville Talvalab6059442013-04-29 15:26:16 -070057 * S5. Cropping
58 * S6. Error management
Zhijun He709e5872014-01-17 15:25:21 -080059 * S7. Key Performance Indicator (KPI) glossary
Zhijun Hebc358682014-01-23 14:42:54 -080060 * S8. Sample Use Cases
Ruben Brunk2d96c742014-03-18 13:39:17 -070061 * S9. Notes on Controls and Metadata
Zhijun Heebdf1282015-01-16 16:44:40 -080062 * S10. Reprocessing flow and controls
Eino-Ville Talvalaacbc4512013-03-16 16:53:28 -070063 */
64
65/**
66 * S1. Version history:
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -080067 *
68 * 1.0: Initial Android camera HAL (Android 4.0) [camera.h]:
69 *
70 * - Converted from C++ CameraHardwareInterface abstraction layer.
71 *
72 * - Supports android.hardware.Camera API.
73 *
74 * 2.0: Initial release of expanded-capability HAL (Android 4.2) [camera2.h]:
75 *
76 * - Sufficient for implementing existing android.hardware.Camera API.
77 *
78 * - Allows for ZSL queue in camera service layer
79 *
80 * - Not tested for any new features such manual capture control, Bayer RAW
81 * capture, reprocessing of RAW data.
82 *
83 * 3.0: First revision of expanded-capability HAL:
84 *
85 * - Major version change since the ABI is completely different. No change to
86 * the required hardware capabilities or operational model from 2.0.
87 *
88 * - Reworked input request and stream queue interfaces: Framework calls into
89 * HAL with next request and stream buffers already dequeued. Sync framework
90 * support is included, necessary for efficient implementations.
91 *
92 * - Moved triggers into requests, most notifications into results.
93 *
94 * - Consolidated all callbacks into framework into one structure, and all
95 * setup methods into a single initialize() call.
96 *
97 * - Made stream configuration into a single call to simplify stream
98 * management. Bidirectional streams replace STREAM_FROM_STREAM construct.
99 *
100 * - Limited mode semantics for older/limited hardware devices.
Alex Ray2ce219a2013-06-14 15:09:30 -0700101 *
102 * 3.1: Minor revision of expanded-capability HAL:
103 *
104 * - configure_streams passes consumer usage flags to the HAL.
Alex Ray5f2fd852013-06-24 11:28:05 -0700105 *
106 * - flush call to drop all in-flight requests/buffers as fast as possible.
Ruben Brunk61cf9eb2014-01-14 15:27:58 -0800107 *
108 * 3.2: Minor revision of expanded-capability HAL:
109 *
110 * - Deprecates get_metadata_vendor_tag_ops. Please use get_vendor_tag_ops
111 * in camera_common.h instead.
Igor Murashkin78aa1262014-01-09 16:23:43 -0800112 *
113 * - register_stream_buffers deprecated. All gralloc buffers provided
114 * by framework to HAL in process_capture_request may be new at any time.
Igor Murashkin5df2f622014-01-10 14:18:45 -0800115 *
116 * - add partial result support. process_capture_result may be called
117 * multiple times with a subset of the available result before the full
118 * result is available.
Zhijun Hebc358682014-01-23 14:42:54 -0800119 *
120 * - add manual template to camera3_request_template. The applications may
121 * use this template to control the capture settings directly.
122 *
123 * - Rework the bidirectional and input stream specifications.
124 *
Zhijun Heceac9e32014-02-05 20:49:45 -0800125 * - change the input buffer return path. The buffer is returned in
126 * process_capture_result instead of process_capture_request.
127 *
Zhijun Heebdf1282015-01-16 16:44:40 -0800128 * 3.3: Minor revision of expanded-capability HAL:
129 *
130 * - OPAQUE and YUV reprocessing API updates.
Eino-Ville Talvala453c7902015-03-06 13:22:03 -0800131 *
Yin-Chia Yehe0042082015-03-09 12:15:36 -0700132 * - Basic support for depth output buffers.
Eino-Ville Talvala453c7902015-03-06 13:22:03 -0800133 *
134 * - Addition of data_space field to camera3_stream_t.
135 *
Yin-Chia Yehe0042082015-03-09 12:15:36 -0700136 * - Addition of rotation field to camera3_stream_t.
137 *
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800138 */
139
140/**
Eino-Ville Talvalaacbc4512013-03-16 16:53:28 -0700141 * S2. Startup and general expected operation sequence:
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800142 *
143 * 1. Framework calls camera_module_t->common.open(), which returns a
144 * hardware_device_t structure.
145 *
146 * 2. Framework inspects the hardware_device_t->version field, and instantiates
147 * the appropriate handler for that version of the camera hardware device. In
148 * case the version is CAMERA_DEVICE_API_VERSION_3_0, the device is cast to
149 * a camera3_device_t.
150 *
151 * 3. Framework calls camera3_device_t->ops->initialize() with the framework
152 * callback function pointers. This will only be called this one time after
153 * open(), before any other functions in the ops structure are called.
154 *
155 * 4. The framework calls camera3_device_t->ops->configure_streams() with a list
156 * of input/output streams to the HAL device.
157 *
Igor Murashkin78aa1262014-01-09 16:23:43 -0800158 * 5. <= CAMERA_DEVICE_API_VERSION_3_1:
159 *
160 * The framework allocates gralloc buffers and calls
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800161 * camera3_device_t->ops->register_stream_buffers() for at least one of the
162 * output streams listed in configure_streams. The same stream is registered
163 * only once.
164 *
Igor Murashkin78aa1262014-01-09 16:23:43 -0800165 * >= CAMERA_DEVICE_API_VERSION_3_2:
166 *
167 * camera3_device_t->ops->register_stream_buffers() is not called and must
168 * be NULL.
169 *
170 * 6. The framework requests default settings for some number of use cases with
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800171 * calls to camera3_device_t->ops->construct_default_request_settings(). This
172 * may occur any time after step 3.
173 *
174 * 7. The framework constructs and sends the first capture request to the HAL,
175 * with settings based on one of the sets of default settings, and with at
176 * least one output stream, which has been registered earlier by the
177 * framework. This is sent to the HAL with
178 * camera3_device_t->ops->process_capture_request(). The HAL must block the
179 * return of this call until it is ready for the next request to be sent.
180 *
Igor Murashkin78aa1262014-01-09 16:23:43 -0800181 * >= CAMERA_DEVICE_API_VERSION_3_2:
182 *
183 * The buffer_handle_t provided in the camera3_stream_buffer_t array
184 * in the camera3_capture_request_t may be new and never-before-seen
185 * by the HAL on any given new request.
186 *
187 * 8. The framework continues to submit requests, and call
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800188 * construct_default_request_settings to get default settings buffers for
189 * other use cases.
190 *
Igor Murashkin78aa1262014-01-09 16:23:43 -0800191 * <= CAMERA_DEVICE_API_VERSION_3_1:
192 *
193 * The framework may call register_stream_buffers() at this time for
194 * not-yet-registered streams.
195 *
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800196 * 9. When the capture of a request begins (sensor starts exposing for the
Chien-Yu Chen73b49eb2015-05-28 17:13:05 -0700197 * capture) or processing a reprocess request begins, the HAL
198 * calls camera3_callback_ops_t->notify() with the SHUTTER event, including
199 * the frame number and the timestamp for start of exposure. For a reprocess
200 * request, the timestamp must be the start of exposure of the input image
201 * which can be looked up with android.sensor.timestamp from
202 * camera3_capture_request_t.settings when process_capture_request() is
203 * called.
Igor Murashkin5df2f622014-01-10 14:18:45 -0800204 *
205 * <= CAMERA_DEVICE_API_VERSION_3_1:
206 *
Eino-Ville Talvala71af1022013-04-22 14:19:21 -0700207 * This notify call must be made before the first call to
208 * process_capture_result() for that frame number.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800209 *
Igor Murashkin5df2f622014-01-10 14:18:45 -0800210 * >= CAMERA_DEVICE_API_VERSION_3_2:
211 *
212 * The camera3_callback_ops_t->notify() call with the SHUTTER event should
213 * be made as early as possible since the framework will be unable to
214 * deliver gralloc buffers to the application layer (for that frame) until
Chien-Yu Chen73b49eb2015-05-28 17:13:05 -0700215 * it has a valid timestamp for the start of exposure (or the input image's
216 * start of exposure for a reprocess request).
Igor Murashkin5df2f622014-01-10 14:18:45 -0800217 *
218 * Both partial metadata results and the gralloc buffers may be sent to the
219 * framework at any time before or after the SHUTTER event.
220 *
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800221 * 10. After some pipeline delay, the HAL begins to return completed captures to
222 * the framework with camera3_callback_ops_t->process_capture_result(). These
223 * are returned in the same order as the requests were submitted. Multiple
224 * requests can be in flight at once, depending on the pipeline depth of the
225 * camera HAL device.
226 *
Igor Murashkin78aa1262014-01-09 16:23:43 -0800227 * >= CAMERA_DEVICE_API_VERSION_3_2:
228 *
229 * Once a buffer is returned by process_capture_result as part of the
230 * camera3_stream_buffer_t array, and the fence specified by release_fence
231 * has been signaled (this is a no-op for -1 fences), the ownership of that
232 * buffer is considered to be transferred back to the framework. After that,
233 * the HAL must no longer retain that particular buffer, and the
234 * framework may clean up the memory for it immediately.
235 *
Igor Murashkin5df2f622014-01-10 14:18:45 -0800236 * process_capture_result may be called multiple times for a single frame,
237 * each time with a new disjoint piece of metadata and/or set of gralloc
238 * buffers. The framework will accumulate these partial metadata results
239 * into one result.
240 *
241 * In particular, it is legal for a process_capture_result to be called
242 * simultaneously for both a frame N and a frame N+1 as long as the
Zhijun Heceac9e32014-02-05 20:49:45 -0800243 * above rule holds for gralloc buffers (both input and output).
Igor Murashkin5df2f622014-01-10 14:18:45 -0800244 *
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800245 * 11. After some time, the framework may stop submitting new requests, wait for
246 * the existing captures to complete (all buffers filled, all results
247 * returned), and then call configure_streams() again. This resets the camera
248 * hardware and pipeline for a new set of input/output streams. Some streams
249 * may be reused from the previous configuration; if these streams' buffers
250 * had already been registered with the HAL, they will not be registered
251 * again. The framework then continues from step 7, if at least one
252 * registered output stream remains (otherwise, step 5 is required first).
253 *
254 * 12. Alternatively, the framework may call camera3_device_t->common->close()
Eino-Ville Talvala2f8cf5c2013-03-06 13:23:31 -0800255 * to end the camera session. This may be called at any time when no other
256 * calls from the framework are active, although the call may block until all
257 * in-flight captures have completed (all results returned, all buffers
258 * filled). After the close call returns, no more calls to the
259 * camera3_callback_ops_t functions are allowed from the HAL. Once the
260 * close() call is underway, the framework may not call any other HAL device
261 * functions.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800262 *
263 * 13. In case of an error or other asynchronous event, the HAL must call
264 * camera3_callback_ops_t->notify() with the appropriate error/event
265 * message. After returning from a fatal device-wide error notification, the
266 * HAL should act as if close() had been called on it. However, the HAL must
267 * either cancel or complete all outstanding captures before calling
268 * notify(), so that once notify() is called with a fatal error, the
269 * framework will not receive further callbacks from the device. Methods
270 * besides close() should return -ENODEV or NULL after the notify() method
271 * returns from a fatal error message.
272 */
273
274/**
Eino-Ville Talvalaacbc4512013-03-16 16:53:28 -0700275 * S3. Operational modes:
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800276 *
277 * The camera 3 HAL device can implement one of two possible operational modes;
278 * limited and full. Full support is expected from new higher-end
279 * devices. Limited mode has hardware requirements roughly in line with those
280 * for a camera HAL device v1 implementation, and is expected from older or
281 * inexpensive devices. Full is a strict superset of limited, and they share the
282 * same essential operational flow, as documented above.
283 *
284 * The HAL must indicate its level of support with the
285 * android.info.supportedHardwareLevel static metadata entry, with 0 indicating
286 * limited mode, and 1 indicating full mode support.
287 *
288 * Roughly speaking, limited-mode devices do not allow for application control
289 * of capture settings (3A control only), high-rate capture of high-resolution
Eino-Ville Talvalaacbc4512013-03-16 16:53:28 -0700290 * images, raw sensor readout, or support for YUV output streams above maximum
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800291 * recording resolution (JPEG only for large images).
292 *
293 * ** Details of limited mode behavior:
294 *
295 * - Limited-mode devices do not need to implement accurate synchronization
296 * between capture request settings and the actual image data
297 * captured. Instead, changes to settings may take effect some time in the
298 * future, and possibly not for the same output frame for each settings
299 * entry. Rapid changes in settings may result in some settings never being
300 * used for a capture. However, captures that include high-resolution output
301 * buffers ( > 1080p ) have to use the settings as specified (but see below
302 * for processing rate).
303 *
304 * - Limited-mode devices do not need to support most of the
Zhijun He1ab5c5e2014-05-26 17:35:50 -0700305 * settings/result/static info metadata. Specifically, only the following settings
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800306 * are expected to be consumed or produced by a limited-mode HAL device:
307 *
Zhijun He1ab5c5e2014-05-26 17:35:50 -0700308 * android.control.aeAntibandingMode (controls and dynamic)
309 * android.control.aeExposureCompensation (controls and dynamic)
310 * android.control.aeLock (controls and dynamic)
311 * android.control.aeMode (controls and dynamic)
312 * android.control.aeRegions (controls and dynamic)
313 * android.control.aeTargetFpsRange (controls and dynamic)
314 * android.control.aePrecaptureTrigger (controls and dynamic)
315 * android.control.afMode (controls and dynamic)
316 * android.control.afRegions (controls and dynamic)
317 * android.control.awbLock (controls and dynamic)
318 * android.control.awbMode (controls and dynamic)
319 * android.control.awbRegions (controls and dynamic)
320 * android.control.captureIntent (controls and dynamic)
321 * android.control.effectMode (controls and dynamic)
322 * android.control.mode (controls and dynamic)
323 * android.control.sceneMode (controls and dynamic)
324 * android.control.videoStabilizationMode (controls and dynamic)
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800325 * android.control.aeAvailableAntibandingModes (static)
326 * android.control.aeAvailableModes (static)
327 * android.control.aeAvailableTargetFpsRanges (static)
328 * android.control.aeCompensationRange (static)
329 * android.control.aeCompensationStep (static)
330 * android.control.afAvailableModes (static)
331 * android.control.availableEffects (static)
332 * android.control.availableSceneModes (static)
333 * android.control.availableVideoStabilizationModes (static)
334 * android.control.awbAvailableModes (static)
335 * android.control.maxRegions (static)
336 * android.control.sceneModeOverrides (static)
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800337 * android.control.aeState (dynamic)
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800338 * android.control.afState (dynamic)
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800339 * android.control.awbState (dynamic)
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800340 *
Zhijun He1ab5c5e2014-05-26 17:35:50 -0700341 * android.flash.mode (controls and dynamic)
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800342 * android.flash.info.available (static)
343 *
344 * android.info.supportedHardwareLevel (static)
345 *
Zhijun He1ab5c5e2014-05-26 17:35:50 -0700346 * android.jpeg.gpsCoordinates (controls and dynamic)
347 * android.jpeg.gpsProcessingMethod (controls and dynamic)
348 * android.jpeg.gpsTimestamp (controls and dynamic)
349 * android.jpeg.orientation (controls and dynamic)
350 * android.jpeg.quality (controls and dynamic)
351 * android.jpeg.thumbnailQuality (controls and dynamic)
352 * android.jpeg.thumbnailSize (controls and dynamic)
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800353 * android.jpeg.availableThumbnailSizes (static)
354 * android.jpeg.maxSize (static)
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800355 *
356 * android.lens.info.minimumFocusDistance (static)
357 *
Zhijun He1ab5c5e2014-05-26 17:35:50 -0700358 * android.request.id (controls and dynamic)
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800359 *
Zhijun He1ab5c5e2014-05-26 17:35:50 -0700360 * android.scaler.cropRegion (controls and dynamic)
Eino-Ville Talvalac5bff0d2014-02-10 16:43:26 -0800361 * android.scaler.availableStreamConfigurations (static)
362 * android.scaler.availableMinFrameDurations (static)
363 * android.scaler.availableStallDurations (static)
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800364 * android.scaler.availableMaxDigitalZoom (static)
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800365 * android.scaler.maxDigitalZoom (static)
Zhijun He1ab5c5e2014-05-26 17:35:50 -0700366 * android.scaler.croppingType (static)
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800367 *
368 * android.sensor.orientation (static)
369 * android.sensor.timestamp (dynamic)
370 *
Zhijun He1ab5c5e2014-05-26 17:35:50 -0700371 * android.statistics.faceDetectMode (controls and dynamic)
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800372 * android.statistics.info.availableFaceDetectModes (static)
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800373 * android.statistics.faceIds (dynamic)
374 * android.statistics.faceLandmarks (dynamic)
375 * android.statistics.faceRectangles (dynamic)
376 * android.statistics.faceScores (dynamic)
377 *
Zhijun He1ab5c5e2014-05-26 17:35:50 -0700378 * android.sync.frameNumber (dynamic)
379 * android.sync.maxLatency (static)
380 *
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800381 * - Captures in limited mode that include high-resolution (> 1080p) output
382 * buffers may block in process_capture_request() until all the output buffers
383 * have been filled. A full-mode HAL device must process sequences of
384 * high-resolution requests at the rate indicated in the static metadata for
385 * that pixel format. The HAL must still call process_capture_result() to
386 * provide the output; the framework must simply be prepared for
387 * process_capture_request() to block until after process_capture_result() for
388 * that request completes for high-resolution captures for limited-mode
389 * devices.
390 *
Zhijun He1ab5c5e2014-05-26 17:35:50 -0700391 * - Full-mode devices must support below additional capabilities:
392 * - 30fps at maximum resolution is preferred, more than 20fps is required.
393 * - Per frame control (android.sync.maxLatency == PER_FRAME_CONTROL).
394 * - Sensor manual control metadata. See MANUAL_SENSOR defined in
395 * android.request.availableCapabilities.
396 * - Post-processing manual control metadata. See MANUAL_POST_PROCESSING defined
397 * in android.request.availableCapabilities.
398 *
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800399 */
400
401/**
Eino-Ville Talvalaacbc4512013-03-16 16:53:28 -0700402 * S4. 3A modes and state machines:
403 *
404 * While the actual 3A algorithms are up to the HAL implementation, a high-level
405 * state machine description is defined by the HAL interface, to allow the HAL
406 * device and the framework to communicate about the current state of 3A, and to
407 * trigger 3A events.
408 *
409 * When the device is opened, all the individual 3A states must be
410 * STATE_INACTIVE. Stream configuration does not reset 3A. For example, locked
411 * focus must be maintained across the configure() call.
412 *
413 * Triggering a 3A action involves simply setting the relevant trigger entry in
414 * the settings for the next request to indicate start of trigger. For example,
415 * the trigger for starting an autofocus scan is setting the entry
416 * ANDROID_CONTROL_AF_TRIGGER to ANDROID_CONTROL_AF_TRIGGER_START for one
417 * request, and cancelling an autofocus scan is triggered by setting
418 * ANDROID_CONTROL_AF_TRIGGER to ANDROID_CONTRL_AF_TRIGGER_CANCEL. Otherwise,
419 * the entry will not exist, or be set to ANDROID_CONTROL_AF_TRIGGER_IDLE. Each
420 * request with a trigger entry set to a non-IDLE value will be treated as an
421 * independent triggering event.
422 *
423 * At the top level, 3A is controlled by the ANDROID_CONTROL_MODE setting, which
424 * selects between no 3A (ANDROID_CONTROL_MODE_OFF), normal AUTO mode
425 * (ANDROID_CONTROL_MODE_AUTO), and using the scene mode setting
426 * (ANDROID_CONTROL_USE_SCENE_MODE).
427 *
428 * - In OFF mode, each of the individual AE/AF/AWB modes are effectively OFF,
429 * and none of the capture controls may be overridden by the 3A routines.
430 *
431 * - In AUTO mode, Auto-focus, auto-exposure, and auto-whitebalance all run
432 * their own independent algorithms, and have their own mode, state, and
433 * trigger metadata entries, as listed in the next section.
434 *
435 * - In USE_SCENE_MODE, the value of the ANDROID_CONTROL_SCENE_MODE entry must
436 * be used to determine the behavior of 3A routines. In SCENE_MODEs other than
437 * FACE_PRIORITY, the HAL must override the values of
438 * ANDROId_CONTROL_AE/AWB/AF_MODE to be the mode it prefers for the selected
439 * SCENE_MODE. For example, the HAL may prefer SCENE_MODE_NIGHT to use
440 * CONTINUOUS_FOCUS AF mode. Any user selection of AE/AWB/AF_MODE when scene
441 * must be ignored for these scene modes.
442 *
443 * - For SCENE_MODE_FACE_PRIORITY, the AE/AWB/AF_MODE controls work as in
444 * ANDROID_CONTROL_MODE_AUTO, but the 3A routines must bias toward metering
445 * and focusing on any detected faces in the scene.
446 *
447 * S4.1. Auto-focus settings and result entries:
448 *
449 * Main metadata entries:
450 *
451 * ANDROID_CONTROL_AF_MODE: Control for selecting the current autofocus
452 * mode. Set by the framework in the request settings.
453 *
454 * AF_MODE_OFF: AF is disabled; the framework/app directly controls lens
455 * position.
456 *
457 * AF_MODE_AUTO: Single-sweep autofocus. No lens movement unless AF is
458 * triggered.
459 *
460 * AF_MODE_MACRO: Single-sweep up-close autofocus. No lens movement unless
461 * AF is triggered.
462 *
463 * AF_MODE_CONTINUOUS_VIDEO: Smooth continuous focusing, for recording
464 * video. Triggering immediately locks focus in current
465 * position. Canceling resumes cotinuous focusing.
466 *
467 * AF_MODE_CONTINUOUS_PICTURE: Fast continuous focusing, for
468 * zero-shutter-lag still capture. Triggering locks focus once currently
469 * active sweep concludes. Canceling resumes continuous focusing.
470 *
471 * AF_MODE_EDOF: Advanced extended depth of field focusing. There is no
472 * autofocus scan, so triggering one or canceling one has no effect.
473 * Images are focused automatically by the HAL.
474 *
475 * ANDROID_CONTROL_AF_STATE: Dynamic metadata describing the current AF
476 * algorithm state, reported by the HAL in the result metadata.
477 *
478 * AF_STATE_INACTIVE: No focusing has been done, or algorithm was
479 * reset. Lens is not moving. Always the state for MODE_OFF or MODE_EDOF.
480 * When the device is opened, it must start in this state.
481 *
482 * AF_STATE_PASSIVE_SCAN: A continuous focus algorithm is currently scanning
483 * for good focus. The lens is moving.
484 *
485 * AF_STATE_PASSIVE_FOCUSED: A continuous focus algorithm believes it is
486 * well focused. The lens is not moving. The HAL may spontaneously leave
487 * this state.
488 *
Eino-Ville Talvala4d45d302013-09-20 17:24:50 -0700489 * AF_STATE_PASSIVE_UNFOCUSED: A continuous focus algorithm believes it is
490 * not well focused. The lens is not moving. The HAL may spontaneously
491 * leave this state.
492 *
Eino-Ville Talvalaacbc4512013-03-16 16:53:28 -0700493 * AF_STATE_ACTIVE_SCAN: A scan triggered by the user is underway.
494 *
495 * AF_STATE_FOCUSED_LOCKED: The AF algorithm believes it is focused. The
496 * lens is not moving.
497 *
498 * AF_STATE_NOT_FOCUSED_LOCKED: The AF algorithm has been unable to
499 * focus. The lens is not moving.
500 *
501 * ANDROID_CONTROL_AF_TRIGGER: Control for starting an autofocus scan, the
502 * meaning of which is mode- and state- dependent. Set by the framework in
503 * the request settings.
504 *
505 * AF_TRIGGER_IDLE: No current trigger.
506 *
507 * AF_TRIGGER_START: Trigger start of AF scan. Effect is mode and state
508 * dependent.
509 *
510 * AF_TRIGGER_CANCEL: Cancel current AF scan if any, and reset algorithm to
511 * default.
512 *
513 * Additional metadata entries:
514 *
515 * ANDROID_CONTROL_AF_REGIONS: Control for selecting the regions of the FOV
516 * that should be used to determine good focus. This applies to all AF
517 * modes that scan for focus. Set by the framework in the request
518 * settings.
519 *
520 * S4.2. Auto-exposure settings and result entries:
521 *
522 * Main metadata entries:
523 *
524 * ANDROID_CONTROL_AE_MODE: Control for selecting the current auto-exposure
525 * mode. Set by the framework in the request settings.
526 *
527 * AE_MODE_OFF: Autoexposure is disabled; the user controls exposure, gain,
528 * frame duration, and flash.
529 *
530 * AE_MODE_ON: Standard autoexposure, with flash control disabled. User may
531 * set flash to fire or to torch mode.
532 *
533 * AE_MODE_ON_AUTO_FLASH: Standard autoexposure, with flash on at HAL's
534 * discretion for precapture and still capture. User control of flash
535 * disabled.
536 *
537 * AE_MODE_ON_ALWAYS_FLASH: Standard autoexposure, with flash always fired
538 * for capture, and at HAL's discretion for precapture.. User control of
539 * flash disabled.
540 *
541 * AE_MODE_ON_AUTO_FLASH_REDEYE: Standard autoexposure, with flash on at
542 * HAL's discretion for precapture and still capture. Use a flash burst
543 * at end of precapture sequence to reduce redeye in the final
544 * picture. User control of flash disabled.
545 *
546 * ANDROID_CONTROL_AE_STATE: Dynamic metadata describing the current AE
547 * algorithm state, reported by the HAL in the result metadata.
548 *
549 * AE_STATE_INACTIVE: Initial AE state after mode switch. When the device is
550 * opened, it must start in this state.
551 *
552 * AE_STATE_SEARCHING: AE is not converged to a good value, and is adjusting
553 * exposure parameters.
554 *
555 * AE_STATE_CONVERGED: AE has found good exposure values for the current
556 * scene, and the exposure parameters are not changing. HAL may
557 * spontaneously leave this state to search for better solution.
558 *
559 * AE_STATE_LOCKED: AE has been locked with the AE_LOCK control. Exposure
560 * values are not changing.
561 *
562 * AE_STATE_FLASH_REQUIRED: The HAL has converged exposure, but believes
563 * flash is required for a sufficiently bright picture. Used for
564 * determining if a zero-shutter-lag frame can be used.
565 *
566 * AE_STATE_PRECAPTURE: The HAL is in the middle of a precapture
567 * sequence. Depending on AE mode, this mode may involve firing the
568 * flash for metering, or a burst of flash pulses for redeye reduction.
569 *
570 * ANDROID_CONTROL_AE_PRECAPTURE_TRIGGER: Control for starting a metering
571 * sequence before capturing a high-quality image. Set by the framework in
572 * the request settings.
573 *
574 * PRECAPTURE_TRIGGER_IDLE: No current trigger.
575 *
576 * PRECAPTURE_TRIGGER_START: Start a precapture sequence. The HAL should
577 * use the subsequent requests to measure good exposure/white balance
578 * for an upcoming high-resolution capture.
579 *
580 * Additional metadata entries:
581 *
582 * ANDROID_CONTROL_AE_LOCK: Control for locking AE controls to their current
583 * values
584 *
585 * ANDROID_CONTROL_AE_EXPOSURE_COMPENSATION: Control for adjusting AE
586 * algorithm target brightness point.
587 *
588 * ANDROID_CONTROL_AE_TARGET_FPS_RANGE: Control for selecting the target frame
589 * rate range for the AE algorithm. The AE routine cannot change the frame
590 * rate to be outside these bounds.
591 *
592 * ANDROID_CONTROL_AE_REGIONS: Control for selecting the regions of the FOV
593 * that should be used to determine good exposure levels. This applies to
594 * all AE modes besides OFF.
595 *
596 * S4.3. Auto-whitebalance settings and result entries:
597 *
598 * Main metadata entries:
599 *
600 * ANDROID_CONTROL_AWB_MODE: Control for selecting the current white-balance
601 * mode.
602 *
603 * AWB_MODE_OFF: Auto-whitebalance is disabled. User controls color matrix.
604 *
605 * AWB_MODE_AUTO: Automatic white balance is enabled; 3A controls color
606 * transform, possibly using more complex transforms than a simple
607 * matrix.
608 *
609 * AWB_MODE_INCANDESCENT: Fixed white balance settings good for indoor
610 * incandescent (tungsten) lighting, roughly 2700K.
611 *
612 * AWB_MODE_FLUORESCENT: Fixed white balance settings good for fluorescent
613 * lighting, roughly 5000K.
614 *
615 * AWB_MODE_WARM_FLUORESCENT: Fixed white balance settings good for
616 * fluorescent lighting, roughly 3000K.
617 *
618 * AWB_MODE_DAYLIGHT: Fixed white balance settings good for daylight,
619 * roughly 5500K.
620 *
621 * AWB_MODE_CLOUDY_DAYLIGHT: Fixed white balance settings good for clouded
622 * daylight, roughly 6500K.
623 *
624 * AWB_MODE_TWILIGHT: Fixed white balance settings good for
625 * near-sunset/sunrise, roughly 15000K.
626 *
627 * AWB_MODE_SHADE: Fixed white balance settings good for areas indirectly
628 * lit by the sun, roughly 7500K.
629 *
630 * ANDROID_CONTROL_AWB_STATE: Dynamic metadata describing the current AWB
631 * algorithm state, reported by the HAL in the result metadata.
632 *
633 * AWB_STATE_INACTIVE: Initial AWB state after mode switch. When the device
634 * is opened, it must start in this state.
635 *
636 * AWB_STATE_SEARCHING: AWB is not converged to a good value, and is
637 * changing color adjustment parameters.
638 *
639 * AWB_STATE_CONVERGED: AWB has found good color adjustment values for the
640 * current scene, and the parameters are not changing. HAL may
641 * spontaneously leave this state to search for better solution.
642 *
643 * AWB_STATE_LOCKED: AWB has been locked with the AWB_LOCK control. Color
644 * adjustment values are not changing.
645 *
646 * Additional metadata entries:
647 *
648 * ANDROID_CONTROL_AWB_LOCK: Control for locking AWB color adjustments to
649 * their current values.
650 *
651 * ANDROID_CONTROL_AWB_REGIONS: Control for selecting the regions of the FOV
652 * that should be used to determine good color balance. This applies only
653 * to auto-WB mode.
654 *
655 * S4.4. General state machine transition notes
656 *
657 * Switching between AF, AE, or AWB modes always resets the algorithm's state
658 * to INACTIVE. Similarly, switching between CONTROL_MODE or
659 * CONTROL_SCENE_MODE if CONTROL_MODE == USE_SCENE_MODE resets all the
660 * algorithm states to INACTIVE.
661 *
662 * The tables below are per-mode.
663 *
664 * S4.5. AF state machines
665 *
Eino-Ville Talvala4d45d302013-09-20 17:24:50 -0700666 * when enabling AF or changing AF mode
667 *| state | trans. cause | new state | notes |
668 *+--------------------+---------------+--------------------+------------------+
669 *| Any | AF mode change| INACTIVE | |
670 *+--------------------+---------------+--------------------+------------------+
671 *
Eino-Ville Talvalaacbc4512013-03-16 16:53:28 -0700672 * mode = AF_MODE_OFF or AF_MODE_EDOF
673 *| state | trans. cause | new state | notes |
674 *+--------------------+---------------+--------------------+------------------+
Eino-Ville Talvala4d45d302013-09-20 17:24:50 -0700675 *| INACTIVE | | INACTIVE | Never changes |
Eino-Ville Talvalaacbc4512013-03-16 16:53:28 -0700676 *+--------------------+---------------+--------------------+------------------+
677 *
678 * mode = AF_MODE_AUTO or AF_MODE_MACRO
679 *| state | trans. cause | new state | notes |
680 *+--------------------+---------------+--------------------+------------------+
681 *| INACTIVE | AF_TRIGGER | ACTIVE_SCAN | Start AF sweep |
682 *| | | | Lens now moving |
683 *+--------------------+---------------+--------------------+------------------+
684 *| ACTIVE_SCAN | AF sweep done | FOCUSED_LOCKED | If AF successful |
685 *| | | | Lens now locked |
686 *+--------------------+---------------+--------------------+------------------+
687 *| ACTIVE_SCAN | AF sweep done | NOT_FOCUSED_LOCKED | If AF successful |
688 *| | | | Lens now locked |
689 *+--------------------+---------------+--------------------+------------------+
690 *| ACTIVE_SCAN | AF_CANCEL | INACTIVE | Cancel/reset AF |
691 *| | | | Lens now locked |
692 *+--------------------+---------------+--------------------+------------------+
693 *| FOCUSED_LOCKED | AF_CANCEL | INACTIVE | Cancel/reset AF |
694 *+--------------------+---------------+--------------------+------------------+
695 *| FOCUSED_LOCKED | AF_TRIGGER | ACTIVE_SCAN | Start new sweep |
696 *| | | | Lens now moving |
697 *+--------------------+---------------+--------------------+------------------+
698 *| NOT_FOCUSED_LOCKED | AF_CANCEL | INACTIVE | Cancel/reset AF |
699 *+--------------------+---------------+--------------------+------------------+
700 *| NOT_FOCUSED_LOCKED | AF_TRIGGER | ACTIVE_SCAN | Start new sweep |
701 *| | | | Lens now moving |
702 *+--------------------+---------------+--------------------+------------------+
703 *| All states | mode change | INACTIVE | |
704 *+--------------------+---------------+--------------------+------------------+
705 *
706 * mode = AF_MODE_CONTINUOUS_VIDEO
707 *| state | trans. cause | new state | notes |
708 *+--------------------+---------------+--------------------+------------------+
709 *| INACTIVE | HAL initiates | PASSIVE_SCAN | Start AF scan |
710 *| | new scan | | Lens now moving |
711 *+--------------------+---------------+--------------------+------------------+
712 *| INACTIVE | AF_TRIGGER | NOT_FOCUSED_LOCKED | AF state query |
713 *| | | | Lens now locked |
714 *+--------------------+---------------+--------------------+------------------+
715 *| PASSIVE_SCAN | HAL completes | PASSIVE_FOCUSED | End AF scan |
716 *| | current scan | | Lens now locked |
717 *+--------------------+---------------+--------------------+------------------+
Eino-Ville Talvala4d45d302013-09-20 17:24:50 -0700718 *| PASSIVE_SCAN | HAL fails | PASSIVE_UNFOCUSED | End AF scan |
719 *| | current scan | | Lens now locked |
720 *+--------------------+---------------+--------------------+------------------+
Eino-Ville Talvalaacbc4512013-03-16 16:53:28 -0700721 *| PASSIVE_SCAN | AF_TRIGGER | FOCUSED_LOCKED | Immediate trans. |
722 *| | | | if focus is good |
723 *| | | | Lens now locked |
724 *+--------------------+---------------+--------------------+------------------+
725 *| PASSIVE_SCAN | AF_TRIGGER | NOT_FOCUSED_LOCKED | Immediate trans. |
726 *| | | | if focus is bad |
727 *| | | | Lens now locked |
728 *+--------------------+---------------+--------------------+------------------+
729 *| PASSIVE_SCAN | AF_CANCEL | INACTIVE | Reset lens |
730 *| | | | position |
731 *| | | | Lens now locked |
732 *+--------------------+---------------+--------------------+------------------+
733 *| PASSIVE_FOCUSED | HAL initiates | PASSIVE_SCAN | Start AF scan |
734 *| | new scan | | Lens now moving |
735 *+--------------------+---------------+--------------------+------------------+
Eino-Ville Talvala4d45d302013-09-20 17:24:50 -0700736 *| PASSIVE_UNFOCUSED | HAL initiates | PASSIVE_SCAN | Start AF scan |
737 *| | new scan | | Lens now moving |
738 *+--------------------+---------------+--------------------+------------------+
Eino-Ville Talvalaacbc4512013-03-16 16:53:28 -0700739 *| PASSIVE_FOCUSED | AF_TRIGGER | FOCUSED_LOCKED | Immediate trans. |
Eino-Ville Talvalaacbc4512013-03-16 16:53:28 -0700740 *| | | | Lens now locked |
741 *+--------------------+---------------+--------------------+------------------+
Eino-Ville Talvala4d45d302013-09-20 17:24:50 -0700742 *| PASSIVE_UNFOCUSED | AF_TRIGGER | NOT_FOCUSED_LOCKED | Immediate trans. |
Eino-Ville Talvalaacbc4512013-03-16 16:53:28 -0700743 *| | | | Lens now locked |
744 *+--------------------+---------------+--------------------+------------------+
745 *| FOCUSED_LOCKED | AF_TRIGGER | FOCUSED_LOCKED | No effect |
746 *+--------------------+---------------+--------------------+------------------+
747 *| FOCUSED_LOCKED | AF_CANCEL | INACTIVE | Restart AF scan |
748 *+--------------------+---------------+--------------------+------------------+
749 *| NOT_FOCUSED_LOCKED | AF_TRIGGER | NOT_FOCUSED_LOCKED | No effect |
750 *+--------------------+---------------+--------------------+------------------+
751 *| NOT_FOCUSED_LOCKED | AF_CANCEL | INACTIVE | Restart AF scan |
752 *+--------------------+---------------+--------------------+------------------+
753 *
754 * mode = AF_MODE_CONTINUOUS_PICTURE
755 *| state | trans. cause | new state | notes |
756 *+--------------------+---------------+--------------------+------------------+
757 *| INACTIVE | HAL initiates | PASSIVE_SCAN | Start AF scan |
758 *| | new scan | | Lens now moving |
759 *+--------------------+---------------+--------------------+------------------+
760 *| INACTIVE | AF_TRIGGER | NOT_FOCUSED_LOCKED | AF state query |
761 *| | | | Lens now locked |
762 *+--------------------+---------------+--------------------+------------------+
763 *| PASSIVE_SCAN | HAL completes | PASSIVE_FOCUSED | End AF scan |
764 *| | current scan | | Lens now locked |
765 *+--------------------+---------------+--------------------+------------------+
Eino-Ville Talvala4d45d302013-09-20 17:24:50 -0700766 *| PASSIVE_SCAN | HAL fails | PASSIVE_UNFOCUSED | End AF scan |
767 *| | current scan | | Lens now locked |
768 *+--------------------+---------------+--------------------+------------------+
Eino-Ville Talvalaacbc4512013-03-16 16:53:28 -0700769 *| PASSIVE_SCAN | AF_TRIGGER | FOCUSED_LOCKED | Eventual trans. |
770 *| | | | once focus good |
771 *| | | | Lens now locked |
772 *+--------------------+---------------+--------------------+------------------+
773 *| PASSIVE_SCAN | AF_TRIGGER | NOT_FOCUSED_LOCKED | Eventual trans. |
774 *| | | | if cannot focus |
775 *| | | | Lens now locked |
776 *+--------------------+---------------+--------------------+------------------+
777 *| PASSIVE_SCAN | AF_CANCEL | INACTIVE | Reset lens |
778 *| | | | position |
779 *| | | | Lens now locked |
780 *+--------------------+---------------+--------------------+------------------+
781 *| PASSIVE_FOCUSED | HAL initiates | PASSIVE_SCAN | Start AF scan |
782 *| | new scan | | Lens now moving |
783 *+--------------------+---------------+--------------------+------------------+
Eino-Ville Talvala4d45d302013-09-20 17:24:50 -0700784 *| PASSIVE_UNFOCUSED | HAL initiates | PASSIVE_SCAN | Start AF scan |
785 *| | new scan | | Lens now moving |
786 *+--------------------+---------------+--------------------+------------------+
Eino-Ville Talvalaacbc4512013-03-16 16:53:28 -0700787 *| PASSIVE_FOCUSED | AF_TRIGGER | FOCUSED_LOCKED | Immediate trans. |
Eino-Ville Talvalaacbc4512013-03-16 16:53:28 -0700788 *| | | | Lens now locked |
789 *+--------------------+---------------+--------------------+------------------+
Eino-Ville Talvala4d45d302013-09-20 17:24:50 -0700790 *| PASSIVE_UNFOCUSED | AF_TRIGGER | NOT_FOCUSED_LOCKED | Immediate trans. |
Eino-Ville Talvalaacbc4512013-03-16 16:53:28 -0700791 *| | | | Lens now locked |
792 *+--------------------+---------------+--------------------+------------------+
793 *| FOCUSED_LOCKED | AF_TRIGGER | FOCUSED_LOCKED | No effect |
794 *+--------------------+---------------+--------------------+------------------+
795 *| FOCUSED_LOCKED | AF_CANCEL | INACTIVE | Restart AF scan |
796 *+--------------------+---------------+--------------------+------------------+
797 *| NOT_FOCUSED_LOCKED | AF_TRIGGER | NOT_FOCUSED_LOCKED | No effect |
798 *+--------------------+---------------+--------------------+------------------+
799 *| NOT_FOCUSED_LOCKED | AF_CANCEL | INACTIVE | Restart AF scan |
800 *+--------------------+---------------+--------------------+------------------+
801 *
802 * S4.6. AE and AWB state machines
803 *
804 * The AE and AWB state machines are mostly identical. AE has additional
805 * FLASH_REQUIRED and PRECAPTURE states. So rows below that refer to those two
806 * states should be ignored for the AWB state machine.
807 *
Eino-Ville Talvala4d45d302013-09-20 17:24:50 -0700808 * when enabling AE/AWB or changing AE/AWB mode
809 *| state | trans. cause | new state | notes |
810 *+--------------------+---------------+--------------------+------------------+
811 *| Any | mode change | INACTIVE | |
812 *+--------------------+---------------+--------------------+------------------+
813 *
Eino-Ville Talvalaacbc4512013-03-16 16:53:28 -0700814 * mode = AE_MODE_OFF / AWB mode not AUTO
815 *| state | trans. cause | new state | notes |
816 *+--------------------+---------------+--------------------+------------------+
Eino-Ville Talvala4d45d302013-09-20 17:24:50 -0700817 *| INACTIVE | | INACTIVE | AE/AWB disabled |
Eino-Ville Talvalaacbc4512013-03-16 16:53:28 -0700818 *+--------------------+---------------+--------------------+------------------+
819 *
820 * mode = AE_MODE_ON_* / AWB_MODE_AUTO
821 *| state | trans. cause | new state | notes |
822 *+--------------------+---------------+--------------------+------------------+
823 *| INACTIVE | HAL initiates | SEARCHING | |
824 *| | AE/AWB scan | | |
825 *+--------------------+---------------+--------------------+------------------+
826 *| INACTIVE | AE/AWB_LOCK | LOCKED | values locked |
827 *| | on | | |
828 *+--------------------+---------------+--------------------+------------------+
829 *| SEARCHING | HAL finishes | CONVERGED | good values, not |
830 *| | AE/AWB scan | | changing |
831 *+--------------------+---------------+--------------------+------------------+
832 *| SEARCHING | HAL finishes | FLASH_REQUIRED | converged but too|
833 *| | AE scan | | dark w/o flash |
834 *+--------------------+---------------+--------------------+------------------+
835 *| SEARCHING | AE/AWB_LOCK | LOCKED | values locked |
836 *| | on | | |
837 *+--------------------+---------------+--------------------+------------------+
838 *| CONVERGED | HAL initiates | SEARCHING | values locked |
839 *| | AE/AWB scan | | |
840 *+--------------------+---------------+--------------------+------------------+
841 *| CONVERGED | AE/AWB_LOCK | LOCKED | values locked |
842 *| | on | | |
843 *+--------------------+---------------+--------------------+------------------+
Eino-Ville Talvala73dba5e2013-05-21 16:29:14 -0700844 *| FLASH_REQUIRED | HAL initiates | SEARCHING | values locked |
845 *| | AE/AWB scan | | |
846 *+--------------------+---------------+--------------------+------------------+
847 *| FLASH_REQUIRED | AE/AWB_LOCK | LOCKED | values locked |
848 *| | on | | |
849 *+--------------------+---------------+--------------------+------------------+
Eino-Ville Talvalaacbc4512013-03-16 16:53:28 -0700850 *| LOCKED | AE/AWB_LOCK | SEARCHING | values not good |
851 *| | off | | after unlock |
852 *+--------------------+---------------+--------------------+------------------+
853 *| LOCKED | AE/AWB_LOCK | CONVERGED | values good |
854 *| | off | | after unlock |
855 *+--------------------+---------------+--------------------+------------------+
856 *| LOCKED | AE_LOCK | FLASH_REQUIRED | exposure good, |
857 *| | off | | but too dark |
858 *+--------------------+---------------+--------------------+------------------+
859 *| All AE states | PRECAPTURE_ | PRECAPTURE | Start precapture |
860 *| | START | | sequence |
861 *+--------------------+---------------+--------------------+------------------+
862 *| PRECAPTURE | Sequence done.| CONVERGED | Ready for high- |
863 *| | AE_LOCK off | | quality capture |
864 *+--------------------+---------------+--------------------+------------------+
865 *| PRECAPTURE | Sequence done.| LOCKED | Ready for high- |
866 *| | AE_LOCK on | | quality capture |
867 *+--------------------+---------------+--------------------+------------------+
868 *
869 */
870
871/**
Eino-Ville Talvalab6059442013-04-29 15:26:16 -0700872 * S5. Cropping:
873 *
874 * Cropping of the full pixel array (for digital zoom and other use cases where
875 * a smaller FOV is desirable) is communicated through the
876 * ANDROID_SCALER_CROP_REGION setting. This is a per-request setting, and can
877 * change on a per-request basis, which is critical for implementing smooth
878 * digital zoom.
879 *
880 * The region is defined as a rectangle (x, y, width, height), with (x, y)
881 * describing the top-left corner of the rectangle. The rectangle is defined on
882 * the coordinate system of the sensor active pixel array, with (0,0) being the
883 * top-left pixel of the active pixel array. Therefore, the width and height
884 * cannot be larger than the dimensions reported in the
885 * ANDROID_SENSOR_ACTIVE_PIXEL_ARRAY static info field. The minimum allowed
886 * width and height are reported by the HAL through the
887 * ANDROID_SCALER_MAX_DIGITAL_ZOOM static info field, which describes the
888 * maximum supported zoom factor. Therefore, the minimum crop region width and
889 * height are:
890 *
891 * {width, height} =
892 * { floor(ANDROID_SENSOR_ACTIVE_PIXEL_ARRAY[0] /
893 * ANDROID_SCALER_MAX_DIGITAL_ZOOM),
894 * floor(ANDROID_SENSOR_ACTIVE_PIXEL_ARRAY[1] /
895 * ANDROID_SCALER_MAX_DIGITAL_ZOOM) }
896 *
897 * If the crop region needs to fulfill specific requirements (for example, it
898 * needs to start on even coordinates, and its width/height needs to be even),
899 * the HAL must do the necessary rounding and write out the final crop region
900 * used in the output result metadata. Similarly, if the HAL implements video
901 * stabilization, it must adjust the result crop region to describe the region
902 * actually included in the output after video stabilization is applied. In
903 * general, a camera-using application must be able to determine the field of
904 * view it is receiving based on the crop region, the dimensions of the image
905 * sensor, and the lens focal length.
906 *
Zhijun Hef1ee67e2014-05-21 11:18:51 -0700907 * It is assumed that the cropping is applied after raw to other color space
908 * conversion. Raw streams (RAW16 and RAW_OPAQUE) don't have this conversion stage,
909 * and are not croppable. Therefore, the crop region must be ignored by the HAL
910 * for raw streams.
911 *
912 * Since the crop region applies to all non-raw streams, which may have different aspect
Eino-Ville Talvalab6059442013-04-29 15:26:16 -0700913 * ratios than the crop region, the exact sensor region used for each stream may
914 * be smaller than the crop region. Specifically, each stream should maintain
915 * square pixels and its aspect ratio by minimally further cropping the defined
916 * crop region. If the stream's aspect ratio is wider than the crop region, the
917 * stream should be further cropped vertically, and if the stream's aspect ratio
918 * is narrower than the crop region, the stream should be further cropped
919 * horizontally.
920 *
921 * In all cases, the stream crop must be centered within the full crop region,
922 * and each stream is only either cropped horizontally or vertical relative to
923 * the full crop region, never both.
924 *
925 * For example, if two streams are defined, a 640x480 stream (4:3 aspect), and a
926 * 1280x720 stream (16:9 aspect), below demonstrates the expected output regions
927 * for each stream for a few sample crop regions, on a hypothetical 3 MP (2000 x
928 * 1500 pixel array) sensor.
929 *
930 * Crop region: (500, 375, 1000, 750) (4:3 aspect ratio)
931 *
932 * 640x480 stream crop: (500, 375, 1000, 750) (equal to crop region)
933 * 1280x720 stream crop: (500, 469, 1000, 562) (marked with =)
934 *
935 * 0 1000 2000
936 * +---------+---------+---------+----------+
937 * | Active pixel array |
938 * | |
939 * | |
940 * + +-------------------+ + 375
941 * | | | |
942 * | O===================O |
943 * | I 1280x720 stream I |
944 * + I I + 750
945 * | I I |
946 * | O===================O |
947 * | | | |
948 * + +-------------------+ + 1125
949 * | Crop region, 640x480 stream |
950 * | |
951 * | |
952 * +---------+---------+---------+----------+ 1500
953 *
954 * Crop region: (500, 375, 1333, 750) (16:9 aspect ratio)
955 *
956 * 640x480 stream crop: (666, 375, 1000, 750) (marked with =)
957 * 1280x720 stream crop: (500, 375, 1333, 750) (equal to crop region)
958 *
959 * 0 1000 2000
960 * +---------+---------+---------+----------+
961 * | Active pixel array |
962 * | |
963 * | |
964 * + +---O==================O---+ + 375
965 * | | I 640x480 stream I | |
966 * | | I I | |
967 * | | I I | |
968 * + | I I | + 750
969 * | | I I | |
970 * | | I I | |
971 * | | I I | |
972 * + +---O==================O---+ + 1125
973 * | Crop region, 1280x720 stream |
974 * | |
975 * | |
976 * +---------+---------+---------+----------+ 1500
977 *
978 * Crop region: (500, 375, 750, 750) (1:1 aspect ratio)
979 *
980 * 640x480 stream crop: (500, 469, 750, 562) (marked with =)
981 * 1280x720 stream crop: (500, 543, 750, 414) (marged with #)
982 *
983 * 0 1000 2000
984 * +---------+---------+---------+----------+
985 * | Active pixel array |
986 * | |
987 * | |
988 * + +--------------+ + 375
989 * | O==============O |
990 * | ################ |
991 * | # # |
992 * + # # + 750
993 * | # # |
994 * | ################ 1280x720 |
995 * | O==============O 640x480 |
996 * + +--------------+ + 1125
997 * | Crop region |
998 * | |
999 * | |
1000 * +---------+---------+---------+----------+ 1500
1001 *
1002 * And a final example, a 1024x1024 square aspect ratio stream instead of the
1003 * 480p stream:
1004 *
1005 * Crop region: (500, 375, 1000, 750) (4:3 aspect ratio)
1006 *
1007 * 1024x1024 stream crop: (625, 375, 750, 750) (marked with #)
1008 * 1280x720 stream crop: (500, 469, 1000, 562) (marked with =)
1009 *
1010 * 0 1000 2000
1011 * +---------+---------+---------+----------+
1012 * | Active pixel array |
1013 * | |
1014 * | 1024x1024 stream |
1015 * + +--###############--+ + 375
1016 * | | # # | |
1017 * | O===================O |
1018 * | I 1280x720 stream I |
1019 * + I I + 750
1020 * | I I |
1021 * | O===================O |
1022 * | | # # | |
1023 * + +--###############--+ + 1125
1024 * | Crop region |
1025 * | |
1026 * | |
1027 * +---------+---------+---------+----------+ 1500
1028 *
1029 */
1030
1031/**
1032 * S6. Error management:
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001033 *
1034 * Camera HAL device ops functions that have a return value will all return
1035 * -ENODEV / NULL in case of a serious error. This means the device cannot
1036 * continue operation, and must be closed by the framework. Once this error is
Alex Rayd5ddbc92013-02-15 13:47:24 -08001037 * returned by some method, or if notify() is called with ERROR_DEVICE, only
1038 * the close() method can be called successfully. All other methods will return
1039 * -ENODEV / NULL.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001040 *
Eino-Ville Talvalaacbc4512013-03-16 16:53:28 -07001041 * If a device op is called in the wrong sequence, for example if the framework
1042 * calls configure_streams() is called before initialize(), the device must
1043 * return -ENOSYS from the call, and do nothing.
1044 *
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001045 * Transient errors in image capture must be reported through notify() as follows:
1046 *
1047 * - The failure of an entire capture to occur must be reported by the HAL by
1048 * calling notify() with ERROR_REQUEST. Individual errors for the result
1049 * metadata or the output buffers must not be reported in this case.
1050 *
1051 * - If the metadata for a capture cannot be produced, but some image buffers
1052 * were filled, the HAL must call notify() with ERROR_RESULT.
1053 *
1054 * - If an output image buffer could not be filled, but either the metadata was
1055 * produced or some other buffers were filled, the HAL must call notify() with
1056 * ERROR_BUFFER for each failed buffer.
1057 *
1058 * In each of these transient failure cases, the HAL must still call
Zhijun Heceac9e32014-02-05 20:49:45 -08001059 * process_capture_result, with valid output and input (if an input buffer was
1060 * submitted) buffer_handle_t. If the result metadata could not be produced, it
1061 * should be NULL. If some buffers could not be filled, they must be returned with
1062 * process_capture_result in the error state, their release fences must be set to
1063 * the acquire fences passed by the framework, or -1 if they have been waited on by
1064 * the HAL already.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001065 *
Eino-Ville Talvalaacbc4512013-03-16 16:53:28 -07001066 * Invalid input arguments result in -EINVAL from the appropriate methods. In
1067 * that case, the framework must act as if that call had never been made.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001068 *
1069 */
1070
Zhijun He2dde4682014-01-09 09:11:49 -08001071/**
Zhijun He709e5872014-01-17 15:25:21 -08001072 * S7. Key Performance Indicator (KPI) glossary:
Zhijun He2dde4682014-01-09 09:11:49 -08001073 *
Zhijun He709e5872014-01-17 15:25:21 -08001074 * This includes some critical definitions that are used by KPI metrics.
Zhijun He2dde4682014-01-09 09:11:49 -08001075 *
1076 * Pipeline Latency:
1077 * For a given capture request, the duration from the framework calling
1078 * process_capture_request to the HAL sending capture result and all buffers
1079 * back by process_capture_result call. To make the Pipeline Latency measure
1080 * independent of frame rate, it is measured by frame count.
1081 *
1082 * For example, when frame rate is 30 (fps), the frame duration (time interval
1083 * between adjacent frame capture time) is 33 (ms).
1084 * If it takes 5 frames for framework to get the result and buffers back for
1085 * a given request, then the Pipeline Latency is 5 (frames), instead of
1086 * 5 x 33 = 165 (ms).
1087 *
1088 * The Pipeline Latency is determined by android.request.pipelineDepth and
1089 * android.request.pipelineMaxDepth, see their definitions for more details.
1090 *
1091 */
1092
Zhijun Hebc358682014-01-23 14:42:54 -08001093/**
1094 * S8. Sample Use Cases:
1095 *
1096 * This includes some typical use case examples the camera HAL may support.
1097 *
Zhijun Heb2bc0e52015-01-29 14:44:37 -08001098 * S8.1 Zero Shutter Lag (ZSL) with CAMERA3_STREAM_BIDIRECTIONAL stream.
Zhijun Hebc358682014-01-23 14:42:54 -08001099 *
1100 * For this use case, the bidirectional stream will be used by the framework as follows:
1101 *
1102 * 1. The framework includes a buffer from this stream as output buffer in a
1103 * request as normal.
1104 *
1105 * 2. Once the HAL device returns a filled output buffer to the framework,
1106 * the framework may do one of two things with the filled buffer:
1107 *
1108 * 2. a. The framework uses the filled data, and returns the now-used buffer
1109 * to the stream queue for reuse. This behavior exactly matches the
1110 * OUTPUT type of stream.
1111 *
1112 * 2. b. The framework wants to reprocess the filled data, and uses the
1113 * buffer as an input buffer for a request. Once the HAL device has
1114 * used the reprocessing buffer, it then returns it to the
1115 * framework. The framework then returns the now-used buffer to the
1116 * stream queue for reuse.
1117 *
1118 * 3. The HAL device will be given the buffer again as an output buffer for
1119 * a request at some future point.
1120 *
1121 * For ZSL use case, the pixel format for bidirectional stream will be
Zhijun He52a18892014-06-30 10:35:58 -07001122 * HAL_PIXEL_FORMAT_RAW_OPAQUE or HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED if it
1123 * is listed in android.scaler.availableInputOutputFormatsMap. When
1124 * HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED is used, the gralloc
1125 * usage flags for the consumer endpoint will be set to GRALLOC_USAGE_HW_CAMERA_ZSL.
1126 * A configuration stream list that has BIDIRECTIONAL stream used as input, will
1127 * usually also have a distinct OUTPUT stream to get the reprocessing data. For example,
1128 * for the ZSL use case, the stream list might be configured with the following:
Zhijun Hebc358682014-01-23 14:42:54 -08001129 *
1130 * - A HAL_PIXEL_FORMAT_RAW_OPAQUE bidirectional stream is used
1131 * as input.
1132 * - And a HAL_PIXEL_FORMAT_BLOB (JPEG) output stream.
1133 *
Zhijun Heebdf1282015-01-16 16:44:40 -08001134 * S8.2 ZSL (OPAQUE) reprocessing with CAMERA3_STREAM_INPUT stream.
1135 *
1136 * CAMERA_DEVICE_API_VERSION_3_3:
1137 * When OPAQUE_REPROCESSING capability is supported by the camera device, the INPUT stream
1138 * can be used for application/framework implemented use case like Zero Shutter Lag (ZSL).
1139 * This kind of stream will be used by the framework as follows:
1140 *
1141 * 1. Application/framework configures an opaque (RAW or YUV based) format output stream that is
1142 * used to produce the ZSL output buffers. The stream pixel format will be
1143 * HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED.
1144 *
1145 * 2. Application/framework configures an opaque format input stream that is used to
1146 * send the reprocessing ZSL buffers to the HAL. The stream pixel format will
1147 * also be HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED.
1148 *
1149 * 3. Application/framework configures a YUV/JPEG output stream that is used to receive the
1150 * reprocessed data. The stream pixel format will be YCbCr_420/HAL_PIXEL_FORMAT_BLOB.
1151 *
1152 * 4. Application/framework picks a ZSL buffer from the ZSL output stream when a ZSL capture is
1153 * issued by the application, and sends the data back as an input buffer in a
1154 * reprocessing request, then sends to the HAL for reprocessing.
1155 *
1156 * 5. The HAL sends back the output YUV/JPEG result to framework.
1157 *
1158 * The HAL can select the actual opaque buffer format and configure the ISP pipeline
1159 * appropriately based on the HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED format and
1160 * the gralloc usage flag GRALLOC_USAGE_HW_CAMERA_ZSL.
1161
1162 * S8.3 YUV reprocessing with CAMERA3_STREAM_INPUT stream.
1163 *
1164 * When YUV reprocessing is supported by the HAL, the INPUT stream
1165 * can be used for the YUV reprocessing use cases like lucky-shot and image fusion.
1166 * This kind of stream will be used by the framework as follows:
1167 *
1168 * 1. Application/framework configures an YCbCr_420 format output stream that is
1169 * used to produce the output buffers.
1170 *
1171 * 2. Application/framework configures an YCbCr_420 format input stream that is used to
1172 * send the reprocessing YUV buffers to the HAL.
1173 *
1174 * 3. Application/framework configures a YUV/JPEG output stream that is used to receive the
1175 * reprocessed data. The stream pixel format will be YCbCr_420/HAL_PIXEL_FORMAT_BLOB.
1176 *
1177 * 4. Application/framework processes the output buffers (could be as simple as picking
1178 * an output buffer directly) from the output stream when a capture is issued, and sends
1179 * the data back as an input buffer in a reprocessing request, then sends to the HAL
1180 * for reprocessing.
1181 *
1182 * 5. The HAL sends back the output YUV/JPEG result to framework.
1183 *
Zhijun Hebc358682014-01-23 14:42:54 -08001184 */
1185
Ruben Brunk2d96c742014-03-18 13:39:17 -07001186/**
1187 * S9. Notes on Controls and Metadata
1188 *
1189 * This section contains notes about the interpretation and usage of various metadata tags.
1190 *
1191 * S9.1 HIGH_QUALITY and FAST modes.
1192 *
1193 * Many camera post-processing blocks may be listed as having HIGH_QUALITY,
1194 * FAST, and OFF operating modes. These blocks will typically also have an
1195 * 'available modes' tag representing which of these operating modes are
1196 * available on a given device. The general policy regarding implementing
1197 * these modes is as follows:
1198 *
1199 * 1. Operating mode controls of hardware blocks that cannot be disabled
1200 * must not list OFF in their corresponding 'available modes' tags.
1201 *
1202 * 2. OFF will always be included in their corresponding 'available modes'
1203 * tag if it is possible to disable that hardware block.
1204 *
1205 * 3. FAST must always be included in the 'available modes' tags for all
1206 * post-processing blocks supported on the device. If a post-processing
1207 * block also has a slower and higher quality operating mode that does
1208 * not meet the framerate requirements for FAST mode, HIGH_QUALITY should
1209 * be included in the 'available modes' tag to represent this operating
1210 * mode.
1211 */
Zhijun Heebdf1282015-01-16 16:44:40 -08001212
1213/**
1214 * S10. Reprocessing flow and controls
1215 *
1216 * This section describes the OPAQUE and YUV reprocessing flow and controls. OPAQUE reprocessing
1217 * uses an opaque format that is not directly application-visible, and the application can
1218 * only select some of the output buffers and send back to HAL for reprocessing, while YUV
1219 * reprocessing gives the application opportunity to process the buffers before reprocessing.
1220 *
1221 * S8 gives the stream configurations for the typical reprocessing uses cases,
1222 * this section specifies the buffer flow and controls in more details.
1223 *
1224 * S10.1 OPAQUE (typically for ZSL use case) reprocessing flow and controls
1225 *
1226 * For OPAQUE reprocessing (e.g. ZSL) use case, after the application creates the specific
1227 * output and input streams, runtime buffer flow and controls are specified as below:
1228 *
1229 * 1. Application starts output streaming by sending repeating requests for output
1230 * opaque buffers and preview. The buffers are held by an application
1231 * maintained circular buffer. The requests are based on CAMERA3_TEMPLATE_ZERO_SHUTTER_LAG
1232 * capture template, which should have all necessary settings that guarantee output
1233 * frame rate is not slowed down relative to sensor output frame rate.
1234 *
1235 * 2. When a capture is issued, the application selects one output buffer based
1236 * on application buffer selection logic, e.g. good AE and AF statistics etc.
1237 * Application then creates an reprocess request based on the capture result associated
1238 * with this selected buffer. The selected output buffer is now added to this reprocess
1239 * request as an input buffer, the output buffer of this reprocess request should be
1240 * either JPEG output buffer or YUV output buffer, or both, depending on the application
1241 * choice.
1242 *
1243 * 3. Application then alters the reprocess settings to get best image quality. The HAL must
1244 * support and only support below controls if the HAL support OPAQUE_REPROCESSING capability:
1245 * - android.jpeg.* (if JPEG buffer is included as one of the output)
1246 * - android.noiseReduction.mode (change to HIGH_QUALITY if it is supported)
1247 * - android.edge.mode (change to HIGH_QUALITY if it is supported)
1248 * All other controls must be ignored by the HAL.
1249 * 4. HAL processed the input buffer and return the output buffers in the capture results
1250 * as normal.
1251 *
1252 * S10.2 YUV reprocessing flow and controls
1253 *
1254 * The YUV reprocessing buffer flow is similar as OPAQUE reprocessing, with below difference:
1255 *
1256 * 1. Application may want to have finer granularity control of the intermediate YUV images
1257 * (before reprocessing). For example, application may choose
1258 * - android.noiseReduction.mode == MINIMAL
1259 * to make sure the no YUV domain noise reduction has applied to the output YUV buffers,
1260 * then it can do its own advanced noise reduction on them. For OPAQUE reprocessing case, this
1261 * doesn't matter, as long as the final reprocessed image has the best quality.
1262 * 2. Application may modify the YUV output buffer data. For example, for image fusion use
1263 * case, where multiple output images are merged together to improve the signal-to-noise
1264 * ratio (SNR). The input buffer may be generated from multiple buffers by the application.
1265 * To avoid excessive amount of noise reduction and insufficient amount of edge enhancement
1266 * being applied to the input buffer, the application can hint the HAL how much effective
1267 * exposure time improvement has been done by the application, then the HAL can adjust the
1268 * noise reduction and edge enhancement paramters to get best reprocessed image quality.
1269 * Below tag can be used for this purpose:
1270 * - android.reprocess.effectiveExposureFactor
1271 * The value would be exposure time increase factor applied to the original output image,
1272 * for example, if there are N image merged, the exposure time increase factor would be up
1273 * to sqrt(N). See this tag spec for more details.
1274 *
1275 * S10.3 Reprocessing pipeline characteristics
1276 *
1277 * Reprocessing pipeline has below different characteristics comparing with normal output
1278 * pipeline:
1279 *
1280 * 1. The reprocessing result can be returned ahead of the pending normal output results. But
1281 * the FIFO ordering must be maintained for all reprocessing results. For example, there are
1282 * below requests (A stands for output requests, B stands for reprocessing requests)
1283 * being processed by the HAL:
1284 * A1, A2, A3, A4, B1, A5, B2, A6...
1285 * result of B1 can be returned before A1-A4, but result of B2 must be returned after B1.
1286 * 2. Single input rule: For a given reprocessing request, all output buffers must be from the
1287 * input buffer, rather than sensor output. For example, if a reprocess request include both
1288 * JPEG and preview buffers, all output buffers must be produced from the input buffer
1289 * included by the reprocessing request, rather than sensor. The HAL must not output preview
1290 * buffers from sensor, while output JPEG buffer from the input buffer.
1291 * 3. Input buffer will be from camera output directly (ZSL case) or indirectly(image fusion
1292 * case). For the case where buffer is modified, the size will remain same. The HAL can
1293 * notify CAMERA3_MSG_ERROR_REQUEST if buffer from unknown source is sent.
1294 * 4. Result as reprocessing request: The HAL can expect that a reprocessing request is a copy
1295 * of one of the output results with minor allowed setting changes. The HAL can notify
1296 * CAMERA3_MSG_ERROR_REQUEST if a request from unknown source is issued.
1297 * 5. Output buffers may not be used as inputs across the configure stream boundary, This is
1298 * because an opaque stream like the ZSL output stream may have different actual image size
1299 * inside of the ZSL buffer to save power and bandwidth for smaller resolution JPEG capture.
1300 * The HAL may notify CAMERA3_MSG_ERROR_REQUEST if this case occurs.
1301 * 6. HAL Reprocess requests error reporting during flush should follow the same rule specified
1302 * by flush() method.
1303 *
1304 */
1305
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001306__BEGIN_DECLS
1307
1308struct camera3_device;
1309
1310/**********************************************************************
1311 *
1312 * Camera3 stream and stream buffer definitions.
1313 *
1314 * These structs and enums define the handles and contents of the input and
1315 * output streams connecting the HAL to various framework and application buffer
1316 * consumers. Each stream is backed by a gralloc buffer queue.
1317 *
1318 */
1319
1320/**
1321 * camera3_stream_type_t:
1322 *
1323 * The type of the camera stream, which defines whether the camera HAL device is
1324 * the producer or the consumer for that stream, and how the buffers of the
1325 * stream relate to the other streams.
1326 */
1327typedef enum camera3_stream_type {
1328 /**
1329 * This stream is an output stream; the camera HAL device will be
1330 * responsible for filling buffers from this stream with newly captured or
1331 * reprocessed image data.
1332 */
1333 CAMERA3_STREAM_OUTPUT = 0,
1334
1335 /**
1336 * This stream is an input stream; the camera HAL device will be responsible
1337 * for reading buffers from this stream and sending them through the camera
1338 * processing pipeline, as if the buffer was a newly captured image from the
1339 * imager.
Zhijun Hebc358682014-01-23 14:42:54 -08001340 *
1341 * The pixel format for input stream can be any format reported by
Eino-Ville Talvalac5bff0d2014-02-10 16:43:26 -08001342 * android.scaler.availableInputOutputFormatsMap. The pixel format of the
1343 * output stream that is used to produce the reprocessing data may be any
1344 * format reported by android.scaler.availableStreamConfigurations. The
1345 * supported input/output stream combinations depends the camera device
1346 * capabilities, see android.scaler.availableInputOutputFormatsMap for
1347 * stream map details.
Zhijun Hebc358682014-01-23 14:42:54 -08001348 *
Eino-Ville Talvalac5bff0d2014-02-10 16:43:26 -08001349 * This kind of stream is generally used to reprocess data into higher
1350 * quality images (that otherwise would cause a frame rate performance
1351 * loss), or to do off-line reprocessing.
Zhijun Hebc358682014-01-23 14:42:54 -08001352 *
Zhijun Heebdf1282015-01-16 16:44:40 -08001353 * CAMERA_DEVICE_API_VERSION_3_3:
1354 * The typical use cases are OPAQUE (typically ZSL) and YUV reprocessing,
1355 * see S8.2, S8.3 and S10 for more details.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001356 */
1357 CAMERA3_STREAM_INPUT = 1,
1358
1359 /**
1360 * This stream can be used for input and output. Typically, the stream is
1361 * used as an output stream, but occasionally one already-filled buffer may
1362 * be sent back to the HAL device for reprocessing.
1363 *
Eino-Ville Talvalac5bff0d2014-02-10 16:43:26 -08001364 * This kind of stream is meant generally for Zero Shutter Lag (ZSL)
1365 * features, where copying the captured image from the output buffer to the
Zhijun Heb2bc0e52015-01-29 14:44:37 -08001366 * reprocessing input buffer would be expensive. See S8.1 for more details.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001367 *
1368 * Note that the HAL will always be reprocessing data it produced.
1369 *
1370 */
1371 CAMERA3_STREAM_BIDIRECTIONAL = 2,
1372
1373 /**
1374 * Total number of framework-defined stream types
1375 */
1376 CAMERA3_NUM_STREAM_TYPES
1377
1378} camera3_stream_type_t;
1379
1380/**
Yin-Chia Yehe0042082015-03-09 12:15:36 -07001381 * camera3_stream_rotation_t:
1382 *
1383 * The required counterclockwise rotation of camera stream.
1384 */
1385typedef enum camera3_stream_rotation {
1386 /* No rotation */
1387 CAMERA3_STREAM_ROTATION_0 = 0,
1388
1389 /* Rotate by 90 degree counterclockwise */
1390 CAMERA3_STREAM_ROTATION_90 = 1,
1391
1392 /* Rotate by 180 degree counterclockwise */
1393 CAMERA3_STREAM_ROTATION_180 = 2,
1394
1395 /* Rotate by 270 degree counterclockwise */
1396 CAMERA3_STREAM_ROTATION_270 = 3
1397} camera3_stream_rotation_t;
1398
1399/**
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001400 * camera3_stream_t:
1401 *
1402 * A handle to a single camera input or output stream. A stream is defined by
1403 * the framework by its buffer resolution and format, and additionally by the
1404 * HAL with the gralloc usage flags and the maximum in-flight buffer count.
1405 *
1406 * The stream structures are owned by the framework, but pointers to a
1407 * camera3_stream passed into the HAL by configure_streams() are valid until the
1408 * end of the first subsequent configure_streams() call that _does not_ include
1409 * that camera3_stream as an argument, or until the end of the close() call.
1410 *
1411 * All camera3_stream framework-controlled members are immutable once the
1412 * camera3_stream is passed into configure_streams(). The HAL may only change
1413 * the HAL-controlled parameters during a configure_streams() call, except for
1414 * the contents of the private pointer.
1415 *
1416 * If a configure_streams() call returns a non-fatal error, all active streams
1417 * remain valid as if configure_streams() had not been called.
1418 *
1419 * The endpoint of the stream is not visible to the camera HAL device.
Alex Ray2ce219a2013-06-14 15:09:30 -07001420 * In DEVICE_API_VERSION_3_1, this was changed to share consumer usage flags
1421 * on streams where the camera is a producer (OUTPUT and BIDIRECTIONAL stream
1422 * types) see the usage field below.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001423 */
1424typedef struct camera3_stream {
1425
1426 /*****
1427 * Set by framework before configure_streams()
1428 */
1429
1430 /**
1431 * The type of the stream, one of the camera3_stream_type_t values.
1432 */
1433 int stream_type;
1434
1435 /**
1436 * The width in pixels of the buffers in this stream
1437 */
1438 uint32_t width;
1439
1440 /**
1441 * The height in pixels of the buffers in this stream
1442 */
1443 uint32_t height;
1444
1445 /**
1446 * The pixel format for the buffers in this stream. Format is a value from
1447 * the HAL_PIXEL_FORMAT_* list in system/core/include/system/graphics.h, or
1448 * from device-specific headers.
1449 *
1450 * If HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED is used, then the platform
1451 * gralloc module will select a format based on the usage flags provided by
1452 * the camera device and the other endpoint of the stream.
1453 *
Igor Murashkin78aa1262014-01-09 16:23:43 -08001454 * <= CAMERA_DEVICE_API_VERSION_3_1:
1455 *
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001456 * The camera HAL device must inspect the buffers handed to it in the
1457 * subsequent register_stream_buffers() call to obtain the
1458 * implementation-specific format details, if necessary.
Igor Murashkin78aa1262014-01-09 16:23:43 -08001459 *
1460 * >= CAMERA_DEVICE_API_VERSION_3_2:
1461 *
1462 * register_stream_buffers() won't be called by the framework, so the HAL
1463 * should configure the ISP and sensor pipeline based purely on the sizes,
1464 * usage flags, and formats for the configured streams.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001465 */
1466 int format;
1467
1468 /*****
1469 * Set by HAL during configure_streams().
1470 */
1471
1472 /**
1473 * The gralloc usage flags for this stream, as needed by the HAL. The usage
1474 * flags are defined in gralloc.h (GRALLOC_USAGE_*), or in device-specific
1475 * headers.
1476 *
1477 * For output streams, these are the HAL's producer usage flags. For input
1478 * streams, these are the HAL's consumer usage flags. The usage flags from
1479 * the producer and the consumer will be combined together and then passed
1480 * to the platform gralloc HAL module for allocating the gralloc buffers for
1481 * each stream.
Alex Ray2ce219a2013-06-14 15:09:30 -07001482 *
1483 * Version information:
1484 *
1485 * == CAMERA_DEVICE_API_VERSION_3_0:
1486 *
1487 * No initial value guaranteed when passed via configure_streams().
1488 * HAL may not use this field as input, and must write over this field
1489 * with its usage flags.
1490 *
1491 * >= CAMERA_DEVICE_API_VERSION_3_1:
1492 *
1493 * For stream_type OUTPUT and BIDIRECTIONAL, when passed via
1494 * configure_streams(), the initial value of this is the consumer's
1495 * usage flags. The HAL may use these consumer flags to decide stream
1496 * configuration.
1497 * For stream_type INPUT, when passed via configure_streams(), the initial
1498 * value of this is 0.
1499 * For all streams passed via configure_streams(), the HAL must write
1500 * over this field with its usage flags.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001501 */
1502 uint32_t usage;
1503
1504 /**
1505 * The maximum number of buffers the HAL device may need to have dequeued at
1506 * the same time. The HAL device may not have more buffers in-flight from
1507 * this stream than this value.
1508 */
1509 uint32_t max_buffers;
1510
1511 /**
1512 * A handle to HAL-private information for the stream. Will not be inspected
1513 * by the framework code.
1514 */
1515 void *priv;
1516
Eino-Ville Talvala453c7902015-03-06 13:22:03 -08001517 /**
1518 * A field that describes the contents of the buffer. The format and buffer
1519 * dimensions define the memory layout and structure of the stream buffers,
1520 * while dataSpace defines the meaning of the data within the buffer.
1521 *
1522 * For most formats, dataSpace defines the color space of the image data.
1523 * In addition, for some formats, dataSpace indicates whether image- or
1524 * depth-based data is requested. See system/core/include/system/graphics.h
1525 * for details of formats and valid dataSpace values for each format.
1526 *
1527 * Version information:
1528 *
1529 * < CAMERA_DEVICE_API_VERSION_3_3:
1530 *
1531 * Not defined and should not be accessed. dataSpace should be assumed to
1532 * be HAL_DATASPACE_UNKNOWN, and the appropriate color space, etc, should
1533 * be determined from the usage flags and the format.
1534 *
1535 * >= CAMERA_DEVICE_API_VERSION_3_3:
1536 *
1537 * Always set by the camera service. HAL must use this dataSpace to
1538 * configure the stream to the correct colorspace, or to select between
1539 * color and depth outputs if supported.
1540 */
1541 android_dataspace_t data_space;
1542
Yin-Chia Yehe0042082015-03-09 12:15:36 -07001543 /**
1544 * The required output rotation of the stream, one of
1545 * the camera3_stream_rotation_t values. This must be inspected by HAL along
1546 * with stream width and height. For example, if the rotation is 90 degree
1547 * and the stream width and height is 720 and 1280 respectively, camera service
1548 * will supply buffers of size 720x1280, and HAL should capture a 1280x720 image
Yin-Chia Yeh5407ef12015-03-12 15:09:27 -07001549 * and rotate the image by 90 degree counterclockwise. The rotation field is
1550 * no-op when the stream type is input. Camera HAL must ignore the rotation
1551 * field for an input stream.
Yin-Chia Yehe0042082015-03-09 12:15:36 -07001552 *
1553 * <= CAMERA_DEVICE_API_VERSION_3_2:
1554 *
1555 * Not defined and must not be accessed. HAL must not apply any rotation
1556 * on output images.
1557 *
1558 * >= CAMERA_DEVICE_API_VERSION_3_3:
1559 *
1560 * Always set by camera service. HAL must inspect this field during stream
1561 * configuration and returns -EINVAL if HAL cannot perform such rotation.
1562 * HAL must always support CAMERA3_STREAM_ROTATION_0, so a
1563 * configure_streams() call must not fail for unsupported rotation if
1564 * rotation field of all streams is CAMERA3_STREAM_ROTATION_0.
1565 *
1566 */
1567 int rotation;
1568
Eino-Ville Talvala453c7902015-03-06 13:22:03 -08001569 /* reserved for future use */
Yin-Chia Yehe0042082015-03-09 12:15:36 -07001570 void *reserved[7];
Eino-Ville Talvala453c7902015-03-06 13:22:03 -08001571
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001572} camera3_stream_t;
1573
1574/**
1575 * camera3_stream_configuration_t:
1576 *
1577 * A structure of stream definitions, used by configure_streams(). This
1578 * structure defines all the output streams and the reprocessing input
1579 * stream for the current camera use case.
1580 */
1581typedef struct camera3_stream_configuration {
1582 /**
1583 * The total number of streams requested by the framework. This includes
1584 * both input and output streams. The number of streams will be at least 1,
1585 * and there will be at least one output-capable stream.
1586 */
1587 uint32_t num_streams;
1588
1589 /**
Eino-Ville Talvala3a6e6b42013-03-06 13:21:11 -08001590 * An array of camera stream pointers, defining the input/output
1591 * configuration for the camera HAL device.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001592 *
1593 * At most one input-capable stream may be defined (INPUT or BIDIRECTIONAL)
1594 * in a single configuration.
1595 *
1596 * At least one output-capable stream must be defined (OUTPUT or
1597 * BIDIRECTIONAL).
1598 */
Eino-Ville Talvala3a6e6b42013-03-06 13:21:11 -08001599 camera3_stream_t **streams;
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001600
1601} camera3_stream_configuration_t;
1602
1603/**
Eino-Ville Talvala2f8cf5c2013-03-06 13:23:31 -08001604 * camera3_buffer_status_t:
1605 *
1606 * The current status of a single stream buffer.
1607 */
1608typedef enum camera3_buffer_status {
1609 /**
1610 * The buffer is in a normal state, and can be used after waiting on its
1611 * sync fence.
1612 */
1613 CAMERA3_BUFFER_STATUS_OK = 0,
1614
1615 /**
1616 * The buffer does not contain valid data, and the data in it should not be
1617 * used. The sync fence must still be waited on before reusing the buffer.
1618 */
1619 CAMERA3_BUFFER_STATUS_ERROR = 1
1620
1621} camera3_buffer_status_t;
1622
1623/**
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001624 * camera3_stream_buffer_t:
1625 *
1626 * A single buffer from a camera3 stream. It includes a handle to its parent
1627 * stream, the handle to the gralloc buffer itself, and sync fences
1628 *
1629 * The buffer does not specify whether it is to be used for input or output;
1630 * that is determined by its parent stream type and how the buffer is passed to
1631 * the HAL device.
1632 */
1633typedef struct camera3_stream_buffer {
1634 /**
1635 * The handle of the stream this buffer is associated with
1636 */
1637 camera3_stream_t *stream;
1638
1639 /**
1640 * The native handle to the buffer
1641 */
1642 buffer_handle_t *buffer;
1643
1644 /**
Eino-Ville Talvala2f8cf5c2013-03-06 13:23:31 -08001645 * Current state of the buffer, one of the camera3_buffer_status_t
1646 * values. The framework will not pass buffers to the HAL that are in an
1647 * error state. In case a buffer could not be filled by the HAL, it must
1648 * have its status set to CAMERA3_BUFFER_STATUS_ERROR when returned to the
1649 * framework with process_capture_result().
1650 */
1651 int status;
1652
1653 /**
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001654 * The acquire sync fence for this buffer. The HAL must wait on this fence
1655 * fd before attempting to read from or write to this buffer.
1656 *
1657 * The framework may be set to -1 to indicate that no waiting is necessary
Eino-Ville Talvala2f8cf5c2013-03-06 13:23:31 -08001658 * for this buffer.
1659 *
1660 * When the HAL returns an output buffer to the framework with
1661 * process_capture_result(), the acquire_fence must be set to -1. If the HAL
1662 * never waits on the acquire_fence due to an error in filling a buffer,
1663 * when calling process_capture_result() the HAL must set the release_fence
1664 * of the buffer to be the acquire_fence passed to it by the framework. This
1665 * will allow the framework to wait on the fence before reusing the buffer.
1666 *
1667 * For input buffers, the HAL must not change the acquire_fence field during
1668 * the process_capture_request() call.
Zhijun Heceac9e32014-02-05 20:49:45 -08001669 *
1670 * >= CAMERA_DEVICE_API_VERSION_3_2:
1671 *
1672 * When the HAL returns an input buffer to the framework with
1673 * process_capture_result(), the acquire_fence must be set to -1. If the HAL
Eino-Ville Talvalac5bff0d2014-02-10 16:43:26 -08001674 * never waits on input buffer acquire fence due to an error, the sync
1675 * fences should be handled similarly to the way they are handled for output
1676 * buffers.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001677 */
1678 int acquire_fence;
1679
1680 /**
1681 * The release sync fence for this buffer. The HAL must set this fence when
1682 * returning buffers to the framework, or write -1 to indicate that no
1683 * waiting is required for this buffer.
1684 *
Zhijun Heceac9e32014-02-05 20:49:45 -08001685 * For the output buffers, the fences must be set in the output_buffers
1686 * array passed to process_capture_result().
1687 *
1688 * <= CAMERA_DEVICE_API_VERSION_3_1:
1689 *
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001690 * For the input buffer, the release fence must be set by the
Zhijun Heceac9e32014-02-05 20:49:45 -08001691 * process_capture_request() call.
Eino-Ville Talvala2f8cf5c2013-03-06 13:23:31 -08001692 *
Igor Murashkin78aa1262014-01-09 16:23:43 -08001693 * >= CAMERA_DEVICE_API_VERSION_3_2:
1694 *
Zhijun Heceac9e32014-02-05 20:49:45 -08001695 * For the input buffer, the fences must be set in the input_buffer
1696 * passed to process_capture_result().
1697 *
Igor Murashkin78aa1262014-01-09 16:23:43 -08001698 * After signaling the release_fence for this buffer, the HAL
1699 * should not make any further attempts to access this buffer as the
1700 * ownership has been fully transferred back to the framework.
1701 *
1702 * If a fence of -1 was specified then the ownership of this buffer
1703 * is transferred back immediately upon the call of process_capture_result.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001704 */
1705 int release_fence;
1706
1707} camera3_stream_buffer_t;
1708
1709/**
1710 * camera3_stream_buffer_set_t:
1711 *
1712 * The complete set of gralloc buffers for a stream. This structure is given to
1713 * register_stream_buffers() to allow the camera HAL device to register/map/etc
1714 * newly allocated stream buffers.
Igor Murashkin78aa1262014-01-09 16:23:43 -08001715 *
1716 * >= CAMERA_DEVICE_API_VERSION_3_2:
1717 *
1718 * Deprecated (and not used). In particular,
1719 * register_stream_buffers is also deprecated and will never be invoked.
1720 *
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001721 */
1722typedef struct camera3_stream_buffer_set {
1723 /**
1724 * The stream handle for the stream these buffers belong to
1725 */
1726 camera3_stream_t *stream;
1727
1728 /**
1729 * The number of buffers in this stream. It is guaranteed to be at least
1730 * stream->max_buffers.
1731 */
1732 uint32_t num_buffers;
1733
1734 /**
1735 * The array of gralloc buffer handles for this stream. If the stream format
1736 * is set to HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, the camera HAL device
1737 * should inspect the passed-in buffers to determine any platform-private
1738 * pixel format information.
1739 */
Eino-Ville Talvala3a6e6b42013-03-06 13:21:11 -08001740 buffer_handle_t **buffers;
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001741
1742} camera3_stream_buffer_set_t;
1743
1744/**
1745 * camera3_jpeg_blob:
1746 *
1747 * Transport header for compressed JPEG buffers in output streams.
1748 *
1749 * To capture JPEG images, a stream is created using the pixel format
Zhijun He44a89152014-04-24 14:34:53 -07001750 * HAL_PIXEL_FORMAT_BLOB. The buffer size for the stream is calculated by the
1751 * framework, based on the static metadata field android.jpeg.maxSize. Since
1752 * compressed JPEG images are of variable size, the HAL needs to include the
1753 * final size of the compressed image using this structure inside the output
1754 * stream buffer. The JPEG blob ID field must be set to CAMERA3_JPEG_BLOB_ID.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001755 *
Zhijun He44a89152014-04-24 14:34:53 -07001756 * Transport header should be at the end of the JPEG output stream buffer. That
1757 * means the jpeg_blob_id must start at byte[buffer_size -
1758 * sizeof(camera3_jpeg_blob)], where the buffer_size is the size of gralloc buffer.
1759 * Any HAL using this transport header must account for it in android.jpeg.maxSize
1760 * The JPEG data itself starts at the beginning of the buffer and should be
1761 * jpeg_size bytes long.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001762 */
1763typedef struct camera3_jpeg_blob {
1764 uint16_t jpeg_blob_id;
1765 uint32_t jpeg_size;
1766} camera3_jpeg_blob_t;
1767
1768enum {
1769 CAMERA3_JPEG_BLOB_ID = 0x00FF
1770};
1771
1772/**********************************************************************
1773 *
1774 * Message definitions for the HAL notify() callback.
1775 *
1776 * These definitions are used for the HAL notify callback, to signal
1777 * asynchronous events from the HAL device to the Android framework.
1778 *
1779 */
1780
1781/**
1782 * camera3_msg_type:
1783 *
1784 * Indicates the type of message sent, which specifies which member of the
1785 * message union is valid.
1786 *
1787 */
1788typedef enum camera3_msg_type {
1789 /**
1790 * An error has occurred. camera3_notify_msg.message.error contains the
1791 * error information.
1792 */
1793 CAMERA3_MSG_ERROR = 1,
1794
1795 /**
Chien-Yu Chen73b49eb2015-05-28 17:13:05 -07001796 * The exposure of a given request or processing a reprocess request has
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001797 * begun. camera3_notify_msg.message.shutter contains the information
1798 * the capture.
1799 */
1800 CAMERA3_MSG_SHUTTER = 2,
1801
1802 /**
1803 * Number of framework message types
1804 */
1805 CAMERA3_NUM_MESSAGES
1806
1807} camera3_msg_type_t;
1808
1809/**
1810 * Defined error codes for CAMERA_MSG_ERROR
1811 */
1812typedef enum camera3_error_msg_code {
1813 /**
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001814 * A serious failure occured. No further frames or buffer streams will
1815 * be produced by the device. Device should be treated as closed. The
1816 * client must reopen the device to use it again. The frame_number field
1817 * is unused.
1818 */
Alex Rayd5ddbc92013-02-15 13:47:24 -08001819 CAMERA3_MSG_ERROR_DEVICE = 1,
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001820
1821 /**
1822 * An error has occurred in processing a request. No output (metadata or
1823 * buffers) will be produced for this request. The frame_number field
1824 * specifies which request has been dropped. Subsequent requests are
1825 * unaffected, and the device remains operational.
1826 */
Alex Rayd5ddbc92013-02-15 13:47:24 -08001827 CAMERA3_MSG_ERROR_REQUEST = 2,
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001828
1829 /**
1830 * An error has occurred in producing an output result metadata buffer
1831 * for a request, but output stream buffers for it will still be
1832 * available. Subsequent requests are unaffected, and the device remains
1833 * operational. The frame_number field specifies the request for which
1834 * result metadata won't be available.
1835 */
Alex Rayd5ddbc92013-02-15 13:47:24 -08001836 CAMERA3_MSG_ERROR_RESULT = 3,
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001837
1838 /**
1839 * An error has occurred in placing an output buffer into a stream for a
1840 * request. The frame metadata and other buffers may still be
1841 * available. Subsequent requests are unaffected, and the device remains
1842 * operational. The frame_number field specifies the request for which the
1843 * buffer was dropped, and error_stream contains a pointer to the stream
1844 * that dropped the frame.u
1845 */
Alex Rayd5ddbc92013-02-15 13:47:24 -08001846 CAMERA3_MSG_ERROR_BUFFER = 4,
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001847
1848 /**
1849 * Number of error types
1850 */
1851 CAMERA3_MSG_NUM_ERRORS
1852
1853} camera3_error_msg_code_t;
1854
1855/**
1856 * camera3_error_msg_t:
1857 *
1858 * Message contents for CAMERA3_MSG_ERROR
1859 */
1860typedef struct camera3_error_msg {
1861 /**
1862 * Frame number of the request the error applies to. 0 if the frame number
1863 * isn't applicable to the error.
1864 */
1865 uint32_t frame_number;
1866
1867 /**
1868 * Pointer to the stream that had a failure. NULL if the stream isn't
1869 * applicable to the error.
1870 */
1871 camera3_stream_t *error_stream;
1872
1873 /**
1874 * The code for this error; one of the CAMERA_MSG_ERROR enum values.
1875 */
1876 int error_code;
1877
1878} camera3_error_msg_t;
1879
1880/**
1881 * camera3_shutter_msg_t:
1882 *
1883 * Message contents for CAMERA3_MSG_SHUTTER
1884 */
1885typedef struct camera3_shutter_msg {
1886 /**
Chien-Yu Chen73b49eb2015-05-28 17:13:05 -07001887 * Frame number of the request that has begun exposure or reprocessing.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001888 */
1889 uint32_t frame_number;
1890
1891 /**
Chien-Yu Chen73b49eb2015-05-28 17:13:05 -07001892 * Timestamp for the start of capture. For a reprocess request, this must
1893 * be input image's start of capture. This must match the capture result
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001894 * metadata's sensor exposure start timestamp.
1895 */
1896 uint64_t timestamp;
1897
1898} camera3_shutter_msg_t;
1899
1900/**
1901 * camera3_notify_msg_t:
1902 *
1903 * The message structure sent to camera3_callback_ops_t.notify()
1904 */
1905typedef struct camera3_notify_msg {
1906
1907 /**
1908 * The message type. One of camera3_notify_msg_type, or a private extension.
1909 */
1910 int type;
1911
1912 union {
1913 /**
1914 * Error message contents. Valid if type is CAMERA3_MSG_ERROR
1915 */
1916 camera3_error_msg_t error;
1917
1918 /**
1919 * Shutter message contents. Valid if type is CAMERA3_MSG_SHUTTER
1920 */
1921 camera3_shutter_msg_t shutter;
1922
1923 /**
1924 * Generic message contents. Used to ensure a minimum size for custom
1925 * message types.
1926 */
1927 uint8_t generic[32];
1928 } message;
1929
1930} camera3_notify_msg_t;
1931
1932/**********************************************************************
1933 *
1934 * Capture request/result definitions for the HAL process_capture_request()
1935 * method, and the process_capture_result() callback.
1936 *
1937 */
1938
1939/**
1940 * camera3_request_template_t:
1941 *
1942 * Available template types for
1943 * camera3_device_ops.construct_default_request_settings()
1944 */
1945typedef enum camera3_request_template {
1946 /**
1947 * Standard camera preview operation with 3A on auto.
1948 */
1949 CAMERA3_TEMPLATE_PREVIEW = 1,
1950
1951 /**
1952 * Standard camera high-quality still capture with 3A and flash on auto.
1953 */
1954 CAMERA3_TEMPLATE_STILL_CAPTURE = 2,
1955
1956 /**
1957 * Standard video recording plus preview with 3A on auto, torch off.
1958 */
1959 CAMERA3_TEMPLATE_VIDEO_RECORD = 3,
1960
1961 /**
1962 * High-quality still capture while recording video. Application will
1963 * include preview, video record, and full-resolution YUV or JPEG streams in
1964 * request. Must not cause stuttering on video stream. 3A on auto.
1965 */
1966 CAMERA3_TEMPLATE_VIDEO_SNAPSHOT = 4,
1967
1968 /**
1969 * Zero-shutter-lag mode. Application will request preview and
1970 * full-resolution data for each frame, and reprocess it to JPEG when a
1971 * still image is requested by user. Settings should provide highest-quality
1972 * full-resolution images without compromising preview frame rate. 3A on
1973 * auto.
1974 */
1975 CAMERA3_TEMPLATE_ZERO_SHUTTER_LAG = 5,
1976
Zhijun Heb0c939f2013-12-13 15:56:33 -08001977 /**
1978 * A basic template for direct application control of capture
1979 * parameters. All automatic control is disabled (auto-exposure, auto-white
1980 * balance, auto-focus), and post-processing parameters are set to preview
1981 * quality. The manual capture parameters (exposure, sensitivity, etc.)
1982 * are set to reasonable defaults, but should be overridden by the
1983 * application depending on the intended use case.
1984 */
1985 CAMERA3_TEMPLATE_MANUAL = 6,
1986
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001987 /* Total number of templates */
1988 CAMERA3_TEMPLATE_COUNT,
1989
1990 /**
1991 * First value for vendor-defined request templates
1992 */
1993 CAMERA3_VENDOR_TEMPLATE_START = 0x40000000
1994
1995} camera3_request_template_t;
1996
1997/**
1998 * camera3_capture_request_t:
1999 *
2000 * A single request for image capture/buffer reprocessing, sent to the Camera
2001 * HAL device by the framework in process_capture_request().
2002 *
2003 * The request contains the settings to be used for this capture, and the set of
2004 * output buffers to write the resulting image data in. It may optionally
2005 * contain an input buffer, in which case the request is for reprocessing that
2006 * input buffer instead of capturing a new image with the camera sensor. The
2007 * capture is identified by the frame_number.
2008 *
2009 * In response, the camera HAL device must send a camera3_capture_result
2010 * structure asynchronously to the framework, using the process_capture_result()
2011 * callback.
2012 */
2013typedef struct camera3_capture_request {
2014 /**
2015 * The frame number is an incrementing integer set by the framework to
2016 * uniquely identify this capture. It needs to be returned in the result
2017 * call, and is also used to identify the request in asynchronous
2018 * notifications sent to camera3_callback_ops_t.notify().
2019 */
2020 uint32_t frame_number;
2021
2022 /**
2023 * The settings buffer contains the capture and processing parameters for
2024 * the request. As a special case, a NULL settings buffer indicates that the
2025 * settings are identical to the most-recently submitted capture request. A
2026 * NULL buffer cannot be used as the first submitted request after a
2027 * configure_streams() call.
2028 */
2029 const camera_metadata_t *settings;
2030
2031 /**
2032 * The input stream buffer to use for this request, if any.
2033 *
2034 * If input_buffer is NULL, then the request is for a new capture from the
2035 * imager. If input_buffer is valid, the request is for reprocessing the
2036 * image contained in input_buffer.
2037 *
2038 * In the latter case, the HAL must set the release_fence of the
2039 * input_buffer to a valid sync fence, or to -1 if the HAL does not support
2040 * sync, before process_capture_request() returns.
2041 *
2042 * The HAL is required to wait on the acquire sync fence of the input buffer
2043 * before accessing it.
2044 *
Igor Murashkin78aa1262014-01-09 16:23:43 -08002045 * <= CAMERA_DEVICE_API_VERSION_3_1:
2046 *
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002047 * Any input buffer included here will have been registered with the HAL
2048 * through register_stream_buffers() before its inclusion in a request.
Igor Murashkin78aa1262014-01-09 16:23:43 -08002049 *
2050 * >= CAMERA_DEVICE_API_VERSION_3_2:
2051 *
2052 * The buffers will not have been pre-registered with the HAL.
2053 * Subsequent requests may reuse buffers, or provide entirely new buffers.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002054 */
2055 camera3_stream_buffer_t *input_buffer;
2056
2057 /**
2058 * The number of output buffers for this capture request. Must be at least
2059 * 1.
2060 */
2061 uint32_t num_output_buffers;
2062
2063 /**
2064 * An array of num_output_buffers stream buffers, to be filled with image
2065 * data from this capture/reprocess. The HAL must wait on the acquire fences
Igor Murashkin78aa1262014-01-09 16:23:43 -08002066 * of each stream buffer before writing to them.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002067 *
2068 * The HAL takes ownership of the actual buffer_handle_t entries in
2069 * output_buffers; the framework does not access them until they are
2070 * returned in a camera3_capture_result_t.
Igor Murashkin78aa1262014-01-09 16:23:43 -08002071 *
2072 * <= CAMERA_DEVICE_API_VERSION_3_1:
2073 *
2074 * All the buffers included here will have been registered with the HAL
2075 * through register_stream_buffers() before their inclusion in a request.
2076 *
2077 * >= CAMERA_DEVICE_API_VERSION_3_2:
2078 *
2079 * Any or all of the buffers included here may be brand new in this
2080 * request (having never before seen by the HAL).
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002081 */
2082 const camera3_stream_buffer_t *output_buffers;
2083
2084} camera3_capture_request_t;
2085
2086/**
2087 * camera3_capture_result_t:
2088 *
2089 * The result of a single capture/reprocess by the camera HAL device. This is
2090 * sent to the framework asynchronously with process_capture_result(), in
2091 * response to a single capture request sent to the HAL with
Eino-Ville Talvala7c9416b2013-04-03 15:18:20 -07002092 * process_capture_request(). Multiple process_capture_result() calls may be
Igor Murashkin5df2f622014-01-10 14:18:45 -08002093 * performed by the HAL for each request.
2094 *
2095 * Each call, all with the same frame
Eino-Ville Talvala7c9416b2013-04-03 15:18:20 -07002096 * number, may contain some subset of the output buffers, and/or the result
2097 * metadata. The metadata may only be provided once for a given frame number;
2098 * all other calls must set the result metadata to NULL.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002099 *
2100 * The result structure contains the output metadata from this capture, and the
2101 * set of output buffers that have been/will be filled for this capture. Each
2102 * output buffer may come with a release sync fence that the framework will wait
2103 * on before reading, in case the buffer has not yet been filled by the HAL.
2104 *
Igor Murashkin5df2f622014-01-10 14:18:45 -08002105 * >= CAMERA_DEVICE_API_VERSION_3_2:
2106 *
2107 * The metadata may be provided multiple times for a single frame number. The
2108 * framework will accumulate together the final result set by combining each
2109 * partial result together into the total result set.
2110 *
Zhijun Heceac9e32014-02-05 20:49:45 -08002111 * If an input buffer is given in a request, the HAL must return it in one of
2112 * the process_capture_result calls, and the call may be to just return the input
2113 * buffer, without metadata and output buffers; the sync fences must be handled
2114 * the same way they are done for output buffers.
2115 *
2116 *
Igor Murashkin5df2f622014-01-10 14:18:45 -08002117 * Performance considerations:
2118 *
2119 * Applications will also receive these partial results immediately, so sending
2120 * partial results is a highly recommended performance optimization to avoid
2121 * the total pipeline latency before sending the results for what is known very
2122 * early on in the pipeline.
2123 *
2124 * A typical use case might be calculating the AF state halfway through the
2125 * pipeline; by sending the state back to the framework immediately, we get a
2126 * 50% performance increase and perceived responsiveness of the auto-focus.
2127 *
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002128 */
2129typedef struct camera3_capture_result {
2130 /**
2131 * The frame number is an incrementing integer set by the framework in the
2132 * submitted request to uniquely identify this capture. It is also used to
2133 * identify the request in asynchronous notifications sent to
2134 * camera3_callback_ops_t.notify().
2135 */
2136 uint32_t frame_number;
2137
2138 /**
2139 * The result metadata for this capture. This contains information about the
2140 * final capture parameters, the state of the capture and post-processing
2141 * hardware, the state of the 3A algorithms, if enabled, and the output of
2142 * any enabled statistics units.
Eino-Ville Talvala7c9416b2013-04-03 15:18:20 -07002143 *
2144 * Only one call to process_capture_result() with a given frame_number may
2145 * include the result metadata. All other calls for the same frame_number
2146 * must set this to NULL.
2147 *
2148 * If there was an error producing the result metadata, result must be an
2149 * empty metadata buffer, and notify() must be called with ERROR_RESULT.
Igor Murashkin5df2f622014-01-10 14:18:45 -08002150 *
2151 * >= CAMERA_DEVICE_API_VERSION_3_2:
2152 *
2153 * Multiple calls to process_capture_result() with a given frame_number
2154 * may include the result metadata.
2155 *
2156 * Partial metadata submitted should not include any metadata key returned
2157 * in a previous partial result for a given frame. Each new partial result
2158 * for that frame must also set a distinct partial_result value.
2159 *
2160 * If notify has been called with ERROR_RESULT, all further partial
2161 * results for that frame are ignored by the framework.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002162 */
2163 const camera_metadata_t *result;
2164
2165 /**
Eino-Ville Talvala7c9416b2013-04-03 15:18:20 -07002166 * The number of output buffers returned in this result structure. Must be
2167 * less than or equal to the matching capture request's count. If this is
2168 * less than the buffer count in the capture request, at least one more call
2169 * to process_capture_result with the same frame_number must be made, to
2170 * return the remaining output buffers to the framework. This may only be
Zhijun He52a18892014-06-30 10:35:58 -07002171 * zero if the structure includes valid result metadata or an input buffer
2172 * is returned in this result.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002173 */
2174 uint32_t num_output_buffers;
2175
2176 /**
2177 * The handles for the output stream buffers for this capture. They may not
2178 * yet be filled at the time the HAL calls process_capture_result(); the
2179 * framework will wait on the release sync fences provided by the HAL before
2180 * reading the buffers.
2181 *
2182 * The HAL must set the stream buffer's release sync fence to a valid sync
2183 * fd, or to -1 if the buffer has already been filled.
Eino-Ville Talvala2f8cf5c2013-03-06 13:23:31 -08002184 *
2185 * If the HAL encounters an error while processing the buffer, and the
2186 * buffer is not filled, the buffer's status field must be set to
2187 * CAMERA3_BUFFER_STATUS_ERROR. If the HAL did not wait on the acquire fence
2188 * before encountering the error, the acquire fence should be copied into
2189 * the release fence, to allow the framework to wait on the fence before
2190 * reusing the buffer.
2191 *
Eino-Ville Talvala7c9416b2013-04-03 15:18:20 -07002192 * The acquire fence must be set to -1 for all output buffers. If
2193 * num_output_buffers is zero, this may be NULL. In that case, at least one
2194 * more process_capture_result call must be made by the HAL to provide the
2195 * output buffers.
Igor Murashkin5df2f622014-01-10 14:18:45 -08002196 *
2197 * When process_capture_result is called with a new buffer for a frame,
2198 * all previous frames' buffers for that corresponding stream must have been
2199 * already delivered (the fences need not have yet been signaled).
2200 *
2201 * >= CAMERA_DEVICE_API_VERSION_3_2:
2202 *
2203 * Gralloc buffers for a frame may be sent to framework before the
2204 * corresponding SHUTTER-notify.
2205 *
2206 * Performance considerations:
2207 *
2208 * Buffers delivered to the framework will not be dispatched to the
2209 * application layer until a start of exposure timestamp has been received
2210 * via a SHUTTER notify() call. It is highly recommended to
2211 * dispatch that call as early as possible.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002212 */
2213 const camera3_stream_buffer_t *output_buffers;
2214
Igor Murashkin5df2f622014-01-10 14:18:45 -08002215 /**
2216 * >= CAMERA_DEVICE_API_VERSION_3_2:
2217 *
Zhijun Heceac9e32014-02-05 20:49:45 -08002218 * The handle for the input stream buffer for this capture. It may not
2219 * yet be consumed at the time the HAL calls process_capture_result(); the
2220 * framework will wait on the release sync fences provided by the HAL before
2221 * reusing the buffer.
2222 *
2223 * The HAL should handle the sync fences the same way they are done for
2224 * output_buffers.
2225 *
2226 * Only one input buffer is allowed to be sent per request. Similarly to
2227 * output buffers, the ordering of returned input buffers must be
2228 * maintained by the HAL.
2229 *
2230 * Performance considerations:
2231 *
2232 * The input buffer should be returned as early as possible. If the HAL
2233 * supports sync fences, it can call process_capture_result to hand it back
2234 * with sync fences being set appropriately. If the sync fences are not
2235 * supported, the buffer can only be returned when it is consumed, which
2236 * may take long time; the HAL may choose to copy this input buffer to make
2237 * the buffer return sooner.
2238 */
2239 const camera3_stream_buffer_t *input_buffer;
2240
2241 /**
2242 * >= CAMERA_DEVICE_API_VERSION_3_2:
2243 *
Igor Murashkin5df2f622014-01-10 14:18:45 -08002244 * In order to take advantage of partial results, the HAL must set the
2245 * static metadata android.request.partialResultCount to the number of
2246 * partial results it will send for each frame.
2247 *
2248 * Each new capture result with a partial result must set
2249 * this field (partial_result) to a distinct inclusive value between
2250 * 1 and android.request.partialResultCount.
2251 *
2252 * HALs not wishing to take advantage of this feature must not
2253 * set an android.request.partialResultCount or partial_result to a value
2254 * other than 1.
2255 *
2256 * This value must be set to 0 when a capture result contains buffers only
2257 * and no metadata.
2258 */
2259 uint32_t partial_result;
2260
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002261} camera3_capture_result_t;
2262
2263/**********************************************************************
2264 *
2265 * Callback methods for the HAL to call into the framework.
2266 *
2267 * These methods are used to return metadata and image buffers for a completed
2268 * or failed captures, and to notify the framework of asynchronous events such
2269 * as errors.
2270 *
2271 * The framework will not call back into the HAL from within these callbacks,
2272 * and these calls will not block for extended periods.
2273 *
2274 */
2275typedef struct camera3_callback_ops {
2276
2277 /**
2278 * process_capture_result:
2279 *
Eino-Ville Talvala7c9416b2013-04-03 15:18:20 -07002280 * Send results from a completed capture to the framework.
2281 * process_capture_result() may be invoked multiple times by the HAL in
2282 * response to a single capture request. This allows, for example, the
2283 * metadata and low-resolution buffers to be returned in one call, and
2284 * post-processed JPEG buffers in a later call, once it is available. Each
2285 * call must include the frame number of the request it is returning
2286 * metadata or buffers for.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002287 *
Eino-Ville Talvala7c9416b2013-04-03 15:18:20 -07002288 * A component (buffer or metadata) of the complete result may only be
2289 * included in one process_capture_result call. A buffer for each stream,
2290 * and the result metadata, must be returned by the HAL for each request in
2291 * one of the process_capture_result calls, even in case of errors producing
2292 * some of the output. A call to process_capture_result() with neither
2293 * output buffers or result metadata is not allowed.
2294 *
2295 * The order of returning metadata and buffers for a single result does not
2296 * matter, but buffers for a given stream must be returned in FIFO order. So
2297 * the buffer for request 5 for stream A must always be returned before the
2298 * buffer for request 6 for stream A. This also applies to the result
2299 * metadata; the metadata for request 5 must be returned before the metadata
2300 * for request 6.
2301 *
2302 * However, different streams are independent of each other, so it is
2303 * acceptable and expected that the buffer for request 5 for stream A may be
2304 * returned after the buffer for request 6 for stream B is. And it is
2305 * acceptable that the result metadata for request 6 for stream B is
2306 * returned before the buffer for request 5 for stream A is.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002307 *
2308 * The HAL retains ownership of result structure, which only needs to be
2309 * valid to access during this call. The framework will copy whatever it
2310 * needs before this call returns.
2311 *
2312 * The output buffers do not need to be filled yet; the framework will wait
2313 * on the stream buffer release sync fence before reading the buffer
Eino-Ville Talvala7c9416b2013-04-03 15:18:20 -07002314 * data. Therefore, this method should be called by the HAL as soon as
2315 * possible, even if some or all of the output buffers are still in
2316 * being filled. The HAL must include valid release sync fences into each
2317 * output_buffers stream buffer entry, or -1 if that stream buffer is
2318 * already filled.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002319 *
2320 * If the result buffer cannot be constructed for a request, the HAL should
Eino-Ville Talvala7c9416b2013-04-03 15:18:20 -07002321 * return an empty metadata buffer, but still provide the output buffers and
2322 * their sync fences. In addition, notify() must be called with an
2323 * ERROR_RESULT message.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002324 *
Eino-Ville Talvala2f8cf5c2013-03-06 13:23:31 -08002325 * If an output buffer cannot be filled, its status field must be set to
2326 * STATUS_ERROR. In addition, notify() must be called with a ERROR_BUFFER
2327 * message.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002328 *
2329 * If the entire capture has failed, then this method still needs to be
Eino-Ville Talvala2f8cf5c2013-03-06 13:23:31 -08002330 * called to return the output buffers to the framework. All the buffer
Eino-Ville Talvala7c9416b2013-04-03 15:18:20 -07002331 * statuses should be STATUS_ERROR, and the result metadata should be an
2332 * empty buffer. In addition, notify() must be called with a ERROR_REQUEST
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002333 * message. In this case, individual ERROR_RESULT/ERROR_BUFFER messages
2334 * should not be sent.
2335 *
Zhijun He2dde4682014-01-09 09:11:49 -08002336 * Performance requirements:
2337 *
2338 * This is a non-blocking call. The framework will return this call in 5ms.
2339 *
2340 * The pipeline latency (see S7 for definition) should be less than or equal to
2341 * 4 frame intervals, and must be less than or equal to 8 frame intervals.
2342 *
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002343 */
2344 void (*process_capture_result)(const struct camera3_callback_ops *,
2345 const camera3_capture_result_t *result);
2346
2347 /**
2348 * notify:
2349 *
2350 * Asynchronous notification callback from the HAL, fired for various
2351 * reasons. Only for information independent of frame capture, or that
2352 * require specific timing. The ownership of the message structure remains
2353 * with the HAL, and the msg only needs to be valid for the duration of this
2354 * call.
2355 *
Igor Murashkin5df2f622014-01-10 14:18:45 -08002356 * Multiple threads may call notify() simultaneously.
2357 *
2358 * <= CAMERA_DEVICE_API_VERSION_3_1:
2359 *
Eino-Ville Talvala71af1022013-04-22 14:19:21 -07002360 * The notification for the start of exposure for a given request must be
2361 * sent by the HAL before the first call to process_capture_result() for
2362 * that request is made.
2363 *
Igor Murashkin5df2f622014-01-10 14:18:45 -08002364 * >= CAMERA_DEVICE_API_VERSION_3_2:
Zhijun He2dde4682014-01-09 09:11:49 -08002365 *
Igor Murashkin5df2f622014-01-10 14:18:45 -08002366 * Buffers delivered to the framework will not be dispatched to the
Chien-Yu Chen73b49eb2015-05-28 17:13:05 -07002367 * application layer until a start of exposure timestamp (or input image's
2368 * start of exposure timestamp for a reprocess request) has been received
2369 * via a SHUTTER notify() call. It is highly recommended to dispatch this
2370 * call as early as possible.
Igor Murashkin5df2f622014-01-10 14:18:45 -08002371 *
2372 * ------------------------------------------------------------------------
Zhijun He2dde4682014-01-09 09:11:49 -08002373 * Performance requirements:
2374 *
2375 * This is a non-blocking call. The framework will return this call in 5ms.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002376 */
2377 void (*notify)(const struct camera3_callback_ops *,
2378 const camera3_notify_msg_t *msg);
2379
2380} camera3_callback_ops_t;
2381
2382/**********************************************************************
2383 *
2384 * Camera device operations
2385 *
2386 */
2387typedef struct camera3_device_ops {
2388
2389 /**
2390 * initialize:
2391 *
2392 * One-time initialization to pass framework callback function pointers to
2393 * the HAL. Will be called once after a successful open() call, before any
2394 * other functions are called on the camera3_device_ops structure.
2395 *
Zhijun He2dde4682014-01-09 09:11:49 -08002396 * Performance requirements:
2397 *
2398 * This should be a non-blocking call. The HAL should return from this call
2399 * in 5ms, and must return from this call in 10ms.
2400 *
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002401 * Return values:
2402 *
2403 * 0: On successful initialization
2404 *
2405 * -ENODEV: If initialization fails. Only close() can be called successfully
2406 * by the framework after this.
2407 */
2408 int (*initialize)(const struct camera3_device *,
2409 const camera3_callback_ops_t *callback_ops);
2410
2411 /**********************************************************************
2412 * Stream management
2413 */
2414
2415 /**
2416 * configure_streams:
2417 *
Igor Murashkin78aa1262014-01-09 16:23:43 -08002418 * CAMERA_DEVICE_API_VERSION_3_0 only:
2419 *
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002420 * Reset the HAL camera device processing pipeline and set up new input and
2421 * output streams. This call replaces any existing stream configuration with
2422 * the streams defined in the stream_list. This method will be called at
2423 * least once after initialize() before a request is submitted with
2424 * process_capture_request().
2425 *
2426 * The stream_list must contain at least one output-capable stream, and may
2427 * not contain more than one input-capable stream.
2428 *
2429 * The stream_list may contain streams that are also in the currently-active
2430 * set of streams (from the previous call to configure_stream()). These
2431 * streams will already have valid values for usage, max_buffers, and the
Igor Murashkin78aa1262014-01-09 16:23:43 -08002432 * private pointer.
2433 *
2434 * If such a stream has already had its buffers registered,
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002435 * register_stream_buffers() will not be called again for the stream, and
2436 * buffers from the stream can be immediately included in input requests.
2437 *
2438 * If the HAL needs to change the stream configuration for an existing
2439 * stream due to the new configuration, it may rewrite the values of usage
Igor Murashkin78aa1262014-01-09 16:23:43 -08002440 * and/or max_buffers during the configure call.
2441 *
2442 * The framework will detect such a change, and will then reallocate the
2443 * stream buffers, and call register_stream_buffers() again before using
2444 * buffers from that stream in a request.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002445 *
2446 * If a currently-active stream is not included in stream_list, the HAL may
2447 * safely remove any references to that stream. It will not be reused in a
2448 * later configure() call by the framework, and all the gralloc buffers for
2449 * it will be freed after the configure_streams() call returns.
2450 *
2451 * The stream_list structure is owned by the framework, and may not be
2452 * accessed once this call completes. The address of an individual
2453 * camera3_stream_t structure will remain valid for access by the HAL until
2454 * the end of the first configure_stream() call which no longer includes
2455 * that camera3_stream_t in the stream_list argument. The HAL may not change
2456 * values in the stream structure outside of the private pointer, except for
2457 * the usage and max_buffers members during the configure_streams() call
2458 * itself.
2459 *
2460 * If the stream is new, the usage, max_buffer, and private pointer fields
2461 * of the stream structure will all be set to 0. The HAL device must set
2462 * these fields before the configure_streams() call returns. These fields
2463 * are then used by the framework and the platform gralloc module to
2464 * allocate the gralloc buffers for each stream.
2465 *
2466 * Before such a new stream can have its buffers included in a capture
2467 * request, the framework will call register_stream_buffers() with that
2468 * stream. However, the framework is not required to register buffers for
2469 * _all_ streams before submitting a request. This allows for quick startup
2470 * of (for example) a preview stream, with allocation for other streams
2471 * happening later or concurrently.
2472 *
Igor Murashkin78aa1262014-01-09 16:23:43 -08002473 * ------------------------------------------------------------------------
2474 * CAMERA_DEVICE_API_VERSION_3_1 only:
2475 *
2476 * Reset the HAL camera device processing pipeline and set up new input and
2477 * output streams. This call replaces any existing stream configuration with
2478 * the streams defined in the stream_list. This method will be called at
2479 * least once after initialize() before a request is submitted with
2480 * process_capture_request().
2481 *
2482 * The stream_list must contain at least one output-capable stream, and may
2483 * not contain more than one input-capable stream.
2484 *
2485 * The stream_list may contain streams that are also in the currently-active
2486 * set of streams (from the previous call to configure_stream()). These
2487 * streams will already have valid values for usage, max_buffers, and the
2488 * private pointer.
2489 *
2490 * If such a stream has already had its buffers registered,
2491 * register_stream_buffers() will not be called again for the stream, and
2492 * buffers from the stream can be immediately included in input requests.
2493 *
2494 * If the HAL needs to change the stream configuration for an existing
2495 * stream due to the new configuration, it may rewrite the values of usage
2496 * and/or max_buffers during the configure call.
2497 *
2498 * The framework will detect such a change, and will then reallocate the
2499 * stream buffers, and call register_stream_buffers() again before using
2500 * buffers from that stream in a request.
2501 *
2502 * If a currently-active stream is not included in stream_list, the HAL may
2503 * safely remove any references to that stream. It will not be reused in a
2504 * later configure() call by the framework, and all the gralloc buffers for
2505 * it will be freed after the configure_streams() call returns.
2506 *
2507 * The stream_list structure is owned by the framework, and may not be
2508 * accessed once this call completes. The address of an individual
2509 * camera3_stream_t structure will remain valid for access by the HAL until
2510 * the end of the first configure_stream() call which no longer includes
2511 * that camera3_stream_t in the stream_list argument. The HAL may not change
2512 * values in the stream structure outside of the private pointer, except for
2513 * the usage and max_buffers members during the configure_streams() call
2514 * itself.
2515 *
2516 * If the stream is new, max_buffer, and private pointer fields of the
2517 * stream structure will all be set to 0. The usage will be set to the
2518 * consumer usage flags. The HAL device must set these fields before the
2519 * configure_streams() call returns. These fields are then used by the
2520 * framework and the platform gralloc module to allocate the gralloc
2521 * buffers for each stream.
2522 *
2523 * Before such a new stream can have its buffers included in a capture
2524 * request, the framework will call register_stream_buffers() with that
2525 * stream. However, the framework is not required to register buffers for
2526 * _all_ streams before submitting a request. This allows for quick startup
2527 * of (for example) a preview stream, with allocation for other streams
2528 * happening later or concurrently.
2529 *
2530 * ------------------------------------------------------------------------
2531 * >= CAMERA_DEVICE_API_VERSION_3_2:
2532 *
2533 * Reset the HAL camera device processing pipeline and set up new input and
2534 * output streams. This call replaces any existing stream configuration with
2535 * the streams defined in the stream_list. This method will be called at
2536 * least once after initialize() before a request is submitted with
2537 * process_capture_request().
2538 *
2539 * The stream_list must contain at least one output-capable stream, and may
2540 * not contain more than one input-capable stream.
2541 *
2542 * The stream_list may contain streams that are also in the currently-active
2543 * set of streams (from the previous call to configure_stream()). These
2544 * streams will already have valid values for usage, max_buffers, and the
2545 * private pointer.
2546 *
2547 * If the HAL needs to change the stream configuration for an existing
2548 * stream due to the new configuration, it may rewrite the values of usage
2549 * and/or max_buffers during the configure call.
2550 *
2551 * The framework will detect such a change, and may then reallocate the
2552 * stream buffers before using buffers from that stream in a request.
2553 *
2554 * If a currently-active stream is not included in stream_list, the HAL may
2555 * safely remove any references to that stream. It will not be reused in a
2556 * later configure() call by the framework, and all the gralloc buffers for
2557 * it will be freed after the configure_streams() call returns.
2558 *
2559 * The stream_list structure is owned by the framework, and may not be
2560 * accessed once this call completes. The address of an individual
2561 * camera3_stream_t structure will remain valid for access by the HAL until
2562 * the end of the first configure_stream() call which no longer includes
2563 * that camera3_stream_t in the stream_list argument. The HAL may not change
2564 * values in the stream structure outside of the private pointer, except for
2565 * the usage and max_buffers members during the configure_streams() call
2566 * itself.
2567 *
2568 * If the stream is new, max_buffer, and private pointer fields of the
2569 * stream structure will all be set to 0. The usage will be set to the
2570 * consumer usage flags. The HAL device must set these fields before the
2571 * configure_streams() call returns. These fields are then used by the
2572 * framework and the platform gralloc module to allocate the gralloc
2573 * buffers for each stream.
2574 *
2575 * Newly allocated buffers may be included in a capture request at any time
2576 * by the framework. Once a gralloc buffer is returned to the framework
2577 * with process_capture_result (and its respective release_fence has been
2578 * signaled) the framework may free or reuse it at any time.
2579 *
2580 * ------------------------------------------------------------------------
2581 *
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002582 * Preconditions:
2583 *
2584 * The framework will only call this method when no captures are being
2585 * processed. That is, all results have been returned to the framework, and
2586 * all in-flight input and output buffers have been returned and their
2587 * release sync fences have been signaled by the HAL. The framework will not
2588 * submit new requests for capture while the configure_streams() call is
2589 * underway.
2590 *
2591 * Postconditions:
2592 *
2593 * The HAL device must configure itself to provide maximum possible output
2594 * frame rate given the sizes and formats of the output streams, as
2595 * documented in the camera device's static metadata.
2596 *
Zhijun He2dde4682014-01-09 09:11:49 -08002597 * Performance requirements:
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002598 *
2599 * This call is expected to be heavyweight and possibly take several hundred
2600 * milliseconds to complete, since it may require resetting and
2601 * reconfiguring the image sensor and the camera processing pipeline.
2602 * Nevertheless, the HAL device should attempt to minimize the
2603 * reconfiguration delay to minimize the user-visible pauses during
2604 * application operational mode changes (such as switching from still
2605 * capture to video recording).
2606 *
Zhijun He2dde4682014-01-09 09:11:49 -08002607 * The HAL should return from this call in 500ms, and must return from this
2608 * call in 1000ms.
2609 *
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002610 * Return values:
2611 *
2612 * 0: On successful stream configuration
2613 *
2614 * -EINVAL: If the requested stream configuration is invalid. Some examples
2615 * of invalid stream configurations include:
2616 *
2617 * - Including more than 1 input-capable stream (INPUT or
2618 * BIDIRECTIONAL)
2619 *
2620 * - Not including any output-capable streams (OUTPUT or
2621 * BIDIRECTIONAL)
2622 *
2623 * - Including streams with unsupported formats, or an unsupported
2624 * size for that format.
2625 *
2626 * - Including too many output streams of a certain format.
2627 *
Yin-Chia Yehe0042082015-03-09 12:15:36 -07002628 * - Unsupported rotation configuration (only applies to
2629 * devices with version >= CAMERA_DEVICE_API_VERSION_3_3)
2630 *
Eino-Ville Talvala7effe0c2013-02-15 12:09:48 -08002631 * Note that the framework submitting an invalid stream
2632 * configuration is not normal operation, since stream
2633 * configurations are checked before configure. An invalid
2634 * configuration means that a bug exists in the framework code, or
2635 * there is a mismatch between the HAL's static metadata and the
2636 * requirements on streams.
2637 *
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002638 * -ENODEV: If there has been a fatal error and the device is no longer
2639 * operational. Only close() can be called successfully by the
2640 * framework after this error is returned.
2641 */
2642 int (*configure_streams)(const struct camera3_device *,
2643 camera3_stream_configuration_t *stream_list);
2644
2645 /**
2646 * register_stream_buffers:
2647 *
Igor Murashkin78aa1262014-01-09 16:23:43 -08002648 * >= CAMERA_DEVICE_API_VERSION_3_2:
2649 *
2650 * DEPRECATED. This will not be called and must be set to NULL.
2651 *
2652 * <= CAMERA_DEVICE_API_VERSION_3_1:
2653 *
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002654 * Register buffers for a given stream with the HAL device. This method is
2655 * called by the framework after a new stream is defined by
2656 * configure_streams, and before buffers from that stream are included in a
2657 * capture request. If the same stream is listed in a subsequent
2658 * configure_streams() call, register_stream_buffers will _not_ be called
2659 * again for that stream.
2660 *
2661 * The framework does not need to register buffers for all configured
2662 * streams before it submits the first capture request. This allows quick
2663 * startup for preview (or similar use cases) while other streams are still
2664 * being allocated.
2665 *
2666 * This method is intended to allow the HAL device to map or otherwise
2667 * prepare the buffers for later use. The buffers passed in will already be
2668 * locked for use. At the end of the call, all the buffers must be ready to
2669 * be returned to the stream. The buffer_set argument is only valid for the
2670 * duration of this call.
2671 *
2672 * If the stream format was set to HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED,
2673 * the camera HAL should inspect the passed-in buffers here to determine any
2674 * platform-private pixel format information.
2675 *
Zhijun He2dde4682014-01-09 09:11:49 -08002676 * Performance requirements:
2677 *
2678 * This should be a non-blocking call. The HAL should return from this call
2679 * in 1ms, and must return from this call in 5ms.
2680 *
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002681 * Return values:
2682 *
2683 * 0: On successful registration of the new stream buffers
2684 *
2685 * -EINVAL: If the stream_buffer_set does not refer to a valid active
2686 * stream, or if the buffers array is invalid.
2687 *
2688 * -ENOMEM: If there was a failure in registering the buffers. The framework
2689 * must consider all the stream buffers to be unregistered, and can
2690 * try to register again later.
2691 *
2692 * -ENODEV: If there is a fatal error, and the device is no longer
2693 * operational. Only close() can be called successfully by the
2694 * framework after this error is returned.
2695 */
2696 int (*register_stream_buffers)(const struct camera3_device *,
2697 const camera3_stream_buffer_set_t *buffer_set);
2698
2699 /**********************************************************************
2700 * Request creation and submission
2701 */
2702
2703 /**
2704 * construct_default_request_settings:
2705 *
2706 * Create capture settings for standard camera use cases.
2707 *
2708 * The device must return a settings buffer that is configured to meet the
2709 * requested use case, which must be one of the CAMERA3_TEMPLATE_*
2710 * enums. All request control fields must be included.
2711 *
2712 * The HAL retains ownership of this structure, but the pointer to the
2713 * structure must be valid until the device is closed. The framework and the
2714 * HAL may not modify the buffer once it is returned by this call. The same
2715 * buffer may be returned for subsequent calls for the same template, or for
2716 * other templates.
2717 *
Zhijun He2dde4682014-01-09 09:11:49 -08002718 * Performance requirements:
2719 *
2720 * This should be a non-blocking call. The HAL should return from this call
2721 * in 1ms, and must return from this call in 5ms.
2722 *
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002723 * Return values:
2724 *
2725 * Valid metadata: On successful creation of a default settings
2726 * buffer.
2727 *
2728 * NULL: In case of a fatal error. After this is returned, only
Eino-Ville Talvalaacbc4512013-03-16 16:53:28 -07002729 * the close() method can be called successfully by the
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002730 * framework.
2731 */
2732 const camera_metadata_t* (*construct_default_request_settings)(
2733 const struct camera3_device *,
2734 int type);
2735
2736 /**
2737 * process_capture_request:
2738 *
2739 * Send a new capture request to the HAL. The HAL should not return from
2740 * this call until it is ready to accept the next request to process. Only
2741 * one call to process_capture_request() will be made at a time by the
2742 * framework, and the calls will all be from the same thread. The next call
2743 * to process_capture_request() will be made as soon as a new request and
2744 * its associated buffers are available. In a normal preview scenario, this
2745 * means the function will be called again by the framework almost
2746 * instantly.
2747 *
2748 * The actual request processing is asynchronous, with the results of
2749 * capture being returned by the HAL through the process_capture_result()
2750 * call. This call requires the result metadata to be available, but output
2751 * buffers may simply provide sync fences to wait on. Multiple requests are
2752 * expected to be in flight at once, to maintain full output frame rate.
2753 *
2754 * The framework retains ownership of the request structure. It is only
2755 * guaranteed to be valid during this call. The HAL device must make copies
Eino-Ville Talvala71af1022013-04-22 14:19:21 -07002756 * of the information it needs to retain for the capture processing. The HAL
2757 * is responsible for waiting on and closing the buffers' fences and
2758 * returning the buffer handles to the framework.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002759 *
2760 * The HAL must write the file descriptor for the input buffer's release
2761 * sync fence into input_buffer->release_fence, if input_buffer is not
2762 * NULL. If the HAL returns -1 for the input buffer release sync fence, the
2763 * framework is free to immediately reuse the input buffer. Otherwise, the
2764 * framework will wait on the sync fence before refilling and reusing the
2765 * input buffer.
2766 *
Igor Murashkin78aa1262014-01-09 16:23:43 -08002767 * >= CAMERA_DEVICE_API_VERSION_3_2:
Zhijun He2dde4682014-01-09 09:11:49 -08002768 *
Igor Murashkin78aa1262014-01-09 16:23:43 -08002769 * The input/output buffers provided by the framework in each request
2770 * may be brand new (having never before seen by the HAL).
2771 *
2772 * ------------------------------------------------------------------------
2773 * Performance considerations:
2774 *
2775 * Handling a new buffer should be extremely lightweight and there should be
2776 * no frame rate degradation or frame jitter introduced.
2777 *
2778 * This call must return fast enough to ensure that the requested frame
2779 * rate can be sustained, especially for streaming cases (post-processing
2780 * quality settings set to FAST). The HAL should return this call in 1
2781 * frame interval, and must return from this call in 4 frame intervals.
Zhijun He2dde4682014-01-09 09:11:49 -08002782 *
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002783 * Return values:
2784 *
2785 * 0: On a successful start to processing the capture request
2786 *
2787 * -EINVAL: If the input is malformed (the settings are NULL when not
2788 * allowed, there are 0 output buffers, etc) and capture processing
2789 * cannot start. Failures during request processing should be
Eino-Ville Talvala71af1022013-04-22 14:19:21 -07002790 * handled by calling camera3_callback_ops_t.notify(). In case of
2791 * this error, the framework will retain responsibility for the
2792 * stream buffers' fences and the buffer handles; the HAL should
2793 * not close the fences or return these buffers with
2794 * process_capture_result.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002795 *
2796 * -ENODEV: If the camera device has encountered a serious error. After this
2797 * error is returned, only the close() method can be successfully
2798 * called by the framework.
2799 *
2800 */
2801 int (*process_capture_request)(const struct camera3_device *,
2802 camera3_capture_request_t *request);
2803
2804 /**********************************************************************
2805 * Miscellaneous methods
2806 */
2807
2808 /**
2809 * get_metadata_vendor_tag_ops:
2810 *
Eino-Ville Talvalaacbc4512013-03-16 16:53:28 -07002811 * Get methods to query for vendor extension metadata tag information. The
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002812 * HAL should fill in all the vendor tag operation methods, or leave ops
2813 * unchanged if no vendor tags are defined.
2814 *
2815 * The definition of vendor_tag_query_ops_t can be found in
2816 * system/media/camera/include/system/camera_metadata.h.
2817 *
Ruben Brunk61cf9eb2014-01-14 15:27:58 -08002818 * >= CAMERA_DEVICE_API_VERSION_3_2:
2819 * DEPRECATED. This function has been deprecated and should be set to
2820 * NULL by the HAL. Please implement get_vendor_tag_ops in camera_common.h
2821 * instead.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002822 */
2823 void (*get_metadata_vendor_tag_ops)(const struct camera3_device*,
2824 vendor_tag_query_ops_t* ops);
2825
2826 /**
2827 * dump:
2828 *
2829 * Print out debugging state for the camera device. This will be called by
2830 * the framework when the camera service is asked for a debug dump, which
2831 * happens when using the dumpsys tool, or when capturing a bugreport.
2832 *
2833 * The passed-in file descriptor can be used to write debugging text using
2834 * dprintf() or write(). The text should be in ASCII encoding only.
Zhijun He2dde4682014-01-09 09:11:49 -08002835 *
2836 * Performance requirements:
2837 *
2838 * This must be a non-blocking call. The HAL should return from this call
2839 * in 1ms, must return from this call in 10ms. This call must avoid
2840 * deadlocks, as it may be called at any point during camera operation.
2841 * Any synchronization primitives used (such as mutex locks or semaphores)
2842 * should be acquired with a timeout.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002843 */
2844 void (*dump)(const struct camera3_device *, int fd);
2845
Alex Ray5f2fd852013-06-24 11:28:05 -07002846 /**
2847 * flush:
2848 *
2849 * Flush all currently in-process captures and all buffers in the pipeline
2850 * on the given device. The framework will use this to dump all state as
2851 * quickly as possible in order to prepare for a configure_streams() call.
2852 *
2853 * No buffers are required to be successfully returned, so every buffer
Zhijun He5a5fbf42014-01-27 14:49:44 -08002854 * held at the time of flush() (whether successfully filled or not) may be
Alex Ray5f2fd852013-06-24 11:28:05 -07002855 * returned with CAMERA3_BUFFER_STATUS_ERROR. Note the HAL is still allowed
Zhijun He5a5fbf42014-01-27 14:49:44 -08002856 * to return valid (CAMERA3_BUFFER_STATUS_OK) buffers during this call,
2857 * provided they are successfully filled.
Alex Ray5f2fd852013-06-24 11:28:05 -07002858 *
2859 * All requests currently in the HAL are expected to be returned as soon as
2860 * possible. Not-in-process requests should return errors immediately. Any
2861 * interruptible hardware blocks should be stopped, and any uninterruptible
2862 * blocks should be waited on.
2863 *
Zhijun He5a5fbf42014-01-27 14:49:44 -08002864 * More specifically, the HAL must follow below requirements for various cases:
2865 *
2866 * 1. For captures that are too late for the HAL to cancel/stop, and will be
2867 * completed normally by the HAL; i.e. the HAL can send shutter/notify and
2868 * process_capture_result and buffers as normal.
2869 *
2870 * 2. For pending requests that have not done any processing, the HAL must call notify
2871 * CAMERA3_MSG_ERROR_REQUEST, and return all the output buffers with
2872 * process_capture_result in the error state (CAMERA3_BUFFER_STATUS_ERROR).
2873 * The HAL must not place the release fence into an error state, instead,
2874 * the release fences must be set to the acquire fences passed by the framework,
2875 * or -1 if they have been waited on by the HAL already. This is also the path
2876 * to follow for any captures for which the HAL already called notify() with
2877 * CAMERA3_MSG_SHUTTER but won't be producing any metadata/valid buffers for.
2878 * After CAMERA3_MSG_ERROR_REQUEST, for a given frame, only process_capture_results with
2879 * buffers in CAMERA3_BUFFER_STATUS_ERROR are allowed. No further notifys or
2880 * process_capture_result with non-null metadata is allowed.
2881 *
2882 * 3. For partially completed pending requests that will not have all the output
2883 * buffers or perhaps missing metadata, the HAL should follow below:
2884 *
2885 * 3.1. Call notify with CAMERA3_MSG_ERROR_RESULT if some of the expected result
2886 * metadata (i.e. one or more partial metadata) won't be available for the capture.
2887 *
2888 * 3.2. Call notify with CAMERA3_MSG_ERROR_BUFFER for every buffer that won't
2889 * be produced for the capture.
2890 *
2891 * 3.3 Call notify with CAMERA3_MSG_SHUTTER with the capture timestamp before
2892 * any buffers/metadata are returned with process_capture_result.
2893 *
2894 * 3.4 For captures that will produce some results, the HAL must not call
2895 * CAMERA3_MSG_ERROR_REQUEST, since that indicates complete failure.
2896 *
2897 * 3.5. Valid buffers/metadata should be passed to the framework as normal.
2898 *
2899 * 3.6. Failed buffers should be returned to the framework as described for case 2.
2900 * But failed buffers do not have to follow the strict ordering valid buffers do,
2901 * and may be out-of-order with respect to valid buffers. For example, if buffers
2902 * A, B, C, D, E are sent, D and E are failed, then A, E, B, D, C is an acceptable
2903 * return order.
2904 *
2905 * 3.7. For fully-missing metadata, calling CAMERA3_MSG_ERROR_RESULT is sufficient, no
2906 * need to call process_capture_result with NULL metadata or equivalent.
2907 *
Alex Ray5f2fd852013-06-24 11:28:05 -07002908 * flush() should only return when there are no more outstanding buffers or
Zhijun He5a5fbf42014-01-27 14:49:44 -08002909 * requests left in the HAL. The framework may call configure_streams (as
Alex Ray5f2fd852013-06-24 11:28:05 -07002910 * the HAL state is now quiesced) or may issue new requests.
2911 *
Zhijun He5a5fbf42014-01-27 14:49:44 -08002912 * Note that it's sufficient to only support fully-succeeded and fully-failed result cases.
2913 * However, it is highly desirable to support the partial failure cases as well, as it
2914 * could help improve the flush call overall performance.
2915 *
Zhijun He2dde4682014-01-09 09:11:49 -08002916 * Performance requirements:
2917 *
2918 * The HAL should return from this call in 100ms, and must return from this
2919 * call in 1000ms. And this call must not be blocked longer than pipeline
2920 * latency (see S7 for definition).
Alex Ray5f2fd852013-06-24 11:28:05 -07002921 *
2922 * Version information:
2923 *
2924 * only available if device version >= CAMERA_DEVICE_API_VERSION_3_1.
2925 *
2926 * Return values:
2927 *
2928 * 0: On a successful flush of the camera HAL.
2929 *
2930 * -EINVAL: If the input is malformed (the device is not valid).
2931 *
2932 * -ENODEV: If the camera device has encountered a serious error. After this
2933 * error is returned, only the close() method can be successfully
2934 * called by the framework.
2935 */
2936 int (*flush)(const struct camera3_device *);
2937
2938 /* reserved for future use */
2939 void *reserved[8];
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002940} camera3_device_ops_t;
2941
2942/**********************************************************************
2943 *
2944 * Camera device definition
2945 *
2946 */
2947typedef struct camera3_device {
2948 /**
2949 * common.version must equal CAMERA_DEVICE_API_VERSION_3_0 to identify this
2950 * device as implementing version 3.0 of the camera device HAL.
Zhijun He2dde4682014-01-09 09:11:49 -08002951 *
2952 * Performance requirements:
2953 *
Zhijun He06da1b32014-02-10 16:04:23 -08002954 * Camera open (common.module->common.methods->open) should return in 200ms, and must return
2955 * in 500ms.
Zhijun He2020ee22014-01-31 11:35:45 -08002956 * Camera close (common.close) should return in 200ms, and must return in 500ms.
2957 *
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002958 */
2959 hw_device_t common;
2960 camera3_device_ops_t *ops;
2961 void *priv;
2962} camera3_device_t;
2963
2964__END_DECLS
2965
2966#endif /* #ifdef ANDROID_INCLUDE_CAMERA3_H */