blob: f93c066a9823dae7046f5f0c41c1f12d54a2c19b [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/**
Ruben Brunk61cf9eb2014-01-14 15:27:58 -080024 * Camera device HAL 3.2 [ CAMERA_DEVICE_API_VERSION_3_2 ]
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -080025 *
26 * EXPERIMENTAL.
27 *
28 * Supports the android.hardware.Camera API.
29 *
30 * Camera devices that support this version of the HAL must return
Ruben Brunk61cf9eb2014-01-14 15:27:58 -080031 * CAMERA_DEVICE_API_VERSION_3_2 in camera_device_t.common.version and in
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -080032 * camera_info_t.device_version (from camera_module_t.get_camera_info).
33 *
Ruben Brunk61cf9eb2014-01-14 15:27:58 -080034 * CAMERA_DEVICE_API_VERSION_3_2:
35 * Camera modules that may contain version 3.2 devices must implement at
36 * least version 2.2 of the camera module interface (as defined by
37 * camera_module_t.common.module_api_version).
38 *
39 * <= CAMERA_DEVICE_API_VERSION_3_1:
40 * Camera modules that may contain version 3.1 (or 3.0) devices must
41 * implement at least version 2.0 of the camera module interface
42 * (as defined by camera_module_t.common.module_api_version).
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -080043 *
44 * See camera_common.h for more versioning details.
45 *
Eino-Ville Talvalaacbc4512013-03-16 16:53:28 -070046 * Documentation index:
47 * S1. Version history
48 * S2. Startup and operation sequencing
49 * S3. Operational modes
50 * S4. 3A modes and state machines
Eino-Ville Talvalab6059442013-04-29 15:26:16 -070051 * S5. Cropping
52 * S6. Error management
Eino-Ville Talvalaacbc4512013-03-16 16:53:28 -070053 */
54
55/**
56 * S1. Version history:
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -080057 *
58 * 1.0: Initial Android camera HAL (Android 4.0) [camera.h]:
59 *
60 * - Converted from C++ CameraHardwareInterface abstraction layer.
61 *
62 * - Supports android.hardware.Camera API.
63 *
64 * 2.0: Initial release of expanded-capability HAL (Android 4.2) [camera2.h]:
65 *
66 * - Sufficient for implementing existing android.hardware.Camera API.
67 *
68 * - Allows for ZSL queue in camera service layer
69 *
70 * - Not tested for any new features such manual capture control, Bayer RAW
71 * capture, reprocessing of RAW data.
72 *
73 * 3.0: First revision of expanded-capability HAL:
74 *
75 * - Major version change since the ABI is completely different. No change to
76 * the required hardware capabilities or operational model from 2.0.
77 *
78 * - Reworked input request and stream queue interfaces: Framework calls into
79 * HAL with next request and stream buffers already dequeued. Sync framework
80 * support is included, necessary for efficient implementations.
81 *
82 * - Moved triggers into requests, most notifications into results.
83 *
84 * - Consolidated all callbacks into framework into one structure, and all
85 * setup methods into a single initialize() call.
86 *
87 * - Made stream configuration into a single call to simplify stream
88 * management. Bidirectional streams replace STREAM_FROM_STREAM construct.
89 *
90 * - Limited mode semantics for older/limited hardware devices.
Alex Ray2ce219a2013-06-14 15:09:30 -070091 *
92 * 3.1: Minor revision of expanded-capability HAL:
93 *
94 * - configure_streams passes consumer usage flags to the HAL.
Alex Ray5f2fd852013-06-24 11:28:05 -070095 *
96 * - flush call to drop all in-flight requests/buffers as fast as possible.
Ruben Brunk61cf9eb2014-01-14 15:27:58 -080097 *
98 * 3.2: Minor revision of expanded-capability HAL:
99 *
100 * - Deprecates get_metadata_vendor_tag_ops. Please use get_vendor_tag_ops
101 * in camera_common.h instead.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800102 */
103
104/**
Eino-Ville Talvalaacbc4512013-03-16 16:53:28 -0700105 * S2. Startup and general expected operation sequence:
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800106 *
107 * 1. Framework calls camera_module_t->common.open(), which returns a
108 * hardware_device_t structure.
109 *
110 * 2. Framework inspects the hardware_device_t->version field, and instantiates
111 * the appropriate handler for that version of the camera hardware device. In
112 * case the version is CAMERA_DEVICE_API_VERSION_3_0, the device is cast to
113 * a camera3_device_t.
114 *
115 * 3. Framework calls camera3_device_t->ops->initialize() with the framework
116 * callback function pointers. This will only be called this one time after
117 * open(), before any other functions in the ops structure are called.
118 *
119 * 4. The framework calls camera3_device_t->ops->configure_streams() with a list
120 * of input/output streams to the HAL device.
121 *
122 * 5. The framework allocates gralloc buffers and calls
123 * camera3_device_t->ops->register_stream_buffers() for at least one of the
124 * output streams listed in configure_streams. The same stream is registered
125 * only once.
126 *
127 * 5. The framework requests default settings for some number of use cases with
128 * calls to camera3_device_t->ops->construct_default_request_settings(). This
129 * may occur any time after step 3.
130 *
131 * 7. The framework constructs and sends the first capture request to the HAL,
132 * with settings based on one of the sets of default settings, and with at
133 * least one output stream, which has been registered earlier by the
134 * framework. This is sent to the HAL with
135 * camera3_device_t->ops->process_capture_request(). The HAL must block the
136 * return of this call until it is ready for the next request to be sent.
137 *
138 * 8. The framework continues to submit requests, and possibly call
139 * register_stream_buffers() for not-yet-registered streams, and call
140 * construct_default_request_settings to get default settings buffers for
141 * other use cases.
142 *
143 * 9. When the capture of a request begins (sensor starts exposing for the
144 * capture), the HAL calls camera3_callback_ops_t->notify() with the SHUTTER
145 * event, including the frame number and the timestamp for start of exposure.
Eino-Ville Talvala71af1022013-04-22 14:19:21 -0700146 * This notify call must be made before the first call to
147 * process_capture_result() for that frame number.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800148 *
149 * 10. After some pipeline delay, the HAL begins to return completed captures to
150 * the framework with camera3_callback_ops_t->process_capture_result(). These
151 * are returned in the same order as the requests were submitted. Multiple
152 * requests can be in flight at once, depending on the pipeline depth of the
153 * camera HAL device.
154 *
155 * 11. After some time, the framework may stop submitting new requests, wait for
156 * the existing captures to complete (all buffers filled, all results
157 * returned), and then call configure_streams() again. This resets the camera
158 * hardware and pipeline for a new set of input/output streams. Some streams
159 * may be reused from the previous configuration; if these streams' buffers
160 * had already been registered with the HAL, they will not be registered
161 * again. The framework then continues from step 7, if at least one
162 * registered output stream remains (otherwise, step 5 is required first).
163 *
164 * 12. Alternatively, the framework may call camera3_device_t->common->close()
Eino-Ville Talvala2f8cf5c2013-03-06 13:23:31 -0800165 * to end the camera session. This may be called at any time when no other
166 * calls from the framework are active, although the call may block until all
167 * in-flight captures have completed (all results returned, all buffers
168 * filled). After the close call returns, no more calls to the
169 * camera3_callback_ops_t functions are allowed from the HAL. Once the
170 * close() call is underway, the framework may not call any other HAL device
171 * functions.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800172 *
173 * 13. In case of an error or other asynchronous event, the HAL must call
174 * camera3_callback_ops_t->notify() with the appropriate error/event
175 * message. After returning from a fatal device-wide error notification, the
176 * HAL should act as if close() had been called on it. However, the HAL must
177 * either cancel or complete all outstanding captures before calling
178 * notify(), so that once notify() is called with a fatal error, the
179 * framework will not receive further callbacks from the device. Methods
180 * besides close() should return -ENODEV or NULL after the notify() method
181 * returns from a fatal error message.
182 */
183
184/**
Eino-Ville Talvalaacbc4512013-03-16 16:53:28 -0700185 * S3. Operational modes:
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800186 *
187 * The camera 3 HAL device can implement one of two possible operational modes;
188 * limited and full. Full support is expected from new higher-end
189 * devices. Limited mode has hardware requirements roughly in line with those
190 * for a camera HAL device v1 implementation, and is expected from older or
191 * inexpensive devices. Full is a strict superset of limited, and they share the
192 * same essential operational flow, as documented above.
193 *
194 * The HAL must indicate its level of support with the
195 * android.info.supportedHardwareLevel static metadata entry, with 0 indicating
196 * limited mode, and 1 indicating full mode support.
197 *
198 * Roughly speaking, limited-mode devices do not allow for application control
199 * of capture settings (3A control only), high-rate capture of high-resolution
Eino-Ville Talvalaacbc4512013-03-16 16:53:28 -0700200 * images, raw sensor readout, or support for YUV output streams above maximum
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800201 * recording resolution (JPEG only for large images).
202 *
203 * ** Details of limited mode behavior:
204 *
205 * - Limited-mode devices do not need to implement accurate synchronization
206 * between capture request settings and the actual image data
207 * captured. Instead, changes to settings may take effect some time in the
208 * future, and possibly not for the same output frame for each settings
209 * entry. Rapid changes in settings may result in some settings never being
210 * used for a capture. However, captures that include high-resolution output
211 * buffers ( > 1080p ) have to use the settings as specified (but see below
212 * for processing rate).
213 *
214 * - Limited-mode devices do not need to support most of the
215 * settings/result/static info metadata. Full-mode devices must support all
216 * metadata fields listed in TODO. Specifically, only the following settings
217 * are expected to be consumed or produced by a limited-mode HAL device:
218 *
219 * android.control.aeAntibandingMode (controls)
220 * android.control.aeExposureCompensation (controls)
221 * android.control.aeLock (controls)
222 * android.control.aeMode (controls)
223 * [OFF means ON_FLASH_TORCH - TODO]
224 * android.control.aeRegions (controls)
225 * android.control.aeTargetFpsRange (controls)
226 * android.control.afMode (controls)
227 * [OFF means infinity focus]
228 * android.control.afRegions (controls)
229 * android.control.awbLock (controls)
230 * android.control.awbMode (controls)
231 * [OFF not supported]
232 * android.control.awbRegions (controls)
233 * android.control.captureIntent (controls)
234 * android.control.effectMode (controls)
235 * android.control.mode (controls)
236 * [OFF not supported]
237 * android.control.sceneMode (controls)
238 * android.control.videoStabilizationMode (controls)
239 * android.control.aeAvailableAntibandingModes (static)
240 * android.control.aeAvailableModes (static)
241 * android.control.aeAvailableTargetFpsRanges (static)
242 * android.control.aeCompensationRange (static)
243 * android.control.aeCompensationStep (static)
244 * android.control.afAvailableModes (static)
245 * android.control.availableEffects (static)
246 * android.control.availableSceneModes (static)
247 * android.control.availableVideoStabilizationModes (static)
248 * android.control.awbAvailableModes (static)
249 * android.control.maxRegions (static)
250 * android.control.sceneModeOverrides (static)
251 * android.control.aeRegions (dynamic)
252 * android.control.aeState (dynamic)
253 * android.control.afMode (dynamic)
254 * android.control.afRegions (dynamic)
255 * android.control.afState (dynamic)
256 * android.control.awbMode (dynamic)
257 * android.control.awbRegions (dynamic)
258 * android.control.awbState (dynamic)
259 * android.control.mode (dynamic)
260 *
261 * android.flash.info.available (static)
262 *
263 * android.info.supportedHardwareLevel (static)
264 *
265 * android.jpeg.gpsCoordinates (controls)
266 * android.jpeg.gpsProcessingMethod (controls)
267 * android.jpeg.gpsTimestamp (controls)
268 * android.jpeg.orientation (controls)
269 * android.jpeg.quality (controls)
270 * android.jpeg.thumbnailQuality (controls)
271 * android.jpeg.thumbnailSize (controls)
272 * android.jpeg.availableThumbnailSizes (static)
273 * android.jpeg.maxSize (static)
274 * android.jpeg.gpsCoordinates (dynamic)
275 * android.jpeg.gpsProcessingMethod (dynamic)
276 * android.jpeg.gpsTimestamp (dynamic)
277 * android.jpeg.orientation (dynamic)
278 * android.jpeg.quality (dynamic)
279 * android.jpeg.size (dynamic)
280 * android.jpeg.thumbnailQuality (dynamic)
281 * android.jpeg.thumbnailSize (dynamic)
282 *
283 * android.lens.info.minimumFocusDistance (static)
284 *
285 * android.request.id (controls)
286 * android.request.id (dynamic)
287 *
288 * android.scaler.cropRegion (controls)
289 * [ignores (x,y), assumes center-zoom]
290 * android.scaler.availableFormats (static)
291 * [RAW not supported]
292 * android.scaler.availableJpegMinDurations (static)
293 * android.scaler.availableJpegSizes (static)
294 * android.scaler.availableMaxDigitalZoom (static)
295 * android.scaler.availableProcessedMinDurations (static)
296 * android.scaler.availableProcessedSizes (static)
297 * [full resolution not supported]
298 * android.scaler.maxDigitalZoom (static)
299 * android.scaler.cropRegion (dynamic)
300 *
301 * android.sensor.orientation (static)
302 * android.sensor.timestamp (dynamic)
303 *
304 * android.statistics.faceDetectMode (controls)
305 * android.statistics.info.availableFaceDetectModes (static)
306 * android.statistics.faceDetectMode (dynamic)
307 * android.statistics.faceIds (dynamic)
308 * android.statistics.faceLandmarks (dynamic)
309 * android.statistics.faceRectangles (dynamic)
310 * android.statistics.faceScores (dynamic)
311 *
312 * - Captures in limited mode that include high-resolution (> 1080p) output
313 * buffers may block in process_capture_request() until all the output buffers
314 * have been filled. A full-mode HAL device must process sequences of
315 * high-resolution requests at the rate indicated in the static metadata for
316 * that pixel format. The HAL must still call process_capture_result() to
317 * provide the output; the framework must simply be prepared for
318 * process_capture_request() to block until after process_capture_result() for
319 * that request completes for high-resolution captures for limited-mode
320 * devices.
321 *
322 */
323
324/**
Eino-Ville Talvalaacbc4512013-03-16 16:53:28 -0700325 * S4. 3A modes and state machines:
326 *
327 * While the actual 3A algorithms are up to the HAL implementation, a high-level
328 * state machine description is defined by the HAL interface, to allow the HAL
329 * device and the framework to communicate about the current state of 3A, and to
330 * trigger 3A events.
331 *
332 * When the device is opened, all the individual 3A states must be
333 * STATE_INACTIVE. Stream configuration does not reset 3A. For example, locked
334 * focus must be maintained across the configure() call.
335 *
336 * Triggering a 3A action involves simply setting the relevant trigger entry in
337 * the settings for the next request to indicate start of trigger. For example,
338 * the trigger for starting an autofocus scan is setting the entry
339 * ANDROID_CONTROL_AF_TRIGGER to ANDROID_CONTROL_AF_TRIGGER_START for one
340 * request, and cancelling an autofocus scan is triggered by setting
341 * ANDROID_CONTROL_AF_TRIGGER to ANDROID_CONTRL_AF_TRIGGER_CANCEL. Otherwise,
342 * the entry will not exist, or be set to ANDROID_CONTROL_AF_TRIGGER_IDLE. Each
343 * request with a trigger entry set to a non-IDLE value will be treated as an
344 * independent triggering event.
345 *
346 * At the top level, 3A is controlled by the ANDROID_CONTROL_MODE setting, which
347 * selects between no 3A (ANDROID_CONTROL_MODE_OFF), normal AUTO mode
348 * (ANDROID_CONTROL_MODE_AUTO), and using the scene mode setting
349 * (ANDROID_CONTROL_USE_SCENE_MODE).
350 *
351 * - In OFF mode, each of the individual AE/AF/AWB modes are effectively OFF,
352 * and none of the capture controls may be overridden by the 3A routines.
353 *
354 * - In AUTO mode, Auto-focus, auto-exposure, and auto-whitebalance all run
355 * their own independent algorithms, and have their own mode, state, and
356 * trigger metadata entries, as listed in the next section.
357 *
358 * - In USE_SCENE_MODE, the value of the ANDROID_CONTROL_SCENE_MODE entry must
359 * be used to determine the behavior of 3A routines. In SCENE_MODEs other than
360 * FACE_PRIORITY, the HAL must override the values of
361 * ANDROId_CONTROL_AE/AWB/AF_MODE to be the mode it prefers for the selected
362 * SCENE_MODE. For example, the HAL may prefer SCENE_MODE_NIGHT to use
363 * CONTINUOUS_FOCUS AF mode. Any user selection of AE/AWB/AF_MODE when scene
364 * must be ignored for these scene modes.
365 *
366 * - For SCENE_MODE_FACE_PRIORITY, the AE/AWB/AF_MODE controls work as in
367 * ANDROID_CONTROL_MODE_AUTO, but the 3A routines must bias toward metering
368 * and focusing on any detected faces in the scene.
369 *
370 * S4.1. Auto-focus settings and result entries:
371 *
372 * Main metadata entries:
373 *
374 * ANDROID_CONTROL_AF_MODE: Control for selecting the current autofocus
375 * mode. Set by the framework in the request settings.
376 *
377 * AF_MODE_OFF: AF is disabled; the framework/app directly controls lens
378 * position.
379 *
380 * AF_MODE_AUTO: Single-sweep autofocus. No lens movement unless AF is
381 * triggered.
382 *
383 * AF_MODE_MACRO: Single-sweep up-close autofocus. No lens movement unless
384 * AF is triggered.
385 *
386 * AF_MODE_CONTINUOUS_VIDEO: Smooth continuous focusing, for recording
387 * video. Triggering immediately locks focus in current
388 * position. Canceling resumes cotinuous focusing.
389 *
390 * AF_MODE_CONTINUOUS_PICTURE: Fast continuous focusing, for
391 * zero-shutter-lag still capture. Triggering locks focus once currently
392 * active sweep concludes. Canceling resumes continuous focusing.
393 *
394 * AF_MODE_EDOF: Advanced extended depth of field focusing. There is no
395 * autofocus scan, so triggering one or canceling one has no effect.
396 * Images are focused automatically by the HAL.
397 *
398 * ANDROID_CONTROL_AF_STATE: Dynamic metadata describing the current AF
399 * algorithm state, reported by the HAL in the result metadata.
400 *
401 * AF_STATE_INACTIVE: No focusing has been done, or algorithm was
402 * reset. Lens is not moving. Always the state for MODE_OFF or MODE_EDOF.
403 * When the device is opened, it must start in this state.
404 *
405 * AF_STATE_PASSIVE_SCAN: A continuous focus algorithm is currently scanning
406 * for good focus. The lens is moving.
407 *
408 * AF_STATE_PASSIVE_FOCUSED: A continuous focus algorithm believes it is
409 * well focused. The lens is not moving. The HAL may spontaneously leave
410 * this state.
411 *
Eino-Ville Talvala4d45d302013-09-20 17:24:50 -0700412 * AF_STATE_PASSIVE_UNFOCUSED: A continuous focus algorithm believes it is
413 * not well focused. The lens is not moving. The HAL may spontaneously
414 * leave this state.
415 *
Eino-Ville Talvalaacbc4512013-03-16 16:53:28 -0700416 * AF_STATE_ACTIVE_SCAN: A scan triggered by the user is underway.
417 *
418 * AF_STATE_FOCUSED_LOCKED: The AF algorithm believes it is focused. The
419 * lens is not moving.
420 *
421 * AF_STATE_NOT_FOCUSED_LOCKED: The AF algorithm has been unable to
422 * focus. The lens is not moving.
423 *
424 * ANDROID_CONTROL_AF_TRIGGER: Control for starting an autofocus scan, the
425 * meaning of which is mode- and state- dependent. Set by the framework in
426 * the request settings.
427 *
428 * AF_TRIGGER_IDLE: No current trigger.
429 *
430 * AF_TRIGGER_START: Trigger start of AF scan. Effect is mode and state
431 * dependent.
432 *
433 * AF_TRIGGER_CANCEL: Cancel current AF scan if any, and reset algorithm to
434 * default.
435 *
436 * Additional metadata entries:
437 *
438 * ANDROID_CONTROL_AF_REGIONS: Control for selecting the regions of the FOV
439 * that should be used to determine good focus. This applies to all AF
440 * modes that scan for focus. Set by the framework in the request
441 * settings.
442 *
443 * S4.2. Auto-exposure settings and result entries:
444 *
445 * Main metadata entries:
446 *
447 * ANDROID_CONTROL_AE_MODE: Control for selecting the current auto-exposure
448 * mode. Set by the framework in the request settings.
449 *
450 * AE_MODE_OFF: Autoexposure is disabled; the user controls exposure, gain,
451 * frame duration, and flash.
452 *
453 * AE_MODE_ON: Standard autoexposure, with flash control disabled. User may
454 * set flash to fire or to torch mode.
455 *
456 * AE_MODE_ON_AUTO_FLASH: Standard autoexposure, with flash on at HAL's
457 * discretion for precapture and still capture. User control of flash
458 * disabled.
459 *
460 * AE_MODE_ON_ALWAYS_FLASH: Standard autoexposure, with flash always fired
461 * for capture, and at HAL's discretion for precapture.. User control of
462 * flash disabled.
463 *
464 * AE_MODE_ON_AUTO_FLASH_REDEYE: Standard autoexposure, with flash on at
465 * HAL's discretion for precapture and still capture. Use a flash burst
466 * at end of precapture sequence to reduce redeye in the final
467 * picture. User control of flash disabled.
468 *
469 * ANDROID_CONTROL_AE_STATE: Dynamic metadata describing the current AE
470 * algorithm state, reported by the HAL in the result metadata.
471 *
472 * AE_STATE_INACTIVE: Initial AE state after mode switch. When the device is
473 * opened, it must start in this state.
474 *
475 * AE_STATE_SEARCHING: AE is not converged to a good value, and is adjusting
476 * exposure parameters.
477 *
478 * AE_STATE_CONVERGED: AE has found good exposure values for the current
479 * scene, and the exposure parameters are not changing. HAL may
480 * spontaneously leave this state to search for better solution.
481 *
482 * AE_STATE_LOCKED: AE has been locked with the AE_LOCK control. Exposure
483 * values are not changing.
484 *
485 * AE_STATE_FLASH_REQUIRED: The HAL has converged exposure, but believes
486 * flash is required for a sufficiently bright picture. Used for
487 * determining if a zero-shutter-lag frame can be used.
488 *
489 * AE_STATE_PRECAPTURE: The HAL is in the middle of a precapture
490 * sequence. Depending on AE mode, this mode may involve firing the
491 * flash for metering, or a burst of flash pulses for redeye reduction.
492 *
493 * ANDROID_CONTROL_AE_PRECAPTURE_TRIGGER: Control for starting a metering
494 * sequence before capturing a high-quality image. Set by the framework in
495 * the request settings.
496 *
497 * PRECAPTURE_TRIGGER_IDLE: No current trigger.
498 *
499 * PRECAPTURE_TRIGGER_START: Start a precapture sequence. The HAL should
500 * use the subsequent requests to measure good exposure/white balance
501 * for an upcoming high-resolution capture.
502 *
503 * Additional metadata entries:
504 *
505 * ANDROID_CONTROL_AE_LOCK: Control for locking AE controls to their current
506 * values
507 *
508 * ANDROID_CONTROL_AE_EXPOSURE_COMPENSATION: Control for adjusting AE
509 * algorithm target brightness point.
510 *
511 * ANDROID_CONTROL_AE_TARGET_FPS_RANGE: Control for selecting the target frame
512 * rate range for the AE algorithm. The AE routine cannot change the frame
513 * rate to be outside these bounds.
514 *
515 * ANDROID_CONTROL_AE_REGIONS: Control for selecting the regions of the FOV
516 * that should be used to determine good exposure levels. This applies to
517 * all AE modes besides OFF.
518 *
519 * S4.3. Auto-whitebalance settings and result entries:
520 *
521 * Main metadata entries:
522 *
523 * ANDROID_CONTROL_AWB_MODE: Control for selecting the current white-balance
524 * mode.
525 *
526 * AWB_MODE_OFF: Auto-whitebalance is disabled. User controls color matrix.
527 *
528 * AWB_MODE_AUTO: Automatic white balance is enabled; 3A controls color
529 * transform, possibly using more complex transforms than a simple
530 * matrix.
531 *
532 * AWB_MODE_INCANDESCENT: Fixed white balance settings good for indoor
533 * incandescent (tungsten) lighting, roughly 2700K.
534 *
535 * AWB_MODE_FLUORESCENT: Fixed white balance settings good for fluorescent
536 * lighting, roughly 5000K.
537 *
538 * AWB_MODE_WARM_FLUORESCENT: Fixed white balance settings good for
539 * fluorescent lighting, roughly 3000K.
540 *
541 * AWB_MODE_DAYLIGHT: Fixed white balance settings good for daylight,
542 * roughly 5500K.
543 *
544 * AWB_MODE_CLOUDY_DAYLIGHT: Fixed white balance settings good for clouded
545 * daylight, roughly 6500K.
546 *
547 * AWB_MODE_TWILIGHT: Fixed white balance settings good for
548 * near-sunset/sunrise, roughly 15000K.
549 *
550 * AWB_MODE_SHADE: Fixed white balance settings good for areas indirectly
551 * lit by the sun, roughly 7500K.
552 *
553 * ANDROID_CONTROL_AWB_STATE: Dynamic metadata describing the current AWB
554 * algorithm state, reported by the HAL in the result metadata.
555 *
556 * AWB_STATE_INACTIVE: Initial AWB state after mode switch. When the device
557 * is opened, it must start in this state.
558 *
559 * AWB_STATE_SEARCHING: AWB is not converged to a good value, and is
560 * changing color adjustment parameters.
561 *
562 * AWB_STATE_CONVERGED: AWB has found good color adjustment values for the
563 * current scene, and the parameters are not changing. HAL may
564 * spontaneously leave this state to search for better solution.
565 *
566 * AWB_STATE_LOCKED: AWB has been locked with the AWB_LOCK control. Color
567 * adjustment values are not changing.
568 *
569 * Additional metadata entries:
570 *
571 * ANDROID_CONTROL_AWB_LOCK: Control for locking AWB color adjustments to
572 * their current values.
573 *
574 * ANDROID_CONTROL_AWB_REGIONS: Control for selecting the regions of the FOV
575 * that should be used to determine good color balance. This applies only
576 * to auto-WB mode.
577 *
578 * S4.4. General state machine transition notes
579 *
580 * Switching between AF, AE, or AWB modes always resets the algorithm's state
581 * to INACTIVE. Similarly, switching between CONTROL_MODE or
582 * CONTROL_SCENE_MODE if CONTROL_MODE == USE_SCENE_MODE resets all the
583 * algorithm states to INACTIVE.
584 *
585 * The tables below are per-mode.
586 *
587 * S4.5. AF state machines
588 *
Eino-Ville Talvala4d45d302013-09-20 17:24:50 -0700589 * when enabling AF or changing AF mode
590 *| state | trans. cause | new state | notes |
591 *+--------------------+---------------+--------------------+------------------+
592 *| Any | AF mode change| INACTIVE | |
593 *+--------------------+---------------+--------------------+------------------+
594 *
Eino-Ville Talvalaacbc4512013-03-16 16:53:28 -0700595 * mode = AF_MODE_OFF or AF_MODE_EDOF
596 *| state | trans. cause | new state | notes |
597 *+--------------------+---------------+--------------------+------------------+
Eino-Ville Talvala4d45d302013-09-20 17:24:50 -0700598 *| INACTIVE | | INACTIVE | Never changes |
Eino-Ville Talvalaacbc4512013-03-16 16:53:28 -0700599 *+--------------------+---------------+--------------------+------------------+
600 *
601 * mode = AF_MODE_AUTO or AF_MODE_MACRO
602 *| state | trans. cause | new state | notes |
603 *+--------------------+---------------+--------------------+------------------+
604 *| INACTIVE | AF_TRIGGER | ACTIVE_SCAN | Start AF sweep |
605 *| | | | Lens now moving |
606 *+--------------------+---------------+--------------------+------------------+
607 *| ACTIVE_SCAN | AF sweep done | FOCUSED_LOCKED | If AF successful |
608 *| | | | Lens now locked |
609 *+--------------------+---------------+--------------------+------------------+
610 *| ACTIVE_SCAN | AF sweep done | NOT_FOCUSED_LOCKED | If AF successful |
611 *| | | | Lens now locked |
612 *+--------------------+---------------+--------------------+------------------+
613 *| ACTIVE_SCAN | AF_CANCEL | INACTIVE | Cancel/reset AF |
614 *| | | | Lens now locked |
615 *+--------------------+---------------+--------------------+------------------+
616 *| FOCUSED_LOCKED | AF_CANCEL | INACTIVE | Cancel/reset AF |
617 *+--------------------+---------------+--------------------+------------------+
618 *| FOCUSED_LOCKED | AF_TRIGGER | ACTIVE_SCAN | Start new sweep |
619 *| | | | Lens now moving |
620 *+--------------------+---------------+--------------------+------------------+
621 *| NOT_FOCUSED_LOCKED | AF_CANCEL | INACTIVE | Cancel/reset AF |
622 *+--------------------+---------------+--------------------+------------------+
623 *| NOT_FOCUSED_LOCKED | AF_TRIGGER | ACTIVE_SCAN | Start new sweep |
624 *| | | | Lens now moving |
625 *+--------------------+---------------+--------------------+------------------+
626 *| All states | mode change | INACTIVE | |
627 *+--------------------+---------------+--------------------+------------------+
628 *
629 * mode = AF_MODE_CONTINUOUS_VIDEO
630 *| state | trans. cause | new state | notes |
631 *+--------------------+---------------+--------------------+------------------+
632 *| INACTIVE | HAL initiates | PASSIVE_SCAN | Start AF scan |
633 *| | new scan | | Lens now moving |
634 *+--------------------+---------------+--------------------+------------------+
635 *| INACTIVE | AF_TRIGGER | NOT_FOCUSED_LOCKED | AF state query |
636 *| | | | Lens now locked |
637 *+--------------------+---------------+--------------------+------------------+
638 *| PASSIVE_SCAN | HAL completes | PASSIVE_FOCUSED | End AF scan |
639 *| | current scan | | Lens now locked |
640 *+--------------------+---------------+--------------------+------------------+
Eino-Ville Talvala4d45d302013-09-20 17:24:50 -0700641 *| PASSIVE_SCAN | HAL fails | PASSIVE_UNFOCUSED | End AF scan |
642 *| | current scan | | Lens now locked |
643 *+--------------------+---------------+--------------------+------------------+
Eino-Ville Talvalaacbc4512013-03-16 16:53:28 -0700644 *| PASSIVE_SCAN | AF_TRIGGER | FOCUSED_LOCKED | Immediate trans. |
645 *| | | | if focus is good |
646 *| | | | Lens now locked |
647 *+--------------------+---------------+--------------------+------------------+
648 *| PASSIVE_SCAN | AF_TRIGGER | NOT_FOCUSED_LOCKED | Immediate trans. |
649 *| | | | if focus is bad |
650 *| | | | Lens now locked |
651 *+--------------------+---------------+--------------------+------------------+
652 *| PASSIVE_SCAN | AF_CANCEL | INACTIVE | Reset lens |
653 *| | | | position |
654 *| | | | Lens now locked |
655 *+--------------------+---------------+--------------------+------------------+
656 *| PASSIVE_FOCUSED | HAL initiates | PASSIVE_SCAN | Start AF scan |
657 *| | new scan | | Lens now moving |
658 *+--------------------+---------------+--------------------+------------------+
Eino-Ville Talvala4d45d302013-09-20 17:24:50 -0700659 *| PASSIVE_UNFOCUSED | HAL initiates | PASSIVE_SCAN | Start AF scan |
660 *| | new scan | | Lens now moving |
661 *+--------------------+---------------+--------------------+------------------+
Eino-Ville Talvalaacbc4512013-03-16 16:53:28 -0700662 *| PASSIVE_FOCUSED | AF_TRIGGER | FOCUSED_LOCKED | Immediate trans. |
Eino-Ville Talvalaacbc4512013-03-16 16:53:28 -0700663 *| | | | Lens now locked |
664 *+--------------------+---------------+--------------------+------------------+
Eino-Ville Talvala4d45d302013-09-20 17:24:50 -0700665 *| PASSIVE_UNFOCUSED | AF_TRIGGER | NOT_FOCUSED_LOCKED | Immediate trans. |
Eino-Ville Talvalaacbc4512013-03-16 16:53:28 -0700666 *| | | | Lens now locked |
667 *+--------------------+---------------+--------------------+------------------+
668 *| FOCUSED_LOCKED | AF_TRIGGER | FOCUSED_LOCKED | No effect |
669 *+--------------------+---------------+--------------------+------------------+
670 *| FOCUSED_LOCKED | AF_CANCEL | INACTIVE | Restart AF scan |
671 *+--------------------+---------------+--------------------+------------------+
672 *| NOT_FOCUSED_LOCKED | AF_TRIGGER | NOT_FOCUSED_LOCKED | No effect |
673 *+--------------------+---------------+--------------------+------------------+
674 *| NOT_FOCUSED_LOCKED | AF_CANCEL | INACTIVE | Restart AF scan |
675 *+--------------------+---------------+--------------------+------------------+
676 *
677 * mode = AF_MODE_CONTINUOUS_PICTURE
678 *| state | trans. cause | new state | notes |
679 *+--------------------+---------------+--------------------+------------------+
680 *| INACTIVE | HAL initiates | PASSIVE_SCAN | Start AF scan |
681 *| | new scan | | Lens now moving |
682 *+--------------------+---------------+--------------------+------------------+
683 *| INACTIVE | AF_TRIGGER | NOT_FOCUSED_LOCKED | AF state query |
684 *| | | | Lens now locked |
685 *+--------------------+---------------+--------------------+------------------+
686 *| PASSIVE_SCAN | HAL completes | PASSIVE_FOCUSED | End AF scan |
687 *| | current scan | | Lens now locked |
688 *+--------------------+---------------+--------------------+------------------+
Eino-Ville Talvala4d45d302013-09-20 17:24:50 -0700689 *| PASSIVE_SCAN | HAL fails | PASSIVE_UNFOCUSED | End AF scan |
690 *| | current scan | | Lens now locked |
691 *+--------------------+---------------+--------------------+------------------+
Eino-Ville Talvalaacbc4512013-03-16 16:53:28 -0700692 *| PASSIVE_SCAN | AF_TRIGGER | FOCUSED_LOCKED | Eventual trans. |
693 *| | | | once focus good |
694 *| | | | Lens now locked |
695 *+--------------------+---------------+--------------------+------------------+
696 *| PASSIVE_SCAN | AF_TRIGGER | NOT_FOCUSED_LOCKED | Eventual trans. |
697 *| | | | if cannot focus |
698 *| | | | Lens now locked |
699 *+--------------------+---------------+--------------------+------------------+
700 *| PASSIVE_SCAN | AF_CANCEL | INACTIVE | Reset lens |
701 *| | | | position |
702 *| | | | Lens now locked |
703 *+--------------------+---------------+--------------------+------------------+
704 *| PASSIVE_FOCUSED | HAL initiates | PASSIVE_SCAN | Start AF scan |
705 *| | new scan | | Lens now moving |
706 *+--------------------+---------------+--------------------+------------------+
Eino-Ville Talvala4d45d302013-09-20 17:24:50 -0700707 *| PASSIVE_UNFOCUSED | HAL initiates | PASSIVE_SCAN | Start AF scan |
708 *| | new scan | | Lens now moving |
709 *+--------------------+---------------+--------------------+------------------+
Eino-Ville Talvalaacbc4512013-03-16 16:53:28 -0700710 *| PASSIVE_FOCUSED | AF_TRIGGER | FOCUSED_LOCKED | Immediate trans. |
Eino-Ville Talvalaacbc4512013-03-16 16:53:28 -0700711 *| | | | Lens now locked |
712 *+--------------------+---------------+--------------------+------------------+
Eino-Ville Talvala4d45d302013-09-20 17:24:50 -0700713 *| PASSIVE_UNFOCUSED | AF_TRIGGER | NOT_FOCUSED_LOCKED | Immediate trans. |
Eino-Ville Talvalaacbc4512013-03-16 16:53:28 -0700714 *| | | | Lens now locked |
715 *+--------------------+---------------+--------------------+------------------+
716 *| FOCUSED_LOCKED | AF_TRIGGER | FOCUSED_LOCKED | No effect |
717 *+--------------------+---------------+--------------------+------------------+
718 *| FOCUSED_LOCKED | AF_CANCEL | INACTIVE | Restart AF scan |
719 *+--------------------+---------------+--------------------+------------------+
720 *| NOT_FOCUSED_LOCKED | AF_TRIGGER | NOT_FOCUSED_LOCKED | No effect |
721 *+--------------------+---------------+--------------------+------------------+
722 *| NOT_FOCUSED_LOCKED | AF_CANCEL | INACTIVE | Restart AF scan |
723 *+--------------------+---------------+--------------------+------------------+
724 *
725 * S4.6. AE and AWB state machines
726 *
727 * The AE and AWB state machines are mostly identical. AE has additional
728 * FLASH_REQUIRED and PRECAPTURE states. So rows below that refer to those two
729 * states should be ignored for the AWB state machine.
730 *
Eino-Ville Talvala4d45d302013-09-20 17:24:50 -0700731 * when enabling AE/AWB or changing AE/AWB mode
732 *| state | trans. cause | new state | notes |
733 *+--------------------+---------------+--------------------+------------------+
734 *| Any | mode change | INACTIVE | |
735 *+--------------------+---------------+--------------------+------------------+
736 *
Eino-Ville Talvalaacbc4512013-03-16 16:53:28 -0700737 * mode = AE_MODE_OFF / AWB mode not AUTO
738 *| state | trans. cause | new state | notes |
739 *+--------------------+---------------+--------------------+------------------+
Eino-Ville Talvala4d45d302013-09-20 17:24:50 -0700740 *| INACTIVE | | INACTIVE | AE/AWB disabled |
Eino-Ville Talvalaacbc4512013-03-16 16:53:28 -0700741 *+--------------------+---------------+--------------------+------------------+
742 *
743 * mode = AE_MODE_ON_* / AWB_MODE_AUTO
744 *| state | trans. cause | new state | notes |
745 *+--------------------+---------------+--------------------+------------------+
746 *| INACTIVE | HAL initiates | SEARCHING | |
747 *| | AE/AWB scan | | |
748 *+--------------------+---------------+--------------------+------------------+
749 *| INACTIVE | AE/AWB_LOCK | LOCKED | values locked |
750 *| | on | | |
751 *+--------------------+---------------+--------------------+------------------+
752 *| SEARCHING | HAL finishes | CONVERGED | good values, not |
753 *| | AE/AWB scan | | changing |
754 *+--------------------+---------------+--------------------+------------------+
755 *| SEARCHING | HAL finishes | FLASH_REQUIRED | converged but too|
756 *| | AE scan | | dark w/o flash |
757 *+--------------------+---------------+--------------------+------------------+
758 *| SEARCHING | AE/AWB_LOCK | LOCKED | values locked |
759 *| | on | | |
760 *+--------------------+---------------+--------------------+------------------+
761 *| CONVERGED | HAL initiates | SEARCHING | values locked |
762 *| | AE/AWB scan | | |
763 *+--------------------+---------------+--------------------+------------------+
764 *| CONVERGED | AE/AWB_LOCK | LOCKED | values locked |
765 *| | on | | |
766 *+--------------------+---------------+--------------------+------------------+
Eino-Ville Talvala73dba5e2013-05-21 16:29:14 -0700767 *| FLASH_REQUIRED | HAL initiates | SEARCHING | values locked |
768 *| | AE/AWB scan | | |
769 *+--------------------+---------------+--------------------+------------------+
770 *| FLASH_REQUIRED | AE/AWB_LOCK | LOCKED | values locked |
771 *| | on | | |
772 *+--------------------+---------------+--------------------+------------------+
Eino-Ville Talvalaacbc4512013-03-16 16:53:28 -0700773 *| LOCKED | AE/AWB_LOCK | SEARCHING | values not good |
774 *| | off | | after unlock |
775 *+--------------------+---------------+--------------------+------------------+
776 *| LOCKED | AE/AWB_LOCK | CONVERGED | values good |
777 *| | off | | after unlock |
778 *+--------------------+---------------+--------------------+------------------+
779 *| LOCKED | AE_LOCK | FLASH_REQUIRED | exposure good, |
780 *| | off | | but too dark |
781 *+--------------------+---------------+--------------------+------------------+
782 *| All AE states | PRECAPTURE_ | PRECAPTURE | Start precapture |
783 *| | START | | sequence |
784 *+--------------------+---------------+--------------------+------------------+
785 *| PRECAPTURE | Sequence done.| CONVERGED | Ready for high- |
786 *| | AE_LOCK off | | quality capture |
787 *+--------------------+---------------+--------------------+------------------+
788 *| PRECAPTURE | Sequence done.| LOCKED | Ready for high- |
789 *| | AE_LOCK on | | quality capture |
790 *+--------------------+---------------+--------------------+------------------+
791 *
792 */
793
794/**
Eino-Ville Talvalab6059442013-04-29 15:26:16 -0700795 * S5. Cropping:
796 *
797 * Cropping of the full pixel array (for digital zoom and other use cases where
798 * a smaller FOV is desirable) is communicated through the
799 * ANDROID_SCALER_CROP_REGION setting. This is a per-request setting, and can
800 * change on a per-request basis, which is critical for implementing smooth
801 * digital zoom.
802 *
803 * The region is defined as a rectangle (x, y, width, height), with (x, y)
804 * describing the top-left corner of the rectangle. The rectangle is defined on
805 * the coordinate system of the sensor active pixel array, with (0,0) being the
806 * top-left pixel of the active pixel array. Therefore, the width and height
807 * cannot be larger than the dimensions reported in the
808 * ANDROID_SENSOR_ACTIVE_PIXEL_ARRAY static info field. The minimum allowed
809 * width and height are reported by the HAL through the
810 * ANDROID_SCALER_MAX_DIGITAL_ZOOM static info field, which describes the
811 * maximum supported zoom factor. Therefore, the minimum crop region width and
812 * height are:
813 *
814 * {width, height} =
815 * { floor(ANDROID_SENSOR_ACTIVE_PIXEL_ARRAY[0] /
816 * ANDROID_SCALER_MAX_DIGITAL_ZOOM),
817 * floor(ANDROID_SENSOR_ACTIVE_PIXEL_ARRAY[1] /
818 * ANDROID_SCALER_MAX_DIGITAL_ZOOM) }
819 *
820 * If the crop region needs to fulfill specific requirements (for example, it
821 * needs to start on even coordinates, and its width/height needs to be even),
822 * the HAL must do the necessary rounding and write out the final crop region
823 * used in the output result metadata. Similarly, if the HAL implements video
824 * stabilization, it must adjust the result crop region to describe the region
825 * actually included in the output after video stabilization is applied. In
826 * general, a camera-using application must be able to determine the field of
827 * view it is receiving based on the crop region, the dimensions of the image
828 * sensor, and the lens focal length.
829 *
830 * Since the crop region applies to all streams, which may have different aspect
831 * ratios than the crop region, the exact sensor region used for each stream may
832 * be smaller than the crop region. Specifically, each stream should maintain
833 * square pixels and its aspect ratio by minimally further cropping the defined
834 * crop region. If the stream's aspect ratio is wider than the crop region, the
835 * stream should be further cropped vertically, and if the stream's aspect ratio
836 * is narrower than the crop region, the stream should be further cropped
837 * horizontally.
838 *
839 * In all cases, the stream crop must be centered within the full crop region,
840 * and each stream is only either cropped horizontally or vertical relative to
841 * the full crop region, never both.
842 *
843 * For example, if two streams are defined, a 640x480 stream (4:3 aspect), and a
844 * 1280x720 stream (16:9 aspect), below demonstrates the expected output regions
845 * for each stream for a few sample crop regions, on a hypothetical 3 MP (2000 x
846 * 1500 pixel array) sensor.
847 *
848 * Crop region: (500, 375, 1000, 750) (4:3 aspect ratio)
849 *
850 * 640x480 stream crop: (500, 375, 1000, 750) (equal to crop region)
851 * 1280x720 stream crop: (500, 469, 1000, 562) (marked with =)
852 *
853 * 0 1000 2000
854 * +---------+---------+---------+----------+
855 * | Active pixel array |
856 * | |
857 * | |
858 * + +-------------------+ + 375
859 * | | | |
860 * | O===================O |
861 * | I 1280x720 stream I |
862 * + I I + 750
863 * | I I |
864 * | O===================O |
865 * | | | |
866 * + +-------------------+ + 1125
867 * | Crop region, 640x480 stream |
868 * | |
869 * | |
870 * +---------+---------+---------+----------+ 1500
871 *
872 * Crop region: (500, 375, 1333, 750) (16:9 aspect ratio)
873 *
874 * 640x480 stream crop: (666, 375, 1000, 750) (marked with =)
875 * 1280x720 stream crop: (500, 375, 1333, 750) (equal to crop region)
876 *
877 * 0 1000 2000
878 * +---------+---------+---------+----------+
879 * | Active pixel array |
880 * | |
881 * | |
882 * + +---O==================O---+ + 375
883 * | | I 640x480 stream I | |
884 * | | I I | |
885 * | | I I | |
886 * + | I I | + 750
887 * | | I I | |
888 * | | I I | |
889 * | | I I | |
890 * + +---O==================O---+ + 1125
891 * | Crop region, 1280x720 stream |
892 * | |
893 * | |
894 * +---------+---------+---------+----------+ 1500
895 *
896 * Crop region: (500, 375, 750, 750) (1:1 aspect ratio)
897 *
898 * 640x480 stream crop: (500, 469, 750, 562) (marked with =)
899 * 1280x720 stream crop: (500, 543, 750, 414) (marged with #)
900 *
901 * 0 1000 2000
902 * +---------+---------+---------+----------+
903 * | Active pixel array |
904 * | |
905 * | |
906 * + +--------------+ + 375
907 * | O==============O |
908 * | ################ |
909 * | # # |
910 * + # # + 750
911 * | # # |
912 * | ################ 1280x720 |
913 * | O==============O 640x480 |
914 * + +--------------+ + 1125
915 * | Crop region |
916 * | |
917 * | |
918 * +---------+---------+---------+----------+ 1500
919 *
920 * And a final example, a 1024x1024 square aspect ratio stream instead of the
921 * 480p stream:
922 *
923 * Crop region: (500, 375, 1000, 750) (4:3 aspect ratio)
924 *
925 * 1024x1024 stream crop: (625, 375, 750, 750) (marked with #)
926 * 1280x720 stream crop: (500, 469, 1000, 562) (marked with =)
927 *
928 * 0 1000 2000
929 * +---------+---------+---------+----------+
930 * | Active pixel array |
931 * | |
932 * | 1024x1024 stream |
933 * + +--###############--+ + 375
934 * | | # # | |
935 * | O===================O |
936 * | I 1280x720 stream I |
937 * + I I + 750
938 * | I I |
939 * | O===================O |
940 * | | # # | |
941 * + +--###############--+ + 1125
942 * | Crop region |
943 * | |
944 * | |
945 * +---------+---------+---------+----------+ 1500
946 *
947 */
948
949/**
950 * S6. Error management:
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800951 *
952 * Camera HAL device ops functions that have a return value will all return
953 * -ENODEV / NULL in case of a serious error. This means the device cannot
954 * continue operation, and must be closed by the framework. Once this error is
Alex Rayd5ddbc92013-02-15 13:47:24 -0800955 * returned by some method, or if notify() is called with ERROR_DEVICE, only
956 * the close() method can be called successfully. All other methods will return
957 * -ENODEV / NULL.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800958 *
Eino-Ville Talvalaacbc4512013-03-16 16:53:28 -0700959 * If a device op is called in the wrong sequence, for example if the framework
960 * calls configure_streams() is called before initialize(), the device must
961 * return -ENOSYS from the call, and do nothing.
962 *
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800963 * Transient errors in image capture must be reported through notify() as follows:
964 *
965 * - The failure of an entire capture to occur must be reported by the HAL by
966 * calling notify() with ERROR_REQUEST. Individual errors for the result
967 * metadata or the output buffers must not be reported in this case.
968 *
969 * - If the metadata for a capture cannot be produced, but some image buffers
970 * were filled, the HAL must call notify() with ERROR_RESULT.
971 *
972 * - If an output image buffer could not be filled, but either the metadata was
973 * produced or some other buffers were filled, the HAL must call notify() with
974 * ERROR_BUFFER for each failed buffer.
975 *
976 * In each of these transient failure cases, the HAL must still call
977 * process_capture_result, with valid output buffer_handle_t. If the result
978 * metadata could not be produced, it should be NULL. If some buffers could not
979 * be filled, their sync fences must be set to the error state.
980 *
Eino-Ville Talvalaacbc4512013-03-16 16:53:28 -0700981 * Invalid input arguments result in -EINVAL from the appropriate methods. In
982 * that case, the framework must act as if that call had never been made.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800983 *
984 */
985
986__BEGIN_DECLS
987
988struct camera3_device;
989
990/**********************************************************************
991 *
992 * Camera3 stream and stream buffer definitions.
993 *
994 * These structs and enums define the handles and contents of the input and
995 * output streams connecting the HAL to various framework and application buffer
996 * consumers. Each stream is backed by a gralloc buffer queue.
997 *
998 */
999
1000/**
1001 * camera3_stream_type_t:
1002 *
1003 * The type of the camera stream, which defines whether the camera HAL device is
1004 * the producer or the consumer for that stream, and how the buffers of the
1005 * stream relate to the other streams.
1006 */
1007typedef enum camera3_stream_type {
1008 /**
1009 * This stream is an output stream; the camera HAL device will be
1010 * responsible for filling buffers from this stream with newly captured or
1011 * reprocessed image data.
1012 */
1013 CAMERA3_STREAM_OUTPUT = 0,
1014
1015 /**
1016 * This stream is an input stream; the camera HAL device will be responsible
1017 * for reading buffers from this stream and sending them through the camera
1018 * processing pipeline, as if the buffer was a newly captured image from the
1019 * imager.
1020 */
1021 CAMERA3_STREAM_INPUT = 1,
1022
1023 /**
1024 * This stream can be used for input and output. Typically, the stream is
1025 * used as an output stream, but occasionally one already-filled buffer may
1026 * be sent back to the HAL device for reprocessing.
1027 *
1028 * This kind of stream is meant generally for zero-shutter-lag features,
1029 * where copying the captured image from the output buffer to the
1030 * reprocessing input buffer would be expensive. The stream will be used by
1031 * the framework as follows:
1032 *
1033 * 1. The framework includes a buffer from this stream as output buffer in a
1034 * request as normal.
1035 *
1036 * 2. Once the HAL device returns a filled output buffer to the framework,
1037 * the framework may do one of two things with the filled buffer:
1038 *
1039 * 2. a. The framework uses the filled data, and returns the now-used buffer
1040 * to the stream queue for reuse. This behavior exactly matches the
1041 * OUTPUT type of stream.
1042 *
1043 * 2. b. The framework wants to reprocess the filled data, and uses the
1044 * buffer as an input buffer for a request. Once the HAL device has
1045 * used the reprocessing buffer, it then returns it to the
1046 * framework. The framework then returns the now-used buffer to the
1047 * stream queue for reuse.
1048 *
1049 * 3. The HAL device will be given the buffer again as an output buffer for
1050 * a request at some future point.
1051 *
1052 * Note that the HAL will always be reprocessing data it produced.
1053 *
1054 */
1055 CAMERA3_STREAM_BIDIRECTIONAL = 2,
1056
1057 /**
1058 * Total number of framework-defined stream types
1059 */
1060 CAMERA3_NUM_STREAM_TYPES
1061
1062} camera3_stream_type_t;
1063
1064/**
1065 * camera3_stream_t:
1066 *
1067 * A handle to a single camera input or output stream. A stream is defined by
1068 * the framework by its buffer resolution and format, and additionally by the
1069 * HAL with the gralloc usage flags and the maximum in-flight buffer count.
1070 *
1071 * The stream structures are owned by the framework, but pointers to a
1072 * camera3_stream passed into the HAL by configure_streams() are valid until the
1073 * end of the first subsequent configure_streams() call that _does not_ include
1074 * that camera3_stream as an argument, or until the end of the close() call.
1075 *
1076 * All camera3_stream framework-controlled members are immutable once the
1077 * camera3_stream is passed into configure_streams(). The HAL may only change
1078 * the HAL-controlled parameters during a configure_streams() call, except for
1079 * the contents of the private pointer.
1080 *
1081 * If a configure_streams() call returns a non-fatal error, all active streams
1082 * remain valid as if configure_streams() had not been called.
1083 *
1084 * The endpoint of the stream is not visible to the camera HAL device.
Alex Ray2ce219a2013-06-14 15:09:30 -07001085 * In DEVICE_API_VERSION_3_1, this was changed to share consumer usage flags
1086 * on streams where the camera is a producer (OUTPUT and BIDIRECTIONAL stream
1087 * types) see the usage field below.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001088 */
1089typedef struct camera3_stream {
1090
1091 /*****
1092 * Set by framework before configure_streams()
1093 */
1094
1095 /**
1096 * The type of the stream, one of the camera3_stream_type_t values.
1097 */
1098 int stream_type;
1099
1100 /**
1101 * The width in pixels of the buffers in this stream
1102 */
1103 uint32_t width;
1104
1105 /**
1106 * The height in pixels of the buffers in this stream
1107 */
1108 uint32_t height;
1109
1110 /**
1111 * The pixel format for the buffers in this stream. Format is a value from
1112 * the HAL_PIXEL_FORMAT_* list in system/core/include/system/graphics.h, or
1113 * from device-specific headers.
1114 *
1115 * If HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED is used, then the platform
1116 * gralloc module will select a format based on the usage flags provided by
1117 * the camera device and the other endpoint of the stream.
1118 *
1119 * The camera HAL device must inspect the buffers handed to it in the
1120 * subsequent register_stream_buffers() call to obtain the
1121 * implementation-specific format details, if necessary.
1122 */
1123 int format;
1124
1125 /*****
1126 * Set by HAL during configure_streams().
1127 */
1128
1129 /**
1130 * The gralloc usage flags for this stream, as needed by the HAL. The usage
1131 * flags are defined in gralloc.h (GRALLOC_USAGE_*), or in device-specific
1132 * headers.
1133 *
1134 * For output streams, these are the HAL's producer usage flags. For input
1135 * streams, these are the HAL's consumer usage flags. The usage flags from
1136 * the producer and the consumer will be combined together and then passed
1137 * to the platform gralloc HAL module for allocating the gralloc buffers for
1138 * each stream.
Alex Ray2ce219a2013-06-14 15:09:30 -07001139 *
1140 * Version information:
1141 *
1142 * == CAMERA_DEVICE_API_VERSION_3_0:
1143 *
1144 * No initial value guaranteed when passed via configure_streams().
1145 * HAL may not use this field as input, and must write over this field
1146 * with its usage flags.
1147 *
1148 * >= CAMERA_DEVICE_API_VERSION_3_1:
1149 *
1150 * For stream_type OUTPUT and BIDIRECTIONAL, when passed via
1151 * configure_streams(), the initial value of this is the consumer's
1152 * usage flags. The HAL may use these consumer flags to decide stream
1153 * configuration.
1154 * For stream_type INPUT, when passed via configure_streams(), the initial
1155 * value of this is 0.
1156 * For all streams passed via configure_streams(), the HAL must write
1157 * over this field with its usage flags.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001158 */
1159 uint32_t usage;
1160
1161 /**
1162 * The maximum number of buffers the HAL device may need to have dequeued at
1163 * the same time. The HAL device may not have more buffers in-flight from
1164 * this stream than this value.
1165 */
1166 uint32_t max_buffers;
1167
1168 /**
1169 * A handle to HAL-private information for the stream. Will not be inspected
1170 * by the framework code.
1171 */
1172 void *priv;
1173
1174} camera3_stream_t;
1175
1176/**
1177 * camera3_stream_configuration_t:
1178 *
1179 * A structure of stream definitions, used by configure_streams(). This
1180 * structure defines all the output streams and the reprocessing input
1181 * stream for the current camera use case.
1182 */
1183typedef struct camera3_stream_configuration {
1184 /**
1185 * The total number of streams requested by the framework. This includes
1186 * both input and output streams. The number of streams will be at least 1,
1187 * and there will be at least one output-capable stream.
1188 */
1189 uint32_t num_streams;
1190
1191 /**
Eino-Ville Talvala3a6e6b42013-03-06 13:21:11 -08001192 * An array of camera stream pointers, defining the input/output
1193 * configuration for the camera HAL device.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001194 *
1195 * At most one input-capable stream may be defined (INPUT or BIDIRECTIONAL)
1196 * in a single configuration.
1197 *
1198 * At least one output-capable stream must be defined (OUTPUT or
1199 * BIDIRECTIONAL).
1200 */
Eino-Ville Talvala3a6e6b42013-03-06 13:21:11 -08001201 camera3_stream_t **streams;
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001202
1203} camera3_stream_configuration_t;
1204
1205/**
Eino-Ville Talvala2f8cf5c2013-03-06 13:23:31 -08001206 * camera3_buffer_status_t:
1207 *
1208 * The current status of a single stream buffer.
1209 */
1210typedef enum camera3_buffer_status {
1211 /**
1212 * The buffer is in a normal state, and can be used after waiting on its
1213 * sync fence.
1214 */
1215 CAMERA3_BUFFER_STATUS_OK = 0,
1216
1217 /**
1218 * The buffer does not contain valid data, and the data in it should not be
1219 * used. The sync fence must still be waited on before reusing the buffer.
1220 */
1221 CAMERA3_BUFFER_STATUS_ERROR = 1
1222
1223} camera3_buffer_status_t;
1224
1225/**
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001226 * camera3_stream_buffer_t:
1227 *
1228 * A single buffer from a camera3 stream. It includes a handle to its parent
1229 * stream, the handle to the gralloc buffer itself, and sync fences
1230 *
1231 * The buffer does not specify whether it is to be used for input or output;
1232 * that is determined by its parent stream type and how the buffer is passed to
1233 * the HAL device.
1234 */
1235typedef struct camera3_stream_buffer {
1236 /**
1237 * The handle of the stream this buffer is associated with
1238 */
1239 camera3_stream_t *stream;
1240
1241 /**
1242 * The native handle to the buffer
1243 */
1244 buffer_handle_t *buffer;
1245
1246 /**
Eino-Ville Talvala2f8cf5c2013-03-06 13:23:31 -08001247 * Current state of the buffer, one of the camera3_buffer_status_t
1248 * values. The framework will not pass buffers to the HAL that are in an
1249 * error state. In case a buffer could not be filled by the HAL, it must
1250 * have its status set to CAMERA3_BUFFER_STATUS_ERROR when returned to the
1251 * framework with process_capture_result().
1252 */
1253 int status;
1254
1255 /**
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001256 * The acquire sync fence for this buffer. The HAL must wait on this fence
1257 * fd before attempting to read from or write to this buffer.
1258 *
1259 * The framework may be set to -1 to indicate that no waiting is necessary
Eino-Ville Talvala2f8cf5c2013-03-06 13:23:31 -08001260 * for this buffer.
1261 *
1262 * When the HAL returns an output buffer to the framework with
1263 * process_capture_result(), the acquire_fence must be set to -1. If the HAL
1264 * never waits on the acquire_fence due to an error in filling a buffer,
1265 * when calling process_capture_result() the HAL must set the release_fence
1266 * of the buffer to be the acquire_fence passed to it by the framework. This
1267 * will allow the framework to wait on the fence before reusing the buffer.
1268 *
1269 * For input buffers, the HAL must not change the acquire_fence field during
1270 * the process_capture_request() call.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001271 */
1272 int acquire_fence;
1273
1274 /**
1275 * The release sync fence for this buffer. The HAL must set this fence when
1276 * returning buffers to the framework, or write -1 to indicate that no
1277 * waiting is required for this buffer.
1278 *
1279 * For the input buffer, the release fence must be set by the
1280 * process_capture_request() call. For the output buffers, the fences must
1281 * be set in the output_buffers array passed to process_capture_result().
Eino-Ville Talvala2f8cf5c2013-03-06 13:23:31 -08001282 *
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001283 */
1284 int release_fence;
1285
1286} camera3_stream_buffer_t;
1287
1288/**
1289 * camera3_stream_buffer_set_t:
1290 *
1291 * The complete set of gralloc buffers for a stream. This structure is given to
1292 * register_stream_buffers() to allow the camera HAL device to register/map/etc
1293 * newly allocated stream buffers.
1294 */
1295typedef struct camera3_stream_buffer_set {
1296 /**
1297 * The stream handle for the stream these buffers belong to
1298 */
1299 camera3_stream_t *stream;
1300
1301 /**
1302 * The number of buffers in this stream. It is guaranteed to be at least
1303 * stream->max_buffers.
1304 */
1305 uint32_t num_buffers;
1306
1307 /**
1308 * The array of gralloc buffer handles for this stream. If the stream format
1309 * is set to HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, the camera HAL device
1310 * should inspect the passed-in buffers to determine any platform-private
1311 * pixel format information.
1312 */
Eino-Ville Talvala3a6e6b42013-03-06 13:21:11 -08001313 buffer_handle_t **buffers;
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001314
1315} camera3_stream_buffer_set_t;
1316
1317/**
1318 * camera3_jpeg_blob:
1319 *
1320 * Transport header for compressed JPEG buffers in output streams.
1321 *
1322 * To capture JPEG images, a stream is created using the pixel format
1323 * HAL_PIXEL_FORMAT_BLOB, and the static metadata field android.jpeg.maxSize is
1324 * used as the buffer size. Since compressed JPEG images are of variable size,
1325 * the HAL needs to include the final size of the compressed image using this
1326 * structure inside the output stream buffer. The JPEG blob ID field must be set
1327 * to CAMERA3_JPEG_BLOB_ID.
1328 *
1329 * Transport header should be at the end of the JPEG output stream buffer. That
1330 * means the jpeg_blob_id must start at byte[android.jpeg.maxSize -
1331 * sizeof(camera3_jpeg_blob)]. Any HAL using this transport header must
1332 * account for it in android.jpeg.maxSize. The JPEG data itself starts at
1333 * the beginning of the buffer and should be jpeg_size bytes long.
1334 */
1335typedef struct camera3_jpeg_blob {
1336 uint16_t jpeg_blob_id;
1337 uint32_t jpeg_size;
1338} camera3_jpeg_blob_t;
1339
1340enum {
1341 CAMERA3_JPEG_BLOB_ID = 0x00FF
1342};
1343
1344/**********************************************************************
1345 *
1346 * Message definitions for the HAL notify() callback.
1347 *
1348 * These definitions are used for the HAL notify callback, to signal
1349 * asynchronous events from the HAL device to the Android framework.
1350 *
1351 */
1352
1353/**
1354 * camera3_msg_type:
1355 *
1356 * Indicates the type of message sent, which specifies which member of the
1357 * message union is valid.
1358 *
1359 */
1360typedef enum camera3_msg_type {
1361 /**
1362 * An error has occurred. camera3_notify_msg.message.error contains the
1363 * error information.
1364 */
1365 CAMERA3_MSG_ERROR = 1,
1366
1367 /**
1368 * The exposure of a given request has
1369 * begun. camera3_notify_msg.message.shutter contains the information
1370 * the capture.
1371 */
1372 CAMERA3_MSG_SHUTTER = 2,
1373
1374 /**
1375 * Number of framework message types
1376 */
1377 CAMERA3_NUM_MESSAGES
1378
1379} camera3_msg_type_t;
1380
1381/**
1382 * Defined error codes for CAMERA_MSG_ERROR
1383 */
1384typedef enum camera3_error_msg_code {
1385 /**
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001386 * A serious failure occured. No further frames or buffer streams will
1387 * be produced by the device. Device should be treated as closed. The
1388 * client must reopen the device to use it again. The frame_number field
1389 * is unused.
1390 */
Alex Rayd5ddbc92013-02-15 13:47:24 -08001391 CAMERA3_MSG_ERROR_DEVICE = 1,
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001392
1393 /**
1394 * An error has occurred in processing a request. No output (metadata or
1395 * buffers) will be produced for this request. The frame_number field
1396 * specifies which request has been dropped. Subsequent requests are
1397 * unaffected, and the device remains operational.
1398 */
Alex Rayd5ddbc92013-02-15 13:47:24 -08001399 CAMERA3_MSG_ERROR_REQUEST = 2,
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001400
1401 /**
1402 * An error has occurred in producing an output result metadata buffer
1403 * for a request, but output stream buffers for it will still be
1404 * available. Subsequent requests are unaffected, and the device remains
1405 * operational. The frame_number field specifies the request for which
1406 * result metadata won't be available.
1407 */
Alex Rayd5ddbc92013-02-15 13:47:24 -08001408 CAMERA3_MSG_ERROR_RESULT = 3,
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001409
1410 /**
1411 * An error has occurred in placing an output buffer into a stream for a
1412 * request. The frame metadata and other buffers may still be
1413 * available. Subsequent requests are unaffected, and the device remains
1414 * operational. The frame_number field specifies the request for which the
1415 * buffer was dropped, and error_stream contains a pointer to the stream
1416 * that dropped the frame.u
1417 */
Alex Rayd5ddbc92013-02-15 13:47:24 -08001418 CAMERA3_MSG_ERROR_BUFFER = 4,
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001419
1420 /**
1421 * Number of error types
1422 */
1423 CAMERA3_MSG_NUM_ERRORS
1424
1425} camera3_error_msg_code_t;
1426
1427/**
1428 * camera3_error_msg_t:
1429 *
1430 * Message contents for CAMERA3_MSG_ERROR
1431 */
1432typedef struct camera3_error_msg {
1433 /**
1434 * Frame number of the request the error applies to. 0 if the frame number
1435 * isn't applicable to the error.
1436 */
1437 uint32_t frame_number;
1438
1439 /**
1440 * Pointer to the stream that had a failure. NULL if the stream isn't
1441 * applicable to the error.
1442 */
1443 camera3_stream_t *error_stream;
1444
1445 /**
1446 * The code for this error; one of the CAMERA_MSG_ERROR enum values.
1447 */
1448 int error_code;
1449
1450} camera3_error_msg_t;
1451
1452/**
1453 * camera3_shutter_msg_t:
1454 *
1455 * Message contents for CAMERA3_MSG_SHUTTER
1456 */
1457typedef struct camera3_shutter_msg {
1458 /**
1459 * Frame number of the request that has begun exposure
1460 */
1461 uint32_t frame_number;
1462
1463 /**
1464 * Timestamp for the start of capture. This must match the capture result
1465 * metadata's sensor exposure start timestamp.
1466 */
1467 uint64_t timestamp;
1468
1469} camera3_shutter_msg_t;
1470
1471/**
1472 * camera3_notify_msg_t:
1473 *
1474 * The message structure sent to camera3_callback_ops_t.notify()
1475 */
1476typedef struct camera3_notify_msg {
1477
1478 /**
1479 * The message type. One of camera3_notify_msg_type, or a private extension.
1480 */
1481 int type;
1482
1483 union {
1484 /**
1485 * Error message contents. Valid if type is CAMERA3_MSG_ERROR
1486 */
1487 camera3_error_msg_t error;
1488
1489 /**
1490 * Shutter message contents. Valid if type is CAMERA3_MSG_SHUTTER
1491 */
1492 camera3_shutter_msg_t shutter;
1493
1494 /**
1495 * Generic message contents. Used to ensure a minimum size for custom
1496 * message types.
1497 */
1498 uint8_t generic[32];
1499 } message;
1500
1501} camera3_notify_msg_t;
1502
1503/**********************************************************************
1504 *
1505 * Capture request/result definitions for the HAL process_capture_request()
1506 * method, and the process_capture_result() callback.
1507 *
1508 */
1509
1510/**
1511 * camera3_request_template_t:
1512 *
1513 * Available template types for
1514 * camera3_device_ops.construct_default_request_settings()
1515 */
1516typedef enum camera3_request_template {
1517 /**
1518 * Standard camera preview operation with 3A on auto.
1519 */
1520 CAMERA3_TEMPLATE_PREVIEW = 1,
1521
1522 /**
1523 * Standard camera high-quality still capture with 3A and flash on auto.
1524 */
1525 CAMERA3_TEMPLATE_STILL_CAPTURE = 2,
1526
1527 /**
1528 * Standard video recording plus preview with 3A on auto, torch off.
1529 */
1530 CAMERA3_TEMPLATE_VIDEO_RECORD = 3,
1531
1532 /**
1533 * High-quality still capture while recording video. Application will
1534 * include preview, video record, and full-resolution YUV or JPEG streams in
1535 * request. Must not cause stuttering on video stream. 3A on auto.
1536 */
1537 CAMERA3_TEMPLATE_VIDEO_SNAPSHOT = 4,
1538
1539 /**
1540 * Zero-shutter-lag mode. Application will request preview and
1541 * full-resolution data for each frame, and reprocess it to JPEG when a
1542 * still image is requested by user. Settings should provide highest-quality
1543 * full-resolution images without compromising preview frame rate. 3A on
1544 * auto.
1545 */
1546 CAMERA3_TEMPLATE_ZERO_SHUTTER_LAG = 5,
1547
Zhijun Heb0c939f2013-12-13 15:56:33 -08001548 /**
1549 * A basic template for direct application control of capture
1550 * parameters. All automatic control is disabled (auto-exposure, auto-white
1551 * balance, auto-focus), and post-processing parameters are set to preview
1552 * quality. The manual capture parameters (exposure, sensitivity, etc.)
1553 * are set to reasonable defaults, but should be overridden by the
1554 * application depending on the intended use case.
1555 */
1556 CAMERA3_TEMPLATE_MANUAL = 6,
1557
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001558 /* Total number of templates */
1559 CAMERA3_TEMPLATE_COUNT,
1560
1561 /**
1562 * First value for vendor-defined request templates
1563 */
1564 CAMERA3_VENDOR_TEMPLATE_START = 0x40000000
1565
1566} camera3_request_template_t;
1567
1568/**
1569 * camera3_capture_request_t:
1570 *
1571 * A single request for image capture/buffer reprocessing, sent to the Camera
1572 * HAL device by the framework in process_capture_request().
1573 *
1574 * The request contains the settings to be used for this capture, and the set of
1575 * output buffers to write the resulting image data in. It may optionally
1576 * contain an input buffer, in which case the request is for reprocessing that
1577 * input buffer instead of capturing a new image with the camera sensor. The
1578 * capture is identified by the frame_number.
1579 *
1580 * In response, the camera HAL device must send a camera3_capture_result
1581 * structure asynchronously to the framework, using the process_capture_result()
1582 * callback.
1583 */
1584typedef struct camera3_capture_request {
1585 /**
1586 * The frame number is an incrementing integer set by the framework to
1587 * uniquely identify this capture. It needs to be returned in the result
1588 * call, and is also used to identify the request in asynchronous
1589 * notifications sent to camera3_callback_ops_t.notify().
1590 */
1591 uint32_t frame_number;
1592
1593 /**
1594 * The settings buffer contains the capture and processing parameters for
1595 * the request. As a special case, a NULL settings buffer indicates that the
1596 * settings are identical to the most-recently submitted capture request. A
1597 * NULL buffer cannot be used as the first submitted request after a
1598 * configure_streams() call.
1599 */
1600 const camera_metadata_t *settings;
1601
1602 /**
1603 * The input stream buffer to use for this request, if any.
1604 *
1605 * If input_buffer is NULL, then the request is for a new capture from the
1606 * imager. If input_buffer is valid, the request is for reprocessing the
1607 * image contained in input_buffer.
1608 *
1609 * In the latter case, the HAL must set the release_fence of the
1610 * input_buffer to a valid sync fence, or to -1 if the HAL does not support
1611 * sync, before process_capture_request() returns.
1612 *
1613 * The HAL is required to wait on the acquire sync fence of the input buffer
1614 * before accessing it.
1615 *
1616 * Any input buffer included here will have been registered with the HAL
1617 * through register_stream_buffers() before its inclusion in a request.
1618 */
1619 camera3_stream_buffer_t *input_buffer;
1620
1621 /**
1622 * The number of output buffers for this capture request. Must be at least
1623 * 1.
1624 */
1625 uint32_t num_output_buffers;
1626
1627 /**
1628 * An array of num_output_buffers stream buffers, to be filled with image
1629 * data from this capture/reprocess. The HAL must wait on the acquire fences
1630 * of each stream buffer before writing to them. All the buffers included
1631 * here will have been registered with the HAL through
1632 * register_stream_buffers() before their inclusion in a request.
1633 *
1634 * The HAL takes ownership of the actual buffer_handle_t entries in
1635 * output_buffers; the framework does not access them until they are
1636 * returned in a camera3_capture_result_t.
1637 */
1638 const camera3_stream_buffer_t *output_buffers;
1639
1640} camera3_capture_request_t;
1641
1642/**
1643 * camera3_capture_result_t:
1644 *
1645 * The result of a single capture/reprocess by the camera HAL device. This is
1646 * sent to the framework asynchronously with process_capture_result(), in
1647 * response to a single capture request sent to the HAL with
Eino-Ville Talvala7c9416b2013-04-03 15:18:20 -07001648 * process_capture_request(). Multiple process_capture_result() calls may be
1649 * performed by the HAL for each request. Each call, all with the same frame
1650 * number, may contain some subset of the output buffers, and/or the result
1651 * metadata. The metadata may only be provided once for a given frame number;
1652 * all other calls must set the result metadata to NULL.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001653 *
1654 * The result structure contains the output metadata from this capture, and the
1655 * set of output buffers that have been/will be filled for this capture. Each
1656 * output buffer may come with a release sync fence that the framework will wait
1657 * on before reading, in case the buffer has not yet been filled by the HAL.
1658 *
1659 */
1660typedef struct camera3_capture_result {
1661 /**
1662 * The frame number is an incrementing integer set by the framework in the
1663 * submitted request to uniquely identify this capture. It is also used to
1664 * identify the request in asynchronous notifications sent to
1665 * camera3_callback_ops_t.notify().
1666 */
1667 uint32_t frame_number;
1668
1669 /**
1670 * The result metadata for this capture. This contains information about the
1671 * final capture parameters, the state of the capture and post-processing
1672 * hardware, the state of the 3A algorithms, if enabled, and the output of
1673 * any enabled statistics units.
Eino-Ville Talvala7c9416b2013-04-03 15:18:20 -07001674 *
1675 * Only one call to process_capture_result() with a given frame_number may
1676 * include the result metadata. All other calls for the same frame_number
1677 * must set this to NULL.
1678 *
1679 * If there was an error producing the result metadata, result must be an
1680 * empty metadata buffer, and notify() must be called with ERROR_RESULT.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001681 */
1682 const camera_metadata_t *result;
1683
1684 /**
Eino-Ville Talvala7c9416b2013-04-03 15:18:20 -07001685 * The number of output buffers returned in this result structure. Must be
1686 * less than or equal to the matching capture request's count. If this is
1687 * less than the buffer count in the capture request, at least one more call
1688 * to process_capture_result with the same frame_number must be made, to
1689 * return the remaining output buffers to the framework. This may only be
1690 * zero if the structure includes valid result metadata.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001691 */
1692 uint32_t num_output_buffers;
1693
1694 /**
1695 * The handles for the output stream buffers for this capture. They may not
1696 * yet be filled at the time the HAL calls process_capture_result(); the
1697 * framework will wait on the release sync fences provided by the HAL before
1698 * reading the buffers.
1699 *
1700 * The HAL must set the stream buffer's release sync fence to a valid sync
1701 * fd, or to -1 if the buffer has already been filled.
Eino-Ville Talvala2f8cf5c2013-03-06 13:23:31 -08001702 *
1703 * If the HAL encounters an error while processing the buffer, and the
1704 * buffer is not filled, the buffer's status field must be set to
1705 * CAMERA3_BUFFER_STATUS_ERROR. If the HAL did not wait on the acquire fence
1706 * before encountering the error, the acquire fence should be copied into
1707 * the release fence, to allow the framework to wait on the fence before
1708 * reusing the buffer.
1709 *
Eino-Ville Talvala7c9416b2013-04-03 15:18:20 -07001710 * The acquire fence must be set to -1 for all output buffers. If
1711 * num_output_buffers is zero, this may be NULL. In that case, at least one
1712 * more process_capture_result call must be made by the HAL to provide the
1713 * output buffers.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001714 */
1715 const camera3_stream_buffer_t *output_buffers;
1716
1717} camera3_capture_result_t;
1718
1719/**********************************************************************
1720 *
1721 * Callback methods for the HAL to call into the framework.
1722 *
1723 * These methods are used to return metadata and image buffers for a completed
1724 * or failed captures, and to notify the framework of asynchronous events such
1725 * as errors.
1726 *
1727 * The framework will not call back into the HAL from within these callbacks,
1728 * and these calls will not block for extended periods.
1729 *
1730 */
1731typedef struct camera3_callback_ops {
1732
1733 /**
1734 * process_capture_result:
1735 *
Eino-Ville Talvala7c9416b2013-04-03 15:18:20 -07001736 * Send results from a completed capture to the framework.
1737 * process_capture_result() may be invoked multiple times by the HAL in
1738 * response to a single capture request. This allows, for example, the
1739 * metadata and low-resolution buffers to be returned in one call, and
1740 * post-processed JPEG buffers in a later call, once it is available. Each
1741 * call must include the frame number of the request it is returning
1742 * metadata or buffers for.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001743 *
Eino-Ville Talvala7c9416b2013-04-03 15:18:20 -07001744 * A component (buffer or metadata) of the complete result may only be
1745 * included in one process_capture_result call. A buffer for each stream,
1746 * and the result metadata, must be returned by the HAL for each request in
1747 * one of the process_capture_result calls, even in case of errors producing
1748 * some of the output. A call to process_capture_result() with neither
1749 * output buffers or result metadata is not allowed.
1750 *
1751 * The order of returning metadata and buffers for a single result does not
1752 * matter, but buffers for a given stream must be returned in FIFO order. So
1753 * the buffer for request 5 for stream A must always be returned before the
1754 * buffer for request 6 for stream A. This also applies to the result
1755 * metadata; the metadata for request 5 must be returned before the metadata
1756 * for request 6.
1757 *
1758 * However, different streams are independent of each other, so it is
1759 * acceptable and expected that the buffer for request 5 for stream A may be
1760 * returned after the buffer for request 6 for stream B is. And it is
1761 * acceptable that the result metadata for request 6 for stream B is
1762 * returned before the buffer for request 5 for stream A is.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001763 *
1764 * The HAL retains ownership of result structure, which only needs to be
1765 * valid to access during this call. The framework will copy whatever it
1766 * needs before this call returns.
1767 *
1768 * The output buffers do not need to be filled yet; the framework will wait
1769 * on the stream buffer release sync fence before reading the buffer
Eino-Ville Talvala7c9416b2013-04-03 15:18:20 -07001770 * data. Therefore, this method should be called by the HAL as soon as
1771 * possible, even if some or all of the output buffers are still in
1772 * being filled. The HAL must include valid release sync fences into each
1773 * output_buffers stream buffer entry, or -1 if that stream buffer is
1774 * already filled.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001775 *
1776 * If the result buffer cannot be constructed for a request, the HAL should
Eino-Ville Talvala7c9416b2013-04-03 15:18:20 -07001777 * return an empty metadata buffer, but still provide the output buffers and
1778 * their sync fences. In addition, notify() must be called with an
1779 * ERROR_RESULT message.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001780 *
Eino-Ville Talvala2f8cf5c2013-03-06 13:23:31 -08001781 * If an output buffer cannot be filled, its status field must be set to
1782 * STATUS_ERROR. In addition, notify() must be called with a ERROR_BUFFER
1783 * message.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001784 *
1785 * If the entire capture has failed, then this method still needs to be
Eino-Ville Talvala2f8cf5c2013-03-06 13:23:31 -08001786 * called to return the output buffers to the framework. All the buffer
Eino-Ville Talvala7c9416b2013-04-03 15:18:20 -07001787 * statuses should be STATUS_ERROR, and the result metadata should be an
1788 * empty buffer. In addition, notify() must be called with a ERROR_REQUEST
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001789 * message. In this case, individual ERROR_RESULT/ERROR_BUFFER messages
1790 * should not be sent.
1791 *
1792 */
1793 void (*process_capture_result)(const struct camera3_callback_ops *,
1794 const camera3_capture_result_t *result);
1795
1796 /**
1797 * notify:
1798 *
1799 * Asynchronous notification callback from the HAL, fired for various
1800 * reasons. Only for information independent of frame capture, or that
1801 * require specific timing. The ownership of the message structure remains
1802 * with the HAL, and the msg only needs to be valid for the duration of this
1803 * call.
1804 *
Eino-Ville Talvala71af1022013-04-22 14:19:21 -07001805 * The notification for the start of exposure for a given request must be
1806 * sent by the HAL before the first call to process_capture_result() for
1807 * that request is made.
1808 *
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001809 * Multiple threads may call notify() simultaneously.
1810 */
1811 void (*notify)(const struct camera3_callback_ops *,
1812 const camera3_notify_msg_t *msg);
1813
1814} camera3_callback_ops_t;
1815
1816/**********************************************************************
1817 *
1818 * Camera device operations
1819 *
1820 */
1821typedef struct camera3_device_ops {
1822
1823 /**
1824 * initialize:
1825 *
1826 * One-time initialization to pass framework callback function pointers to
1827 * the HAL. Will be called once after a successful open() call, before any
1828 * other functions are called on the camera3_device_ops structure.
1829 *
1830 * Return values:
1831 *
1832 * 0: On successful initialization
1833 *
1834 * -ENODEV: If initialization fails. Only close() can be called successfully
1835 * by the framework after this.
1836 */
1837 int (*initialize)(const struct camera3_device *,
1838 const camera3_callback_ops_t *callback_ops);
1839
1840 /**********************************************************************
1841 * Stream management
1842 */
1843
1844 /**
1845 * configure_streams:
1846 *
1847 * Reset the HAL camera device processing pipeline and set up new input and
1848 * output streams. This call replaces any existing stream configuration with
1849 * the streams defined in the stream_list. This method will be called at
1850 * least once after initialize() before a request is submitted with
1851 * process_capture_request().
1852 *
1853 * The stream_list must contain at least one output-capable stream, and may
1854 * not contain more than one input-capable stream.
1855 *
1856 * The stream_list may contain streams that are also in the currently-active
1857 * set of streams (from the previous call to configure_stream()). These
1858 * streams will already have valid values for usage, max_buffers, and the
1859 * private pointer. If such a stream has already had its buffers registered,
1860 * register_stream_buffers() will not be called again for the stream, and
1861 * buffers from the stream can be immediately included in input requests.
1862 *
1863 * If the HAL needs to change the stream configuration for an existing
1864 * stream due to the new configuration, it may rewrite the values of usage
1865 * and/or max_buffers during the configure call. The framework will detect
1866 * such a change, and will then reallocate the stream buffers, and call
1867 * register_stream_buffers() again before using buffers from that stream in
1868 * a request.
1869 *
1870 * If a currently-active stream is not included in stream_list, the HAL may
1871 * safely remove any references to that stream. It will not be reused in a
1872 * later configure() call by the framework, and all the gralloc buffers for
1873 * it will be freed after the configure_streams() call returns.
1874 *
1875 * The stream_list structure is owned by the framework, and may not be
1876 * accessed once this call completes. The address of an individual
1877 * camera3_stream_t structure will remain valid for access by the HAL until
1878 * the end of the first configure_stream() call which no longer includes
1879 * that camera3_stream_t in the stream_list argument. The HAL may not change
1880 * values in the stream structure outside of the private pointer, except for
1881 * the usage and max_buffers members during the configure_streams() call
1882 * itself.
1883 *
1884 * If the stream is new, the usage, max_buffer, and private pointer fields
1885 * of the stream structure will all be set to 0. The HAL device must set
1886 * these fields before the configure_streams() call returns. These fields
1887 * are then used by the framework and the platform gralloc module to
1888 * allocate the gralloc buffers for each stream.
1889 *
1890 * Before such a new stream can have its buffers included in a capture
1891 * request, the framework will call register_stream_buffers() with that
1892 * stream. However, the framework is not required to register buffers for
1893 * _all_ streams before submitting a request. This allows for quick startup
1894 * of (for example) a preview stream, with allocation for other streams
1895 * happening later or concurrently.
1896 *
1897 * Preconditions:
1898 *
1899 * The framework will only call this method when no captures are being
1900 * processed. That is, all results have been returned to the framework, and
1901 * all in-flight input and output buffers have been returned and their
1902 * release sync fences have been signaled by the HAL. The framework will not
1903 * submit new requests for capture while the configure_streams() call is
1904 * underway.
1905 *
1906 * Postconditions:
1907 *
1908 * The HAL device must configure itself to provide maximum possible output
1909 * frame rate given the sizes and formats of the output streams, as
1910 * documented in the camera device's static metadata.
1911 *
1912 * Performance expectations:
1913 *
1914 * This call is expected to be heavyweight and possibly take several hundred
1915 * milliseconds to complete, since it may require resetting and
1916 * reconfiguring the image sensor and the camera processing pipeline.
1917 * Nevertheless, the HAL device should attempt to minimize the
1918 * reconfiguration delay to minimize the user-visible pauses during
1919 * application operational mode changes (such as switching from still
1920 * capture to video recording).
1921 *
1922 * Return values:
1923 *
1924 * 0: On successful stream configuration
1925 *
1926 * -EINVAL: If the requested stream configuration is invalid. Some examples
1927 * of invalid stream configurations include:
1928 *
1929 * - Including more than 1 input-capable stream (INPUT or
1930 * BIDIRECTIONAL)
1931 *
1932 * - Not including any output-capable streams (OUTPUT or
1933 * BIDIRECTIONAL)
1934 *
1935 * - Including streams with unsupported formats, or an unsupported
1936 * size for that format.
1937 *
1938 * - Including too many output streams of a certain format.
1939 *
Eino-Ville Talvala7effe0c2013-02-15 12:09:48 -08001940 * Note that the framework submitting an invalid stream
1941 * configuration is not normal operation, since stream
1942 * configurations are checked before configure. An invalid
1943 * configuration means that a bug exists in the framework code, or
1944 * there is a mismatch between the HAL's static metadata and the
1945 * requirements on streams.
1946 *
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001947 * -ENODEV: If there has been a fatal error and the device is no longer
1948 * operational. Only close() can be called successfully by the
1949 * framework after this error is returned.
1950 */
1951 int (*configure_streams)(const struct camera3_device *,
1952 camera3_stream_configuration_t *stream_list);
1953
1954 /**
1955 * register_stream_buffers:
1956 *
1957 * Register buffers for a given stream with the HAL device. This method is
1958 * called by the framework after a new stream is defined by
1959 * configure_streams, and before buffers from that stream are included in a
1960 * capture request. If the same stream is listed in a subsequent
1961 * configure_streams() call, register_stream_buffers will _not_ be called
1962 * again for that stream.
1963 *
1964 * The framework does not need to register buffers for all configured
1965 * streams before it submits the first capture request. This allows quick
1966 * startup for preview (or similar use cases) while other streams are still
1967 * being allocated.
1968 *
1969 * This method is intended to allow the HAL device to map or otherwise
1970 * prepare the buffers for later use. The buffers passed in will already be
1971 * locked for use. At the end of the call, all the buffers must be ready to
1972 * be returned to the stream. The buffer_set argument is only valid for the
1973 * duration of this call.
1974 *
1975 * If the stream format was set to HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED,
1976 * the camera HAL should inspect the passed-in buffers here to determine any
1977 * platform-private pixel format information.
1978 *
1979 * Return values:
1980 *
1981 * 0: On successful registration of the new stream buffers
1982 *
1983 * -EINVAL: If the stream_buffer_set does not refer to a valid active
1984 * stream, or if the buffers array is invalid.
1985 *
1986 * -ENOMEM: If there was a failure in registering the buffers. The framework
1987 * must consider all the stream buffers to be unregistered, and can
1988 * try to register again later.
1989 *
1990 * -ENODEV: If there is a fatal error, and the device is no longer
1991 * operational. Only close() can be called successfully by the
1992 * framework after this error is returned.
1993 */
1994 int (*register_stream_buffers)(const struct camera3_device *,
1995 const camera3_stream_buffer_set_t *buffer_set);
1996
1997 /**********************************************************************
1998 * Request creation and submission
1999 */
2000
2001 /**
2002 * construct_default_request_settings:
2003 *
2004 * Create capture settings for standard camera use cases.
2005 *
2006 * The device must return a settings buffer that is configured to meet the
2007 * requested use case, which must be one of the CAMERA3_TEMPLATE_*
2008 * enums. All request control fields must be included.
2009 *
2010 * The HAL retains ownership of this structure, but the pointer to the
2011 * structure must be valid until the device is closed. The framework and the
2012 * HAL may not modify the buffer once it is returned by this call. The same
2013 * buffer may be returned for subsequent calls for the same template, or for
2014 * other templates.
2015 *
2016 * Return values:
2017 *
2018 * Valid metadata: On successful creation of a default settings
2019 * buffer.
2020 *
2021 * NULL: In case of a fatal error. After this is returned, only
Eino-Ville Talvalaacbc4512013-03-16 16:53:28 -07002022 * the close() method can be called successfully by the
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002023 * framework.
2024 */
2025 const camera_metadata_t* (*construct_default_request_settings)(
2026 const struct camera3_device *,
2027 int type);
2028
2029 /**
2030 * process_capture_request:
2031 *
2032 * Send a new capture request to the HAL. The HAL should not return from
2033 * this call until it is ready to accept the next request to process. Only
2034 * one call to process_capture_request() will be made at a time by the
2035 * framework, and the calls will all be from the same thread. The next call
2036 * to process_capture_request() will be made as soon as a new request and
2037 * its associated buffers are available. In a normal preview scenario, this
2038 * means the function will be called again by the framework almost
2039 * instantly.
2040 *
2041 * The actual request processing is asynchronous, with the results of
2042 * capture being returned by the HAL through the process_capture_result()
2043 * call. This call requires the result metadata to be available, but output
2044 * buffers may simply provide sync fences to wait on. Multiple requests are
2045 * expected to be in flight at once, to maintain full output frame rate.
2046 *
2047 * The framework retains ownership of the request structure. It is only
2048 * guaranteed to be valid during this call. The HAL device must make copies
Eino-Ville Talvala71af1022013-04-22 14:19:21 -07002049 * of the information it needs to retain for the capture processing. The HAL
2050 * is responsible for waiting on and closing the buffers' fences and
2051 * returning the buffer handles to the framework.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002052 *
2053 * The HAL must write the file descriptor for the input buffer's release
2054 * sync fence into input_buffer->release_fence, if input_buffer is not
2055 * NULL. If the HAL returns -1 for the input buffer release sync fence, the
2056 * framework is free to immediately reuse the input buffer. Otherwise, the
2057 * framework will wait on the sync fence before refilling and reusing the
2058 * input buffer.
2059 *
2060 * Return values:
2061 *
2062 * 0: On a successful start to processing the capture request
2063 *
2064 * -EINVAL: If the input is malformed (the settings are NULL when not
2065 * allowed, there are 0 output buffers, etc) and capture processing
2066 * cannot start. Failures during request processing should be
Eino-Ville Talvala71af1022013-04-22 14:19:21 -07002067 * handled by calling camera3_callback_ops_t.notify(). In case of
2068 * this error, the framework will retain responsibility for the
2069 * stream buffers' fences and the buffer handles; the HAL should
2070 * not close the fences or return these buffers with
2071 * process_capture_result.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002072 *
2073 * -ENODEV: If the camera device has encountered a serious error. After this
2074 * error is returned, only the close() method can be successfully
2075 * called by the framework.
2076 *
2077 */
2078 int (*process_capture_request)(const struct camera3_device *,
2079 camera3_capture_request_t *request);
2080
2081 /**********************************************************************
2082 * Miscellaneous methods
2083 */
2084
2085 /**
2086 * get_metadata_vendor_tag_ops:
2087 *
Eino-Ville Talvalaacbc4512013-03-16 16:53:28 -07002088 * Get methods to query for vendor extension metadata tag information. The
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002089 * HAL should fill in all the vendor tag operation methods, or leave ops
2090 * unchanged if no vendor tags are defined.
2091 *
2092 * The definition of vendor_tag_query_ops_t can be found in
2093 * system/media/camera/include/system/camera_metadata.h.
2094 *
Ruben Brunk61cf9eb2014-01-14 15:27:58 -08002095 * >= CAMERA_DEVICE_API_VERSION_3_2:
2096 * DEPRECATED. This function has been deprecated and should be set to
2097 * NULL by the HAL. Please implement get_vendor_tag_ops in camera_common.h
2098 * instead.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002099 */
2100 void (*get_metadata_vendor_tag_ops)(const struct camera3_device*,
2101 vendor_tag_query_ops_t* ops);
2102
2103 /**
2104 * dump:
2105 *
2106 * Print out debugging state for the camera device. This will be called by
2107 * the framework when the camera service is asked for a debug dump, which
2108 * happens when using the dumpsys tool, or when capturing a bugreport.
2109 *
2110 * The passed-in file descriptor can be used to write debugging text using
2111 * dprintf() or write(). The text should be in ASCII encoding only.
2112 */
2113 void (*dump)(const struct camera3_device *, int fd);
2114
Alex Ray5f2fd852013-06-24 11:28:05 -07002115 /**
2116 * flush:
2117 *
2118 * Flush all currently in-process captures and all buffers in the pipeline
2119 * on the given device. The framework will use this to dump all state as
2120 * quickly as possible in order to prepare for a configure_streams() call.
2121 *
2122 * No buffers are required to be successfully returned, so every buffer
2123 * held at the time of flush() (whether sucessfully filled or not) may be
2124 * returned with CAMERA3_BUFFER_STATUS_ERROR. Note the HAL is still allowed
2125 * to return valid (STATUS_OK) buffers during this call, provided they are
2126 * succesfully filled.
2127 *
2128 * All requests currently in the HAL are expected to be returned as soon as
2129 * possible. Not-in-process requests should return errors immediately. Any
2130 * interruptible hardware blocks should be stopped, and any uninterruptible
2131 * blocks should be waited on.
2132 *
2133 * flush() should only return when there are no more outstanding buffers or
2134 * requests left in the HAL. The framework may call configure_streams (as
2135 * the HAL state is now quiesced) or may issue new requests.
2136 *
2137 * A flush() call should only take 100ms or less. The maximum time it can
2138 * take is 1 second.
2139 *
2140 * Version information:
2141 *
2142 * only available if device version >= CAMERA_DEVICE_API_VERSION_3_1.
2143 *
2144 * Return values:
2145 *
2146 * 0: On a successful flush of the camera HAL.
2147 *
2148 * -EINVAL: If the input is malformed (the device is not valid).
2149 *
2150 * -ENODEV: If the camera device has encountered a serious error. After this
2151 * error is returned, only the close() method can be successfully
2152 * called by the framework.
2153 */
2154 int (*flush)(const struct camera3_device *);
2155
2156 /* reserved for future use */
2157 void *reserved[8];
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08002158} camera3_device_ops_t;
2159
2160/**********************************************************************
2161 *
2162 * Camera device definition
2163 *
2164 */
2165typedef struct camera3_device {
2166 /**
2167 * common.version must equal CAMERA_DEVICE_API_VERSION_3_0 to identify this
2168 * device as implementing version 3.0 of the camera device HAL.
2169 */
2170 hw_device_t common;
2171 camera3_device_ops_t *ops;
2172 void *priv;
2173} camera3_device_t;
2174
2175__END_DECLS
2176
2177#endif /* #ifdef ANDROID_INCLUDE_CAMERA3_H */