Yin-Chia Yeh | e074a93 | 2015-01-30 10:29:02 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2015 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 | #define LOG_TAG "CameraModule" |
Eino-Ville Talvala | a84bbe6 | 2015-09-08 17:59:17 -0700 | [diff] [blame] | 18 | #define ATRACE_TAG ATRACE_TAG_CAMERA |
Yin-Chia Yeh | e074a93 | 2015-01-30 10:29:02 -0800 | [diff] [blame] | 19 | //#define LOG_NDEBUG 0 |
| 20 | |
Eino-Ville Talvala | a84bbe6 | 2015-09-08 17:59:17 -0700 | [diff] [blame] | 21 | #include <utils/Trace.h> |
| 22 | |
Yin-Chia Yeh | e074a93 | 2015-01-30 10:29:02 -0800 | [diff] [blame] | 23 | #include "CameraModule.h" |
| 24 | |
| 25 | namespace android { |
| 26 | |
| 27 | void CameraModule::deriveCameraCharacteristicsKeys( |
| 28 | uint32_t deviceVersion, CameraMetadata &chars) { |
Eino-Ville Talvala | a84bbe6 | 2015-09-08 17:59:17 -0700 | [diff] [blame] | 29 | ATRACE_CALL(); |
Yin-Chia Yeh | e074a93 | 2015-01-30 10:29:02 -0800 | [diff] [blame] | 30 | |
Yin-Chia Yeh | e9154ce | 2015-12-07 14:38:04 -0800 | [diff] [blame^] | 31 | Vector<int32_t> derivedCharKeys; |
Yin-Chia Yeh | e074a93 | 2015-01-30 10:29:02 -0800 | [diff] [blame] | 32 | // Keys added in HAL3.3 |
| 33 | if (deviceVersion < CAMERA_DEVICE_API_VERSION_3_3) { |
| 34 | Vector<uint8_t> controlModes; |
| 35 | uint8_t data = ANDROID_CONTROL_AE_LOCK_AVAILABLE_TRUE; |
| 36 | chars.update(ANDROID_CONTROL_AE_LOCK_AVAILABLE, &data, /*count*/1); |
| 37 | data = ANDROID_CONTROL_AWB_LOCK_AVAILABLE_TRUE; |
| 38 | chars.update(ANDROID_CONTROL_AWB_LOCK_AVAILABLE, &data, /*count*/1); |
Yin-Chia Yeh | e074a93 | 2015-01-30 10:29:02 -0800 | [diff] [blame] | 39 | controlModes.push(ANDROID_CONTROL_MODE_AUTO); |
| 40 | camera_metadata_entry entry = chars.find(ANDROID_CONTROL_AVAILABLE_SCENE_MODES); |
| 41 | if (entry.count > 1 || entry.data.u8[0] != ANDROID_CONTROL_SCENE_MODE_DISABLED) { |
| 42 | controlModes.push(ANDROID_CONTROL_MODE_USE_SCENE_MODE); |
| 43 | } |
Zhijun He | 9c5af61 | 2015-05-04 16:34:37 -0700 | [diff] [blame] | 44 | |
| 45 | // Only advertise CONTROL_OFF mode if 3A manual controls are supported. |
| 46 | bool isManualAeSupported = false; |
| 47 | bool isManualAfSupported = false; |
| 48 | bool isManualAwbSupported = false; |
| 49 | entry = chars.find(ANDROID_CONTROL_AE_AVAILABLE_MODES); |
| 50 | if (entry.count > 0) { |
| 51 | for (size_t i = 0; i < entry.count; i++) { |
| 52 | if (entry.data.u8[i] == ANDROID_CONTROL_AE_MODE_OFF) { |
| 53 | isManualAeSupported = true; |
| 54 | break; |
| 55 | } |
| 56 | } |
| 57 | } |
| 58 | entry = chars.find(ANDROID_CONTROL_AF_AVAILABLE_MODES); |
| 59 | if (entry.count > 0) { |
| 60 | for (size_t i = 0; i < entry.count; i++) { |
| 61 | if (entry.data.u8[i] == ANDROID_CONTROL_AF_MODE_OFF) { |
| 62 | isManualAfSupported = true; |
| 63 | break; |
| 64 | } |
| 65 | } |
| 66 | } |
| 67 | entry = chars.find(ANDROID_CONTROL_AWB_AVAILABLE_MODES); |
| 68 | if (entry.count > 0) { |
| 69 | for (size_t i = 0; i < entry.count; i++) { |
| 70 | if (entry.data.u8[i] == ANDROID_CONTROL_AWB_MODE_OFF) { |
| 71 | isManualAwbSupported = true; |
| 72 | break; |
| 73 | } |
| 74 | } |
| 75 | } |
| 76 | if (isManualAeSupported && isManualAfSupported && isManualAwbSupported) { |
| 77 | controlModes.push(ANDROID_CONTROL_MODE_OFF); |
| 78 | } |
| 79 | |
Yin-Chia Yeh | e074a93 | 2015-01-30 10:29:02 -0800 | [diff] [blame] | 80 | chars.update(ANDROID_CONTROL_AVAILABLE_MODES, controlModes); |
Yin-Chia Yeh | b28c344 | 2015-05-07 14:43:19 -0700 | [diff] [blame] | 81 | |
Yin-Chia Yeh | 3e28a1a | 2015-05-22 15:03:38 -0700 | [diff] [blame] | 82 | entry = chars.find(ANDROID_REQUEST_AVAILABLE_REQUEST_KEYS); |
| 83 | // HAL3.2 devices passing existing CTS test should all support all LSC modes and LSC map |
| 84 | bool lensShadingModeSupported = false; |
| 85 | if (entry.count > 0) { |
| 86 | for (size_t i = 0; i < entry.count; i++) { |
| 87 | if (entry.data.i32[i] == ANDROID_SHADING_MODE) { |
| 88 | lensShadingModeSupported = true; |
| 89 | break; |
| 90 | } |
| 91 | } |
| 92 | } |
| 93 | Vector<uint8_t> lscModes; |
| 94 | Vector<uint8_t> lscMapModes; |
| 95 | lscModes.push(ANDROID_SHADING_MODE_FAST); |
| 96 | lscModes.push(ANDROID_SHADING_MODE_HIGH_QUALITY); |
| 97 | lscMapModes.push(ANDROID_STATISTICS_LENS_SHADING_MAP_MODE_OFF); |
| 98 | if (lensShadingModeSupported) { |
| 99 | lscModes.push(ANDROID_SHADING_MODE_OFF); |
| 100 | lscMapModes.push(ANDROID_STATISTICS_LENS_SHADING_MAP_MODE_ON); |
| 101 | } |
| 102 | chars.update(ANDROID_SHADING_AVAILABLE_MODES, lscModes); |
| 103 | chars.update(ANDROID_STATISTICS_INFO_AVAILABLE_LENS_SHADING_MAP_MODES, lscMapModes); |
| 104 | |
Yin-Chia Yeh | e9154ce | 2015-12-07 14:38:04 -0800 | [diff] [blame^] | 105 | derivedCharKeys.push(ANDROID_CONTROL_AE_LOCK_AVAILABLE); |
| 106 | derivedCharKeys.push(ANDROID_CONTROL_AWB_LOCK_AVAILABLE); |
| 107 | derivedCharKeys.push(ANDROID_CONTROL_AVAILABLE_MODES); |
| 108 | derivedCharKeys.push(ANDROID_SHADING_AVAILABLE_MODES); |
| 109 | derivedCharKeys.push(ANDROID_STATISTICS_INFO_AVAILABLE_LENS_SHADING_MAP_MODES); |
Yin-Chia Yeh | 3e28a1a | 2015-05-22 15:03:38 -0700 | [diff] [blame] | 110 | |
Zhijun He | 1fa8999 | 2015-06-01 15:44:31 -0700 | [diff] [blame] | 111 | // Need update android.control.availableHighSpeedVideoConfigurations since HAL3.3 |
| 112 | // adds batch size to this array. |
| 113 | entry = chars.find(ANDROID_CONTROL_AVAILABLE_HIGH_SPEED_VIDEO_CONFIGURATIONS); |
| 114 | if (entry.count > 0) { |
| 115 | Vector<int32_t> highSpeedConfig; |
| 116 | for (size_t i = 0; i < entry.count; i += 4) { |
| 117 | highSpeedConfig.add(entry.data.i32[i]); // width |
| 118 | highSpeedConfig.add(entry.data.i32[i + 1]); // height |
| 119 | highSpeedConfig.add(entry.data.i32[i + 2]); // fps_min |
| 120 | highSpeedConfig.add(entry.data.i32[i + 3]); // fps_max |
| 121 | highSpeedConfig.add(1); // batchSize_max. default to 1 for HAL3.2 |
| 122 | } |
| 123 | chars.update(ANDROID_CONTROL_AVAILABLE_HIGH_SPEED_VIDEO_CONFIGURATIONS, |
| 124 | highSpeedConfig); |
| 125 | } |
Yin-Chia Yeh | e074a93 | 2015-01-30 10:29:02 -0800 | [diff] [blame] | 126 | } |
Ruben Brunk | a3b3caa | 2015-06-22 14:26:51 -0700 | [diff] [blame] | 127 | |
Yin-Chia Yeh | e9154ce | 2015-12-07 14:38:04 -0800 | [diff] [blame^] | 128 | // Keys added in HAL3.4 |
| 129 | if (deviceVersion < CAMERA_DEVICE_API_VERSION_3_4) { |
| 130 | // Check if HAL supports RAW_OPAQUE output |
| 131 | camera_metadata_entry entry = chars.find(ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS); |
| 132 | bool supportRawOpaque = false; |
| 133 | const int STREAM_CONFIGURATION_SIZE = 4; |
| 134 | const int STREAM_FORMAT_OFFSET = 0; |
| 135 | const int STREAM_WIDTH_OFFSET = 1; |
| 136 | const int STREAM_HEIGHT_OFFSET = 2; |
| 137 | const int STREAM_IS_INPUT_OFFSET = 3; |
| 138 | Vector<int32_t> rawOpaqueSizes; |
| 139 | |
| 140 | for (size_t i=0; i < entry.count; i += STREAM_CONFIGURATION_SIZE) { |
| 141 | int32_t format = entry.data.i32[i + STREAM_FORMAT_OFFSET]; |
| 142 | int32_t width = entry.data.i32[i + STREAM_WIDTH_OFFSET]; |
| 143 | int32_t height = entry.data.i32[i + STREAM_HEIGHT_OFFSET]; |
| 144 | int32_t isInput = entry.data.i32[i + STREAM_IS_INPUT_OFFSET]; |
| 145 | if (isInput == ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT && |
| 146 | format == HAL_PIXEL_FORMAT_RAW_OPAQUE) { |
| 147 | supportRawOpaque = true; |
| 148 | rawOpaqueSizes.push(width); |
| 149 | rawOpaqueSizes.push(height); |
| 150 | // 2 bytes per pixel. This rough estimation is only used when |
| 151 | // HAL does not fill in the opaque raw size |
| 152 | rawOpaqueSizes.push(width * height *2); |
| 153 | } |
| 154 | } |
| 155 | |
| 156 | if (supportRawOpaque) { |
| 157 | entry = chars.find(ANDROID_SENSOR_OPAQUE_RAW_SIZE); |
| 158 | if (entry.count == 0) { |
| 159 | // Fill in estimated value if HAL does not list it |
| 160 | chars.update(ANDROID_SENSOR_OPAQUE_RAW_SIZE, rawOpaqueSizes); |
| 161 | derivedCharKeys.push(ANDROID_SENSOR_OPAQUE_RAW_SIZE); |
| 162 | } |
| 163 | } |
| 164 | } |
| 165 | |
Ruben Brunk | a3b3caa | 2015-06-22 14:26:51 -0700 | [diff] [blame] | 166 | // Always add a default for the pre-correction active array if the vendor chooses to omit this |
| 167 | camera_metadata_entry entry = chars.find(ANDROID_SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE); |
| 168 | if (entry.count == 0) { |
Ruben Brunk | eff134a | 2015-07-17 15:22:01 -0700 | [diff] [blame] | 169 | Vector<int32_t> preCorrectionArray; |
Ruben Brunk | a3b3caa | 2015-06-22 14:26:51 -0700 | [diff] [blame] | 170 | entry = chars.find(ANDROID_SENSOR_INFO_ACTIVE_ARRAY_SIZE); |
Ruben Brunk | eff134a | 2015-07-17 15:22:01 -0700 | [diff] [blame] | 171 | preCorrectionArray.appendArray(entry.data.i32, entry.count); |
| 172 | chars.update(ANDROID_SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE, preCorrectionArray); |
Yin-Chia Yeh | e9154ce | 2015-12-07 14:38:04 -0800 | [diff] [blame^] | 173 | derivedCharKeys.push(ANDROID_SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE); |
Ruben Brunk | a3b3caa | 2015-06-22 14:26:51 -0700 | [diff] [blame] | 174 | } |
| 175 | |
Yin-Chia Yeh | e9154ce | 2015-12-07 14:38:04 -0800 | [diff] [blame^] | 176 | // Add those newly added keys to AVAILABLE_CHARACTERISTICS_KEYS |
| 177 | // This has to be done at this end of this function. |
| 178 | entry = chars.find(ANDROID_REQUEST_AVAILABLE_CHARACTERISTICS_KEYS); |
| 179 | Vector<int32_t> availableCharsKeys; |
| 180 | availableCharsKeys.setCapacity(entry.count + derivedCharKeys.size()); |
| 181 | for (size_t i = 0; i < entry.count; i++) { |
| 182 | availableCharsKeys.push(entry.data.i32[i]); |
| 183 | } |
| 184 | for (size_t i = 0; i < derivedCharKeys.size(); i++) { |
| 185 | availableCharsKeys.push(derivedCharKeys[i]); |
| 186 | } |
| 187 | chars.update(ANDROID_REQUEST_AVAILABLE_CHARACTERISTICS_KEYS, availableCharsKeys); |
Yin-Chia Yeh | e074a93 | 2015-01-30 10:29:02 -0800 | [diff] [blame] | 188 | return; |
| 189 | } |
| 190 | |
| 191 | CameraModule::CameraModule(camera_module_t *module) { |
| 192 | if (module == NULL) { |
| 193 | ALOGE("%s: camera hardware module must not be null", __FUNCTION__); |
| 194 | assert(0); |
| 195 | } |
Yin-Chia Yeh | e074a93 | 2015-01-30 10:29:02 -0800 | [diff] [blame] | 196 | mModule = module; |
Yin-Chia Yeh | e074a93 | 2015-01-30 10:29:02 -0800 | [diff] [blame] | 197 | } |
| 198 | |
Chien-Yu Chen | 944f843 | 2015-07-01 17:08:03 -0700 | [diff] [blame] | 199 | CameraModule::~CameraModule() |
| 200 | { |
| 201 | while (mCameraInfoMap.size() > 0) { |
| 202 | camera_info cameraInfo = mCameraInfoMap.editValueAt(0); |
| 203 | if (cameraInfo.static_camera_characteristics != NULL) { |
| 204 | free_camera_metadata( |
| 205 | const_cast<camera_metadata_t*>(cameraInfo.static_camera_characteristics)); |
| 206 | } |
| 207 | mCameraInfoMap.removeItemsAt(0); |
| 208 | } |
| 209 | } |
| 210 | |
Eino-Ville Talvala | 1527f07 | 2015-04-07 15:55:31 -0700 | [diff] [blame] | 211 | int CameraModule::init() { |
Eino-Ville Talvala | a84bbe6 | 2015-09-08 17:59:17 -0700 | [diff] [blame] | 212 | ATRACE_CALL(); |
| 213 | int res = OK; |
Eino-Ville Talvala | 1527f07 | 2015-04-07 15:55:31 -0700 | [diff] [blame] | 214 | if (getModuleApiVersion() >= CAMERA_MODULE_API_VERSION_2_4 && |
| 215 | mModule->init != NULL) { |
Eino-Ville Talvala | a84bbe6 | 2015-09-08 17:59:17 -0700 | [diff] [blame] | 216 | ATRACE_BEGIN("camera_module->init"); |
| 217 | res = mModule->init(); |
| 218 | ATRACE_END(); |
Eino-Ville Talvala | 1527f07 | 2015-04-07 15:55:31 -0700 | [diff] [blame] | 219 | } |
Eino-Ville Talvala | a84bbe6 | 2015-09-08 17:59:17 -0700 | [diff] [blame] | 220 | mCameraInfoMap.setCapacity(getNumberOfCameras()); |
| 221 | return res; |
Eino-Ville Talvala | 1527f07 | 2015-04-07 15:55:31 -0700 | [diff] [blame] | 222 | } |
| 223 | |
Yin-Chia Yeh | e074a93 | 2015-01-30 10:29:02 -0800 | [diff] [blame] | 224 | int CameraModule::getCameraInfo(int cameraId, struct camera_info *info) { |
Eino-Ville Talvala | a84bbe6 | 2015-09-08 17:59:17 -0700 | [diff] [blame] | 225 | ATRACE_CALL(); |
Yin-Chia Yeh | e074a93 | 2015-01-30 10:29:02 -0800 | [diff] [blame] | 226 | Mutex::Autolock lock(mCameraInfoLock); |
Chien-Yu Chen | 676b21b | 2015-02-24 10:28:19 -0800 | [diff] [blame] | 227 | if (cameraId < 0) { |
Yin-Chia Yeh | e074a93 | 2015-01-30 10:29:02 -0800 | [diff] [blame] | 228 | ALOGE("%s: Invalid camera ID %d", __FUNCTION__, cameraId); |
| 229 | return -EINVAL; |
| 230 | } |
| 231 | |
Yin-Chia Yeh | b6dc0bf | 2015-02-18 14:42:16 -0800 | [diff] [blame] | 232 | // Only override static_camera_characteristics for API2 devices |
| 233 | int apiVersion = mModule->common.module_api_version; |
| 234 | if (apiVersion < CAMERA_MODULE_API_VERSION_2_0) { |
Eino-Ville Talvala | a84bbe6 | 2015-09-08 17:59:17 -0700 | [diff] [blame] | 235 | int ret; |
| 236 | ATRACE_BEGIN("camera_module->get_camera_info"); |
| 237 | ret = mModule->get_camera_info(cameraId, info); |
Yin-Chia Yeh | 654b4bf | 2015-12-08 12:19:31 -0800 | [diff] [blame] | 238 | // Fill in this so CameraService won't be confused by |
| 239 | // possibly 0 device_version |
| 240 | info->device_version = CAMERA_DEVICE_API_VERSION_1_0; |
Eino-Ville Talvala | a84bbe6 | 2015-09-08 17:59:17 -0700 | [diff] [blame] | 241 | ATRACE_END(); |
| 242 | return ret; |
Yin-Chia Yeh | b6dc0bf | 2015-02-18 14:42:16 -0800 | [diff] [blame] | 243 | } |
| 244 | |
Chien-Yu Chen | 676b21b | 2015-02-24 10:28:19 -0800 | [diff] [blame] | 245 | ssize_t index = mCameraInfoMap.indexOfKey(cameraId); |
| 246 | if (index == NAME_NOT_FOUND) { |
| 247 | // Get camera info from raw module and cache it |
Yin-Chia Yeh | 54298b3 | 2015-03-24 16:51:41 -0700 | [diff] [blame] | 248 | camera_info rawInfo, cameraInfo; |
Eino-Ville Talvala | a84bbe6 | 2015-09-08 17:59:17 -0700 | [diff] [blame] | 249 | ATRACE_BEGIN("camera_module->get_camera_info"); |
Yin-Chia Yeh | e074a93 | 2015-01-30 10:29:02 -0800 | [diff] [blame] | 250 | int ret = mModule->get_camera_info(cameraId, &rawInfo); |
Eino-Ville Talvala | a84bbe6 | 2015-09-08 17:59:17 -0700 | [diff] [blame] | 251 | ATRACE_END(); |
Yin-Chia Yeh | e074a93 | 2015-01-30 10:29:02 -0800 | [diff] [blame] | 252 | if (ret != 0) { |
| 253 | return ret; |
| 254 | } |
Zhijun He | 9c5af61 | 2015-05-04 16:34:37 -0700 | [diff] [blame] | 255 | int deviceVersion = rawInfo.device_version; |
Eino-Ville Talvala | d309fb9 | 2015-11-25 12:12:45 -0800 | [diff] [blame] | 256 | if (deviceVersion < CAMERA_DEVICE_API_VERSION_3_0) { |
Yin-Chia Yeh | 7768ded | 2015-04-15 12:16:02 -0700 | [diff] [blame] | 257 | // static_camera_characteristics is invalid |
| 258 | *info = rawInfo; |
| 259 | return ret; |
| 260 | } |
Yin-Chia Yeh | 54298b3 | 2015-03-24 16:51:41 -0700 | [diff] [blame] | 261 | CameraMetadata m; |
Yin-Chia Yeh | e074a93 | 2015-01-30 10:29:02 -0800 | [diff] [blame] | 262 | m = rawInfo.static_camera_characteristics; |
Yin-Chia Yeh | b6dc0bf | 2015-02-18 14:42:16 -0800 | [diff] [blame] | 263 | deriveCameraCharacteristicsKeys(rawInfo.device_version, m); |
Yin-Chia Yeh | 54298b3 | 2015-03-24 16:51:41 -0700 | [diff] [blame] | 264 | cameraInfo = rawInfo; |
Chien-Yu Chen | 944f843 | 2015-07-01 17:08:03 -0700 | [diff] [blame] | 265 | cameraInfo.static_camera_characteristics = m.release(); |
| 266 | index = mCameraInfoMap.add(cameraId, cameraInfo); |
Yin-Chia Yeh | e074a93 | 2015-01-30 10:29:02 -0800 | [diff] [blame] | 267 | } |
Chien-Yu Chen | 676b21b | 2015-02-24 10:28:19 -0800 | [diff] [blame] | 268 | |
| 269 | assert(index != NAME_NOT_FOUND); |
| 270 | // return the cached camera info |
Yin-Chia Yeh | 54298b3 | 2015-03-24 16:51:41 -0700 | [diff] [blame] | 271 | *info = mCameraInfoMap[index]; |
Eino-Ville Talvala | 1527f07 | 2015-04-07 15:55:31 -0700 | [diff] [blame] | 272 | return OK; |
Yin-Chia Yeh | e074a93 | 2015-01-30 10:29:02 -0800 | [diff] [blame] | 273 | } |
| 274 | |
| 275 | int CameraModule::open(const char* id, struct hw_device_t** device) { |
Eino-Ville Talvala | a84bbe6 | 2015-09-08 17:59:17 -0700 | [diff] [blame] | 276 | int res; |
| 277 | ATRACE_BEGIN("camera_module->open"); |
| 278 | res = filterOpenErrorCode(mModule->common.methods->open(&mModule->common, id, device)); |
| 279 | ATRACE_END(); |
| 280 | return res; |
Yin-Chia Yeh | e074a93 | 2015-01-30 10:29:02 -0800 | [diff] [blame] | 281 | } |
| 282 | |
| 283 | int CameraModule::openLegacy( |
| 284 | const char* id, uint32_t halVersion, struct hw_device_t** device) { |
Eino-Ville Talvala | a84bbe6 | 2015-09-08 17:59:17 -0700 | [diff] [blame] | 285 | int res; |
| 286 | ATRACE_BEGIN("camera_module->open_legacy"); |
| 287 | res = mModule->open_legacy(&mModule->common, id, halVersion, device); |
| 288 | ATRACE_END(); |
| 289 | return res; |
Yin-Chia Yeh | e074a93 | 2015-01-30 10:29:02 -0800 | [diff] [blame] | 290 | } |
| 291 | |
Yin-Chia Yeh | e074a93 | 2015-01-30 10:29:02 -0800 | [diff] [blame] | 292 | int CameraModule::getNumberOfCameras() { |
Eino-Ville Talvala | a84bbe6 | 2015-09-08 17:59:17 -0700 | [diff] [blame] | 293 | int numCameras; |
| 294 | ATRACE_BEGIN("camera_module->get_number_of_cameras"); |
| 295 | numCameras = mModule->get_number_of_cameras(); |
| 296 | ATRACE_END(); |
| 297 | return numCameras; |
Yin-Chia Yeh | e074a93 | 2015-01-30 10:29:02 -0800 | [diff] [blame] | 298 | } |
| 299 | |
| 300 | int CameraModule::setCallbacks(const camera_module_callbacks_t *callbacks) { |
Eino-Ville Talvala | a84bbe6 | 2015-09-08 17:59:17 -0700 | [diff] [blame] | 301 | int res; |
| 302 | ATRACE_BEGIN("camera_module->set_callbacks"); |
| 303 | res = mModule->set_callbacks(callbacks); |
| 304 | ATRACE_END(); |
| 305 | return res; |
Yin-Chia Yeh | e074a93 | 2015-01-30 10:29:02 -0800 | [diff] [blame] | 306 | } |
| 307 | |
| 308 | bool CameraModule::isVendorTagDefined() { |
| 309 | return mModule->get_vendor_tag_ops != NULL; |
| 310 | } |
| 311 | |
| 312 | void CameraModule::getVendorTagOps(vendor_tag_ops_t* ops) { |
| 313 | if (mModule->get_vendor_tag_ops) { |
Eino-Ville Talvala | a84bbe6 | 2015-09-08 17:59:17 -0700 | [diff] [blame] | 314 | ATRACE_BEGIN("camera_module->get_vendor_tag_ops"); |
Yin-Chia Yeh | e074a93 | 2015-01-30 10:29:02 -0800 | [diff] [blame] | 315 | mModule->get_vendor_tag_ops(ops); |
Eino-Ville Talvala | a84bbe6 | 2015-09-08 17:59:17 -0700 | [diff] [blame] | 316 | ATRACE_END(); |
Yin-Chia Yeh | e074a93 | 2015-01-30 10:29:02 -0800 | [diff] [blame] | 317 | } |
| 318 | } |
| 319 | |
| 320 | int CameraModule::setTorchMode(const char* camera_id, bool enable) { |
Eino-Ville Talvala | a84bbe6 | 2015-09-08 17:59:17 -0700 | [diff] [blame] | 321 | int res; |
| 322 | ATRACE_BEGIN("camera_module->set_torch_mode"); |
| 323 | res = mModule->set_torch_mode(camera_id, enable); |
| 324 | ATRACE_END(); |
| 325 | return res; |
Yin-Chia Yeh | e074a93 | 2015-01-30 10:29:02 -0800 | [diff] [blame] | 326 | } |
| 327 | |
Chien-Yu Chen | d231fd6 | 2015-02-25 16:04:22 -0800 | [diff] [blame] | 328 | status_t CameraModule::filterOpenErrorCode(status_t err) { |
| 329 | switch(err) { |
| 330 | case NO_ERROR: |
| 331 | case -EBUSY: |
| 332 | case -EINVAL: |
| 333 | case -EUSERS: |
| 334 | return err; |
| 335 | default: |
| 336 | break; |
| 337 | } |
| 338 | return -ENODEV; |
| 339 | } |
| 340 | |
Chien-Yu Chen | 676b21b | 2015-02-24 10:28:19 -0800 | [diff] [blame] | 341 | uint16_t CameraModule::getModuleApiVersion() { |
| 342 | return mModule->common.module_api_version; |
| 343 | } |
| 344 | |
| 345 | const char* CameraModule::getModuleName() { |
| 346 | return mModule->common.name; |
| 347 | } |
| 348 | |
| 349 | uint16_t CameraModule::getHalApiVersion() { |
| 350 | return mModule->common.hal_api_version; |
| 351 | } |
| 352 | |
| 353 | const char* CameraModule::getModuleAuthor() { |
| 354 | return mModule->common.author; |
| 355 | } |
| 356 | |
| 357 | void* CameraModule::getDso() { |
| 358 | return mModule->common.dso; |
| 359 | } |
Chien-Yu Chen | d231fd6 | 2015-02-25 16:04:22 -0800 | [diff] [blame] | 360 | |
Yin-Chia Yeh | e074a93 | 2015-01-30 10:29:02 -0800 | [diff] [blame] | 361 | }; // namespace android |