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