blob: ad088835b07f1ec046203c38ed8ae26a18c6c4ae [file] [log] [blame]
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001/*
Shuzhen Wangbf39eb52017-11-29 15:16:03 -08002 * Copyright (C) 2013-2018 The Android Open Source Project
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08003 *
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/**
Emilian Peeveec2ee92017-11-08 19:33:27 +000024 * Camera device HAL 3.5[ CAMERA_DEVICE_API_VERSION_3_5 ]
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
Eino-Ville Talvalacd86b0d2016-03-06 17:08:40 -080029 * android.hardware.camera2 API as LIMITED or above hardware level.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -080030 *
31 * Camera devices that support this version of the HAL must return
Emilian Peeveec2ee92017-11-08 19:33:27 +000032 * CAMERA_DEVICE_API_VERSION_3_5 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 *
Eino-Ville Talvalacd86b0d2016-03-06 17:08:40 -080035 * CAMERA_DEVICE_API_VERSION_3_3 and above:
36 * Camera modules that may contain version 3.3 or above devices must
37 * implement at least version 2.2 of the camera module interface (as defined
38 * by camera_module_t.common.module_api_version).
Zhijun Heebdf1282015-01-16 16:44:40 -080039 *
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 *
Zhijun He21126b72015-05-22 18:12:28 -0700138 * - Addition of camera3 stream configuration operation mode to camera3_stream_configuration_t
139 *
Eino-Ville Talvalacd86b0d2016-03-06 17:08:40 -0800140 * 3.4: Minor additions to supported metadata and changes to data_space support
141 *
142 * - Add ANDROID_SENSOR_OPAQUE_RAW_SIZE static metadata as mandatory if
143 * RAW_OPAQUE format is supported.
144 *
145 * - Add ANDROID_CONTROL_POST_RAW_SENSITIVITY_BOOST_RANGE static metadata as
146 * mandatory if any RAW format is supported
147 *
148 * - Switch camera3_stream_t data_space field to a more flexible definition,
149 * using the version 0 definition of dataspace encoding.
150 *
151 * - General metadata additions which are available to use for HALv3.2 or
152 * newer:
153 * - ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_3
154 * - ANDROID_CONTROL_POST_RAW_SENSITIVITY_BOOST
155 * - ANDROID_CONTROL_POST_RAW_SENSITIVITY_BOOST_RANGE
156 * - ANDROID_SENSOR_DYNAMIC_BLACK_LEVEL
157 * - ANDROID_SENSOR_DYNAMIC_WHITE_LEVEL
158 * - ANDROID_SENSOR_OPAQUE_RAW_SIZE
159 * - ANDROID_SENSOR_OPTICAL_BLACK_REGIONS
Emilian Peeveec2ee92017-11-08 19:33:27 +0000160 *
Shuzhen Wangbf39eb52017-11-29 15:16:03 -0800161 * 3.5: Minor revisions to support session parameters and logical multi camera:
Emilian Peeveec2ee92017-11-08 19:33:27 +0000162 *
163 * - Add ANDROID_REQUEST_AVAILABLE_SESSION_KEYS static metadata, which is
164 * optional for implementations that want to support session parameters. If support is
165 * needed, then Hal should populate the list with all available capture request keys
166 * that can cause severe processing delays when modified by client. Typical examples
167 * include parameters that require time-consuming HW re-configuration or internal camera
168 * pipeline update.
169 *
170 * - Add a session parameter field to camera3_stream_configuration which can be populated
171 * by clients with initial values for the keys found in ANDROID_REQUEST_AVAILABLE_SESSION_KEYS.
Shuzhen Wangbf39eb52017-11-29 15:16:03 -0800172 *
173 * - Metadata additions for logical multi camera capability:
174 * - ANDROID_REQUEST_AVAILABLE_CAPABILITIES_LOGICAL_MULTI_CAMERA
175 * - ANDROID_LOGICAL_MULTI_CAMERA_PHYSICAL_IDS
176 * - ANDROID_LOGICAL_MULTI_CAMERA_SYNC_TYPE
177 *
178 * - Add physical camera id field in camera3_stream, so that for a logical
179 * multi camera, the application has the option to specify which physical camera
180 * a particular stream is configured on.
Emilian Peev92261ff2018-01-16 15:01:22 +0000181 *
182 * - Add physical camera id and settings field in camera3_capture_request, so that
183 * for a logical multi camera, the application has the option to specify individual
184 * settings for a particular physical device.
Eino-Ville Talvalacc1aa872018-01-22 13:30:52 -0800185 *
186 * - Add request templates MOTION_TRACKING_PREVIEW and MOTION_TRACKING_BEST
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800187 */
188
189/**
Eino-Ville Talvalaacbc4512013-03-16 16:53:28 -0700190 * S2. Startup and general expected operation sequence:
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800191 *
192 * 1. Framework calls camera_module_t->common.open(), which returns a
193 * hardware_device_t structure.
194 *
195 * 2. Framework inspects the hardware_device_t->version field, and instantiates
196 * the appropriate handler for that version of the camera hardware device. In
197 * case the version is CAMERA_DEVICE_API_VERSION_3_0, the device is cast to
198 * a camera3_device_t.
199 *
200 * 3. Framework calls camera3_device_t->ops->initialize() with the framework
201 * callback function pointers. This will only be called this one time after
202 * open(), before any other functions in the ops structure are called.
203 *
204 * 4. The framework calls camera3_device_t->ops->configure_streams() with a list
205 * of input/output streams to the HAL device.
206 *
Igor Murashkin78aa1262014-01-09 16:23:43 -0800207 * 5. <= CAMERA_DEVICE_API_VERSION_3_1:
208 *
209 * The framework allocates gralloc buffers and calls
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800210 * camera3_device_t->ops->register_stream_buffers() for at least one of the
211 * output streams listed in configure_streams. The same stream is registered
212 * only once.
213 *
Igor Murashkin78aa1262014-01-09 16:23:43 -0800214 * >= CAMERA_DEVICE_API_VERSION_3_2:
215 *
216 * camera3_device_t->ops->register_stream_buffers() is not called and must
217 * be NULL.
218 *
219 * 6. The framework requests default settings for some number of use cases with
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800220 * calls to camera3_device_t->ops->construct_default_request_settings(). This
221 * may occur any time after step 3.
222 *
223 * 7. The framework constructs and sends the first capture request to the HAL,
224 * with settings based on one of the sets of default settings, and with at
225 * least one output stream, which has been registered earlier by the
226 * framework. This is sent to the HAL with
227 * camera3_device_t->ops->process_capture_request(). The HAL must block the
228 * return of this call until it is ready for the next request to be sent.
229 *
Igor Murashkin78aa1262014-01-09 16:23:43 -0800230 * >= CAMERA_DEVICE_API_VERSION_3_2:
231 *
232 * The buffer_handle_t provided in the camera3_stream_buffer_t array
233 * in the camera3_capture_request_t may be new and never-before-seen
234 * by the HAL on any given new request.
235 *
236 * 8. The framework continues to submit requests, and call
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800237 * construct_default_request_settings to get default settings buffers for
238 * other use cases.
239 *
Igor Murashkin78aa1262014-01-09 16:23:43 -0800240 * <= CAMERA_DEVICE_API_VERSION_3_1:
241 *
242 * The framework may call register_stream_buffers() at this time for
243 * not-yet-registered streams.
244 *
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800245 * 9. When the capture of a request begins (sensor starts exposing for the
Chien-Yu Chen73b49eb2015-05-28 17:13:05 -0700246 * capture) or processing a reprocess request begins, the HAL
247 * calls camera3_callback_ops_t->notify() with the SHUTTER event, including
248 * the frame number and the timestamp for start of exposure. For a reprocess
249 * request, the timestamp must be the start of exposure of the input image
250 * which can be looked up with android.sensor.timestamp from
251 * camera3_capture_request_t.settings when process_capture_request() is
252 * called.
Igor Murashkin5df2f622014-01-10 14:18:45 -0800253 *
254 * <= CAMERA_DEVICE_API_VERSION_3_1:
255 *
Eino-Ville Talvala71af1022013-04-22 14:19:21 -0700256 * This notify call must be made before the first call to
257 * process_capture_result() for that frame number.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800258 *
Igor Murashkin5df2f622014-01-10 14:18:45 -0800259 * >= CAMERA_DEVICE_API_VERSION_3_2:
260 *
261 * The camera3_callback_ops_t->notify() call with the SHUTTER event should
262 * be made as early as possible since the framework will be unable to
263 * deliver gralloc buffers to the application layer (for that frame) until
Chien-Yu Chen73b49eb2015-05-28 17:13:05 -0700264 * it has a valid timestamp for the start of exposure (or the input image's
265 * start of exposure for a reprocess request).
Igor Murashkin5df2f622014-01-10 14:18:45 -0800266 *
267 * Both partial metadata results and the gralloc buffers may be sent to the
268 * framework at any time before or after the SHUTTER event.
269 *
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800270 * 10. After some pipeline delay, the HAL begins to return completed captures to
271 * the framework with camera3_callback_ops_t->process_capture_result(). These
272 * are returned in the same order as the requests were submitted. Multiple
273 * requests can be in flight at once, depending on the pipeline depth of the
274 * camera HAL device.
275 *
Igor Murashkin78aa1262014-01-09 16:23:43 -0800276 * >= CAMERA_DEVICE_API_VERSION_3_2:
277 *
278 * Once a buffer is returned by process_capture_result as part of the
279 * camera3_stream_buffer_t array, and the fence specified by release_fence
280 * has been signaled (this is a no-op for -1 fences), the ownership of that
281 * buffer is considered to be transferred back to the framework. After that,
282 * the HAL must no longer retain that particular buffer, and the
283 * framework may clean up the memory for it immediately.
284 *
Igor Murashkin5df2f622014-01-10 14:18:45 -0800285 * process_capture_result may be called multiple times for a single frame,
286 * each time with a new disjoint piece of metadata and/or set of gralloc
287 * buffers. The framework will accumulate these partial metadata results
288 * into one result.
289 *
290 * In particular, it is legal for a process_capture_result to be called
291 * simultaneously for both a frame N and a frame N+1 as long as the
Zhijun Heceac9e32014-02-05 20:49:45 -0800292 * above rule holds for gralloc buffers (both input and output).
Igor Murashkin5df2f622014-01-10 14:18:45 -0800293 *
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800294 * 11. After some time, the framework may stop submitting new requests, wait for
295 * the existing captures to complete (all buffers filled, all results
296 * returned), and then call configure_streams() again. This resets the camera
297 * hardware and pipeline for a new set of input/output streams. Some streams
298 * may be reused from the previous configuration; if these streams' buffers
299 * had already been registered with the HAL, they will not be registered
300 * again. The framework then continues from step 7, if at least one
301 * registered output stream remains (otherwise, step 5 is required first).
302 *
303 * 12. Alternatively, the framework may call camera3_device_t->common->close()
Eino-Ville Talvala2f8cf5c2013-03-06 13:23:31 -0800304 * to end the camera session. This may be called at any time when no other
305 * calls from the framework are active, although the call may block until all
306 * in-flight captures have completed (all results returned, all buffers
307 * filled). After the close call returns, no more calls to the
308 * camera3_callback_ops_t functions are allowed from the HAL. Once the
309 * close() call is underway, the framework may not call any other HAL device
310 * functions.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800311 *
312 * 13. In case of an error or other asynchronous event, the HAL must call
313 * camera3_callback_ops_t->notify() with the appropriate error/event
314 * message. After returning from a fatal device-wide error notification, the
315 * HAL should act as if close() had been called on it. However, the HAL must
316 * either cancel or complete all outstanding captures before calling
317 * notify(), so that once notify() is called with a fatal error, the
318 * framework will not receive further callbacks from the device. Methods
319 * besides close() should return -ENODEV or NULL after the notify() method
320 * returns from a fatal error message.
321 */
322
323/**
Eino-Ville Talvalaacbc4512013-03-16 16:53:28 -0700324 * S3. Operational modes:
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800325 *
326 * The camera 3 HAL device can implement one of two possible operational modes;
327 * limited and full. Full support is expected from new higher-end
328 * devices. Limited mode has hardware requirements roughly in line with those
329 * for a camera HAL device v1 implementation, and is expected from older or
330 * inexpensive devices. Full is a strict superset of limited, and they share the
331 * same essential operational flow, as documented above.
332 *
333 * The HAL must indicate its level of support with the
334 * android.info.supportedHardwareLevel static metadata entry, with 0 indicating
335 * limited mode, and 1 indicating full mode support.
336 *
337 * Roughly speaking, limited-mode devices do not allow for application control
338 * of capture settings (3A control only), high-rate capture of high-resolution
Eino-Ville Talvalaacbc4512013-03-16 16:53:28 -0700339 * images, raw sensor readout, or support for YUV output streams above maximum
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800340 * recording resolution (JPEG only for large images).
341 *
342 * ** Details of limited mode behavior:
343 *
344 * - Limited-mode devices do not need to implement accurate synchronization
345 * between capture request settings and the actual image data
346 * captured. Instead, changes to settings may take effect some time in the
347 * future, and possibly not for the same output frame for each settings
348 * entry. Rapid changes in settings may result in some settings never being
349 * used for a capture. However, captures that include high-resolution output
350 * buffers ( > 1080p ) have to use the settings as specified (but see below
351 * for processing rate).
352 *
353 * - Limited-mode devices do not need to support most of the
Zhijun He1ab5c5e2014-05-26 17:35:50 -0700354 * settings/result/static info metadata. Specifically, only the following settings
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800355 * are expected to be consumed or produced by a limited-mode HAL device:
356 *
Zhijun He1ab5c5e2014-05-26 17:35:50 -0700357 * android.control.aeAntibandingMode (controls and dynamic)
358 * android.control.aeExposureCompensation (controls and dynamic)
359 * android.control.aeLock (controls and dynamic)
360 * android.control.aeMode (controls and dynamic)
361 * android.control.aeRegions (controls and dynamic)
362 * android.control.aeTargetFpsRange (controls and dynamic)
363 * android.control.aePrecaptureTrigger (controls and dynamic)
364 * android.control.afMode (controls and dynamic)
365 * android.control.afRegions (controls and dynamic)
366 * android.control.awbLock (controls and dynamic)
367 * android.control.awbMode (controls and dynamic)
368 * android.control.awbRegions (controls and dynamic)
369 * android.control.captureIntent (controls and dynamic)
370 * android.control.effectMode (controls and dynamic)
371 * android.control.mode (controls and dynamic)
372 * android.control.sceneMode (controls and dynamic)
373 * android.control.videoStabilizationMode (controls and dynamic)
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800374 * android.control.aeAvailableAntibandingModes (static)
375 * android.control.aeAvailableModes (static)
376 * android.control.aeAvailableTargetFpsRanges (static)
377 * android.control.aeCompensationRange (static)
378 * android.control.aeCompensationStep (static)
379 * android.control.afAvailableModes (static)
380 * android.control.availableEffects (static)
381 * android.control.availableSceneModes (static)
382 * android.control.availableVideoStabilizationModes (static)
383 * android.control.awbAvailableModes (static)
384 * android.control.maxRegions (static)
385 * android.control.sceneModeOverrides (static)
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800386 * android.control.aeState (dynamic)
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800387 * android.control.afState (dynamic)
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800388 * android.control.awbState (dynamic)
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800389 *
Zhijun He1ab5c5e2014-05-26 17:35:50 -0700390 * android.flash.mode (controls and dynamic)
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800391 * android.flash.info.available (static)
392 *
393 * android.info.supportedHardwareLevel (static)
394 *
Zhijun He1ab5c5e2014-05-26 17:35:50 -0700395 * android.jpeg.gpsCoordinates (controls and dynamic)
396 * android.jpeg.gpsProcessingMethod (controls and dynamic)
397 * android.jpeg.gpsTimestamp (controls and dynamic)
398 * android.jpeg.orientation (controls and dynamic)
399 * android.jpeg.quality (controls and dynamic)
400 * android.jpeg.thumbnailQuality (controls and dynamic)
401 * android.jpeg.thumbnailSize (controls and dynamic)
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800402 * android.jpeg.availableThumbnailSizes (static)
403 * android.jpeg.maxSize (static)
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800404 *
405 * android.lens.info.minimumFocusDistance (static)
406 *
Zhijun He1ab5c5e2014-05-26 17:35:50 -0700407 * android.request.id (controls and dynamic)
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800408 *
Zhijun He1ab5c5e2014-05-26 17:35:50 -0700409 * android.scaler.cropRegion (controls and dynamic)
Eino-Ville Talvalac5bff0d2014-02-10 16:43:26 -0800410 * android.scaler.availableStreamConfigurations (static)
411 * android.scaler.availableMinFrameDurations (static)
412 * android.scaler.availableStallDurations (static)
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800413 * android.scaler.availableMaxDigitalZoom (static)
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800414 * android.scaler.maxDigitalZoom (static)
Zhijun He1ab5c5e2014-05-26 17:35:50 -0700415 * android.scaler.croppingType (static)
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800416 *
417 * android.sensor.orientation (static)
418 * android.sensor.timestamp (dynamic)
419 *
Zhijun He1ab5c5e2014-05-26 17:35:50 -0700420 * android.statistics.faceDetectMode (controls and dynamic)
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800421 * android.statistics.info.availableFaceDetectModes (static)
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800422 * android.statistics.faceIds (dynamic)
423 * android.statistics.faceLandmarks (dynamic)
424 * android.statistics.faceRectangles (dynamic)
425 * android.statistics.faceScores (dynamic)
426 *
Zhijun He1ab5c5e2014-05-26 17:35:50 -0700427 * android.sync.frameNumber (dynamic)
428 * android.sync.maxLatency (static)
429 *
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800430 * - Captures in limited mode that include high-resolution (> 1080p) output
431 * buffers may block in process_capture_request() until all the output buffers
432 * have been filled. A full-mode HAL device must process sequences of
433 * high-resolution requests at the rate indicated in the static metadata for
434 * that pixel format. The HAL must still call process_capture_result() to
435 * provide the output; the framework must simply be prepared for
436 * process_capture_request() to block until after process_capture_result() for
437 * that request completes for high-resolution captures for limited-mode
438 * devices.
439 *
Zhijun He1ab5c5e2014-05-26 17:35:50 -0700440 * - Full-mode devices must support below additional capabilities:
441 * - 30fps at maximum resolution is preferred, more than 20fps is required.
442 * - Per frame control (android.sync.maxLatency == PER_FRAME_CONTROL).
443 * - Sensor manual control metadata. See MANUAL_SENSOR defined in
444 * android.request.availableCapabilities.
445 * - Post-processing manual control metadata. See MANUAL_POST_PROCESSING defined
446 * in android.request.availableCapabilities.
447 *
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800448 */
449
450/**
Eino-Ville Talvalaacbc4512013-03-16 16:53:28 -0700451 * S4. 3A modes and state machines:
452 *
453 * While the actual 3A algorithms are up to the HAL implementation, a high-level
454 * state machine description is defined by the HAL interface, to allow the HAL
455 * device and the framework to communicate about the current state of 3A, and to
456 * trigger 3A events.
457 *
458 * When the device is opened, all the individual 3A states must be
459 * STATE_INACTIVE. Stream configuration does not reset 3A. For example, locked
460 * focus must be maintained across the configure() call.
461 *
462 * Triggering a 3A action involves simply setting the relevant trigger entry in
463 * the settings for the next request to indicate start of trigger. For example,
464 * the trigger for starting an autofocus scan is setting the entry
465 * ANDROID_CONTROL_AF_TRIGGER to ANDROID_CONTROL_AF_TRIGGER_START for one
466 * request, and cancelling an autofocus scan is triggered by setting
467 * ANDROID_CONTROL_AF_TRIGGER to ANDROID_CONTRL_AF_TRIGGER_CANCEL. Otherwise,
468 * the entry will not exist, or be set to ANDROID_CONTROL_AF_TRIGGER_IDLE. Each
469 * request with a trigger entry set to a non-IDLE value will be treated as an
470 * independent triggering event.
471 *
472 * At the top level, 3A is controlled by the ANDROID_CONTROL_MODE setting, which
473 * selects between no 3A (ANDROID_CONTROL_MODE_OFF), normal AUTO mode
474 * (ANDROID_CONTROL_MODE_AUTO), and using the scene mode setting
475 * (ANDROID_CONTROL_USE_SCENE_MODE).
476 *
477 * - In OFF mode, each of the individual AE/AF/AWB modes are effectively OFF,
478 * and none of the capture controls may be overridden by the 3A routines.
479 *
480 * - In AUTO mode, Auto-focus, auto-exposure, and auto-whitebalance all run
481 * their own independent algorithms, and have their own mode, state, and
482 * trigger metadata entries, as listed in the next section.
483 *
484 * - In USE_SCENE_MODE, the value of the ANDROID_CONTROL_SCENE_MODE entry must
485 * be used to determine the behavior of 3A routines. In SCENE_MODEs other than
486 * FACE_PRIORITY, the HAL must override the values of
487 * ANDROId_CONTROL_AE/AWB/AF_MODE to be the mode it prefers for the selected
488 * SCENE_MODE. For example, the HAL may prefer SCENE_MODE_NIGHT to use
489 * CONTINUOUS_FOCUS AF mode. Any user selection of AE/AWB/AF_MODE when scene
490 * must be ignored for these scene modes.
491 *
492 * - For SCENE_MODE_FACE_PRIORITY, the AE/AWB/AF_MODE controls work as in
493 * ANDROID_CONTROL_MODE_AUTO, but the 3A routines must bias toward metering
494 * and focusing on any detected faces in the scene.
495 *
496 * S4.1. Auto-focus settings and result entries:
497 *
498 * Main metadata entries:
499 *
500 * ANDROID_CONTROL_AF_MODE: Control for selecting the current autofocus
501 * mode. Set by the framework in the request settings.
502 *
503 * AF_MODE_OFF: AF is disabled; the framework/app directly controls lens
504 * position.
505 *
506 * AF_MODE_AUTO: Single-sweep autofocus. No lens movement unless AF is
507 * triggered.
508 *
509 * AF_MODE_MACRO: Single-sweep up-close autofocus. No lens movement unless
510 * AF is triggered.
511 *
512 * AF_MODE_CONTINUOUS_VIDEO: Smooth continuous focusing, for recording
513 * video. Triggering immediately locks focus in current
514 * position. Canceling resumes cotinuous focusing.
515 *
516 * AF_MODE_CONTINUOUS_PICTURE: Fast continuous focusing, for
517 * zero-shutter-lag still capture. Triggering locks focus once currently
518 * active sweep concludes. Canceling resumes continuous focusing.
519 *
520 * AF_MODE_EDOF: Advanced extended depth of field focusing. There is no
521 * autofocus scan, so triggering one or canceling one has no effect.
522 * Images are focused automatically by the HAL.
523 *
524 * ANDROID_CONTROL_AF_STATE: Dynamic metadata describing the current AF
525 * algorithm state, reported by the HAL in the result metadata.
526 *
527 * AF_STATE_INACTIVE: No focusing has been done, or algorithm was
528 * reset. Lens is not moving. Always the state for MODE_OFF or MODE_EDOF.
529 * When the device is opened, it must start in this state.
530 *
531 * AF_STATE_PASSIVE_SCAN: A continuous focus algorithm is currently scanning
532 * for good focus. The lens is moving.
533 *
534 * AF_STATE_PASSIVE_FOCUSED: A continuous focus algorithm believes it is
535 * well focused. The lens is not moving. The HAL may spontaneously leave
536 * this state.
537 *
Eino-Ville Talvala4d45d302013-09-20 17:24:50 -0700538 * AF_STATE_PASSIVE_UNFOCUSED: A continuous focus algorithm believes it is
539 * not well focused. The lens is not moving. The HAL may spontaneously
540 * leave this state.
541 *
Eino-Ville Talvalaacbc4512013-03-16 16:53:28 -0700542 * AF_STATE_ACTIVE_SCAN: A scan triggered by the user is underway.
543 *
544 * AF_STATE_FOCUSED_LOCKED: The AF algorithm believes it is focused. The
545 * lens is not moving.
546 *
547 * AF_STATE_NOT_FOCUSED_LOCKED: The AF algorithm has been unable to
548 * focus. The lens is not moving.
549 *
550 * ANDROID_CONTROL_AF_TRIGGER: Control for starting an autofocus scan, the
551 * meaning of which is mode- and state- dependent. Set by the framework in
552 * the request settings.
553 *
554 * AF_TRIGGER_IDLE: No current trigger.
555 *
556 * AF_TRIGGER_START: Trigger start of AF scan. Effect is mode and state
557 * dependent.
558 *
559 * AF_TRIGGER_CANCEL: Cancel current AF scan if any, and reset algorithm to
560 * default.
561 *
562 * Additional metadata entries:
563 *
564 * ANDROID_CONTROL_AF_REGIONS: Control for selecting the regions of the FOV
565 * that should be used to determine good focus. This applies to all AF
566 * modes that scan for focus. Set by the framework in the request
567 * settings.
568 *
569 * S4.2. Auto-exposure settings and result entries:
570 *
571 * Main metadata entries:
572 *
573 * ANDROID_CONTROL_AE_MODE: Control for selecting the current auto-exposure
574 * mode. Set by the framework in the request settings.
575 *
576 * AE_MODE_OFF: Autoexposure is disabled; the user controls exposure, gain,
577 * frame duration, and flash.
578 *
579 * AE_MODE_ON: Standard autoexposure, with flash control disabled. User may
580 * set flash to fire or to torch mode.
581 *
582 * AE_MODE_ON_AUTO_FLASH: Standard autoexposure, with flash on at HAL's
583 * discretion for precapture and still capture. User control of flash
584 * disabled.
585 *
586 * AE_MODE_ON_ALWAYS_FLASH: Standard autoexposure, with flash always fired
587 * for capture, and at HAL's discretion for precapture.. User control of
588 * flash disabled.
589 *
590 * AE_MODE_ON_AUTO_FLASH_REDEYE: Standard autoexposure, with flash on at
591 * HAL's discretion for precapture and still capture. Use a flash burst
592 * at end of precapture sequence to reduce redeye in the final
593 * picture. User control of flash disabled.
594 *
595 * ANDROID_CONTROL_AE_STATE: Dynamic metadata describing the current AE
596 * algorithm state, reported by the HAL in the result metadata.
597 *
598 * AE_STATE_INACTIVE: Initial AE state after mode switch. When the device is
599 * opened, it must start in this state.
600 *
601 * AE_STATE_SEARCHING: AE is not converged to a good value, and is adjusting
602 * exposure parameters.
603 *
604 * AE_STATE_CONVERGED: AE has found good exposure values for the current
605 * scene, and the exposure parameters are not changing. HAL may
606 * spontaneously leave this state to search for better solution.
607 *
608 * AE_STATE_LOCKED: AE has been locked with the AE_LOCK control. Exposure
609 * values are not changing.
610 *
611 * AE_STATE_FLASH_REQUIRED: The HAL has converged exposure, but believes
612 * flash is required for a sufficiently bright picture. Used for
613 * determining if a zero-shutter-lag frame can be used.
614 *
615 * AE_STATE_PRECAPTURE: The HAL is in the middle of a precapture
616 * sequence. Depending on AE mode, this mode may involve firing the
617 * flash for metering, or a burst of flash pulses for redeye reduction.
618 *
619 * ANDROID_CONTROL_AE_PRECAPTURE_TRIGGER: Control for starting a metering
620 * sequence before capturing a high-quality image. Set by the framework in
621 * the request settings.
622 *
623 * PRECAPTURE_TRIGGER_IDLE: No current trigger.
624 *
625 * PRECAPTURE_TRIGGER_START: Start a precapture sequence. The HAL should
626 * use the subsequent requests to measure good exposure/white balance
627 * for an upcoming high-resolution capture.
628 *
629 * Additional metadata entries:
630 *
631 * ANDROID_CONTROL_AE_LOCK: Control for locking AE controls to their current
632 * values
633 *
634 * ANDROID_CONTROL_AE_EXPOSURE_COMPENSATION: Control for adjusting AE
635 * algorithm target brightness point.
636 *
637 * ANDROID_CONTROL_AE_TARGET_FPS_RANGE: Control for selecting the target frame
638 * rate range for the AE algorithm. The AE routine cannot change the frame
639 * rate to be outside these bounds.
640 *
641 * ANDROID_CONTROL_AE_REGIONS: Control for selecting the regions of the FOV
642 * that should be used to determine good exposure levels. This applies to
643 * all AE modes besides OFF.
644 *
645 * S4.3. Auto-whitebalance settings and result entries:
646 *
647 * Main metadata entries:
648 *
649 * ANDROID_CONTROL_AWB_MODE: Control for selecting the current white-balance
650 * mode.
651 *
652 * AWB_MODE_OFF: Auto-whitebalance is disabled. User controls color matrix.
653 *
654 * AWB_MODE_AUTO: Automatic white balance is enabled; 3A controls color
655 * transform, possibly using more complex transforms than a simple
656 * matrix.
657 *
658 * AWB_MODE_INCANDESCENT: Fixed white balance settings good for indoor
659 * incandescent (tungsten) lighting, roughly 2700K.
660 *
661 * AWB_MODE_FLUORESCENT: Fixed white balance settings good for fluorescent
662 * lighting, roughly 5000K.
663 *
664 * AWB_MODE_WARM_FLUORESCENT: Fixed white balance settings good for
665 * fluorescent lighting, roughly 3000K.
666 *
667 * AWB_MODE_DAYLIGHT: Fixed white balance settings good for daylight,
668 * roughly 5500K.
669 *
670 * AWB_MODE_CLOUDY_DAYLIGHT: Fixed white balance settings good for clouded
671 * daylight, roughly 6500K.
672 *
673 * AWB_MODE_TWILIGHT: Fixed white balance settings good for
674 * near-sunset/sunrise, roughly 15000K.
675 *
676 * AWB_MODE_SHADE: Fixed white balance settings good for areas indirectly
677 * lit by the sun, roughly 7500K.
678 *
679 * ANDROID_CONTROL_AWB_STATE: Dynamic metadata describing the current AWB
680 * algorithm state, reported by the HAL in the result metadata.
681 *
682 * AWB_STATE_INACTIVE: Initial AWB state after mode switch. When the device
683 * is opened, it must start in this state.
684 *
685 * AWB_STATE_SEARCHING: AWB is not converged to a good value, and is
686 * changing color adjustment parameters.
687 *
688 * AWB_STATE_CONVERGED: AWB has found good color adjustment values for the
689 * current scene, and the parameters are not changing. HAL may
690 * spontaneously leave this state to search for better solution.
691 *
692 * AWB_STATE_LOCKED: AWB has been locked with the AWB_LOCK control. Color
693 * adjustment values are not changing.
694 *
695 * Additional metadata entries:
696 *
697 * ANDROID_CONTROL_AWB_LOCK: Control for locking AWB color adjustments to
698 * their current values.
699 *
700 * ANDROID_CONTROL_AWB_REGIONS: Control for selecting the regions of the FOV
701 * that should be used to determine good color balance. This applies only
702 * to auto-WB mode.
703 *
704 * S4.4. General state machine transition notes
705 *
706 * Switching between AF, AE, or AWB modes always resets the algorithm's state
707 * to INACTIVE. Similarly, switching between CONTROL_MODE or
708 * CONTROL_SCENE_MODE if CONTROL_MODE == USE_SCENE_MODE resets all the
709 * algorithm states to INACTIVE.
710 *
711 * The tables below are per-mode.
712 *
713 * S4.5. AF state machines
714 *
Eino-Ville Talvala4d45d302013-09-20 17:24:50 -0700715 * when enabling AF or changing AF mode
716 *| state | trans. cause | new state | notes |
717 *+--------------------+---------------+--------------------+------------------+
718 *| Any | AF mode change| INACTIVE | |
719 *+--------------------+---------------+--------------------+------------------+
720 *
Eino-Ville Talvalaacbc4512013-03-16 16:53:28 -0700721 * mode = AF_MODE_OFF or AF_MODE_EDOF
722 *| state | trans. cause | new state | notes |
723 *+--------------------+---------------+--------------------+------------------+
Eino-Ville Talvala4d45d302013-09-20 17:24:50 -0700724 *| INACTIVE | | INACTIVE | Never changes |
Eino-Ville Talvalaacbc4512013-03-16 16:53:28 -0700725 *+--------------------+---------------+--------------------+------------------+
726 *
727 * mode = AF_MODE_AUTO or AF_MODE_MACRO
728 *| state | trans. cause | new state | notes |
729 *+--------------------+---------------+--------------------+------------------+
730 *| INACTIVE | AF_TRIGGER | ACTIVE_SCAN | Start AF sweep |
731 *| | | | Lens now moving |
732 *+--------------------+---------------+--------------------+------------------+
733 *| ACTIVE_SCAN | AF sweep done | FOCUSED_LOCKED | If AF successful |
734 *| | | | Lens now locked |
735 *+--------------------+---------------+--------------------+------------------+
736 *| ACTIVE_SCAN | AF sweep done | NOT_FOCUSED_LOCKED | If AF successful |
737 *| | | | Lens now locked |
738 *+--------------------+---------------+--------------------+------------------+
739 *| ACTIVE_SCAN | AF_CANCEL | INACTIVE | Cancel/reset AF |
740 *| | | | Lens now locked |
741 *+--------------------+---------------+--------------------+------------------+
742 *| FOCUSED_LOCKED | AF_CANCEL | INACTIVE | Cancel/reset AF |
743 *+--------------------+---------------+--------------------+------------------+
744 *| FOCUSED_LOCKED | AF_TRIGGER | ACTIVE_SCAN | Start new sweep |
745 *| | | | Lens now moving |
746 *+--------------------+---------------+--------------------+------------------+
747 *| NOT_FOCUSED_LOCKED | AF_CANCEL | INACTIVE | Cancel/reset AF |
748 *+--------------------+---------------+--------------------+------------------+
749 *| NOT_FOCUSED_LOCKED | AF_TRIGGER | ACTIVE_SCAN | Start new sweep |
750 *| | | | Lens now moving |
751 *+--------------------+---------------+--------------------+------------------+
752 *| All states | mode change | INACTIVE | |
753 *+--------------------+---------------+--------------------+------------------+
754 *
755 * mode = AF_MODE_CONTINUOUS_VIDEO
756 *| state | trans. cause | new state | notes |
757 *+--------------------+---------------+--------------------+------------------+
758 *| INACTIVE | HAL initiates | PASSIVE_SCAN | Start AF scan |
759 *| | new scan | | Lens now moving |
760 *+--------------------+---------------+--------------------+------------------+
761 *| INACTIVE | AF_TRIGGER | NOT_FOCUSED_LOCKED | AF state query |
762 *| | | | Lens now locked |
763 *+--------------------+---------------+--------------------+------------------+
764 *| PASSIVE_SCAN | HAL completes | PASSIVE_FOCUSED | End AF scan |
765 *| | current scan | | Lens now locked |
766 *+--------------------+---------------+--------------------+------------------+
Eino-Ville Talvala4d45d302013-09-20 17:24:50 -0700767 *| PASSIVE_SCAN | HAL fails | PASSIVE_UNFOCUSED | End AF scan |
768 *| | current scan | | Lens now locked |
769 *+--------------------+---------------+--------------------+------------------+
Eino-Ville Talvalaacbc4512013-03-16 16:53:28 -0700770 *| PASSIVE_SCAN | AF_TRIGGER | FOCUSED_LOCKED | Immediate trans. |
771 *| | | | if focus is good |
772 *| | | | Lens now locked |
773 *+--------------------+---------------+--------------------+------------------+
774 *| PASSIVE_SCAN | AF_TRIGGER | NOT_FOCUSED_LOCKED | Immediate trans. |
775 *| | | | if focus is bad |
776 *| | | | Lens now locked |
777 *+--------------------+---------------+--------------------+------------------+
778 *| PASSIVE_SCAN | AF_CANCEL | INACTIVE | Reset lens |
779 *| | | | position |
780 *| | | | Lens now locked |
781 *+--------------------+---------------+--------------------+------------------+
782 *| PASSIVE_FOCUSED | HAL initiates | PASSIVE_SCAN | Start AF scan |
783 *| | new scan | | Lens now moving |
784 *+--------------------+---------------+--------------------+------------------+
Eino-Ville Talvala4d45d302013-09-20 17:24:50 -0700785 *| PASSIVE_UNFOCUSED | HAL initiates | PASSIVE_SCAN | Start AF scan |
786 *| | new scan | | Lens now moving |
787 *+--------------------+---------------+--------------------+------------------+
Eino-Ville Talvalaacbc4512013-03-16 16:53:28 -0700788 *| PASSIVE_FOCUSED | AF_TRIGGER | FOCUSED_LOCKED | Immediate trans. |
Eino-Ville Talvalaacbc4512013-03-16 16:53:28 -0700789 *| | | | Lens now locked |
790 *+--------------------+---------------+--------------------+------------------+
Eino-Ville Talvala4d45d302013-09-20 17:24:50 -0700791 *| PASSIVE_UNFOCUSED | AF_TRIGGER | NOT_FOCUSED_LOCKED | Immediate trans. |
Eino-Ville Talvalaacbc4512013-03-16 16:53:28 -0700792 *| | | | Lens now locked |
793 *+--------------------+---------------+--------------------+------------------+
794 *| FOCUSED_LOCKED | AF_TRIGGER | FOCUSED_LOCKED | No effect |
795 *+--------------------+---------------+--------------------+------------------+
796 *| FOCUSED_LOCKED | AF_CANCEL | INACTIVE | Restart AF scan |
797 *+--------------------+---------------+--------------------+------------------+
798 *| NOT_FOCUSED_LOCKED | AF_TRIGGER | NOT_FOCUSED_LOCKED | No effect |
799 *+--------------------+---------------+--------------------+------------------+
800 *| NOT_FOCUSED_LOCKED | AF_CANCEL | INACTIVE | Restart AF scan |
801 *+--------------------+---------------+--------------------+------------------+
802 *
803 * mode = AF_MODE_CONTINUOUS_PICTURE
804 *| state | trans. cause | new state | notes |
805 *+--------------------+---------------+--------------------+------------------+
806 *| INACTIVE | HAL initiates | PASSIVE_SCAN | Start AF scan |
807 *| | new scan | | Lens now moving |
808 *+--------------------+---------------+--------------------+------------------+
809 *| INACTIVE | AF_TRIGGER | NOT_FOCUSED_LOCKED | AF state query |
810 *| | | | Lens now locked |
811 *+--------------------+---------------+--------------------+------------------+
812 *| PASSIVE_SCAN | HAL completes | PASSIVE_FOCUSED | End AF scan |
813 *| | current scan | | Lens now locked |
814 *+--------------------+---------------+--------------------+------------------+
Eino-Ville Talvala4d45d302013-09-20 17:24:50 -0700815 *| PASSIVE_SCAN | HAL fails | PASSIVE_UNFOCUSED | End AF scan |
816 *| | current scan | | Lens now locked |
817 *+--------------------+---------------+--------------------+------------------+
Eino-Ville Talvalaacbc4512013-03-16 16:53:28 -0700818 *| PASSIVE_SCAN | AF_TRIGGER | FOCUSED_LOCKED | Eventual trans. |
819 *| | | | once focus good |
820 *| | | | Lens now locked |
821 *+--------------------+---------------+--------------------+------------------+
822 *| PASSIVE_SCAN | AF_TRIGGER | NOT_FOCUSED_LOCKED | Eventual trans. |
823 *| | | | if cannot focus |
824 *| | | | Lens now locked |
825 *+--------------------+---------------+--------------------+------------------+
826 *| PASSIVE_SCAN | AF_CANCEL | INACTIVE | Reset lens |
827 *| | | | position |
828 *| | | | Lens now locked |
829 *+--------------------+---------------+--------------------+------------------+
830 *| PASSIVE_FOCUSED | HAL initiates | PASSIVE_SCAN | Start AF scan |
831 *| | new scan | | Lens now moving |
832 *+--------------------+---------------+--------------------+------------------+
Eino-Ville Talvala4d45d302013-09-20 17:24:50 -0700833 *| PASSIVE_UNFOCUSED | HAL initiates | PASSIVE_SCAN | Start AF scan |
834 *| | new scan | | Lens now moving |
835 *+--------------------+---------------+--------------------+------------------+
Eino-Ville Talvalaacbc4512013-03-16 16:53:28 -0700836 *| PASSIVE_FOCUSED | AF_TRIGGER | FOCUSED_LOCKED | Immediate trans. |
Eino-Ville Talvalaacbc4512013-03-16 16:53:28 -0700837 *| | | | Lens now locked |
838 *+--------------------+---------------+--------------------+------------------+
Eino-Ville Talvala4d45d302013-09-20 17:24:50 -0700839 *| PASSIVE_UNFOCUSED | AF_TRIGGER | NOT_FOCUSED_LOCKED | Immediate trans. |
Eino-Ville Talvalaacbc4512013-03-16 16:53:28 -0700840 *| | | | Lens now locked |
841 *+--------------------+---------------+--------------------+------------------+
842 *| FOCUSED_LOCKED | AF_TRIGGER | FOCUSED_LOCKED | No effect |
843 *+--------------------+---------------+--------------------+------------------+
844 *| FOCUSED_LOCKED | AF_CANCEL | INACTIVE | Restart AF scan |
845 *+--------------------+---------------+--------------------+------------------+
846 *| NOT_FOCUSED_LOCKED | AF_TRIGGER | NOT_FOCUSED_LOCKED | No effect |
847 *+--------------------+---------------+--------------------+------------------+
848 *| NOT_FOCUSED_LOCKED | AF_CANCEL | INACTIVE | Restart AF scan |
849 *+--------------------+---------------+--------------------+------------------+
850 *
851 * S4.6. AE and AWB state machines
852 *
853 * The AE and AWB state machines are mostly identical. AE has additional
854 * FLASH_REQUIRED and PRECAPTURE states. So rows below that refer to those two
855 * states should be ignored for the AWB state machine.
856 *
Eino-Ville Talvala4d45d302013-09-20 17:24:50 -0700857 * when enabling AE/AWB or changing AE/AWB mode
858 *| state | trans. cause | new state | notes |
859 *+--------------------+---------------+--------------------+------------------+
860 *| Any | mode change | INACTIVE | |
861 *+--------------------+---------------+--------------------+------------------+
862 *
Eino-Ville Talvalaacbc4512013-03-16 16:53:28 -0700863 * mode = AE_MODE_OFF / AWB mode not AUTO
864 *| state | trans. cause | new state | notes |
865 *+--------------------+---------------+--------------------+------------------+
Eino-Ville Talvala4d45d302013-09-20 17:24:50 -0700866 *| INACTIVE | | INACTIVE | AE/AWB disabled |
Eino-Ville Talvalaacbc4512013-03-16 16:53:28 -0700867 *+--------------------+---------------+--------------------+------------------+
868 *
869 * mode = AE_MODE_ON_* / AWB_MODE_AUTO
870 *| state | trans. cause | new state | notes |
871 *+--------------------+---------------+--------------------+------------------+
872 *| INACTIVE | HAL initiates | SEARCHING | |
873 *| | AE/AWB scan | | |
874 *+--------------------+---------------+--------------------+------------------+
875 *| INACTIVE | AE/AWB_LOCK | LOCKED | values locked |
876 *| | on | | |
877 *+--------------------+---------------+--------------------+------------------+
878 *| SEARCHING | HAL finishes | CONVERGED | good values, not |
879 *| | AE/AWB scan | | changing |
880 *+--------------------+---------------+--------------------+------------------+
881 *| SEARCHING | HAL finishes | FLASH_REQUIRED | converged but too|
882 *| | AE scan | | dark w/o flash |
883 *+--------------------+---------------+--------------------+------------------+
884 *| SEARCHING | AE/AWB_LOCK | LOCKED | values locked |
885 *| | on | | |
886 *+--------------------+---------------+--------------------+------------------+
887 *| CONVERGED | HAL initiates | SEARCHING | values locked |
888 *| | AE/AWB scan | | |
889 *+--------------------+---------------+--------------------+------------------+
890 *| CONVERGED | AE/AWB_LOCK | LOCKED | values locked |
891 *| | on | | |
892 *+--------------------+---------------+--------------------+------------------+
Eino-Ville Talvala73dba5e2013-05-21 16:29:14 -0700893 *| FLASH_REQUIRED | HAL initiates | SEARCHING | values locked |
894 *| | AE/AWB scan | | |
895 *+--------------------+---------------+--------------------+------------------+
896 *| FLASH_REQUIRED | AE/AWB_LOCK | LOCKED | values locked |
897 *| | on | | |
898 *+--------------------+---------------+--------------------+------------------+
Eino-Ville Talvalaacbc4512013-03-16 16:53:28 -0700899 *| LOCKED | AE/AWB_LOCK | SEARCHING | values not good |
900 *| | off | | after unlock |
901 *+--------------------+---------------+--------------------+------------------+
902 *| LOCKED | AE/AWB_LOCK | CONVERGED | values good |
903 *| | off | | after unlock |
904 *+--------------------+---------------+--------------------+------------------+
905 *| LOCKED | AE_LOCK | FLASH_REQUIRED | exposure good, |
906 *| | off | | but too dark |
907 *+--------------------+---------------+--------------------+------------------+
908 *| All AE states | PRECAPTURE_ | PRECAPTURE | Start precapture |
909 *| | START | | sequence |
910 *+--------------------+---------------+--------------------+------------------+
911 *| PRECAPTURE | Sequence done.| CONVERGED | Ready for high- |
912 *| | AE_LOCK off | | quality capture |
913 *+--------------------+---------------+--------------------+------------------+
914 *| PRECAPTURE | Sequence done.| LOCKED | Ready for high- |
915 *| | AE_LOCK on | | quality capture |
916 *+--------------------+---------------+--------------------+------------------+
917 *
918 */
919
920/**
Eino-Ville Talvalab6059442013-04-29 15:26:16 -0700921 * S5. Cropping:
922 *
923 * Cropping of the full pixel array (for digital zoom and other use cases where
924 * a smaller FOV is desirable) is communicated through the
925 * ANDROID_SCALER_CROP_REGION setting. This is a per-request setting, and can
926 * change on a per-request basis, which is critical for implementing smooth
927 * digital zoom.
928 *
929 * The region is defined as a rectangle (x, y, width, height), with (x, y)
930 * describing the top-left corner of the rectangle. The rectangle is defined on
931 * the coordinate system of the sensor active pixel array, with (0,0) being the
932 * top-left pixel of the active pixel array. Therefore, the width and height
933 * cannot be larger than the dimensions reported in the
934 * ANDROID_SENSOR_ACTIVE_PIXEL_ARRAY static info field. The minimum allowed
935 * width and height are reported by the HAL through the
936 * ANDROID_SCALER_MAX_DIGITAL_ZOOM static info field, which describes the
937 * maximum supported zoom factor. Therefore, the minimum crop region width and
938 * height are:
939 *
940 * {width, height} =
941 * { floor(ANDROID_SENSOR_ACTIVE_PIXEL_ARRAY[0] /
942 * ANDROID_SCALER_MAX_DIGITAL_ZOOM),
943 * floor(ANDROID_SENSOR_ACTIVE_PIXEL_ARRAY[1] /
944 * ANDROID_SCALER_MAX_DIGITAL_ZOOM) }
945 *
946 * If the crop region needs to fulfill specific requirements (for example, it
947 * needs to start on even coordinates, and its width/height needs to be even),
948 * the HAL must do the necessary rounding and write out the final crop region
949 * used in the output result metadata. Similarly, if the HAL implements video
950 * stabilization, it must adjust the result crop region to describe the region
951 * actually included in the output after video stabilization is applied. In
952 * general, a camera-using application must be able to determine the field of
953 * view it is receiving based on the crop region, the dimensions of the image
954 * sensor, and the lens focal length.
955 *
Zhijun Hef1ee67e2014-05-21 11:18:51 -0700956 * It is assumed that the cropping is applied after raw to other color space
957 * conversion. Raw streams (RAW16 and RAW_OPAQUE) don't have this conversion stage,
958 * and are not croppable. Therefore, the crop region must be ignored by the HAL
959 * for raw streams.
960 *
961 * Since the crop region applies to all non-raw streams, which may have different aspect
Eino-Ville Talvalab6059442013-04-29 15:26:16 -0700962 * ratios than the crop region, the exact sensor region used for each stream may
963 * be smaller than the crop region. Specifically, each stream should maintain
964 * square pixels and its aspect ratio by minimally further cropping the defined
965 * crop region. If the stream's aspect ratio is wider than the crop region, the
966 * stream should be further cropped vertically, and if the stream's aspect ratio
967 * is narrower than the crop region, the stream should be further cropped
968 * horizontally.
969 *
970 * In all cases, the stream crop must be centered within the full crop region,
971 * and each stream is only either cropped horizontally or vertical relative to
972 * the full crop region, never both.
973 *
974 * For example, if two streams are defined, a 640x480 stream (4:3 aspect), and a
975 * 1280x720 stream (16:9 aspect), below demonstrates the expected output regions
976 * for each stream for a few sample crop regions, on a hypothetical 3 MP (2000 x
977 * 1500 pixel array) sensor.
978 *
979 * Crop region: (500, 375, 1000, 750) (4:3 aspect ratio)
980 *
981 * 640x480 stream crop: (500, 375, 1000, 750) (equal to crop region)
982 * 1280x720 stream crop: (500, 469, 1000, 562) (marked with =)
983 *
984 * 0 1000 2000
985 * +---------+---------+---------+----------+
986 * | Active pixel array |
987 * | |
988 * | |
989 * + +-------------------+ + 375
990 * | | | |
991 * | O===================O |
992 * | I 1280x720 stream I |
993 * + I I + 750
994 * | I I |
995 * | O===================O |
996 * | | | |
997 * + +-------------------+ + 1125
998 * | Crop region, 640x480 stream |
999 * | |
1000 * | |
1001 * +---------+---------+---------+----------+ 1500
1002 *
1003 * Crop region: (500, 375, 1333, 750) (16:9 aspect ratio)
1004 *
1005 * 640x480 stream crop: (666, 375, 1000, 750) (marked with =)
1006 * 1280x720 stream crop: (500, 375, 1333, 750) (equal to crop region)
1007 *
1008 * 0 1000 2000
1009 * +---------+---------+---------+----------+
1010 * | Active pixel array |
1011 * | |
1012 * | |
1013 * + +---O==================O---+ + 375
1014 * | | I 640x480 stream I | |
1015 * | | I I | |
1016 * | | I I | |
1017 * + | I I | + 750
1018 * | | I I | |
1019 * | | I I | |
1020 * | | I I | |
1021 * + +---O==================O---+ + 1125
1022 * | Crop region, 1280x720 stream |
1023 * | |
1024 * | |
1025 * +---------+---------+---------+----------+ 1500
1026 *
1027 * Crop region: (500, 375, 750, 750) (1:1 aspect ratio)
1028 *
1029 * 640x480 stream crop: (500, 469, 750, 562) (marked with =)
1030 * 1280x720 stream crop: (500, 543, 750, 414) (marged with #)
1031 *
1032 * 0 1000 2000
1033 * +---------+---------+---------+----------+
1034 * | Active pixel array |
1035 * | |
1036 * | |
1037 * + +--------------+ + 375
1038 * | O==============O |
1039 * | ################ |
1040 * | # # |
1041 * + # # + 750
1042 * | # # |
1043 * | ################ 1280x720 |
1044 * | O==============O 640x480 |
1045 * + +--------------+ + 1125
1046 * | Crop region |
1047 * | |
1048 * | |
1049 * +---------+---------+---------+----------+ 1500
1050 *
1051 * And a final example, a 1024x1024 square aspect ratio stream instead of the
1052 * 480p stream:
1053 *
1054 * Crop region: (500, 375, 1000, 750) (4:3 aspect ratio)
1055 *
1056 * 1024x1024 stream crop: (625, 375, 750, 750) (marked with #)
1057 * 1280x720 stream crop: (500, 469, 1000, 562) (marked with =)
1058 *
1059 * 0 1000 2000
1060 * +---------+---------+---------+----------+
1061 * | Active pixel array |
1062 * | |
1063 * | 1024x1024 stream |
1064 * + +--###############--+ + 375
1065 * | | # # | |
1066 * | O===================O |
1067 * | I 1280x720 stream I |
1068 * + I I + 750
1069 * | I I |
1070 * | O===================O |
1071 * | | # # | |
1072 * + +--###############--+ + 1125
1073 * | Crop region |
1074 * | |
1075 * | |
1076 * +---------+---------+---------+----------+ 1500
1077 *
1078 */
1079
1080/**
1081 * S6. Error management:
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001082 *
1083 * Camera HAL device ops functions that have a return value will all return
1084 * -ENODEV / NULL in case of a serious error. This means the device cannot
1085 * continue operation, and must be closed by the framework. Once this error is
Alex Rayd5ddbc92013-02-15 13:47:24 -08001086 * returned by some method, or if notify() is called with ERROR_DEVICE, only
1087 * the close() method can be called successfully. All other methods will return
1088 * -ENODEV / NULL.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001089 *
Eino-Ville Talvalaacbc4512013-03-16 16:53:28 -07001090 * If a device op is called in the wrong sequence, for example if the framework
1091 * calls configure_streams() is called before initialize(), the device must
1092 * return -ENOSYS from the call, and do nothing.
1093 *
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001094 * Transient errors in image capture must be reported through notify() as follows:
1095 *
1096 * - The failure of an entire capture to occur must be reported by the HAL by
1097 * calling notify() with ERROR_REQUEST. Individual errors for the result
1098 * metadata or the output buffers must not be reported in this case.
1099 *
1100 * - If the metadata for a capture cannot be produced, but some image buffers
1101 * were filled, the HAL must call notify() with ERROR_RESULT.
1102 *
1103 * - If an output image buffer could not be filled, but either the metadata was
1104 * produced or some other buffers were filled, the HAL must call notify() with
1105 * ERROR_BUFFER for each failed buffer.
1106 *
1107 * In each of these transient failure cases, the HAL must still call
Zhijun Heceac9e32014-02-05 20:49:45 -08001108 * process_capture_result, with valid output and input (if an input buffer was
1109 * submitted) buffer_handle_t. If the result metadata could not be produced, it
1110 * should be NULL. If some buffers could not be filled, they must be returned with
1111 * process_capture_result in the error state, their release fences must be set to
1112 * the acquire fences passed by the framework, or -1 if they have been waited on by
1113 * the HAL already.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001114 *
Eino-Ville Talvalaacbc4512013-03-16 16:53:28 -07001115 * Invalid input arguments result in -EINVAL from the appropriate methods. In
1116 * that case, the framework must act as if that call had never been made.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001117 *
1118 */
1119
Zhijun He2dde4682014-01-09 09:11:49 -08001120/**
Zhijun He709e5872014-01-17 15:25:21 -08001121 * S7. Key Performance Indicator (KPI) glossary:
Zhijun He2dde4682014-01-09 09:11:49 -08001122 *
Zhijun He709e5872014-01-17 15:25:21 -08001123 * This includes some critical definitions that are used by KPI metrics.
Zhijun He2dde4682014-01-09 09:11:49 -08001124 *
1125 * Pipeline Latency:
1126 * For a given capture request, the duration from the framework calling
1127 * process_capture_request to the HAL sending capture result and all buffers
1128 * back by process_capture_result call. To make the Pipeline Latency measure
1129 * independent of frame rate, it is measured by frame count.
1130 *
1131 * For example, when frame rate is 30 (fps), the frame duration (time interval
1132 * between adjacent frame capture time) is 33 (ms).
1133 * If it takes 5 frames for framework to get the result and buffers back for
1134 * a given request, then the Pipeline Latency is 5 (frames), instead of
1135 * 5 x 33 = 165 (ms).
1136 *
1137 * The Pipeline Latency is determined by android.request.pipelineDepth and
1138 * android.request.pipelineMaxDepth, see their definitions for more details.
1139 *
1140 */
1141
Zhijun Hebc358682014-01-23 14:42:54 -08001142/**
1143 * S8. Sample Use Cases:
1144 *
1145 * This includes some typical use case examples the camera HAL may support.
1146 *
Zhijun Heb2bc0e52015-01-29 14:44:37 -08001147 * S8.1 Zero Shutter Lag (ZSL) with CAMERA3_STREAM_BIDIRECTIONAL stream.
Zhijun Hebc358682014-01-23 14:42:54 -08001148 *
1149 * For this use case, the bidirectional stream will be used by the framework as follows:
1150 *
1151 * 1. The framework includes a buffer from this stream as output buffer in a
1152 * request as normal.
1153 *
1154 * 2. Once the HAL device returns a filled output buffer to the framework,
1155 * the framework may do one of two things with the filled buffer:
1156 *
1157 * 2. a. The framework uses the filled data, and returns the now-used buffer
1158 * to the stream queue for reuse. This behavior exactly matches the
1159 * OUTPUT type of stream.
1160 *
1161 * 2. b. The framework wants to reprocess the filled data, and uses the
1162 * buffer as an input buffer for a request. Once the HAL device has
1163 * used the reprocessing buffer, it then returns it to the
1164 * framework. The framework then returns the now-used buffer to the
1165 * stream queue for reuse.
1166 *
1167 * 3. The HAL device will be given the buffer again as an output buffer for
1168 * a request at some future point.
1169 *
1170 * For ZSL use case, the pixel format for bidirectional stream will be
Zhijun He52a18892014-06-30 10:35:58 -07001171 * HAL_PIXEL_FORMAT_RAW_OPAQUE or HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED if it
1172 * is listed in android.scaler.availableInputOutputFormatsMap. When
1173 * HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED is used, the gralloc
1174 * usage flags for the consumer endpoint will be set to GRALLOC_USAGE_HW_CAMERA_ZSL.
1175 * A configuration stream list that has BIDIRECTIONAL stream used as input, will
1176 * usually also have a distinct OUTPUT stream to get the reprocessing data. For example,
1177 * for the ZSL use case, the stream list might be configured with the following:
Zhijun Hebc358682014-01-23 14:42:54 -08001178 *
1179 * - A HAL_PIXEL_FORMAT_RAW_OPAQUE bidirectional stream is used
1180 * as input.
1181 * - And a HAL_PIXEL_FORMAT_BLOB (JPEG) output stream.
1182 *
Zhijun Heebdf1282015-01-16 16:44:40 -08001183 * S8.2 ZSL (OPAQUE) reprocessing with CAMERA3_STREAM_INPUT stream.
1184 *
1185 * CAMERA_DEVICE_API_VERSION_3_3:
1186 * When OPAQUE_REPROCESSING capability is supported by the camera device, the INPUT stream
1187 * can be used for application/framework implemented use case like Zero Shutter Lag (ZSL).
1188 * This kind of stream will be used by the framework as follows:
1189 *
1190 * 1. Application/framework configures an opaque (RAW or YUV based) format output stream that is
1191 * used to produce the ZSL output buffers. The stream pixel format will be
1192 * HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED.
1193 *
1194 * 2. Application/framework configures an opaque format input stream that is used to
1195 * send the reprocessing ZSL buffers to the HAL. The stream pixel format will
1196 * also be HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED.
1197 *
1198 * 3. Application/framework configures a YUV/JPEG output stream that is used to receive the
1199 * reprocessed data. The stream pixel format will be YCbCr_420/HAL_PIXEL_FORMAT_BLOB.
1200 *
1201 * 4. Application/framework picks a ZSL buffer from the ZSL output stream when a ZSL capture is
1202 * issued by the application, and sends the data back as an input buffer in a
1203 * reprocessing request, then sends to the HAL for reprocessing.
1204 *
1205 * 5. The HAL sends back the output YUV/JPEG result to framework.
1206 *
1207 * The HAL can select the actual opaque buffer format and configure the ISP pipeline
1208 * appropriately based on the HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED format and
1209 * the gralloc usage flag GRALLOC_USAGE_HW_CAMERA_ZSL.
1210
1211 * S8.3 YUV reprocessing with CAMERA3_STREAM_INPUT stream.
1212 *
1213 * When YUV reprocessing is supported by the HAL, the INPUT stream
1214 * can be used for the YUV reprocessing use cases like lucky-shot and image fusion.
1215 * This kind of stream will be used by the framework as follows:
1216 *
1217 * 1. Application/framework configures an YCbCr_420 format output stream that is
1218 * used to produce the output buffers.
1219 *
1220 * 2. Application/framework configures an YCbCr_420 format input stream that is used to
1221 * send the reprocessing YUV buffers to the HAL.
1222 *
1223 * 3. Application/framework configures a YUV/JPEG output stream that is used to receive the
1224 * reprocessed data. The stream pixel format will be YCbCr_420/HAL_PIXEL_FORMAT_BLOB.
1225 *
1226 * 4. Application/framework processes the output buffers (could be as simple as picking
1227 * an output buffer directly) from the output stream when a capture is issued, and sends
1228 * the data back as an input buffer in a reprocessing request, then sends to the HAL
1229 * for reprocessing.
1230 *
1231 * 5. The HAL sends back the output YUV/JPEG result to framework.
1232 *
Zhijun Hebc358682014-01-23 14:42:54 -08001233 */
1234
Ruben Brunk2d96c742014-03-18 13:39:17 -07001235/**
1236 * S9. Notes on Controls and Metadata
1237 *
1238 * This section contains notes about the interpretation and usage of various metadata tags.
1239 *
1240 * S9.1 HIGH_QUALITY and FAST modes.
1241 *
1242 * Many camera post-processing blocks may be listed as having HIGH_QUALITY,
1243 * FAST, and OFF operating modes. These blocks will typically also have an
1244 * 'available modes' tag representing which of these operating modes are
1245 * available on a given device. The general policy regarding implementing
1246 * these modes is as follows:
1247 *
1248 * 1. Operating mode controls of hardware blocks that cannot be disabled
1249 * must not list OFF in their corresponding 'available modes' tags.
1250 *
1251 * 2. OFF will always be included in their corresponding 'available modes'
1252 * tag if it is possible to disable that hardware block.
1253 *
1254 * 3. FAST must always be included in the 'available modes' tags for all
1255 * post-processing blocks supported on the device. If a post-processing
1256 * block also has a slower and higher quality operating mode that does
1257 * not meet the framerate requirements for FAST mode, HIGH_QUALITY should
1258 * be included in the 'available modes' tag to represent this operating
1259 * mode.
1260 */
Zhijun Heebdf1282015-01-16 16:44:40 -08001261
1262/**
1263 * S10. Reprocessing flow and controls
1264 *
1265 * This section describes the OPAQUE and YUV reprocessing flow and controls. OPAQUE reprocessing
1266 * uses an opaque format that is not directly application-visible, and the application can
1267 * only select some of the output buffers and send back to HAL for reprocessing, while YUV
1268 * reprocessing gives the application opportunity to process the buffers before reprocessing.
1269 *
1270 * S8 gives the stream configurations for the typical reprocessing uses cases,
1271 * this section specifies the buffer flow and controls in more details.
1272 *
1273 * S10.1 OPAQUE (typically for ZSL use case) reprocessing flow and controls
1274 *
1275 * For OPAQUE reprocessing (e.g. ZSL) use case, after the application creates the specific
1276 * output and input streams, runtime buffer flow and controls are specified as below:
1277 *
1278 * 1. Application starts output streaming by sending repeating requests for output
1279 * opaque buffers and preview. The buffers are held by an application
1280 * maintained circular buffer. The requests are based on CAMERA3_TEMPLATE_ZERO_SHUTTER_LAG
1281 * capture template, which should have all necessary settings that guarantee output
1282 * frame rate is not slowed down relative to sensor output frame rate.
1283 *
1284 * 2. When a capture is issued, the application selects one output buffer based
1285 * on application buffer selection logic, e.g. good AE and AF statistics etc.
1286 * Application then creates an reprocess request based on the capture result associated
1287 * with this selected buffer. The selected output buffer is now added to this reprocess
1288 * request as an input buffer, the output buffer of this reprocess request should be
1289 * either JPEG output buffer or YUV output buffer, or both, depending on the application
1290 * choice.
1291 *
1292 * 3. Application then alters the reprocess settings to get best image quality. The HAL must
1293 * support and only support below controls if the HAL support OPAQUE_REPROCESSING capability:
1294 * - android.jpeg.* (if JPEG buffer is included as one of the output)
1295 * - android.noiseReduction.mode (change to HIGH_QUALITY if it is supported)
1296 * - android.edge.mode (change to HIGH_QUALITY if it is supported)
1297 * All other controls must be ignored by the HAL.
1298 * 4. HAL processed the input buffer and return the output buffers in the capture results
1299 * as normal.
1300 *
1301 * S10.2 YUV reprocessing flow and controls
1302 *
1303 * The YUV reprocessing buffer flow is similar as OPAQUE reprocessing, with below difference:
1304 *
1305 * 1. Application may want to have finer granularity control of the intermediate YUV images
1306 * (before reprocessing). For example, application may choose
1307 * - android.noiseReduction.mode == MINIMAL
1308 * to make sure the no YUV domain noise reduction has applied to the output YUV buffers,
1309 * then it can do its own advanced noise reduction on them. For OPAQUE reprocessing case, this
1310 * doesn't matter, as long as the final reprocessed image has the best quality.
1311 * 2. Application may modify the YUV output buffer data. For example, for image fusion use
1312 * case, where multiple output images are merged together to improve the signal-to-noise
1313 * ratio (SNR). The input buffer may be generated from multiple buffers by the application.
1314 * To avoid excessive amount of noise reduction and insufficient amount of edge enhancement
1315 * being applied to the input buffer, the application can hint the HAL how much effective
1316 * exposure time improvement has been done by the application, then the HAL can adjust the
1317 * noise reduction and edge enhancement paramters to get best reprocessed image quality.
1318 * Below tag can be used for this purpose:
1319 * - android.reprocess.effectiveExposureFactor
1320 * The value would be exposure time increase factor applied to the original output image,
1321 * for example, if there are N image merged, the exposure time increase factor would be up
1322 * to sqrt(N). See this tag spec for more details.
1323 *
1324 * S10.3 Reprocessing pipeline characteristics
1325 *
1326 * Reprocessing pipeline has below different characteristics comparing with normal output
1327 * pipeline:
1328 *
1329 * 1. The reprocessing result can be returned ahead of the pending normal output results. But
1330 * the FIFO ordering must be maintained for all reprocessing results. For example, there are
1331 * below requests (A stands for output requests, B stands for reprocessing requests)
1332 * being processed by the HAL:
1333 * A1, A2, A3, A4, B1, A5, B2, A6...
1334 * result of B1 can be returned before A1-A4, but result of B2 must be returned after B1.
1335 * 2. Single input rule: For a given reprocessing request, all output buffers must be from the
1336 * input buffer, rather than sensor output. For example, if a reprocess request include both
1337 * JPEG and preview buffers, all output buffers must be produced from the input buffer
1338 * included by the reprocessing request, rather than sensor. The HAL must not output preview
1339 * buffers from sensor, while output JPEG buffer from the input buffer.
1340 * 3. Input buffer will be from camera output directly (ZSL case) or indirectly(image fusion
1341 * case). For the case where buffer is modified, the size will remain same. The HAL can
1342 * notify CAMERA3_MSG_ERROR_REQUEST if buffer from unknown source is sent.
1343 * 4. Result as reprocessing request: The HAL can expect that a reprocessing request is a copy
1344 * of one of the output results with minor allowed setting changes. The HAL can notify
1345 * CAMERA3_MSG_ERROR_REQUEST if a request from unknown source is issued.
1346 * 5. Output buffers may not be used as inputs across the configure stream boundary, This is
1347 * because an opaque stream like the ZSL output stream may have different actual image size
1348 * inside of the ZSL buffer to save power and bandwidth for smaller resolution JPEG capture.
1349 * The HAL may notify CAMERA3_MSG_ERROR_REQUEST if this case occurs.
1350 * 6. HAL Reprocess requests error reporting during flush should follow the same rule specified
1351 * by flush() method.
1352 *
1353 */
1354
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001355__BEGIN_DECLS
1356
1357struct camera3_device;
1358
1359/**********************************************************************
1360 *
1361 * Camera3 stream and stream buffer definitions.
1362 *
1363 * These structs and enums define the handles and contents of the input and
1364 * output streams connecting the HAL to various framework and application buffer
1365 * consumers. Each stream is backed by a gralloc buffer queue.
1366 *
1367 */
1368
1369/**
1370 * camera3_stream_type_t:
1371 *
1372 * The type of the camera stream, which defines whether the camera HAL device is
1373 * the producer or the consumer for that stream, and how the buffers of the
1374 * stream relate to the other streams.
1375 */
1376typedef enum camera3_stream_type {
1377 /**
1378 * This stream is an output stream; the camera HAL device will be
1379 * responsible for filling buffers from this stream with newly captured or
1380 * reprocessed image data.
1381 */
1382 CAMERA3_STREAM_OUTPUT = 0,
1383
1384 /**
1385 * This stream is an input stream; the camera HAL device will be responsible
1386 * for reading buffers from this stream and sending them through the camera
1387 * processing pipeline, as if the buffer was a newly captured image from the
1388 * imager.
Zhijun Hebc358682014-01-23 14:42:54 -08001389 *
1390 * The pixel format for input stream can be any format reported by
Eino-Ville Talvalac5bff0d2014-02-10 16:43:26 -08001391 * android.scaler.availableInputOutputFormatsMap. The pixel format of the
1392 * output stream that is used to produce the reprocessing data may be any
1393 * format reported by android.scaler.availableStreamConfigurations. The
1394 * supported input/output stream combinations depends the camera device
1395 * capabilities, see android.scaler.availableInputOutputFormatsMap for
1396 * stream map details.
Zhijun Hebc358682014-01-23 14:42:54 -08001397 *
Eino-Ville Talvalac5bff0d2014-02-10 16:43:26 -08001398 * This kind of stream is generally used to reprocess data into higher
1399 * quality images (that otherwise would cause a frame rate performance
1400 * loss), or to do off-line reprocessing.
Zhijun Hebc358682014-01-23 14:42:54 -08001401 *
Zhijun Heebdf1282015-01-16 16:44:40 -08001402 * CAMERA_DEVICE_API_VERSION_3_3:
1403 * The typical use cases are OPAQUE (typically ZSL) and YUV reprocessing,
1404 * see S8.2, S8.3 and S10 for more details.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001405 */
1406 CAMERA3_STREAM_INPUT = 1,
1407
1408 /**
1409 * This stream can be used for input and output. Typically, the stream is
1410 * used as an output stream, but occasionally one already-filled buffer may
1411 * be sent back to the HAL device for reprocessing.
1412 *
Eino-Ville Talvalac5bff0d2014-02-10 16:43:26 -08001413 * This kind of stream is meant generally for Zero Shutter Lag (ZSL)
1414 * features, where copying the captured image from the output buffer to the
Zhijun Heb2bc0e52015-01-29 14:44:37 -08001415 * reprocessing input buffer would be expensive. See S8.1 for more details.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001416 *
1417 * Note that the HAL will always be reprocessing data it produced.
1418 *
1419 */
1420 CAMERA3_STREAM_BIDIRECTIONAL = 2,
1421
1422 /**
1423 * Total number of framework-defined stream types
1424 */
1425 CAMERA3_NUM_STREAM_TYPES
1426
1427} camera3_stream_type_t;
1428
1429/**
Yin-Chia Yehe0042082015-03-09 12:15:36 -07001430 * camera3_stream_rotation_t:
1431 *
1432 * The required counterclockwise rotation of camera stream.
1433 */
1434typedef enum camera3_stream_rotation {
1435 /* No rotation */
1436 CAMERA3_STREAM_ROTATION_0 = 0,
1437
1438 /* Rotate by 90 degree counterclockwise */
1439 CAMERA3_STREAM_ROTATION_90 = 1,
1440
1441 /* Rotate by 180 degree counterclockwise */
1442 CAMERA3_STREAM_ROTATION_180 = 2,
1443
1444 /* Rotate by 270 degree counterclockwise */
1445 CAMERA3_STREAM_ROTATION_270 = 3
1446} camera3_stream_rotation_t;
1447
1448/**
Zhijun He21126b72015-05-22 18:12:28 -07001449 * camera3_stream_configuration_mode_t:
1450 *
1451 * This defines the general operation mode for the HAL (for a given stream configuration), where
1452 * modes besides NORMAL have different semantics, and usually limit the generality of the API in
1453 * exchange for higher performance in some particular area.
1454 */
1455typedef enum camera3_stream_configuration_mode {
1456 /**
1457 * Normal stream configuration operation mode. This is the default camera operation mode,
1458 * where all semantics of HAL APIs and metadata controls apply.
1459 */
1460 CAMERA3_STREAM_CONFIGURATION_NORMAL_MODE = 0,
1461
1462 /**
1463 * Special constrained high speed operation mode for devices that can not support high
1464 * speed output in NORMAL mode. All streams in this configuration are operating at high speed
1465 * mode and have different characteristics and limitations to achieve high speed output.
1466 * The NORMAL mode can still be used for high speed output if the HAL can support high speed
1467 * output while satisfying all the semantics of HAL APIs and metadata controls. It is
1468 * recommended for the HAL to support high speed output in NORMAL mode (by advertising the high
1469 * speed FPS ranges in android.control.aeAvailableTargetFpsRanges) if possible.
1470 *
1471 * This mode has below limitations/requirements:
1472 *
1473 * 1. The HAL must support up to 2 streams with sizes reported by
1474 * android.control.availableHighSpeedVideoConfigurations.
1475 * 2. In this mode, the HAL is expected to output up to 120fps or higher. This mode must
1476 * support the targeted FPS range and size configurations reported by
1477 * android.control.availableHighSpeedVideoConfigurations.
1478 * 3. The HAL must support HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED output stream format.
1479 * 4. To achieve efficient high speed streaming, the HAL may have to aggregate
1480 * multiple frames together and send to camera device for processing where the request
1481 * controls are same for all the frames in this batch (batch mode). The HAL must support
1482 * max batch size and the max batch size requirements defined by
1483 * android.control.availableHighSpeedVideoConfigurations.
1484 * 5. In this mode, the HAL must override aeMode, awbMode, and afMode to ON, ON, and
1485 * CONTINUOUS_VIDEO, respectively. All post-processing block mode controls must be
1486 * overridden to be FAST. Therefore, no manual control of capture and post-processing
1487 * parameters is possible. All other controls operate the same as when
1488 * android.control.mode == AUTO. This means that all other android.control.* fields
1489 * must continue to work, such as
1490 *
1491 * android.control.aeTargetFpsRange
1492 * android.control.aeExposureCompensation
1493 * android.control.aeLock
1494 * android.control.awbLock
1495 * android.control.effectMode
1496 * android.control.aeRegions
1497 * android.control.afRegions
1498 * android.control.awbRegions
1499 * android.control.afTrigger
1500 * android.control.aePrecaptureTrigger
1501 *
1502 * Outside of android.control.*, the following controls must work:
1503 *
1504 * android.flash.mode (TORCH mode only, automatic flash for still capture will not work
1505 * since aeMode is ON)
1506 * android.lens.opticalStabilizationMode (if it is supported)
1507 * android.scaler.cropRegion
1508 * android.statistics.faceDetectMode (if it is supported)
Shuzhen Wang13a19e12017-03-08 16:41:13 -08001509 * 6. To reduce the amount of data passed across process boundaries at
1510 * high frame rate, within one batch, camera framework only propagates
1511 * the last shutter notify and the last capture results (including partial
1512 * results and final result) to the app. The shutter notifies and capture
1513 * results for the other requests in the batch are derived by
1514 * the camera framework. As a result, the HAL can return empty metadata
1515 * except for the last result in the batch.
Zhijun He21126b72015-05-22 18:12:28 -07001516 *
1517 * For more details about high speed stream requirements, see
1518 * android.control.availableHighSpeedVideoConfigurations and CONSTRAINED_HIGH_SPEED_VIDEO
1519 * capability defined in android.request.availableCapabilities.
1520 *
1521 * This mode only needs to be supported by HALs that include CONSTRAINED_HIGH_SPEED_VIDEO in
1522 * the android.request.availableCapabilities static metadata.
1523 */
1524 CAMERA3_STREAM_CONFIGURATION_CONSTRAINED_HIGH_SPEED_MODE = 1,
1525
1526 /**
1527 * First value for vendor-defined stream configuration modes.
1528 */
1529 CAMERA3_VENDOR_STREAM_CONFIGURATION_MODE_START = 0x8000
1530} camera3_stream_configuration_mode_t;
1531
1532/**
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001533 * camera3_stream_t:
1534 *
1535 * A handle to a single camera input or output stream. A stream is defined by
1536 * the framework by its buffer resolution and format, and additionally by the
1537 * HAL with the gralloc usage flags and the maximum in-flight buffer count.
1538 *
1539 * The stream structures are owned by the framework, but pointers to a
1540 * camera3_stream passed into the HAL by configure_streams() are valid until the
1541 * end of the first subsequent configure_streams() call that _does not_ include
1542 * that camera3_stream as an argument, or until the end of the close() call.
1543 *
1544 * All camera3_stream framework-controlled members are immutable once the
1545 * camera3_stream is passed into configure_streams(). The HAL may only change
1546 * the HAL-controlled parameters during a configure_streams() call, except for
1547 * the contents of the private pointer.
1548 *
1549 * If a configure_streams() call returns a non-fatal error, all active streams
1550 * remain valid as if configure_streams() had not been called.
1551 *
1552 * The endpoint of the stream is not visible to the camera HAL device.
Alex Ray2ce219a2013-06-14 15:09:30 -07001553 * In DEVICE_API_VERSION_3_1, this was changed to share consumer usage flags
1554 * on streams where the camera is a producer (OUTPUT and BIDIRECTIONAL stream
1555 * types) see the usage field below.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001556 */
1557typedef struct camera3_stream {
1558
1559 /*****
1560 * Set by framework before configure_streams()
1561 */
1562
1563 /**
1564 * The type of the stream, one of the camera3_stream_type_t values.
1565 */
1566 int stream_type;
1567
1568 /**
1569 * The width in pixels of the buffers in this stream
1570 */
1571 uint32_t width;
1572
1573 /**
1574 * The height in pixels of the buffers in this stream
1575 */
1576 uint32_t height;
1577
1578 /**
1579 * The pixel format for the buffers in this stream. Format is a value from
1580 * the HAL_PIXEL_FORMAT_* list in system/core/include/system/graphics.h, or
1581 * from device-specific headers.
1582 *
1583 * If HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED is used, then the platform
1584 * gralloc module will select a format based on the usage flags provided by
1585 * the camera device and the other endpoint of the stream.
1586 *
Igor Murashkin78aa1262014-01-09 16:23:43 -08001587 * <= CAMERA_DEVICE_API_VERSION_3_1:
1588 *
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001589 * The camera HAL device must inspect the buffers handed to it in the
1590 * subsequent register_stream_buffers() call to obtain the
1591 * implementation-specific format details, if necessary.
Igor Murashkin78aa1262014-01-09 16:23:43 -08001592 *
1593 * >= CAMERA_DEVICE_API_VERSION_3_2:
1594 *
1595 * register_stream_buffers() won't be called by the framework, so the HAL
1596 * should configure the ISP and sensor pipeline based purely on the sizes,
1597 * usage flags, and formats for the configured streams.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001598 */
1599 int format;
1600
1601 /*****
1602 * Set by HAL during configure_streams().
1603 */
1604
1605 /**
1606 * The gralloc usage flags for this stream, as needed by the HAL. The usage
1607 * flags are defined in gralloc.h (GRALLOC_USAGE_*), or in device-specific
1608 * headers.
1609 *
1610 * For output streams, these are the HAL's producer usage flags. For input
1611 * streams, these are the HAL's consumer usage flags. The usage flags from
1612 * the producer and the consumer will be combined together and then passed
1613 * to the platform gralloc HAL module for allocating the gralloc buffers for
1614 * each stream.
Alex Ray2ce219a2013-06-14 15:09:30 -07001615 *
1616 * Version information:
1617 *
1618 * == CAMERA_DEVICE_API_VERSION_3_0:
1619 *
1620 * No initial value guaranteed when passed via configure_streams().
1621 * HAL may not use this field as input, and must write over this field
1622 * with its usage flags.
1623 *
1624 * >= CAMERA_DEVICE_API_VERSION_3_1:
1625 *
1626 * For stream_type OUTPUT and BIDIRECTIONAL, when passed via
1627 * configure_streams(), the initial value of this is the consumer's
1628 * usage flags. The HAL may use these consumer flags to decide stream
1629 * configuration.
1630 * For stream_type INPUT, when passed via configure_streams(), the initial
1631 * value of this is 0.
1632 * For all streams passed via configure_streams(), the HAL must write
1633 * over this field with its usage flags.
Shuzhen Wang07a5cd52017-03-20 09:26:42 -07001634 *
1635 * From Android O, the usage flag for an output stream may be bitwise
1636 * combination of usage flags for multiple consumers, for the purpose of
1637 * sharing one camera stream between those consumers. The HAL must fail
1638 * configure_streams call with -EINVAL if the combined flags cannot be
1639 * supported due to imcompatible buffer format, dataSpace, or other hardware
1640 * limitations.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001641 */
1642 uint32_t usage;
1643
1644 /**
1645 * The maximum number of buffers the HAL device may need to have dequeued at
1646 * the same time. The HAL device may not have more buffers in-flight from
1647 * this stream than this value.
1648 */
1649 uint32_t max_buffers;
1650
1651 /**
1652 * A handle to HAL-private information for the stream. Will not be inspected
1653 * by the framework code.
1654 */
1655 void *priv;
1656
Eino-Ville Talvala453c7902015-03-06 13:22:03 -08001657 /**
1658 * A field that describes the contents of the buffer. The format and buffer
1659 * dimensions define the memory layout and structure of the stream buffers,
1660 * while dataSpace defines the meaning of the data within the buffer.
1661 *
1662 * For most formats, dataSpace defines the color space of the image data.
1663 * In addition, for some formats, dataSpace indicates whether image- or
1664 * depth-based data is requested. See system/core/include/system/graphics.h
1665 * for details of formats and valid dataSpace values for each format.
1666 *
1667 * Version information:
1668 *
1669 * < CAMERA_DEVICE_API_VERSION_3_3:
1670 *
1671 * Not defined and should not be accessed. dataSpace should be assumed to
1672 * be HAL_DATASPACE_UNKNOWN, and the appropriate color space, etc, should
1673 * be determined from the usage flags and the format.
1674 *
Eino-Ville Talvalacd86b0d2016-03-06 17:08:40 -08001675 * = CAMERA_DEVICE_API_VERSION_3_3:
Eino-Ville Talvala453c7902015-03-06 13:22:03 -08001676 *
1677 * Always set by the camera service. HAL must use this dataSpace to
1678 * configure the stream to the correct colorspace, or to select between
Eino-Ville Talvalacd86b0d2016-03-06 17:08:40 -08001679 * color and depth outputs if supported. The dataspace values are the
1680 * legacy definitions in graphics.h
1681 *
1682 * >= CAMERA_DEVICE_API_VERSION_3_4:
1683 *
1684 * Always set by the camera service. HAL must use this dataSpace to
1685 * configure the stream to the correct colorspace, or to select between
1686 * color and depth outputs if supported. The dataspace values are set
1687 * using the V0 dataspace definitions in graphics.h
Eino-Ville Talvala453c7902015-03-06 13:22:03 -08001688 */
1689 android_dataspace_t data_space;
1690
Yin-Chia Yehe0042082015-03-09 12:15:36 -07001691 /**
1692 * The required output rotation of the stream, one of
1693 * the camera3_stream_rotation_t values. This must be inspected by HAL along
1694 * with stream width and height. For example, if the rotation is 90 degree
1695 * and the stream width and height is 720 and 1280 respectively, camera service
1696 * will supply buffers of size 720x1280, and HAL should capture a 1280x720 image
Yin-Chia Yeh5407ef12015-03-12 15:09:27 -07001697 * and rotate the image by 90 degree counterclockwise. The rotation field is
1698 * no-op when the stream type is input. Camera HAL must ignore the rotation
1699 * field for an input stream.
Yin-Chia Yehe0042082015-03-09 12:15:36 -07001700 *
1701 * <= CAMERA_DEVICE_API_VERSION_3_2:
1702 *
1703 * Not defined and must not be accessed. HAL must not apply any rotation
1704 * on output images.
1705 *
1706 * >= CAMERA_DEVICE_API_VERSION_3_3:
1707 *
1708 * Always set by camera service. HAL must inspect this field during stream
1709 * configuration and returns -EINVAL if HAL cannot perform such rotation.
1710 * HAL must always support CAMERA3_STREAM_ROTATION_0, so a
1711 * configure_streams() call must not fail for unsupported rotation if
1712 * rotation field of all streams is CAMERA3_STREAM_ROTATION_0.
1713 *
1714 */
1715 int rotation;
1716
Shuzhen Wangbf39eb52017-11-29 15:16:03 -08001717 /**
1718 * The physical camera id this stream belongs to.
1719 *
1720 * <= CAMERA_DEVICE_API_VERISON_3_4:
1721 *
1722 * Not defined and must not be accessed.
1723 *
1724 * >= CAMERA_DEVICE_API_VERISON_3_5:
1725 *
1726 * Always set by camera service. If the camera device is not a logical
1727 * multi camera, or if the camera is a logical multi camera but the stream
1728 * is not a physical output stream, this field will point to a 0-length
1729 * string.
1730 *
1731 * A logical multi camera is a camera device backed by multiple physical
1732 * cameras that are also exposed to the application. And for a logical
1733 * multi camera, a physical output stream is an output stream specifically
1734 * requested on an underlying physical camera.
1735 *
1736 * For an input stream, this field is guaranteed to be a 0-length string.
1737 */
1738 const char* physical_camera_id;
1739
Eino-Ville Talvala453c7902015-03-06 13:22:03 -08001740 /* reserved for future use */
Shuzhen Wangbf39eb52017-11-29 15:16:03 -08001741 void *reserved[6];
Eino-Ville Talvala453c7902015-03-06 13:22:03 -08001742
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001743} camera3_stream_t;
1744
1745/**
1746 * camera3_stream_configuration_t:
1747 *
1748 * A structure of stream definitions, used by configure_streams(). This
1749 * structure defines all the output streams and the reprocessing input
1750 * stream for the current camera use case.
1751 */
1752typedef struct camera3_stream_configuration {
1753 /**
1754 * The total number of streams requested by the framework. This includes
1755 * both input and output streams. The number of streams will be at least 1,
1756 * and there will be at least one output-capable stream.
1757 */
1758 uint32_t num_streams;
1759
1760 /**
Eino-Ville Talvala3a6e6b42013-03-06 13:21:11 -08001761 * An array of camera stream pointers, defining the input/output
1762 * configuration for the camera HAL device.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001763 *
1764 * At most one input-capable stream may be defined (INPUT or BIDIRECTIONAL)
1765 * in a single configuration.
1766 *
1767 * At least one output-capable stream must be defined (OUTPUT or
1768 * BIDIRECTIONAL).
1769 */
Eino-Ville Talvala3a6e6b42013-03-06 13:21:11 -08001770 camera3_stream_t **streams;
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001771
Zhijun He21126b72015-05-22 18:12:28 -07001772 /**
1773 * >= CAMERA_DEVICE_API_VERSION_3_3:
1774 *
Eino-Ville Talvalacd86b0d2016-03-06 17:08:40 -08001775 * The operation mode of streams in this configuration, one of the value
1776 * defined in camera3_stream_configuration_mode_t. The HAL can use this
1777 * mode as an indicator to set the stream property (e.g.,
1778 * camera3_stream->max_buffers) appropriately. For example, if the
1779 * configuration is
1780 * CAMERA3_STREAM_CONFIGURATION_CONSTRAINED_HIGH_SPEED_MODE, the HAL may
1781 * want to set aside more buffers for batch mode operation (see
1782 * android.control.availableHighSpeedVideoConfigurations for batch mode
1783 * definition).
Zhijun He21126b72015-05-22 18:12:28 -07001784 *
1785 */
1786 uint32_t operation_mode;
Emilian Peeveec2ee92017-11-08 19:33:27 +00001787
1788 /**
1789 * >= CAMERA_DEVICE_API_VERSION_3_5:
1790 *
1791 * The session metadata buffer contains the initial values of
1792 * ANDROID_REQUEST_AVAILABLE_SESSION_KEYS. This field is optional
1793 * and camera clients can choose to ignore it, in which case it will
1794 * be set to NULL. If parameters are present, then Hal should examine
1795 * the parameter values and configure its internal camera pipeline
1796 * accordingly.
1797 */
1798 const camera_metadata_t *session_parameters;
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001799} camera3_stream_configuration_t;
1800
1801/**
Eino-Ville Talvala2f8cf5c2013-03-06 13:23:31 -08001802 * camera3_buffer_status_t:
1803 *
1804 * The current status of a single stream buffer.
1805 */
1806typedef enum camera3_buffer_status {
1807 /**
1808 * The buffer is in a normal state, and can be used after waiting on its
1809 * sync fence.
1810 */
1811 CAMERA3_BUFFER_STATUS_OK = 0,
1812
1813 /**
1814 * The buffer does not contain valid data, and the data in it should not be
1815 * used. The sync fence must still be waited on before reusing the buffer.
1816 */
1817 CAMERA3_BUFFER_STATUS_ERROR = 1
1818
1819} camera3_buffer_status_t;
1820
1821/**
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001822 * camera3_stream_buffer_t:
1823 *
1824 * A single buffer from a camera3 stream. It includes a handle to its parent
1825 * stream, the handle to the gralloc buffer itself, and sync fences
1826 *
1827 * The buffer does not specify whether it is to be used for input or output;
1828 * that is determined by its parent stream type and how the buffer is passed to
1829 * the HAL device.
1830 */
1831typedef struct camera3_stream_buffer {
1832 /**
1833 * The handle of the stream this buffer is associated with
1834 */
1835 camera3_stream_t *stream;
1836
1837 /**
1838 * The native handle to the buffer
1839 */
1840 buffer_handle_t *buffer;
1841
1842 /**
Eino-Ville Talvala2f8cf5c2013-03-06 13:23:31 -08001843 * Current state of the buffer, one of the camera3_buffer_status_t
1844 * values. The framework will not pass buffers to the HAL that are in an
1845 * error state. In case a buffer could not be filled by the HAL, it must
1846 * have its status set to CAMERA3_BUFFER_STATUS_ERROR when returned to the
1847 * framework with process_capture_result().
1848 */
1849 int status;
1850
1851 /**
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001852 * The acquire sync fence for this buffer. The HAL must wait on this fence
1853 * fd before attempting to read from or write to this buffer.
1854 *
1855 * The framework may be set to -1 to indicate that no waiting is necessary
Eino-Ville Talvala2f8cf5c2013-03-06 13:23:31 -08001856 * for this buffer.
1857 *
1858 * When the HAL returns an output buffer to the framework with
1859 * process_capture_result(), the acquire_fence must be set to -1. If the HAL
1860 * never waits on the acquire_fence due to an error in filling a buffer,
1861 * when calling process_capture_result() the HAL must set the release_fence
1862 * of the buffer to be the acquire_fence passed to it by the framework. This
1863 * will allow the framework to wait on the fence before reusing the buffer.
1864 *
1865 * For input buffers, the HAL must not change the acquire_fence field during
1866 * the process_capture_request() call.
Zhijun Heceac9e32014-02-05 20:49:45 -08001867 *
1868 * >= CAMERA_DEVICE_API_VERSION_3_2:
1869 *
1870 * When the HAL returns an input buffer to the framework with
1871 * process_capture_result(), the acquire_fence must be set to -1. If the HAL
Eino-Ville Talvalac5bff0d2014-02-10 16:43:26 -08001872 * never waits on input buffer acquire fence due to an error, the sync
1873 * fences should be handled similarly to the way they are handled for output
1874 * buffers.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001875 */
1876 int acquire_fence;
1877
1878 /**
1879 * The release sync fence for this buffer. The HAL must set this fence when
1880 * returning buffers to the framework, or write -1 to indicate that no
1881 * waiting is required for this buffer.
1882 *
Zhijun Heceac9e32014-02-05 20:49:45 -08001883 * For the output buffers, the fences must be set in the output_buffers
1884 * array passed to process_capture_result().
1885 *
1886 * <= CAMERA_DEVICE_API_VERSION_3_1:
1887 *
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001888 * For the input buffer, the release fence must be set by the
Zhijun Heceac9e32014-02-05 20:49:45 -08001889 * process_capture_request() call.
Eino-Ville Talvala2f8cf5c2013-03-06 13:23:31 -08001890 *
Igor Murashkin78aa1262014-01-09 16:23:43 -08001891 * >= CAMERA_DEVICE_API_VERSION_3_2:
1892 *
Zhijun Heceac9e32014-02-05 20:49:45 -08001893 * For the input buffer, the fences must be set in the input_buffer
1894 * passed to process_capture_result().
1895 *
Igor Murashkin78aa1262014-01-09 16:23:43 -08001896 * After signaling the release_fence for this buffer, the HAL
1897 * should not make any further attempts to access this buffer as the
1898 * ownership has been fully transferred back to the framework.
1899 *
1900 * If a fence of -1 was specified then the ownership of this buffer
1901 * is transferred back immediately upon the call of process_capture_result.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001902 */
1903 int release_fence;
1904
1905} camera3_stream_buffer_t;
1906
1907/**
1908 * camera3_stream_buffer_set_t:
1909 *
1910 * The complete set of gralloc buffers for a stream. This structure is given to
1911 * register_stream_buffers() to allow the camera HAL device to register/map/etc
1912 * newly allocated stream buffers.
Igor Murashkin78aa1262014-01-09 16:23:43 -08001913 *
1914 * >= CAMERA_DEVICE_API_VERSION_3_2:
1915 *
1916 * Deprecated (and not used). In particular,
1917 * register_stream_buffers is also deprecated and will never be invoked.
1918 *
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001919 */
1920typedef struct camera3_stream_buffer_set {
1921 /**
1922 * The stream handle for the stream these buffers belong to
1923 */
1924 camera3_stream_t *stream;
1925
1926 /**
1927 * The number of buffers in this stream. It is guaranteed to be at least
1928 * stream->max_buffers.
1929 */
1930 uint32_t num_buffers;
1931
1932 /**
1933 * The array of gralloc buffer handles for this stream. If the stream format
1934 * is set to HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, the camera HAL device
1935 * should inspect the passed-in buffers to determine any platform-private
1936 * pixel format information.
1937 */
Eino-Ville Talvala3a6e6b42013-03-06 13:21:11 -08001938 buffer_handle_t **buffers;
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001939
1940} camera3_stream_buffer_set_t;
1941
1942/**
1943 * camera3_jpeg_blob:
1944 *
1945 * Transport header for compressed JPEG buffers in output streams.
1946 *
1947 * To capture JPEG images, a stream is created using the pixel format
Zhijun He44a89152014-04-24 14:34:53 -07001948 * HAL_PIXEL_FORMAT_BLOB. The buffer size for the stream is calculated by the
1949 * framework, based on the static metadata field android.jpeg.maxSize. Since
1950 * compressed JPEG images are of variable size, the HAL needs to include the
1951 * final size of the compressed image using this structure inside the output
1952 * stream buffer. The JPEG blob ID field must be set to CAMERA3_JPEG_BLOB_ID.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001953 *
Zhijun He44a89152014-04-24 14:34:53 -07001954 * Transport header should be at the end of the JPEG output stream buffer. That
1955 * means the jpeg_blob_id must start at byte[buffer_size -
1956 * sizeof(camera3_jpeg_blob)], where the buffer_size is the size of gralloc buffer.
1957 * Any HAL using this transport header must account for it in android.jpeg.maxSize
1958 * The JPEG data itself starts at the beginning of the buffer and should be
1959 * jpeg_size bytes long.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001960 */
1961typedef struct camera3_jpeg_blob {
1962 uint16_t jpeg_blob_id;
1963 uint32_t jpeg_size;
1964} camera3_jpeg_blob_t;
1965
1966enum {
1967 CAMERA3_JPEG_BLOB_ID = 0x00FF
1968};
1969
1970/**********************************************************************
1971 *
1972 * Message definitions for the HAL notify() callback.
1973 *
1974 * These definitions are used for the HAL notify callback, to signal
1975 * asynchronous events from the HAL device to the Android framework.
1976 *
1977 */
1978
1979/**
1980 * camera3_msg_type:
1981 *
1982 * Indicates the type of message sent, which specifies which member of the
1983 * message union is valid.
1984 *
1985 */
1986typedef enum camera3_msg_type {
1987 /**
1988 * An error has occurred. camera3_notify_msg.message.error contains the
1989 * error information.
1990 */
1991 CAMERA3_MSG_ERROR = 1,
1992
1993 /**
Chien-Yu Chen73b49eb2015-05-28 17:13:05 -07001994 * The exposure of a given request or processing a reprocess request has
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001995 * begun. camera3_notify_msg.message.shutter contains the information
1996 * the capture.
1997 */
1998 CAMERA3_MSG_SHUTTER = 2,
1999
2000 /**
2001 * Number of framework message types
2002 */
2003 CAMERA3_NUM_MESSAGES
2004
2005} camera3_msg_type_t;
2006
2007/**
2008 * Defined error codes for CAMERA_MSG_ERROR
2009 */
2010typedef enum camera3_error_msg_code {
2011 /**
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002012 * A serious failure occured. No further frames or buffer streams will
2013 * be produced by the device. Device should be treated as closed. The
2014 * client must reopen the device to use it again. The frame_number field
2015 * is unused.
2016 */
Alex Rayd5ddbc92013-02-15 13:47:24 -08002017 CAMERA3_MSG_ERROR_DEVICE = 1,
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002018
2019 /**
2020 * An error has occurred in processing a request. No output (metadata or
2021 * buffers) will be produced for this request. The frame_number field
2022 * specifies which request has been dropped. Subsequent requests are
2023 * unaffected, and the device remains operational.
2024 */
Alex Rayd5ddbc92013-02-15 13:47:24 -08002025 CAMERA3_MSG_ERROR_REQUEST = 2,
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002026
2027 /**
2028 * An error has occurred in producing an output result metadata buffer
2029 * for a request, but output stream buffers for it will still be
2030 * available. Subsequent requests are unaffected, and the device remains
2031 * operational. The frame_number field specifies the request for which
2032 * result metadata won't be available.
2033 */
Alex Rayd5ddbc92013-02-15 13:47:24 -08002034 CAMERA3_MSG_ERROR_RESULT = 3,
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002035
2036 /**
2037 * An error has occurred in placing an output buffer into a stream for a
2038 * request. The frame metadata and other buffers may still be
2039 * available. Subsequent requests are unaffected, and the device remains
2040 * operational. The frame_number field specifies the request for which the
2041 * buffer was dropped, and error_stream contains a pointer to the stream
Eino-Ville Talvalacd86b0d2016-03-06 17:08:40 -08002042 * that dropped the frame.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002043 */
Alex Rayd5ddbc92013-02-15 13:47:24 -08002044 CAMERA3_MSG_ERROR_BUFFER = 4,
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002045
2046 /**
2047 * Number of error types
2048 */
2049 CAMERA3_MSG_NUM_ERRORS
2050
2051} camera3_error_msg_code_t;
2052
2053/**
2054 * camera3_error_msg_t:
2055 *
2056 * Message contents for CAMERA3_MSG_ERROR
2057 */
2058typedef struct camera3_error_msg {
2059 /**
2060 * Frame number of the request the error applies to. 0 if the frame number
2061 * isn't applicable to the error.
2062 */
2063 uint32_t frame_number;
2064
2065 /**
2066 * Pointer to the stream that had a failure. NULL if the stream isn't
2067 * applicable to the error.
2068 */
2069 camera3_stream_t *error_stream;
2070
2071 /**
2072 * The code for this error; one of the CAMERA_MSG_ERROR enum values.
2073 */
2074 int error_code;
2075
2076} camera3_error_msg_t;
2077
2078/**
2079 * camera3_shutter_msg_t:
2080 *
2081 * Message contents for CAMERA3_MSG_SHUTTER
2082 */
2083typedef struct camera3_shutter_msg {
2084 /**
Chien-Yu Chen73b49eb2015-05-28 17:13:05 -07002085 * Frame number of the request that has begun exposure or reprocessing.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002086 */
2087 uint32_t frame_number;
2088
2089 /**
Chien-Yu Chen73b49eb2015-05-28 17:13:05 -07002090 * Timestamp for the start of capture. For a reprocess request, this must
2091 * be input image's start of capture. This must match the capture result
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002092 * metadata's sensor exposure start timestamp.
2093 */
2094 uint64_t timestamp;
2095
2096} camera3_shutter_msg_t;
2097
2098/**
2099 * camera3_notify_msg_t:
2100 *
2101 * The message structure sent to camera3_callback_ops_t.notify()
2102 */
2103typedef struct camera3_notify_msg {
2104
2105 /**
2106 * The message type. One of camera3_notify_msg_type, or a private extension.
2107 */
2108 int type;
2109
2110 union {
2111 /**
2112 * Error message contents. Valid if type is CAMERA3_MSG_ERROR
2113 */
2114 camera3_error_msg_t error;
2115
2116 /**
2117 * Shutter message contents. Valid if type is CAMERA3_MSG_SHUTTER
2118 */
2119 camera3_shutter_msg_t shutter;
2120
2121 /**
2122 * Generic message contents. Used to ensure a minimum size for custom
2123 * message types.
2124 */
2125 uint8_t generic[32];
2126 } message;
2127
2128} camera3_notify_msg_t;
2129
2130/**********************************************************************
2131 *
2132 * Capture request/result definitions for the HAL process_capture_request()
2133 * method, and the process_capture_result() callback.
2134 *
2135 */
2136
2137/**
2138 * camera3_request_template_t:
2139 *
2140 * Available template types for
2141 * camera3_device_ops.construct_default_request_settings()
2142 */
2143typedef enum camera3_request_template {
2144 /**
2145 * Standard camera preview operation with 3A on auto.
2146 */
2147 CAMERA3_TEMPLATE_PREVIEW = 1,
2148
2149 /**
2150 * Standard camera high-quality still capture with 3A and flash on auto.
2151 */
2152 CAMERA3_TEMPLATE_STILL_CAPTURE = 2,
2153
2154 /**
2155 * Standard video recording plus preview with 3A on auto, torch off.
2156 */
2157 CAMERA3_TEMPLATE_VIDEO_RECORD = 3,
2158
2159 /**
2160 * High-quality still capture while recording video. Application will
2161 * include preview, video record, and full-resolution YUV or JPEG streams in
2162 * request. Must not cause stuttering on video stream. 3A on auto.
2163 */
2164 CAMERA3_TEMPLATE_VIDEO_SNAPSHOT = 4,
2165
2166 /**
2167 * Zero-shutter-lag mode. Application will request preview and
2168 * full-resolution data for each frame, and reprocess it to JPEG when a
2169 * still image is requested by user. Settings should provide highest-quality
2170 * full-resolution images without compromising preview frame rate. 3A on
2171 * auto.
2172 */
2173 CAMERA3_TEMPLATE_ZERO_SHUTTER_LAG = 5,
2174
Zhijun Heb0c939f2013-12-13 15:56:33 -08002175 /**
2176 * A basic template for direct application control of capture
2177 * parameters. All automatic control is disabled (auto-exposure, auto-white
2178 * balance, auto-focus), and post-processing parameters are set to preview
2179 * quality. The manual capture parameters (exposure, sensitivity, etc.)
2180 * are set to reasonable defaults, but should be overridden by the
2181 * application depending on the intended use case.
2182 */
2183 CAMERA3_TEMPLATE_MANUAL = 6,
2184
Eino-Ville Talvalacc1aa872018-01-22 13:30:52 -08002185 // Added in 3.5
2186 CAMERA3_TEMPLATE_MOTION_TRACKING_PREVIEW = 7,
2187 CAMERA3_TEMPLATE_MOTION_TRACKING_BEST = 8,
2188
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002189 /* Total number of templates */
2190 CAMERA3_TEMPLATE_COUNT,
2191
2192 /**
2193 * First value for vendor-defined request templates
2194 */
2195 CAMERA3_VENDOR_TEMPLATE_START = 0x40000000
2196
2197} camera3_request_template_t;
2198
2199/**
2200 * camera3_capture_request_t:
2201 *
2202 * A single request for image capture/buffer reprocessing, sent to the Camera
2203 * HAL device by the framework in process_capture_request().
2204 *
2205 * The request contains the settings to be used for this capture, and the set of
2206 * output buffers to write the resulting image data in. It may optionally
2207 * contain an input buffer, in which case the request is for reprocessing that
2208 * input buffer instead of capturing a new image with the camera sensor. The
2209 * capture is identified by the frame_number.
2210 *
2211 * In response, the camera HAL device must send a camera3_capture_result
2212 * structure asynchronously to the framework, using the process_capture_result()
2213 * callback.
2214 */
2215typedef struct camera3_capture_request {
2216 /**
2217 * The frame number is an incrementing integer set by the framework to
2218 * uniquely identify this capture. It needs to be returned in the result
2219 * call, and is also used to identify the request in asynchronous
2220 * notifications sent to camera3_callback_ops_t.notify().
2221 */
2222 uint32_t frame_number;
2223
2224 /**
2225 * The settings buffer contains the capture and processing parameters for
2226 * the request. As a special case, a NULL settings buffer indicates that the
2227 * settings are identical to the most-recently submitted capture request. A
2228 * NULL buffer cannot be used as the first submitted request after a
2229 * configure_streams() call.
2230 */
2231 const camera_metadata_t *settings;
2232
2233 /**
2234 * The input stream buffer to use for this request, if any.
2235 *
2236 * If input_buffer is NULL, then the request is for a new capture from the
2237 * imager. If input_buffer is valid, the request is for reprocessing the
2238 * image contained in input_buffer.
2239 *
2240 * In the latter case, the HAL must set the release_fence of the
2241 * input_buffer to a valid sync fence, or to -1 if the HAL does not support
2242 * sync, before process_capture_request() returns.
2243 *
2244 * The HAL is required to wait on the acquire sync fence of the input buffer
2245 * before accessing it.
2246 *
Igor Murashkin78aa1262014-01-09 16:23:43 -08002247 * <= CAMERA_DEVICE_API_VERSION_3_1:
2248 *
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002249 * Any input buffer included here will have been registered with the HAL
2250 * through register_stream_buffers() before its inclusion in a request.
Igor Murashkin78aa1262014-01-09 16:23:43 -08002251 *
2252 * >= CAMERA_DEVICE_API_VERSION_3_2:
2253 *
2254 * The buffers will not have been pre-registered with the HAL.
2255 * Subsequent requests may reuse buffers, or provide entirely new buffers.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002256 */
2257 camera3_stream_buffer_t *input_buffer;
2258
2259 /**
2260 * The number of output buffers for this capture request. Must be at least
2261 * 1.
2262 */
2263 uint32_t num_output_buffers;
2264
2265 /**
2266 * An array of num_output_buffers stream buffers, to be filled with image
2267 * data from this capture/reprocess. The HAL must wait on the acquire fences
Igor Murashkin78aa1262014-01-09 16:23:43 -08002268 * of each stream buffer before writing to them.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002269 *
2270 * The HAL takes ownership of the actual buffer_handle_t entries in
2271 * output_buffers; the framework does not access them until they are
2272 * returned in a camera3_capture_result_t.
Igor Murashkin78aa1262014-01-09 16:23:43 -08002273 *
2274 * <= CAMERA_DEVICE_API_VERSION_3_1:
2275 *
2276 * All the buffers included here will have been registered with the HAL
2277 * through register_stream_buffers() before their inclusion in a request.
2278 *
2279 * >= CAMERA_DEVICE_API_VERSION_3_2:
2280 *
2281 * Any or all of the buffers included here may be brand new in this
2282 * request (having never before seen by the HAL).
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002283 */
2284 const camera3_stream_buffer_t *output_buffers;
2285
Emilian Peev92261ff2018-01-16 15:01:22 +00002286 /**
2287 * <= CAMERA_DEVICE_API_VERISON_3_4:
2288 *
2289 * Not defined and must not be accessed.
2290 *
2291 * >= CAMERA_DEVICE_API_VERSION_3_5:
2292 * The number of physical camera settings to be applied. If 'num_physcam_settings'
2293 * equals 0 or a physical device is not included, then Hal must decide the
2294 * specific physical device settings based on the default 'settings'.
2295 */
2296 uint32_t num_physcam_settings;
2297
2298 /**
2299 * <= CAMERA_DEVICE_API_VERISON_3_4:
2300 *
2301 * Not defined and must not be accessed.
2302 *
2303 * >= CAMERA_DEVICE_API_VERSION_3_5:
2304 * The physical camera ids. The array will contain 'num_physcam_settings'
2305 * camera id strings for all physical devices that have specific settings.
2306 * In case some id is invalid, the process capture request must fail and return
2307 * -EINVAL.
2308 */
2309 const char **physcam_id;
2310
2311 /**
2312 * <= CAMERA_DEVICE_API_VERISON_3_4:
2313 *
2314 * Not defined and must not be accessed.
2315 *
2316 * >= CAMERA_DEVICE_API_VERSION_3_5:
2317 * The capture settings for the physical cameras. The array will contain
2318 * 'num_physcam_settings' settings for invididual physical devices. In
2319 * case the settings at some particular index are empty, the process capture
2320 * request must fail and return -EINVAL.
2321 */
2322 const camera_metadata_t **physcam_settings;
2323
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002324} camera3_capture_request_t;
2325
2326/**
2327 * camera3_capture_result_t:
2328 *
2329 * The result of a single capture/reprocess by the camera HAL device. This is
2330 * sent to the framework asynchronously with process_capture_result(), in
2331 * response to a single capture request sent to the HAL with
Eino-Ville Talvala7c9416b2013-04-03 15:18:20 -07002332 * process_capture_request(). Multiple process_capture_result() calls may be
Igor Murashkin5df2f622014-01-10 14:18:45 -08002333 * performed by the HAL for each request.
2334 *
2335 * Each call, all with the same frame
Eino-Ville Talvala7c9416b2013-04-03 15:18:20 -07002336 * number, may contain some subset of the output buffers, and/or the result
2337 * metadata. The metadata may only be provided once for a given frame number;
2338 * all other calls must set the result metadata to NULL.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002339 *
2340 * The result structure contains the output metadata from this capture, and the
2341 * set of output buffers that have been/will be filled for this capture. Each
2342 * output buffer may come with a release sync fence that the framework will wait
2343 * on before reading, in case the buffer has not yet been filled by the HAL.
2344 *
Igor Murashkin5df2f622014-01-10 14:18:45 -08002345 * >= CAMERA_DEVICE_API_VERSION_3_2:
2346 *
2347 * The metadata may be provided multiple times for a single frame number. The
2348 * framework will accumulate together the final result set by combining each
2349 * partial result together into the total result set.
2350 *
Zhijun Heceac9e32014-02-05 20:49:45 -08002351 * If an input buffer is given in a request, the HAL must return it in one of
2352 * the process_capture_result calls, and the call may be to just return the input
2353 * buffer, without metadata and output buffers; the sync fences must be handled
2354 * the same way they are done for output buffers.
2355 *
2356 *
Igor Murashkin5df2f622014-01-10 14:18:45 -08002357 * Performance considerations:
2358 *
2359 * Applications will also receive these partial results immediately, so sending
2360 * partial results is a highly recommended performance optimization to avoid
2361 * the total pipeline latency before sending the results for what is known very
2362 * early on in the pipeline.
2363 *
2364 * A typical use case might be calculating the AF state halfway through the
2365 * pipeline; by sending the state back to the framework immediately, we get a
2366 * 50% performance increase and perceived responsiveness of the auto-focus.
2367 *
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002368 */
2369typedef struct camera3_capture_result {
2370 /**
2371 * The frame number is an incrementing integer set by the framework in the
2372 * submitted request to uniquely identify this capture. It is also used to
2373 * identify the request in asynchronous notifications sent to
2374 * camera3_callback_ops_t.notify().
2375 */
2376 uint32_t frame_number;
2377
2378 /**
2379 * The result metadata for this capture. This contains information about the
2380 * final capture parameters, the state of the capture and post-processing
2381 * hardware, the state of the 3A algorithms, if enabled, and the output of
2382 * any enabled statistics units.
Eino-Ville Talvala7c9416b2013-04-03 15:18:20 -07002383 *
2384 * Only one call to process_capture_result() with a given frame_number may
2385 * include the result metadata. All other calls for the same frame_number
2386 * must set this to NULL.
2387 *
2388 * If there was an error producing the result metadata, result must be an
2389 * empty metadata buffer, and notify() must be called with ERROR_RESULT.
Igor Murashkin5df2f622014-01-10 14:18:45 -08002390 *
2391 * >= CAMERA_DEVICE_API_VERSION_3_2:
2392 *
2393 * Multiple calls to process_capture_result() with a given frame_number
2394 * may include the result metadata.
2395 *
2396 * Partial metadata submitted should not include any metadata key returned
2397 * in a previous partial result for a given frame. Each new partial result
2398 * for that frame must also set a distinct partial_result value.
2399 *
2400 * If notify has been called with ERROR_RESULT, all further partial
2401 * results for that frame are ignored by the framework.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002402 */
2403 const camera_metadata_t *result;
2404
2405 /**
Eino-Ville Talvala7c9416b2013-04-03 15:18:20 -07002406 * The number of output buffers returned in this result structure. Must be
2407 * less than or equal to the matching capture request's count. If this is
2408 * less than the buffer count in the capture request, at least one more call
2409 * to process_capture_result with the same frame_number must be made, to
2410 * return the remaining output buffers to the framework. This may only be
Zhijun He52a18892014-06-30 10:35:58 -07002411 * zero if the structure includes valid result metadata or an input buffer
2412 * is returned in this result.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002413 */
2414 uint32_t num_output_buffers;
2415
2416 /**
2417 * The handles for the output stream buffers for this capture. They may not
2418 * yet be filled at the time the HAL calls process_capture_result(); the
2419 * framework will wait on the release sync fences provided by the HAL before
2420 * reading the buffers.
2421 *
2422 * The HAL must set the stream buffer's release sync fence to a valid sync
2423 * fd, or to -1 if the buffer has already been filled.
Eino-Ville Talvala2f8cf5c2013-03-06 13:23:31 -08002424 *
2425 * If the HAL encounters an error while processing the buffer, and the
2426 * buffer is not filled, the buffer's status field must be set to
2427 * CAMERA3_BUFFER_STATUS_ERROR. If the HAL did not wait on the acquire fence
2428 * before encountering the error, the acquire fence should be copied into
2429 * the release fence, to allow the framework to wait on the fence before
2430 * reusing the buffer.
2431 *
Eino-Ville Talvala7c9416b2013-04-03 15:18:20 -07002432 * The acquire fence must be set to -1 for all output buffers. If
2433 * num_output_buffers is zero, this may be NULL. In that case, at least one
2434 * more process_capture_result call must be made by the HAL to provide the
2435 * output buffers.
Igor Murashkin5df2f622014-01-10 14:18:45 -08002436 *
2437 * When process_capture_result is called with a new buffer for a frame,
2438 * all previous frames' buffers for that corresponding stream must have been
2439 * already delivered (the fences need not have yet been signaled).
2440 *
2441 * >= CAMERA_DEVICE_API_VERSION_3_2:
2442 *
2443 * Gralloc buffers for a frame may be sent to framework before the
2444 * corresponding SHUTTER-notify.
2445 *
2446 * Performance considerations:
2447 *
2448 * Buffers delivered to the framework will not be dispatched to the
2449 * application layer until a start of exposure timestamp has been received
2450 * via a SHUTTER notify() call. It is highly recommended to
2451 * dispatch that call as early as possible.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002452 */
2453 const camera3_stream_buffer_t *output_buffers;
2454
Igor Murashkin5df2f622014-01-10 14:18:45 -08002455 /**
2456 * >= CAMERA_DEVICE_API_VERSION_3_2:
2457 *
Zhijun Heceac9e32014-02-05 20:49:45 -08002458 * The handle for the input stream buffer for this capture. It may not
2459 * yet be consumed at the time the HAL calls process_capture_result(); the
2460 * framework will wait on the release sync fences provided by the HAL before
2461 * reusing the buffer.
2462 *
2463 * The HAL should handle the sync fences the same way they are done for
2464 * output_buffers.
2465 *
2466 * Only one input buffer is allowed to be sent per request. Similarly to
2467 * output buffers, the ordering of returned input buffers must be
2468 * maintained by the HAL.
2469 *
2470 * Performance considerations:
2471 *
2472 * The input buffer should be returned as early as possible. If the HAL
2473 * supports sync fences, it can call process_capture_result to hand it back
2474 * with sync fences being set appropriately. If the sync fences are not
2475 * supported, the buffer can only be returned when it is consumed, which
2476 * may take long time; the HAL may choose to copy this input buffer to make
2477 * the buffer return sooner.
2478 */
2479 const camera3_stream_buffer_t *input_buffer;
2480
2481 /**
2482 * >= CAMERA_DEVICE_API_VERSION_3_2:
2483 *
Igor Murashkin5df2f622014-01-10 14:18:45 -08002484 * In order to take advantage of partial results, the HAL must set the
2485 * static metadata android.request.partialResultCount to the number of
2486 * partial results it will send for each frame.
2487 *
2488 * Each new capture result with a partial result must set
2489 * this field (partial_result) to a distinct inclusive value between
2490 * 1 and android.request.partialResultCount.
2491 *
2492 * HALs not wishing to take advantage of this feature must not
2493 * set an android.request.partialResultCount or partial_result to a value
2494 * other than 1.
2495 *
2496 * This value must be set to 0 when a capture result contains buffers only
2497 * and no metadata.
2498 */
2499 uint32_t partial_result;
2500
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002501} camera3_capture_result_t;
2502
2503/**********************************************************************
2504 *
2505 * Callback methods for the HAL to call into the framework.
2506 *
2507 * These methods are used to return metadata and image buffers for a completed
2508 * or failed captures, and to notify the framework of asynchronous events such
2509 * as errors.
2510 *
2511 * The framework will not call back into the HAL from within these callbacks,
2512 * and these calls will not block for extended periods.
2513 *
2514 */
2515typedef struct camera3_callback_ops {
2516
2517 /**
2518 * process_capture_result:
2519 *
Eino-Ville Talvala7c9416b2013-04-03 15:18:20 -07002520 * Send results from a completed capture to the framework.
2521 * process_capture_result() may be invoked multiple times by the HAL in
2522 * response to a single capture request. This allows, for example, the
2523 * metadata and low-resolution buffers to be returned in one call, and
2524 * post-processed JPEG buffers in a later call, once it is available. Each
2525 * call must include the frame number of the request it is returning
2526 * metadata or buffers for.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002527 *
Eino-Ville Talvala7c9416b2013-04-03 15:18:20 -07002528 * A component (buffer or metadata) of the complete result may only be
2529 * included in one process_capture_result call. A buffer for each stream,
2530 * and the result metadata, must be returned by the HAL for each request in
2531 * one of the process_capture_result calls, even in case of errors producing
2532 * some of the output. A call to process_capture_result() with neither
2533 * output buffers or result metadata is not allowed.
2534 *
2535 * The order of returning metadata and buffers for a single result does not
2536 * matter, but buffers for a given stream must be returned in FIFO order. So
2537 * the buffer for request 5 for stream A must always be returned before the
2538 * buffer for request 6 for stream A. This also applies to the result
2539 * metadata; the metadata for request 5 must be returned before the metadata
2540 * for request 6.
2541 *
2542 * However, different streams are independent of each other, so it is
2543 * acceptable and expected that the buffer for request 5 for stream A may be
2544 * returned after the buffer for request 6 for stream B is. And it is
2545 * acceptable that the result metadata for request 6 for stream B is
2546 * returned before the buffer for request 5 for stream A is.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002547 *
2548 * The HAL retains ownership of result structure, which only needs to be
2549 * valid to access during this call. The framework will copy whatever it
2550 * needs before this call returns.
2551 *
2552 * The output buffers do not need to be filled yet; the framework will wait
2553 * on the stream buffer release sync fence before reading the buffer
Eino-Ville Talvala7c9416b2013-04-03 15:18:20 -07002554 * data. Therefore, this method should be called by the HAL as soon as
2555 * possible, even if some or all of the output buffers are still in
2556 * being filled. The HAL must include valid release sync fences into each
2557 * output_buffers stream buffer entry, or -1 if that stream buffer is
2558 * already filled.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002559 *
2560 * If the result buffer cannot be constructed for a request, the HAL should
Eino-Ville Talvala7c9416b2013-04-03 15:18:20 -07002561 * return an empty metadata buffer, but still provide the output buffers and
2562 * their sync fences. In addition, notify() must be called with an
2563 * ERROR_RESULT message.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002564 *
Eino-Ville Talvala2f8cf5c2013-03-06 13:23:31 -08002565 * If an output buffer cannot be filled, its status field must be set to
2566 * STATUS_ERROR. In addition, notify() must be called with a ERROR_BUFFER
2567 * message.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002568 *
2569 * If the entire capture has failed, then this method still needs to be
Eino-Ville Talvala2f8cf5c2013-03-06 13:23:31 -08002570 * called to return the output buffers to the framework. All the buffer
Eino-Ville Talvala7c9416b2013-04-03 15:18:20 -07002571 * statuses should be STATUS_ERROR, and the result metadata should be an
2572 * empty buffer. In addition, notify() must be called with a ERROR_REQUEST
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002573 * message. In this case, individual ERROR_RESULT/ERROR_BUFFER messages
2574 * should not be sent.
2575 *
Zhijun He2dde4682014-01-09 09:11:49 -08002576 * Performance requirements:
2577 *
2578 * This is a non-blocking call. The framework will return this call in 5ms.
2579 *
2580 * The pipeline latency (see S7 for definition) should be less than or equal to
2581 * 4 frame intervals, and must be less than or equal to 8 frame intervals.
2582 *
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002583 */
2584 void (*process_capture_result)(const struct camera3_callback_ops *,
2585 const camera3_capture_result_t *result);
2586
2587 /**
2588 * notify:
2589 *
2590 * Asynchronous notification callback from the HAL, fired for various
2591 * reasons. Only for information independent of frame capture, or that
2592 * require specific timing. The ownership of the message structure remains
2593 * with the HAL, and the msg only needs to be valid for the duration of this
2594 * call.
2595 *
Igor Murashkin5df2f622014-01-10 14:18:45 -08002596 * Multiple threads may call notify() simultaneously.
2597 *
2598 * <= CAMERA_DEVICE_API_VERSION_3_1:
2599 *
Eino-Ville Talvala71af1022013-04-22 14:19:21 -07002600 * The notification for the start of exposure for a given request must be
2601 * sent by the HAL before the first call to process_capture_result() for
2602 * that request is made.
2603 *
Igor Murashkin5df2f622014-01-10 14:18:45 -08002604 * >= CAMERA_DEVICE_API_VERSION_3_2:
Zhijun He2dde4682014-01-09 09:11:49 -08002605 *
Igor Murashkin5df2f622014-01-10 14:18:45 -08002606 * Buffers delivered to the framework will not be dispatched to the
Chien-Yu Chen73b49eb2015-05-28 17:13:05 -07002607 * application layer until a start of exposure timestamp (or input image's
2608 * start of exposure timestamp for a reprocess request) has been received
2609 * via a SHUTTER notify() call. It is highly recommended to dispatch this
2610 * call as early as possible.
Igor Murashkin5df2f622014-01-10 14:18:45 -08002611 *
2612 * ------------------------------------------------------------------------
Zhijun He2dde4682014-01-09 09:11:49 -08002613 * Performance requirements:
2614 *
2615 * This is a non-blocking call. The framework will return this call in 5ms.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002616 */
2617 void (*notify)(const struct camera3_callback_ops *,
2618 const camera3_notify_msg_t *msg);
2619
2620} camera3_callback_ops_t;
2621
2622/**********************************************************************
2623 *
2624 * Camera device operations
2625 *
2626 */
2627typedef struct camera3_device_ops {
2628
2629 /**
2630 * initialize:
2631 *
2632 * One-time initialization to pass framework callback function pointers to
2633 * the HAL. Will be called once after a successful open() call, before any
2634 * other functions are called on the camera3_device_ops structure.
2635 *
Zhijun He2dde4682014-01-09 09:11:49 -08002636 * Performance requirements:
2637 *
2638 * This should be a non-blocking call. The HAL should return from this call
2639 * in 5ms, and must return from this call in 10ms.
2640 *
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002641 * Return values:
2642 *
2643 * 0: On successful initialization
2644 *
2645 * -ENODEV: If initialization fails. Only close() can be called successfully
2646 * by the framework after this.
2647 */
2648 int (*initialize)(const struct camera3_device *,
2649 const camera3_callback_ops_t *callback_ops);
2650
2651 /**********************************************************************
2652 * Stream management
2653 */
2654
2655 /**
2656 * configure_streams:
2657 *
Igor Murashkin78aa1262014-01-09 16:23:43 -08002658 * CAMERA_DEVICE_API_VERSION_3_0 only:
2659 *
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002660 * Reset the HAL camera device processing pipeline and set up new input and
2661 * output streams. This call replaces any existing stream configuration with
2662 * the streams defined in the stream_list. This method will be called at
2663 * least once after initialize() before a request is submitted with
2664 * process_capture_request().
2665 *
2666 * The stream_list must contain at least one output-capable stream, and may
2667 * not contain more than one input-capable stream.
2668 *
2669 * The stream_list may contain streams that are also in the currently-active
2670 * set of streams (from the previous call to configure_stream()). These
2671 * streams will already have valid values for usage, max_buffers, and the
Igor Murashkin78aa1262014-01-09 16:23:43 -08002672 * private pointer.
2673 *
2674 * If such a stream has already had its buffers registered,
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002675 * register_stream_buffers() will not be called again for the stream, and
2676 * buffers from the stream can be immediately included in input requests.
2677 *
2678 * If the HAL needs to change the stream configuration for an existing
2679 * stream due to the new configuration, it may rewrite the values of usage
Igor Murashkin78aa1262014-01-09 16:23:43 -08002680 * and/or max_buffers during the configure call.
2681 *
2682 * The framework will detect such a change, and will then reallocate the
2683 * stream buffers, and call register_stream_buffers() again before using
2684 * buffers from that stream in a request.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002685 *
2686 * If a currently-active stream is not included in stream_list, the HAL may
2687 * safely remove any references to that stream. It will not be reused in a
2688 * later configure() call by the framework, and all the gralloc buffers for
2689 * it will be freed after the configure_streams() call returns.
2690 *
2691 * The stream_list structure is owned by the framework, and may not be
2692 * accessed once this call completes. The address of an individual
2693 * camera3_stream_t structure will remain valid for access by the HAL until
2694 * the end of the first configure_stream() call which no longer includes
2695 * that camera3_stream_t in the stream_list argument. The HAL may not change
2696 * values in the stream structure outside of the private pointer, except for
2697 * the usage and max_buffers members during the configure_streams() call
2698 * itself.
2699 *
2700 * If the stream is new, the usage, max_buffer, and private pointer fields
2701 * of the stream structure will all be set to 0. The HAL device must set
2702 * these fields before the configure_streams() call returns. These fields
2703 * are then used by the framework and the platform gralloc module to
2704 * allocate the gralloc buffers for each stream.
2705 *
2706 * Before such a new stream can have its buffers included in a capture
2707 * request, the framework will call register_stream_buffers() with that
2708 * stream. However, the framework is not required to register buffers for
2709 * _all_ streams before submitting a request. This allows for quick startup
2710 * of (for example) a preview stream, with allocation for other streams
2711 * happening later or concurrently.
2712 *
Igor Murashkin78aa1262014-01-09 16:23:43 -08002713 * ------------------------------------------------------------------------
2714 * CAMERA_DEVICE_API_VERSION_3_1 only:
2715 *
2716 * Reset the HAL camera device processing pipeline and set up new input and
2717 * output streams. This call replaces any existing stream configuration with
2718 * the streams defined in the stream_list. This method will be called at
2719 * least once after initialize() before a request is submitted with
2720 * process_capture_request().
2721 *
2722 * The stream_list must contain at least one output-capable stream, and may
2723 * not contain more than one input-capable stream.
2724 *
2725 * The stream_list may contain streams that are also in the currently-active
2726 * set of streams (from the previous call to configure_stream()). These
2727 * streams will already have valid values for usage, max_buffers, and the
2728 * private pointer.
2729 *
2730 * If such a stream has already had its buffers registered,
2731 * register_stream_buffers() will not be called again for the stream, and
2732 * buffers from the stream can be immediately included in input requests.
2733 *
2734 * If the HAL needs to change the stream configuration for an existing
2735 * stream due to the new configuration, it may rewrite the values of usage
2736 * and/or max_buffers during the configure call.
2737 *
2738 * The framework will detect such a change, and will then reallocate the
2739 * stream buffers, and call register_stream_buffers() again before using
2740 * buffers from that stream in a request.
2741 *
2742 * If a currently-active stream is not included in stream_list, the HAL may
2743 * safely remove any references to that stream. It will not be reused in a
2744 * later configure() call by the framework, and all the gralloc buffers for
2745 * it will be freed after the configure_streams() call returns.
2746 *
2747 * The stream_list structure is owned by the framework, and may not be
2748 * accessed once this call completes. The address of an individual
2749 * camera3_stream_t structure will remain valid for access by the HAL until
2750 * the end of the first configure_stream() call which no longer includes
2751 * that camera3_stream_t in the stream_list argument. The HAL may not change
2752 * values in the stream structure outside of the private pointer, except for
2753 * the usage and max_buffers members during the configure_streams() call
2754 * itself.
2755 *
2756 * If the stream is new, max_buffer, and private pointer fields of the
2757 * stream structure will all be set to 0. The usage will be set to the
2758 * consumer usage flags. The HAL device must set these fields before the
2759 * configure_streams() call returns. These fields are then used by the
2760 * framework and the platform gralloc module to allocate the gralloc
2761 * buffers for each stream.
2762 *
2763 * Before such a new stream can have its buffers included in a capture
2764 * request, the framework will call register_stream_buffers() with that
2765 * stream. However, the framework is not required to register buffers for
2766 * _all_ streams before submitting a request. This allows for quick startup
2767 * of (for example) a preview stream, with allocation for other streams
2768 * happening later or concurrently.
2769 *
2770 * ------------------------------------------------------------------------
2771 * >= CAMERA_DEVICE_API_VERSION_3_2:
2772 *
2773 * Reset the HAL camera device processing pipeline and set up new input and
2774 * output streams. This call replaces any existing stream configuration with
2775 * the streams defined in the stream_list. This method will be called at
2776 * least once after initialize() before a request is submitted with
2777 * process_capture_request().
2778 *
2779 * The stream_list must contain at least one output-capable stream, and may
2780 * not contain more than one input-capable stream.
2781 *
2782 * The stream_list may contain streams that are also in the currently-active
2783 * set of streams (from the previous call to configure_stream()). These
2784 * streams will already have valid values for usage, max_buffers, and the
2785 * private pointer.
2786 *
2787 * If the HAL needs to change the stream configuration for an existing
2788 * stream due to the new configuration, it may rewrite the values of usage
2789 * and/or max_buffers during the configure call.
2790 *
2791 * The framework will detect such a change, and may then reallocate the
2792 * stream buffers before using buffers from that stream in a request.
2793 *
2794 * If a currently-active stream is not included in stream_list, the HAL may
2795 * safely remove any references to that stream. It will not be reused in a
2796 * later configure() call by the framework, and all the gralloc buffers for
2797 * it will be freed after the configure_streams() call returns.
2798 *
2799 * The stream_list structure is owned by the framework, and may not be
2800 * accessed once this call completes. The address of an individual
2801 * camera3_stream_t structure will remain valid for access by the HAL until
2802 * the end of the first configure_stream() call which no longer includes
2803 * that camera3_stream_t in the stream_list argument. The HAL may not change
2804 * values in the stream structure outside of the private pointer, except for
2805 * the usage and max_buffers members during the configure_streams() call
2806 * itself.
2807 *
2808 * If the stream is new, max_buffer, and private pointer fields of the
2809 * stream structure will all be set to 0. The usage will be set to the
2810 * consumer usage flags. The HAL device must set these fields before the
2811 * configure_streams() call returns. These fields are then used by the
2812 * framework and the platform gralloc module to allocate the gralloc
2813 * buffers for each stream.
2814 *
2815 * Newly allocated buffers may be included in a capture request at any time
2816 * by the framework. Once a gralloc buffer is returned to the framework
2817 * with process_capture_result (and its respective release_fence has been
2818 * signaled) the framework may free or reuse it at any time.
2819 *
2820 * ------------------------------------------------------------------------
2821 *
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002822 * Preconditions:
2823 *
2824 * The framework will only call this method when no captures are being
2825 * processed. That is, all results have been returned to the framework, and
2826 * all in-flight input and output buffers have been returned and their
2827 * release sync fences have been signaled by the HAL. The framework will not
2828 * submit new requests for capture while the configure_streams() call is
2829 * underway.
2830 *
2831 * Postconditions:
2832 *
2833 * The HAL device must configure itself to provide maximum possible output
2834 * frame rate given the sizes and formats of the output streams, as
2835 * documented in the camera device's static metadata.
2836 *
Zhijun He2dde4682014-01-09 09:11:49 -08002837 * Performance requirements:
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002838 *
2839 * This call is expected to be heavyweight and possibly take several hundred
2840 * milliseconds to complete, since it may require resetting and
2841 * reconfiguring the image sensor and the camera processing pipeline.
2842 * Nevertheless, the HAL device should attempt to minimize the
2843 * reconfiguration delay to minimize the user-visible pauses during
2844 * application operational mode changes (such as switching from still
2845 * capture to video recording).
2846 *
Zhijun He2dde4682014-01-09 09:11:49 -08002847 * The HAL should return from this call in 500ms, and must return from this
2848 * call in 1000ms.
2849 *
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002850 * Return values:
2851 *
2852 * 0: On successful stream configuration
2853 *
2854 * -EINVAL: If the requested stream configuration is invalid. Some examples
2855 * of invalid stream configurations include:
2856 *
2857 * - Including more than 1 input-capable stream (INPUT or
2858 * BIDIRECTIONAL)
2859 *
2860 * - Not including any output-capable streams (OUTPUT or
2861 * BIDIRECTIONAL)
2862 *
2863 * - Including streams with unsupported formats, or an unsupported
2864 * size for that format.
2865 *
2866 * - Including too many output streams of a certain format.
2867 *
Yin-Chia Yehe0042082015-03-09 12:15:36 -07002868 * - Unsupported rotation configuration (only applies to
2869 * devices with version >= CAMERA_DEVICE_API_VERSION_3_3)
2870 *
Zhijun He21126b72015-05-22 18:12:28 -07002871 * - Stream sizes/formats don't satisfy the
2872 * camera3_stream_configuration_t->operation_mode requirements for non-NORMAL mode,
2873 * or the requested operation_mode is not supported by the HAL.
2874 * (only applies to devices with version >= CAMERA_DEVICE_API_VERSION_3_3)
2875 *
Eino-Ville Talvala7effe0c2013-02-15 12:09:48 -08002876 * Note that the framework submitting an invalid stream
2877 * configuration is not normal operation, since stream
2878 * configurations are checked before configure. An invalid
2879 * configuration means that a bug exists in the framework code, or
2880 * there is a mismatch between the HAL's static metadata and the
2881 * requirements on streams.
2882 *
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002883 * -ENODEV: If there has been a fatal error and the device is no longer
2884 * operational. Only close() can be called successfully by the
2885 * framework after this error is returned.
2886 */
2887 int (*configure_streams)(const struct camera3_device *,
2888 camera3_stream_configuration_t *stream_list);
2889
2890 /**
2891 * register_stream_buffers:
2892 *
Igor Murashkin78aa1262014-01-09 16:23:43 -08002893 * >= CAMERA_DEVICE_API_VERSION_3_2:
2894 *
2895 * DEPRECATED. This will not be called and must be set to NULL.
2896 *
2897 * <= CAMERA_DEVICE_API_VERSION_3_1:
2898 *
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002899 * Register buffers for a given stream with the HAL device. This method is
2900 * called by the framework after a new stream is defined by
2901 * configure_streams, and before buffers from that stream are included in a
2902 * capture request. If the same stream is listed in a subsequent
2903 * configure_streams() call, register_stream_buffers will _not_ be called
2904 * again for that stream.
2905 *
2906 * The framework does not need to register buffers for all configured
2907 * streams before it submits the first capture request. This allows quick
2908 * startup for preview (or similar use cases) while other streams are still
2909 * being allocated.
2910 *
2911 * This method is intended to allow the HAL device to map or otherwise
2912 * prepare the buffers for later use. The buffers passed in will already be
2913 * locked for use. At the end of the call, all the buffers must be ready to
2914 * be returned to the stream. The buffer_set argument is only valid for the
2915 * duration of this call.
2916 *
2917 * If the stream format was set to HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED,
2918 * the camera HAL should inspect the passed-in buffers here to determine any
2919 * platform-private pixel format information.
2920 *
Zhijun He2dde4682014-01-09 09:11:49 -08002921 * Performance requirements:
2922 *
2923 * This should be a non-blocking call. The HAL should return from this call
2924 * in 1ms, and must return from this call in 5ms.
2925 *
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002926 * Return values:
2927 *
2928 * 0: On successful registration of the new stream buffers
2929 *
2930 * -EINVAL: If the stream_buffer_set does not refer to a valid active
2931 * stream, or if the buffers array is invalid.
2932 *
2933 * -ENOMEM: If there was a failure in registering the buffers. The framework
2934 * must consider all the stream buffers to be unregistered, and can
2935 * try to register again later.
2936 *
2937 * -ENODEV: If there is a fatal error, and the device is no longer
2938 * operational. Only close() can be called successfully by the
2939 * framework after this error is returned.
2940 */
2941 int (*register_stream_buffers)(const struct camera3_device *,
2942 const camera3_stream_buffer_set_t *buffer_set);
2943
2944 /**********************************************************************
2945 * Request creation and submission
2946 */
2947
2948 /**
2949 * construct_default_request_settings:
2950 *
2951 * Create capture settings for standard camera use cases.
2952 *
2953 * The device must return a settings buffer that is configured to meet the
2954 * requested use case, which must be one of the CAMERA3_TEMPLATE_*
2955 * enums. All request control fields must be included.
2956 *
2957 * The HAL retains ownership of this structure, but the pointer to the
2958 * structure must be valid until the device is closed. The framework and the
2959 * HAL may not modify the buffer once it is returned by this call. The same
2960 * buffer may be returned for subsequent calls for the same template, or for
2961 * other templates.
2962 *
Zhijun He2dde4682014-01-09 09:11:49 -08002963 * Performance requirements:
2964 *
2965 * This should be a non-blocking call. The HAL should return from this call
2966 * in 1ms, and must return from this call in 5ms.
2967 *
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002968 * Return values:
2969 *
2970 * Valid metadata: On successful creation of a default settings
2971 * buffer.
2972 *
2973 * NULL: In case of a fatal error. After this is returned, only
Eino-Ville Talvalaacbc4512013-03-16 16:53:28 -07002974 * the close() method can be called successfully by the
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002975 * framework.
2976 */
2977 const camera_metadata_t* (*construct_default_request_settings)(
2978 const struct camera3_device *,
2979 int type);
2980
2981 /**
2982 * process_capture_request:
2983 *
2984 * Send a new capture request to the HAL. The HAL should not return from
2985 * this call until it is ready to accept the next request to process. Only
2986 * one call to process_capture_request() will be made at a time by the
2987 * framework, and the calls will all be from the same thread. The next call
2988 * to process_capture_request() will be made as soon as a new request and
2989 * its associated buffers are available. In a normal preview scenario, this
2990 * means the function will be called again by the framework almost
2991 * instantly.
2992 *
2993 * The actual request processing is asynchronous, with the results of
2994 * capture being returned by the HAL through the process_capture_result()
2995 * call. This call requires the result metadata to be available, but output
2996 * buffers may simply provide sync fences to wait on. Multiple requests are
2997 * expected to be in flight at once, to maintain full output frame rate.
2998 *
2999 * The framework retains ownership of the request structure. It is only
3000 * guaranteed to be valid during this call. The HAL device must make copies
Eino-Ville Talvala71af1022013-04-22 14:19:21 -07003001 * of the information it needs to retain for the capture processing. The HAL
3002 * is responsible for waiting on and closing the buffers' fences and
3003 * returning the buffer handles to the framework.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08003004 *
3005 * The HAL must write the file descriptor for the input buffer's release
3006 * sync fence into input_buffer->release_fence, if input_buffer is not
3007 * NULL. If the HAL returns -1 for the input buffer release sync fence, the
3008 * framework is free to immediately reuse the input buffer. Otherwise, the
3009 * framework will wait on the sync fence before refilling and reusing the
3010 * input buffer.
3011 *
Igor Murashkin78aa1262014-01-09 16:23:43 -08003012 * >= CAMERA_DEVICE_API_VERSION_3_2:
Zhijun He2dde4682014-01-09 09:11:49 -08003013 *
Igor Murashkin78aa1262014-01-09 16:23:43 -08003014 * The input/output buffers provided by the framework in each request
3015 * may be brand new (having never before seen by the HAL).
3016 *
3017 * ------------------------------------------------------------------------
3018 * Performance considerations:
3019 *
3020 * Handling a new buffer should be extremely lightweight and there should be
3021 * no frame rate degradation or frame jitter introduced.
3022 *
3023 * This call must return fast enough to ensure that the requested frame
3024 * rate can be sustained, especially for streaming cases (post-processing
3025 * quality settings set to FAST). The HAL should return this call in 1
3026 * frame interval, and must return from this call in 4 frame intervals.
Zhijun He2dde4682014-01-09 09:11:49 -08003027 *
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08003028 * Return values:
3029 *
3030 * 0: On a successful start to processing the capture request
3031 *
3032 * -EINVAL: If the input is malformed (the settings are NULL when not
Emilian Peev92261ff2018-01-16 15:01:22 +00003033 * allowed, invalid physical camera settings,
3034 * there are 0 output buffers, etc) and capture processing
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08003035 * cannot start. Failures during request processing should be
Eino-Ville Talvala71af1022013-04-22 14:19:21 -07003036 * handled by calling camera3_callback_ops_t.notify(). In case of
3037 * this error, the framework will retain responsibility for the
3038 * stream buffers' fences and the buffer handles; the HAL should
3039 * not close the fences or return these buffers with
3040 * process_capture_result.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08003041 *
3042 * -ENODEV: If the camera device has encountered a serious error. After this
3043 * error is returned, only the close() method can be successfully
3044 * called by the framework.
3045 *
3046 */
3047 int (*process_capture_request)(const struct camera3_device *,
3048 camera3_capture_request_t *request);
3049
3050 /**********************************************************************
3051 * Miscellaneous methods
3052 */
3053
3054 /**
3055 * get_metadata_vendor_tag_ops:
3056 *
Eino-Ville Talvalaacbc4512013-03-16 16:53:28 -07003057 * Get methods to query for vendor extension metadata tag information. The
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08003058 * HAL should fill in all the vendor tag operation methods, or leave ops
3059 * unchanged if no vendor tags are defined.
3060 *
3061 * The definition of vendor_tag_query_ops_t can be found in
3062 * system/media/camera/include/system/camera_metadata.h.
3063 *
Ruben Brunk61cf9eb2014-01-14 15:27:58 -08003064 * >= CAMERA_DEVICE_API_VERSION_3_2:
3065 * DEPRECATED. This function has been deprecated and should be set to
3066 * NULL by the HAL. Please implement get_vendor_tag_ops in camera_common.h
3067 * instead.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08003068 */
3069 void (*get_metadata_vendor_tag_ops)(const struct camera3_device*,
3070 vendor_tag_query_ops_t* ops);
3071
3072 /**
3073 * dump:
3074 *
3075 * Print out debugging state for the camera device. This will be called by
3076 * the framework when the camera service is asked for a debug dump, which
3077 * happens when using the dumpsys tool, or when capturing a bugreport.
3078 *
3079 * The passed-in file descriptor can be used to write debugging text using
3080 * dprintf() or write(). The text should be in ASCII encoding only.
Zhijun He2dde4682014-01-09 09:11:49 -08003081 *
3082 * Performance requirements:
3083 *
3084 * This must be a non-blocking call. The HAL should return from this call
3085 * in 1ms, must return from this call in 10ms. This call must avoid
3086 * deadlocks, as it may be called at any point during camera operation.
3087 * Any synchronization primitives used (such as mutex locks or semaphores)
3088 * should be acquired with a timeout.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08003089 */
3090 void (*dump)(const struct camera3_device *, int fd);
3091
Alex Ray5f2fd852013-06-24 11:28:05 -07003092 /**
3093 * flush:
3094 *
3095 * Flush all currently in-process captures and all buffers in the pipeline
3096 * on the given device. The framework will use this to dump all state as
3097 * quickly as possible in order to prepare for a configure_streams() call.
3098 *
3099 * No buffers are required to be successfully returned, so every buffer
Zhijun He5a5fbf42014-01-27 14:49:44 -08003100 * held at the time of flush() (whether successfully filled or not) may be
Alex Ray5f2fd852013-06-24 11:28:05 -07003101 * returned with CAMERA3_BUFFER_STATUS_ERROR. Note the HAL is still allowed
Zhijun He5a5fbf42014-01-27 14:49:44 -08003102 * to return valid (CAMERA3_BUFFER_STATUS_OK) buffers during this call,
3103 * provided they are successfully filled.
Alex Ray5f2fd852013-06-24 11:28:05 -07003104 *
3105 * All requests currently in the HAL are expected to be returned as soon as
3106 * possible. Not-in-process requests should return errors immediately. Any
3107 * interruptible hardware blocks should be stopped, and any uninterruptible
3108 * blocks should be waited on.
3109 *
Eino-Ville Talvala85fdb3f2015-06-10 14:58:32 -07003110 * flush() may be called concurrently to process_capture_request(), with the expectation that
3111 * process_capture_request will return quickly and the request submitted in that
3112 * process_capture_request call is treated like all other in-flight requests. Due to
3113 * concurrency issues, it is possible that from the HAL's point of view, a
3114 * process_capture_request() call may be started after flush has been invoked but has not
3115 * returned yet. If such a call happens before flush() returns, the HAL should treat the new
3116 * capture request like other in-flight pending requests (see #4 below).
3117 *
Zhijun He5a5fbf42014-01-27 14:49:44 -08003118 * More specifically, the HAL must follow below requirements for various cases:
3119 *
3120 * 1. For captures that are too late for the HAL to cancel/stop, and will be
3121 * completed normally by the HAL; i.e. the HAL can send shutter/notify and
3122 * process_capture_result and buffers as normal.
3123 *
3124 * 2. For pending requests that have not done any processing, the HAL must call notify
3125 * CAMERA3_MSG_ERROR_REQUEST, and return all the output buffers with
3126 * process_capture_result in the error state (CAMERA3_BUFFER_STATUS_ERROR).
3127 * The HAL must not place the release fence into an error state, instead,
3128 * the release fences must be set to the acquire fences passed by the framework,
3129 * or -1 if they have been waited on by the HAL already. This is also the path
3130 * to follow for any captures for which the HAL already called notify() with
3131 * CAMERA3_MSG_SHUTTER but won't be producing any metadata/valid buffers for.
3132 * After CAMERA3_MSG_ERROR_REQUEST, for a given frame, only process_capture_results with
3133 * buffers in CAMERA3_BUFFER_STATUS_ERROR are allowed. No further notifys or
3134 * process_capture_result with non-null metadata is allowed.
3135 *
3136 * 3. For partially completed pending requests that will not have all the output
3137 * buffers or perhaps missing metadata, the HAL should follow below:
3138 *
3139 * 3.1. Call notify with CAMERA3_MSG_ERROR_RESULT if some of the expected result
3140 * metadata (i.e. one or more partial metadata) won't be available for the capture.
3141 *
3142 * 3.2. Call notify with CAMERA3_MSG_ERROR_BUFFER for every buffer that won't
3143 * be produced for the capture.
3144 *
3145 * 3.3 Call notify with CAMERA3_MSG_SHUTTER with the capture timestamp before
3146 * any buffers/metadata are returned with process_capture_result.
3147 *
3148 * 3.4 For captures that will produce some results, the HAL must not call
3149 * CAMERA3_MSG_ERROR_REQUEST, since that indicates complete failure.
3150 *
3151 * 3.5. Valid buffers/metadata should be passed to the framework as normal.
3152 *
3153 * 3.6. Failed buffers should be returned to the framework as described for case 2.
3154 * But failed buffers do not have to follow the strict ordering valid buffers do,
3155 * and may be out-of-order with respect to valid buffers. For example, if buffers
3156 * A, B, C, D, E are sent, D and E are failed, then A, E, B, D, C is an acceptable
3157 * return order.
3158 *
3159 * 3.7. For fully-missing metadata, calling CAMERA3_MSG_ERROR_RESULT is sufficient, no
3160 * need to call process_capture_result with NULL metadata or equivalent.
3161 *
Eino-Ville Talvala85fdb3f2015-06-10 14:58:32 -07003162 * 4. If a flush() is invoked while a process_capture_request() invocation is active, that
3163 * process call should return as soon as possible. In addition, if a process_capture_request()
3164 * call is made after flush() has been invoked but before flush() has returned, the
3165 * capture request provided by the late process_capture_request call should be treated like
3166 * a pending request in case #2 above.
3167 *
Alex Ray5f2fd852013-06-24 11:28:05 -07003168 * flush() should only return when there are no more outstanding buffers or
Zhijun He5a5fbf42014-01-27 14:49:44 -08003169 * requests left in the HAL. The framework may call configure_streams (as
Alex Ray5f2fd852013-06-24 11:28:05 -07003170 * the HAL state is now quiesced) or may issue new requests.
3171 *
Zhijun He5a5fbf42014-01-27 14:49:44 -08003172 * Note that it's sufficient to only support fully-succeeded and fully-failed result cases.
3173 * However, it is highly desirable to support the partial failure cases as well, as it
3174 * could help improve the flush call overall performance.
3175 *
Zhijun He2dde4682014-01-09 09:11:49 -08003176 * Performance requirements:
3177 *
3178 * The HAL should return from this call in 100ms, and must return from this
3179 * call in 1000ms. And this call must not be blocked longer than pipeline
3180 * latency (see S7 for definition).
Alex Ray5f2fd852013-06-24 11:28:05 -07003181 *
3182 * Version information:
3183 *
3184 * only available if device version >= CAMERA_DEVICE_API_VERSION_3_1.
3185 *
3186 * Return values:
3187 *
3188 * 0: On a successful flush of the camera HAL.
3189 *
3190 * -EINVAL: If the input is malformed (the device is not valid).
3191 *
3192 * -ENODEV: If the camera device has encountered a serious error. After this
3193 * error is returned, only the close() method can be successfully
3194 * called by the framework.
3195 */
3196 int (*flush)(const struct camera3_device *);
3197
3198 /* reserved for future use */
3199 void *reserved[8];
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08003200} camera3_device_ops_t;
3201
3202/**********************************************************************
3203 *
3204 * Camera device definition
3205 *
3206 */
3207typedef struct camera3_device {
3208 /**
3209 * common.version must equal CAMERA_DEVICE_API_VERSION_3_0 to identify this
3210 * device as implementing version 3.0 of the camera device HAL.
Zhijun He2dde4682014-01-09 09:11:49 -08003211 *
3212 * Performance requirements:
3213 *
Zhijun He06da1b32014-02-10 16:04:23 -08003214 * Camera open (common.module->common.methods->open) should return in 200ms, and must return
3215 * in 500ms.
Zhijun He2020ee22014-01-31 11:35:45 -08003216 * Camera close (common.close) should return in 200ms, and must return in 500ms.
3217 *
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08003218 */
3219 hw_device_t common;
3220 camera3_device_ops_t *ops;
3221 void *priv;
3222} camera3_device_t;
3223
3224__END_DECLS
3225
3226#endif /* #ifdef ANDROID_INCLUDE_CAMERA3_H */