blob: d4cae271a0ac892245f301ea4531cf20a20ff4b0 [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/**
24 * Camera device HAL 3.0 [ CAMERA_DEVICE_API_VERSION_3_0 ]
25 *
26 * EXPERIMENTAL.
27 *
28 * Supports the android.hardware.Camera API.
29 *
30 * Camera devices that support this version of the HAL must return
31 * CAMERA_DEVICE_API_VERSION_3_0 in camera_device_t.common.version and in
32 * camera_info_t.device_version (from camera_module_t.get_camera_info).
33 *
34 * Camera modules that may contain version 3.0 devices must implement at least
35 * version 2.0 of the camera module interface (as defined by
36 * camera_module_t.common.module_api_version).
37 *
38 * See camera_common.h for more versioning details.
39 *
40 * Version history:
41 *
42 * 1.0: Initial Android camera HAL (Android 4.0) [camera.h]:
43 *
44 * - Converted from C++ CameraHardwareInterface abstraction layer.
45 *
46 * - Supports android.hardware.Camera API.
47 *
48 * 2.0: Initial release of expanded-capability HAL (Android 4.2) [camera2.h]:
49 *
50 * - Sufficient for implementing existing android.hardware.Camera API.
51 *
52 * - Allows for ZSL queue in camera service layer
53 *
54 * - Not tested for any new features such manual capture control, Bayer RAW
55 * capture, reprocessing of RAW data.
56 *
57 * 3.0: First revision of expanded-capability HAL:
58 *
59 * - Major version change since the ABI is completely different. No change to
60 * the required hardware capabilities or operational model from 2.0.
61 *
62 * - Reworked input request and stream queue interfaces: Framework calls into
63 * HAL with next request and stream buffers already dequeued. Sync framework
64 * support is included, necessary for efficient implementations.
65 *
66 * - Moved triggers into requests, most notifications into results.
67 *
68 * - Consolidated all callbacks into framework into one structure, and all
69 * setup methods into a single initialize() call.
70 *
71 * - Made stream configuration into a single call to simplify stream
72 * management. Bidirectional streams replace STREAM_FROM_STREAM construct.
73 *
74 * - Limited mode semantics for older/limited hardware devices.
75 */
76
77/**
78 * Startup and general expected operation sequence:
79 *
80 * 1. Framework calls camera_module_t->common.open(), which returns a
81 * hardware_device_t structure.
82 *
83 * 2. Framework inspects the hardware_device_t->version field, and instantiates
84 * the appropriate handler for that version of the camera hardware device. In
85 * case the version is CAMERA_DEVICE_API_VERSION_3_0, the device is cast to
86 * a camera3_device_t.
87 *
88 * 3. Framework calls camera3_device_t->ops->initialize() with the framework
89 * callback function pointers. This will only be called this one time after
90 * open(), before any other functions in the ops structure are called.
91 *
92 * 4. The framework calls camera3_device_t->ops->configure_streams() with a list
93 * of input/output streams to the HAL device.
94 *
95 * 5. The framework allocates gralloc buffers and calls
96 * camera3_device_t->ops->register_stream_buffers() for at least one of the
97 * output streams listed in configure_streams. The same stream is registered
98 * only once.
99 *
100 * 5. The framework requests default settings for some number of use cases with
101 * calls to camera3_device_t->ops->construct_default_request_settings(). This
102 * may occur any time after step 3.
103 *
104 * 7. The framework constructs and sends the first capture request to the HAL,
105 * with settings based on one of the sets of default settings, and with at
106 * least one output stream, which has been registered earlier by the
107 * framework. This is sent to the HAL with
108 * camera3_device_t->ops->process_capture_request(). The HAL must block the
109 * return of this call until it is ready for the next request to be sent.
110 *
111 * 8. The framework continues to submit requests, and possibly call
112 * register_stream_buffers() for not-yet-registered streams, and call
113 * construct_default_request_settings to get default settings buffers for
114 * other use cases.
115 *
116 * 9. When the capture of a request begins (sensor starts exposing for the
117 * capture), the HAL calls camera3_callback_ops_t->notify() with the SHUTTER
118 * event, including the frame number and the timestamp for start of exposure.
119 *
120 * 10. After some pipeline delay, the HAL begins to return completed captures to
121 * the framework with camera3_callback_ops_t->process_capture_result(). These
122 * are returned in the same order as the requests were submitted. Multiple
123 * requests can be in flight at once, depending on the pipeline depth of the
124 * camera HAL device.
125 *
126 * 11. After some time, the framework may stop submitting new requests, wait for
127 * the existing captures to complete (all buffers filled, all results
128 * returned), and then call configure_streams() again. This resets the camera
129 * hardware and pipeline for a new set of input/output streams. Some streams
130 * may be reused from the previous configuration; if these streams' buffers
131 * had already been registered with the HAL, they will not be registered
132 * again. The framework then continues from step 7, if at least one
133 * registered output stream remains (otherwise, step 5 is required first).
134 *
135 * 12. Alternatively, the framework may call camera3_device_t->common->close()
Eino-Ville Talvala2f8cf5c2013-03-06 13:23:31 -0800136 * to end the camera session. This may be called at any time when no other
137 * calls from the framework are active, although the call may block until all
138 * in-flight captures have completed (all results returned, all buffers
139 * filled). After the close call returns, no more calls to the
140 * camera3_callback_ops_t functions are allowed from the HAL. Once the
141 * close() call is underway, the framework may not call any other HAL device
142 * functions.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800143 *
144 * 13. In case of an error or other asynchronous event, the HAL must call
145 * camera3_callback_ops_t->notify() with the appropriate error/event
146 * message. After returning from a fatal device-wide error notification, the
147 * HAL should act as if close() had been called on it. However, the HAL must
148 * either cancel or complete all outstanding captures before calling
149 * notify(), so that once notify() is called with a fatal error, the
150 * framework will not receive further callbacks from the device. Methods
151 * besides close() should return -ENODEV or NULL after the notify() method
152 * returns from a fatal error message.
153 */
154
155/**
156 * Operational modes:
157 *
158 * The camera 3 HAL device can implement one of two possible operational modes;
159 * limited and full. Full support is expected from new higher-end
160 * devices. Limited mode has hardware requirements roughly in line with those
161 * for a camera HAL device v1 implementation, and is expected from older or
162 * inexpensive devices. Full is a strict superset of limited, and they share the
163 * same essential operational flow, as documented above.
164 *
165 * The HAL must indicate its level of support with the
166 * android.info.supportedHardwareLevel static metadata entry, with 0 indicating
167 * limited mode, and 1 indicating full mode support.
168 *
169 * Roughly speaking, limited-mode devices do not allow for application control
170 * of capture settings (3A control only), high-rate capture of high-resolution
171 * images, raw sensor readout, and support for YUV output streams maximum
172 * recording resolution (JPEG only for large images).
173 *
174 * ** Details of limited mode behavior:
175 *
176 * - Limited-mode devices do not need to implement accurate synchronization
177 * between capture request settings and the actual image data
178 * captured. Instead, changes to settings may take effect some time in the
179 * future, and possibly not for the same output frame for each settings
180 * entry. Rapid changes in settings may result in some settings never being
181 * used for a capture. However, captures that include high-resolution output
182 * buffers ( > 1080p ) have to use the settings as specified (but see below
183 * for processing rate).
184 *
185 * - Limited-mode devices do not need to support most of the
186 * settings/result/static info metadata. Full-mode devices must support all
187 * metadata fields listed in TODO. Specifically, only the following settings
188 * are expected to be consumed or produced by a limited-mode HAL device:
189 *
190 * android.control.aeAntibandingMode (controls)
191 * android.control.aeExposureCompensation (controls)
192 * android.control.aeLock (controls)
193 * android.control.aeMode (controls)
194 * [OFF means ON_FLASH_TORCH - TODO]
195 * android.control.aeRegions (controls)
196 * android.control.aeTargetFpsRange (controls)
197 * android.control.afMode (controls)
198 * [OFF means infinity focus]
199 * android.control.afRegions (controls)
200 * android.control.awbLock (controls)
201 * android.control.awbMode (controls)
202 * [OFF not supported]
203 * android.control.awbRegions (controls)
204 * android.control.captureIntent (controls)
205 * android.control.effectMode (controls)
206 * android.control.mode (controls)
207 * [OFF not supported]
208 * android.control.sceneMode (controls)
209 * android.control.videoStabilizationMode (controls)
210 * android.control.aeAvailableAntibandingModes (static)
211 * android.control.aeAvailableModes (static)
212 * android.control.aeAvailableTargetFpsRanges (static)
213 * android.control.aeCompensationRange (static)
214 * android.control.aeCompensationStep (static)
215 * android.control.afAvailableModes (static)
216 * android.control.availableEffects (static)
217 * android.control.availableSceneModes (static)
218 * android.control.availableVideoStabilizationModes (static)
219 * android.control.awbAvailableModes (static)
220 * android.control.maxRegions (static)
221 * android.control.sceneModeOverrides (static)
222 * android.control.aeRegions (dynamic)
223 * android.control.aeState (dynamic)
224 * android.control.afMode (dynamic)
225 * android.control.afRegions (dynamic)
226 * android.control.afState (dynamic)
227 * android.control.awbMode (dynamic)
228 * android.control.awbRegions (dynamic)
229 * android.control.awbState (dynamic)
230 * android.control.mode (dynamic)
231 *
232 * android.flash.info.available (static)
233 *
234 * android.info.supportedHardwareLevel (static)
235 *
236 * android.jpeg.gpsCoordinates (controls)
237 * android.jpeg.gpsProcessingMethod (controls)
238 * android.jpeg.gpsTimestamp (controls)
239 * android.jpeg.orientation (controls)
240 * android.jpeg.quality (controls)
241 * android.jpeg.thumbnailQuality (controls)
242 * android.jpeg.thumbnailSize (controls)
243 * android.jpeg.availableThumbnailSizes (static)
244 * android.jpeg.maxSize (static)
245 * android.jpeg.gpsCoordinates (dynamic)
246 * android.jpeg.gpsProcessingMethod (dynamic)
247 * android.jpeg.gpsTimestamp (dynamic)
248 * android.jpeg.orientation (dynamic)
249 * android.jpeg.quality (dynamic)
250 * android.jpeg.size (dynamic)
251 * android.jpeg.thumbnailQuality (dynamic)
252 * android.jpeg.thumbnailSize (dynamic)
253 *
254 * android.lens.info.minimumFocusDistance (static)
255 *
256 * android.request.id (controls)
257 * android.request.id (dynamic)
258 *
259 * android.scaler.cropRegion (controls)
260 * [ignores (x,y), assumes center-zoom]
261 * android.scaler.availableFormats (static)
262 * [RAW not supported]
263 * android.scaler.availableJpegMinDurations (static)
264 * android.scaler.availableJpegSizes (static)
265 * android.scaler.availableMaxDigitalZoom (static)
266 * android.scaler.availableProcessedMinDurations (static)
267 * android.scaler.availableProcessedSizes (static)
268 * [full resolution not supported]
269 * android.scaler.maxDigitalZoom (static)
270 * android.scaler.cropRegion (dynamic)
271 *
272 * android.sensor.orientation (static)
273 * android.sensor.timestamp (dynamic)
274 *
275 * android.statistics.faceDetectMode (controls)
276 * android.statistics.info.availableFaceDetectModes (static)
277 * android.statistics.faceDetectMode (dynamic)
278 * android.statistics.faceIds (dynamic)
279 * android.statistics.faceLandmarks (dynamic)
280 * android.statistics.faceRectangles (dynamic)
281 * android.statistics.faceScores (dynamic)
282 *
283 * - Captures in limited mode that include high-resolution (> 1080p) output
284 * buffers may block in process_capture_request() until all the output buffers
285 * have been filled. A full-mode HAL device must process sequences of
286 * high-resolution requests at the rate indicated in the static metadata for
287 * that pixel format. The HAL must still call process_capture_result() to
288 * provide the output; the framework must simply be prepared for
289 * process_capture_request() to block until after process_capture_result() for
290 * that request completes for high-resolution captures for limited-mode
291 * devices.
292 *
293 */
294
295/**
296 * Error management:
297 *
298 * Camera HAL device ops functions that have a return value will all return
299 * -ENODEV / NULL in case of a serious error. This means the device cannot
300 * continue operation, and must be closed by the framework. Once this error is
Alex Rayd5ddbc92013-02-15 13:47:24 -0800301 * returned by some method, or if notify() is called with ERROR_DEVICE, only
302 * the close() method can be called successfully. All other methods will return
303 * -ENODEV / NULL.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800304 *
305 * Transient errors in image capture must be reported through notify() as follows:
306 *
307 * - The failure of an entire capture to occur must be reported by the HAL by
308 * calling notify() with ERROR_REQUEST. Individual errors for the result
309 * metadata or the output buffers must not be reported in this case.
310 *
311 * - If the metadata for a capture cannot be produced, but some image buffers
312 * were filled, the HAL must call notify() with ERROR_RESULT.
313 *
314 * - If an output image buffer could not be filled, but either the metadata was
315 * produced or some other buffers were filled, the HAL must call notify() with
316 * ERROR_BUFFER for each failed buffer.
317 *
318 * In each of these transient failure cases, the HAL must still call
319 * process_capture_result, with valid output buffer_handle_t. If the result
320 * metadata could not be produced, it should be NULL. If some buffers could not
321 * be filled, their sync fences must be set to the error state.
322 *
323 * Invalid input aguments result in -EINVAL from the appropriate methods. In
324 * that case, the framework should act as if that call had never been made.
325 *
326 */
327
328__BEGIN_DECLS
329
330struct camera3_device;
331
332/**********************************************************************
333 *
334 * Camera3 stream and stream buffer definitions.
335 *
336 * These structs and enums define the handles and contents of the input and
337 * output streams connecting the HAL to various framework and application buffer
338 * consumers. Each stream is backed by a gralloc buffer queue.
339 *
340 */
341
342/**
343 * camera3_stream_type_t:
344 *
345 * The type of the camera stream, which defines whether the camera HAL device is
346 * the producer or the consumer for that stream, and how the buffers of the
347 * stream relate to the other streams.
348 */
349typedef enum camera3_stream_type {
350 /**
351 * This stream is an output stream; the camera HAL device will be
352 * responsible for filling buffers from this stream with newly captured or
353 * reprocessed image data.
354 */
355 CAMERA3_STREAM_OUTPUT = 0,
356
357 /**
358 * This stream is an input stream; the camera HAL device will be responsible
359 * for reading buffers from this stream and sending them through the camera
360 * processing pipeline, as if the buffer was a newly captured image from the
361 * imager.
362 */
363 CAMERA3_STREAM_INPUT = 1,
364
365 /**
366 * This stream can be used for input and output. Typically, the stream is
367 * used as an output stream, but occasionally one already-filled buffer may
368 * be sent back to the HAL device for reprocessing.
369 *
370 * This kind of stream is meant generally for zero-shutter-lag features,
371 * where copying the captured image from the output buffer to the
372 * reprocessing input buffer would be expensive. The stream will be used by
373 * the framework as follows:
374 *
375 * 1. The framework includes a buffer from this stream as output buffer in a
376 * request as normal.
377 *
378 * 2. Once the HAL device returns a filled output buffer to the framework,
379 * the framework may do one of two things with the filled buffer:
380 *
381 * 2. a. The framework uses the filled data, and returns the now-used buffer
382 * to the stream queue for reuse. This behavior exactly matches the
383 * OUTPUT type of stream.
384 *
385 * 2. b. The framework wants to reprocess the filled data, and uses the
386 * buffer as an input buffer for a request. Once the HAL device has
387 * used the reprocessing buffer, it then returns it to the
388 * framework. The framework then returns the now-used buffer to the
389 * stream queue for reuse.
390 *
391 * 3. The HAL device will be given the buffer again as an output buffer for
392 * a request at some future point.
393 *
394 * Note that the HAL will always be reprocessing data it produced.
395 *
396 */
397 CAMERA3_STREAM_BIDIRECTIONAL = 2,
398
399 /**
400 * Total number of framework-defined stream types
401 */
402 CAMERA3_NUM_STREAM_TYPES
403
404} camera3_stream_type_t;
405
406/**
407 * camera3_stream_t:
408 *
409 * A handle to a single camera input or output stream. A stream is defined by
410 * the framework by its buffer resolution and format, and additionally by the
411 * HAL with the gralloc usage flags and the maximum in-flight buffer count.
412 *
413 * The stream structures are owned by the framework, but pointers to a
414 * camera3_stream passed into the HAL by configure_streams() are valid until the
415 * end of the first subsequent configure_streams() call that _does not_ include
416 * that camera3_stream as an argument, or until the end of the close() call.
417 *
418 * All camera3_stream framework-controlled members are immutable once the
419 * camera3_stream is passed into configure_streams(). The HAL may only change
420 * the HAL-controlled parameters during a configure_streams() call, except for
421 * the contents of the private pointer.
422 *
423 * If a configure_streams() call returns a non-fatal error, all active streams
424 * remain valid as if configure_streams() had not been called.
425 *
426 * The endpoint of the stream is not visible to the camera HAL device.
427 */
428typedef struct camera3_stream {
429
430 /*****
431 * Set by framework before configure_streams()
432 */
433
434 /**
435 * The type of the stream, one of the camera3_stream_type_t values.
436 */
437 int stream_type;
438
439 /**
440 * The width in pixels of the buffers in this stream
441 */
442 uint32_t width;
443
444 /**
445 * The height in pixels of the buffers in this stream
446 */
447 uint32_t height;
448
449 /**
450 * The pixel format for the buffers in this stream. Format is a value from
451 * the HAL_PIXEL_FORMAT_* list in system/core/include/system/graphics.h, or
452 * from device-specific headers.
453 *
454 * If HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED is used, then the platform
455 * gralloc module will select a format based on the usage flags provided by
456 * the camera device and the other endpoint of the stream.
457 *
458 * The camera HAL device must inspect the buffers handed to it in the
459 * subsequent register_stream_buffers() call to obtain the
460 * implementation-specific format details, if necessary.
461 */
462 int format;
463
464 /*****
465 * Set by HAL during configure_streams().
466 */
467
468 /**
469 * The gralloc usage flags for this stream, as needed by the HAL. The usage
470 * flags are defined in gralloc.h (GRALLOC_USAGE_*), or in device-specific
471 * headers.
472 *
473 * For output streams, these are the HAL's producer usage flags. For input
474 * streams, these are the HAL's consumer usage flags. The usage flags from
475 * the producer and the consumer will be combined together and then passed
476 * to the platform gralloc HAL module for allocating the gralloc buffers for
477 * each stream.
478 */
479 uint32_t usage;
480
481 /**
482 * The maximum number of buffers the HAL device may need to have dequeued at
483 * the same time. The HAL device may not have more buffers in-flight from
484 * this stream than this value.
485 */
486 uint32_t max_buffers;
487
488 /**
489 * A handle to HAL-private information for the stream. Will not be inspected
490 * by the framework code.
491 */
492 void *priv;
493
494} camera3_stream_t;
495
496/**
497 * camera3_stream_configuration_t:
498 *
499 * A structure of stream definitions, used by configure_streams(). This
500 * structure defines all the output streams and the reprocessing input
501 * stream for the current camera use case.
502 */
503typedef struct camera3_stream_configuration {
504 /**
505 * The total number of streams requested by the framework. This includes
506 * both input and output streams. The number of streams will be at least 1,
507 * and there will be at least one output-capable stream.
508 */
509 uint32_t num_streams;
510
511 /**
Eino-Ville Talvala3a6e6b42013-03-06 13:21:11 -0800512 * An array of camera stream pointers, defining the input/output
513 * configuration for the camera HAL device.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800514 *
515 * At most one input-capable stream may be defined (INPUT or BIDIRECTIONAL)
516 * in a single configuration.
517 *
518 * At least one output-capable stream must be defined (OUTPUT or
519 * BIDIRECTIONAL).
520 */
Eino-Ville Talvala3a6e6b42013-03-06 13:21:11 -0800521 camera3_stream_t **streams;
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800522
523} camera3_stream_configuration_t;
524
525/**
Eino-Ville Talvala2f8cf5c2013-03-06 13:23:31 -0800526 * camera3_buffer_status_t:
527 *
528 * The current status of a single stream buffer.
529 */
530typedef enum camera3_buffer_status {
531 /**
532 * The buffer is in a normal state, and can be used after waiting on its
533 * sync fence.
534 */
535 CAMERA3_BUFFER_STATUS_OK = 0,
536
537 /**
538 * The buffer does not contain valid data, and the data in it should not be
539 * used. The sync fence must still be waited on before reusing the buffer.
540 */
541 CAMERA3_BUFFER_STATUS_ERROR = 1
542
543} camera3_buffer_status_t;
544
545/**
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800546 * camera3_stream_buffer_t:
547 *
548 * A single buffer from a camera3 stream. It includes a handle to its parent
549 * stream, the handle to the gralloc buffer itself, and sync fences
550 *
551 * The buffer does not specify whether it is to be used for input or output;
552 * that is determined by its parent stream type and how the buffer is passed to
553 * the HAL device.
554 */
555typedef struct camera3_stream_buffer {
556 /**
557 * The handle of the stream this buffer is associated with
558 */
559 camera3_stream_t *stream;
560
561 /**
562 * The native handle to the buffer
563 */
564 buffer_handle_t *buffer;
565
566 /**
Eino-Ville Talvala2f8cf5c2013-03-06 13:23:31 -0800567 * Current state of the buffer, one of the camera3_buffer_status_t
568 * values. The framework will not pass buffers to the HAL that are in an
569 * error state. In case a buffer could not be filled by the HAL, it must
570 * have its status set to CAMERA3_BUFFER_STATUS_ERROR when returned to the
571 * framework with process_capture_result().
572 */
573 int status;
574
575 /**
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800576 * The acquire sync fence for this buffer. The HAL must wait on this fence
577 * fd before attempting to read from or write to this buffer.
578 *
579 * The framework may be set to -1 to indicate that no waiting is necessary
Eino-Ville Talvala2f8cf5c2013-03-06 13:23:31 -0800580 * for this buffer.
581 *
582 * When the HAL returns an output buffer to the framework with
583 * process_capture_result(), the acquire_fence must be set to -1. If the HAL
584 * never waits on the acquire_fence due to an error in filling a buffer,
585 * when calling process_capture_result() the HAL must set the release_fence
586 * of the buffer to be the acquire_fence passed to it by the framework. This
587 * will allow the framework to wait on the fence before reusing the buffer.
588 *
589 * For input buffers, the HAL must not change the acquire_fence field during
590 * the process_capture_request() call.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800591 */
592 int acquire_fence;
593
594 /**
595 * The release sync fence for this buffer. The HAL must set this fence when
596 * returning buffers to the framework, or write -1 to indicate that no
597 * waiting is required for this buffer.
598 *
599 * For the input buffer, the release fence must be set by the
600 * process_capture_request() call. For the output buffers, the fences must
601 * be set in the output_buffers array passed to process_capture_result().
Eino-Ville Talvala2f8cf5c2013-03-06 13:23:31 -0800602 *
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800603 */
604 int release_fence;
605
606} camera3_stream_buffer_t;
607
608/**
609 * camera3_stream_buffer_set_t:
610 *
611 * The complete set of gralloc buffers for a stream. This structure is given to
612 * register_stream_buffers() to allow the camera HAL device to register/map/etc
613 * newly allocated stream buffers.
614 */
615typedef struct camera3_stream_buffer_set {
616 /**
617 * The stream handle for the stream these buffers belong to
618 */
619 camera3_stream_t *stream;
620
621 /**
622 * The number of buffers in this stream. It is guaranteed to be at least
623 * stream->max_buffers.
624 */
625 uint32_t num_buffers;
626
627 /**
628 * The array of gralloc buffer handles for this stream. If the stream format
629 * is set to HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, the camera HAL device
630 * should inspect the passed-in buffers to determine any platform-private
631 * pixel format information.
632 */
Eino-Ville Talvala3a6e6b42013-03-06 13:21:11 -0800633 buffer_handle_t **buffers;
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800634
635} camera3_stream_buffer_set_t;
636
637/**
638 * camera3_jpeg_blob:
639 *
640 * Transport header for compressed JPEG buffers in output streams.
641 *
642 * To capture JPEG images, a stream is created using the pixel format
643 * HAL_PIXEL_FORMAT_BLOB, and the static metadata field android.jpeg.maxSize is
644 * used as the buffer size. Since compressed JPEG images are of variable size,
645 * the HAL needs to include the final size of the compressed image using this
646 * structure inside the output stream buffer. The JPEG blob ID field must be set
647 * to CAMERA3_JPEG_BLOB_ID.
648 *
649 * Transport header should be at the end of the JPEG output stream buffer. That
650 * means the jpeg_blob_id must start at byte[android.jpeg.maxSize -
651 * sizeof(camera3_jpeg_blob)]. Any HAL using this transport header must
652 * account for it in android.jpeg.maxSize. The JPEG data itself starts at
653 * the beginning of the buffer and should be jpeg_size bytes long.
654 */
655typedef struct camera3_jpeg_blob {
656 uint16_t jpeg_blob_id;
657 uint32_t jpeg_size;
658} camera3_jpeg_blob_t;
659
660enum {
661 CAMERA3_JPEG_BLOB_ID = 0x00FF
662};
663
664/**********************************************************************
665 *
666 * Message definitions for the HAL notify() callback.
667 *
668 * These definitions are used for the HAL notify callback, to signal
669 * asynchronous events from the HAL device to the Android framework.
670 *
671 */
672
673/**
674 * camera3_msg_type:
675 *
676 * Indicates the type of message sent, which specifies which member of the
677 * message union is valid.
678 *
679 */
680typedef enum camera3_msg_type {
681 /**
682 * An error has occurred. camera3_notify_msg.message.error contains the
683 * error information.
684 */
685 CAMERA3_MSG_ERROR = 1,
686
687 /**
688 * The exposure of a given request has
689 * begun. camera3_notify_msg.message.shutter contains the information
690 * the capture.
691 */
692 CAMERA3_MSG_SHUTTER = 2,
693
694 /**
695 * Number of framework message types
696 */
697 CAMERA3_NUM_MESSAGES
698
699} camera3_msg_type_t;
700
701/**
702 * Defined error codes for CAMERA_MSG_ERROR
703 */
704typedef enum camera3_error_msg_code {
705 /**
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800706 * A serious failure occured. No further frames or buffer streams will
707 * be produced by the device. Device should be treated as closed. The
708 * client must reopen the device to use it again. The frame_number field
709 * is unused.
710 */
Alex Rayd5ddbc92013-02-15 13:47:24 -0800711 CAMERA3_MSG_ERROR_DEVICE = 1,
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800712
713 /**
714 * An error has occurred in processing a request. No output (metadata or
715 * buffers) will be produced for this request. The frame_number field
716 * specifies which request has been dropped. Subsequent requests are
717 * unaffected, and the device remains operational.
718 */
Alex Rayd5ddbc92013-02-15 13:47:24 -0800719 CAMERA3_MSG_ERROR_REQUEST = 2,
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800720
721 /**
722 * An error has occurred in producing an output result metadata buffer
723 * for a request, but output stream buffers for it will still be
724 * available. Subsequent requests are unaffected, and the device remains
725 * operational. The frame_number field specifies the request for which
726 * result metadata won't be available.
727 */
Alex Rayd5ddbc92013-02-15 13:47:24 -0800728 CAMERA3_MSG_ERROR_RESULT = 3,
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800729
730 /**
731 * An error has occurred in placing an output buffer into a stream for a
732 * request. The frame metadata and other buffers may still be
733 * available. Subsequent requests are unaffected, and the device remains
734 * operational. The frame_number field specifies the request for which the
735 * buffer was dropped, and error_stream contains a pointer to the stream
736 * that dropped the frame.u
737 */
Alex Rayd5ddbc92013-02-15 13:47:24 -0800738 CAMERA3_MSG_ERROR_BUFFER = 4,
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -0800739
740 /**
741 * Number of error types
742 */
743 CAMERA3_MSG_NUM_ERRORS
744
745} camera3_error_msg_code_t;
746
747/**
748 * camera3_error_msg_t:
749 *
750 * Message contents for CAMERA3_MSG_ERROR
751 */
752typedef struct camera3_error_msg {
753 /**
754 * Frame number of the request the error applies to. 0 if the frame number
755 * isn't applicable to the error.
756 */
757 uint32_t frame_number;
758
759 /**
760 * Pointer to the stream that had a failure. NULL if the stream isn't
761 * applicable to the error.
762 */
763 camera3_stream_t *error_stream;
764
765 /**
766 * The code for this error; one of the CAMERA_MSG_ERROR enum values.
767 */
768 int error_code;
769
770} camera3_error_msg_t;
771
772/**
773 * camera3_shutter_msg_t:
774 *
775 * Message contents for CAMERA3_MSG_SHUTTER
776 */
777typedef struct camera3_shutter_msg {
778 /**
779 * Frame number of the request that has begun exposure
780 */
781 uint32_t frame_number;
782
783 /**
784 * Timestamp for the start of capture. This must match the capture result
785 * metadata's sensor exposure start timestamp.
786 */
787 uint64_t timestamp;
788
789} camera3_shutter_msg_t;
790
791/**
792 * camera3_notify_msg_t:
793 *
794 * The message structure sent to camera3_callback_ops_t.notify()
795 */
796typedef struct camera3_notify_msg {
797
798 /**
799 * The message type. One of camera3_notify_msg_type, or a private extension.
800 */
801 int type;
802
803 union {
804 /**
805 * Error message contents. Valid if type is CAMERA3_MSG_ERROR
806 */
807 camera3_error_msg_t error;
808
809 /**
810 * Shutter message contents. Valid if type is CAMERA3_MSG_SHUTTER
811 */
812 camera3_shutter_msg_t shutter;
813
814 /**
815 * Generic message contents. Used to ensure a minimum size for custom
816 * message types.
817 */
818 uint8_t generic[32];
819 } message;
820
821} camera3_notify_msg_t;
822
823/**********************************************************************
824 *
825 * Capture request/result definitions for the HAL process_capture_request()
826 * method, and the process_capture_result() callback.
827 *
828 */
829
830/**
831 * camera3_request_template_t:
832 *
833 * Available template types for
834 * camera3_device_ops.construct_default_request_settings()
835 */
836typedef enum camera3_request_template {
837 /**
838 * Standard camera preview operation with 3A on auto.
839 */
840 CAMERA3_TEMPLATE_PREVIEW = 1,
841
842 /**
843 * Standard camera high-quality still capture with 3A and flash on auto.
844 */
845 CAMERA3_TEMPLATE_STILL_CAPTURE = 2,
846
847 /**
848 * Standard video recording plus preview with 3A on auto, torch off.
849 */
850 CAMERA3_TEMPLATE_VIDEO_RECORD = 3,
851
852 /**
853 * High-quality still capture while recording video. Application will
854 * include preview, video record, and full-resolution YUV or JPEG streams in
855 * request. Must not cause stuttering on video stream. 3A on auto.
856 */
857 CAMERA3_TEMPLATE_VIDEO_SNAPSHOT = 4,
858
859 /**
860 * Zero-shutter-lag mode. Application will request preview and
861 * full-resolution data for each frame, and reprocess it to JPEG when a
862 * still image is requested by user. Settings should provide highest-quality
863 * full-resolution images without compromising preview frame rate. 3A on
864 * auto.
865 */
866 CAMERA3_TEMPLATE_ZERO_SHUTTER_LAG = 5,
867
868 /* Total number of templates */
869 CAMERA3_TEMPLATE_COUNT,
870
871 /**
872 * First value for vendor-defined request templates
873 */
874 CAMERA3_VENDOR_TEMPLATE_START = 0x40000000
875
876} camera3_request_template_t;
877
878/**
879 * camera3_capture_request_t:
880 *
881 * A single request for image capture/buffer reprocessing, sent to the Camera
882 * HAL device by the framework in process_capture_request().
883 *
884 * The request contains the settings to be used for this capture, and the set of
885 * output buffers to write the resulting image data in. It may optionally
886 * contain an input buffer, in which case the request is for reprocessing that
887 * input buffer instead of capturing a new image with the camera sensor. The
888 * capture is identified by the frame_number.
889 *
890 * In response, the camera HAL device must send a camera3_capture_result
891 * structure asynchronously to the framework, using the process_capture_result()
892 * callback.
893 */
894typedef struct camera3_capture_request {
895 /**
896 * The frame number is an incrementing integer set by the framework to
897 * uniquely identify this capture. It needs to be returned in the result
898 * call, and is also used to identify the request in asynchronous
899 * notifications sent to camera3_callback_ops_t.notify().
900 */
901 uint32_t frame_number;
902
903 /**
904 * The settings buffer contains the capture and processing parameters for
905 * the request. As a special case, a NULL settings buffer indicates that the
906 * settings are identical to the most-recently submitted capture request. A
907 * NULL buffer cannot be used as the first submitted request after a
908 * configure_streams() call.
909 */
910 const camera_metadata_t *settings;
911
912 /**
913 * The input stream buffer to use for this request, if any.
914 *
915 * If input_buffer is NULL, then the request is for a new capture from the
916 * imager. If input_buffer is valid, the request is for reprocessing the
917 * image contained in input_buffer.
918 *
919 * In the latter case, the HAL must set the release_fence of the
920 * input_buffer to a valid sync fence, or to -1 if the HAL does not support
921 * sync, before process_capture_request() returns.
922 *
923 * The HAL is required to wait on the acquire sync fence of the input buffer
924 * before accessing it.
925 *
926 * Any input buffer included here will have been registered with the HAL
927 * through register_stream_buffers() before its inclusion in a request.
928 */
929 camera3_stream_buffer_t *input_buffer;
930
931 /**
932 * The number of output buffers for this capture request. Must be at least
933 * 1.
934 */
935 uint32_t num_output_buffers;
936
937 /**
938 * An array of num_output_buffers stream buffers, to be filled with image
939 * data from this capture/reprocess. The HAL must wait on the acquire fences
940 * of each stream buffer before writing to them. All the buffers included
941 * here will have been registered with the HAL through
942 * register_stream_buffers() before their inclusion in a request.
943 *
944 * The HAL takes ownership of the actual buffer_handle_t entries in
945 * output_buffers; the framework does not access them until they are
946 * returned in a camera3_capture_result_t.
947 */
948 const camera3_stream_buffer_t *output_buffers;
949
950} camera3_capture_request_t;
951
952/**
953 * camera3_capture_result_t:
954 *
955 * The result of a single capture/reprocess by the camera HAL device. This is
956 * sent to the framework asynchronously with process_capture_result(), in
957 * response to a single capture request sent to the HAL with
958 * process_capture_request().
959 *
960 * The result structure contains the output metadata from this capture, and the
961 * set of output buffers that have been/will be filled for this capture. Each
962 * output buffer may come with a release sync fence that the framework will wait
963 * on before reading, in case the buffer has not yet been filled by the HAL.
964 *
965 */
966typedef struct camera3_capture_result {
967 /**
968 * The frame number is an incrementing integer set by the framework in the
969 * submitted request to uniquely identify this capture. It is also used to
970 * identify the request in asynchronous notifications sent to
971 * camera3_callback_ops_t.notify().
972 */
973 uint32_t frame_number;
974
975 /**
976 * The result metadata for this capture. This contains information about the
977 * final capture parameters, the state of the capture and post-processing
978 * hardware, the state of the 3A algorithms, if enabled, and the output of
979 * any enabled statistics units.
980 */
981 const camera_metadata_t *result;
982
983 /**
984 * The number of output buffers used for this capture. Must equal the
985 * matching capture request's count.
986 */
987 uint32_t num_output_buffers;
988
989 /**
990 * The handles for the output stream buffers for this capture. They may not
991 * yet be filled at the time the HAL calls process_capture_result(); the
992 * framework will wait on the release sync fences provided by the HAL before
993 * reading the buffers.
994 *
995 * The HAL must set the stream buffer's release sync fence to a valid sync
996 * fd, or to -1 if the buffer has already been filled.
Eino-Ville Talvala2f8cf5c2013-03-06 13:23:31 -0800997 *
998 * If the HAL encounters an error while processing the buffer, and the
999 * buffer is not filled, the buffer's status field must be set to
1000 * CAMERA3_BUFFER_STATUS_ERROR. If the HAL did not wait on the acquire fence
1001 * before encountering the error, the acquire fence should be copied into
1002 * the release fence, to allow the framework to wait on the fence before
1003 * reusing the buffer.
1004 *
1005 * The acquire fence must be set to -1 for all output buffers.
1006 *
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001007 */
1008 const camera3_stream_buffer_t *output_buffers;
1009
1010} camera3_capture_result_t;
1011
1012/**********************************************************************
1013 *
1014 * Callback methods for the HAL to call into the framework.
1015 *
1016 * These methods are used to return metadata and image buffers for a completed
1017 * or failed captures, and to notify the framework of asynchronous events such
1018 * as errors.
1019 *
1020 * The framework will not call back into the HAL from within these callbacks,
1021 * and these calls will not block for extended periods.
1022 *
1023 */
1024typedef struct camera3_callback_ops {
1025
1026 /**
1027 * process_capture_result:
1028 *
1029 * Send a completed capture result metadata buffer to the framework, along
1030 * with the possibly completed output stream buffers.
1031 *
1032 * Captures must be processed in-order, so that the Nth request submitted
1033 * will match with the Nth result returned. Only one call to
1034 * process_capture_request() should be made at a time to ensure correct
1035 * ordering.
1036 *
1037 * The HAL retains ownership of result structure, which only needs to be
1038 * valid to access during this call. The framework will copy whatever it
1039 * needs before this call returns.
1040 *
1041 * The output buffers do not need to be filled yet; the framework will wait
1042 * on the stream buffer release sync fence before reading the buffer
1043 * data. Therefore, this method must be called by the HAL as soon as the
1044 * result metadata is available, even if some or all of the output buffers
1045 * are still in processing. The HAL must include valid release sync fences
1046 * into each output_buffers stream buffer entry, or -1 if it does not
1047 * support streams or if that stream buffer is already filled.
1048 *
1049 * If the result buffer cannot be constructed for a request, the HAL should
1050 * return a NULL buffer here, but still provide the output buffers and their
1051 * sync fences. In addition, notify() must be called with an ERROR_RESULT
1052 * message.
1053 *
Eino-Ville Talvala2f8cf5c2013-03-06 13:23:31 -08001054 * If an output buffer cannot be filled, its status field must be set to
1055 * STATUS_ERROR. In addition, notify() must be called with a ERROR_BUFFER
1056 * message.
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001057 *
1058 * If the entire capture has failed, then this method still needs to be
Eino-Ville Talvala2f8cf5c2013-03-06 13:23:31 -08001059 * called to return the output buffers to the framework. All the buffer
1060 * statuses should be STATUS_ERROR, and the result metadata should be
1061 * NULL. In addition, notify() must be called with a ERROR_REQUEST
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001062 * message. In this case, individual ERROR_RESULT/ERROR_BUFFER messages
1063 * should not be sent.
1064 *
1065 */
1066 void (*process_capture_result)(const struct camera3_callback_ops *,
1067 const camera3_capture_result_t *result);
1068
1069 /**
1070 * notify:
1071 *
1072 * Asynchronous notification callback from the HAL, fired for various
1073 * reasons. Only for information independent of frame capture, or that
1074 * require specific timing. The ownership of the message structure remains
1075 * with the HAL, and the msg only needs to be valid for the duration of this
1076 * call.
1077 *
1078 * Multiple threads may call notify() simultaneously.
1079 */
1080 void (*notify)(const struct camera3_callback_ops *,
1081 const camera3_notify_msg_t *msg);
1082
1083} camera3_callback_ops_t;
1084
1085/**********************************************************************
1086 *
1087 * Camera device operations
1088 *
1089 */
1090typedef struct camera3_device_ops {
1091
1092 /**
1093 * initialize:
1094 *
1095 * One-time initialization to pass framework callback function pointers to
1096 * the HAL. Will be called once after a successful open() call, before any
1097 * other functions are called on the camera3_device_ops structure.
1098 *
1099 * Return values:
1100 *
1101 * 0: On successful initialization
1102 *
1103 * -ENODEV: If initialization fails. Only close() can be called successfully
1104 * by the framework after this.
1105 */
1106 int (*initialize)(const struct camera3_device *,
1107 const camera3_callback_ops_t *callback_ops);
1108
1109 /**********************************************************************
1110 * Stream management
1111 */
1112
1113 /**
1114 * configure_streams:
1115 *
1116 * Reset the HAL camera device processing pipeline and set up new input and
1117 * output streams. This call replaces any existing stream configuration with
1118 * the streams defined in the stream_list. This method will be called at
1119 * least once after initialize() before a request is submitted with
1120 * process_capture_request().
1121 *
1122 * The stream_list must contain at least one output-capable stream, and may
1123 * not contain more than one input-capable stream.
1124 *
1125 * The stream_list may contain streams that are also in the currently-active
1126 * set of streams (from the previous call to configure_stream()). These
1127 * streams will already have valid values for usage, max_buffers, and the
1128 * private pointer. If such a stream has already had its buffers registered,
1129 * register_stream_buffers() will not be called again for the stream, and
1130 * buffers from the stream can be immediately included in input requests.
1131 *
1132 * If the HAL needs to change the stream configuration for an existing
1133 * stream due to the new configuration, it may rewrite the values of usage
1134 * and/or max_buffers during the configure call. The framework will detect
1135 * such a change, and will then reallocate the stream buffers, and call
1136 * register_stream_buffers() again before using buffers from that stream in
1137 * a request.
1138 *
1139 * If a currently-active stream is not included in stream_list, the HAL may
1140 * safely remove any references to that stream. It will not be reused in a
1141 * later configure() call by the framework, and all the gralloc buffers for
1142 * it will be freed after the configure_streams() call returns.
1143 *
1144 * The stream_list structure is owned by the framework, and may not be
1145 * accessed once this call completes. The address of an individual
1146 * camera3_stream_t structure will remain valid for access by the HAL until
1147 * the end of the first configure_stream() call which no longer includes
1148 * that camera3_stream_t in the stream_list argument. The HAL may not change
1149 * values in the stream structure outside of the private pointer, except for
1150 * the usage and max_buffers members during the configure_streams() call
1151 * itself.
1152 *
1153 * If the stream is new, the usage, max_buffer, and private pointer fields
1154 * of the stream structure will all be set to 0. The HAL device must set
1155 * these fields before the configure_streams() call returns. These fields
1156 * are then used by the framework and the platform gralloc module to
1157 * allocate the gralloc buffers for each stream.
1158 *
1159 * Before such a new stream can have its buffers included in a capture
1160 * request, the framework will call register_stream_buffers() with that
1161 * stream. However, the framework is not required to register buffers for
1162 * _all_ streams before submitting a request. This allows for quick startup
1163 * of (for example) a preview stream, with allocation for other streams
1164 * happening later or concurrently.
1165 *
1166 * Preconditions:
1167 *
1168 * The framework will only call this method when no captures are being
1169 * processed. That is, all results have been returned to the framework, and
1170 * all in-flight input and output buffers have been returned and their
1171 * release sync fences have been signaled by the HAL. The framework will not
1172 * submit new requests for capture while the configure_streams() call is
1173 * underway.
1174 *
1175 * Postconditions:
1176 *
1177 * The HAL device must configure itself to provide maximum possible output
1178 * frame rate given the sizes and formats of the output streams, as
1179 * documented in the camera device's static metadata.
1180 *
1181 * Performance expectations:
1182 *
1183 * This call is expected to be heavyweight and possibly take several hundred
1184 * milliseconds to complete, since it may require resetting and
1185 * reconfiguring the image sensor and the camera processing pipeline.
1186 * Nevertheless, the HAL device should attempt to minimize the
1187 * reconfiguration delay to minimize the user-visible pauses during
1188 * application operational mode changes (such as switching from still
1189 * capture to video recording).
1190 *
1191 * Return values:
1192 *
1193 * 0: On successful stream configuration
1194 *
1195 * -EINVAL: If the requested stream configuration is invalid. Some examples
1196 * of invalid stream configurations include:
1197 *
1198 * - Including more than 1 input-capable stream (INPUT or
1199 * BIDIRECTIONAL)
1200 *
1201 * - Not including any output-capable streams (OUTPUT or
1202 * BIDIRECTIONAL)
1203 *
1204 * - Including streams with unsupported formats, or an unsupported
1205 * size for that format.
1206 *
1207 * - Including too many output streams of a certain format.
1208 *
Eino-Ville Talvala7effe0c2013-02-15 12:09:48 -08001209 * Note that the framework submitting an invalid stream
1210 * configuration is not normal operation, since stream
1211 * configurations are checked before configure. An invalid
1212 * configuration means that a bug exists in the framework code, or
1213 * there is a mismatch between the HAL's static metadata and the
1214 * requirements on streams.
1215 *
Eino-Ville Talvalad2a87752012-11-27 18:06:06 -08001216 * -ENODEV: If there has been a fatal error and the device is no longer
1217 * operational. Only close() can be called successfully by the
1218 * framework after this error is returned.
1219 */
1220 int (*configure_streams)(const struct camera3_device *,
1221 camera3_stream_configuration_t *stream_list);
1222
1223 /**
1224 * register_stream_buffers:
1225 *
1226 * Register buffers for a given stream with the HAL device. This method is
1227 * called by the framework after a new stream is defined by
1228 * configure_streams, and before buffers from that stream are included in a
1229 * capture request. If the same stream is listed in a subsequent
1230 * configure_streams() call, register_stream_buffers will _not_ be called
1231 * again for that stream.
1232 *
1233 * The framework does not need to register buffers for all configured
1234 * streams before it submits the first capture request. This allows quick
1235 * startup for preview (or similar use cases) while other streams are still
1236 * being allocated.
1237 *
1238 * This method is intended to allow the HAL device to map or otherwise
1239 * prepare the buffers for later use. The buffers passed in will already be
1240 * locked for use. At the end of the call, all the buffers must be ready to
1241 * be returned to the stream. The buffer_set argument is only valid for the
1242 * duration of this call.
1243 *
1244 * If the stream format was set to HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED,
1245 * the camera HAL should inspect the passed-in buffers here to determine any
1246 * platform-private pixel format information.
1247 *
1248 * Return values:
1249 *
1250 * 0: On successful registration of the new stream buffers
1251 *
1252 * -EINVAL: If the stream_buffer_set does not refer to a valid active
1253 * stream, or if the buffers array is invalid.
1254 *
1255 * -ENOMEM: If there was a failure in registering the buffers. The framework
1256 * must consider all the stream buffers to be unregistered, and can
1257 * try to register again later.
1258 *
1259 * -ENODEV: If there is a fatal error, and the device is no longer
1260 * operational. Only close() can be called successfully by the
1261 * framework after this error is returned.
1262 */
1263 int (*register_stream_buffers)(const struct camera3_device *,
1264 const camera3_stream_buffer_set_t *buffer_set);
1265
1266 /**********************************************************************
1267 * Request creation and submission
1268 */
1269
1270 /**
1271 * construct_default_request_settings:
1272 *
1273 * Create capture settings for standard camera use cases.
1274 *
1275 * The device must return a settings buffer that is configured to meet the
1276 * requested use case, which must be one of the CAMERA3_TEMPLATE_*
1277 * enums. All request control fields must be included.
1278 *
1279 * The HAL retains ownership of this structure, but the pointer to the
1280 * structure must be valid until the device is closed. The framework and the
1281 * HAL may not modify the buffer once it is returned by this call. The same
1282 * buffer may be returned for subsequent calls for the same template, or for
1283 * other templates.
1284 *
1285 * Return values:
1286 *
1287 * Valid metadata: On successful creation of a default settings
1288 * buffer.
1289 *
1290 * NULL: In case of a fatal error. After this is returned, only
1291 * the close() method can be called succesfully by the
1292 * framework.
1293 */
1294 const camera_metadata_t* (*construct_default_request_settings)(
1295 const struct camera3_device *,
1296 int type);
1297
1298 /**
1299 * process_capture_request:
1300 *
1301 * Send a new capture request to the HAL. The HAL should not return from
1302 * this call until it is ready to accept the next request to process. Only
1303 * one call to process_capture_request() will be made at a time by the
1304 * framework, and the calls will all be from the same thread. The next call
1305 * to process_capture_request() will be made as soon as a new request and
1306 * its associated buffers are available. In a normal preview scenario, this
1307 * means the function will be called again by the framework almost
1308 * instantly.
1309 *
1310 * The actual request processing is asynchronous, with the results of
1311 * capture being returned by the HAL through the process_capture_result()
1312 * call. This call requires the result metadata to be available, but output
1313 * buffers may simply provide sync fences to wait on. Multiple requests are
1314 * expected to be in flight at once, to maintain full output frame rate.
1315 *
1316 * The framework retains ownership of the request structure. It is only
1317 * guaranteed to be valid during this call. The HAL device must make copies
1318 * of the information it needs to retain for the capture processing.
1319 *
1320 * The HAL must write the file descriptor for the input buffer's release
1321 * sync fence into input_buffer->release_fence, if input_buffer is not
1322 * NULL. If the HAL returns -1 for the input buffer release sync fence, the
1323 * framework is free to immediately reuse the input buffer. Otherwise, the
1324 * framework will wait on the sync fence before refilling and reusing the
1325 * input buffer.
1326 *
1327 * Return values:
1328 *
1329 * 0: On a successful start to processing the capture request
1330 *
1331 * -EINVAL: If the input is malformed (the settings are NULL when not
1332 * allowed, there are 0 output buffers, etc) and capture processing
1333 * cannot start. Failures during request processing should be
1334 * handled by calling camera3_callback_ops_t.notify().
1335 *
1336 * -ENODEV: If the camera device has encountered a serious error. After this
1337 * error is returned, only the close() method can be successfully
1338 * called by the framework.
1339 *
1340 */
1341 int (*process_capture_request)(const struct camera3_device *,
1342 camera3_capture_request_t *request);
1343
1344 /**********************************************************************
1345 * Miscellaneous methods
1346 */
1347
1348 /**
1349 * get_metadata_vendor_tag_ops:
1350 *
1351 * Get methods to query for vendor extension metadata tag infomation. The
1352 * HAL should fill in all the vendor tag operation methods, or leave ops
1353 * unchanged if no vendor tags are defined.
1354 *
1355 * The definition of vendor_tag_query_ops_t can be found in
1356 * system/media/camera/include/system/camera_metadata.h.
1357 *
1358 */
1359 void (*get_metadata_vendor_tag_ops)(const struct camera3_device*,
1360 vendor_tag_query_ops_t* ops);
1361
1362 /**
1363 * dump:
1364 *
1365 * Print out debugging state for the camera device. This will be called by
1366 * the framework when the camera service is asked for a debug dump, which
1367 * happens when using the dumpsys tool, or when capturing a bugreport.
1368 *
1369 * The passed-in file descriptor can be used to write debugging text using
1370 * dprintf() or write(). The text should be in ASCII encoding only.
1371 */
1372 void (*dump)(const struct camera3_device *, int fd);
1373
1374} camera3_device_ops_t;
1375
1376/**********************************************************************
1377 *
1378 * Camera device definition
1379 *
1380 */
1381typedef struct camera3_device {
1382 /**
1383 * common.version must equal CAMERA_DEVICE_API_VERSION_3_0 to identify this
1384 * device as implementing version 3.0 of the camera device HAL.
1385 */
1386 hw_device_t common;
1387 camera3_device_ops_t *ops;
1388 void *priv;
1389} camera3_device_t;
1390
1391__END_DECLS
1392
1393#endif /* #ifdef ANDROID_INCLUDE_CAMERA3_H */