Eino-Ville Talvala | 8bf364e | 2011-12-22 13:50:37 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2012 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_CAMERA2_H |
| 18 | #define ANDROID_INCLUDE_CAMERA2_H |
| 19 | |
| 20 | #include "camera_common.h" |
Eino-Ville Talvala | 567b4a2 | 2012-04-23 09:29:38 -0700 | [diff] [blame] | 21 | #include "system/camera_metadata.h" |
Eino-Ville Talvala | 8bf364e | 2011-12-22 13:50:37 -0800 | [diff] [blame] | 22 | |
| 23 | /** |
Eino-Ville Talvala | ddc026e | 2012-03-27 16:15:25 -0700 | [diff] [blame] | 24 | * Camera device HAL 2.0 [ CAMERA_DEVICE_API_VERSION_2_0 ] |
Eino-Ville Talvala | 8bf364e | 2011-12-22 13:50:37 -0800 | [diff] [blame] | 25 | * |
| 26 | * EXPERIMENTAL. |
| 27 | * |
| 28 | * Supports both the android.hardware.ProCamera and |
| 29 | * android.hardware.Camera APIs. |
| 30 | * |
| 31 | * Camera devices that support this version of the HAL must return |
Eino-Ville Talvala | ddc026e | 2012-03-27 16:15:25 -0700 | [diff] [blame] | 32 | * CAMERA_DEVICE_API_VERSION_2_0 in camera_device_t.common.version and in |
Eino-Ville Talvala | 8bf364e | 2011-12-22 13:50:37 -0800 | [diff] [blame] | 33 | * camera_info_t.device_version (from camera_module_t.get_camera_info). |
| 34 | * |
| 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). |
| 38 | * |
Eino-Ville Talvala | 567b4a2 | 2012-04-23 09:29:38 -0700 | [diff] [blame] | 39 | * See camera_common.h for more versioning details. |
Eino-Ville Talvala | 8bf364e | 2011-12-22 13:50:37 -0800 | [diff] [blame] | 40 | * |
| 41 | */ |
| 42 | |
| 43 | __BEGIN_DECLS |
| 44 | |
Eino-Ville Talvala | fed0c02 | 2012-03-22 13:11:05 -0700 | [diff] [blame] | 45 | struct camera2_device; |
| 46 | |
Eino-Ville Talvala | 567b4a2 | 2012-04-23 09:29:38 -0700 | [diff] [blame] | 47 | /********************************************************************** |
| 48 | * |
| 49 | * Input/output stream buffer queue interface definitions |
| 50 | * |
Eino-Ville Talvala | 8bf364e | 2011-12-22 13:50:37 -0800 | [diff] [blame] | 51 | */ |
| 52 | |
Eino-Ville Talvala | 567b4a2 | 2012-04-23 09:29:38 -0700 | [diff] [blame] | 53 | /** |
| 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. |
| 58 | */ |
Eino-Ville Talvala | 8bf364e | 2011-12-22 13:50:37 -0800 | [diff] [blame] | 59 | typedef struct camera2_stream_ops { |
Eino-Ville Talvala | 567b4a2 | 2012-04-23 09:29:38 -0700 | [diff] [blame] | 60 | /** |
| 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. |
| 66 | */ |
Eino-Ville Talvala | 08a6e5e | 2012-05-17 17:54:56 -0700 | [diff] [blame] | 67 | int (*dequeue_buffer)(const struct camera2_stream_ops* w, |
Eino-Ville Talvala | 567b4a2 | 2012-04-23 09:29:38 -0700 | [diff] [blame] | 68 | buffer_handle_t** buffer); |
| 69 | |
| 70 | /** |
| 71 | * Push a filled buffer to the stream to be used by the consumer. |
| 72 | * |
| 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. |
| 81 | */ |
Eino-Ville Talvala | 08a6e5e | 2012-05-17 17:54:56 -0700 | [diff] [blame] | 82 | int (*enqueue_buffer)(const struct camera2_stream_ops* w, |
Eino-Ville Talvala | 567b4a2 | 2012-04-23 09:29:38 -0700 | [diff] [blame] | 83 | int64_t timestamp, |
| 84 | buffer_handle_t* buffer); |
| 85 | /** |
| 86 | * Return a buffer to the queue without marking it as filled. |
| 87 | */ |
Eino-Ville Talvala | 08a6e5e | 2012-05-17 17:54:56 -0700 | [diff] [blame] | 88 | int (*cancel_buffer)(const struct camera2_stream_ops* w, |
Eino-Ville Talvala | 567b4a2 | 2012-04-23 09:29:38 -0700 | [diff] [blame] | 89 | buffer_handle_t* buffer); |
| 90 | /** |
| 91 | * Set the crop window for subsequently enqueued buffers. The parameters are |
| 92 | * measured in pixels relative to the buffer width and height. |
| 93 | */ |
Eino-Ville Talvala | 08a6e5e | 2012-05-17 17:54:56 -0700 | [diff] [blame] | 94 | int (*set_crop)(const struct camera2_stream_ops *w, |
Eino-Ville Talvala | 567b4a2 | 2012-04-23 09:29:38 -0700 | [diff] [blame] | 95 | int left, int top, int right, int bottom); |
| 96 | |
Eino-Ville Talvala | 8bf364e | 2011-12-22 13:50:37 -0800 | [diff] [blame] | 97 | } camera2_stream_ops_t; |
| 98 | |
Eino-Ville Talvala | 2388a2d | 2012-08-28 14:01:26 -0700 | [diff] [blame] | 99 | /** |
Eino-Ville Talvala | 9633d50 | 2012-09-13 16:32:14 -0700 | [diff] [blame] | 100 | * Temporary definition during transition. |
| 101 | * |
| 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 |
| 109 | * consumer. |
| 110 | */ |
Eino-Ville Talvala | 567b4a2 | 2012-04-23 09:29:38 -0700 | [diff] [blame] | 111 | enum { |
Eino-Ville Talvala | 9633d50 | 2012-09-13 16:32:14 -0700 | [diff] [blame] | 112 | CAMERA2_HAL_PIXEL_FORMAT_OPAQUE = HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, |
| 113 | CAMERA2_HAL_PIXEL_FORMAT_ZSL = -1 |
Eino-Ville Talvala | 567b4a2 | 2012-04-23 09:29:38 -0700 | [diff] [blame] | 114 | }; |
| 115 | |
| 116 | /** |
| 117 | * Input reprocess stream queue management. A set of these methods is provided |
Eino-Ville Talvala | fa7a91d | 2012-05-22 10:41:20 -0700 | [diff] [blame] | 118 | * to the HAL device in allocate_reprocess_stream(); they are used to interact |
| 119 | * with the reprocess stream's input gralloc buffer queue. |
Eino-Ville Talvala | 567b4a2 | 2012-04-23 09:29:38 -0700 | [diff] [blame] | 120 | */ |
| 121 | typedef struct camera2_stream_in_ops { |
| 122 | /** |
| 123 | * Get the next buffer of image data to reprocess. The width, height, and |
| 124 | * format of the buffer is fixed in allocate_reprocess_stream(), and the |
| 125 | * stride and other details should be queried from the platform gralloc |
| 126 | * module as needed. The buffer will already be locked for use. |
| 127 | */ |
Eino-Ville Talvala | 08a6e5e | 2012-05-17 17:54:56 -0700 | [diff] [blame] | 128 | int (*acquire_buffer)(const struct camera2_stream_in_ops *w, |
Eino-Ville Talvala | 567b4a2 | 2012-04-23 09:29:38 -0700 | [diff] [blame] | 129 | buffer_handle_t** buffer); |
| 130 | /** |
| 131 | * Return a used buffer to the buffer queue for reuse. |
| 132 | */ |
Eino-Ville Talvala | 08a6e5e | 2012-05-17 17:54:56 -0700 | [diff] [blame] | 133 | int (*release_buffer)(const struct camera2_stream_in_ops *w, |
Eino-Ville Talvala | 567b4a2 | 2012-04-23 09:29:38 -0700 | [diff] [blame] | 134 | buffer_handle_t* buffer); |
| 135 | |
| 136 | } camera2_stream_in_ops_t; |
| 137 | |
| 138 | /********************************************************************** |
| 139 | * |
Eino-Ville Talvala | 8bf364e | 2011-12-22 13:50:37 -0800 | [diff] [blame] | 140 | * Metadata queue management, used for requests sent to HAL module, and for |
| 141 | * frames produced by the HAL. |
Eino-Ville Talvala | fed0c02 | 2012-03-22 13:11:05 -0700 | [diff] [blame] | 142 | * |
Eino-Ville Talvala | 8bf364e | 2011-12-22 13:50:37 -0800 | [diff] [blame] | 143 | */ |
| 144 | |
Eino-Ville Talvala | 567b4a2 | 2012-04-23 09:29:38 -0700 | [diff] [blame] | 145 | enum { |
| 146 | CAMERA2_REQUEST_QUEUE_IS_BOTTOMLESS = -1 |
| 147 | }; |
| 148 | |
| 149 | /** |
| 150 | * Request input queue protocol: |
| 151 | * |
| 152 | * The framework holds the queue and its contents. At start, the queue is empty. |
| 153 | * |
| 154 | * 1. When the first metadata buffer is placed into the queue, the framework |
| 155 | * signals the device by calling notify_request_queue_not_empty(). |
| 156 | * |
| 157 | * 2. After receiving notify_request_queue_not_empty, the device must call |
| 158 | * dequeue() once it's ready to handle the next buffer. |
| 159 | * |
| 160 | * 3. Once the device has processed a buffer, and is ready for the next buffer, |
| 161 | * it must call dequeue() again instead of waiting for a notification. If |
| 162 | * there are no more buffers available, dequeue() will return NULL. After |
| 163 | * this point, when a buffer becomes available, the framework must call |
| 164 | * notify_request_queue_not_empty() again. If the device receives a NULL |
| 165 | * return from dequeue, it does not need to query the queue again until a |
| 166 | * notify_request_queue_not_empty() call is received from the source. |
| 167 | * |
| 168 | * 4. If the device calls buffer_count() and receives 0, this does not mean that |
| 169 | * the framework will provide a notify_request_queue_not_empty() call. The |
| 170 | * framework will only provide such a notification after the device has |
| 171 | * received a NULL from dequeue, or on initial startup. |
| 172 | * |
| 173 | * 5. The dequeue() call in response to notify_request_queue_not_empty() may be |
| 174 | * on the same thread as the notify_request_queue_not_empty() call, and may |
| 175 | * be performed from within the notify call. |
| 176 | * |
| 177 | * 6. All dequeued request buffers must be returned to the framework by calling |
| 178 | * free_request, including when errors occur, a device flush is requested, or |
| 179 | * when the device is shutting down. |
| 180 | */ |
| 181 | typedef struct camera2_request_queue_src_ops { |
Eino-Ville Talvala | 8bf364e | 2011-12-22 13:50:37 -0800 | [diff] [blame] | 182 | /** |
Eino-Ville Talvala | 567b4a2 | 2012-04-23 09:29:38 -0700 | [diff] [blame] | 183 | * Get the count of request buffers pending in the queue. May return |
| 184 | * CAMERA2_REQUEST_QUEUE_IS_BOTTOMLESS if a repeating request (stream |
| 185 | * request) is currently configured. Calling this method has no effect on |
| 186 | * whether the notify_request_queue_not_empty() method will be called by the |
| 187 | * framework. |
Eino-Ville Talvala | 8bf364e | 2011-12-22 13:50:37 -0800 | [diff] [blame] | 188 | */ |
Eino-Ville Talvala | 08a6e5e | 2012-05-17 17:54:56 -0700 | [diff] [blame] | 189 | int (*request_count)(const struct camera2_request_queue_src_ops *q); |
Eino-Ville Talvala | 8bf364e | 2011-12-22 13:50:37 -0800 | [diff] [blame] | 190 | |
| 191 | /** |
Eino-Ville Talvala | 567b4a2 | 2012-04-23 09:29:38 -0700 | [diff] [blame] | 192 | * Get a metadata buffer from the framework. Returns OK if there is no |
| 193 | * error. If the queue is empty, returns NULL in buffer. In that case, the |
| 194 | * device must wait for a notify_request_queue_not_empty() message before |
| 195 | * attempting to dequeue again. Buffers obtained in this way must be |
| 196 | * returned to the framework with free_request(). |
Eino-Ville Talvala | 8bf364e | 2011-12-22 13:50:37 -0800 | [diff] [blame] | 197 | */ |
Eino-Ville Talvala | 08a6e5e | 2012-05-17 17:54:56 -0700 | [diff] [blame] | 198 | int (*dequeue_request)(const struct camera2_request_queue_src_ops *q, |
Eino-Ville Talvala | 8bf364e | 2011-12-22 13:50:37 -0800 | [diff] [blame] | 199 | camera_metadata_t **buffer); |
| 200 | /** |
Eino-Ville Talvala | 567b4a2 | 2012-04-23 09:29:38 -0700 | [diff] [blame] | 201 | * Return a metadata buffer to the framework once it has been used, or if |
| 202 | * an error or shutdown occurs. |
Eino-Ville Talvala | 8bf364e | 2011-12-22 13:50:37 -0800 | [diff] [blame] | 203 | */ |
Eino-Ville Talvala | 08a6e5e | 2012-05-17 17:54:56 -0700 | [diff] [blame] | 204 | int (*free_request)(const struct camera2_request_queue_src_ops *q, |
Eino-Ville Talvala | 8bf364e | 2011-12-22 13:50:37 -0800 | [diff] [blame] | 205 | camera_metadata_t *old_buffer); |
| 206 | |
Eino-Ville Talvala | 567b4a2 | 2012-04-23 09:29:38 -0700 | [diff] [blame] | 207 | } camera2_request_queue_src_ops_t; |
Eino-Ville Talvala | 8bf364e | 2011-12-22 13:50:37 -0800 | [diff] [blame] | 208 | |
Eino-Ville Talvala | 567b4a2 | 2012-04-23 09:29:38 -0700 | [diff] [blame] | 209 | /** |
| 210 | * Frame output queue protocol: |
| 211 | * |
| 212 | * The framework holds the queue and its contents. At start, the queue is empty. |
| 213 | * |
| 214 | * 1. When the device is ready to fill an output metadata frame, it must dequeue |
| 215 | * a metadata buffer of the required size. |
| 216 | * |
| 217 | * 2. It should then fill the metadata buffer, and place it on the frame queue |
| 218 | * using enqueue_frame. The framework takes ownership of the frame. |
| 219 | * |
| 220 | * 3. In case of an error, a request to flush the pipeline, or shutdown, the |
| 221 | * device must return any affected dequeued frames to the framework by |
| 222 | * calling cancel_frame. |
| 223 | */ |
| 224 | typedef struct camera2_frame_queue_dst_ops { |
Eino-Ville Talvala | 8bf364e | 2011-12-22 13:50:37 -0800 | [diff] [blame] | 225 | /** |
Eino-Ville Talvala | 567b4a2 | 2012-04-23 09:29:38 -0700 | [diff] [blame] | 226 | * Get an empty metadata buffer to fill from the framework. The new metadata |
| 227 | * buffer will have room for entries number of metadata entries, plus |
| 228 | * data_bytes worth of extra storage. Frames dequeued here must be returned |
| 229 | * to the framework with either cancel_frame or enqueue_frame. |
Eino-Ville Talvala | 8bf364e | 2011-12-22 13:50:37 -0800 | [diff] [blame] | 230 | */ |
Eino-Ville Talvala | 08a6e5e | 2012-05-17 17:54:56 -0700 | [diff] [blame] | 231 | int (*dequeue_frame)(const struct camera2_frame_queue_dst_ops *q, |
Eino-Ville Talvala | 567b4a2 | 2012-04-23 09:29:38 -0700 | [diff] [blame] | 232 | size_t entries, size_t data_bytes, |
| 233 | camera_metadata_t **buffer); |
Eino-Ville Talvala | fed0c02 | 2012-03-22 13:11:05 -0700 | [diff] [blame] | 234 | |
Eino-Ville Talvala | 567b4a2 | 2012-04-23 09:29:38 -0700 | [diff] [blame] | 235 | /** |
| 236 | * Return a dequeued metadata buffer to the framework for reuse; do not mark it as |
| 237 | * filled. Use when encountering errors, or flushing the internal request queue. |
| 238 | */ |
Eino-Ville Talvala | 08a6e5e | 2012-05-17 17:54:56 -0700 | [diff] [blame] | 239 | int (*cancel_frame)(const struct camera2_frame_queue_dst_ops *q, |
Eino-Ville Talvala | 567b4a2 | 2012-04-23 09:29:38 -0700 | [diff] [blame] | 240 | camera_metadata_t *buffer); |
Eino-Ville Talvala | 8bf364e | 2011-12-22 13:50:37 -0800 | [diff] [blame] | 241 | |
Eino-Ville Talvala | 567b4a2 | 2012-04-23 09:29:38 -0700 | [diff] [blame] | 242 | /** |
| 243 | * Place a completed metadata frame on the frame output queue. |
| 244 | */ |
Eino-Ville Talvala | 08a6e5e | 2012-05-17 17:54:56 -0700 | [diff] [blame] | 245 | int (*enqueue_frame)(const struct camera2_frame_queue_dst_ops *q, |
Eino-Ville Talvala | 567b4a2 | 2012-04-23 09:29:38 -0700 | [diff] [blame] | 246 | camera_metadata_t *buffer); |
| 247 | |
| 248 | } camera2_frame_queue_dst_ops_t; |
| 249 | |
| 250 | /********************************************************************** |
| 251 | * |
| 252 | * Notification callback and message definition, and trigger definitions |
| 253 | * |
| 254 | */ |
Eino-Ville Talvala | 8bf364e | 2011-12-22 13:50:37 -0800 | [diff] [blame] | 255 | |
| 256 | /** |
| 257 | * Asynchronous notification callback from the HAL, fired for various |
| 258 | * reasons. Only for information independent of frame capture, or that require |
Eino-Ville Talvala | 567b4a2 | 2012-04-23 09:29:38 -0700 | [diff] [blame] | 259 | * specific timing. The user pointer must be the same one that was passed to the |
| 260 | * device in set_notify_callback(). |
Eino-Ville Talvala | 8bf364e | 2011-12-22 13:50:37 -0800 | [diff] [blame] | 261 | */ |
| 262 | typedef void (*camera2_notify_callback)(int32_t msg_type, |
| 263 | int32_t ext1, |
| 264 | int32_t ext2, |
Eino-Ville Talvala | 567b4a2 | 2012-04-23 09:29:38 -0700 | [diff] [blame] | 265 | int32_t ext3, |
Eino-Ville Talvala | 8bf364e | 2011-12-22 13:50:37 -0800 | [diff] [blame] | 266 | void *user); |
| 267 | |
| 268 | /** |
| 269 | * Possible message types for camera2_notify_callback |
| 270 | */ |
| 271 | enum { |
| 272 | /** |
Eino-Ville Talvala | 567b4a2 | 2012-04-23 09:29:38 -0700 | [diff] [blame] | 273 | * An error has occurred. Argument ext1 contains the error code, and |
| 274 | * ext2 and ext3 contain any error-specific information. |
Eino-Ville Talvala | 8bf364e | 2011-12-22 13:50:37 -0800 | [diff] [blame] | 275 | */ |
Eino-Ville Talvala | daacbf4 | 2012-03-22 13:09:56 -0700 | [diff] [blame] | 276 | CAMERA2_MSG_ERROR = 0x0001, |
Eino-Ville Talvala | 8bf364e | 2011-12-22 13:50:37 -0800 | [diff] [blame] | 277 | /** |
| 278 | * The exposure of a given request has begun. Argument ext1 contains the |
Eino-Ville Talvala | 567b4a2 | 2012-04-23 09:29:38 -0700 | [diff] [blame] | 279 | * frame number, and ext2 and ext3 contain the low-order and high-order |
| 280 | * bytes of the timestamp for when exposure began. |
| 281 | * (timestamp = (ext3 << 32 | ext2)) |
Eino-Ville Talvala | 8bf364e | 2011-12-22 13:50:37 -0800 | [diff] [blame] | 282 | */ |
Eino-Ville Talvala | 567b4a2 | 2012-04-23 09:29:38 -0700 | [diff] [blame] | 283 | CAMERA2_MSG_SHUTTER = 0x0010, |
| 284 | /** |
| 285 | * The autofocus routine has changed state. Argument ext1 contains the new |
| 286 | * state; the values are the same as those for the metadata field |
Eino-Ville Talvala | f7a60c4 | 2012-08-03 10:56:57 -0700 | [diff] [blame] | 287 | * android.control.afState. Ext2 contains the latest trigger ID passed to |
| 288 | * trigger_action(CAMERA2_TRIGGER_AUTOFOCUS) or |
| 289 | * trigger_action(CAMERA2_TRIGGER_CANCEL_AUTOFOCUS), or 0 if trigger has not |
| 290 | * been called with either of those actions. |
Eino-Ville Talvala | 567b4a2 | 2012-04-23 09:29:38 -0700 | [diff] [blame] | 291 | */ |
| 292 | CAMERA2_MSG_AUTOFOCUS = 0x0020, |
| 293 | /** |
| 294 | * The autoexposure routine has changed state. Argument ext1 contains the |
| 295 | * new state; the values are the same as those for the metadata field |
Eino-Ville Talvala | f7a60c4 | 2012-08-03 10:56:57 -0700 | [diff] [blame] | 296 | * android.control.aeState. Ext2 contains the latest trigger ID value passed to |
Eino-Ville Talvala | 567b4a2 | 2012-04-23 09:29:38 -0700 | [diff] [blame] | 297 | * trigger_action(CAMERA2_TRIGGER_PRECAPTURE_METERING), or 0 if that method |
| 298 | * has not been called. |
| 299 | */ |
| 300 | CAMERA2_MSG_AUTOEXPOSURE = 0x0021, |
| 301 | /** |
| 302 | * The auto-whitebalance routine has changed state. Argument ext1 contains |
| 303 | * the new state; the values are the same as those for the metadata field |
Eino-Ville Talvala | f7a60c4 | 2012-08-03 10:56:57 -0700 | [diff] [blame] | 304 | * android.control.awbState. Ext2 contains the latest trigger ID passed to |
| 305 | * trigger_action(CAMERA2_TRIGGER_PRECAPTURE_METERING), or 0 if that method |
| 306 | * has not been called. |
Eino-Ville Talvala | 567b4a2 | 2012-04-23 09:29:38 -0700 | [diff] [blame] | 307 | */ |
| 308 | CAMERA2_MSG_AUTOWB = 0x0022 |
Eino-Ville Talvala | 8bf364e | 2011-12-22 13:50:37 -0800 | [diff] [blame] | 309 | }; |
| 310 | |
| 311 | /** |
| 312 | * Error codes for CAMERA_MSG_ERROR |
| 313 | */ |
| 314 | enum { |
| 315 | /** |
| 316 | * A serious failure occured. Camera device may not work without reboot, and |
| 317 | * no further frames or buffer streams will be produced by the |
| 318 | * device. Device should be treated as closed. |
| 319 | */ |
Eino-Ville Talvala | 567b4a2 | 2012-04-23 09:29:38 -0700 | [diff] [blame] | 320 | CAMERA2_MSG_ERROR_HARDWARE = 0x0001, |
Eino-Ville Talvala | 8bf364e | 2011-12-22 13:50:37 -0800 | [diff] [blame] | 321 | /** |
| 322 | * A serious failure occured. No further frames or buffer streams will be |
| 323 | * produced by the device. Device should be treated as closed. The client |
| 324 | * must reopen the device to use it again. |
| 325 | */ |
Eino-Ville Talvala | 567b4a2 | 2012-04-23 09:29:38 -0700 | [diff] [blame] | 326 | CAMERA2_MSG_ERROR_DEVICE, |
Eino-Ville Talvala | 8bf364e | 2011-12-22 13:50:37 -0800 | [diff] [blame] | 327 | /** |
Eino-Ville Talvala | 567b4a2 | 2012-04-23 09:29:38 -0700 | [diff] [blame] | 328 | * An error has occurred in processing a request. No output (metadata or |
| 329 | * buffers) will be produced for this request. ext2 contains the frame |
| 330 | * number of the request. Subsequent requests are unaffected, and the device |
| 331 | * remains operational. |
Eino-Ville Talvala | 8bf364e | 2011-12-22 13:50:37 -0800 | [diff] [blame] | 332 | */ |
Eino-Ville Talvala | 567b4a2 | 2012-04-23 09:29:38 -0700 | [diff] [blame] | 333 | CAMERA2_MSG_ERROR_REQUEST, |
| 334 | /** |
| 335 | * An error has occurred in producing an output frame metadata buffer for a |
| 336 | * request, but image buffers for it will still be available. Subsequent |
| 337 | * requests are unaffected, and the device remains operational. ext2 |
| 338 | * contains the frame number of the request. |
| 339 | */ |
| 340 | CAMERA2_MSG_ERROR_FRAME, |
| 341 | /** |
| 342 | * An error has occurred in placing an output buffer into a stream for a |
| 343 | * request. The frame metadata and other buffers may still be |
| 344 | * available. Subsequent requests are unaffected, and the device remains |
| 345 | * operational. ext2 contains the frame number of the request, and ext3 |
| 346 | * contains the stream id. |
| 347 | */ |
| 348 | CAMERA2_MSG_ERROR_STREAM, |
| 349 | /** |
| 350 | * Number of error types |
| 351 | */ |
| 352 | CAMERA2_MSG_NUM_ERRORS |
Eino-Ville Talvala | 8bf364e | 2011-12-22 13:50:37 -0800 | [diff] [blame] | 353 | }; |
| 354 | |
Eino-Ville Talvala | 567b4a2 | 2012-04-23 09:29:38 -0700 | [diff] [blame] | 355 | /** |
| 356 | * Possible trigger ids for trigger_action() |
| 357 | */ |
| 358 | enum { |
Eino-Ville Talvala | 8bf364e | 2011-12-22 13:50:37 -0800 | [diff] [blame] | 359 | /** |
Eino-Ville Talvala | 567b4a2 | 2012-04-23 09:29:38 -0700 | [diff] [blame] | 360 | * Trigger an autofocus cycle. The effect of the trigger depends on the |
| 361 | * autofocus mode in effect when the trigger is received, which is the mode |
Eino-Ville Talvala | f7a60c4 | 2012-08-03 10:56:57 -0700 | [diff] [blame] | 362 | * listed in the latest capture request to be dequeued by the HAL. If the |
| 363 | * mode is OFF, EDOF, or FIXED, the trigger has no effect. In AUTO, MACRO, |
| 364 | * or CONTINUOUS_* modes, see below for the expected behavior. The state of |
Eino-Ville Talvala | 567b4a2 | 2012-04-23 09:29:38 -0700 | [diff] [blame] | 365 | * the autofocus cycle can be tracked in android.control.afMode and the |
Eino-Ville Talvala | f7a60c4 | 2012-08-03 10:56:57 -0700 | [diff] [blame] | 366 | * corresponding notifications. |
| 367 | * |
| 368 | ** |
| 369 | * In AUTO or MACRO mode, the AF state transitions (and notifications) |
| 370 | * when calling with trigger ID = N with the previous ID being K are: |
| 371 | * |
| 372 | * Initial state Transitions |
| 373 | * INACTIVE (K) -> ACTIVE_SCAN (N) -> AF_FOCUSED (N) or AF_NOT_FOCUSED (N) |
| 374 | * AF_FOCUSED (K) -> ACTIVE_SCAN (N) -> AF_FOCUSED (N) or AF_NOT_FOCUSED (N) |
| 375 | * AF_NOT_FOCUSED (K) -> ACTIVE_SCAN (N) -> AF_FOCUSED (N) or AF_NOT_FOCUSED (N) |
| 376 | * ACTIVE_SCAN (K) -> AF_FOCUSED(N) or AF_NOT_FOCUSED(N) |
| 377 | * PASSIVE_SCAN (K) Not used in AUTO/MACRO mode |
| 378 | * PASSIVE_FOCUSED (K) Not used in AUTO/MACRO mode |
| 379 | * |
| 380 | ** |
| 381 | * In CONTINUOUS_PICTURE mode, triggering AF must lock the AF to the current |
| 382 | * lens position and transition the AF state to either AF_FOCUSED or |
| 383 | * NOT_FOCUSED. If a passive scan is underway, that scan must complete and |
| 384 | * then lock the lens position and change AF state. TRIGGER_CANCEL_AUTOFOCUS |
| 385 | * will allow the AF to restart its operation. |
| 386 | * |
| 387 | * Initial state Transitions |
| 388 | * INACTIVE (K) -> immediate AF_FOCUSED (N) or AF_NOT_FOCUSED (N) |
| 389 | * PASSIVE_FOCUSED (K) -> immediate AF_FOCUSED (N) or AF_NOT_FOCUSED (N) |
| 390 | * PASSIVE_SCAN (K) -> AF_FOCUSED (N) or AF_NOT_FOCUSED (N) |
| 391 | * AF_FOCUSED (K) no effect except to change next notification ID to N |
| 392 | * AF_NOT_FOCUSED (K) no effect except to change next notification ID to N |
| 393 | * |
| 394 | ** |
| 395 | * In CONTINUOUS_VIDEO mode, triggering AF must lock the AF to the current |
| 396 | * lens position and transition the AF state to either AF_FOCUSED or |
| 397 | * NOT_FOCUSED. If a passive scan is underway, it must immediately halt, in |
| 398 | * contrast with CONTINUOUS_PICTURE mode. TRIGGER_CANCEL_AUTOFOCUS will |
| 399 | * allow the AF to restart its operation. |
| 400 | * |
| 401 | * Initial state Transitions |
| 402 | * INACTIVE (K) -> immediate AF_FOCUSED (N) or AF_NOT_FOCUSED (N) |
| 403 | * PASSIVE_FOCUSED (K) -> immediate AF_FOCUSED (N) or AF_NOT_FOCUSED (N) |
| 404 | * PASSIVE_SCAN (K) -> immediate AF_FOCUSED (N) or AF_NOT_FOCUSED (N) |
| 405 | * AF_FOCUSED (K) no effect except to change next notification ID to N |
| 406 | * AF_NOT_FOCUSED (K) no effect except to change next notification ID to N |
| 407 | * |
| 408 | * Ext1 is an ID that must be returned in subsequent auto-focus state change |
| 409 | * notifications through camera2_notify_callback() and stored in |
| 410 | * android.control.afTriggerId. |
Eino-Ville Talvala | 567b4a2 | 2012-04-23 09:29:38 -0700 | [diff] [blame] | 411 | */ |
| 412 | CAMERA2_TRIGGER_AUTOFOCUS = 0x0001, |
| 413 | /** |
Eino-Ville Talvala | f7a60c4 | 2012-08-03 10:56:57 -0700 | [diff] [blame] | 414 | * Send a cancel message to the autofocus algorithm. The effect of the |
| 415 | * cancellation depends on the autofocus mode in effect when the trigger is |
| 416 | * received, which is the mode listed in the latest capture request to be |
| 417 | * dequeued by the HAL. If the AF mode is OFF or EDOF, the cancel has no |
| 418 | * effect. For other modes, the lens should return to its default position, |
| 419 | * any current autofocus scan must be canceled, and the AF state should be |
| 420 | * set to INACTIVE. |
| 421 | * |
| 422 | * The state of the autofocus cycle can be tracked in android.control.afMode |
| 423 | * and the corresponding notification. Continuous autofocus modes may resume |
| 424 | * focusing operations thereafter exactly as if the camera had just been set |
| 425 | * to a continuous AF mode. |
| 426 | * |
| 427 | * Ext1 is an ID that must be returned in subsequent auto-focus state change |
| 428 | * notifications through camera2_notify_callback() and stored in |
| 429 | * android.control.afTriggerId. |
| 430 | */ |
| 431 | CAMERA2_TRIGGER_CANCEL_AUTOFOCUS, |
| 432 | /** |
Eino-Ville Talvala | 567b4a2 | 2012-04-23 09:29:38 -0700 | [diff] [blame] | 433 | * Trigger a pre-capture metering cycle, which may include firing the flash |
| 434 | * to determine proper capture parameters. Typically, this trigger would be |
| 435 | * fired for a half-depress of a camera shutter key, or before a snapshot |
| 436 | * capture in general. The state of the metering cycle can be tracked in |
| 437 | * android.control.aeMode and the corresponding notification. If the |
Eino-Ville Talvala | f7a60c4 | 2012-08-03 10:56:57 -0700 | [diff] [blame] | 438 | * auto-exposure mode is OFF, the trigger does nothing. |
| 439 | * |
| 440 | * Ext1 is an ID that must be returned in subsequent |
| 441 | * auto-exposure/auto-white balance state change notifications through |
| 442 | * camera2_notify_callback() and stored in android.control.aePrecaptureId. |
Eino-Ville Talvala | 567b4a2 | 2012-04-23 09:29:38 -0700 | [diff] [blame] | 443 | */ |
| 444 | CAMERA2_TRIGGER_PRECAPTURE_METERING |
| 445 | }; |
| 446 | |
| 447 | /** |
| 448 | * Possible template types for construct_default_request() |
| 449 | */ |
| 450 | enum { |
| 451 | /** |
| 452 | * Standard camera preview operation with 3A on auto. |
| 453 | */ |
| 454 | CAMERA2_TEMPLATE_PREVIEW = 1, |
| 455 | /** |
| 456 | * Standard camera high-quality still capture with 3A and flash on auto. |
| 457 | */ |
| 458 | CAMERA2_TEMPLATE_STILL_CAPTURE, |
| 459 | /** |
| 460 | * Standard video recording plus preview with 3A on auto, torch off. |
| 461 | */ |
| 462 | CAMERA2_TEMPLATE_VIDEO_RECORD, |
| 463 | /** |
| 464 | * High-quality still capture while recording video. Application will |
| 465 | * include preview, video record, and full-resolution YUV or JPEG streams in |
| 466 | * request. Must not cause stuttering on video stream. 3A on auto. |
| 467 | */ |
| 468 | CAMERA2_TEMPLATE_VIDEO_SNAPSHOT, |
| 469 | /** |
| 470 | * Zero-shutter-lag mode. Application will request preview and |
Eino-Ville Talvala | f7a60c4 | 2012-08-03 10:56:57 -0700 | [diff] [blame] | 471 | * full-resolution data for each frame, and reprocess it to JPEG when a |
Eino-Ville Talvala | 567b4a2 | 2012-04-23 09:29:38 -0700 | [diff] [blame] | 472 | * still image is requested by user. Settings should provide highest-quality |
| 473 | * full-resolution images without compromising preview frame rate. 3A on |
| 474 | * auto. |
| 475 | */ |
Eino-Ville Talvala | 6adfd6b | 2012-05-14 15:25:27 -0700 | [diff] [blame] | 476 | CAMERA2_TEMPLATE_ZERO_SHUTTER_LAG, |
| 477 | |
| 478 | /* Total number of templates */ |
| 479 | CAMERA2_TEMPLATE_COUNT |
Eino-Ville Talvala | 567b4a2 | 2012-04-23 09:29:38 -0700 | [diff] [blame] | 480 | }; |
| 481 | |
| 482 | |
| 483 | /********************************************************************** |
| 484 | * |
| 485 | * Camera device operations |
| 486 | * |
| 487 | */ |
| 488 | typedef struct camera2_device_ops { |
| 489 | |
| 490 | /********************************************************************** |
| 491 | * Request and frame queue setup and management methods |
| 492 | */ |
| 493 | |
| 494 | /** |
| 495 | * Pass in input request queue interface methods. |
Eino-Ville Talvala | 8bf364e | 2011-12-22 13:50:37 -0800 | [diff] [blame] | 496 | */ |
Eino-Ville Talvala | 08a6e5e | 2012-05-17 17:54:56 -0700 | [diff] [blame] | 497 | int (*set_request_queue_src_ops)(const struct camera2_device *, |
| 498 | const camera2_request_queue_src_ops_t *request_src_ops); |
Eino-Ville Talvala | 8bf364e | 2011-12-22 13:50:37 -0800 | [diff] [blame] | 499 | |
| 500 | /** |
Eino-Ville Talvala | 567b4a2 | 2012-04-23 09:29:38 -0700 | [diff] [blame] | 501 | * Notify device that the request queue is no longer empty. Must only be |
| 502 | * called when the first buffer is added a new queue, or after the source |
| 503 | * has returned NULL in response to a dequeue call. |
Eino-Ville Talvala | 8bf364e | 2011-12-22 13:50:37 -0800 | [diff] [blame] | 504 | */ |
Eino-Ville Talvala | 08a6e5e | 2012-05-17 17:54:56 -0700 | [diff] [blame] | 505 | int (*notify_request_queue_not_empty)(const struct camera2_device *); |
Eino-Ville Talvala | 8bf364e | 2011-12-22 13:50:37 -0800 | [diff] [blame] | 506 | |
| 507 | /** |
Eino-Ville Talvala | 567b4a2 | 2012-04-23 09:29:38 -0700 | [diff] [blame] | 508 | * Pass in output frame queue interface methods |
Eino-Ville Talvala | 8bf364e | 2011-12-22 13:50:37 -0800 | [diff] [blame] | 509 | */ |
Eino-Ville Talvala | 08a6e5e | 2012-05-17 17:54:56 -0700 | [diff] [blame] | 510 | int (*set_frame_queue_dst_ops)(const struct camera2_device *, |
| 511 | const camera2_frame_queue_dst_ops_t *frame_dst_ops); |
Eino-Ville Talvala | 8bf364e | 2011-12-22 13:50:37 -0800 | [diff] [blame] | 512 | |
| 513 | /** |
Eino-Ville Talvala | 567b4a2 | 2012-04-23 09:29:38 -0700 | [diff] [blame] | 514 | * Number of camera requests being processed by the device at the moment |
| 515 | * (captures/reprocesses that have had their request dequeued, but have not |
| 516 | * yet been enqueued onto output pipeline(s) ). No streams may be released |
| 517 | * by the framework until the in-progress count is 0. |
Eino-Ville Talvala | 8bf364e | 2011-12-22 13:50:37 -0800 | [diff] [blame] | 518 | */ |
Eino-Ville Talvala | 08a6e5e | 2012-05-17 17:54:56 -0700 | [diff] [blame] | 519 | int (*get_in_progress_count)(const struct camera2_device *); |
Eino-Ville Talvala | 8bf364e | 2011-12-22 13:50:37 -0800 | [diff] [blame] | 520 | |
| 521 | /** |
| 522 | * Flush all in-progress captures. This includes all dequeued requests |
| 523 | * (regular or reprocessing) that have not yet placed any outputs into a |
| 524 | * stream or the frame queue. Partially completed captures must be completed |
Eino-Ville Talvala | 567b4a2 | 2012-04-23 09:29:38 -0700 | [diff] [blame] | 525 | * normally. No new requests may be dequeued from the request queue until |
| 526 | * the flush completes. |
Eino-Ville Talvala | 8bf364e | 2011-12-22 13:50:37 -0800 | [diff] [blame] | 527 | */ |
Eino-Ville Talvala | 08a6e5e | 2012-05-17 17:54:56 -0700 | [diff] [blame] | 528 | int (*flush_captures_in_progress)(const struct camera2_device *); |
Eino-Ville Talvala | 8bf364e | 2011-12-22 13:50:37 -0800 | [diff] [blame] | 529 | |
| 530 | /** |
Eino-Ville Talvala | 567b4a2 | 2012-04-23 09:29:38 -0700 | [diff] [blame] | 531 | * Create a filled-in default request for standard camera use cases. |
| 532 | * |
| 533 | * The device must return a complete request that is configured to meet the |
| 534 | * requested use case, which must be one of the CAMERA2_TEMPLATE_* |
| 535 | * enums. All request control fields must be included, except for |
Eino-Ville Talvala | fa7a91d | 2012-05-22 10:41:20 -0700 | [diff] [blame] | 536 | * android.request.outputStreams. |
Eino-Ville Talvala | 567b4a2 | 2012-04-23 09:29:38 -0700 | [diff] [blame] | 537 | * |
| 538 | * The metadata buffer returned must be allocated with |
| 539 | * allocate_camera_metadata. The framework takes ownership of the buffer. |
| 540 | */ |
Eino-Ville Talvala | 08a6e5e | 2012-05-17 17:54:56 -0700 | [diff] [blame] | 541 | int (*construct_default_request)(const struct camera2_device *, |
Eino-Ville Talvala | 567b4a2 | 2012-04-23 09:29:38 -0700 | [diff] [blame] | 542 | int request_template, |
| 543 | camera_metadata_t **request); |
| 544 | |
| 545 | /********************************************************************** |
| 546 | * Stream management |
Eino-Ville Talvala | 8bf364e | 2011-12-22 13:50:37 -0800 | [diff] [blame] | 547 | */ |
| 548 | |
| 549 | /** |
Eino-Ville Talvala | 567b4a2 | 2012-04-23 09:29:38 -0700 | [diff] [blame] | 550 | * allocate_stream: |
| 551 | * |
| 552 | * Allocate a new output stream for use, defined by the output buffer width, |
| 553 | * height, target, and possibly the pixel format. Returns the new stream's |
| 554 | * ID, gralloc usage flags, minimum queue buffer count, and possibly the |
| 555 | * pixel format, on success. Error conditions: |
| 556 | * |
| 557 | * - Requesting a width/height/format combination not listed as |
| 558 | * supported by the sensor's static characteristics |
| 559 | * |
| 560 | * - Asking for too many streams of a given format type (2 bayer raw |
| 561 | * streams, for example). |
| 562 | * |
| 563 | * Input parameters: |
| 564 | * |
| 565 | * - width, height, format: Specification for the buffers to be sent through |
Eino-Ville Talvala | 2388a2d | 2012-08-28 14:01:26 -0700 | [diff] [blame] | 566 | * this stream. Format is a value from the HAL_PIXEL_FORMAT_* list. If |
| 567 | * HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED is used, then the platform |
| 568 | * gralloc module will select a format based on the usage flags provided |
| 569 | * by the camera HAL and the consumer of the stream. The camera HAL should |
| 570 | * inspect the buffers handed to it in the register_stream_buffers call to |
| 571 | * obtain the implementation-specific format if necessary. |
Eino-Ville Talvala | 567b4a2 | 2012-04-23 09:29:38 -0700 | [diff] [blame] | 572 | * |
| 573 | * - stream_ops: A structure of function pointers for obtaining and queuing |
| 574 | * up buffers for this stream. The underlying stream will be configured |
| 575 | * based on the usage and max_buffers outputs. The methods in this |
| 576 | * structure may not be called until after allocate_stream returns. |
| 577 | * |
| 578 | * Output parameters: |
| 579 | * |
| 580 | * - stream_id: An unsigned integer identifying this stream. This value is |
| 581 | * used in incoming requests to identify the stream, and in releasing the |
| 582 | * stream. |
| 583 | * |
Eino-Ville Talvala | 567b4a2 | 2012-04-23 09:29:38 -0700 | [diff] [blame] | 584 | * - usage: The gralloc usage mask needed by the HAL device for producing |
| 585 | * the requested type of data. This is used in allocating new gralloc |
| 586 | * buffers for the stream buffer queue. |
| 587 | * |
| 588 | * - max_buffers: The maximum number of buffers the HAL device may need to |
| 589 | * have dequeued at the same time. The device may not dequeue more buffers |
| 590 | * than this value at the same time. |
| 591 | * |
Eino-Ville Talvala | 8bf364e | 2011-12-22 13:50:37 -0800 | [diff] [blame] | 592 | */ |
| 593 | int (*allocate_stream)( |
Eino-Ville Talvala | 08a6e5e | 2012-05-17 17:54:56 -0700 | [diff] [blame] | 594 | const struct camera2_device *, |
Eino-Ville Talvala | 567b4a2 | 2012-04-23 09:29:38 -0700 | [diff] [blame] | 595 | // inputs |
| 596 | uint32_t width, |
| 597 | uint32_t height, |
| 598 | int format, |
Eino-Ville Talvala | 08a6e5e | 2012-05-17 17:54:56 -0700 | [diff] [blame] | 599 | const camera2_stream_ops_t *stream_ops, |
Eino-Ville Talvala | 567b4a2 | 2012-04-23 09:29:38 -0700 | [diff] [blame] | 600 | // outputs |
| 601 | uint32_t *stream_id, |
Eino-Ville Talvala | 2388a2d | 2012-08-28 14:01:26 -0700 | [diff] [blame] | 602 | uint32_t *format_actual, // IGNORED, will be removed |
Eino-Ville Talvala | 567b4a2 | 2012-04-23 09:29:38 -0700 | [diff] [blame] | 603 | uint32_t *usage, |
| 604 | uint32_t *max_buffers); |
Eino-Ville Talvala | 8bf364e | 2011-12-22 13:50:37 -0800 | [diff] [blame] | 605 | |
| 606 | /** |
Eino-Ville Talvala | 567b4a2 | 2012-04-23 09:29:38 -0700 | [diff] [blame] | 607 | * Register buffers for a given stream. This is called after a successful |
| 608 | * allocate_stream call, and before the first request referencing the stream |
| 609 | * is enqueued. This method is intended to allow the HAL device to map or |
| 610 | * otherwise prepare the buffers for later use. num_buffers is guaranteed to |
| 611 | * be at least max_buffers (from allocate_stream), but may be larger. The |
| 612 | * buffers will already be locked for use. At the end of the call, all the |
Eino-Ville Talvala | 2388a2d | 2012-08-28 14:01:26 -0700 | [diff] [blame] | 613 | * buffers must be ready to be returned to the queue. If the stream format |
| 614 | * was set to HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, the camera HAL should |
| 615 | * inspect the passed-in buffers here to determine any platform-private |
| 616 | * pixel format information. |
Eino-Ville Talvala | 567b4a2 | 2012-04-23 09:29:38 -0700 | [diff] [blame] | 617 | */ |
| 618 | int (*register_stream_buffers)( |
Eino-Ville Talvala | 08a6e5e | 2012-05-17 17:54:56 -0700 | [diff] [blame] | 619 | const struct camera2_device *, |
Eino-Ville Talvala | 567b4a2 | 2012-04-23 09:29:38 -0700 | [diff] [blame] | 620 | uint32_t stream_id, |
| 621 | int num_buffers, |
| 622 | buffer_handle_t *buffers); |
| 623 | |
| 624 | /** |
| 625 | * Release a stream. Returns an error if called when get_in_progress_count |
| 626 | * is non-zero, or if the stream id is invalid. |
Eino-Ville Talvala | 8bf364e | 2011-12-22 13:50:37 -0800 | [diff] [blame] | 627 | */ |
| 628 | int (*release_stream)( |
Eino-Ville Talvala | 08a6e5e | 2012-05-17 17:54:56 -0700 | [diff] [blame] | 629 | const struct camera2_device *, |
Eino-Ville Talvala | 567b4a2 | 2012-04-23 09:29:38 -0700 | [diff] [blame] | 630 | uint32_t stream_id); |
| 631 | |
| 632 | /** |
| 633 | * allocate_reprocess_stream: |
| 634 | * |
| 635 | * Allocate a new input stream for use, defined by the output buffer width, |
| 636 | * height, and the pixel format. Returns the new stream's ID, gralloc usage |
| 637 | * flags, and required simultaneously acquirable buffer count, on |
| 638 | * success. Error conditions: |
| 639 | * |
| 640 | * - Requesting a width/height/format combination not listed as |
| 641 | * supported by the sensor's static characteristics |
| 642 | * |
| 643 | * - Asking for too many reprocessing streams to be configured at once. |
| 644 | * |
| 645 | * Input parameters: |
| 646 | * |
| 647 | * - width, height, format: Specification for the buffers to be sent through |
| 648 | * this stream. Format must be a value from the HAL_PIXEL_FORMAT_* list. |
| 649 | * |
| 650 | * - reprocess_stream_ops: A structure of function pointers for acquiring |
| 651 | * and releasing buffers for this stream. The underlying stream will be |
| 652 | * configured based on the usage and max_buffers outputs. |
| 653 | * |
| 654 | * Output parameters: |
| 655 | * |
| 656 | * - stream_id: An unsigned integer identifying this stream. This value is |
| 657 | * used in incoming requests to identify the stream, and in releasing the |
| 658 | * stream. These ids are numbered separately from the input stream ids. |
| 659 | * |
| 660 | * - consumer_usage: The gralloc usage mask needed by the HAL device for |
| 661 | * consuming the requested type of data. This is used in allocating new |
| 662 | * gralloc buffers for the stream buffer queue. |
| 663 | * |
| 664 | * - max_buffers: The maximum number of buffers the HAL device may need to |
| 665 | * have acquired at the same time. The device may not have more buffers |
| 666 | * acquired at the same time than this value. |
| 667 | * |
| 668 | */ |
Eino-Ville Talvala | 08a6e5e | 2012-05-17 17:54:56 -0700 | [diff] [blame] | 669 | int (*allocate_reprocess_stream)(const struct camera2_device *, |
Eino-Ville Talvala | 567b4a2 | 2012-04-23 09:29:38 -0700 | [diff] [blame] | 670 | uint32_t width, |
| 671 | uint32_t height, |
| 672 | uint32_t format, |
Eino-Ville Talvala | 08a6e5e | 2012-05-17 17:54:56 -0700 | [diff] [blame] | 673 | const camera2_stream_in_ops_t *reprocess_stream_ops, |
Eino-Ville Talvala | 567b4a2 | 2012-04-23 09:29:38 -0700 | [diff] [blame] | 674 | // outputs |
| 675 | uint32_t *stream_id, |
| 676 | uint32_t *consumer_usage, |
| 677 | uint32_t *max_buffers); |
| 678 | |
| 679 | /** |
Eino-Ville Talvala | 7f8dd0a | 2012-09-04 14:21:07 -0700 | [diff] [blame] | 680 | * allocate_reprocess_stream_from_stream: |
| 681 | * |
| 682 | * Allocate a new input stream for use, which will use the buffers allocated |
| 683 | * for an existing output stream. That is, after the HAL enqueues a buffer |
| 684 | * onto the output stream, it may see that same buffer handed to it from |
| 685 | * this input reprocessing stream. After the HAL releases the buffer back to |
| 686 | * the reprocessing stream, it will be returned to the output queue for |
| 687 | * reuse. |
| 688 | * |
| 689 | * Error conditions: |
| 690 | * |
| 691 | * - Using an output stream of unsuitable size/format for the basis of the |
| 692 | * reprocessing stream. |
| 693 | * |
| 694 | * - Attempting to allocatee too many reprocessing streams at once. |
| 695 | * |
| 696 | * Input parameters: |
| 697 | * |
| 698 | * - output_stream_id: The ID of an existing output stream which has |
| 699 | * a size and format suitable for reprocessing. |
| 700 | * |
| 701 | * - reprocess_stream_ops: A structure of function pointers for acquiring |
| 702 | * and releasing buffers for this stream. The underlying stream will use |
| 703 | * the same graphics buffer handles as the output stream uses. |
| 704 | * |
| 705 | * Output parameters: |
| 706 | * |
| 707 | * - stream_id: An unsigned integer identifying this stream. This value is |
| 708 | * used in incoming requests to identify the stream, and in releasing the |
| 709 | * stream. These ids are numbered separately from the input stream ids. |
| 710 | * |
| 711 | * The HAL client must always release the reprocessing stream before it |
| 712 | * releases the output stream it is based on. |
| 713 | * |
| 714 | */ |
| 715 | int (*allocate_reprocess_stream_from_stream)(const struct camera2_device *, |
| 716 | uint32_t output_stream_id, |
| 717 | const camera2_stream_in_ops_t *reprocess_stream_ops, |
| 718 | // outputs |
| 719 | uint32_t *stream_id); |
| 720 | |
| 721 | /** |
Eino-Ville Talvala | 567b4a2 | 2012-04-23 09:29:38 -0700 | [diff] [blame] | 722 | * Release a reprocessing stream. Returns an error if called when |
| 723 | * get_in_progress_count is non-zero, or if the stream id is not |
| 724 | * valid. |
| 725 | */ |
| 726 | int (*release_reprocess_stream)( |
Eino-Ville Talvala | 08a6e5e | 2012-05-17 17:54:56 -0700 | [diff] [blame] | 727 | const struct camera2_device *, |
Eino-Ville Talvala | 567b4a2 | 2012-04-23 09:29:38 -0700 | [diff] [blame] | 728 | uint32_t stream_id); |
| 729 | |
| 730 | /********************************************************************** |
| 731 | * Miscellaneous methods |
| 732 | */ |
| 733 | |
| 734 | /** |
| 735 | * Trigger asynchronous activity. This is used for triggering special |
| 736 | * behaviors of the camera 3A routines when they are in use. See the |
| 737 | * documentation for CAMERA2_TRIGGER_* above for details of the trigger ids |
| 738 | * and their arguments. |
| 739 | */ |
Eino-Ville Talvala | 08a6e5e | 2012-05-17 17:54:56 -0700 | [diff] [blame] | 740 | int (*trigger_action)(const struct camera2_device *, |
Eino-Ville Talvala | 567b4a2 | 2012-04-23 09:29:38 -0700 | [diff] [blame] | 741 | uint32_t trigger_id, |
Eino-Ville Talvala | f7a60c4 | 2012-08-03 10:56:57 -0700 | [diff] [blame] | 742 | int32_t ext1, |
| 743 | int32_t ext2); |
Eino-Ville Talvala | 567b4a2 | 2012-04-23 09:29:38 -0700 | [diff] [blame] | 744 | |
| 745 | /** |
| 746 | * Notification callback setup |
| 747 | */ |
Eino-Ville Talvala | 08a6e5e | 2012-05-17 17:54:56 -0700 | [diff] [blame] | 748 | int (*set_notify_callback)(const struct camera2_device *, |
Eino-Ville Talvala | 567b4a2 | 2012-04-23 09:29:38 -0700 | [diff] [blame] | 749 | camera2_notify_callback notify_cb, |
| 750 | void *user); |
Eino-Ville Talvala | 8bf364e | 2011-12-22 13:50:37 -0800 | [diff] [blame] | 751 | |
| 752 | /** |
Eino-Ville Talvala | fed0c02 | 2012-03-22 13:11:05 -0700 | [diff] [blame] | 753 | * Get methods to query for vendor extension metadata tag infomation. May |
| 754 | * set ops to NULL if no vendor extension tags are defined. |
| 755 | */ |
Eino-Ville Talvala | 08a6e5e | 2012-05-17 17:54:56 -0700 | [diff] [blame] | 756 | int (*get_metadata_vendor_tag_ops)(const struct camera2_device*, |
Eino-Ville Talvala | fed0c02 | 2012-03-22 13:11:05 -0700 | [diff] [blame] | 757 | vendor_tag_query_ops_t **ops); |
| 758 | |
| 759 | /** |
Eino-Ville Talvala | 8bf364e | 2011-12-22 13:50:37 -0800 | [diff] [blame] | 760 | * Dump state of the camera hardware |
| 761 | */ |
Eino-Ville Talvala | 08a6e5e | 2012-05-17 17:54:56 -0700 | [diff] [blame] | 762 | int (*dump)(const struct camera2_device *, int fd); |
Eino-Ville Talvala | 8bf364e | 2011-12-22 13:50:37 -0800 | [diff] [blame] | 763 | |
| 764 | } camera2_device_ops_t; |
| 765 | |
Eino-Ville Talvala | 567b4a2 | 2012-04-23 09:29:38 -0700 | [diff] [blame] | 766 | /********************************************************************** |
| 767 | * |
| 768 | * Camera device definition |
| 769 | * |
| 770 | */ |
Eino-Ville Talvala | 8bf364e | 2011-12-22 13:50:37 -0800 | [diff] [blame] | 771 | typedef struct camera2_device { |
| 772 | /** |
Eino-Ville Talvala | ddc026e | 2012-03-27 16:15:25 -0700 | [diff] [blame] | 773 | * common.version must equal CAMERA_DEVICE_API_VERSION_2_0 to identify |
Eino-Ville Talvala | 8bf364e | 2011-12-22 13:50:37 -0800 | [diff] [blame] | 774 | * this device as implementing version 2.0 of the camera device HAL. |
| 775 | */ |
| 776 | hw_device_t common; |
| 777 | camera2_device_ops_t *ops; |
| 778 | void *priv; |
| 779 | } camera2_device_t; |
| 780 | |
| 781 | __END_DECLS |
| 782 | |
| 783 | #endif /* #ifdef ANDROID_INCLUDE_CAMERA2_H */ |