2 * Copyright (C) 2012 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef ANDROID_INCLUDE_CAMERA2_H
18 #define ANDROID_INCLUDE_CAMERA2_H
20 #include "camera_common.h"
21 #include "system/camera_metadata.h"
24 * Camera device HAL 2.0 [ CAMERA_DEVICE_API_VERSION_2_0 ]
28 * Supports both the android.hardware.ProCamera and
29 * android.hardware.Camera APIs.
31 * Camera devices that support this version of the HAL must return
32 * CAMERA_DEVICE_API_VERSION_2_0 in camera_device_t.common.version and in
33 * camera_info_t.device_version (from camera_module_t.get_camera_info).
35 * Camera modules that may contain version 2.0 devices must implement at least
36 * version 2.0 of the camera module interface (as defined by
37 * camera_module_t.common.module_api_version).
39 * See camera_common.h for more versioning details.
45 struct camera2_device
;
47 /**********************************************************************
49 * Input/output stream buffer queue interface definitions
54 * Output image stream queue interface. A set of these methods is provided to
55 * the HAL device in allocate_stream(), and are used to interact with the
56 * gralloc buffer queue for that stream. They may not be called until after
57 * allocate_stream returns.
59 typedef struct camera2_stream_ops
{
61 * Get a buffer to fill from the queue. The size and format of the buffer
62 * are fixed for a given stream (defined in allocate_stream), and the stride
63 * should be queried from the platform gralloc module. The gralloc buffer
64 * will have been allocated based on the usage flags provided by
65 * allocate_stream, and will be locked for use.
67 int (*dequeue_buffer
)(const struct camera2_stream_ops
* w
,
68 buffer_handle_t
** buffer
);
71 * Push a filled buffer to the stream to be used by the consumer.
73 * The timestamp represents the time at start of exposure of the first row
74 * of the image; it must be from a monotonic clock, and is measured in
75 * nanoseconds. The timestamps do not need to be comparable between
76 * different cameras, or consecutive instances of the same camera. However,
77 * they must be comparable between streams from the same camera. If one
78 * capture produces buffers for multiple streams, each stream must have the
79 * same timestamp for that buffer, and that timestamp must match the
80 * timestamp in the output frame metadata.
82 int (*enqueue_buffer
)(const struct camera2_stream_ops
* w
,
84 buffer_handle_t
* buffer
);
86 * Return a buffer to the queue without marking it as filled.
88 int (*cancel_buffer
)(const struct camera2_stream_ops
* w
,
89 buffer_handle_t
* buffer
);
91 * Set the crop window for subsequently enqueued buffers. The parameters are
92 * measured in pixels relative to the buffer width and height.
94 int (*set_crop
)(const struct camera2_stream_ops
*w
,
95 int left
, int top
, int right
, int bottom
);
97 } camera2_stream_ops_t
;
100 * Temporary definition during transition.
102 * These formats will be removed and replaced with
103 * HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED. To maximize forward compatibility,
104 * HAL implementations are strongly recommended to treat FORMAT_OPAQUE and
105 * FORMAT_ZSL as equivalent to HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, and
106 * return HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED in the format_actual output
107 * parameter of allocate_stream, allowing the gralloc module to select the
108 * specific format based on the usage flags from the camera and the stream
112 CAMERA2_HAL_PIXEL_FORMAT_OPAQUE
= HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED
,
113 CAMERA2_HAL_PIXEL_FORMAT_ZSL
= -1
117 * Transport header for compressed JPEG buffers in output streams.
119 * To capture JPEG images, a stream is created using the pixel format
120 * HAL_PIXEL_FORMAT_BLOB, and the static metadata field android.jpeg.maxSize is
121 * used as the buffer size. Since compressed JPEG images are of variable size,
122 * the HAL needs to include the final size of the compressed image using this
123 * structure inside the output stream buffer. The JPEG blob ID field must be set
124 * to CAMERA2_JPEG_BLOB_ID.
126 * Transport header should be at the end of the JPEG output stream buffer. That
127 * means the jpeg_blob_id must start at byte[android.jpeg.maxSize -
128 * sizeof(camera2_jpeg_blob)]. Any HAL using this transport header must
129 * account for it in android.jpeg.maxSize. The JPEG data itself starts at
130 * byte[0] and should be jpeg_size bytes long.
132 typedef struct camera2_jpeg_blob
{
133 uint16_t jpeg_blob_id
;
138 CAMERA2_JPEG_BLOB_ID
= 0x00FF
142 * Input reprocess stream queue management. A set of these methods is provided
143 * to the HAL device in allocate_reprocess_stream(); they are used to interact
144 * with the reprocess stream's input gralloc buffer queue.
146 typedef struct camera2_stream_in_ops
{
148 * Get the next buffer of image data to reprocess. The width, height, and
149 * format of the buffer is fixed in allocate_reprocess_stream(), and the
150 * stride and other details should be queried from the platform gralloc
151 * module as needed. The buffer will already be locked for use.
153 int (*acquire_buffer
)(const struct camera2_stream_in_ops
*w
,
154 buffer_handle_t
** buffer
);
156 * Return a used buffer to the buffer queue for reuse.
158 int (*release_buffer
)(const struct camera2_stream_in_ops
*w
,
159 buffer_handle_t
* buffer
);
161 } camera2_stream_in_ops_t
;
163 /**********************************************************************
165 * Metadata queue management, used for requests sent to HAL module, and for
166 * frames produced by the HAL.
171 CAMERA2_REQUEST_QUEUE_IS_BOTTOMLESS
= -1
175 * Request input queue protocol:
177 * The framework holds the queue and its contents. At start, the queue is empty.
179 * 1. When the first metadata buffer is placed into the queue, the framework
180 * signals the device by calling notify_request_queue_not_empty().
182 * 2. After receiving notify_request_queue_not_empty, the device must call
183 * dequeue() once it's ready to handle the next buffer.
185 * 3. Once the device has processed a buffer, and is ready for the next buffer,
186 * it must call dequeue() again instead of waiting for a notification. If
187 * there are no more buffers available, dequeue() will return NULL. After
188 * this point, when a buffer becomes available, the framework must call
189 * notify_request_queue_not_empty() again. If the device receives a NULL
190 * return from dequeue, it does not need to query the queue again until a
191 * notify_request_queue_not_empty() call is received from the source.
193 * 4. If the device calls buffer_count() and receives 0, this does not mean that
194 * the framework will provide a notify_request_queue_not_empty() call. The
195 * framework will only provide such a notification after the device has
196 * received a NULL from dequeue, or on initial startup.
198 * 5. The dequeue() call in response to notify_request_queue_not_empty() may be
199 * on the same thread as the notify_request_queue_not_empty() call, and may
200 * be performed from within the notify call.
202 * 6. All dequeued request buffers must be returned to the framework by calling
203 * free_request, including when errors occur, a device flush is requested, or
204 * when the device is shutting down.
206 typedef struct camera2_request_queue_src_ops
{
208 * Get the count of request buffers pending in the queue. May return
209 * CAMERA2_REQUEST_QUEUE_IS_BOTTOMLESS if a repeating request (stream
210 * request) is currently configured. Calling this method has no effect on
211 * whether the notify_request_queue_not_empty() method will be called by the
214 int (*request_count
)(const struct camera2_request_queue_src_ops
*q
);
217 * Get a metadata buffer from the framework. Returns OK if there is no
218 * error. If the queue is empty, returns NULL in buffer. In that case, the
219 * device must wait for a notify_request_queue_not_empty() message before
220 * attempting to dequeue again. Buffers obtained in this way must be
221 * returned to the framework with free_request().
223 int (*dequeue_request
)(const struct camera2_request_queue_src_ops
*q
,
224 camera_metadata_t
**buffer
);
226 * Return a metadata buffer to the framework once it has been used, or if
227 * an error or shutdown occurs.
229 int (*free_request
)(const struct camera2_request_queue_src_ops
*q
,
230 camera_metadata_t
*old_buffer
);
232 } camera2_request_queue_src_ops_t
;
235 * Frame output queue protocol:
237 * The framework holds the queue and its contents. At start, the queue is empty.
239 * 1. When the device is ready to fill an output metadata frame, it must dequeue
240 * a metadata buffer of the required size.
242 * 2. It should then fill the metadata buffer, and place it on the frame queue
243 * using enqueue_frame. The framework takes ownership of the frame.
245 * 3. In case of an error, a request to flush the pipeline, or shutdown, the
246 * device must return any affected dequeued frames to the framework by
247 * calling cancel_frame.
249 typedef struct camera2_frame_queue_dst_ops
{
251 * Get an empty metadata buffer to fill from the framework. The new metadata
252 * buffer will have room for entries number of metadata entries, plus
253 * data_bytes worth of extra storage. Frames dequeued here must be returned
254 * to the framework with either cancel_frame or enqueue_frame.
256 int (*dequeue_frame
)(const struct camera2_frame_queue_dst_ops
*q
,
257 size_t entries
, size_t data_bytes
,
258 camera_metadata_t
**buffer
);
261 * Return a dequeued metadata buffer to the framework for reuse; do not mark it as
262 * filled. Use when encountering errors, or flushing the internal request queue.
264 int (*cancel_frame
)(const struct camera2_frame_queue_dst_ops
*q
,
265 camera_metadata_t
*buffer
);
268 * Place a completed metadata frame on the frame output queue.
270 int (*enqueue_frame
)(const struct camera2_frame_queue_dst_ops
*q
,
271 camera_metadata_t
*buffer
);
273 } camera2_frame_queue_dst_ops_t
;
275 /**********************************************************************
277 * Notification callback and message definition, and trigger definitions
282 * Asynchronous notification callback from the HAL, fired for various
283 * reasons. Only for information independent of frame capture, or that require
284 * specific timing. The user pointer must be the same one that was passed to the
285 * device in set_notify_callback().
287 typedef void (*camera2_notify_callback
)(int32_t msg_type
,
294 * Possible message types for camera2_notify_callback
298 * An error has occurred. Argument ext1 contains the error code, and
299 * ext2 and ext3 contain any error-specific information.
301 CAMERA2_MSG_ERROR
= 0x0001,
303 * The exposure of a given request has begun. Argument ext1 contains the
304 * frame number, and ext2 and ext3 contain the low-order and high-order
305 * bytes of the timestamp for when exposure began.
306 * (timestamp = (ext3 << 32 | ext2))
308 CAMERA2_MSG_SHUTTER
= 0x0010,
310 * The autofocus routine has changed state. Argument ext1 contains the new
311 * state; the values are the same as those for the metadata field
312 * android.control.afState. Ext2 contains the latest trigger ID passed to
313 * trigger_action(CAMERA2_TRIGGER_AUTOFOCUS) or
314 * trigger_action(CAMERA2_TRIGGER_CANCEL_AUTOFOCUS), or 0 if trigger has not
315 * been called with either of those actions.
317 CAMERA2_MSG_AUTOFOCUS
= 0x0020,
319 * The autoexposure routine has changed state. Argument ext1 contains the
320 * new state; the values are the same as those for the metadata field
321 * android.control.aeState. Ext2 contains the latest trigger ID value passed to
322 * trigger_action(CAMERA2_TRIGGER_PRECAPTURE_METERING), or 0 if that method
323 * has not been called.
325 CAMERA2_MSG_AUTOEXPOSURE
= 0x0021,
327 * The auto-whitebalance routine has changed state. Argument ext1 contains
328 * the new state; the values are the same as those for the metadata field
329 * android.control.awbState. Ext2 contains the latest trigger ID passed to
330 * trigger_action(CAMERA2_TRIGGER_PRECAPTURE_METERING), or 0 if that method
331 * has not been called.
333 CAMERA2_MSG_AUTOWB
= 0x0022
337 * Error codes for CAMERA_MSG_ERROR
341 * A serious failure occured. Camera device may not work without reboot, and
342 * no further frames or buffer streams will be produced by the
343 * device. Device should be treated as closed.
345 CAMERA2_MSG_ERROR_HARDWARE
= 0x0001,
347 * A serious failure occured. No further frames or buffer streams will be
348 * produced by the device. Device should be treated as closed. The client
349 * must reopen the device to use it again.
351 CAMERA2_MSG_ERROR_DEVICE
,
353 * An error has occurred in processing a request. No output (metadata or
354 * buffers) will be produced for this request. ext2 contains the frame
355 * number of the request. Subsequent requests are unaffected, and the device
356 * remains operational.
358 CAMERA2_MSG_ERROR_REQUEST
,
360 * An error has occurred in producing an output frame metadata buffer for a
361 * request, but image buffers for it will still be available. Subsequent
362 * requests are unaffected, and the device remains operational. ext2
363 * contains the frame number of the request.
365 CAMERA2_MSG_ERROR_FRAME
,
367 * An error has occurred in placing an output buffer into a stream for a
368 * request. The frame metadata and other buffers may still be
369 * available. Subsequent requests are unaffected, and the device remains
370 * operational. ext2 contains the frame number of the request, and ext3
371 * contains the stream id.
373 CAMERA2_MSG_ERROR_STREAM
,
375 * Number of error types
377 CAMERA2_MSG_NUM_ERRORS
381 * Possible trigger ids for trigger_action()
385 * Trigger an autofocus cycle. The effect of the trigger depends on the
386 * autofocus mode in effect when the trigger is received, which is the mode
387 * listed in the latest capture request to be dequeued by the HAL. If the
388 * mode is OFF, EDOF, or FIXED, the trigger has no effect. In AUTO, MACRO,
389 * or CONTINUOUS_* modes, see below for the expected behavior. The state of
390 * the autofocus cycle can be tracked in android.control.afMode and the
391 * corresponding notifications.
394 * In AUTO or MACRO mode, the AF state transitions (and notifications)
395 * when calling with trigger ID = N with the previous ID being K are:
397 * Initial state Transitions
398 * INACTIVE (K) -> ACTIVE_SCAN (N) -> AF_FOCUSED (N) or AF_NOT_FOCUSED (N)
399 * AF_FOCUSED (K) -> ACTIVE_SCAN (N) -> AF_FOCUSED (N) or AF_NOT_FOCUSED (N)
400 * AF_NOT_FOCUSED (K) -> ACTIVE_SCAN (N) -> AF_FOCUSED (N) or AF_NOT_FOCUSED (N)
401 * ACTIVE_SCAN (K) -> AF_FOCUSED(N) or AF_NOT_FOCUSED(N)
402 * PASSIVE_SCAN (K) Not used in AUTO/MACRO mode
403 * PASSIVE_FOCUSED (K) Not used in AUTO/MACRO mode
406 * In CONTINUOUS_PICTURE mode, triggering AF must lock the AF to the current
407 * lens position and transition the AF state to either AF_FOCUSED or
408 * NOT_FOCUSED. If a passive scan is underway, that scan must complete and
409 * then lock the lens position and change AF state. TRIGGER_CANCEL_AUTOFOCUS
410 * will allow the AF to restart its operation.
412 * Initial state Transitions
413 * INACTIVE (K) -> immediate AF_FOCUSED (N) or AF_NOT_FOCUSED (N)
414 * PASSIVE_FOCUSED (K) -> immediate AF_FOCUSED (N) or AF_NOT_FOCUSED (N)
415 * PASSIVE_SCAN (K) -> AF_FOCUSED (N) or AF_NOT_FOCUSED (N)
416 * AF_FOCUSED (K) no effect except to change next notification ID to N
417 * AF_NOT_FOCUSED (K) no effect except to change next notification ID to N
420 * In CONTINUOUS_VIDEO mode, triggering AF must lock the AF to the current
421 * lens position and transition the AF state to either AF_FOCUSED or
422 * NOT_FOCUSED. If a passive scan is underway, it must immediately halt, in
423 * contrast with CONTINUOUS_PICTURE mode. TRIGGER_CANCEL_AUTOFOCUS will
424 * allow the AF to restart its operation.
426 * Initial state Transitions
427 * INACTIVE (K) -> immediate AF_FOCUSED (N) or AF_NOT_FOCUSED (N)
428 * PASSIVE_FOCUSED (K) -> immediate AF_FOCUSED (N) or AF_NOT_FOCUSED (N)
429 * PASSIVE_SCAN (K) -> immediate AF_FOCUSED (N) or AF_NOT_FOCUSED (N)
430 * AF_FOCUSED (K) no effect except to change next notification ID to N
431 * AF_NOT_FOCUSED (K) no effect except to change next notification ID to N
433 * Ext1 is an ID that must be returned in subsequent auto-focus state change
434 * notifications through camera2_notify_callback() and stored in
435 * android.control.afTriggerId.
437 CAMERA2_TRIGGER_AUTOFOCUS
= 0x0001,
439 * Send a cancel message to the autofocus algorithm. The effect of the
440 * cancellation depends on the autofocus mode in effect when the trigger is
441 * received, which is the mode listed in the latest capture request to be
442 * dequeued by the HAL. If the AF mode is OFF or EDOF, the cancel has no
443 * effect. For other modes, the lens should return to its default position,
444 * any current autofocus scan must be canceled, and the AF state should be
447 * The state of the autofocus cycle can be tracked in android.control.afMode
448 * and the corresponding notification. Continuous autofocus modes may resume
449 * focusing operations thereafter exactly as if the camera had just been set
450 * to a continuous AF mode.
452 * Ext1 is an ID that must be returned in subsequent auto-focus state change
453 * notifications through camera2_notify_callback() and stored in
454 * android.control.afTriggerId.
456 CAMERA2_TRIGGER_CANCEL_AUTOFOCUS
,
458 * Trigger a pre-capture metering cycle, which may include firing the flash
459 * to determine proper capture parameters. Typically, this trigger would be
460 * fired for a half-depress of a camera shutter key, or before a snapshot
461 * capture in general. The state of the metering cycle can be tracked in
462 * android.control.aeMode and the corresponding notification. If the
463 * auto-exposure mode is OFF, the trigger does nothing.
465 * Ext1 is an ID that must be returned in subsequent
466 * auto-exposure/auto-white balance state change notifications through
467 * camera2_notify_callback() and stored in android.control.aePrecaptureId.
469 CAMERA2_TRIGGER_PRECAPTURE_METERING
473 * Possible template types for construct_default_request()
477 * Standard camera preview operation with 3A on auto.
479 CAMERA2_TEMPLATE_PREVIEW
= 1,
481 * Standard camera high-quality still capture with 3A and flash on auto.
483 CAMERA2_TEMPLATE_STILL_CAPTURE
,
485 * Standard video recording plus preview with 3A on auto, torch off.
487 CAMERA2_TEMPLATE_VIDEO_RECORD
,
489 * High-quality still capture while recording video. Application will
490 * include preview, video record, and full-resolution YUV or JPEG streams in
491 * request. Must not cause stuttering on video stream. 3A on auto.
493 CAMERA2_TEMPLATE_VIDEO_SNAPSHOT
,
495 * Zero-shutter-lag mode. Application will request preview and
496 * full-resolution data for each frame, and reprocess it to JPEG when a
497 * still image is requested by user. Settings should provide highest-quality
498 * full-resolution images without compromising preview frame rate. 3A on
501 CAMERA2_TEMPLATE_ZERO_SHUTTER_LAG
,
503 /* Total number of templates */
504 CAMERA2_TEMPLATE_COUNT
508 /**********************************************************************
510 * Camera device operations
513 typedef struct camera2_device_ops
{
515 /**********************************************************************
516 * Request and frame queue setup and management methods
520 * Pass in input request queue interface methods.
522 int (*set_request_queue_src_ops
)(const struct camera2_device
*,
523 const camera2_request_queue_src_ops_t
*request_src_ops
);
526 * Notify device that the request queue is no longer empty. Must only be
527 * called when the first buffer is added a new queue, or after the source
528 * has returned NULL in response to a dequeue call.
530 int (*notify_request_queue_not_empty
)(const struct camera2_device
*);
533 * Pass in output frame queue interface methods
535 int (*set_frame_queue_dst_ops
)(const struct camera2_device
*,
536 const camera2_frame_queue_dst_ops_t
*frame_dst_ops
);
539 * Number of camera requests being processed by the device at the moment
540 * (captures/reprocesses that have had their request dequeued, but have not
541 * yet been enqueued onto output pipeline(s) ). No streams may be released
542 * by the framework until the in-progress count is 0.
544 int (*get_in_progress_count
)(const struct camera2_device
*);
547 * Flush all in-progress captures. This includes all dequeued requests
548 * (regular or reprocessing) that have not yet placed any outputs into a
549 * stream or the frame queue. Partially completed captures must be completed
550 * normally. No new requests may be dequeued from the request queue until
551 * the flush completes.
553 int (*flush_captures_in_progress
)(const struct camera2_device
*);
556 * Create a filled-in default request for standard camera use cases.
558 * The device must return a complete request that is configured to meet the
559 * requested use case, which must be one of the CAMERA2_TEMPLATE_*
560 * enums. All request control fields must be included, except for
561 * android.request.outputStreams.
563 * The metadata buffer returned must be allocated with
564 * allocate_camera_metadata. The framework takes ownership of the buffer.
566 int (*construct_default_request
)(const struct camera2_device
*,
567 int request_template
,
568 camera_metadata_t
**request
);
570 /**********************************************************************
577 * Allocate a new output stream for use, defined by the output buffer width,
578 * height, target, and possibly the pixel format. Returns the new stream's
579 * ID, gralloc usage flags, minimum queue buffer count, and possibly the
580 * pixel format, on success. Error conditions:
582 * - Requesting a width/height/format combination not listed as
583 * supported by the sensor's static characteristics
585 * - Asking for too many streams of a given format type (2 bayer raw
586 * streams, for example).
590 * - width, height, format: Specification for the buffers to be sent through
591 * this stream. Format is a value from the HAL_PIXEL_FORMAT_* list. If
592 * HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED is used, then the platform
593 * gralloc module will select a format based on the usage flags provided
594 * by the camera HAL and the consumer of the stream. The camera HAL should
595 * inspect the buffers handed to it in the register_stream_buffers call to
596 * obtain the implementation-specific format if necessary.
598 * - stream_ops: A structure of function pointers for obtaining and queuing
599 * up buffers for this stream. The underlying stream will be configured
600 * based on the usage and max_buffers outputs. The methods in this
601 * structure may not be called until after allocate_stream returns.
605 * - stream_id: An unsigned integer identifying this stream. This value is
606 * used in incoming requests to identify the stream, and in releasing the
609 * - usage: The gralloc usage mask needed by the HAL device for producing
610 * the requested type of data. This is used in allocating new gralloc
611 * buffers for the stream buffer queue.
613 * - max_buffers: The maximum number of buffers the HAL device may need to
614 * have dequeued at the same time. The device may not dequeue more buffers
615 * than this value at the same time.
618 int (*allocate_stream
)(
619 const struct camera2_device
*,
624 const camera2_stream_ops_t
*stream_ops
,
627 uint32_t *format_actual
, // IGNORED, will be removed
629 uint32_t *max_buffers
);
632 * Register buffers for a given stream. This is called after a successful
633 * allocate_stream call, and before the first request referencing the stream
634 * is enqueued. This method is intended to allow the HAL device to map or
635 * otherwise prepare the buffers for later use. num_buffers is guaranteed to
636 * be at least max_buffers (from allocate_stream), but may be larger. The
637 * buffers will already be locked for use. At the end of the call, all the
638 * buffers must be ready to be returned to the queue. If the stream format
639 * was set to HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, the camera HAL should
640 * inspect the passed-in buffers here to determine any platform-private
641 * pixel format information.
643 int (*register_stream_buffers
)(
644 const struct camera2_device
*,
647 buffer_handle_t
*buffers
);
650 * Release a stream. Returns an error if called when get_in_progress_count
651 * is non-zero, or if the stream id is invalid.
653 int (*release_stream
)(
654 const struct camera2_device
*,
658 * allocate_reprocess_stream:
660 * Allocate a new input stream for use, defined by the output buffer width,
661 * height, and the pixel format. Returns the new stream's ID, gralloc usage
662 * flags, and required simultaneously acquirable buffer count, on
663 * success. Error conditions:
665 * - Requesting a width/height/format combination not listed as
666 * supported by the sensor's static characteristics
668 * - Asking for too many reprocessing streams to be configured at once.
672 * - width, height, format: Specification for the buffers to be sent through
673 * this stream. Format must be a value from the HAL_PIXEL_FORMAT_* list.
675 * - reprocess_stream_ops: A structure of function pointers for acquiring
676 * and releasing buffers for this stream. The underlying stream will be
677 * configured based on the usage and max_buffers outputs.
681 * - stream_id: An unsigned integer identifying this stream. This value is
682 * used in incoming requests to identify the stream, and in releasing the
683 * stream. These ids are numbered separately from the input stream ids.
685 * - consumer_usage: The gralloc usage mask needed by the HAL device for
686 * consuming the requested type of data. This is used in allocating new
687 * gralloc buffers for the stream buffer queue.
689 * - max_buffers: The maximum number of buffers the HAL device may need to
690 * have acquired at the same time. The device may not have more buffers
691 * acquired at the same time than this value.
694 int (*allocate_reprocess_stream
)(const struct camera2_device
*,
698 const camera2_stream_in_ops_t
*reprocess_stream_ops
,
701 uint32_t *consumer_usage
,
702 uint32_t *max_buffers
);
705 * allocate_reprocess_stream_from_stream:
707 * Allocate a new input stream for use, which will use the buffers allocated
708 * for an existing output stream. That is, after the HAL enqueues a buffer
709 * onto the output stream, it may see that same buffer handed to it from
710 * this input reprocessing stream. After the HAL releases the buffer back to
711 * the reprocessing stream, it will be returned to the output queue for
716 * - Using an output stream of unsuitable size/format for the basis of the
717 * reprocessing stream.
719 * - Attempting to allocatee too many reprocessing streams at once.
723 * - output_stream_id: The ID of an existing output stream which has
724 * a size and format suitable for reprocessing.
726 * - reprocess_stream_ops: A structure of function pointers for acquiring
727 * and releasing buffers for this stream. The underlying stream will use
728 * the same graphics buffer handles as the output stream uses.
732 * - stream_id: An unsigned integer identifying this stream. This value is
733 * used in incoming requests to identify the stream, and in releasing the
734 * stream. These ids are numbered separately from the input stream ids.
736 * The HAL client must always release the reprocessing stream before it
737 * releases the output stream it is based on.
740 int (*allocate_reprocess_stream_from_stream
)(const struct camera2_device
*,
741 uint32_t output_stream_id
,
742 const camera2_stream_in_ops_t
*reprocess_stream_ops
,
744 uint32_t *stream_id
);
747 * Release a reprocessing stream. Returns an error if called when
748 * get_in_progress_count is non-zero, or if the stream id is not
751 int (*release_reprocess_stream
)(
752 const struct camera2_device
*,
755 /**********************************************************************
756 * Miscellaneous methods
760 * Trigger asynchronous activity. This is used for triggering special
761 * behaviors of the camera 3A routines when they are in use. See the
762 * documentation for CAMERA2_TRIGGER_* above for details of the trigger ids
763 * and their arguments.
765 int (*trigger_action
)(const struct camera2_device
*,
771 * Notification callback setup
773 int (*set_notify_callback
)(const struct camera2_device
*,
774 camera2_notify_callback notify_cb
,
778 * Get methods to query for vendor extension metadata tag infomation. May
779 * set ops to NULL if no vendor extension tags are defined.
781 int (*get_metadata_vendor_tag_ops
)(const struct camera2_device
*,
782 vendor_tag_query_ops_t
**ops
);
785 * Dump state of the camera hardware
787 int (*dump
)(const struct camera2_device
*, int fd
);
789 } camera2_device_ops_t
;
791 /**********************************************************************
793 * Camera device definition
796 typedef struct camera2_device
{
798 * common.version must equal CAMERA_DEVICE_API_VERSION_2_0 to identify
799 * this device as implementing version 2.0 of the camera device HAL.
802 camera2_device_ops_t
*ops
;
808 #endif /* #ifdef ANDROID_INCLUDE_CAMERA2_H */