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