blob: 75efa28fc24b0ea8115ef8b2a47babc066c523e9 [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/**
Yin-Chia Yeh875df2a2018-09-20 15:05:13 -070024 * Camera device HAL 3.6[ CAMERA_DEVICE_API_VERSION_3_6 ]
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
Yin-Chia Yeh875df2a2018-09-20 15:05:13 -070032 * CAMERA_DEVICE_API_VERSION_3_6 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 *
Yin-Chia Yeh875df2a2018-09-20 15:05:13 -0700186 * 3.6: Minor revisions to support HAL buffer management APIs:
187 *
188 * - Add ANDROID_INFO_SUPPORTED_BUFFER_MANAGEMENT_VERSION static metadata, which allows HAL to
189 * opt in to the new buffer management APIs described below.
190 *
191 * - Add request_stream_buffers() and return_stream_buffers() to camera3_callback_ops_t for HAL to
192 * request and return output buffers from camera service.
193 *
194 * - Add signal_stream_flush() to camera3_device_ops_t for camera service to notify HAL an
195 * upcoming configure_streams() call requires HAL to return buffers of certain streams. Also add
196 * stream_configuration_counter to camera3_stream_configuration_t to address the potential
197 * race condition between signal_stream_flush() call and configure_streams() call.
198 *
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800199 */
200
201/**
Eino-Ville Talvalaacbc4512013-03-16 16:53:28 -0700202 * S2. Startup and general expected operation sequence:
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800203 *
204 * 1. Framework calls camera_module_t->common.open(), which returns a
205 * hardware_device_t structure.
206 *
207 * 2. Framework inspects the hardware_device_t->version field, and instantiates
208 * the appropriate handler for that version of the camera hardware device. In
209 * case the version is CAMERA_DEVICE_API_VERSION_3_0, the device is cast to
210 * a camera3_device_t.
211 *
212 * 3. Framework calls camera3_device_t->ops->initialize() with the framework
213 * callback function pointers. This will only be called this one time after
214 * open(), before any other functions in the ops structure are called.
215 *
216 * 4. The framework calls camera3_device_t->ops->configure_streams() with a list
217 * of input/output streams to the HAL device.
218 *
Igor Murashkin78aa1262014-01-09 16:23:43 -0800219 * 5. <= CAMERA_DEVICE_API_VERSION_3_1:
220 *
221 * The framework allocates gralloc buffers and calls
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800222 * camera3_device_t->ops->register_stream_buffers() for at least one of the
223 * output streams listed in configure_streams. The same stream is registered
224 * only once.
225 *
Igor Murashkin78aa1262014-01-09 16:23:43 -0800226 * >= CAMERA_DEVICE_API_VERSION_3_2:
227 *
228 * camera3_device_t->ops->register_stream_buffers() is not called and must
229 * be NULL.
230 *
231 * 6. The framework requests default settings for some number of use cases with
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800232 * calls to camera3_device_t->ops->construct_default_request_settings(). This
233 * may occur any time after step 3.
234 *
235 * 7. The framework constructs and sends the first capture request to the HAL,
236 * with settings based on one of the sets of default settings, and with at
237 * least one output stream, which has been registered earlier by the
238 * framework. This is sent to the HAL with
239 * camera3_device_t->ops->process_capture_request(). The HAL must block the
240 * return of this call until it is ready for the next request to be sent.
241 *
Igor Murashkin78aa1262014-01-09 16:23:43 -0800242 * >= CAMERA_DEVICE_API_VERSION_3_2:
243 *
244 * The buffer_handle_t provided in the camera3_stream_buffer_t array
245 * in the camera3_capture_request_t may be new and never-before-seen
246 * by the HAL on any given new request.
247 *
248 * 8. The framework continues to submit requests, and call
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800249 * construct_default_request_settings to get default settings buffers for
250 * other use cases.
251 *
Igor Murashkin78aa1262014-01-09 16:23:43 -0800252 * <= CAMERA_DEVICE_API_VERSION_3_1:
253 *
254 * The framework may call register_stream_buffers() at this time for
255 * not-yet-registered streams.
256 *
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800257 * 9. When the capture of a request begins (sensor starts exposing for the
Chien-Yu Chen73b49eb2015-05-28 17:13:05 -0700258 * capture) or processing a reprocess request begins, the HAL
259 * calls camera3_callback_ops_t->notify() with the SHUTTER event, including
260 * the frame number and the timestamp for start of exposure. For a reprocess
261 * request, the timestamp must be the start of exposure of the input image
262 * which can be looked up with android.sensor.timestamp from
263 * camera3_capture_request_t.settings when process_capture_request() is
264 * called.
Igor Murashkin5df2f622014-01-10 14:18:45 -0800265 *
266 * <= CAMERA_DEVICE_API_VERSION_3_1:
267 *
Eino-Ville Talvala71af1022013-04-22 14:19:21 -0700268 * This notify call must be made before the first call to
269 * process_capture_result() for that frame number.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800270 *
Igor Murashkin5df2f622014-01-10 14:18:45 -0800271 * >= CAMERA_DEVICE_API_VERSION_3_2:
272 *
273 * The camera3_callback_ops_t->notify() call with the SHUTTER event should
274 * be made as early as possible since the framework will be unable to
275 * deliver gralloc buffers to the application layer (for that frame) until
Chien-Yu Chen73b49eb2015-05-28 17:13:05 -0700276 * it has a valid timestamp for the start of exposure (or the input image's
277 * start of exposure for a reprocess request).
Igor Murashkin5df2f622014-01-10 14:18:45 -0800278 *
279 * Both partial metadata results and the gralloc buffers may be sent to the
280 * framework at any time before or after the SHUTTER event.
281 *
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800282 * 10. After some pipeline delay, the HAL begins to return completed captures to
283 * the framework with camera3_callback_ops_t->process_capture_result(). These
284 * are returned in the same order as the requests were submitted. Multiple
285 * requests can be in flight at once, depending on the pipeline depth of the
286 * camera HAL device.
287 *
Igor Murashkin78aa1262014-01-09 16:23:43 -0800288 * >= CAMERA_DEVICE_API_VERSION_3_2:
289 *
290 * Once a buffer is returned by process_capture_result as part of the
291 * camera3_stream_buffer_t array, and the fence specified by release_fence
292 * has been signaled (this is a no-op for -1 fences), the ownership of that
293 * buffer is considered to be transferred back to the framework. After that,
294 * the HAL must no longer retain that particular buffer, and the
295 * framework may clean up the memory for it immediately.
296 *
Igor Murashkin5df2f622014-01-10 14:18:45 -0800297 * process_capture_result may be called multiple times for a single frame,
298 * each time with a new disjoint piece of metadata and/or set of gralloc
299 * buffers. The framework will accumulate these partial metadata results
300 * into one result.
301 *
302 * In particular, it is legal for a process_capture_result to be called
303 * simultaneously for both a frame N and a frame N+1 as long as the
Zhijun Heceac9e32014-02-05 20:49:45 -0800304 * above rule holds for gralloc buffers (both input and output).
Igor Murashkin5df2f622014-01-10 14:18:45 -0800305 *
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800306 * 11. After some time, the framework may stop submitting new requests, wait for
307 * the existing captures to complete (all buffers filled, all results
308 * returned), and then call configure_streams() again. This resets the camera
309 * hardware and pipeline for a new set of input/output streams. Some streams
310 * may be reused from the previous configuration; if these streams' buffers
311 * had already been registered with the HAL, they will not be registered
312 * again. The framework then continues from step 7, if at least one
313 * registered output stream remains (otherwise, step 5 is required first).
314 *
315 * 12. Alternatively, the framework may call camera3_device_t->common->close()
Eino-Ville Talvala2f8cf5c2013-03-06 13:23:31 -0800316 * to end the camera session. This may be called at any time when no other
317 * calls from the framework are active, although the call may block until all
318 * in-flight captures have completed (all results returned, all buffers
319 * filled). After the close call returns, no more calls to the
320 * camera3_callback_ops_t functions are allowed from the HAL. Once the
321 * close() call is underway, the framework may not call any other HAL device
322 * functions.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800323 *
324 * 13. In case of an error or other asynchronous event, the HAL must call
325 * camera3_callback_ops_t->notify() with the appropriate error/event
326 * message. After returning from a fatal device-wide error notification, the
327 * HAL should act as if close() had been called on it. However, the HAL must
328 * either cancel or complete all outstanding captures before calling
329 * notify(), so that once notify() is called with a fatal error, the
330 * framework will not receive further callbacks from the device. Methods
331 * besides close() should return -ENODEV or NULL after the notify() method
332 * returns from a fatal error message.
333 */
334
335/**
Eino-Ville Talvalaacbc4512013-03-16 16:53:28 -0700336 * S3. Operational modes:
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800337 *
338 * The camera 3 HAL device can implement one of two possible operational modes;
339 * limited and full. Full support is expected from new higher-end
340 * devices. Limited mode has hardware requirements roughly in line with those
341 * for a camera HAL device v1 implementation, and is expected from older or
342 * inexpensive devices. Full is a strict superset of limited, and they share the
343 * same essential operational flow, as documented above.
344 *
345 * The HAL must indicate its level of support with the
346 * android.info.supportedHardwareLevel static metadata entry, with 0 indicating
347 * limited mode, and 1 indicating full mode support.
348 *
349 * Roughly speaking, limited-mode devices do not allow for application control
350 * of capture settings (3A control only), high-rate capture of high-resolution
Eino-Ville Talvalaacbc4512013-03-16 16:53:28 -0700351 * images, raw sensor readout, or support for YUV output streams above maximum
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800352 * recording resolution (JPEG only for large images).
353 *
354 * ** Details of limited mode behavior:
355 *
356 * - Limited-mode devices do not need to implement accurate synchronization
357 * between capture request settings and the actual image data
358 * captured. Instead, changes to settings may take effect some time in the
359 * future, and possibly not for the same output frame for each settings
360 * entry. Rapid changes in settings may result in some settings never being
361 * used for a capture. However, captures that include high-resolution output
362 * buffers ( > 1080p ) have to use the settings as specified (but see below
363 * for processing rate).
364 *
365 * - Limited-mode devices do not need to support most of the
Zhijun He1ab5c5e2014-05-26 17:35:50 -0700366 * settings/result/static info metadata. Specifically, only the following settings
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800367 * are expected to be consumed or produced by a limited-mode HAL device:
368 *
Zhijun He1ab5c5e2014-05-26 17:35:50 -0700369 * android.control.aeAntibandingMode (controls and dynamic)
370 * android.control.aeExposureCompensation (controls and dynamic)
371 * android.control.aeLock (controls and dynamic)
372 * android.control.aeMode (controls and dynamic)
373 * android.control.aeRegions (controls and dynamic)
374 * android.control.aeTargetFpsRange (controls and dynamic)
375 * android.control.aePrecaptureTrigger (controls and dynamic)
376 * android.control.afMode (controls and dynamic)
377 * android.control.afRegions (controls and dynamic)
378 * android.control.awbLock (controls and dynamic)
379 * android.control.awbMode (controls and dynamic)
380 * android.control.awbRegions (controls and dynamic)
381 * android.control.captureIntent (controls and dynamic)
382 * android.control.effectMode (controls and dynamic)
383 * android.control.mode (controls and dynamic)
384 * android.control.sceneMode (controls and dynamic)
385 * android.control.videoStabilizationMode (controls and dynamic)
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800386 * android.control.aeAvailableAntibandingModes (static)
387 * android.control.aeAvailableModes (static)
388 * android.control.aeAvailableTargetFpsRanges (static)
389 * android.control.aeCompensationRange (static)
390 * android.control.aeCompensationStep (static)
391 * android.control.afAvailableModes (static)
392 * android.control.availableEffects (static)
393 * android.control.availableSceneModes (static)
394 * android.control.availableVideoStabilizationModes (static)
395 * android.control.awbAvailableModes (static)
396 * android.control.maxRegions (static)
397 * android.control.sceneModeOverrides (static)
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800398 * android.control.aeState (dynamic)
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800399 * android.control.afState (dynamic)
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800400 * android.control.awbState (dynamic)
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800401 *
Zhijun He1ab5c5e2014-05-26 17:35:50 -0700402 * android.flash.mode (controls and dynamic)
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800403 * android.flash.info.available (static)
404 *
405 * android.info.supportedHardwareLevel (static)
406 *
Zhijun He1ab5c5e2014-05-26 17:35:50 -0700407 * android.jpeg.gpsCoordinates (controls and dynamic)
408 * android.jpeg.gpsProcessingMethod (controls and dynamic)
409 * android.jpeg.gpsTimestamp (controls and dynamic)
410 * android.jpeg.orientation (controls and dynamic)
411 * android.jpeg.quality (controls and dynamic)
412 * android.jpeg.thumbnailQuality (controls and dynamic)
413 * android.jpeg.thumbnailSize (controls and dynamic)
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800414 * android.jpeg.availableThumbnailSizes (static)
415 * android.jpeg.maxSize (static)
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800416 *
417 * android.lens.info.minimumFocusDistance (static)
418 *
Zhijun He1ab5c5e2014-05-26 17:35:50 -0700419 * android.request.id (controls and dynamic)
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800420 *
Zhijun He1ab5c5e2014-05-26 17:35:50 -0700421 * android.scaler.cropRegion (controls and dynamic)
Eino-Ville Talvalac5bff0d2014-02-10 16:43:26 -0800422 * android.scaler.availableStreamConfigurations (static)
423 * android.scaler.availableMinFrameDurations (static)
424 * android.scaler.availableStallDurations (static)
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800425 * android.scaler.availableMaxDigitalZoom (static)
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800426 * android.scaler.maxDigitalZoom (static)
Zhijun He1ab5c5e2014-05-26 17:35:50 -0700427 * android.scaler.croppingType (static)
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800428 *
429 * android.sensor.orientation (static)
430 * android.sensor.timestamp (dynamic)
431 *
Zhijun He1ab5c5e2014-05-26 17:35:50 -0700432 * android.statistics.faceDetectMode (controls and dynamic)
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800433 * android.statistics.info.availableFaceDetectModes (static)
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800434 * android.statistics.faceIds (dynamic)
435 * android.statistics.faceLandmarks (dynamic)
436 * android.statistics.faceRectangles (dynamic)
437 * android.statistics.faceScores (dynamic)
438 *
Zhijun He1ab5c5e2014-05-26 17:35:50 -0700439 * android.sync.frameNumber (dynamic)
440 * android.sync.maxLatency (static)
441 *
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800442 * - Captures in limited mode that include high-resolution (> 1080p) output
443 * buffers may block in process_capture_request() until all the output buffers
444 * have been filled. A full-mode HAL device must process sequences of
445 * high-resolution requests at the rate indicated in the static metadata for
446 * that pixel format. The HAL must still call process_capture_result() to
447 * provide the output; the framework must simply be prepared for
448 * process_capture_request() to block until after process_capture_result() for
449 * that request completes for high-resolution captures for limited-mode
450 * devices.
451 *
Zhijun He1ab5c5e2014-05-26 17:35:50 -0700452 * - Full-mode devices must support below additional capabilities:
453 * - 30fps at maximum resolution is preferred, more than 20fps is required.
454 * - Per frame control (android.sync.maxLatency == PER_FRAME_CONTROL).
455 * - Sensor manual control metadata. See MANUAL_SENSOR defined in
456 * android.request.availableCapabilities.
457 * - Post-processing manual control metadata. See MANUAL_POST_PROCESSING defined
458 * in android.request.availableCapabilities.
459 *
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800460 */
461
462/**
Eino-Ville Talvalaacbc4512013-03-16 16:53:28 -0700463 * S4. 3A modes and state machines:
464 *
465 * While the actual 3A algorithms are up to the HAL implementation, a high-level
466 * state machine description is defined by the HAL interface, to allow the HAL
467 * device and the framework to communicate about the current state of 3A, and to
468 * trigger 3A events.
469 *
470 * When the device is opened, all the individual 3A states must be
471 * STATE_INACTIVE. Stream configuration does not reset 3A. For example, locked
472 * focus must be maintained across the configure() call.
473 *
474 * Triggering a 3A action involves simply setting the relevant trigger entry in
475 * the settings for the next request to indicate start of trigger. For example,
476 * the trigger for starting an autofocus scan is setting the entry
477 * ANDROID_CONTROL_AF_TRIGGER to ANDROID_CONTROL_AF_TRIGGER_START for one
478 * request, and cancelling an autofocus scan is triggered by setting
479 * ANDROID_CONTROL_AF_TRIGGER to ANDROID_CONTRL_AF_TRIGGER_CANCEL. Otherwise,
480 * the entry will not exist, or be set to ANDROID_CONTROL_AF_TRIGGER_IDLE. Each
481 * request with a trigger entry set to a non-IDLE value will be treated as an
482 * independent triggering event.
483 *
484 * At the top level, 3A is controlled by the ANDROID_CONTROL_MODE setting, which
485 * selects between no 3A (ANDROID_CONTROL_MODE_OFF), normal AUTO mode
486 * (ANDROID_CONTROL_MODE_AUTO), and using the scene mode setting
487 * (ANDROID_CONTROL_USE_SCENE_MODE).
488 *
489 * - In OFF mode, each of the individual AE/AF/AWB modes are effectively OFF,
490 * and none of the capture controls may be overridden by the 3A routines.
491 *
492 * - In AUTO mode, Auto-focus, auto-exposure, and auto-whitebalance all run
493 * their own independent algorithms, and have their own mode, state, and
494 * trigger metadata entries, as listed in the next section.
495 *
496 * - In USE_SCENE_MODE, the value of the ANDROID_CONTROL_SCENE_MODE entry must
497 * be used to determine the behavior of 3A routines. In SCENE_MODEs other than
498 * FACE_PRIORITY, the HAL must override the values of
499 * ANDROId_CONTROL_AE/AWB/AF_MODE to be the mode it prefers for the selected
500 * SCENE_MODE. For example, the HAL may prefer SCENE_MODE_NIGHT to use
501 * CONTINUOUS_FOCUS AF mode. Any user selection of AE/AWB/AF_MODE when scene
502 * must be ignored for these scene modes.
503 *
504 * - For SCENE_MODE_FACE_PRIORITY, the AE/AWB/AF_MODE controls work as in
505 * ANDROID_CONTROL_MODE_AUTO, but the 3A routines must bias toward metering
506 * and focusing on any detected faces in the scene.
507 *
508 * S4.1. Auto-focus settings and result entries:
509 *
510 * Main metadata entries:
511 *
512 * ANDROID_CONTROL_AF_MODE: Control for selecting the current autofocus
513 * mode. Set by the framework in the request settings.
514 *
515 * AF_MODE_OFF: AF is disabled; the framework/app directly controls lens
516 * position.
517 *
518 * AF_MODE_AUTO: Single-sweep autofocus. No lens movement unless AF is
519 * triggered.
520 *
521 * AF_MODE_MACRO: Single-sweep up-close autofocus. No lens movement unless
522 * AF is triggered.
523 *
524 * AF_MODE_CONTINUOUS_VIDEO: Smooth continuous focusing, for recording
525 * video. Triggering immediately locks focus in current
526 * position. Canceling resumes cotinuous focusing.
527 *
528 * AF_MODE_CONTINUOUS_PICTURE: Fast continuous focusing, for
529 * zero-shutter-lag still capture. Triggering locks focus once currently
530 * active sweep concludes. Canceling resumes continuous focusing.
531 *
532 * AF_MODE_EDOF: Advanced extended depth of field focusing. There is no
533 * autofocus scan, so triggering one or canceling one has no effect.
534 * Images are focused automatically by the HAL.
535 *
536 * ANDROID_CONTROL_AF_STATE: Dynamic metadata describing the current AF
537 * algorithm state, reported by the HAL in the result metadata.
538 *
539 * AF_STATE_INACTIVE: No focusing has been done, or algorithm was
540 * reset. Lens is not moving. Always the state for MODE_OFF or MODE_EDOF.
541 * When the device is opened, it must start in this state.
542 *
543 * AF_STATE_PASSIVE_SCAN: A continuous focus algorithm is currently scanning
544 * for good focus. The lens is moving.
545 *
546 * AF_STATE_PASSIVE_FOCUSED: A continuous focus algorithm believes it is
547 * well focused. The lens is not moving. The HAL may spontaneously leave
548 * this state.
549 *
Eino-Ville Talvala4d45d302013-09-20 17:24:50 -0700550 * AF_STATE_PASSIVE_UNFOCUSED: A continuous focus algorithm believes it is
551 * not well focused. The lens is not moving. The HAL may spontaneously
552 * leave this state.
553 *
Eino-Ville Talvalaacbc4512013-03-16 16:53:28 -0700554 * AF_STATE_ACTIVE_SCAN: A scan triggered by the user is underway.
555 *
556 * AF_STATE_FOCUSED_LOCKED: The AF algorithm believes it is focused. The
557 * lens is not moving.
558 *
559 * AF_STATE_NOT_FOCUSED_LOCKED: The AF algorithm has been unable to
560 * focus. The lens is not moving.
561 *
562 * ANDROID_CONTROL_AF_TRIGGER: Control for starting an autofocus scan, the
563 * meaning of which is mode- and state- dependent. Set by the framework in
564 * the request settings.
565 *
566 * AF_TRIGGER_IDLE: No current trigger.
567 *
568 * AF_TRIGGER_START: Trigger start of AF scan. Effect is mode and state
569 * dependent.
570 *
571 * AF_TRIGGER_CANCEL: Cancel current AF scan if any, and reset algorithm to
572 * default.
573 *
574 * Additional metadata entries:
575 *
576 * ANDROID_CONTROL_AF_REGIONS: Control for selecting the regions of the FOV
577 * that should be used to determine good focus. This applies to all AF
578 * modes that scan for focus. Set by the framework in the request
579 * settings.
580 *
581 * S4.2. Auto-exposure settings and result entries:
582 *
583 * Main metadata entries:
584 *
585 * ANDROID_CONTROL_AE_MODE: Control for selecting the current auto-exposure
586 * mode. Set by the framework in the request settings.
587 *
588 * AE_MODE_OFF: Autoexposure is disabled; the user controls exposure, gain,
589 * frame duration, and flash.
590 *
591 * AE_MODE_ON: Standard autoexposure, with flash control disabled. User may
592 * set flash to fire or to torch mode.
593 *
594 * AE_MODE_ON_AUTO_FLASH: Standard autoexposure, with flash on at HAL's
595 * discretion for precapture and still capture. User control of flash
596 * disabled.
597 *
598 * AE_MODE_ON_ALWAYS_FLASH: Standard autoexposure, with flash always fired
599 * for capture, and at HAL's discretion for precapture.. User control of
600 * flash disabled.
601 *
602 * AE_MODE_ON_AUTO_FLASH_REDEYE: Standard autoexposure, with flash on at
603 * HAL's discretion for precapture and still capture. Use a flash burst
604 * at end of precapture sequence to reduce redeye in the final
605 * picture. User control of flash disabled.
606 *
607 * ANDROID_CONTROL_AE_STATE: Dynamic metadata describing the current AE
608 * algorithm state, reported by the HAL in the result metadata.
609 *
610 * AE_STATE_INACTIVE: Initial AE state after mode switch. When the device is
611 * opened, it must start in this state.
612 *
613 * AE_STATE_SEARCHING: AE is not converged to a good value, and is adjusting
614 * exposure parameters.
615 *
616 * AE_STATE_CONVERGED: AE has found good exposure values for the current
617 * scene, and the exposure parameters are not changing. HAL may
618 * spontaneously leave this state to search for better solution.
619 *
620 * AE_STATE_LOCKED: AE has been locked with the AE_LOCK control. Exposure
621 * values are not changing.
622 *
623 * AE_STATE_FLASH_REQUIRED: The HAL has converged exposure, but believes
624 * flash is required for a sufficiently bright picture. Used for
625 * determining if a zero-shutter-lag frame can be used.
626 *
627 * AE_STATE_PRECAPTURE: The HAL is in the middle of a precapture
628 * sequence. Depending on AE mode, this mode may involve firing the
629 * flash for metering, or a burst of flash pulses for redeye reduction.
630 *
631 * ANDROID_CONTROL_AE_PRECAPTURE_TRIGGER: Control for starting a metering
632 * sequence before capturing a high-quality image. Set by the framework in
633 * the request settings.
634 *
635 * PRECAPTURE_TRIGGER_IDLE: No current trigger.
636 *
637 * PRECAPTURE_TRIGGER_START: Start a precapture sequence. The HAL should
638 * use the subsequent requests to measure good exposure/white balance
639 * for an upcoming high-resolution capture.
640 *
641 * Additional metadata entries:
642 *
643 * ANDROID_CONTROL_AE_LOCK: Control for locking AE controls to their current
644 * values
645 *
646 * ANDROID_CONTROL_AE_EXPOSURE_COMPENSATION: Control for adjusting AE
647 * algorithm target brightness point.
648 *
649 * ANDROID_CONTROL_AE_TARGET_FPS_RANGE: Control for selecting the target frame
650 * rate range for the AE algorithm. The AE routine cannot change the frame
651 * rate to be outside these bounds.
652 *
653 * ANDROID_CONTROL_AE_REGIONS: Control for selecting the regions of the FOV
654 * that should be used to determine good exposure levels. This applies to
655 * all AE modes besides OFF.
656 *
657 * S4.3. Auto-whitebalance settings and result entries:
658 *
659 * Main metadata entries:
660 *
661 * ANDROID_CONTROL_AWB_MODE: Control for selecting the current white-balance
662 * mode.
663 *
664 * AWB_MODE_OFF: Auto-whitebalance is disabled. User controls color matrix.
665 *
666 * AWB_MODE_AUTO: Automatic white balance is enabled; 3A controls color
667 * transform, possibly using more complex transforms than a simple
668 * matrix.
669 *
670 * AWB_MODE_INCANDESCENT: Fixed white balance settings good for indoor
671 * incandescent (tungsten) lighting, roughly 2700K.
672 *
673 * AWB_MODE_FLUORESCENT: Fixed white balance settings good for fluorescent
674 * lighting, roughly 5000K.
675 *
676 * AWB_MODE_WARM_FLUORESCENT: Fixed white balance settings good for
677 * fluorescent lighting, roughly 3000K.
678 *
679 * AWB_MODE_DAYLIGHT: Fixed white balance settings good for daylight,
680 * roughly 5500K.
681 *
682 * AWB_MODE_CLOUDY_DAYLIGHT: Fixed white balance settings good for clouded
683 * daylight, roughly 6500K.
684 *
685 * AWB_MODE_TWILIGHT: Fixed white balance settings good for
686 * near-sunset/sunrise, roughly 15000K.
687 *
688 * AWB_MODE_SHADE: Fixed white balance settings good for areas indirectly
689 * lit by the sun, roughly 7500K.
690 *
691 * ANDROID_CONTROL_AWB_STATE: Dynamic metadata describing the current AWB
692 * algorithm state, reported by the HAL in the result metadata.
693 *
694 * AWB_STATE_INACTIVE: Initial AWB state after mode switch. When the device
695 * is opened, it must start in this state.
696 *
697 * AWB_STATE_SEARCHING: AWB is not converged to a good value, and is
698 * changing color adjustment parameters.
699 *
700 * AWB_STATE_CONVERGED: AWB has found good color adjustment values for the
701 * current scene, and the parameters are not changing. HAL may
702 * spontaneously leave this state to search for better solution.
703 *
704 * AWB_STATE_LOCKED: AWB has been locked with the AWB_LOCK control. Color
705 * adjustment values are not changing.
706 *
707 * Additional metadata entries:
708 *
709 * ANDROID_CONTROL_AWB_LOCK: Control for locking AWB color adjustments to
710 * their current values.
711 *
712 * ANDROID_CONTROL_AWB_REGIONS: Control for selecting the regions of the FOV
713 * that should be used to determine good color balance. This applies only
714 * to auto-WB mode.
715 *
716 * S4.4. General state machine transition notes
717 *
718 * Switching between AF, AE, or AWB modes always resets the algorithm's state
719 * to INACTIVE. Similarly, switching between CONTROL_MODE or
720 * CONTROL_SCENE_MODE if CONTROL_MODE == USE_SCENE_MODE resets all the
721 * algorithm states to INACTIVE.
722 *
723 * The tables below are per-mode.
724 *
725 * S4.5. AF state machines
726 *
Eino-Ville Talvala4d45d302013-09-20 17:24:50 -0700727 * when enabling AF or changing AF mode
728 *| state | trans. cause | new state | notes |
729 *+--------------------+---------------+--------------------+------------------+
730 *| Any | AF mode change| INACTIVE | |
731 *+--------------------+---------------+--------------------+------------------+
732 *
Eino-Ville Talvalaacbc4512013-03-16 16:53:28 -0700733 * mode = AF_MODE_OFF or AF_MODE_EDOF
734 *| state | trans. cause | new state | notes |
735 *+--------------------+---------------+--------------------+------------------+
Eino-Ville Talvala4d45d302013-09-20 17:24:50 -0700736 *| INACTIVE | | INACTIVE | Never changes |
Eino-Ville Talvalaacbc4512013-03-16 16:53:28 -0700737 *+--------------------+---------------+--------------------+------------------+
738 *
739 * mode = AF_MODE_AUTO or AF_MODE_MACRO
740 *| state | trans. cause | new state | notes |
741 *+--------------------+---------------+--------------------+------------------+
742 *| INACTIVE | AF_TRIGGER | ACTIVE_SCAN | Start AF sweep |
743 *| | | | Lens now moving |
744 *+--------------------+---------------+--------------------+------------------+
745 *| ACTIVE_SCAN | AF sweep done | FOCUSED_LOCKED | If AF successful |
746 *| | | | Lens now locked |
747 *+--------------------+---------------+--------------------+------------------+
748 *| ACTIVE_SCAN | AF sweep done | NOT_FOCUSED_LOCKED | If AF successful |
749 *| | | | Lens now locked |
750 *+--------------------+---------------+--------------------+------------------+
751 *| ACTIVE_SCAN | AF_CANCEL | INACTIVE | Cancel/reset AF |
752 *| | | | Lens now locked |
753 *+--------------------+---------------+--------------------+------------------+
754 *| FOCUSED_LOCKED | AF_CANCEL | INACTIVE | Cancel/reset AF |
755 *+--------------------+---------------+--------------------+------------------+
756 *| FOCUSED_LOCKED | AF_TRIGGER | ACTIVE_SCAN | Start new sweep |
757 *| | | | Lens now moving |
758 *+--------------------+---------------+--------------------+------------------+
759 *| NOT_FOCUSED_LOCKED | AF_CANCEL | INACTIVE | Cancel/reset AF |
760 *+--------------------+---------------+--------------------+------------------+
761 *| NOT_FOCUSED_LOCKED | AF_TRIGGER | ACTIVE_SCAN | Start new sweep |
762 *| | | | Lens now moving |
763 *+--------------------+---------------+--------------------+------------------+
764 *| All states | mode change | INACTIVE | |
765 *+--------------------+---------------+--------------------+------------------+
766 *
767 * mode = AF_MODE_CONTINUOUS_VIDEO
768 *| state | trans. cause | new state | notes |
769 *+--------------------+---------------+--------------------+------------------+
770 *| INACTIVE | HAL initiates | PASSIVE_SCAN | Start AF scan |
771 *| | new scan | | Lens now moving |
772 *+--------------------+---------------+--------------------+------------------+
773 *| INACTIVE | AF_TRIGGER | NOT_FOCUSED_LOCKED | AF state query |
774 *| | | | Lens now locked |
775 *+--------------------+---------------+--------------------+------------------+
776 *| PASSIVE_SCAN | HAL completes | PASSIVE_FOCUSED | End AF scan |
777 *| | current scan | | Lens now locked |
778 *+--------------------+---------------+--------------------+------------------+
Eino-Ville Talvala4d45d302013-09-20 17:24:50 -0700779 *| PASSIVE_SCAN | HAL fails | PASSIVE_UNFOCUSED | End AF scan |
780 *| | current scan | | Lens now locked |
781 *+--------------------+---------------+--------------------+------------------+
Eino-Ville Talvalaacbc4512013-03-16 16:53:28 -0700782 *| PASSIVE_SCAN | AF_TRIGGER | FOCUSED_LOCKED | Immediate trans. |
783 *| | | | if focus is good |
784 *| | | | Lens now locked |
785 *+--------------------+---------------+--------------------+------------------+
786 *| PASSIVE_SCAN | AF_TRIGGER | NOT_FOCUSED_LOCKED | Immediate trans. |
787 *| | | | if focus is bad |
788 *| | | | Lens now locked |
789 *+--------------------+---------------+--------------------+------------------+
790 *| PASSIVE_SCAN | AF_CANCEL | INACTIVE | Reset lens |
791 *| | | | position |
792 *| | | | Lens now locked |
793 *+--------------------+---------------+--------------------+------------------+
794 *| PASSIVE_FOCUSED | HAL initiates | PASSIVE_SCAN | Start AF scan |
795 *| | new scan | | Lens now moving |
796 *+--------------------+---------------+--------------------+------------------+
Eino-Ville Talvala4d45d302013-09-20 17:24:50 -0700797 *| PASSIVE_UNFOCUSED | HAL initiates | PASSIVE_SCAN | Start AF scan |
798 *| | new scan | | Lens now moving |
799 *+--------------------+---------------+--------------------+------------------+
Eino-Ville Talvalaacbc4512013-03-16 16:53:28 -0700800 *| PASSIVE_FOCUSED | AF_TRIGGER | FOCUSED_LOCKED | Immediate trans. |
Eino-Ville Talvalaacbc4512013-03-16 16:53:28 -0700801 *| | | | Lens now locked |
802 *+--------------------+---------------+--------------------+------------------+
Eino-Ville Talvala4d45d302013-09-20 17:24:50 -0700803 *| PASSIVE_UNFOCUSED | AF_TRIGGER | NOT_FOCUSED_LOCKED | Immediate trans. |
Eino-Ville Talvalaacbc4512013-03-16 16:53:28 -0700804 *| | | | Lens now locked |
805 *+--------------------+---------------+--------------------+------------------+
806 *| FOCUSED_LOCKED | AF_TRIGGER | FOCUSED_LOCKED | No effect |
807 *+--------------------+---------------+--------------------+------------------+
808 *| FOCUSED_LOCKED | AF_CANCEL | INACTIVE | Restart AF scan |
809 *+--------------------+---------------+--------------------+------------------+
810 *| NOT_FOCUSED_LOCKED | AF_TRIGGER | NOT_FOCUSED_LOCKED | No effect |
811 *+--------------------+---------------+--------------------+------------------+
812 *| NOT_FOCUSED_LOCKED | AF_CANCEL | INACTIVE | Restart AF scan |
813 *+--------------------+---------------+--------------------+------------------+
814 *
815 * mode = AF_MODE_CONTINUOUS_PICTURE
816 *| state | trans. cause | new state | notes |
817 *+--------------------+---------------+--------------------+------------------+
818 *| INACTIVE | HAL initiates | PASSIVE_SCAN | Start AF scan |
819 *| | new scan | | Lens now moving |
820 *+--------------------+---------------+--------------------+------------------+
821 *| INACTIVE | AF_TRIGGER | NOT_FOCUSED_LOCKED | AF state query |
822 *| | | | Lens now locked |
823 *+--------------------+---------------+--------------------+------------------+
824 *| PASSIVE_SCAN | HAL completes | PASSIVE_FOCUSED | End AF scan |
825 *| | current scan | | Lens now locked |
826 *+--------------------+---------------+--------------------+------------------+
Eino-Ville Talvala4d45d302013-09-20 17:24:50 -0700827 *| PASSIVE_SCAN | HAL fails | PASSIVE_UNFOCUSED | End AF scan |
828 *| | current scan | | Lens now locked |
829 *+--------------------+---------------+--------------------+------------------+
Eino-Ville Talvalaacbc4512013-03-16 16:53:28 -0700830 *| PASSIVE_SCAN | AF_TRIGGER | FOCUSED_LOCKED | Eventual trans. |
831 *| | | | once focus good |
832 *| | | | Lens now locked |
833 *+--------------------+---------------+--------------------+------------------+
834 *| PASSIVE_SCAN | AF_TRIGGER | NOT_FOCUSED_LOCKED | Eventual trans. |
835 *| | | | if cannot focus |
836 *| | | | Lens now locked |
837 *+--------------------+---------------+--------------------+------------------+
838 *| PASSIVE_SCAN | AF_CANCEL | INACTIVE | Reset lens |
839 *| | | | position |
840 *| | | | Lens now locked |
841 *+--------------------+---------------+--------------------+------------------+
842 *| PASSIVE_FOCUSED | HAL initiates | PASSIVE_SCAN | Start AF scan |
843 *| | new scan | | Lens now moving |
844 *+--------------------+---------------+--------------------+------------------+
Eino-Ville Talvala4d45d302013-09-20 17:24:50 -0700845 *| PASSIVE_UNFOCUSED | HAL initiates | PASSIVE_SCAN | Start AF scan |
846 *| | new scan | | Lens now moving |
847 *+--------------------+---------------+--------------------+------------------+
Eino-Ville Talvalaacbc4512013-03-16 16:53:28 -0700848 *| PASSIVE_FOCUSED | AF_TRIGGER | FOCUSED_LOCKED | Immediate trans. |
Eino-Ville Talvalaacbc4512013-03-16 16:53:28 -0700849 *| | | | Lens now locked |
850 *+--------------------+---------------+--------------------+------------------+
Eino-Ville Talvala4d45d302013-09-20 17:24:50 -0700851 *| PASSIVE_UNFOCUSED | AF_TRIGGER | NOT_FOCUSED_LOCKED | Immediate trans. |
Eino-Ville Talvalaacbc4512013-03-16 16:53:28 -0700852 *| | | | Lens now locked |
853 *+--------------------+---------------+--------------------+------------------+
854 *| FOCUSED_LOCKED | AF_TRIGGER | FOCUSED_LOCKED | No effect |
855 *+--------------------+---------------+--------------------+------------------+
856 *| FOCUSED_LOCKED | AF_CANCEL | INACTIVE | Restart AF scan |
857 *+--------------------+---------------+--------------------+------------------+
858 *| NOT_FOCUSED_LOCKED | AF_TRIGGER | NOT_FOCUSED_LOCKED | No effect |
859 *+--------------------+---------------+--------------------+------------------+
860 *| NOT_FOCUSED_LOCKED | AF_CANCEL | INACTIVE | Restart AF scan |
861 *+--------------------+---------------+--------------------+------------------+
862 *
863 * S4.6. AE and AWB state machines
864 *
865 * The AE and AWB state machines are mostly identical. AE has additional
866 * FLASH_REQUIRED and PRECAPTURE states. So rows below that refer to those two
867 * states should be ignored for the AWB state machine.
868 *
Eino-Ville Talvala4d45d302013-09-20 17:24:50 -0700869 * when enabling AE/AWB or changing AE/AWB mode
870 *| state | trans. cause | new state | notes |
871 *+--------------------+---------------+--------------------+------------------+
872 *| Any | mode change | INACTIVE | |
873 *+--------------------+---------------+--------------------+------------------+
874 *
Eino-Ville Talvalaacbc4512013-03-16 16:53:28 -0700875 * mode = AE_MODE_OFF / AWB mode not AUTO
876 *| state | trans. cause | new state | notes |
877 *+--------------------+---------------+--------------------+------------------+
Eino-Ville Talvala4d45d302013-09-20 17:24:50 -0700878 *| INACTIVE | | INACTIVE | AE/AWB disabled |
Eino-Ville Talvalaacbc4512013-03-16 16:53:28 -0700879 *+--------------------+---------------+--------------------+------------------+
880 *
881 * mode = AE_MODE_ON_* / AWB_MODE_AUTO
882 *| state | trans. cause | new state | notes |
883 *+--------------------+---------------+--------------------+------------------+
884 *| INACTIVE | HAL initiates | SEARCHING | |
885 *| | AE/AWB scan | | |
886 *+--------------------+---------------+--------------------+------------------+
887 *| INACTIVE | AE/AWB_LOCK | LOCKED | values locked |
888 *| | on | | |
889 *+--------------------+---------------+--------------------+------------------+
890 *| SEARCHING | HAL finishes | CONVERGED | good values, not |
891 *| | AE/AWB scan | | changing |
892 *+--------------------+---------------+--------------------+------------------+
893 *| SEARCHING | HAL finishes | FLASH_REQUIRED | converged but too|
894 *| | AE scan | | dark w/o flash |
895 *+--------------------+---------------+--------------------+------------------+
896 *| SEARCHING | AE/AWB_LOCK | LOCKED | values locked |
897 *| | on | | |
898 *+--------------------+---------------+--------------------+------------------+
899 *| CONVERGED | HAL initiates | SEARCHING | values locked |
900 *| | AE/AWB scan | | |
901 *+--------------------+---------------+--------------------+------------------+
902 *| CONVERGED | AE/AWB_LOCK | LOCKED | values locked |
903 *| | on | | |
904 *+--------------------+---------------+--------------------+------------------+
Eino-Ville Talvala73dba5e2013-05-21 16:29:14 -0700905 *| FLASH_REQUIRED | HAL initiates | SEARCHING | values locked |
906 *| | AE/AWB scan | | |
907 *+--------------------+---------------+--------------------+------------------+
908 *| FLASH_REQUIRED | AE/AWB_LOCK | LOCKED | values locked |
909 *| | on | | |
910 *+--------------------+---------------+--------------------+------------------+
Eino-Ville Talvalaacbc4512013-03-16 16:53:28 -0700911 *| LOCKED | AE/AWB_LOCK | SEARCHING | values not good |
912 *| | off | | after unlock |
913 *+--------------------+---------------+--------------------+------------------+
914 *| LOCKED | AE/AWB_LOCK | CONVERGED | values good |
915 *| | off | | after unlock |
916 *+--------------------+---------------+--------------------+------------------+
917 *| LOCKED | AE_LOCK | FLASH_REQUIRED | exposure good, |
918 *| | off | | but too dark |
919 *+--------------------+---------------+--------------------+------------------+
920 *| All AE states | PRECAPTURE_ | PRECAPTURE | Start precapture |
921 *| | START | | sequence |
922 *+--------------------+---------------+--------------------+------------------+
923 *| PRECAPTURE | Sequence done.| CONVERGED | Ready for high- |
924 *| | AE_LOCK off | | quality capture |
925 *+--------------------+---------------+--------------------+------------------+
926 *| PRECAPTURE | Sequence done.| LOCKED | Ready for high- |
927 *| | AE_LOCK on | | quality capture |
928 *+--------------------+---------------+--------------------+------------------+
929 *
930 */
931
932/**
Eino-Ville Talvalab6059442013-04-29 15:26:16 -0700933 * S5. Cropping:
934 *
935 * Cropping of the full pixel array (for digital zoom and other use cases where
936 * a smaller FOV is desirable) is communicated through the
937 * ANDROID_SCALER_CROP_REGION setting. This is a per-request setting, and can
938 * change on a per-request basis, which is critical for implementing smooth
939 * digital zoom.
940 *
941 * The region is defined as a rectangle (x, y, width, height), with (x, y)
942 * describing the top-left corner of the rectangle. The rectangle is defined on
943 * the coordinate system of the sensor active pixel array, with (0,0) being the
944 * top-left pixel of the active pixel array. Therefore, the width and height
945 * cannot be larger than the dimensions reported in the
946 * ANDROID_SENSOR_ACTIVE_PIXEL_ARRAY static info field. The minimum allowed
947 * width and height are reported by the HAL through the
948 * ANDROID_SCALER_MAX_DIGITAL_ZOOM static info field, which describes the
949 * maximum supported zoom factor. Therefore, the minimum crop region width and
950 * height are:
951 *
952 * {width, height} =
953 * { floor(ANDROID_SENSOR_ACTIVE_PIXEL_ARRAY[0] /
954 * ANDROID_SCALER_MAX_DIGITAL_ZOOM),
955 * floor(ANDROID_SENSOR_ACTIVE_PIXEL_ARRAY[1] /
956 * ANDROID_SCALER_MAX_DIGITAL_ZOOM) }
957 *
958 * If the crop region needs to fulfill specific requirements (for example, it
959 * needs to start on even coordinates, and its width/height needs to be even),
960 * the HAL must do the necessary rounding and write out the final crop region
961 * used in the output result metadata. Similarly, if the HAL implements video
962 * stabilization, it must adjust the result crop region to describe the region
963 * actually included in the output after video stabilization is applied. In
964 * general, a camera-using application must be able to determine the field of
965 * view it is receiving based on the crop region, the dimensions of the image
966 * sensor, and the lens focal length.
967 *
Zhijun Hef1ee67e2014-05-21 11:18:51 -0700968 * It is assumed that the cropping is applied after raw to other color space
969 * conversion. Raw streams (RAW16 and RAW_OPAQUE) don't have this conversion stage,
970 * and are not croppable. Therefore, the crop region must be ignored by the HAL
971 * for raw streams.
972 *
973 * Since the crop region applies to all non-raw streams, which may have different aspect
Eino-Ville Talvalab6059442013-04-29 15:26:16 -0700974 * ratios than the crop region, the exact sensor region used for each stream may
975 * be smaller than the crop region. Specifically, each stream should maintain
976 * square pixels and its aspect ratio by minimally further cropping the defined
977 * crop region. If the stream's aspect ratio is wider than the crop region, the
978 * stream should be further cropped vertically, and if the stream's aspect ratio
979 * is narrower than the crop region, the stream should be further cropped
980 * horizontally.
981 *
982 * In all cases, the stream crop must be centered within the full crop region,
983 * and each stream is only either cropped horizontally or vertical relative to
984 * the full crop region, never both.
985 *
986 * For example, if two streams are defined, a 640x480 stream (4:3 aspect), and a
987 * 1280x720 stream (16:9 aspect), below demonstrates the expected output regions
988 * for each stream for a few sample crop regions, on a hypothetical 3 MP (2000 x
989 * 1500 pixel array) sensor.
990 *
991 * Crop region: (500, 375, 1000, 750) (4:3 aspect ratio)
992 *
993 * 640x480 stream crop: (500, 375, 1000, 750) (equal to crop region)
994 * 1280x720 stream crop: (500, 469, 1000, 562) (marked with =)
995 *
996 * 0 1000 2000
997 * +---------+---------+---------+----------+
998 * | Active pixel array |
999 * | |
1000 * | |
1001 * + +-------------------+ + 375
1002 * | | | |
1003 * | O===================O |
1004 * | I 1280x720 stream I |
1005 * + I I + 750
1006 * | I I |
1007 * | O===================O |
1008 * | | | |
1009 * + +-------------------+ + 1125
1010 * | Crop region, 640x480 stream |
1011 * | |
1012 * | |
1013 * +---------+---------+---------+----------+ 1500
1014 *
1015 * Crop region: (500, 375, 1333, 750) (16:9 aspect ratio)
1016 *
1017 * 640x480 stream crop: (666, 375, 1000, 750) (marked with =)
1018 * 1280x720 stream crop: (500, 375, 1333, 750) (equal to crop region)
1019 *
1020 * 0 1000 2000
1021 * +---------+---------+---------+----------+
1022 * | Active pixel array |
1023 * | |
1024 * | |
1025 * + +---O==================O---+ + 375
1026 * | | I 640x480 stream I | |
1027 * | | I I | |
1028 * | | I I | |
1029 * + | I I | + 750
1030 * | | I I | |
1031 * | | I I | |
1032 * | | I I | |
1033 * + +---O==================O---+ + 1125
1034 * | Crop region, 1280x720 stream |
1035 * | |
1036 * | |
1037 * +---------+---------+---------+----------+ 1500
1038 *
1039 * Crop region: (500, 375, 750, 750) (1:1 aspect ratio)
1040 *
1041 * 640x480 stream crop: (500, 469, 750, 562) (marked with =)
1042 * 1280x720 stream crop: (500, 543, 750, 414) (marged with #)
1043 *
1044 * 0 1000 2000
1045 * +---------+---------+---------+----------+
1046 * | Active pixel array |
1047 * | |
1048 * | |
1049 * + +--------------+ + 375
1050 * | O==============O |
1051 * | ################ |
1052 * | # # |
1053 * + # # + 750
1054 * | # # |
1055 * | ################ 1280x720 |
1056 * | O==============O 640x480 |
1057 * + +--------------+ + 1125
1058 * | Crop region |
1059 * | |
1060 * | |
1061 * +---------+---------+---------+----------+ 1500
1062 *
1063 * And a final example, a 1024x1024 square aspect ratio stream instead of the
1064 * 480p stream:
1065 *
1066 * Crop region: (500, 375, 1000, 750) (4:3 aspect ratio)
1067 *
1068 * 1024x1024 stream crop: (625, 375, 750, 750) (marked with #)
1069 * 1280x720 stream crop: (500, 469, 1000, 562) (marked with =)
1070 *
1071 * 0 1000 2000
1072 * +---------+---------+---------+----------+
1073 * | Active pixel array |
1074 * | |
1075 * | 1024x1024 stream |
1076 * + +--###############--+ + 375
1077 * | | # # | |
1078 * | O===================O |
1079 * | I 1280x720 stream I |
1080 * + I I + 750
1081 * | I I |
1082 * | O===================O |
1083 * | | # # | |
1084 * + +--###############--+ + 1125
1085 * | Crop region |
1086 * | |
1087 * | |
1088 * +---------+---------+---------+----------+ 1500
1089 *
1090 */
1091
1092/**
1093 * S6. Error management:
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001094 *
1095 * Camera HAL device ops functions that have a return value will all return
1096 * -ENODEV / NULL in case of a serious error. This means the device cannot
1097 * continue operation, and must be closed by the framework. Once this error is
Alex Rayd5ddbc92013-02-15 13:47:24 -08001098 * returned by some method, or if notify() is called with ERROR_DEVICE, only
1099 * the close() method can be called successfully. All other methods will return
1100 * -ENODEV / NULL.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001101 *
Eino-Ville Talvalaacbc4512013-03-16 16:53:28 -07001102 * If a device op is called in the wrong sequence, for example if the framework
1103 * calls configure_streams() is called before initialize(), the device must
1104 * return -ENOSYS from the call, and do nothing.
1105 *
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001106 * Transient errors in image capture must be reported through notify() as follows:
1107 *
1108 * - The failure of an entire capture to occur must be reported by the HAL by
1109 * calling notify() with ERROR_REQUEST. Individual errors for the result
1110 * metadata or the output buffers must not be reported in this case.
1111 *
1112 * - If the metadata for a capture cannot be produced, but some image buffers
1113 * were filled, the HAL must call notify() with ERROR_RESULT.
1114 *
1115 * - If an output image buffer could not be filled, but either the metadata was
1116 * produced or some other buffers were filled, the HAL must call notify() with
1117 * ERROR_BUFFER for each failed buffer.
1118 *
1119 * In each of these transient failure cases, the HAL must still call
Zhijun Heceac9e32014-02-05 20:49:45 -08001120 * process_capture_result, with valid output and input (if an input buffer was
1121 * submitted) buffer_handle_t. If the result metadata could not be produced, it
1122 * should be NULL. If some buffers could not be filled, they must be returned with
1123 * process_capture_result in the error state, their release fences must be set to
1124 * the acquire fences passed by the framework, or -1 if they have been waited on by
1125 * the HAL already.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001126 *
Eino-Ville Talvalaacbc4512013-03-16 16:53:28 -07001127 * Invalid input arguments result in -EINVAL from the appropriate methods. In
1128 * that case, the framework must act as if that call had never been made.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001129 *
1130 */
1131
Zhijun He2dde4682014-01-09 09:11:49 -08001132/**
Zhijun He709e5872014-01-17 15:25:21 -08001133 * S7. Key Performance Indicator (KPI) glossary:
Zhijun He2dde4682014-01-09 09:11:49 -08001134 *
Zhijun He709e5872014-01-17 15:25:21 -08001135 * This includes some critical definitions that are used by KPI metrics.
Zhijun He2dde4682014-01-09 09:11:49 -08001136 *
1137 * Pipeline Latency:
1138 * For a given capture request, the duration from the framework calling
1139 * process_capture_request to the HAL sending capture result and all buffers
1140 * back by process_capture_result call. To make the Pipeline Latency measure
1141 * independent of frame rate, it is measured by frame count.
1142 *
1143 * For example, when frame rate is 30 (fps), the frame duration (time interval
1144 * between adjacent frame capture time) is 33 (ms).
1145 * If it takes 5 frames for framework to get the result and buffers back for
1146 * a given request, then the Pipeline Latency is 5 (frames), instead of
1147 * 5 x 33 = 165 (ms).
1148 *
1149 * The Pipeline Latency is determined by android.request.pipelineDepth and
1150 * android.request.pipelineMaxDepth, see their definitions for more details.
1151 *
1152 */
1153
Zhijun Hebc358682014-01-23 14:42:54 -08001154/**
1155 * S8. Sample Use Cases:
1156 *
1157 * This includes some typical use case examples the camera HAL may support.
1158 *
Zhijun Heb2bc0e52015-01-29 14:44:37 -08001159 * S8.1 Zero Shutter Lag (ZSL) with CAMERA3_STREAM_BIDIRECTIONAL stream.
Zhijun Hebc358682014-01-23 14:42:54 -08001160 *
1161 * For this use case, the bidirectional stream will be used by the framework as follows:
1162 *
1163 * 1. The framework includes a buffer from this stream as output buffer in a
1164 * request as normal.
1165 *
1166 * 2. Once the HAL device returns a filled output buffer to the framework,
1167 * the framework may do one of two things with the filled buffer:
1168 *
1169 * 2. a. The framework uses the filled data, and returns the now-used buffer
1170 * to the stream queue for reuse. This behavior exactly matches the
1171 * OUTPUT type of stream.
1172 *
1173 * 2. b. The framework wants to reprocess the filled data, and uses the
1174 * buffer as an input buffer for a request. Once the HAL device has
1175 * used the reprocessing buffer, it then returns it to the
1176 * framework. The framework then returns the now-used buffer to the
1177 * stream queue for reuse.
1178 *
1179 * 3. The HAL device will be given the buffer again as an output buffer for
1180 * a request at some future point.
1181 *
1182 * For ZSL use case, the pixel format for bidirectional stream will be
Zhijun He52a18892014-06-30 10:35:58 -07001183 * HAL_PIXEL_FORMAT_RAW_OPAQUE or HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED if it
1184 * is listed in android.scaler.availableInputOutputFormatsMap. When
1185 * HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED is used, the gralloc
1186 * usage flags for the consumer endpoint will be set to GRALLOC_USAGE_HW_CAMERA_ZSL.
1187 * A configuration stream list that has BIDIRECTIONAL stream used as input, will
1188 * usually also have a distinct OUTPUT stream to get the reprocessing data. For example,
1189 * for the ZSL use case, the stream list might be configured with the following:
Zhijun Hebc358682014-01-23 14:42:54 -08001190 *
1191 * - A HAL_PIXEL_FORMAT_RAW_OPAQUE bidirectional stream is used
1192 * as input.
1193 * - And a HAL_PIXEL_FORMAT_BLOB (JPEG) output stream.
1194 *
Zhijun Heebdf1282015-01-16 16:44:40 -08001195 * S8.2 ZSL (OPAQUE) reprocessing with CAMERA3_STREAM_INPUT stream.
1196 *
1197 * CAMERA_DEVICE_API_VERSION_3_3:
1198 * When OPAQUE_REPROCESSING capability is supported by the camera device, the INPUT stream
1199 * can be used for application/framework implemented use case like Zero Shutter Lag (ZSL).
1200 * This kind of stream will be used by the framework as follows:
1201 *
1202 * 1. Application/framework configures an opaque (RAW or YUV based) format output stream that is
1203 * used to produce the ZSL output buffers. The stream pixel format will be
1204 * HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED.
1205 *
1206 * 2. Application/framework configures an opaque format input stream that is used to
1207 * send the reprocessing ZSL buffers to the HAL. The stream pixel format will
1208 * also be HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED.
1209 *
1210 * 3. Application/framework configures a YUV/JPEG output stream that is used to receive the
1211 * reprocessed data. The stream pixel format will be YCbCr_420/HAL_PIXEL_FORMAT_BLOB.
1212 *
1213 * 4. Application/framework picks a ZSL buffer from the ZSL output stream when a ZSL capture is
1214 * issued by the application, and sends the data back as an input buffer in a
1215 * reprocessing request, then sends to the HAL for reprocessing.
1216 *
1217 * 5. The HAL sends back the output YUV/JPEG result to framework.
1218 *
1219 * The HAL can select the actual opaque buffer format and configure the ISP pipeline
1220 * appropriately based on the HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED format and
1221 * the gralloc usage flag GRALLOC_USAGE_HW_CAMERA_ZSL.
1222
1223 * S8.3 YUV reprocessing with CAMERA3_STREAM_INPUT stream.
1224 *
1225 * When YUV reprocessing is supported by the HAL, the INPUT stream
1226 * can be used for the YUV reprocessing use cases like lucky-shot and image fusion.
1227 * This kind of stream will be used by the framework as follows:
1228 *
1229 * 1. Application/framework configures an YCbCr_420 format output stream that is
1230 * used to produce the output buffers.
1231 *
1232 * 2. Application/framework configures an YCbCr_420 format input stream that is used to
1233 * send the reprocessing YUV buffers to the HAL.
1234 *
1235 * 3. Application/framework configures a YUV/JPEG output stream that is used to receive the
1236 * reprocessed data. The stream pixel format will be YCbCr_420/HAL_PIXEL_FORMAT_BLOB.
1237 *
1238 * 4. Application/framework processes the output buffers (could be as simple as picking
1239 * an output buffer directly) from the output stream when a capture is issued, and sends
1240 * the data back as an input buffer in a reprocessing request, then sends to the HAL
1241 * for reprocessing.
1242 *
1243 * 5. The HAL sends back the output YUV/JPEG result to framework.
1244 *
Zhijun Hebc358682014-01-23 14:42:54 -08001245 */
1246
Ruben Brunk2d96c742014-03-18 13:39:17 -07001247/**
1248 * S9. Notes on Controls and Metadata
1249 *
1250 * This section contains notes about the interpretation and usage of various metadata tags.
1251 *
1252 * S9.1 HIGH_QUALITY and FAST modes.
1253 *
1254 * Many camera post-processing blocks may be listed as having HIGH_QUALITY,
1255 * FAST, and OFF operating modes. These blocks will typically also have an
1256 * 'available modes' tag representing which of these operating modes are
1257 * available on a given device. The general policy regarding implementing
1258 * these modes is as follows:
1259 *
1260 * 1. Operating mode controls of hardware blocks that cannot be disabled
1261 * must not list OFF in their corresponding 'available modes' tags.
1262 *
1263 * 2. OFF will always be included in their corresponding 'available modes'
1264 * tag if it is possible to disable that hardware block.
1265 *
1266 * 3. FAST must always be included in the 'available modes' tags for all
1267 * post-processing blocks supported on the device. If a post-processing
1268 * block also has a slower and higher quality operating mode that does
1269 * not meet the framerate requirements for FAST mode, HIGH_QUALITY should
1270 * be included in the 'available modes' tag to represent this operating
1271 * mode.
1272 */
Zhijun Heebdf1282015-01-16 16:44:40 -08001273
1274/**
1275 * S10. Reprocessing flow and controls
1276 *
1277 * This section describes the OPAQUE and YUV reprocessing flow and controls. OPAQUE reprocessing
1278 * uses an opaque format that is not directly application-visible, and the application can
1279 * only select some of the output buffers and send back to HAL for reprocessing, while YUV
1280 * reprocessing gives the application opportunity to process the buffers before reprocessing.
1281 *
1282 * S8 gives the stream configurations for the typical reprocessing uses cases,
1283 * this section specifies the buffer flow and controls in more details.
1284 *
1285 * S10.1 OPAQUE (typically for ZSL use case) reprocessing flow and controls
1286 *
1287 * For OPAQUE reprocessing (e.g. ZSL) use case, after the application creates the specific
1288 * output and input streams, runtime buffer flow and controls are specified as below:
1289 *
1290 * 1. Application starts output streaming by sending repeating requests for output
1291 * opaque buffers and preview. The buffers are held by an application
1292 * maintained circular buffer. The requests are based on CAMERA3_TEMPLATE_ZERO_SHUTTER_LAG
1293 * capture template, which should have all necessary settings that guarantee output
1294 * frame rate is not slowed down relative to sensor output frame rate.
1295 *
1296 * 2. When a capture is issued, the application selects one output buffer based
1297 * on application buffer selection logic, e.g. good AE and AF statistics etc.
1298 * Application then creates an reprocess request based on the capture result associated
1299 * with this selected buffer. The selected output buffer is now added to this reprocess
1300 * request as an input buffer, the output buffer of this reprocess request should be
1301 * either JPEG output buffer or YUV output buffer, or both, depending on the application
1302 * choice.
1303 *
1304 * 3. Application then alters the reprocess settings to get best image quality. The HAL must
1305 * support and only support below controls if the HAL support OPAQUE_REPROCESSING capability:
1306 * - android.jpeg.* (if JPEG buffer is included as one of the output)
1307 * - android.noiseReduction.mode (change to HIGH_QUALITY if it is supported)
1308 * - android.edge.mode (change to HIGH_QUALITY if it is supported)
1309 * All other controls must be ignored by the HAL.
1310 * 4. HAL processed the input buffer and return the output buffers in the capture results
1311 * as normal.
1312 *
1313 * S10.2 YUV reprocessing flow and controls
1314 *
1315 * The YUV reprocessing buffer flow is similar as OPAQUE reprocessing, with below difference:
1316 *
1317 * 1. Application may want to have finer granularity control of the intermediate YUV images
1318 * (before reprocessing). For example, application may choose
1319 * - android.noiseReduction.mode == MINIMAL
1320 * to make sure the no YUV domain noise reduction has applied to the output YUV buffers,
1321 * then it can do its own advanced noise reduction on them. For OPAQUE reprocessing case, this
1322 * doesn't matter, as long as the final reprocessed image has the best quality.
1323 * 2. Application may modify the YUV output buffer data. For example, for image fusion use
1324 * case, where multiple output images are merged together to improve the signal-to-noise
1325 * ratio (SNR). The input buffer may be generated from multiple buffers by the application.
1326 * To avoid excessive amount of noise reduction and insufficient amount of edge enhancement
1327 * being applied to the input buffer, the application can hint the HAL how much effective
1328 * exposure time improvement has been done by the application, then the HAL can adjust the
Yin-Chia Yeh875df2a2018-09-20 15:05:13 -07001329 * noise reduction and edge enhancement parameters to get best reprocessed image quality.
Zhijun Heebdf1282015-01-16 16:44:40 -08001330 * Below tag can be used for this purpose:
1331 * - android.reprocess.effectiveExposureFactor
1332 * The value would be exposure time increase factor applied to the original output image,
1333 * for example, if there are N image merged, the exposure time increase factor would be up
1334 * to sqrt(N). See this tag spec for more details.
1335 *
1336 * S10.3 Reprocessing pipeline characteristics
1337 *
1338 * Reprocessing pipeline has below different characteristics comparing with normal output
1339 * pipeline:
1340 *
1341 * 1. The reprocessing result can be returned ahead of the pending normal output results. But
1342 * the FIFO ordering must be maintained for all reprocessing results. For example, there are
1343 * below requests (A stands for output requests, B stands for reprocessing requests)
1344 * being processed by the HAL:
1345 * A1, A2, A3, A4, B1, A5, B2, A6...
1346 * result of B1 can be returned before A1-A4, but result of B2 must be returned after B1.
1347 * 2. Single input rule: For a given reprocessing request, all output buffers must be from the
1348 * input buffer, rather than sensor output. For example, if a reprocess request include both
1349 * JPEG and preview buffers, all output buffers must be produced from the input buffer
1350 * included by the reprocessing request, rather than sensor. The HAL must not output preview
1351 * buffers from sensor, while output JPEG buffer from the input buffer.
1352 * 3. Input buffer will be from camera output directly (ZSL case) or indirectly(image fusion
1353 * case). For the case where buffer is modified, the size will remain same. The HAL can
1354 * notify CAMERA3_MSG_ERROR_REQUEST if buffer from unknown source is sent.
1355 * 4. Result as reprocessing request: The HAL can expect that a reprocessing request is a copy
1356 * of one of the output results with minor allowed setting changes. The HAL can notify
1357 * CAMERA3_MSG_ERROR_REQUEST if a request from unknown source is issued.
1358 * 5. Output buffers may not be used as inputs across the configure stream boundary, This is
1359 * because an opaque stream like the ZSL output stream may have different actual image size
1360 * inside of the ZSL buffer to save power and bandwidth for smaller resolution JPEG capture.
1361 * The HAL may notify CAMERA3_MSG_ERROR_REQUEST if this case occurs.
1362 * 6. HAL Reprocess requests error reporting during flush should follow the same rule specified
1363 * by flush() method.
1364 *
1365 */
1366
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001367__BEGIN_DECLS
1368
1369struct camera3_device;
1370
1371/**********************************************************************
1372 *
1373 * Camera3 stream and stream buffer definitions.
1374 *
1375 * These structs and enums define the handles and contents of the input and
1376 * output streams connecting the HAL to various framework and application buffer
1377 * consumers. Each stream is backed by a gralloc buffer queue.
1378 *
1379 */
1380
1381/**
1382 * camera3_stream_type_t:
1383 *
1384 * The type of the camera stream, which defines whether the camera HAL device is
1385 * the producer or the consumer for that stream, and how the buffers of the
1386 * stream relate to the other streams.
1387 */
1388typedef enum camera3_stream_type {
1389 /**
1390 * This stream is an output stream; the camera HAL device will be
1391 * responsible for filling buffers from this stream with newly captured or
1392 * reprocessed image data.
1393 */
1394 CAMERA3_STREAM_OUTPUT = 0,
1395
1396 /**
1397 * This stream is an input stream; the camera HAL device will be responsible
1398 * for reading buffers from this stream and sending them through the camera
1399 * processing pipeline, as if the buffer was a newly captured image from the
1400 * imager.
Zhijun Hebc358682014-01-23 14:42:54 -08001401 *
1402 * The pixel format for input stream can be any format reported by
Eino-Ville Talvalac5bff0d2014-02-10 16:43:26 -08001403 * android.scaler.availableInputOutputFormatsMap. The pixel format of the
1404 * output stream that is used to produce the reprocessing data may be any
1405 * format reported by android.scaler.availableStreamConfigurations. The
1406 * supported input/output stream combinations depends the camera device
1407 * capabilities, see android.scaler.availableInputOutputFormatsMap for
1408 * stream map details.
Zhijun Hebc358682014-01-23 14:42:54 -08001409 *
Eino-Ville Talvalac5bff0d2014-02-10 16:43:26 -08001410 * This kind of stream is generally used to reprocess data into higher
1411 * quality images (that otherwise would cause a frame rate performance
1412 * loss), or to do off-line reprocessing.
Zhijun Hebc358682014-01-23 14:42:54 -08001413 *
Zhijun Heebdf1282015-01-16 16:44:40 -08001414 * CAMERA_DEVICE_API_VERSION_3_3:
1415 * The typical use cases are OPAQUE (typically ZSL) and YUV reprocessing,
1416 * see S8.2, S8.3 and S10 for more details.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001417 */
1418 CAMERA3_STREAM_INPUT = 1,
1419
1420 /**
1421 * This stream can be used for input and output. Typically, the stream is
1422 * used as an output stream, but occasionally one already-filled buffer may
1423 * be sent back to the HAL device for reprocessing.
1424 *
Eino-Ville Talvalac5bff0d2014-02-10 16:43:26 -08001425 * This kind of stream is meant generally for Zero Shutter Lag (ZSL)
1426 * features, where copying the captured image from the output buffer to the
Zhijun Heb2bc0e52015-01-29 14:44:37 -08001427 * reprocessing input buffer would be expensive. See S8.1 for more details.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001428 *
1429 * Note that the HAL will always be reprocessing data it produced.
1430 *
1431 */
1432 CAMERA3_STREAM_BIDIRECTIONAL = 2,
1433
1434 /**
1435 * Total number of framework-defined stream types
1436 */
1437 CAMERA3_NUM_STREAM_TYPES
1438
1439} camera3_stream_type_t;
1440
1441/**
Yin-Chia Yehe0042082015-03-09 12:15:36 -07001442 * camera3_stream_rotation_t:
1443 *
1444 * The required counterclockwise rotation of camera stream.
1445 */
1446typedef enum camera3_stream_rotation {
1447 /* No rotation */
1448 CAMERA3_STREAM_ROTATION_0 = 0,
1449
1450 /* Rotate by 90 degree counterclockwise */
1451 CAMERA3_STREAM_ROTATION_90 = 1,
1452
1453 /* Rotate by 180 degree counterclockwise */
1454 CAMERA3_STREAM_ROTATION_180 = 2,
1455
1456 /* Rotate by 270 degree counterclockwise */
1457 CAMERA3_STREAM_ROTATION_270 = 3
1458} camera3_stream_rotation_t;
1459
1460/**
Zhijun He21126b72015-05-22 18:12:28 -07001461 * camera3_stream_configuration_mode_t:
1462 *
1463 * This defines the general operation mode for the HAL (for a given stream configuration), where
1464 * modes besides NORMAL have different semantics, and usually limit the generality of the API in
1465 * exchange for higher performance in some particular area.
1466 */
1467typedef enum camera3_stream_configuration_mode {
1468 /**
1469 * Normal stream configuration operation mode. This is the default camera operation mode,
1470 * where all semantics of HAL APIs and metadata controls apply.
1471 */
1472 CAMERA3_STREAM_CONFIGURATION_NORMAL_MODE = 0,
1473
1474 /**
1475 * Special constrained high speed operation mode for devices that can not support high
1476 * speed output in NORMAL mode. All streams in this configuration are operating at high speed
1477 * mode and have different characteristics and limitations to achieve high speed output.
1478 * The NORMAL mode can still be used for high speed output if the HAL can support high speed
1479 * output while satisfying all the semantics of HAL APIs and metadata controls. It is
1480 * recommended for the HAL to support high speed output in NORMAL mode (by advertising the high
1481 * speed FPS ranges in android.control.aeAvailableTargetFpsRanges) if possible.
1482 *
1483 * This mode has below limitations/requirements:
1484 *
1485 * 1. The HAL must support up to 2 streams with sizes reported by
1486 * android.control.availableHighSpeedVideoConfigurations.
1487 * 2. In this mode, the HAL is expected to output up to 120fps or higher. This mode must
1488 * support the targeted FPS range and size configurations reported by
1489 * android.control.availableHighSpeedVideoConfigurations.
1490 * 3. The HAL must support HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED output stream format.
1491 * 4. To achieve efficient high speed streaming, the HAL may have to aggregate
1492 * multiple frames together and send to camera device for processing where the request
1493 * controls are same for all the frames in this batch (batch mode). The HAL must support
1494 * max batch size and the max batch size requirements defined by
1495 * android.control.availableHighSpeedVideoConfigurations.
1496 * 5. In this mode, the HAL must override aeMode, awbMode, and afMode to ON, ON, and
1497 * CONTINUOUS_VIDEO, respectively. All post-processing block mode controls must be
1498 * overridden to be FAST. Therefore, no manual control of capture and post-processing
1499 * parameters is possible. All other controls operate the same as when
1500 * android.control.mode == AUTO. This means that all other android.control.* fields
1501 * must continue to work, such as
1502 *
1503 * android.control.aeTargetFpsRange
1504 * android.control.aeExposureCompensation
1505 * android.control.aeLock
1506 * android.control.awbLock
1507 * android.control.effectMode
1508 * android.control.aeRegions
1509 * android.control.afRegions
1510 * android.control.awbRegions
1511 * android.control.afTrigger
1512 * android.control.aePrecaptureTrigger
1513 *
1514 * Outside of android.control.*, the following controls must work:
1515 *
1516 * android.flash.mode (TORCH mode only, automatic flash for still capture will not work
1517 * since aeMode is ON)
1518 * android.lens.opticalStabilizationMode (if it is supported)
1519 * android.scaler.cropRegion
1520 * android.statistics.faceDetectMode (if it is supported)
Shuzhen Wang13a19e12017-03-08 16:41:13 -08001521 * 6. To reduce the amount of data passed across process boundaries at
1522 * high frame rate, within one batch, camera framework only propagates
1523 * the last shutter notify and the last capture results (including partial
1524 * results and final result) to the app. The shutter notifies and capture
1525 * results for the other requests in the batch are derived by
1526 * the camera framework. As a result, the HAL can return empty metadata
1527 * except for the last result in the batch.
Zhijun He21126b72015-05-22 18:12:28 -07001528 *
1529 * For more details about high speed stream requirements, see
1530 * android.control.availableHighSpeedVideoConfigurations and CONSTRAINED_HIGH_SPEED_VIDEO
1531 * capability defined in android.request.availableCapabilities.
1532 *
1533 * This mode only needs to be supported by HALs that include CONSTRAINED_HIGH_SPEED_VIDEO in
1534 * the android.request.availableCapabilities static metadata.
1535 */
1536 CAMERA3_STREAM_CONFIGURATION_CONSTRAINED_HIGH_SPEED_MODE = 1,
1537
1538 /**
1539 * First value for vendor-defined stream configuration modes.
1540 */
1541 CAMERA3_VENDOR_STREAM_CONFIGURATION_MODE_START = 0x8000
1542} camera3_stream_configuration_mode_t;
1543
1544/**
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001545 * camera3_stream_t:
1546 *
1547 * A handle to a single camera input or output stream. A stream is defined by
1548 * the framework by its buffer resolution and format, and additionally by the
1549 * HAL with the gralloc usage flags and the maximum in-flight buffer count.
1550 *
1551 * The stream structures are owned by the framework, but pointers to a
1552 * camera3_stream passed into the HAL by configure_streams() are valid until the
1553 * end of the first subsequent configure_streams() call that _does not_ include
1554 * that camera3_stream as an argument, or until the end of the close() call.
1555 *
1556 * All camera3_stream framework-controlled members are immutable once the
1557 * camera3_stream is passed into configure_streams(). The HAL may only change
1558 * the HAL-controlled parameters during a configure_streams() call, except for
1559 * the contents of the private pointer.
1560 *
1561 * If a configure_streams() call returns a non-fatal error, all active streams
1562 * remain valid as if configure_streams() had not been called.
1563 *
1564 * The endpoint of the stream is not visible to the camera HAL device.
Alex Ray2ce219a2013-06-14 15:09:30 -07001565 * In DEVICE_API_VERSION_3_1, this was changed to share consumer usage flags
1566 * on streams where the camera is a producer (OUTPUT and BIDIRECTIONAL stream
1567 * types) see the usage field below.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001568 */
1569typedef struct camera3_stream {
1570
1571 /*****
1572 * Set by framework before configure_streams()
1573 */
1574
1575 /**
1576 * The type of the stream, one of the camera3_stream_type_t values.
1577 */
1578 int stream_type;
1579
1580 /**
1581 * The width in pixels of the buffers in this stream
1582 */
1583 uint32_t width;
1584
1585 /**
1586 * The height in pixels of the buffers in this stream
1587 */
1588 uint32_t height;
1589
1590 /**
1591 * The pixel format for the buffers in this stream. Format is a value from
1592 * the HAL_PIXEL_FORMAT_* list in system/core/include/system/graphics.h, or
1593 * from device-specific headers.
1594 *
1595 * If HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED is used, then the platform
1596 * gralloc module will select a format based on the usage flags provided by
1597 * the camera device and the other endpoint of the stream.
1598 *
Igor Murashkin78aa1262014-01-09 16:23:43 -08001599 * <= CAMERA_DEVICE_API_VERSION_3_1:
1600 *
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001601 * The camera HAL device must inspect the buffers handed to it in the
1602 * subsequent register_stream_buffers() call to obtain the
1603 * implementation-specific format details, if necessary.
Igor Murashkin78aa1262014-01-09 16:23:43 -08001604 *
1605 * >= CAMERA_DEVICE_API_VERSION_3_2:
1606 *
1607 * register_stream_buffers() won't be called by the framework, so the HAL
1608 * should configure the ISP and sensor pipeline based purely on the sizes,
1609 * usage flags, and formats for the configured streams.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001610 */
1611 int format;
1612
1613 /*****
1614 * Set by HAL during configure_streams().
1615 */
1616
1617 /**
1618 * The gralloc usage flags for this stream, as needed by the HAL. The usage
1619 * flags are defined in gralloc.h (GRALLOC_USAGE_*), or in device-specific
1620 * headers.
1621 *
1622 * For output streams, these are the HAL's producer usage flags. For input
1623 * streams, these are the HAL's consumer usage flags. The usage flags from
1624 * the producer and the consumer will be combined together and then passed
1625 * to the platform gralloc HAL module for allocating the gralloc buffers for
1626 * each stream.
Alex Ray2ce219a2013-06-14 15:09:30 -07001627 *
1628 * Version information:
1629 *
1630 * == CAMERA_DEVICE_API_VERSION_3_0:
1631 *
1632 * No initial value guaranteed when passed via configure_streams().
1633 * HAL may not use this field as input, and must write over this field
1634 * with its usage flags.
1635 *
1636 * >= CAMERA_DEVICE_API_VERSION_3_1:
1637 *
1638 * For stream_type OUTPUT and BIDIRECTIONAL, when passed via
1639 * configure_streams(), the initial value of this is the consumer's
1640 * usage flags. The HAL may use these consumer flags to decide stream
1641 * configuration.
1642 * For stream_type INPUT, when passed via configure_streams(), the initial
1643 * value of this is 0.
1644 * For all streams passed via configure_streams(), the HAL must write
1645 * over this field with its usage flags.
Shuzhen Wang07a5cd52017-03-20 09:26:42 -07001646 *
1647 * From Android O, the usage flag for an output stream may be bitwise
1648 * combination of usage flags for multiple consumers, for the purpose of
1649 * sharing one camera stream between those consumers. The HAL must fail
1650 * configure_streams call with -EINVAL if the combined flags cannot be
1651 * supported due to imcompatible buffer format, dataSpace, or other hardware
1652 * limitations.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001653 */
1654 uint32_t usage;
1655
1656 /**
1657 * The maximum number of buffers the HAL device may need to have dequeued at
1658 * the same time. The HAL device may not have more buffers in-flight from
1659 * this stream than this value.
1660 */
1661 uint32_t max_buffers;
1662
1663 /**
1664 * A handle to HAL-private information for the stream. Will not be inspected
1665 * by the framework code.
1666 */
1667 void *priv;
1668
Eino-Ville Talvala453c7902015-03-06 13:22:03 -08001669 /**
1670 * A field that describes the contents of the buffer. The format and buffer
1671 * dimensions define the memory layout and structure of the stream buffers,
1672 * while dataSpace defines the meaning of the data within the buffer.
1673 *
1674 * For most formats, dataSpace defines the color space of the image data.
1675 * In addition, for some formats, dataSpace indicates whether image- or
1676 * depth-based data is requested. See system/core/include/system/graphics.h
1677 * for details of formats and valid dataSpace values for each format.
1678 *
1679 * Version information:
1680 *
1681 * < CAMERA_DEVICE_API_VERSION_3_3:
1682 *
1683 * Not defined and should not be accessed. dataSpace should be assumed to
1684 * be HAL_DATASPACE_UNKNOWN, and the appropriate color space, etc, should
1685 * be determined from the usage flags and the format.
1686 *
Eino-Ville Talvalacd86b0d2016-03-06 17:08:40 -08001687 * = CAMERA_DEVICE_API_VERSION_3_3:
Eino-Ville Talvala453c7902015-03-06 13:22:03 -08001688 *
1689 * Always set by the camera service. HAL must use this dataSpace to
1690 * configure the stream to the correct colorspace, or to select between
Eino-Ville Talvalacd86b0d2016-03-06 17:08:40 -08001691 * color and depth outputs if supported. The dataspace values are the
1692 * legacy definitions in graphics.h
1693 *
1694 * >= CAMERA_DEVICE_API_VERSION_3_4:
1695 *
1696 * Always set by the camera service. HAL must use this dataSpace to
1697 * configure the stream to the correct colorspace, or to select between
1698 * color and depth outputs if supported. The dataspace values are set
1699 * using the V0 dataspace definitions in graphics.h
Eino-Ville Talvala453c7902015-03-06 13:22:03 -08001700 */
1701 android_dataspace_t data_space;
1702
Yin-Chia Yehe0042082015-03-09 12:15:36 -07001703 /**
1704 * The required output rotation of the stream, one of
1705 * the camera3_stream_rotation_t values. This must be inspected by HAL along
1706 * with stream width and height. For example, if the rotation is 90 degree
1707 * and the stream width and height is 720 and 1280 respectively, camera service
1708 * will supply buffers of size 720x1280, and HAL should capture a 1280x720 image
Yin-Chia Yeh5407ef12015-03-12 15:09:27 -07001709 * and rotate the image by 90 degree counterclockwise. The rotation field is
1710 * no-op when the stream type is input. Camera HAL must ignore the rotation
1711 * field for an input stream.
Yin-Chia Yehe0042082015-03-09 12:15:36 -07001712 *
1713 * <= CAMERA_DEVICE_API_VERSION_3_2:
1714 *
1715 * Not defined and must not be accessed. HAL must not apply any rotation
1716 * on output images.
1717 *
1718 * >= CAMERA_DEVICE_API_VERSION_3_3:
1719 *
1720 * Always set by camera service. HAL must inspect this field during stream
1721 * configuration and returns -EINVAL if HAL cannot perform such rotation.
1722 * HAL must always support CAMERA3_STREAM_ROTATION_0, so a
1723 * configure_streams() call must not fail for unsupported rotation if
1724 * rotation field of all streams is CAMERA3_STREAM_ROTATION_0.
1725 *
1726 */
1727 int rotation;
1728
Shuzhen Wangbf39eb52017-11-29 15:16:03 -08001729 /**
1730 * The physical camera id this stream belongs to.
1731 *
1732 * <= CAMERA_DEVICE_API_VERISON_3_4:
1733 *
1734 * Not defined and must not be accessed.
1735 *
1736 * >= CAMERA_DEVICE_API_VERISON_3_5:
1737 *
1738 * Always set by camera service. If the camera device is not a logical
1739 * multi camera, or if the camera is a logical multi camera but the stream
1740 * is not a physical output stream, this field will point to a 0-length
1741 * string.
1742 *
1743 * A logical multi camera is a camera device backed by multiple physical
1744 * cameras that are also exposed to the application. And for a logical
1745 * multi camera, a physical output stream is an output stream specifically
1746 * requested on an underlying physical camera.
1747 *
1748 * For an input stream, this field is guaranteed to be a 0-length string.
1749 */
1750 const char* physical_camera_id;
1751
Eino-Ville Talvala453c7902015-03-06 13:22:03 -08001752 /* reserved for future use */
Shuzhen Wangbf39eb52017-11-29 15:16:03 -08001753 void *reserved[6];
Eino-Ville Talvala453c7902015-03-06 13:22:03 -08001754
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001755} camera3_stream_t;
1756
1757/**
1758 * camera3_stream_configuration_t:
1759 *
1760 * A structure of stream definitions, used by configure_streams(). This
1761 * structure defines all the output streams and the reprocessing input
1762 * stream for the current camera use case.
1763 */
1764typedef struct camera3_stream_configuration {
1765 /**
1766 * The total number of streams requested by the framework. This includes
1767 * both input and output streams. The number of streams will be at least 1,
1768 * and there will be at least one output-capable stream.
1769 */
1770 uint32_t num_streams;
1771
1772 /**
Eino-Ville Talvala3a6e6b42013-03-06 13:21:11 -08001773 * An array of camera stream pointers, defining the input/output
1774 * configuration for the camera HAL device.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001775 *
1776 * At most one input-capable stream may be defined (INPUT or BIDIRECTIONAL)
1777 * in a single configuration.
1778 *
1779 * At least one output-capable stream must be defined (OUTPUT or
1780 * BIDIRECTIONAL).
1781 */
Eino-Ville Talvala3a6e6b42013-03-06 13:21:11 -08001782 camera3_stream_t **streams;
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001783
Zhijun He21126b72015-05-22 18:12:28 -07001784 /**
1785 * >= CAMERA_DEVICE_API_VERSION_3_3:
1786 *
Eino-Ville Talvalacd86b0d2016-03-06 17:08:40 -08001787 * The operation mode of streams in this configuration, one of the value
1788 * defined in camera3_stream_configuration_mode_t. The HAL can use this
1789 * mode as an indicator to set the stream property (e.g.,
1790 * camera3_stream->max_buffers) appropriately. For example, if the
1791 * configuration is
1792 * CAMERA3_STREAM_CONFIGURATION_CONSTRAINED_HIGH_SPEED_MODE, the HAL may
1793 * want to set aside more buffers for batch mode operation (see
1794 * android.control.availableHighSpeedVideoConfigurations for batch mode
1795 * definition).
Zhijun He21126b72015-05-22 18:12:28 -07001796 *
1797 */
1798 uint32_t operation_mode;
Emilian Peeveec2ee92017-11-08 19:33:27 +00001799
1800 /**
1801 * >= CAMERA_DEVICE_API_VERSION_3_5:
1802 *
1803 * The session metadata buffer contains the initial values of
1804 * ANDROID_REQUEST_AVAILABLE_SESSION_KEYS. This field is optional
1805 * and camera clients can choose to ignore it, in which case it will
1806 * be set to NULL. If parameters are present, then Hal should examine
1807 * the parameter values and configure its internal camera pipeline
1808 * accordingly.
1809 */
1810 const camera_metadata_t *session_parameters;
Yin-Chia Yeh875df2a2018-09-20 15:05:13 -07001811
1812 /**
1813 * >= CAMERA_DEVICE_API_VERSION_3_6:
1814 *
1815 * An incrementing counter used for HAL to keep track of the stream
1816 * configuration and the paired oneway signal_stream_flush call. When the
1817 * counter in signal_stream_flush call is less than the counter here, that
1818 * signal_stream_flush call is stale.
1819 */
1820 int32_t stream_configuration_counter;
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001821} camera3_stream_configuration_t;
1822
1823/**
Eino-Ville Talvala2f8cf5c2013-03-06 13:23:31 -08001824 * camera3_buffer_status_t:
1825 *
1826 * The current status of a single stream buffer.
1827 */
1828typedef enum camera3_buffer_status {
1829 /**
1830 * The buffer is in a normal state, and can be used after waiting on its
1831 * sync fence.
1832 */
1833 CAMERA3_BUFFER_STATUS_OK = 0,
1834
1835 /**
1836 * The buffer does not contain valid data, and the data in it should not be
1837 * used. The sync fence must still be waited on before reusing the buffer.
1838 */
1839 CAMERA3_BUFFER_STATUS_ERROR = 1
1840
1841} camera3_buffer_status_t;
1842
1843/**
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001844 * camera3_stream_buffer_t:
1845 *
1846 * A single buffer from a camera3 stream. It includes a handle to its parent
1847 * stream, the handle to the gralloc buffer itself, and sync fences
1848 *
1849 * The buffer does not specify whether it is to be used for input or output;
1850 * that is determined by its parent stream type and how the buffer is passed to
1851 * the HAL device.
1852 */
1853typedef struct camera3_stream_buffer {
1854 /**
1855 * The handle of the stream this buffer is associated with
1856 */
1857 camera3_stream_t *stream;
1858
1859 /**
1860 * The native handle to the buffer
1861 */
1862 buffer_handle_t *buffer;
1863
1864 /**
Eino-Ville Talvala2f8cf5c2013-03-06 13:23:31 -08001865 * Current state of the buffer, one of the camera3_buffer_status_t
1866 * values. The framework will not pass buffers to the HAL that are in an
1867 * error state. In case a buffer could not be filled by the HAL, it must
1868 * have its status set to CAMERA3_BUFFER_STATUS_ERROR when returned to the
1869 * framework with process_capture_result().
1870 */
1871 int status;
1872
1873 /**
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001874 * The acquire sync fence for this buffer. The HAL must wait on this fence
1875 * fd before attempting to read from or write to this buffer.
1876 *
1877 * The framework may be set to -1 to indicate that no waiting is necessary
Eino-Ville Talvala2f8cf5c2013-03-06 13:23:31 -08001878 * for this buffer.
1879 *
1880 * When the HAL returns an output buffer to the framework with
1881 * process_capture_result(), the acquire_fence must be set to -1. If the HAL
1882 * never waits on the acquire_fence due to an error in filling a buffer,
1883 * when calling process_capture_result() the HAL must set the release_fence
1884 * of the buffer to be the acquire_fence passed to it by the framework. This
1885 * will allow the framework to wait on the fence before reusing the buffer.
1886 *
1887 * For input buffers, the HAL must not change the acquire_fence field during
1888 * the process_capture_request() call.
Zhijun Heceac9e32014-02-05 20:49:45 -08001889 *
1890 * >= CAMERA_DEVICE_API_VERSION_3_2:
1891 *
1892 * When the HAL returns an input buffer to the framework with
1893 * process_capture_result(), the acquire_fence must be set to -1. If the HAL
Eino-Ville Talvalac5bff0d2014-02-10 16:43:26 -08001894 * never waits on input buffer acquire fence due to an error, the sync
1895 * fences should be handled similarly to the way they are handled for output
1896 * buffers.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001897 */
1898 int acquire_fence;
1899
1900 /**
1901 * The release sync fence for this buffer. The HAL must set this fence when
1902 * returning buffers to the framework, or write -1 to indicate that no
1903 * waiting is required for this buffer.
1904 *
Zhijun Heceac9e32014-02-05 20:49:45 -08001905 * For the output buffers, the fences must be set in the output_buffers
1906 * array passed to process_capture_result().
1907 *
1908 * <= CAMERA_DEVICE_API_VERSION_3_1:
1909 *
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001910 * For the input buffer, the release fence must be set by the
Zhijun Heceac9e32014-02-05 20:49:45 -08001911 * process_capture_request() call.
Eino-Ville Talvala2f8cf5c2013-03-06 13:23:31 -08001912 *
Igor Murashkin78aa1262014-01-09 16:23:43 -08001913 * >= CAMERA_DEVICE_API_VERSION_3_2:
1914 *
Zhijun Heceac9e32014-02-05 20:49:45 -08001915 * For the input buffer, the fences must be set in the input_buffer
1916 * passed to process_capture_result().
1917 *
Igor Murashkin78aa1262014-01-09 16:23:43 -08001918 * After signaling the release_fence for this buffer, the HAL
1919 * should not make any further attempts to access this buffer as the
1920 * ownership has been fully transferred back to the framework.
1921 *
1922 * If a fence of -1 was specified then the ownership of this buffer
1923 * is transferred back immediately upon the call of process_capture_result.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001924 */
1925 int release_fence;
1926
1927} camera3_stream_buffer_t;
1928
1929/**
1930 * camera3_stream_buffer_set_t:
1931 *
1932 * The complete set of gralloc buffers for a stream. This structure is given to
1933 * register_stream_buffers() to allow the camera HAL device to register/map/etc
1934 * newly allocated stream buffers.
Igor Murashkin78aa1262014-01-09 16:23:43 -08001935 *
1936 * >= CAMERA_DEVICE_API_VERSION_3_2:
1937 *
1938 * Deprecated (and not used). In particular,
1939 * register_stream_buffers is also deprecated and will never be invoked.
1940 *
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001941 */
1942typedef struct camera3_stream_buffer_set {
1943 /**
1944 * The stream handle for the stream these buffers belong to
1945 */
1946 camera3_stream_t *stream;
1947
1948 /**
1949 * The number of buffers in this stream. It is guaranteed to be at least
1950 * stream->max_buffers.
1951 */
1952 uint32_t num_buffers;
1953
1954 /**
1955 * The array of gralloc buffer handles for this stream. If the stream format
1956 * is set to HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, the camera HAL device
1957 * should inspect the passed-in buffers to determine any platform-private
1958 * pixel format information.
1959 */
Eino-Ville Talvala3a6e6b42013-03-06 13:21:11 -08001960 buffer_handle_t **buffers;
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001961
1962} camera3_stream_buffer_set_t;
1963
1964/**
1965 * camera3_jpeg_blob:
1966 *
1967 * Transport header for compressed JPEG buffers in output streams.
1968 *
1969 * To capture JPEG images, a stream is created using the pixel format
Zhijun He44a89152014-04-24 14:34:53 -07001970 * HAL_PIXEL_FORMAT_BLOB. The buffer size for the stream is calculated by the
1971 * framework, based on the static metadata field android.jpeg.maxSize. Since
1972 * compressed JPEG images are of variable size, the HAL needs to include the
1973 * final size of the compressed image using this structure inside the output
1974 * stream buffer. The JPEG blob ID field must be set to CAMERA3_JPEG_BLOB_ID.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001975 *
Zhijun He44a89152014-04-24 14:34:53 -07001976 * Transport header should be at the end of the JPEG output stream buffer. That
1977 * means the jpeg_blob_id must start at byte[buffer_size -
1978 * sizeof(camera3_jpeg_blob)], where the buffer_size is the size of gralloc buffer.
1979 * Any HAL using this transport header must account for it in android.jpeg.maxSize
1980 * The JPEG data itself starts at the beginning of the buffer and should be
1981 * jpeg_size bytes long.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001982 */
1983typedef struct camera3_jpeg_blob {
1984 uint16_t jpeg_blob_id;
1985 uint32_t jpeg_size;
1986} camera3_jpeg_blob_t;
1987
1988enum {
1989 CAMERA3_JPEG_BLOB_ID = 0x00FF
1990};
1991
1992/**********************************************************************
1993 *
1994 * Message definitions for the HAL notify() callback.
1995 *
1996 * These definitions are used for the HAL notify callback, to signal
1997 * asynchronous events from the HAL device to the Android framework.
1998 *
1999 */
2000
2001/**
2002 * camera3_msg_type:
2003 *
2004 * Indicates the type of message sent, which specifies which member of the
2005 * message union is valid.
2006 *
2007 */
2008typedef enum camera3_msg_type {
2009 /**
2010 * An error has occurred. camera3_notify_msg.message.error contains the
2011 * error information.
2012 */
2013 CAMERA3_MSG_ERROR = 1,
2014
2015 /**
Chien-Yu Chen73b49eb2015-05-28 17:13:05 -07002016 * The exposure of a given request or processing a reprocess request has
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002017 * begun. camera3_notify_msg.message.shutter contains the information
2018 * the capture.
2019 */
2020 CAMERA3_MSG_SHUTTER = 2,
2021
2022 /**
2023 * Number of framework message types
2024 */
2025 CAMERA3_NUM_MESSAGES
2026
2027} camera3_msg_type_t;
2028
2029/**
2030 * Defined error codes for CAMERA_MSG_ERROR
2031 */
2032typedef enum camera3_error_msg_code {
2033 /**
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002034 * A serious failure occured. No further frames or buffer streams will
2035 * be produced by the device. Device should be treated as closed. The
2036 * client must reopen the device to use it again. The frame_number field
2037 * is unused.
2038 */
Alex Rayd5ddbc92013-02-15 13:47:24 -08002039 CAMERA3_MSG_ERROR_DEVICE = 1,
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002040
2041 /**
2042 * An error has occurred in processing a request. No output (metadata or
2043 * buffers) will be produced for this request. The frame_number field
2044 * specifies which request has been dropped. Subsequent requests are
2045 * unaffected, and the device remains operational.
2046 */
Alex Rayd5ddbc92013-02-15 13:47:24 -08002047 CAMERA3_MSG_ERROR_REQUEST = 2,
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002048
2049 /**
2050 * An error has occurred in producing an output result metadata buffer
2051 * for a request, but output stream buffers for it will still be
2052 * available. Subsequent requests are unaffected, and the device remains
2053 * operational. The frame_number field specifies the request for which
2054 * result metadata won't be available.
2055 */
Alex Rayd5ddbc92013-02-15 13:47:24 -08002056 CAMERA3_MSG_ERROR_RESULT = 3,
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002057
2058 /**
2059 * An error has occurred in placing an output buffer into a stream for a
2060 * request. The frame metadata and other buffers may still be
2061 * available. Subsequent requests are unaffected, and the device remains
2062 * operational. The frame_number field specifies the request for which the
2063 * buffer was dropped, and error_stream contains a pointer to the stream
Eino-Ville Talvalacd86b0d2016-03-06 17:08:40 -08002064 * that dropped the frame.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002065 */
Alex Rayd5ddbc92013-02-15 13:47:24 -08002066 CAMERA3_MSG_ERROR_BUFFER = 4,
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002067
2068 /**
2069 * Number of error types
2070 */
2071 CAMERA3_MSG_NUM_ERRORS
2072
2073} camera3_error_msg_code_t;
2074
2075/**
2076 * camera3_error_msg_t:
2077 *
2078 * Message contents for CAMERA3_MSG_ERROR
2079 */
2080typedef struct camera3_error_msg {
2081 /**
2082 * Frame number of the request the error applies to. 0 if the frame number
2083 * isn't applicable to the error.
2084 */
2085 uint32_t frame_number;
2086
2087 /**
2088 * Pointer to the stream that had a failure. NULL if the stream isn't
2089 * applicable to the error.
2090 */
2091 camera3_stream_t *error_stream;
2092
2093 /**
2094 * The code for this error; one of the CAMERA_MSG_ERROR enum values.
2095 */
2096 int error_code;
2097
2098} camera3_error_msg_t;
2099
2100/**
2101 * camera3_shutter_msg_t:
2102 *
2103 * Message contents for CAMERA3_MSG_SHUTTER
2104 */
2105typedef struct camera3_shutter_msg {
2106 /**
Chien-Yu Chen73b49eb2015-05-28 17:13:05 -07002107 * Frame number of the request that has begun exposure or reprocessing.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002108 */
2109 uint32_t frame_number;
2110
2111 /**
Chien-Yu Chen73b49eb2015-05-28 17:13:05 -07002112 * Timestamp for the start of capture. For a reprocess request, this must
2113 * be input image's start of capture. This must match the capture result
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002114 * metadata's sensor exposure start timestamp.
2115 */
2116 uint64_t timestamp;
2117
2118} camera3_shutter_msg_t;
2119
2120/**
2121 * camera3_notify_msg_t:
2122 *
2123 * The message structure sent to camera3_callback_ops_t.notify()
2124 */
2125typedef struct camera3_notify_msg {
2126
2127 /**
2128 * The message type. One of camera3_notify_msg_type, or a private extension.
2129 */
2130 int type;
2131
2132 union {
2133 /**
2134 * Error message contents. Valid if type is CAMERA3_MSG_ERROR
2135 */
2136 camera3_error_msg_t error;
2137
2138 /**
2139 * Shutter message contents. Valid if type is CAMERA3_MSG_SHUTTER
2140 */
2141 camera3_shutter_msg_t shutter;
2142
2143 /**
2144 * Generic message contents. Used to ensure a minimum size for custom
2145 * message types.
2146 */
2147 uint8_t generic[32];
2148 } message;
2149
2150} camera3_notify_msg_t;
2151
Yin-Chia Yeh875df2a2018-09-20 15:05:13 -07002152
2153/**********************************************************************
2154 *
2155 * Types definition for request_stream_buffers() callback.
2156 *
2157 */
2158
2159/**
2160 * camera3_buffer_request_status_t:
2161 *
2162 * The overall buffer request status returned by request_stream_buffers()
2163 */
2164typedef enum camera3_buffer_request_status {
2165 /**
2166 * request_stream_buffers() call succeeded and all requested buffers are
2167 * returned.
2168 */
2169 CAMERA3_BUF_REQ_OK = 0,
2170
2171 /**
2172 * request_stream_buffers() call failed for some streams.
2173 * Check per stream status for each returned camera3_stream_buffer_ret_t.
2174 */
2175 CAMERA3_BUF_REQ_FAILED_PARTIAL = 1,
2176
2177 /**
2178 * request_stream_buffers() call failed for all streams and no buffers are
2179 * returned at all. Camera service is about to or is performing
2180 * configure_streams() call. HAL must wait until next configure_streams()
2181 * call is finished before requesting buffers again.
2182 */
2183 CAMERA3_BUF_REQ_FAILED_CONFIGURING = 2,
2184
2185 /**
2186 * request_stream_buffers() call failed for all streams and no buffers are
2187 * returned at all. Failure due to bad camera3_buffer_request input, eg:
2188 * unknown stream or repeated stream in the list of buffer requests.
2189 */
2190 CAMERA3_BUF_REQ_FAILED_ILLEGAL_ARGUMENTS = 3,
2191
2192 /**
2193 * request_stream_buffers() call failed for all streams and no buffers are
2194 * returned at all due to unknown reason.
2195 */
2196 CAMERA3_BUF_REQ_FAILED_UNKNOWN = 4,
2197
2198 /**
2199 * Number of buffer request status
2200 */
2201 CAMERA3_BUF_REQ_NUM_STATUS
2202
2203} camera3_buffer_request_status_t;
2204
2205/**
2206 * camera3_stream_buffer_req_status_t:
2207 *
2208 * The per stream buffer request status returned by request_stream_buffers()
2209 */
2210typedef enum camera3_stream_buffer_req_status {
2211 /**
2212 * Get buffer succeeds and all requested buffers are returned.
2213 */
2214 CAMERA3_PS_BUF_REQ_OK = 0,
2215
2216 /**
2217 * Get buffer failed due to timeout waiting for an available buffer. This is
2218 * likely due to the client application holding too many buffers, or the
2219 * system is under memory pressure.
2220 * This is not a fatal error. HAL can try to request buffer for this stream
2221 * later. If HAL cannot get a buffer for certain capture request in time
2222 * due to this error, HAL can send an ERROR_REQUEST to camera service and
2223 * drop processing that request.
2224 */
2225 CAMERA3_PS_BUF_REQ_NO_BUFFER_AVAILABLE = 1,
2226
2227 /**
2228 * Get buffer failed due to HAL has reached its maxBuffer count. This is not
2229 * a fatal error. HAL can try to request buffer for this stream again after
2230 * it returns at least one buffer of that stream to camera service.
2231 */
2232 CAMERA3_PS_BUF_REQ_MAX_BUFFER_EXCEEDED = 2,
2233
2234 /**
2235 * Get buffer failed due to the stream is disconnected by client
2236 * application, has been removed, or not recognized by camera service.
2237 * This means application is no longer interested in this stream.
2238 * Requesting buffer for this stream will never succeed after this error is
2239 * returned. HAL must safely return all buffers of this stream after
2240 * getting this error. If HAL gets another capture request later targeting
2241 * a disconnected stream, HAL must send an ERROR_REQUEST to camera service
2242 * and drop processing that request.
2243 */
2244 CAMERA3_PS_BUF_REQ_STREAM_DISCONNECTED = 3,
2245
2246 /**
2247 * Get buffer failed for unknown reason. This is a fatal error and HAL must
2248 * send ERROR_DEVICE to camera service and be ready to be closed.
2249 */
2250 CAMERA3_PS_BUF_REQ_UNKNOWN_ERROR = 4,
2251
2252 /**
2253 * Number of buffer request status
2254 */
2255 CAMERA3_PS_BUF_REQ_NUM_STATUS
2256} camera3_stream_buffer_req_status_t;
2257
2258typedef struct camera3_buffer_request {
2259 /**
2260 * The stream HAL wants to request buffer from
2261 */
2262 camera3_stream_t *stream;
2263
2264 /**
2265 * The number of buffers HAL requested
2266 */
2267 uint32_t num_buffers_requested;
2268} camera3_buffer_request_t;
2269
2270typedef struct camera3_stream_buffer_ret {
2271 /**
2272 * The stream HAL wants to request buffer from
2273 */
2274 camera3_stream_t *stream;
2275
2276 /**
2277 * The status of buffer request of this stream
2278 */
2279 camera3_stream_buffer_req_status_t status;
2280
2281 /**
2282 * Number of output buffers returned. Must be 0 when above status is not
2283 * CAMERA3_PS_BUF_REQ_OK; otherwise the value must be equal to
2284 * num_buffers_requested in the corresponding camera3_buffer_request_t
2285 */
2286 uint32_t num_output_buffers;
2287
2288 /**
2289 * The returned output buffers for the stream.
2290 * Caller of request_stream_buffers() should supply this with enough memory
2291 * (num_buffers_requested * sizeof(camera3_stream_buffer_t))
2292 */
2293 camera3_stream_buffer_t *output_buffers;
2294} camera3_stream_buffer_ret_t;
2295
2296
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002297/**********************************************************************
2298 *
2299 * Capture request/result definitions for the HAL process_capture_request()
2300 * method, and the process_capture_result() callback.
2301 *
2302 */
2303
2304/**
2305 * camera3_request_template_t:
2306 *
2307 * Available template types for
2308 * camera3_device_ops.construct_default_request_settings()
2309 */
2310typedef enum camera3_request_template {
2311 /**
2312 * Standard camera preview operation with 3A on auto.
2313 */
2314 CAMERA3_TEMPLATE_PREVIEW = 1,
2315
2316 /**
2317 * Standard camera high-quality still capture with 3A and flash on auto.
2318 */
2319 CAMERA3_TEMPLATE_STILL_CAPTURE = 2,
2320
2321 /**
2322 * Standard video recording plus preview with 3A on auto, torch off.
2323 */
2324 CAMERA3_TEMPLATE_VIDEO_RECORD = 3,
2325
2326 /**
2327 * High-quality still capture while recording video. Application will
2328 * include preview, video record, and full-resolution YUV or JPEG streams in
2329 * request. Must not cause stuttering on video stream. 3A on auto.
2330 */
2331 CAMERA3_TEMPLATE_VIDEO_SNAPSHOT = 4,
2332
2333 /**
2334 * Zero-shutter-lag mode. Application will request preview and
2335 * full-resolution data for each frame, and reprocess it to JPEG when a
2336 * still image is requested by user. Settings should provide highest-quality
2337 * full-resolution images without compromising preview frame rate. 3A on
2338 * auto.
2339 */
2340 CAMERA3_TEMPLATE_ZERO_SHUTTER_LAG = 5,
2341
Zhijun Heb0c939f2013-12-13 15:56:33 -08002342 /**
2343 * A basic template for direct application control of capture
2344 * parameters. All automatic control is disabled (auto-exposure, auto-white
2345 * balance, auto-focus), and post-processing parameters are set to preview
2346 * quality. The manual capture parameters (exposure, sensitivity, etc.)
2347 * are set to reasonable defaults, but should be overridden by the
2348 * application depending on the intended use case.
2349 */
2350 CAMERA3_TEMPLATE_MANUAL = 6,
2351
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002352 /* Total number of templates */
2353 CAMERA3_TEMPLATE_COUNT,
2354
2355 /**
2356 * First value for vendor-defined request templates
2357 */
2358 CAMERA3_VENDOR_TEMPLATE_START = 0x40000000
2359
2360} camera3_request_template_t;
2361
2362/**
2363 * camera3_capture_request_t:
2364 *
2365 * A single request for image capture/buffer reprocessing, sent to the Camera
2366 * HAL device by the framework in process_capture_request().
2367 *
2368 * The request contains the settings to be used for this capture, and the set of
2369 * output buffers to write the resulting image data in. It may optionally
2370 * contain an input buffer, in which case the request is for reprocessing that
2371 * input buffer instead of capturing a new image with the camera sensor. The
2372 * capture is identified by the frame_number.
2373 *
2374 * In response, the camera HAL device must send a camera3_capture_result
2375 * structure asynchronously to the framework, using the process_capture_result()
2376 * callback.
2377 */
2378typedef struct camera3_capture_request {
2379 /**
2380 * The frame number is an incrementing integer set by the framework to
2381 * uniquely identify this capture. It needs to be returned in the result
2382 * call, and is also used to identify the request in asynchronous
2383 * notifications sent to camera3_callback_ops_t.notify().
2384 */
2385 uint32_t frame_number;
2386
2387 /**
2388 * The settings buffer contains the capture and processing parameters for
2389 * the request. As a special case, a NULL settings buffer indicates that the
2390 * settings are identical to the most-recently submitted capture request. A
2391 * NULL buffer cannot be used as the first submitted request after a
2392 * configure_streams() call.
2393 */
2394 const camera_metadata_t *settings;
2395
2396 /**
2397 * The input stream buffer to use for this request, if any.
2398 *
2399 * If input_buffer is NULL, then the request is for a new capture from the
2400 * imager. If input_buffer is valid, the request is for reprocessing the
2401 * image contained in input_buffer.
2402 *
2403 * In the latter case, the HAL must set the release_fence of the
2404 * input_buffer to a valid sync fence, or to -1 if the HAL does not support
2405 * sync, before process_capture_request() returns.
2406 *
2407 * The HAL is required to wait on the acquire sync fence of the input buffer
2408 * before accessing it.
2409 *
Igor Murashkin78aa1262014-01-09 16:23:43 -08002410 * <= CAMERA_DEVICE_API_VERSION_3_1:
2411 *
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002412 * Any input buffer included here will have been registered with the HAL
2413 * through register_stream_buffers() before its inclusion in a request.
Igor Murashkin78aa1262014-01-09 16:23:43 -08002414 *
2415 * >= CAMERA_DEVICE_API_VERSION_3_2:
2416 *
2417 * The buffers will not have been pre-registered with the HAL.
2418 * Subsequent requests may reuse buffers, or provide entirely new buffers.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002419 */
2420 camera3_stream_buffer_t *input_buffer;
2421
2422 /**
2423 * The number of output buffers for this capture request. Must be at least
2424 * 1.
2425 */
2426 uint32_t num_output_buffers;
2427
2428 /**
2429 * An array of num_output_buffers stream buffers, to be filled with image
2430 * data from this capture/reprocess. The HAL must wait on the acquire fences
Igor Murashkin78aa1262014-01-09 16:23:43 -08002431 * of each stream buffer before writing to them.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002432 *
2433 * The HAL takes ownership of the actual buffer_handle_t entries in
2434 * output_buffers; the framework does not access them until they are
2435 * returned in a camera3_capture_result_t.
Igor Murashkin78aa1262014-01-09 16:23:43 -08002436 *
2437 * <= CAMERA_DEVICE_API_VERSION_3_1:
2438 *
2439 * All the buffers included here will have been registered with the HAL
2440 * through register_stream_buffers() before their inclusion in a request.
2441 *
2442 * >= CAMERA_DEVICE_API_VERSION_3_2:
2443 *
2444 * Any or all of the buffers included here may be brand new in this
2445 * request (having never before seen by the HAL).
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002446 */
2447 const camera3_stream_buffer_t *output_buffers;
2448
Emilian Peev92261ff2018-01-16 15:01:22 +00002449 /**
2450 * <= CAMERA_DEVICE_API_VERISON_3_4:
2451 *
2452 * Not defined and must not be accessed.
2453 *
2454 * >= CAMERA_DEVICE_API_VERSION_3_5:
2455 * The number of physical camera settings to be applied. If 'num_physcam_settings'
2456 * equals 0 or a physical device is not included, then Hal must decide the
2457 * specific physical device settings based on the default 'settings'.
2458 */
2459 uint32_t num_physcam_settings;
2460
2461 /**
2462 * <= CAMERA_DEVICE_API_VERISON_3_4:
2463 *
2464 * Not defined and must not be accessed.
2465 *
2466 * >= CAMERA_DEVICE_API_VERSION_3_5:
2467 * The physical camera ids. The array will contain 'num_physcam_settings'
2468 * camera id strings for all physical devices that have specific settings.
2469 * In case some id is invalid, the process capture request must fail and return
2470 * -EINVAL.
2471 */
2472 const char **physcam_id;
2473
2474 /**
2475 * <= CAMERA_DEVICE_API_VERISON_3_4:
2476 *
2477 * Not defined and must not be accessed.
2478 *
2479 * >= CAMERA_DEVICE_API_VERSION_3_5:
2480 * The capture settings for the physical cameras. The array will contain
2481 * 'num_physcam_settings' settings for invididual physical devices. In
2482 * case the settings at some particular index are empty, the process capture
2483 * request must fail and return -EINVAL.
2484 */
2485 const camera_metadata_t **physcam_settings;
2486
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002487} camera3_capture_request_t;
2488
2489/**
2490 * camera3_capture_result_t:
2491 *
2492 * The result of a single capture/reprocess by the camera HAL device. This is
2493 * sent to the framework asynchronously with process_capture_result(), in
2494 * response to a single capture request sent to the HAL with
Eino-Ville Talvala7c9416b2013-04-03 15:18:20 -07002495 * process_capture_request(). Multiple process_capture_result() calls may be
Igor Murashkin5df2f622014-01-10 14:18:45 -08002496 * performed by the HAL for each request.
2497 *
2498 * Each call, all with the same frame
Eino-Ville Talvala7c9416b2013-04-03 15:18:20 -07002499 * number, may contain some subset of the output buffers, and/or the result
2500 * metadata. The metadata may only be provided once for a given frame number;
2501 * all other calls must set the result metadata to NULL.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002502 *
2503 * The result structure contains the output metadata from this capture, and the
2504 * set of output buffers that have been/will be filled for this capture. Each
2505 * output buffer may come with a release sync fence that the framework will wait
2506 * on before reading, in case the buffer has not yet been filled by the HAL.
2507 *
Igor Murashkin5df2f622014-01-10 14:18:45 -08002508 * >= CAMERA_DEVICE_API_VERSION_3_2:
2509 *
2510 * The metadata may be provided multiple times for a single frame number. The
2511 * framework will accumulate together the final result set by combining each
2512 * partial result together into the total result set.
2513 *
Zhijun Heceac9e32014-02-05 20:49:45 -08002514 * If an input buffer is given in a request, the HAL must return it in one of
2515 * the process_capture_result calls, and the call may be to just return the input
2516 * buffer, without metadata and output buffers; the sync fences must be handled
2517 * the same way they are done for output buffers.
2518 *
2519 *
Igor Murashkin5df2f622014-01-10 14:18:45 -08002520 * Performance considerations:
2521 *
2522 * Applications will also receive these partial results immediately, so sending
2523 * partial results is a highly recommended performance optimization to avoid
2524 * the total pipeline latency before sending the results for what is known very
2525 * early on in the pipeline.
2526 *
2527 * A typical use case might be calculating the AF state halfway through the
2528 * pipeline; by sending the state back to the framework immediately, we get a
2529 * 50% performance increase and perceived responsiveness of the auto-focus.
2530 *
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002531 */
2532typedef struct camera3_capture_result {
2533 /**
2534 * The frame number is an incrementing integer set by the framework in the
2535 * submitted request to uniquely identify this capture. It is also used to
2536 * identify the request in asynchronous notifications sent to
2537 * camera3_callback_ops_t.notify().
2538 */
2539 uint32_t frame_number;
2540
2541 /**
2542 * The result metadata for this capture. This contains information about the
2543 * final capture parameters, the state of the capture and post-processing
2544 * hardware, the state of the 3A algorithms, if enabled, and the output of
2545 * any enabled statistics units.
Eino-Ville Talvala7c9416b2013-04-03 15:18:20 -07002546 *
2547 * Only one call to process_capture_result() with a given frame_number may
2548 * include the result metadata. All other calls for the same frame_number
2549 * must set this to NULL.
2550 *
2551 * If there was an error producing the result metadata, result must be an
2552 * empty metadata buffer, and notify() must be called with ERROR_RESULT.
Igor Murashkin5df2f622014-01-10 14:18:45 -08002553 *
2554 * >= CAMERA_DEVICE_API_VERSION_3_2:
2555 *
2556 * Multiple calls to process_capture_result() with a given frame_number
2557 * may include the result metadata.
2558 *
2559 * Partial metadata submitted should not include any metadata key returned
2560 * in a previous partial result for a given frame. Each new partial result
2561 * for that frame must also set a distinct partial_result value.
2562 *
2563 * If notify has been called with ERROR_RESULT, all further partial
2564 * results for that frame are ignored by the framework.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002565 */
2566 const camera_metadata_t *result;
2567
2568 /**
Eino-Ville Talvala7c9416b2013-04-03 15:18:20 -07002569 * The number of output buffers returned in this result structure. Must be
2570 * less than or equal to the matching capture request's count. If this is
2571 * less than the buffer count in the capture request, at least one more call
2572 * to process_capture_result with the same frame_number must be made, to
2573 * return the remaining output buffers to the framework. This may only be
Zhijun He52a18892014-06-30 10:35:58 -07002574 * zero if the structure includes valid result metadata or an input buffer
2575 * is returned in this result.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002576 */
2577 uint32_t num_output_buffers;
2578
2579 /**
2580 * The handles for the output stream buffers for this capture. They may not
2581 * yet be filled at the time the HAL calls process_capture_result(); the
2582 * framework will wait on the release sync fences provided by the HAL before
2583 * reading the buffers.
2584 *
2585 * The HAL must set the stream buffer's release sync fence to a valid sync
2586 * fd, or to -1 if the buffer has already been filled.
Eino-Ville Talvala2f8cf5c2013-03-06 13:23:31 -08002587 *
2588 * If the HAL encounters an error while processing the buffer, and the
2589 * buffer is not filled, the buffer's status field must be set to
2590 * CAMERA3_BUFFER_STATUS_ERROR. If the HAL did not wait on the acquire fence
2591 * before encountering the error, the acquire fence should be copied into
2592 * the release fence, to allow the framework to wait on the fence before
2593 * reusing the buffer.
2594 *
Eino-Ville Talvala7c9416b2013-04-03 15:18:20 -07002595 * The acquire fence must be set to -1 for all output buffers. If
2596 * num_output_buffers is zero, this may be NULL. In that case, at least one
2597 * more process_capture_result call must be made by the HAL to provide the
2598 * output buffers.
Igor Murashkin5df2f622014-01-10 14:18:45 -08002599 *
2600 * When process_capture_result is called with a new buffer for a frame,
2601 * all previous frames' buffers for that corresponding stream must have been
2602 * already delivered (the fences need not have yet been signaled).
2603 *
2604 * >= CAMERA_DEVICE_API_VERSION_3_2:
2605 *
2606 * Gralloc buffers for a frame may be sent to framework before the
2607 * corresponding SHUTTER-notify.
2608 *
2609 * Performance considerations:
2610 *
2611 * Buffers delivered to the framework will not be dispatched to the
2612 * application layer until a start of exposure timestamp has been received
2613 * via a SHUTTER notify() call. It is highly recommended to
2614 * dispatch that call as early as possible.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002615 */
2616 const camera3_stream_buffer_t *output_buffers;
2617
Igor Murashkin5df2f622014-01-10 14:18:45 -08002618 /**
2619 * >= CAMERA_DEVICE_API_VERSION_3_2:
2620 *
Zhijun Heceac9e32014-02-05 20:49:45 -08002621 * The handle for the input stream buffer for this capture. It may not
2622 * yet be consumed at the time the HAL calls process_capture_result(); the
2623 * framework will wait on the release sync fences provided by the HAL before
2624 * reusing the buffer.
2625 *
2626 * The HAL should handle the sync fences the same way they are done for
2627 * output_buffers.
2628 *
2629 * Only one input buffer is allowed to be sent per request. Similarly to
2630 * output buffers, the ordering of returned input buffers must be
2631 * maintained by the HAL.
2632 *
2633 * Performance considerations:
2634 *
2635 * The input buffer should be returned as early as possible. If the HAL
2636 * supports sync fences, it can call process_capture_result to hand it back
2637 * with sync fences being set appropriately. If the sync fences are not
2638 * supported, the buffer can only be returned when it is consumed, which
2639 * may take long time; the HAL may choose to copy this input buffer to make
2640 * the buffer return sooner.
2641 */
2642 const camera3_stream_buffer_t *input_buffer;
2643
2644 /**
2645 * >= CAMERA_DEVICE_API_VERSION_3_2:
2646 *
Igor Murashkin5df2f622014-01-10 14:18:45 -08002647 * In order to take advantage of partial results, the HAL must set the
2648 * static metadata android.request.partialResultCount to the number of
2649 * partial results it will send for each frame.
2650 *
2651 * Each new capture result with a partial result must set
2652 * this field (partial_result) to a distinct inclusive value between
2653 * 1 and android.request.partialResultCount.
2654 *
2655 * HALs not wishing to take advantage of this feature must not
2656 * set an android.request.partialResultCount or partial_result to a value
2657 * other than 1.
2658 *
2659 * This value must be set to 0 when a capture result contains buffers only
2660 * and no metadata.
2661 */
2662 uint32_t partial_result;
2663
Shuzhen Wang1d4c09e2017-12-31 16:57:11 -08002664 /**
2665 * >= CAMERA_DEVICE_API_VERSION_3_5:
2666 *
2667 * Specifies the number of physical camera metadata this capture result
2668 * contains. It must be equal to the number of physical cameras being
2669 * requested from.
2670 *
2671 * If the current camera device is not a logical multi-camera, or the
2672 * corresponding capture_request doesn't request on any physical camera,
2673 * this field must be 0.
2674 */
2675 uint32_t num_physcam_metadata;
2676
2677 /**
2678 * >= CAMERA_DEVICE_API_VERSION_3_5:
2679 *
2680 * An array of strings containing the physical camera ids for the returned
2681 * physical camera metadata. The length of the array is
2682 * num_physcam_metadata.
2683 */
2684 const char **physcam_ids;
2685
2686 /**
2687 * >= CAMERA_DEVICE_API_VERSION_3_5:
2688 *
2689 * The array of physical camera metadata for the physical cameras being
2690 * requested upon. This array should have a 1-to-1 mapping with the
2691 * physcam_ids. The length of the array is num_physcam_metadata.
2692 */
2693 const camera_metadata_t **physcam_metadata;
2694
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002695} camera3_capture_result_t;
2696
2697/**********************************************************************
2698 *
2699 * Callback methods for the HAL to call into the framework.
2700 *
2701 * These methods are used to return metadata and image buffers for a completed
2702 * or failed captures, and to notify the framework of asynchronous events such
2703 * as errors.
2704 *
2705 * The framework will not call back into the HAL from within these callbacks,
2706 * and these calls will not block for extended periods.
2707 *
2708 */
2709typedef struct camera3_callback_ops {
2710
2711 /**
2712 * process_capture_result:
2713 *
Eino-Ville Talvala7c9416b2013-04-03 15:18:20 -07002714 * Send results from a completed capture to the framework.
2715 * process_capture_result() may be invoked multiple times by the HAL in
2716 * response to a single capture request. This allows, for example, the
2717 * metadata and low-resolution buffers to be returned in one call, and
2718 * post-processed JPEG buffers in a later call, once it is available. Each
2719 * call must include the frame number of the request it is returning
2720 * metadata or buffers for.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002721 *
Eino-Ville Talvala7c9416b2013-04-03 15:18:20 -07002722 * A component (buffer or metadata) of the complete result may only be
2723 * included in one process_capture_result call. A buffer for each stream,
2724 * and the result metadata, must be returned by the HAL for each request in
2725 * one of the process_capture_result calls, even in case of errors producing
2726 * some of the output. A call to process_capture_result() with neither
2727 * output buffers or result metadata is not allowed.
2728 *
2729 * The order of returning metadata and buffers for a single result does not
2730 * matter, but buffers for a given stream must be returned in FIFO order. So
2731 * the buffer for request 5 for stream A must always be returned before the
2732 * buffer for request 6 for stream A. This also applies to the result
2733 * metadata; the metadata for request 5 must be returned before the metadata
2734 * for request 6.
2735 *
2736 * However, different streams are independent of each other, so it is
2737 * acceptable and expected that the buffer for request 5 for stream A may be
2738 * returned after the buffer for request 6 for stream B is. And it is
2739 * acceptable that the result metadata for request 6 for stream B is
2740 * returned before the buffer for request 5 for stream A is.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002741 *
2742 * The HAL retains ownership of result structure, which only needs to be
2743 * valid to access during this call. The framework will copy whatever it
2744 * needs before this call returns.
2745 *
2746 * The output buffers do not need to be filled yet; the framework will wait
2747 * on the stream buffer release sync fence before reading the buffer
Eino-Ville Talvala7c9416b2013-04-03 15:18:20 -07002748 * data. Therefore, this method should be called by the HAL as soon as
2749 * possible, even if some or all of the output buffers are still in
2750 * being filled. The HAL must include valid release sync fences into each
2751 * output_buffers stream buffer entry, or -1 if that stream buffer is
2752 * already filled.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002753 *
2754 * If the result buffer cannot be constructed for a request, the HAL should
Eino-Ville Talvala7c9416b2013-04-03 15:18:20 -07002755 * return an empty metadata buffer, but still provide the output buffers and
2756 * their sync fences. In addition, notify() must be called with an
2757 * ERROR_RESULT message.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002758 *
Eino-Ville Talvala2f8cf5c2013-03-06 13:23:31 -08002759 * If an output buffer cannot be filled, its status field must be set to
2760 * STATUS_ERROR. In addition, notify() must be called with a ERROR_BUFFER
2761 * message.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002762 *
2763 * If the entire capture has failed, then this method still needs to be
Eino-Ville Talvala2f8cf5c2013-03-06 13:23:31 -08002764 * called to return the output buffers to the framework. All the buffer
Eino-Ville Talvala7c9416b2013-04-03 15:18:20 -07002765 * statuses should be STATUS_ERROR, and the result metadata should be an
2766 * empty buffer. In addition, notify() must be called with a ERROR_REQUEST
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002767 * message. In this case, individual ERROR_RESULT/ERROR_BUFFER messages
2768 * should not be sent.
2769 *
Zhijun He2dde4682014-01-09 09:11:49 -08002770 * Performance requirements:
2771 *
2772 * This is a non-blocking call. The framework will return this call in 5ms.
2773 *
2774 * The pipeline latency (see S7 for definition) should be less than or equal to
2775 * 4 frame intervals, and must be less than or equal to 8 frame intervals.
2776 *
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002777 */
2778 void (*process_capture_result)(const struct camera3_callback_ops *,
2779 const camera3_capture_result_t *result);
2780
2781 /**
2782 * notify:
2783 *
2784 * Asynchronous notification callback from the HAL, fired for various
2785 * reasons. Only for information independent of frame capture, or that
2786 * require specific timing. The ownership of the message structure remains
2787 * with the HAL, and the msg only needs to be valid for the duration of this
2788 * call.
2789 *
Igor Murashkin5df2f622014-01-10 14:18:45 -08002790 * Multiple threads may call notify() simultaneously.
2791 *
2792 * <= CAMERA_DEVICE_API_VERSION_3_1:
2793 *
Eino-Ville Talvala71af1022013-04-22 14:19:21 -07002794 * The notification for the start of exposure for a given request must be
2795 * sent by the HAL before the first call to process_capture_result() for
2796 * that request is made.
2797 *
Igor Murashkin5df2f622014-01-10 14:18:45 -08002798 * >= CAMERA_DEVICE_API_VERSION_3_2:
Zhijun He2dde4682014-01-09 09:11:49 -08002799 *
Igor Murashkin5df2f622014-01-10 14:18:45 -08002800 * Buffers delivered to the framework will not be dispatched to the
Chien-Yu Chen73b49eb2015-05-28 17:13:05 -07002801 * application layer until a start of exposure timestamp (or input image's
2802 * start of exposure timestamp for a reprocess request) has been received
2803 * via a SHUTTER notify() call. It is highly recommended to dispatch this
2804 * call as early as possible.
Igor Murashkin5df2f622014-01-10 14:18:45 -08002805 *
2806 * ------------------------------------------------------------------------
Zhijun He2dde4682014-01-09 09:11:49 -08002807 * Performance requirements:
2808 *
2809 * This is a non-blocking call. The framework will return this call in 5ms.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002810 */
2811 void (*notify)(const struct camera3_callback_ops *,
2812 const camera3_notify_msg_t *msg);
2813
Yin-Chia Yeh875df2a2018-09-20 15:05:13 -07002814 /**
2815 * request_stream_buffers:
2816 *
2817 * <= CAMERA_DEVICE_API_VERISON_3_5:
2818 *
2819 * DO NOT USE: not defined and must be NULL.
2820 *
2821 * >= CAMERA_DEVICE_API_VERISON_3_6:
2822 *
2823 * Synchronous callback for HAL to ask for output buffer from camera service.
2824 *
2825 * This call may be serialized in camera service so it is strongly
2826 * recommended to only call this method from one thread.
2827 *
2828 * When camera device advertises
2829 * (android.info.supportedBufferManagementVersion ==
2830 * ANDROID_INFO_SUPPORTED_BUFFER_MANAGEMENT_VERSION_HIDL_DEVICE_3_5), HAL
2831 * can use this method to request buffers from camera service.
2832 *
2833 * Caller is responsible for allocating enough memory for returned_buf_reqs
2834 * argument (num_buffer_reqs * sizeof(camera3_stream_buffer_ret_t)) bytes
2835 * and also the memory for the output_buffers field in each
2836 * camera3_stream_buffer_ret_t
2837 * (num_buffers_requested * sizeof(camera3_stream_buffer_t)) bytes
2838 *
2839 * Performance requirements:
2840 * This is a blocking call that takes more time with more buffers requested.
2841 * HAL should not request large amount of buffers on a latency critical code
2842 * path. It is highly recommended to use a dedicated thread to perform
2843 * all requestStreamBuffer calls, and adjust the thread priority and/or
2844 * timing of making the call in order for buffers to arrive before HAL is
2845 * ready to fill the buffer.
2846 */
2847 camera3_buffer_request_status_t (*request_stream_buffers)(
2848 const struct camera3_callback_ops *,
2849 uint32_t num_buffer_reqs,
2850 const camera3_buffer_request_t *buffer_reqs,
2851 /*out*/uint32_t *num_returned_buf_reqs,
2852 /*out*/camera3_stream_buffer_ret_t *returned_buf_reqs);
2853
2854 /**
2855 * return_stream_buffers:
2856 *
2857 * <= CAMERA_DEVICE_API_VERISON_3_5:
2858 *
2859 * DO NOT USE: not defined and must be NULL.
2860 *
2861 * >= CAMERA_DEVICE_API_VERISON_3_6:
2862 *
2863 * Synchronous callback for HAL to return output buffers to camera service.
2864 *
2865 * If this method is called during a configure_streams() call, it will be
2866 * blocked until camera service finishes the ongoing configure_streams() call.
2867 */
2868 void (*return_stream_buffers)(
2869 const struct camera3_callback_ops *,
2870 uint32_t num_buffers,
2871 const camera3_stream_buffer_t* const* buffers);
2872
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002873} camera3_callback_ops_t;
2874
2875/**********************************************************************
2876 *
2877 * Camera device operations
2878 *
2879 */
2880typedef struct camera3_device_ops {
2881
2882 /**
2883 * initialize:
2884 *
2885 * One-time initialization to pass framework callback function pointers to
2886 * the HAL. Will be called once after a successful open() call, before any
2887 * other functions are called on the camera3_device_ops structure.
2888 *
Zhijun He2dde4682014-01-09 09:11:49 -08002889 * Performance requirements:
2890 *
2891 * This should be a non-blocking call. The HAL should return from this call
2892 * in 5ms, and must return from this call in 10ms.
2893 *
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002894 * Return values:
2895 *
2896 * 0: On successful initialization
2897 *
2898 * -ENODEV: If initialization fails. Only close() can be called successfully
2899 * by the framework after this.
2900 */
2901 int (*initialize)(const struct camera3_device *,
2902 const camera3_callback_ops_t *callback_ops);
2903
2904 /**********************************************************************
2905 * Stream management
2906 */
2907
2908 /**
2909 * configure_streams:
2910 *
Igor Murashkin78aa1262014-01-09 16:23:43 -08002911 * CAMERA_DEVICE_API_VERSION_3_0 only:
2912 *
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002913 * Reset the HAL camera device processing pipeline and set up new input and
2914 * output streams. This call replaces any existing stream configuration with
2915 * the streams defined in the stream_list. This method will be called at
2916 * least once after initialize() before a request is submitted with
2917 * process_capture_request().
2918 *
2919 * The stream_list must contain at least one output-capable stream, and may
2920 * not contain more than one input-capable stream.
2921 *
2922 * The stream_list may contain streams that are also in the currently-active
2923 * set of streams (from the previous call to configure_stream()). These
2924 * streams will already have valid values for usage, max_buffers, and the
Igor Murashkin78aa1262014-01-09 16:23:43 -08002925 * private pointer.
2926 *
2927 * If such a stream has already had its buffers registered,
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002928 * register_stream_buffers() will not be called again for the stream, and
2929 * buffers from the stream can be immediately included in input requests.
2930 *
2931 * If the HAL needs to change the stream configuration for an existing
2932 * stream due to the new configuration, it may rewrite the values of usage
Igor Murashkin78aa1262014-01-09 16:23:43 -08002933 * and/or max_buffers during the configure call.
2934 *
2935 * The framework will detect such a change, and will then reallocate the
2936 * stream buffers, and call register_stream_buffers() again before using
2937 * buffers from that stream in a request.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002938 *
2939 * If a currently-active stream is not included in stream_list, the HAL may
2940 * safely remove any references to that stream. It will not be reused in a
2941 * later configure() call by the framework, and all the gralloc buffers for
2942 * it will be freed after the configure_streams() call returns.
2943 *
2944 * The stream_list structure is owned by the framework, and may not be
2945 * accessed once this call completes. The address of an individual
2946 * camera3_stream_t structure will remain valid for access by the HAL until
2947 * the end of the first configure_stream() call which no longer includes
2948 * that camera3_stream_t in the stream_list argument. The HAL may not change
2949 * values in the stream structure outside of the private pointer, except for
2950 * the usage and max_buffers members during the configure_streams() call
2951 * itself.
2952 *
2953 * If the stream is new, the usage, max_buffer, and private pointer fields
2954 * of the stream structure will all be set to 0. The HAL device must set
2955 * these fields before the configure_streams() call returns. These fields
2956 * are then used by the framework and the platform gralloc module to
2957 * allocate the gralloc buffers for each stream.
2958 *
2959 * Before such a new stream can have its buffers included in a capture
2960 * request, the framework will call register_stream_buffers() with that
2961 * stream. However, the framework is not required to register buffers for
2962 * _all_ streams before submitting a request. This allows for quick startup
2963 * of (for example) a preview stream, with allocation for other streams
2964 * happening later or concurrently.
2965 *
Igor Murashkin78aa1262014-01-09 16:23:43 -08002966 * ------------------------------------------------------------------------
2967 * CAMERA_DEVICE_API_VERSION_3_1 only:
2968 *
2969 * Reset the HAL camera device processing pipeline and set up new input and
2970 * output streams. This call replaces any existing stream configuration with
2971 * the streams defined in the stream_list. This method will be called at
2972 * least once after initialize() before a request is submitted with
2973 * process_capture_request().
2974 *
2975 * The stream_list must contain at least one output-capable stream, and may
2976 * not contain more than one input-capable stream.
2977 *
2978 * The stream_list may contain streams that are also in the currently-active
2979 * set of streams (from the previous call to configure_stream()). These
2980 * streams will already have valid values for usage, max_buffers, and the
2981 * private pointer.
2982 *
2983 * If such a stream has already had its buffers registered,
2984 * register_stream_buffers() will not be called again for the stream, and
2985 * buffers from the stream can be immediately included in input requests.
2986 *
2987 * If the HAL needs to change the stream configuration for an existing
2988 * stream due to the new configuration, it may rewrite the values of usage
2989 * and/or max_buffers during the configure call.
2990 *
2991 * The framework will detect such a change, and will then reallocate the
2992 * stream buffers, and call register_stream_buffers() again before using
2993 * buffers from that stream in a request.
2994 *
2995 * If a currently-active stream is not included in stream_list, the HAL may
2996 * safely remove any references to that stream. It will not be reused in a
2997 * later configure() call by the framework, and all the gralloc buffers for
2998 * it will be freed after the configure_streams() call returns.
2999 *
3000 * The stream_list structure is owned by the framework, and may not be
3001 * accessed once this call completes. The address of an individual
3002 * camera3_stream_t structure will remain valid for access by the HAL until
3003 * the end of the first configure_stream() call which no longer includes
3004 * that camera3_stream_t in the stream_list argument. The HAL may not change
3005 * values in the stream structure outside of the private pointer, except for
3006 * the usage and max_buffers members during the configure_streams() call
3007 * itself.
3008 *
3009 * If the stream is new, max_buffer, and private pointer fields of the
3010 * stream structure will all be set to 0. The usage will be set to the
3011 * consumer usage flags. The HAL device must set these fields before the
3012 * configure_streams() call returns. These fields are then used by the
3013 * framework and the platform gralloc module to allocate the gralloc
3014 * buffers for each stream.
3015 *
3016 * Before such a new stream can have its buffers included in a capture
3017 * request, the framework will call register_stream_buffers() with that
3018 * stream. However, the framework is not required to register buffers for
3019 * _all_ streams before submitting a request. This allows for quick startup
3020 * of (for example) a preview stream, with allocation for other streams
3021 * happening later or concurrently.
3022 *
3023 * ------------------------------------------------------------------------
3024 * >= CAMERA_DEVICE_API_VERSION_3_2:
3025 *
3026 * Reset the HAL camera device processing pipeline and set up new input and
3027 * output streams. This call replaces any existing stream configuration with
3028 * the streams defined in the stream_list. This method will be called at
3029 * least once after initialize() before a request is submitted with
3030 * process_capture_request().
3031 *
3032 * The stream_list must contain at least one output-capable stream, and may
3033 * not contain more than one input-capable stream.
3034 *
3035 * The stream_list may contain streams that are also in the currently-active
3036 * set of streams (from the previous call to configure_stream()). These
3037 * streams will already have valid values for usage, max_buffers, and the
3038 * private pointer.
3039 *
3040 * If the HAL needs to change the stream configuration for an existing
3041 * stream due to the new configuration, it may rewrite the values of usage
3042 * and/or max_buffers during the configure call.
3043 *
3044 * The framework will detect such a change, and may then reallocate the
3045 * stream buffers before using buffers from that stream in a request.
3046 *
3047 * If a currently-active stream is not included in stream_list, the HAL may
3048 * safely remove any references to that stream. It will not be reused in a
3049 * later configure() call by the framework, and all the gralloc buffers for
3050 * it will be freed after the configure_streams() call returns.
3051 *
3052 * The stream_list structure is owned by the framework, and may not be
3053 * accessed once this call completes. The address of an individual
3054 * camera3_stream_t structure will remain valid for access by the HAL until
3055 * the end of the first configure_stream() call which no longer includes
3056 * that camera3_stream_t in the stream_list argument. The HAL may not change
3057 * values in the stream structure outside of the private pointer, except for
3058 * the usage and max_buffers members during the configure_streams() call
3059 * itself.
3060 *
3061 * If the stream is new, max_buffer, and private pointer fields of the
3062 * stream structure will all be set to 0. The usage will be set to the
3063 * consumer usage flags. The HAL device must set these fields before the
3064 * configure_streams() call returns. These fields are then used by the
3065 * framework and the platform gralloc module to allocate the gralloc
3066 * buffers for each stream.
3067 *
3068 * Newly allocated buffers may be included in a capture request at any time
3069 * by the framework. Once a gralloc buffer is returned to the framework
3070 * with process_capture_result (and its respective release_fence has been
3071 * signaled) the framework may free or reuse it at any time.
3072 *
3073 * ------------------------------------------------------------------------
3074 *
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08003075 * Preconditions:
3076 *
3077 * The framework will only call this method when no captures are being
3078 * processed. That is, all results have been returned to the framework, and
3079 * all in-flight input and output buffers have been returned and their
3080 * release sync fences have been signaled by the HAL. The framework will not
3081 * submit new requests for capture while the configure_streams() call is
3082 * underway.
3083 *
3084 * Postconditions:
3085 *
3086 * The HAL device must configure itself to provide maximum possible output
3087 * frame rate given the sizes and formats of the output streams, as
3088 * documented in the camera device's static metadata.
3089 *
Zhijun He2dde4682014-01-09 09:11:49 -08003090 * Performance requirements:
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08003091 *
3092 * This call is expected to be heavyweight and possibly take several hundred
3093 * milliseconds to complete, since it may require resetting and
3094 * reconfiguring the image sensor and the camera processing pipeline.
3095 * Nevertheless, the HAL device should attempt to minimize the
3096 * reconfiguration delay to minimize the user-visible pauses during
3097 * application operational mode changes (such as switching from still
3098 * capture to video recording).
3099 *
Zhijun He2dde4682014-01-09 09:11:49 -08003100 * The HAL should return from this call in 500ms, and must return from this
3101 * call in 1000ms.
3102 *
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08003103 * Return values:
3104 *
3105 * 0: On successful stream configuration
3106 *
3107 * -EINVAL: If the requested stream configuration is invalid. Some examples
3108 * of invalid stream configurations include:
3109 *
3110 * - Including more than 1 input-capable stream (INPUT or
3111 * BIDIRECTIONAL)
3112 *
3113 * - Not including any output-capable streams (OUTPUT or
3114 * BIDIRECTIONAL)
3115 *
3116 * - Including streams with unsupported formats, or an unsupported
3117 * size for that format.
3118 *
3119 * - Including too many output streams of a certain format.
3120 *
Yin-Chia Yehe0042082015-03-09 12:15:36 -07003121 * - Unsupported rotation configuration (only applies to
3122 * devices with version >= CAMERA_DEVICE_API_VERSION_3_3)
3123 *
Zhijun He21126b72015-05-22 18:12:28 -07003124 * - Stream sizes/formats don't satisfy the
3125 * camera3_stream_configuration_t->operation_mode requirements for non-NORMAL mode,
3126 * or the requested operation_mode is not supported by the HAL.
3127 * (only applies to devices with version >= CAMERA_DEVICE_API_VERSION_3_3)
3128 *
Eino-Ville Talvala7effe0c2013-02-15 12:09:48 -08003129 * Note that the framework submitting an invalid stream
3130 * configuration is not normal operation, since stream
3131 * configurations are checked before configure. An invalid
3132 * configuration means that a bug exists in the framework code, or
3133 * there is a mismatch between the HAL's static metadata and the
3134 * requirements on streams.
3135 *
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08003136 * -ENODEV: If there has been a fatal error and the device is no longer
3137 * operational. Only close() can be called successfully by the
3138 * framework after this error is returned.
3139 */
3140 int (*configure_streams)(const struct camera3_device *,
3141 camera3_stream_configuration_t *stream_list);
3142
3143 /**
3144 * register_stream_buffers:
3145 *
Igor Murashkin78aa1262014-01-09 16:23:43 -08003146 * >= CAMERA_DEVICE_API_VERSION_3_2:
3147 *
3148 * DEPRECATED. This will not be called and must be set to NULL.
3149 *
3150 * <= CAMERA_DEVICE_API_VERSION_3_1:
3151 *
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08003152 * Register buffers for a given stream with the HAL device. This method is
3153 * called by the framework after a new stream is defined by
3154 * configure_streams, and before buffers from that stream are included in a
3155 * capture request. If the same stream is listed in a subsequent
3156 * configure_streams() call, register_stream_buffers will _not_ be called
3157 * again for that stream.
3158 *
3159 * The framework does not need to register buffers for all configured
3160 * streams before it submits the first capture request. This allows quick
3161 * startup for preview (or similar use cases) while other streams are still
3162 * being allocated.
3163 *
3164 * This method is intended to allow the HAL device to map or otherwise
3165 * prepare the buffers for later use. The buffers passed in will already be
3166 * locked for use. At the end of the call, all the buffers must be ready to
3167 * be returned to the stream. The buffer_set argument is only valid for the
3168 * duration of this call.
3169 *
3170 * If the stream format was set to HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED,
3171 * the camera HAL should inspect the passed-in buffers here to determine any
3172 * platform-private pixel format information.
3173 *
Zhijun He2dde4682014-01-09 09:11:49 -08003174 * Performance requirements:
3175 *
3176 * This should be a non-blocking call. The HAL should return from this call
3177 * in 1ms, and must return from this call in 5ms.
3178 *
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08003179 * Return values:
3180 *
3181 * 0: On successful registration of the new stream buffers
3182 *
3183 * -EINVAL: If the stream_buffer_set does not refer to a valid active
3184 * stream, or if the buffers array is invalid.
3185 *
3186 * -ENOMEM: If there was a failure in registering the buffers. The framework
3187 * must consider all the stream buffers to be unregistered, and can
3188 * try to register again later.
3189 *
3190 * -ENODEV: If there is a fatal error, and the device is no longer
3191 * operational. Only close() can be called successfully by the
3192 * framework after this error is returned.
3193 */
3194 int (*register_stream_buffers)(const struct camera3_device *,
3195 const camera3_stream_buffer_set_t *buffer_set);
3196
3197 /**********************************************************************
3198 * Request creation and submission
3199 */
3200
3201 /**
3202 * construct_default_request_settings:
3203 *
3204 * Create capture settings for standard camera use cases.
3205 *
3206 * The device must return a settings buffer that is configured to meet the
3207 * requested use case, which must be one of the CAMERA3_TEMPLATE_*
3208 * enums. All request control fields must be included.
3209 *
3210 * The HAL retains ownership of this structure, but the pointer to the
3211 * structure must be valid until the device is closed. The framework and the
3212 * HAL may not modify the buffer once it is returned by this call. The same
3213 * buffer may be returned for subsequent calls for the same template, or for
3214 * other templates.
3215 *
Zhijun He2dde4682014-01-09 09:11:49 -08003216 * Performance requirements:
3217 *
3218 * This should be a non-blocking call. The HAL should return from this call
3219 * in 1ms, and must return from this call in 5ms.
3220 *
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08003221 * Return values:
3222 *
3223 * Valid metadata: On successful creation of a default settings
3224 * buffer.
3225 *
3226 * NULL: In case of a fatal error. After this is returned, only
Eino-Ville Talvalaacbc4512013-03-16 16:53:28 -07003227 * the close() method can be called successfully by the
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08003228 * framework.
3229 */
3230 const camera_metadata_t* (*construct_default_request_settings)(
3231 const struct camera3_device *,
3232 int type);
3233
3234 /**
3235 * process_capture_request:
3236 *
3237 * Send a new capture request to the HAL. The HAL should not return from
3238 * this call until it is ready to accept the next request to process. Only
3239 * one call to process_capture_request() will be made at a time by the
3240 * framework, and the calls will all be from the same thread. The next call
3241 * to process_capture_request() will be made as soon as a new request and
3242 * its associated buffers are available. In a normal preview scenario, this
3243 * means the function will be called again by the framework almost
3244 * instantly.
3245 *
3246 * The actual request processing is asynchronous, with the results of
3247 * capture being returned by the HAL through the process_capture_result()
3248 * call. This call requires the result metadata to be available, but output
3249 * buffers may simply provide sync fences to wait on. Multiple requests are
3250 * expected to be in flight at once, to maintain full output frame rate.
3251 *
3252 * The framework retains ownership of the request structure. It is only
3253 * guaranteed to be valid during this call. The HAL device must make copies
Eino-Ville Talvala71af1022013-04-22 14:19:21 -07003254 * of the information it needs to retain for the capture processing. The HAL
3255 * is responsible for waiting on and closing the buffers' fences and
3256 * returning the buffer handles to the framework.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08003257 *
3258 * The HAL must write the file descriptor for the input buffer's release
3259 * sync fence into input_buffer->release_fence, if input_buffer is not
3260 * NULL. If the HAL returns -1 for the input buffer release sync fence, the
3261 * framework is free to immediately reuse the input buffer. Otherwise, the
3262 * framework will wait on the sync fence before refilling and reusing the
3263 * input buffer.
3264 *
Igor Murashkin78aa1262014-01-09 16:23:43 -08003265 * >= CAMERA_DEVICE_API_VERSION_3_2:
Zhijun He2dde4682014-01-09 09:11:49 -08003266 *
Igor Murashkin78aa1262014-01-09 16:23:43 -08003267 * The input/output buffers provided by the framework in each request
3268 * may be brand new (having never before seen by the HAL).
3269 *
3270 * ------------------------------------------------------------------------
3271 * Performance considerations:
3272 *
3273 * Handling a new buffer should be extremely lightweight and there should be
3274 * no frame rate degradation or frame jitter introduced.
3275 *
3276 * This call must return fast enough to ensure that the requested frame
3277 * rate can be sustained, especially for streaming cases (post-processing
3278 * quality settings set to FAST). The HAL should return this call in 1
3279 * frame interval, and must return from this call in 4 frame intervals.
Zhijun He2dde4682014-01-09 09:11:49 -08003280 *
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08003281 * Return values:
3282 *
3283 * 0: On a successful start to processing the capture request
3284 *
3285 * -EINVAL: If the input is malformed (the settings are NULL when not
Emilian Peev92261ff2018-01-16 15:01:22 +00003286 * allowed, invalid physical camera settings,
3287 * there are 0 output buffers, etc) and capture processing
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08003288 * cannot start. Failures during request processing should be
Eino-Ville Talvala71af1022013-04-22 14:19:21 -07003289 * handled by calling camera3_callback_ops_t.notify(). In case of
3290 * this error, the framework will retain responsibility for the
3291 * stream buffers' fences and the buffer handles; the HAL should
3292 * not close the fences or return these buffers with
3293 * process_capture_result.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08003294 *
3295 * -ENODEV: If the camera device has encountered a serious error. After this
3296 * error is returned, only the close() method can be successfully
3297 * called by the framework.
3298 *
3299 */
3300 int (*process_capture_request)(const struct camera3_device *,
3301 camera3_capture_request_t *request);
3302
3303 /**********************************************************************
3304 * Miscellaneous methods
3305 */
3306
3307 /**
3308 * get_metadata_vendor_tag_ops:
3309 *
Eino-Ville Talvalaacbc4512013-03-16 16:53:28 -07003310 * Get methods to query for vendor extension metadata tag information. The
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08003311 * HAL should fill in all the vendor tag operation methods, or leave ops
3312 * unchanged if no vendor tags are defined.
3313 *
3314 * The definition of vendor_tag_query_ops_t can be found in
3315 * system/media/camera/include/system/camera_metadata.h.
3316 *
Ruben Brunk61cf9eb2014-01-14 15:27:58 -08003317 * >= CAMERA_DEVICE_API_VERSION_3_2:
3318 * DEPRECATED. This function has been deprecated and should be set to
3319 * NULL by the HAL. Please implement get_vendor_tag_ops in camera_common.h
3320 * instead.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08003321 */
3322 void (*get_metadata_vendor_tag_ops)(const struct camera3_device*,
3323 vendor_tag_query_ops_t* ops);
3324
3325 /**
3326 * dump:
3327 *
3328 * Print out debugging state for the camera device. This will be called by
3329 * the framework when the camera service is asked for a debug dump, which
3330 * happens when using the dumpsys tool, or when capturing a bugreport.
3331 *
3332 * The passed-in file descriptor can be used to write debugging text using
3333 * dprintf() or write(). The text should be in ASCII encoding only.
Zhijun He2dde4682014-01-09 09:11:49 -08003334 *
3335 * Performance requirements:
3336 *
3337 * This must be a non-blocking call. The HAL should return from this call
3338 * in 1ms, must return from this call in 10ms. This call must avoid
3339 * deadlocks, as it may be called at any point during camera operation.
3340 * Any synchronization primitives used (such as mutex locks or semaphores)
3341 * should be acquired with a timeout.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08003342 */
3343 void (*dump)(const struct camera3_device *, int fd);
3344
Alex Ray5f2fd852013-06-24 11:28:05 -07003345 /**
3346 * flush:
3347 *
3348 * Flush all currently in-process captures and all buffers in the pipeline
3349 * on the given device. The framework will use this to dump all state as
3350 * quickly as possible in order to prepare for a configure_streams() call.
3351 *
3352 * No buffers are required to be successfully returned, so every buffer
Zhijun He5a5fbf42014-01-27 14:49:44 -08003353 * held at the time of flush() (whether successfully filled or not) may be
Alex Ray5f2fd852013-06-24 11:28:05 -07003354 * returned with CAMERA3_BUFFER_STATUS_ERROR. Note the HAL is still allowed
Zhijun He5a5fbf42014-01-27 14:49:44 -08003355 * to return valid (CAMERA3_BUFFER_STATUS_OK) buffers during this call,
3356 * provided they are successfully filled.
Alex Ray5f2fd852013-06-24 11:28:05 -07003357 *
3358 * All requests currently in the HAL are expected to be returned as soon as
3359 * possible. Not-in-process requests should return errors immediately. Any
3360 * interruptible hardware blocks should be stopped, and any uninterruptible
3361 * blocks should be waited on.
3362 *
Eino-Ville Talvala85fdb3f2015-06-10 14:58:32 -07003363 * flush() may be called concurrently to process_capture_request(), with the expectation that
3364 * process_capture_request will return quickly and the request submitted in that
3365 * process_capture_request call is treated like all other in-flight requests. Due to
3366 * concurrency issues, it is possible that from the HAL's point of view, a
3367 * process_capture_request() call may be started after flush has been invoked but has not
3368 * returned yet. If such a call happens before flush() returns, the HAL should treat the new
3369 * capture request like other in-flight pending requests (see #4 below).
3370 *
Zhijun He5a5fbf42014-01-27 14:49:44 -08003371 * More specifically, the HAL must follow below requirements for various cases:
3372 *
3373 * 1. For captures that are too late for the HAL to cancel/stop, and will be
3374 * completed normally by the HAL; i.e. the HAL can send shutter/notify and
3375 * process_capture_result and buffers as normal.
3376 *
3377 * 2. For pending requests that have not done any processing, the HAL must call notify
3378 * CAMERA3_MSG_ERROR_REQUEST, and return all the output buffers with
3379 * process_capture_result in the error state (CAMERA3_BUFFER_STATUS_ERROR).
3380 * The HAL must not place the release fence into an error state, instead,
3381 * the release fences must be set to the acquire fences passed by the framework,
3382 * or -1 if they have been waited on by the HAL already. This is also the path
3383 * to follow for any captures for which the HAL already called notify() with
3384 * CAMERA3_MSG_SHUTTER but won't be producing any metadata/valid buffers for.
3385 * After CAMERA3_MSG_ERROR_REQUEST, for a given frame, only process_capture_results with
3386 * buffers in CAMERA3_BUFFER_STATUS_ERROR are allowed. No further notifys or
3387 * process_capture_result with non-null metadata is allowed.
3388 *
3389 * 3. For partially completed pending requests that will not have all the output
3390 * buffers or perhaps missing metadata, the HAL should follow below:
3391 *
3392 * 3.1. Call notify with CAMERA3_MSG_ERROR_RESULT if some of the expected result
3393 * metadata (i.e. one or more partial metadata) won't be available for the capture.
3394 *
3395 * 3.2. Call notify with CAMERA3_MSG_ERROR_BUFFER for every buffer that won't
3396 * be produced for the capture.
3397 *
3398 * 3.3 Call notify with CAMERA3_MSG_SHUTTER with the capture timestamp before
3399 * any buffers/metadata are returned with process_capture_result.
3400 *
3401 * 3.4 For captures that will produce some results, the HAL must not call
3402 * CAMERA3_MSG_ERROR_REQUEST, since that indicates complete failure.
3403 *
3404 * 3.5. Valid buffers/metadata should be passed to the framework as normal.
3405 *
3406 * 3.6. Failed buffers should be returned to the framework as described for case 2.
3407 * But failed buffers do not have to follow the strict ordering valid buffers do,
3408 * and may be out-of-order with respect to valid buffers. For example, if buffers
3409 * A, B, C, D, E are sent, D and E are failed, then A, E, B, D, C is an acceptable
3410 * return order.
3411 *
3412 * 3.7. For fully-missing metadata, calling CAMERA3_MSG_ERROR_RESULT is sufficient, no
3413 * need to call process_capture_result with NULL metadata or equivalent.
3414 *
Eino-Ville Talvala85fdb3f2015-06-10 14:58:32 -07003415 * 4. If a flush() is invoked while a process_capture_request() invocation is active, that
3416 * process call should return as soon as possible. In addition, if a process_capture_request()
3417 * call is made after flush() has been invoked but before flush() has returned, the
3418 * capture request provided by the late process_capture_request call should be treated like
3419 * a pending request in case #2 above.
3420 *
Alex Ray5f2fd852013-06-24 11:28:05 -07003421 * flush() should only return when there are no more outstanding buffers or
Zhijun He5a5fbf42014-01-27 14:49:44 -08003422 * requests left in the HAL. The framework may call configure_streams (as
Alex Ray5f2fd852013-06-24 11:28:05 -07003423 * the HAL state is now quiesced) or may issue new requests.
3424 *
Zhijun He5a5fbf42014-01-27 14:49:44 -08003425 * Note that it's sufficient to only support fully-succeeded and fully-failed result cases.
3426 * However, it is highly desirable to support the partial failure cases as well, as it
3427 * could help improve the flush call overall performance.
3428 *
Zhijun He2dde4682014-01-09 09:11:49 -08003429 * Performance requirements:
3430 *
3431 * The HAL should return from this call in 100ms, and must return from this
3432 * call in 1000ms. And this call must not be blocked longer than pipeline
3433 * latency (see S7 for definition).
Alex Ray5f2fd852013-06-24 11:28:05 -07003434 *
3435 * Version information:
3436 *
3437 * only available if device version >= CAMERA_DEVICE_API_VERSION_3_1.
3438 *
3439 * Return values:
3440 *
3441 * 0: On a successful flush of the camera HAL.
3442 *
3443 * -EINVAL: If the input is malformed (the device is not valid).
3444 *
3445 * -ENODEV: If the camera device has encountered a serious error. After this
3446 * error is returned, only the close() method can be successfully
3447 * called by the framework.
3448 */
3449 int (*flush)(const struct camera3_device *);
3450
Yin-Chia Yeh875df2a2018-09-20 15:05:13 -07003451 /**
3452 * signal_stream_flush:
3453 *
3454 * <= CAMERA_DEVICE_API_VERISON_3_5:
3455 *
3456 * Not defined and must be NULL
3457 *
3458 * >= CAMERA_DEVICE_API_VERISON_3_6:
3459 *
3460 * Signaling HAL camera service is about to perform configure_streams() call
3461 * and HAL must return all buffers of designated streams. HAL must finish
3462 * inflight requests normally and return all buffers belonging to the
3463 * designated streams through process_capture_result() or
3464 * return_stream_buffers() API in a timely manner, or camera service will run
3465 * into a fatal error.
3466 *
3467 * Note that this call serves as an optional hint and camera service may
3468 * skip calling this if all buffers are already returned.
3469 *
3470 * stream_configuration_counter: Note that this method may be called from
3471 * a different thread than configure_streams() and due to concurrency
3472 * issues, it is possible the signalStreamFlush call arrives later than
3473 * the corresponding configure_streams() call, so the HAL must check
3474 * stream_configuration_counter for such race condition. If the counter is
3475 * less than the counter in the last configure_streams() call HAL last
3476 * received, the call is stale and HAL should ignore this call.
3477 */
3478 void (*signal_stream_flush)(const struct camera3_device*,
3479 uint32_t stream_configuration_counter,
3480 uint32_t num_streams,
3481 const camera3_stream_t* const* streams);
3482
Alex Ray5f2fd852013-06-24 11:28:05 -07003483 /* reserved for future use */
Yin-Chia Yeh875df2a2018-09-20 15:05:13 -07003484 void *reserved[7];
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08003485} camera3_device_ops_t;
3486
3487/**********************************************************************
3488 *
3489 * Camera device definition
3490 *
3491 */
3492typedef struct camera3_device {
3493 /**
3494 * common.version must equal CAMERA_DEVICE_API_VERSION_3_0 to identify this
3495 * device as implementing version 3.0 of the camera device HAL.
Zhijun He2dde4682014-01-09 09:11:49 -08003496 *
3497 * Performance requirements:
3498 *
Zhijun He06da1b32014-02-10 16:04:23 -08003499 * Camera open (common.module->common.methods->open) should return in 200ms, and must return
3500 * in 500ms.
Zhijun He2020ee22014-01-31 11:35:45 -08003501 * Camera close (common.close) should return in 200ms, and must return in 500ms.
3502 *
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08003503 */
3504 hw_device_t common;
3505 camera3_device_ops_t *ops;
3506 void *priv;
3507} camera3_device_t;
3508
3509__END_DECLS
3510
3511#endif /* #ifdef ANDROID_INCLUDE_CAMERA3_H */