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