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 | // FIXME: add well-defined names for cameras |
| 18 | |
| 19 | #ifndef ANDROID_INCLUDE_CAMERA_COMMON_H |
| 20 | #define ANDROID_INCLUDE_CAMERA_COMMON_H |
| 21 | |
| 22 | #include <stdint.h> |
Chien-Yu Chen | 3015917 | 2015-01-08 11:06:38 -0800 | [diff] [blame] | 23 | #include <stdbool.h> |
Eino-Ville Talvala | 8bf364e | 2011-12-22 13:50:37 -0800 | [diff] [blame] | 24 | #include <sys/cdefs.h> |
| 25 | #include <sys/types.h> |
| 26 | #include <cutils/native_handle.h> |
| 27 | #include <system/camera.h> |
Ruben Brunk | 61cf9eb | 2014-01-14 15:27:58 -0800 | [diff] [blame] | 28 | #include <system/camera_vendor_tags.h> |
Eino-Ville Talvala | 8bf364e | 2011-12-22 13:50:37 -0800 | [diff] [blame] | 29 | #include <hardware/hardware.h> |
| 30 | #include <hardware/gralloc.h> |
| 31 | |
| 32 | __BEGIN_DECLS |
| 33 | |
| 34 | /** |
| 35 | * The id of this module |
| 36 | */ |
| 37 | #define CAMERA_HARDWARE_MODULE_ID "camera" |
| 38 | |
| 39 | /** |
| 40 | * Module versioning information for the Camera hardware module, based on |
| 41 | * camera_module_t.common.module_api_version. The two most significant hex |
| 42 | * digits represent the major version, and the two least significant represent |
| 43 | * the minor version. |
| 44 | * |
| 45 | ******************************************************************************* |
Eino-Ville Talvala | ddc026e | 2012-03-27 16:15:25 -0700 | [diff] [blame] | 46 | * Versions: 0.X - 1.X [CAMERA_MODULE_API_VERSION_1_0] |
Eino-Ville Talvala | 8bf364e | 2011-12-22 13:50:37 -0800 | [diff] [blame] | 47 | * |
| 48 | * Camera modules that report these version numbers implement the initial |
| 49 | * camera module HAL interface. All camera devices openable through this |
| 50 | * module support only version 1 of the camera device HAL. The device_version |
| 51 | * and static_camera_characteristics fields of camera_info are not valid. Only |
| 52 | * the android.hardware.Camera API can be supported by this module and its |
| 53 | * devices. |
| 54 | * |
| 55 | ******************************************************************************* |
Eino-Ville Talvala | ddc026e | 2012-03-27 16:15:25 -0700 | [diff] [blame] | 56 | * Version: 2.0 [CAMERA_MODULE_API_VERSION_2_0] |
Eino-Ville Talvala | 8bf364e | 2011-12-22 13:50:37 -0800 | [diff] [blame] | 57 | * |
| 58 | * Camera modules that report this version number implement the second version |
| 59 | * of the camera module HAL interface. Camera devices openable through this |
| 60 | * module may support either version 1.0 or version 2.0 of the camera device |
| 61 | * HAL interface. The device_version field of camera_info is always valid; the |
| 62 | * static_camera_characteristics field of camera_info is valid if the |
| 63 | * device_version field is 2.0 or higher. |
Eino-Ville Talvala | d76f8af | 2013-02-13 15:29:48 -0800 | [diff] [blame] | 64 | * |
| 65 | ******************************************************************************* |
| 66 | * Version: 2.1 [CAMERA_MODULE_API_VERSION_2_1] |
| 67 | * |
| 68 | * This camera module version adds support for asynchronous callbacks to the |
| 69 | * framework from the camera HAL module, which is used to notify the framework |
| 70 | * about changes to the camera module state. Modules that provide a valid |
| 71 | * set_callbacks() method must report at least this version number. |
Alex Ray | 19b2cea | 2013-06-13 12:40:52 -0700 | [diff] [blame] | 72 | * |
| 73 | ******************************************************************************* |
| 74 | * Version: 2.2 [CAMERA_MODULE_API_VERSION_2_2] |
| 75 | * |
| 76 | * This camera module version adds vendor tag support from the module, and |
| 77 | * deprecates the old vendor_tag_query_ops that were previously only |
| 78 | * accessible with a device open. |
Zhijun He | bcdebf3 | 2014-06-06 15:42:17 -0700 | [diff] [blame] | 79 | * |
| 80 | ******************************************************************************* |
| 81 | * Version: 2.3 [CAMERA_MODULE_API_VERSION_2_3] |
| 82 | * |
| 83 | * This camera module version adds open legacy camera HAL device support. |
| 84 | * Framework can use it to open the camera device as lower device HAL version |
| 85 | * HAL device if the same device can support multiple device API versions. |
| 86 | * The standard hardware module open call (common.methods->open) continues |
| 87 | * to open the camera device with the latest supported version, which is |
| 88 | * also the version listed in camera_info_t.device_version. |
Chien-Yu Chen | 3015917 | 2015-01-08 11:06:38 -0800 | [diff] [blame] | 89 | * |
| 90 | ******************************************************************************* |
| 91 | * Version: 2.4 [CAMERA_MODULE_API_VERSION_2_4] |
| 92 | * |
Zhijun He | 94e23b2 | 2015-01-12 14:45:33 -0800 | [diff] [blame] | 93 | * This camera module version adds below API changes: |
| 94 | * |
| 95 | * 1. Torch mode support. The framework can use it to turn on torch mode for |
| 96 | * any camera device that has a flash unit, without opening a camera device. The |
| 97 | * camera device has a higher priority accessing the flash unit than the camera |
| 98 | * module; opening a camera device will turn off the torch if it had been enabled |
| 99 | * through the module interface. When there are any resource conflicts, such as |
| 100 | * open() is called to open a camera device, the camera HAL module must notify the |
| 101 | * framework through the torch mode status callback that the torch mode has been |
| 102 | * turned off. |
| 103 | * |
| 104 | * 2. External camera (e.g. USB hot-plug camera) support. The API updates specify that |
| 105 | * the camera static info is only available when camera is connected and ready to |
| 106 | * use for external hot-plug cameras. Calls to get static info will be invalid |
| 107 | * calls when camera status is not CAMERA_DEVICE_STATUS_PRESENT. The frameworks |
| 108 | * will only count on device status change callbacks to manage the available external |
| 109 | * camera list. |
Ruben Brunk | 0388bcd | 2015-01-16 14:29:21 -0800 | [diff] [blame] | 110 | * |
| 111 | * 3. Camera arbitration hints. This module version adds support for explicitly |
| 112 | * indicating the number of camera devices that can be simultaneously opened and used. |
| 113 | * To specify valid combinations of devices, the resource_cost and conflicting_devices |
| 114 | * fields should always be set in the camera_info structure returned by the |
| 115 | * get_camera_info call. |
Eino-Ville Talvala | 8bf364e | 2011-12-22 13:50:37 -0800 | [diff] [blame] | 116 | */ |
| 117 | |
Eino-Ville Talvala | ddc026e | 2012-03-27 16:15:25 -0700 | [diff] [blame] | 118 | /** |
| 119 | * Predefined macros for currently-defined version numbers |
| 120 | */ |
Eino-Ville Talvala | 8bf364e | 2011-12-22 13:50:37 -0800 | [diff] [blame] | 121 | |
Eino-Ville Talvala | ddc026e | 2012-03-27 16:15:25 -0700 | [diff] [blame] | 122 | /** |
| 123 | * All module versions <= HARDWARE_MODULE_API_VERSION(1, 0xFF) must be treated |
| 124 | * as CAMERA_MODULE_API_VERSION_1_0 |
| 125 | */ |
| 126 | #define CAMERA_MODULE_API_VERSION_1_0 HARDWARE_MODULE_API_VERSION(1, 0) |
| 127 | #define CAMERA_MODULE_API_VERSION_2_0 HARDWARE_MODULE_API_VERSION(2, 0) |
Eino-Ville Talvala | d76f8af | 2013-02-13 15:29:48 -0800 | [diff] [blame] | 128 | #define CAMERA_MODULE_API_VERSION_2_1 HARDWARE_MODULE_API_VERSION(2, 1) |
Alex Ray | 19b2cea | 2013-06-13 12:40:52 -0700 | [diff] [blame] | 129 | #define CAMERA_MODULE_API_VERSION_2_2 HARDWARE_MODULE_API_VERSION(2, 2) |
Zhijun He | bcdebf3 | 2014-06-06 15:42:17 -0700 | [diff] [blame] | 130 | #define CAMERA_MODULE_API_VERSION_2_3 HARDWARE_MODULE_API_VERSION(2, 3) |
Chien-Yu Chen | 3015917 | 2015-01-08 11:06:38 -0800 | [diff] [blame] | 131 | #define CAMERA_MODULE_API_VERSION_2_4 HARDWARE_MODULE_API_VERSION(2, 4) |
Eino-Ville Talvala | ddc026e | 2012-03-27 16:15:25 -0700 | [diff] [blame] | 132 | |
Chien-Yu Chen | 3015917 | 2015-01-08 11:06:38 -0800 | [diff] [blame] | 133 | #define CAMERA_MODULE_API_VERSION_CURRENT CAMERA_MODULE_API_VERSION_2_4 |
Eino-Ville Talvala | ddc026e | 2012-03-27 16:15:25 -0700 | [diff] [blame] | 134 | |
| 135 | /** |
| 136 | * All device versions <= HARDWARE_DEVICE_API_VERSION(1, 0xFF) must be treated |
| 137 | * as CAMERA_DEVICE_API_VERSION_1_0 |
| 138 | */ |
| 139 | #define CAMERA_DEVICE_API_VERSION_1_0 HARDWARE_DEVICE_API_VERSION(1, 0) |
| 140 | #define CAMERA_DEVICE_API_VERSION_2_0 HARDWARE_DEVICE_API_VERSION(2, 0) |
Eino-Ville Talvala | d76f8af | 2013-02-13 15:29:48 -0800 | [diff] [blame] | 141 | #define CAMERA_DEVICE_API_VERSION_2_1 HARDWARE_DEVICE_API_VERSION(2, 1) |
Eino-Ville Talvala | d2a8775 | 2012-11-27 18:06:06 -0800 | [diff] [blame] | 142 | #define CAMERA_DEVICE_API_VERSION_3_0 HARDWARE_DEVICE_API_VERSION(3, 0) |
Eino-Ville Talvala | 9d51856 | 2013-07-30 14:58:31 -0700 | [diff] [blame] | 143 | #define CAMERA_DEVICE_API_VERSION_3_1 HARDWARE_DEVICE_API_VERSION(3, 1) |
Ruben Brunk | 61cf9eb | 2014-01-14 15:27:58 -0800 | [diff] [blame] | 144 | #define CAMERA_DEVICE_API_VERSION_3_2 HARDWARE_DEVICE_API_VERSION(3, 2) |
Zhijun He | ebdf128 | 2015-01-16 16:44:40 -0800 | [diff] [blame] | 145 | #define CAMERA_DEVICE_API_VERSION_3_3 HARDWARE_DEVICE_API_VERSION(3, 3) |
Eino-Ville Talvala | ddc026e | 2012-03-27 16:15:25 -0700 | [diff] [blame] | 146 | |
Zhijun He | ebdf128 | 2015-01-16 16:44:40 -0800 | [diff] [blame] | 147 | // Device version 3.3 is current, older HAL camera device versions are not |
Eino-Ville Talvala | b545983 | 2014-09-09 16:42:27 -0700 | [diff] [blame] | 148 | // recommended for new devices. |
Zhijun He | ebdf128 | 2015-01-16 16:44:40 -0800 | [diff] [blame] | 149 | #define CAMERA_DEVICE_API_VERSION_CURRENT CAMERA_DEVICE_API_VERSION_3_3 |
Eino-Ville Talvala | 8bf364e | 2011-12-22 13:50:37 -0800 | [diff] [blame] | 150 | |
| 151 | /** |
James Dong | d0ca70d | 2012-03-26 16:22:35 -0700 | [diff] [blame] | 152 | * Defined in /system/media/camera/include/system/camera_metadata.h |
Eino-Ville Talvala | 8bf364e | 2011-12-22 13:50:37 -0800 | [diff] [blame] | 153 | */ |
| 154 | typedef struct camera_metadata camera_metadata_t; |
| 155 | |
Alex Ray | 9acc740 | 2013-02-07 15:44:24 -0800 | [diff] [blame] | 156 | typedef struct camera_info { |
Eino-Ville Talvala | 8bf364e | 2011-12-22 13:50:37 -0800 | [diff] [blame] | 157 | /** |
Zhijun He | 94e23b2 | 2015-01-12 14:45:33 -0800 | [diff] [blame] | 158 | * The direction that the camera faces to. See system/core/include/system/camera.h |
| 159 | * for camera facing definitions. |
Eino-Ville Talvala | 8bf364e | 2011-12-22 13:50:37 -0800 | [diff] [blame] | 160 | * |
Zhijun He | 94e23b2 | 2015-01-12 14:45:33 -0800 | [diff] [blame] | 161 | * Version information (based on camera_module_t.common.module_api_version): |
| 162 | * |
| 163 | * CAMERA_MODULE_API_VERSION_2_3 or lower: |
| 164 | * |
| 165 | * It should be CAMERA_FACING_BACK or CAMERA_FACING_FRONT. |
| 166 | * |
| 167 | * CAMERA_MODULE_API_VERSION_2_4 or higher: |
| 168 | * |
| 169 | * It should be CAMERA_FACING_BACK, CAMERA_FACING_FRONT or |
| 170 | * CAMERA_FACING_EXTERNAL. |
Eino-Ville Talvala | 8bf364e | 2011-12-22 13:50:37 -0800 | [diff] [blame] | 171 | */ |
| 172 | int facing; |
| 173 | |
| 174 | /** |
| 175 | * The orientation of the camera image. The value is the angle that the |
| 176 | * camera image needs to be rotated clockwise so it shows correctly on the |
| 177 | * display in its natural orientation. It should be 0, 90, 180, or 270. |
| 178 | * |
| 179 | * For example, suppose a device has a naturally tall screen. The |
Eino-Ville Talvala | d76f8af | 2013-02-13 15:29:48 -0800 | [diff] [blame] | 180 | * back-facing camera sensor is mounted in landscape. You are looking at the |
| 181 | * screen. If the top side of the camera sensor is aligned with the right |
| 182 | * edge of the screen in natural orientation, the value should be 90. If the |
| 183 | * top side of a front-facing camera sensor is aligned with the right of the |
| 184 | * screen, the value should be 270. |
Eino-Ville Talvala | 8bf364e | 2011-12-22 13:50:37 -0800 | [diff] [blame] | 185 | * |
Zhijun He | 94e23b2 | 2015-01-12 14:45:33 -0800 | [diff] [blame] | 186 | * Version information (based on camera_module_t.common.module_api_version): |
| 187 | * |
| 188 | * CAMERA_MODULE_API_VERSION_2_3 or lower: |
| 189 | * |
| 190 | * Valid in all camera_module versions. |
| 191 | * |
| 192 | * CAMERA_MODULE_API_VERSION_2_4 or higher: |
| 193 | * |
| 194 | * Valid if camera facing is CAMERA_FACING_BACK or CAMERA_FACING_FRONT, |
| 195 | * not valid if camera facing is CAMERA_FACING_EXTERNAL. |
Eino-Ville Talvala | 8bf364e | 2011-12-22 13:50:37 -0800 | [diff] [blame] | 196 | */ |
| 197 | int orientation; |
| 198 | |
| 199 | /** |
| 200 | * The value of camera_device_t.common.version. |
| 201 | * |
| 202 | * Version information (based on camera_module_t.common.module_api_version): |
| 203 | * |
Eino-Ville Talvala | ddc026e | 2012-03-27 16:15:25 -0700 | [diff] [blame] | 204 | * CAMERA_MODULE_API_VERSION_1_0: |
Eino-Ville Talvala | 8bf364e | 2011-12-22 13:50:37 -0800 | [diff] [blame] | 205 | * |
Eino-Ville Talvala | ddc026e | 2012-03-27 16:15:25 -0700 | [diff] [blame] | 206 | * Not valid. Can be assumed to be CAMERA_DEVICE_API_VERSION_1_0. Do |
Eino-Ville Talvala | 8bf364e | 2011-12-22 13:50:37 -0800 | [diff] [blame] | 207 | * not read this field. |
| 208 | * |
Eino-Ville Talvala | d76f8af | 2013-02-13 15:29:48 -0800 | [diff] [blame] | 209 | * CAMERA_MODULE_API_VERSION_2_0 or higher: |
Eino-Ville Talvala | 8bf364e | 2011-12-22 13:50:37 -0800 | [diff] [blame] | 210 | * |
| 211 | * Always valid |
| 212 | * |
| 213 | */ |
| 214 | uint32_t device_version; |
| 215 | |
| 216 | /** |
Zhijun He | 94e23b2 | 2015-01-12 14:45:33 -0800 | [diff] [blame] | 217 | * The camera's fixed characteristics, which include all static camera metadata |
| 218 | * specified in system/media/camera/docs/docs.html. This should be a sorted metadata |
| 219 | * buffer, and may not be modified or freed by the caller. The pointer should remain |
Eino-Ville Talvala | d76f8af | 2013-02-13 15:29:48 -0800 | [diff] [blame] | 220 | * valid for the lifetime of the camera module, and values in it may not |
| 221 | * change after it is returned by get_camera_info(). |
Eino-Ville Talvala | 8bf364e | 2011-12-22 13:50:37 -0800 | [diff] [blame] | 222 | * |
| 223 | * Version information (based on camera_module_t.common.module_api_version): |
| 224 | * |
Eino-Ville Talvala | ddc026e | 2012-03-27 16:15:25 -0700 | [diff] [blame] | 225 | * CAMERA_MODULE_API_VERSION_1_0: |
Eino-Ville Talvala | 8bf364e | 2011-12-22 13:50:37 -0800 | [diff] [blame] | 226 | * |
| 227 | * Not valid. Extra characteristics are not available. Do not read this |
| 228 | * field. |
| 229 | * |
Eino-Ville Talvala | d76f8af | 2013-02-13 15:29:48 -0800 | [diff] [blame] | 230 | * CAMERA_MODULE_API_VERSION_2_0 or higher: |
Eino-Ville Talvala | 8bf364e | 2011-12-22 13:50:37 -0800 | [diff] [blame] | 231 | * |
Eino-Ville Talvala | ddc026e | 2012-03-27 16:15:25 -0700 | [diff] [blame] | 232 | * Valid if device_version >= CAMERA_DEVICE_API_VERSION_2_0. Do not read |
| 233 | * otherwise. |
Eino-Ville Talvala | 8bf364e | 2011-12-22 13:50:37 -0800 | [diff] [blame] | 234 | * |
| 235 | */ |
Eino-Ville Talvala | b8b6439 | 2012-08-24 12:32:17 -0700 | [diff] [blame] | 236 | const camera_metadata_t *static_camera_characteristics; |
Ruben Brunk | 0388bcd | 2015-01-16 14:29:21 -0800 | [diff] [blame] | 237 | |
| 238 | /** |
| 239 | * The total resource "cost" of using this this camera, represented as |
| 240 | * an integer value in the range [0, 100] where 100 represents total usage |
| 241 | * of the shared resource that is the limiting bottleneck of the camera |
| 242 | * subsystem. |
| 243 | * |
| 244 | * The camera service must be able to simultaneously open and use any |
| 245 | * combination of camera devices exposed by the HAL where the sum of |
| 246 | * the resource costs of these cameras is <= 100. For determining cost, |
| 247 | * each camera device must be assumed to be configured and operating at |
| 248 | * the maximally resource-consuming framerate and stream size settings |
| 249 | * available in the configuration settings exposed for that device through |
| 250 | * the camera metadata. |
| 251 | * |
| 252 | * Note: The camera service may still attempt to simultaneously open |
| 253 | * combinations of camera devices with a total resource cost > 100. This |
| 254 | * may succeed or fail. If this succeeds, combinations of configurations |
| 255 | * that are not supported should fail during the configure calls. If the |
| 256 | * total resource cost is <= 100, configuration should never fail due to |
| 257 | * resource constraints. |
| 258 | * |
| 259 | * Version information (based on camera_module_t.common.module_api_version): |
| 260 | * |
| 261 | * CAMERA_MODULE_API_VERSION_2_3 or lower: |
| 262 | * |
| 263 | * Not valid. Can be assumed to be 100. Do not read this field. |
| 264 | * |
| 265 | * CAMERA_MODULE_API_VERSION_2_4 or higher: |
| 266 | * |
| 267 | * Always valid. |
| 268 | */ |
| 269 | int resource_cost; |
| 270 | |
| 271 | /** |
| 272 | * An array of camera device IDs represented as NULL-terminated strings |
| 273 | * indicating other devices that cannot be simultaneously opened while this |
| 274 | * camera device is in use. |
| 275 | * |
| 276 | * This field is intended to be used to indicate that this camera device |
| 277 | * is a composite of several other camera devices, or otherwise has |
| 278 | * hardware dependencies that prohibit simultaneous usage. If there are no |
| 279 | * dependencies, a NULL may be returned in this field to indicate this. |
| 280 | * |
| 281 | * The camera service will never simultaneously open any of the devices |
| 282 | * in this list while this camera device is open. |
| 283 | * |
| 284 | * Version information (based on camera_module_t.common.module_api_version): |
| 285 | * |
| 286 | * CAMERA_MODULE_API_VERSION_2_3 or lower: |
| 287 | * |
| 288 | * Not valid. Can be assumed to be NULL. Do not read this field. |
| 289 | * |
| 290 | * CAMERA_MODULE_API_VERSION_2_4 or higher: |
| 291 | * |
| 292 | * Always valid. |
| 293 | */ |
| 294 | char** conflicting_devices; |
| 295 | |
| 296 | /** |
| 297 | * The length of the array given in the conflicting_devices field. |
| 298 | * |
| 299 | * Version information (based on camera_module_t.common.module_api_version): |
| 300 | * |
| 301 | * CAMERA_MODULE_API_VERSION_2_3 or lower: |
| 302 | * |
| 303 | * Not valid. Can be assumed to be 0. Do not read this field. |
| 304 | * |
| 305 | * CAMERA_MODULE_API_VERSION_2_4 or higher: |
| 306 | * |
| 307 | * Always valid. |
| 308 | */ |
| 309 | size_t conflicting_devices_length; |
| 310 | |
Alex Ray | 9acc740 | 2013-02-07 15:44:24 -0800 | [diff] [blame] | 311 | } camera_info_t; |
Eino-Ville Talvala | 8bf364e | 2011-12-22 13:50:37 -0800 | [diff] [blame] | 312 | |
Eino-Ville Talvala | d76f8af | 2013-02-13 15:29:48 -0800 | [diff] [blame] | 313 | /** |
| 314 | * camera_device_status_t: |
| 315 | * |
| 316 | * The current status of the camera device, as provided by the HAL through the |
| 317 | * camera_module_callbacks.camera_device_status_change() call. |
Igor Murashkin | 152b50f | 2013-03-18 13:30:14 -0700 | [diff] [blame] | 318 | * |
| 319 | * At module load time, the framework will assume all camera devices are in the |
| 320 | * CAMERA_DEVICE_STATUS_PRESENT state. The HAL should invoke |
| 321 | * camera_module_callbacks::camera_device_status_change to inform the framework |
| 322 | * of any initially NOT_PRESENT devices. |
| 323 | * |
| 324 | * Allowed transitions: |
| 325 | * PRESENT -> NOT_PRESENT |
| 326 | * NOT_PRESENT -> ENUMERATING |
| 327 | * NOT_PRESENT -> PRESENT |
| 328 | * ENUMERATING -> PRESENT |
| 329 | * ENUMERATING -> NOT_PRESENT |
Eino-Ville Talvala | d76f8af | 2013-02-13 15:29:48 -0800 | [diff] [blame] | 330 | */ |
| 331 | typedef enum camera_device_status { |
| 332 | /** |
| 333 | * The camera device is not currently connected, and opening it will return |
Zhijun He | 94e23b2 | 2015-01-12 14:45:33 -0800 | [diff] [blame] | 334 | * failure. |
| 335 | * |
| 336 | * Version information (based on camera_module_t.common.module_api_version): |
| 337 | * |
| 338 | * CAMERA_MODULE_API_VERSION_2_3 or lower: |
| 339 | * |
| 340 | * Calls to get_camera_info must still succeed, and provide the same information |
| 341 | * it would if the camera were connected. |
| 342 | * |
| 343 | * CAMERA_MODULE_API_VERSION_2_4: |
| 344 | * |
| 345 | * The camera device at this status must return -EINVAL for get_camera_info call, |
| 346 | * as the device is not connected. |
Eino-Ville Talvala | d76f8af | 2013-02-13 15:29:48 -0800 | [diff] [blame] | 347 | */ |
| 348 | CAMERA_DEVICE_STATUS_NOT_PRESENT = 0, |
| 349 | |
| 350 | /** |
Zhijun He | 94e23b2 | 2015-01-12 14:45:33 -0800 | [diff] [blame] | 351 | * The camera device is connected, and opening it will succeed. |
| 352 | * |
| 353 | * CAMERA_MODULE_API_VERSION_2_3 or lower: |
| 354 | * |
| 355 | * The information returned by get_camera_info cannot change due to this status |
| 356 | * change. By default, the framework will assume all devices are in this state. |
| 357 | * |
| 358 | * CAMERA_MODULE_API_VERSION_2_4: |
| 359 | * |
| 360 | * The information returned by get_camera_info will become valid after a device's |
| 361 | * status changes to this. By default, the framework will assume all devices are in |
| 362 | * this state. |
Eino-Ville Talvala | d76f8af | 2013-02-13 15:29:48 -0800 | [diff] [blame] | 363 | */ |
Igor Murashkin | 152b50f | 2013-03-18 13:30:14 -0700 | [diff] [blame] | 364 | CAMERA_DEVICE_STATUS_PRESENT = 1, |
| 365 | |
| 366 | /** |
| 367 | * The camera device is connected, but it is undergoing an enumeration and |
Zhijun He | 94e23b2 | 2015-01-12 14:45:33 -0800 | [diff] [blame] | 368 | * so opening the device will return -EBUSY. |
| 369 | * |
| 370 | * CAMERA_MODULE_API_VERSION_2_3 or lower: |
| 371 | * |
| 372 | * Calls to get_camera_info must still succeed, as if the camera was in the |
| 373 | * PRESENT status. |
| 374 | * |
| 375 | * CAMERA_MODULE_API_VERSION_2_4: |
| 376 | * |
| 377 | * The camera device at this status must return -EINVAL for get_camera_info for call, |
| 378 | * as the device is not ready. |
Igor Murashkin | 152b50f | 2013-03-18 13:30:14 -0700 | [diff] [blame] | 379 | */ |
| 380 | CAMERA_DEVICE_STATUS_ENUMERATING = 2, |
Eino-Ville Talvala | d76f8af | 2013-02-13 15:29:48 -0800 | [diff] [blame] | 381 | |
| 382 | } camera_device_status_t; |
| 383 | |
| 384 | /** |
Chien-Yu Chen | 3015917 | 2015-01-08 11:06:38 -0800 | [diff] [blame] | 385 | * torch_mode_status_t: |
| 386 | * |
| 387 | * The current status of the torch mode, as provided by the HAL through the |
| 388 | * camera_module_callbacks.torch_mode_status_change() call. |
| 389 | * |
| 390 | * The torch mode status of a camera device is applicable only when the camera |
| 391 | * device is present. The framework will not call set_torch_mode() to turn on |
| 392 | * torch mode of a camera device if the camera device is not present. At module |
| 393 | * load time, the framework will assume torch modes are in the |
Chien-Yu Chen | 8558510 | 2015-02-25 14:50:13 -0800 | [diff] [blame^] | 394 | * TORCH_MODE_STATUS_OFF state if the camera device is present and |
Chien-Yu Chen | 3015917 | 2015-01-08 11:06:38 -0800 | [diff] [blame] | 395 | * android.flash.info.available is reported as true via get_camera_info() call. |
| 396 | * |
| 397 | * The behaviors of the camera HAL module that the framework expects in the |
| 398 | * following situations when a camera device's status changes: |
| 399 | * 1. A previously-disconnected camera device becomes connected. |
| 400 | * After camera_module_callbacks::camera_device_status_change() is invoked |
| 401 | * to inform the framework that the camera device is present, the framework |
| 402 | * will assume the camera device's torch mode is in |
Chien-Yu Chen | 8558510 | 2015-02-25 14:50:13 -0800 | [diff] [blame^] | 403 | * TORCH_MODE_STATUS_OFF state. The camera HAL module does not need |
Chien-Yu Chen | 3015917 | 2015-01-08 11:06:38 -0800 | [diff] [blame] | 404 | * to invoke camera_module_callbacks::torch_mode_status_change() unless the |
| 405 | * flash unit is unavailable to use by set_torch_mode(). |
| 406 | * |
| 407 | * 2. A previously-connected camera becomes disconnected. |
| 408 | * After camera_module_callbacks::camera_device_status_change() is invoked |
| 409 | * to inform the framework that the camera device is not present, the |
| 410 | * framework will not call set_torch_mode() for the disconnected camera |
| 411 | * device until its flash unit becomes available again. The camera HAL |
| 412 | * module does not need to invoke |
| 413 | * camera_module_callbacks::torch_mode_status_change() separately to inform |
| 414 | * that the flash unit has become unavailable. |
| 415 | * |
| 416 | * 3. open() is called to open a camera device. |
| 417 | * The camera HAL module must invoke |
| 418 | * camera_module_callbacks::torch_mode_status_change() for all flash units |
Chien-Yu Chen | 8558510 | 2015-02-25 14:50:13 -0800 | [diff] [blame^] | 419 | * that have entered TORCH_MODE_STATUS_NOT_AVAILABLE state and can not be |
Chien-Yu Chen | 3015917 | 2015-01-08 11:06:38 -0800 | [diff] [blame] | 420 | * turned on by calling set_torch_mode() anymore due to this open() call. |
| 421 | * |
| 422 | * 4. close() is called to close a camera device. |
| 423 | * The camera HAL module must invoke |
| 424 | * camera_module_callbacks::torch_mode_status_change() for all flash units |
Chien-Yu Chen | 8558510 | 2015-02-25 14:50:13 -0800 | [diff] [blame^] | 425 | * that have entered TORCH_MODE_STATUS_OFF state and can be turned |
Chien-Yu Chen | 3015917 | 2015-01-08 11:06:38 -0800 | [diff] [blame] | 426 | * on by calling set_torch_mode() again because of enough resources freed |
| 427 | * up by this close() call. |
| 428 | * |
Chien-Yu Chen | 8558510 | 2015-02-25 14:50:13 -0800 | [diff] [blame^] | 429 | * Note that the framework calling set_torch_mode() successfully must trigger |
| 430 | * TORCH_MODE_STATUS_OFF or TORCH_MODE_STATUS_ON callback for the given camera |
| 431 | * device. Additionally it must trigger TORCH_MODE_STATUS_OFF callbacks for |
| 432 | * other previously-on torch modes if HAL cannot keep multiple torch modes on |
| 433 | * simultaneously. |
Chien-Yu Chen | 3015917 | 2015-01-08 11:06:38 -0800 | [diff] [blame] | 434 | */ |
| 435 | typedef enum torch_mode_status { |
Chien-Yu Chen | 3015917 | 2015-01-08 11:06:38 -0800 | [diff] [blame] | 436 | |
| 437 | /** |
| 438 | * The flash unit is no longer available and the torch mode can not be |
| 439 | * turned on by calling set_torch_mode(). If the torch mode is on, it |
| 440 | * will be turned off by HAL before HAL calls torch_mode_status_change(). |
| 441 | */ |
Chien-Yu Chen | 8558510 | 2015-02-25 14:50:13 -0800 | [diff] [blame^] | 442 | TORCH_MODE_STATUS_NOT_AVAILABLE = 0, |
Chien-Yu Chen | 3015917 | 2015-01-08 11:06:38 -0800 | [diff] [blame] | 443 | |
Chien-Yu Chen | 46edf1a | 2015-01-29 15:12:47 -0800 | [diff] [blame] | 444 | /** |
Chien-Yu Chen | 8558510 | 2015-02-25 14:50:13 -0800 | [diff] [blame^] | 445 | * A torch mode has become off and available to be turned on via |
| 446 | * set_torch_mode(). This may happen in the following |
| 447 | * cases: |
| 448 | * 1. After the resources to turn on the torch mode have become available. |
| 449 | * 2. After set_torch_mode() is called to turn off the torch mode. |
| 450 | * 3. After the framework turned on the torch mode of some other camera |
| 451 | * device and HAL had to turn off the torch modes of any camera devices |
| 452 | * that were previously on. |
Chien-Yu Chen | 46edf1a | 2015-01-29 15:12:47 -0800 | [diff] [blame] | 453 | */ |
Chien-Yu Chen | 8558510 | 2015-02-25 14:50:13 -0800 | [diff] [blame^] | 454 | TORCH_MODE_STATUS_AVAILABLE_OFF = 1, |
| 455 | |
| 456 | /** |
| 457 | * A torch mode has become on and available to be turned off via |
| 458 | * set_torch_mode(). This can happen only after set_torch_mode() is called |
| 459 | * to turn on the torch mode. |
| 460 | */ |
| 461 | TORCH_MODE_STATUS_AVAILABLE_ON = 2, |
Chien-Yu Chen | 46edf1a | 2015-01-29 15:12:47 -0800 | [diff] [blame] | 462 | |
Chien-Yu Chen | 3015917 | 2015-01-08 11:06:38 -0800 | [diff] [blame] | 463 | } torch_mode_status_t; |
| 464 | |
| 465 | /** |
Eino-Ville Talvala | d76f8af | 2013-02-13 15:29:48 -0800 | [diff] [blame] | 466 | * Callback functions for the camera HAL module to use to inform the framework |
Chien-Yu Chen | 3015917 | 2015-01-08 11:06:38 -0800 | [diff] [blame] | 467 | * of changes to the camera subsystem. |
| 468 | * |
| 469 | * Version information (based on camera_module_t.common.module_api_version): |
| 470 | * |
| 471 | * Each callback is called only by HAL modules implementing the indicated |
| 472 | * version or higher of the HAL module API interface. |
| 473 | * |
| 474 | * CAMERA_MODULE_API_VERSION_2_1: |
| 475 | * camera_device_status_change() |
| 476 | * |
| 477 | * CAMERA_MODULE_API_VERSION_2_4: |
| 478 | * torch_mode_status_change() |
| 479 | |
Eino-Ville Talvala | d76f8af | 2013-02-13 15:29:48 -0800 | [diff] [blame] | 480 | */ |
| 481 | typedef struct camera_module_callbacks { |
| 482 | |
| 483 | /** |
| 484 | * camera_device_status_change: |
| 485 | * |
| 486 | * Callback to the framework to indicate that the state of a specific camera |
| 487 | * device has changed. At module load time, the framework will assume all |
| 488 | * camera devices are in the CAMERA_DEVICE_STATUS_PRESENT state. The HAL |
| 489 | * must call this method to inform the framework of any initially |
| 490 | * NOT_PRESENT devices. |
| 491 | * |
Chien-Yu Chen | 3015917 | 2015-01-08 11:06:38 -0800 | [diff] [blame] | 492 | * This callback is added for CAMERA_MODULE_API_VERSION_2_1. |
| 493 | * |
Eino-Ville Talvala | d76f8af | 2013-02-13 15:29:48 -0800 | [diff] [blame] | 494 | * camera_module_callbacks: The instance of camera_module_callbacks_t passed |
| 495 | * to the module with set_callbacks. |
| 496 | * |
| 497 | * camera_id: The ID of the camera device that has a new status. |
| 498 | * |
| 499 | * new_status: The new status code, one of the camera_device_status_t enums, |
| 500 | * or a platform-specific status. |
| 501 | * |
| 502 | */ |
| 503 | void (*camera_device_status_change)(const struct camera_module_callbacks*, |
| 504 | int camera_id, |
| 505 | int new_status); |
| 506 | |
Chien-Yu Chen | 3015917 | 2015-01-08 11:06:38 -0800 | [diff] [blame] | 507 | /** |
| 508 | * torch_mode_status_change: |
| 509 | * |
| 510 | * Callback to the framework to indicate that the state of the torch mode |
| 511 | * of the flash unit associated with a specific camera device has changed. |
| 512 | * At module load time, the framework will assume the torch modes are in |
| 513 | * the TORCH_MODE_STATUS_AVAILABLE state if android.flash.info.available |
| 514 | * is reported as true via get_camera_info() call. |
| 515 | * |
| 516 | * This callback is added for CAMERA_MODULE_API_VERSION_2_4. |
| 517 | * |
| 518 | * camera_module_callbacks: The instance of camera_module_callbacks_t |
| 519 | * passed to the module with set_callbacks. |
| 520 | * |
| 521 | * camera_id: The ID of camera device whose flash unit has a new torch mode |
| 522 | * status. |
| 523 | * |
| 524 | * new_status: The new status code, one of the torch_mode_status_t enums. |
| 525 | */ |
| 526 | void (*torch_mode_status_change)(const struct camera_module_callbacks*, |
| 527 | const char* camera_id, |
| 528 | int new_status); |
| 529 | |
| 530 | |
Eino-Ville Talvala | d76f8af | 2013-02-13 15:29:48 -0800 | [diff] [blame] | 531 | } camera_module_callbacks_t; |
| 532 | |
Eino-Ville Talvala | 8bf364e | 2011-12-22 13:50:37 -0800 | [diff] [blame] | 533 | typedef struct camera_module { |
Stewart Miles | 84d3549 | 2014-05-01 09:03:27 -0700 | [diff] [blame] | 534 | /** |
| 535 | * Common methods of the camera module. This *must* be the first member of |
| 536 | * camera_module as users of this structure will cast a hw_module_t to |
Eino-Ville Talvala | c984be7 | 2014-07-24 16:44:56 -0700 | [diff] [blame] | 537 | * camera_module pointer in contexts where it's known the hw_module_t |
| 538 | * references a camera_module. |
| 539 | * |
| 540 | * The return values for common.methods->open for camera_module are: |
| 541 | * |
| 542 | * 0: On a successful open of the camera device. |
| 543 | * |
| 544 | * -ENODEV: The camera device cannot be opened due to an internal |
| 545 | * error. |
| 546 | * |
| 547 | * -EINVAL: The input arguments are invalid, i.e. the id is invalid, |
| 548 | * and/or the module is invalid. |
| 549 | * |
| 550 | * -EBUSY: The camera device was already opened for this camera id |
| 551 | * (by using this method or open_legacy), |
| 552 | * regardless of the device HAL version it was opened as. |
| 553 | * |
| 554 | * -EUSERS: The maximal number of camera devices that can be |
| 555 | * opened concurrently were opened already, either by |
| 556 | * this method or the open_legacy method. |
| 557 | * |
| 558 | * All other return values from common.methods->open will be treated as |
| 559 | * -ENODEV. |
Stewart Miles | 84d3549 | 2014-05-01 09:03:27 -0700 | [diff] [blame] | 560 | */ |
Eino-Ville Talvala | 8bf364e | 2011-12-22 13:50:37 -0800 | [diff] [blame] | 561 | hw_module_t common; |
Eino-Ville Talvala | d76f8af | 2013-02-13 15:29:48 -0800 | [diff] [blame] | 562 | |
| 563 | /** |
| 564 | * get_number_of_cameras: |
| 565 | * |
| 566 | * Returns the number of camera devices accessible through the camera |
| 567 | * module. The camera devices are numbered 0 through N-1, where N is the |
| 568 | * value returned by this call. The name of the camera device for open() is |
| 569 | * simply the number converted to a string. That is, "0" for camera ID 0, |
| 570 | * "1" for camera ID 1. |
| 571 | * |
Zhijun He | 94e23b2 | 2015-01-12 14:45:33 -0800 | [diff] [blame] | 572 | * Version information (based on camera_module_t.common.module_api_version): |
| 573 | * |
| 574 | * CAMERA_MODULE_API_VERSION_2_3 or lower: |
| 575 | * |
| 576 | * The value here must be static, and cannot change after the first call |
| 577 | * to this method. |
| 578 | * |
| 579 | * CAMERA_MODULE_API_VERSION_2_4 or higher: |
| 580 | * |
| 581 | * The value here must be static, and must count only built-in cameras, |
| 582 | * which have CAMERA_FACING_BACK or CAMERA_FACING_FRONT camera facing values |
| 583 | * (camera_info.facing). The HAL must not include the external cameras |
| 584 | * (camera_info.facing == CAMERA_FACING_EXTERNAL) into the return value |
| 585 | * of this call. Frameworks will use camera_device_status_change callback |
| 586 | * to manage number of external cameras. |
Eino-Ville Talvala | d76f8af | 2013-02-13 15:29:48 -0800 | [diff] [blame] | 587 | */ |
Eino-Ville Talvala | 8bf364e | 2011-12-22 13:50:37 -0800 | [diff] [blame] | 588 | int (*get_number_of_cameras)(void); |
Eino-Ville Talvala | d76f8af | 2013-02-13 15:29:48 -0800 | [diff] [blame] | 589 | |
| 590 | /** |
| 591 | * get_camera_info: |
| 592 | * |
| 593 | * Return the static camera information for a given camera device. This |
| 594 | * information may not change for a camera device. |
| 595 | * |
Eino-Ville Talvala | c984be7 | 2014-07-24 16:44:56 -0700 | [diff] [blame] | 596 | * Return values: |
| 597 | * |
| 598 | * 0: On a successful operation |
| 599 | * |
| 600 | * -ENODEV: The information cannot be provided due to an internal |
| 601 | * error. |
| 602 | * |
| 603 | * -EINVAL: The input arguments are invalid, i.e. the id is invalid, |
| 604 | * and/or the module is invalid. |
Zhijun He | 94e23b2 | 2015-01-12 14:45:33 -0800 | [diff] [blame] | 605 | * |
| 606 | * Version information (based on camera_module_t.common.module_api_version): |
| 607 | * |
| 608 | * CAMERA_MODULE_API_VERSION_2_4 or higher: |
| 609 | * |
| 610 | * When a camera is disconnected, its camera id becomes invalid. Calling this |
| 611 | * this method with this invalid camera id will get -EINVAL and NULL camera |
| 612 | * static metadata (camera_info.static_camera_characteristics). |
Eino-Ville Talvala | d76f8af | 2013-02-13 15:29:48 -0800 | [diff] [blame] | 613 | */ |
Eino-Ville Talvala | 8bf364e | 2011-12-22 13:50:37 -0800 | [diff] [blame] | 614 | int (*get_camera_info)(int camera_id, struct camera_info *info); |
Eino-Ville Talvala | d76f8af | 2013-02-13 15:29:48 -0800 | [diff] [blame] | 615 | |
| 616 | /** |
| 617 | * set_callbacks: |
| 618 | * |
| 619 | * Provide callback function pointers to the HAL module to inform framework |
| 620 | * of asynchronous camera module events. The framework will call this |
| 621 | * function once after initial camera HAL module load, after the |
| 622 | * get_number_of_cameras() method is called for the first time, and before |
| 623 | * any other calls to the module. |
| 624 | * |
| 625 | * Version information (based on camera_module_t.common.module_api_version): |
| 626 | * |
| 627 | * CAMERA_MODULE_API_VERSION_1_0, CAMERA_MODULE_API_VERSION_2_0: |
| 628 | * |
| 629 | * Not provided by HAL module. Framework may not call this function. |
| 630 | * |
| 631 | * CAMERA_MODULE_API_VERSION_2_1: |
| 632 | * |
| 633 | * Valid to be called by the framework. |
| 634 | * |
Eino-Ville Talvala | c984be7 | 2014-07-24 16:44:56 -0700 | [diff] [blame] | 635 | * Return values: |
| 636 | * |
| 637 | * 0: On a successful operation |
| 638 | * |
| 639 | * -ENODEV: The operation cannot be completed due to an internal |
| 640 | * error. |
| 641 | * |
| 642 | * -EINVAL: The input arguments are invalid, i.e. the callbacks are |
| 643 | * null |
Eino-Ville Talvala | d76f8af | 2013-02-13 15:29:48 -0800 | [diff] [blame] | 644 | */ |
| 645 | int (*set_callbacks)(const camera_module_callbacks_t *callbacks); |
| 646 | |
Alex Ray | 19b2cea | 2013-06-13 12:40:52 -0700 | [diff] [blame] | 647 | /** |
| 648 | * get_vendor_tag_ops: |
| 649 | * |
| 650 | * Get methods to query for vendor extension metadata tag information. The |
| 651 | * HAL should fill in all the vendor tag operation methods, or leave ops |
| 652 | * unchanged if no vendor tags are defined. |
| 653 | * |
Ruben Brunk | 61cf9eb | 2014-01-14 15:27:58 -0800 | [diff] [blame] | 654 | * The vendor_tag_ops structure used here is defined in: |
| 655 | * system/media/camera/include/system/vendor_tags.h |
| 656 | * |
Alex Ray | 19b2cea | 2013-06-13 12:40:52 -0700 | [diff] [blame] | 657 | * Version information (based on camera_module_t.common.module_api_version): |
| 658 | * |
| 659 | * CAMERA_MODULE_API_VERSION_1_x/2_0/2_1: |
| 660 | * Not provided by HAL module. Framework may not call this function. |
| 661 | * |
| 662 | * CAMERA_MODULE_API_VERSION_2_2: |
| 663 | * Valid to be called by the framework. |
| 664 | */ |
| 665 | void (*get_vendor_tag_ops)(vendor_tag_ops_t* ops); |
| 666 | |
Zhijun He | bcdebf3 | 2014-06-06 15:42:17 -0700 | [diff] [blame] | 667 | /** |
| 668 | * open_legacy: |
| 669 | * |
| 670 | * Open a specific legacy camera HAL device if multiple device HAL API |
| 671 | * versions are supported by this camera HAL module. For example, if the |
| 672 | * camera module supports both CAMERA_DEVICE_API_VERSION_1_0 and |
| 673 | * CAMERA_DEVICE_API_VERSION_3_2 device API for the same camera id, |
| 674 | * framework can call this function to open the camera device as |
| 675 | * CAMERA_DEVICE_API_VERSION_1_0 device. |
| 676 | * |
| 677 | * This is an optional method. A Camera HAL module does not need to support |
| 678 | * more than one device HAL version per device, and such modules may return |
| 679 | * -ENOSYS for all calls to this method. For all older HAL device API |
| 680 | * versions that are not supported, it may return -EOPNOTSUPP. When above |
| 681 | * cases occur, The normal open() method (common.methods->open) will be |
| 682 | * used by the framework instead. |
| 683 | * |
| 684 | * Version information (based on camera_module_t.common.module_api_version): |
| 685 | * |
| 686 | * CAMERA_MODULE_API_VERSION_1_x/2_0/2_1/2_2: |
| 687 | * Not provided by HAL module. Framework will not call this function. |
| 688 | * |
| 689 | * CAMERA_MODULE_API_VERSION_2_3: |
| 690 | * Valid to be called by the framework. |
| 691 | * |
| 692 | * Return values: |
| 693 | * |
| 694 | * 0: On a successful open of the camera device. |
| 695 | * |
| 696 | * -ENOSYS This method is not supported. |
| 697 | * |
| 698 | * -EOPNOTSUPP: The requested HAL version is not supported by this method. |
| 699 | * |
| 700 | * -EINVAL: The input arguments are invalid, i.e. the id is invalid, |
| 701 | * and/or the module is invalid. |
| 702 | * |
| 703 | * -EBUSY: The camera device was already opened for this camera id |
| 704 | * (by using this method or common.methods->open method), |
| 705 | * regardless of the device HAL version it was opened as. |
| 706 | * |
| 707 | * -EUSERS: The maximal number of camera devices that can be |
| 708 | * opened concurrently were opened already, either by |
| 709 | * this method or common.methods->open method. |
| 710 | */ |
| 711 | int (*open_legacy)(const struct hw_module_t* module, const char* id, |
| 712 | uint32_t halVersion, struct hw_device_t** device); |
| 713 | |
Chien-Yu Chen | 3015917 | 2015-01-08 11:06:38 -0800 | [diff] [blame] | 714 | /** |
| 715 | * set_torch_mode: |
| 716 | * |
| 717 | * Turn on or off the torch mode of the flash unit associated with a given |
Chien-Yu Chen | 8558510 | 2015-02-25 14:50:13 -0800 | [diff] [blame^] | 718 | * camera ID. If the operation is successful, HAL must notify the framework |
| 719 | * torch state by invoking |
| 720 | * camera_module_callbacks.torch_mode_status_change() with the new state. |
Chien-Yu Chen | 3015917 | 2015-01-08 11:06:38 -0800 | [diff] [blame] | 721 | * |
| 722 | * The camera device has a higher priority accessing the flash unit. When |
| 723 | * there are any resource conflicts, such as open() is called to open a |
| 724 | * camera device, HAL module must notify the framework through |
| 725 | * camera_module_callbacks.torch_mode_status_change() that the |
| 726 | * torch mode has been turned off and the torch mode state has become |
Chien-Yu Chen | 8558510 | 2015-02-25 14:50:13 -0800 | [diff] [blame^] | 727 | * TORCH_MODE_STATUS_NOT_AVAILABLE. When resources to turn on torch mode |
Chien-Yu Chen | 3015917 | 2015-01-08 11:06:38 -0800 | [diff] [blame] | 728 | * become available again, HAL module must notify the framework through |
| 729 | * camera_module_callbacks.torch_mode_status_change() that the torch mode |
Chien-Yu Chen | 8558510 | 2015-02-25 14:50:13 -0800 | [diff] [blame^] | 730 | * state has become TORCH_MODE_STATUS_OFF for set_torch_mode() to be called. |
Chien-Yu Chen | 3015917 | 2015-01-08 11:06:38 -0800 | [diff] [blame] | 731 | * |
Chien-Yu Chen | 46edf1a | 2015-01-29 15:12:47 -0800 | [diff] [blame] | 732 | * When the framework calls set_torch_mode() to turn on the torch mode of a |
| 733 | * flash unit, if HAL cannot keep multiple torch modes on simultaneously, |
| 734 | * HAL should turn off the torch mode that was turned on by |
| 735 | * a previous set_torch_mode() call and notify the framework that the torch |
| 736 | * mode state of that flash unit has become TORCH_MODE_STATUS_OFF. |
| 737 | * |
Chien-Yu Chen | 3015917 | 2015-01-08 11:06:38 -0800 | [diff] [blame] | 738 | * Version information (based on camera_module_t.common.module_api_version): |
| 739 | * |
| 740 | * CAMERA_MODULE_API_VERSION_1_x/2_0/2_1/2_2/2_3: |
| 741 | * Not provided by HAL module. Framework will not call this function. |
| 742 | * |
| 743 | * CAMERA_MODULE_API_VERSION_2_4: |
| 744 | * Valid to be called by the framework. |
| 745 | * |
| 746 | * Return values: |
| 747 | * |
| 748 | * 0: On a successful operation. |
| 749 | * |
| 750 | * -ENOSYS: The camera device does not support this operation. It is |
| 751 | * returned if and only if android.flash.info.available is |
| 752 | * false. |
| 753 | * |
Chien-Yu Chen | 273def3 | 2015-02-11 11:31:12 -0800 | [diff] [blame] | 754 | * -EBUSY: The camera device is already in use. |
| 755 | * |
| 756 | * -EUSERS: The resources needed to turn on the torch mode are not |
| 757 | * available, typically because other camera devices are |
| 758 | * holding the resources to make using the flash unit not |
| 759 | * possible. |
Chien-Yu Chen | 3015917 | 2015-01-08 11:06:38 -0800 | [diff] [blame] | 760 | * |
| 761 | * -EINVAL: camera_id is invalid. |
| 762 | * |
| 763 | */ |
Chien-Yu Chen | 46edf1a | 2015-01-29 15:12:47 -0800 | [diff] [blame] | 764 | int (*set_torch_mode)(const char* camera_id, bool enabled); |
Chien-Yu Chen | 3015917 | 2015-01-08 11:06:38 -0800 | [diff] [blame] | 765 | |
Alex Ray | 19b2cea | 2013-06-13 12:40:52 -0700 | [diff] [blame] | 766 | /* reserved for future use */ |
Chien-Yu Chen | 3015917 | 2015-01-08 11:06:38 -0800 | [diff] [blame] | 767 | void* reserved[6]; |
Eino-Ville Talvala | 8bf364e | 2011-12-22 13:50:37 -0800 | [diff] [blame] | 768 | } camera_module_t; |
| 769 | |
| 770 | __END_DECLS |
| 771 | |
| 772 | #endif /* ANDROID_INCLUDE_CAMERA_COMMON_H */ |