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