1 /*
2 * Copyright (C) 2016 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 "CamComm1.0-CamModule"
18 #define ATRACE_TAG ATRACE_TAG_CAMERA
19 // #define LOG_NDEBUG 0
20
21 #include <utils/Trace.h>
22
23 #include "CameraModule.h"
24
25 namespace android {
26 namespace hardware {
27 namespace camera {
28 namespace common {
29 namespace helper {
30
deriveCameraCharacteristicsKeys(uint32_t deviceVersion,CameraMetadata & chars)31 void CameraModule::deriveCameraCharacteristicsKeys(uint32_t deviceVersion, CameraMetadata& chars) {
32 ATRACE_CALL();
33
34 Vector<int32_t> derivedCharKeys;
35 Vector<int32_t> derivedRequestKeys;
36 Vector<int32_t> derivedResultKeys;
37 // Keys added in HAL3.3
38 if (deviceVersion < CAMERA_DEVICE_API_VERSION_3_3) {
39 Vector<uint8_t> controlModes;
40 uint8_t data = ANDROID_CONTROL_AE_LOCK_AVAILABLE_TRUE;
41 chars.update(ANDROID_CONTROL_AE_LOCK_AVAILABLE, &data, /*count*/ 1);
42 data = ANDROID_CONTROL_AWB_LOCK_AVAILABLE_TRUE;
43 chars.update(ANDROID_CONTROL_AWB_LOCK_AVAILABLE, &data, /*count*/ 1);
44 controlModes.push(ANDROID_CONTROL_MODE_AUTO);
45 camera_metadata_entry entry = chars.find(ANDROID_CONTROL_AVAILABLE_SCENE_MODES);
46 if (entry.count > 1 || entry.data.u8[0] != ANDROID_CONTROL_SCENE_MODE_DISABLED) {
47 controlModes.push(ANDROID_CONTROL_MODE_USE_SCENE_MODE);
48 }
49
50 // Only advertise CONTROL_OFF mode if 3A manual controls are supported.
51 bool isManualAeSupported = false;
52 bool isManualAfSupported = false;
53 bool isManualAwbSupported = false;
54 entry = chars.find(ANDROID_CONTROL_AE_AVAILABLE_MODES);
55 if (entry.count > 0) {
56 for (size_t i = 0; i < entry.count; i++) {
57 if (entry.data.u8[i] == ANDROID_CONTROL_AE_MODE_OFF) {
58 isManualAeSupported = true;
59 break;
60 }
61 }
62 }
63 entry = chars.find(ANDROID_CONTROL_AF_AVAILABLE_MODES);
64 if (entry.count > 0) {
65 for (size_t i = 0; i < entry.count; i++) {
66 if (entry.data.u8[i] == ANDROID_CONTROL_AF_MODE_OFF) {
67 isManualAfSupported = true;
68 break;
69 }
70 }
71 }
72 entry = chars.find(ANDROID_CONTROL_AWB_AVAILABLE_MODES);
73 if (entry.count > 0) {
74 for (size_t i = 0; i < entry.count; i++) {
75 if (entry.data.u8[i] == ANDROID_CONTROL_AWB_MODE_OFF) {
76 isManualAwbSupported = true;
77 break;
78 }
79 }
80 }
81 if (isManualAeSupported && isManualAfSupported && isManualAwbSupported) {
82 controlModes.push(ANDROID_CONTROL_MODE_OFF);
83 }
84
85 chars.update(ANDROID_CONTROL_AVAILABLE_MODES, controlModes);
86
87 entry = chars.find(ANDROID_REQUEST_AVAILABLE_REQUEST_KEYS);
88 // HAL3.2 devices passing existing CTS test should all support all LSC modes and LSC map
89 bool lensShadingModeSupported = false;
90 if (entry.count > 0) {
91 for (size_t i = 0; i < entry.count; i++) {
92 if (entry.data.i32[i] == ANDROID_SHADING_MODE) {
93 lensShadingModeSupported = true;
94 break;
95 }
96 }
97 }
98 Vector<uint8_t> lscModes;
99 Vector<uint8_t> lscMapModes;
100 lscModes.push(ANDROID_SHADING_MODE_FAST);
101 lscModes.push(ANDROID_SHADING_MODE_HIGH_QUALITY);
102 lscMapModes.push(ANDROID_STATISTICS_LENS_SHADING_MAP_MODE_OFF);
103 if (lensShadingModeSupported) {
104 lscModes.push(ANDROID_SHADING_MODE_OFF);
105 lscMapModes.push(ANDROID_STATISTICS_LENS_SHADING_MAP_MODE_ON);
106 }
107 chars.update(ANDROID_SHADING_AVAILABLE_MODES, lscModes);
108 chars.update(ANDROID_STATISTICS_INFO_AVAILABLE_LENS_SHADING_MAP_MODES, lscMapModes);
109
110 derivedCharKeys.push(ANDROID_CONTROL_AE_LOCK_AVAILABLE);
111 derivedCharKeys.push(ANDROID_CONTROL_AWB_LOCK_AVAILABLE);
112 derivedCharKeys.push(ANDROID_CONTROL_AVAILABLE_MODES);
113 derivedCharKeys.push(ANDROID_SHADING_AVAILABLE_MODES);
114 derivedCharKeys.push(ANDROID_STATISTICS_INFO_AVAILABLE_LENS_SHADING_MAP_MODES);
115
116 // Need update android.control.availableHighSpeedVideoConfigurations since HAL3.3
117 // adds batch size to this array.
118 entry = chars.find(ANDROID_CONTROL_AVAILABLE_HIGH_SPEED_VIDEO_CONFIGURATIONS);
119 if (entry.count > 0) {
120 Vector<int32_t> highSpeedConfig;
121 for (size_t i = 0; i < entry.count; i += 4) {
122 highSpeedConfig.add(entry.data.i32[i]); // width
123 highSpeedConfig.add(entry.data.i32[i + 1]); // height
124 highSpeedConfig.add(entry.data.i32[i + 2]); // fps_min
125 highSpeedConfig.add(entry.data.i32[i + 3]); // fps_max
126 highSpeedConfig.add(1); // batchSize_max. default to 1 for HAL3.2
127 }
128 chars.update(ANDROID_CONTROL_AVAILABLE_HIGH_SPEED_VIDEO_CONFIGURATIONS,
129 highSpeedConfig);
130 }
131 }
132
133 // Keys added in HAL3.4
134 if (deviceVersion < CAMERA_DEVICE_API_VERSION_3_4) {
135 // Check if HAL supports RAW_OPAQUE output
136 camera_metadata_entry entry = chars.find(ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS);
137 bool supportRawOpaque = false;
138 bool supportAnyRaw = false;
139 const int STREAM_CONFIGURATION_SIZE = 4;
140 const int STREAM_FORMAT_OFFSET = 0;
141 const int STREAM_WIDTH_OFFSET = 1;
142 const int STREAM_HEIGHT_OFFSET = 2;
143 const int STREAM_IS_INPUT_OFFSET = 3;
144 Vector<int32_t> rawOpaqueSizes;
145
146 for (size_t i = 0; i < entry.count; i += STREAM_CONFIGURATION_SIZE) {
147 int32_t format = entry.data.i32[i + STREAM_FORMAT_OFFSET];
148 int32_t width = entry.data.i32[i + STREAM_WIDTH_OFFSET];
149 int32_t height = entry.data.i32[i + STREAM_HEIGHT_OFFSET];
150 int32_t isInput = entry.data.i32[i + STREAM_IS_INPUT_OFFSET];
151 if (isInput == ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT &&
152 format == HAL_PIXEL_FORMAT_RAW_OPAQUE) {
153 supportRawOpaque = true;
154 rawOpaqueSizes.push(width);
155 rawOpaqueSizes.push(height);
156 // 2 bytes per pixel. This rough estimation is only used when
157 // HAL does not fill in the opaque raw size
158 rawOpaqueSizes.push(width * height * 2);
159 }
160 if (isInput == ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT &&
161 (format == HAL_PIXEL_FORMAT_RAW16 || format == HAL_PIXEL_FORMAT_RAW10 ||
162 format == HAL_PIXEL_FORMAT_RAW12 || format == HAL_PIXEL_FORMAT_RAW_OPAQUE)) {
163 supportAnyRaw = true;
164 }
165 }
166
167 if (supportRawOpaque) {
168 entry = chars.find(ANDROID_SENSOR_OPAQUE_RAW_SIZE);
169 if (entry.count == 0) {
170 // Fill in estimated value if HAL does not list it
171 chars.update(ANDROID_SENSOR_OPAQUE_RAW_SIZE, rawOpaqueSizes);
172 derivedCharKeys.push(ANDROID_SENSOR_OPAQUE_RAW_SIZE);
173 }
174 }
175
176 // Check if HAL supports any RAW output, if so, fill in postRawSensitivityBoost range
177 if (supportAnyRaw) {
178 int32_t defaultRange[2] = {100, 100};
179 entry = chars.find(ANDROID_CONTROL_POST_RAW_SENSITIVITY_BOOST_RANGE);
180 if (entry.count == 0) {
181 // Fill in default value (100, 100)
182 chars.update(ANDROID_CONTROL_POST_RAW_SENSITIVITY_BOOST_RANGE, defaultRange, 2);
183 derivedCharKeys.push(ANDROID_CONTROL_POST_RAW_SENSITIVITY_BOOST_RANGE);
184 // Actual request/results will be derived by camera device.
185 derivedRequestKeys.push(ANDROID_CONTROL_POST_RAW_SENSITIVITY_BOOST);
186 derivedResultKeys.push(ANDROID_CONTROL_POST_RAW_SENSITIVITY_BOOST);
187 }
188 }
189 }
190
191 // Add those newly added keys to AVAILABLE_CHARACTERISTICS_KEYS
192 // This has to be done at this end of this function.
193 if (derivedCharKeys.size() > 0) {
194 appendAvailableKeys(chars, ANDROID_REQUEST_AVAILABLE_CHARACTERISTICS_KEYS, derivedCharKeys);
195 }
196 if (derivedRequestKeys.size() > 0) {
197 appendAvailableKeys(chars, ANDROID_REQUEST_AVAILABLE_REQUEST_KEYS, derivedRequestKeys);
198 }
199 if (derivedResultKeys.size() > 0) {
200 appendAvailableKeys(chars, ANDROID_REQUEST_AVAILABLE_RESULT_KEYS, derivedResultKeys);
201 }
202 return;
203 }
204
appendAvailableKeys(CameraMetadata & chars,int32_t keyTag,const Vector<int32_t> & appendKeys)205 void CameraModule::appendAvailableKeys(CameraMetadata& chars, int32_t keyTag,
206 const Vector<int32_t>& appendKeys) {
207 camera_metadata_entry entry = chars.find(keyTag);
208 Vector<int32_t> availableKeys;
209 availableKeys.setCapacity(entry.count + appendKeys.size());
210 for (size_t i = 0; i < entry.count; i++) {
211 availableKeys.push(entry.data.i32[i]);
212 }
213 for (size_t i = 0; i < appendKeys.size(); i++) {
214 availableKeys.push(appendKeys[i]);
215 }
216 chars.update(keyTag, availableKeys);
217 }
218
CameraModule(camera_module_t * module)219 CameraModule::CameraModule(camera_module_t* module) : mNumberOfCameras(0) {
220 if (module == NULL) {
221 ALOGE("%s: camera hardware module must not be null", __FUNCTION__);
222 assert(0);
223 }
224 mModule = module;
225 }
226
~CameraModule()227 CameraModule::~CameraModule() {
228 while (mCameraInfoMap.size() > 0) {
229 camera_info cameraInfo = mCameraInfoMap.editValueAt(0);
230 if (cameraInfo.static_camera_characteristics != NULL) {
231 free_camera_metadata(
232 const_cast<camera_metadata_t*>(cameraInfo.static_camera_characteristics));
233 }
234 mCameraInfoMap.removeItemsAt(0);
235 }
236
237 while (mPhysicalCameraInfoMap.size() > 0) {
238 camera_metadata_t* metadata = mPhysicalCameraInfoMap.editValueAt(0);
239 if (metadata != NULL) {
240 free_camera_metadata(metadata);
241 }
242 mPhysicalCameraInfoMap.removeItemsAt(0);
243 }
244 }
245
init()246 int CameraModule::init() {
247 ATRACE_CALL();
248 int res = OK;
249 if (getModuleApiVersion() >= CAMERA_MODULE_API_VERSION_2_4 && mModule->init != NULL) {
250 ATRACE_BEGIN("camera_module->init");
251 res = mModule->init();
252 ATRACE_END();
253 }
254 mNumberOfCameras = getNumberOfCameras();
255 mCameraInfoMap.setCapacity(mNumberOfCameras);
256 return res;
257 }
258
getCameraInfo(int cameraId,struct camera_info * info)259 int CameraModule::getCameraInfo(int cameraId, struct camera_info* info) {
260 ATRACE_CALL();
261 Mutex::Autolock lock(mCameraInfoLock);
262 if (cameraId < 0) {
263 ALOGE("%s: Invalid camera ID %d", __FUNCTION__, cameraId);
264 return -EINVAL;
265 }
266
267 // Only override static_camera_characteristics for API2 devices
268 int apiVersion = mModule->common.module_api_version;
269 if (apiVersion < CAMERA_MODULE_API_VERSION_2_0) {
270 int ret;
271 ATRACE_BEGIN("camera_module->get_camera_info");
272 ret = mModule->get_camera_info(cameraId, info);
273 // Fill in this so CameraService won't be confused by
274 // possibly 0 device_version
275 info->device_version = CAMERA_DEVICE_API_VERSION_1_0;
276 ATRACE_END();
277 return ret;
278 }
279
280 ssize_t index = mCameraInfoMap.indexOfKey(cameraId);
281 if (index == NAME_NOT_FOUND) {
282 // Get camera info from raw module and cache it
283 camera_info rawInfo, cameraInfo;
284 ATRACE_BEGIN("camera_module->get_camera_info");
285 int ret = mModule->get_camera_info(cameraId, &rawInfo);
286 ATRACE_END();
287 if (ret != 0) {
288 return ret;
289 }
290 int deviceVersion = rawInfo.device_version;
291 if (deviceVersion < CAMERA_DEVICE_API_VERSION_3_0) {
292 // static_camera_characteristics is invalid
293 *info = rawInfo;
294 return ret;
295 }
296 CameraMetadata m;
297 m.append(rawInfo.static_camera_characteristics);
298 deriveCameraCharacteristicsKeys(rawInfo.device_version, m);
299 cameraInfo = rawInfo;
300 cameraInfo.static_camera_characteristics = m.release();
301 index = mCameraInfoMap.add(cameraId, cameraInfo);
302 }
303
304 assert(index != NAME_NOT_FOUND);
305 // return the cached camera info
306 *info = mCameraInfoMap[index];
307 return OK;
308 }
309
getPhysicalCameraInfo(int physicalCameraId,camera_metadata_t ** physicalInfo)310 int CameraModule::getPhysicalCameraInfo(int physicalCameraId, camera_metadata_t** physicalInfo) {
311 ATRACE_CALL();
312 Mutex::Autolock lock(mCameraInfoLock);
313 if (physicalCameraId < mNumberOfCameras) {
314 ALOGE("%s: Invalid physical camera ID %d", __FUNCTION__, physicalCameraId);
315 return -EINVAL;
316 }
317
318 // Only query physical camera info for 2.5 version for newer
319 int apiVersion = mModule->common.module_api_version;
320 if (apiVersion < CAMERA_MODULE_API_VERSION_2_5) {
321 ALOGE("%s: Module version must be at least 2.5 to handle getPhysicalCameraInfo",
322 __FUNCTION__);
323 return -ENODEV;
324 }
325 if (mModule->get_physical_camera_info == nullptr) {
326 ALOGE("%s: get_physical_camera is NULL for module version 2.5", __FUNCTION__);
327 return -EINVAL;
328 }
329
330 ssize_t index = mPhysicalCameraInfoMap.indexOfKey(physicalCameraId);
331 if (index == NAME_NOT_FOUND) {
332 // Get physical camera characteristics, and cache it
333 camera_metadata_t* info = nullptr;
334 ATRACE_BEGIN("camera_module->get_physical_camera_info");
335 int ret = mModule->get_physical_camera_info(physicalCameraId, &info);
336 ATRACE_END();
337 if (ret != 0) {
338 return ret;
339 }
340
341 // The camera_metadata_t returned by get_physical_camera_info could be using
342 // more memory than necessary due to unused reserved space. Reduce the
343 // size by appending it to a new CameraMetadata object, which internally
344 // calls resizeIfNeeded.
345 CameraMetadata m;
346 m.append(info);
347 camera_metadata_t* derivedMetadata = m.release();
348 index = mPhysicalCameraInfoMap.add(physicalCameraId, derivedMetadata);
349 }
350
351 assert(index != NAME_NOT_FOUND);
352 *physicalInfo = mPhysicalCameraInfoMap[index];
353 return OK;
354 }
355
getDeviceVersion(int cameraId)356 int CameraModule::getDeviceVersion(int cameraId) {
357 ssize_t index = mDeviceVersionMap.indexOfKey(cameraId);
358 if (index == NAME_NOT_FOUND) {
359 int deviceVersion;
360 if (getModuleApiVersion() >= CAMERA_MODULE_API_VERSION_2_0) {
361 struct camera_info info;
362 getCameraInfo(cameraId, &info);
363 deviceVersion = info.device_version;
364 } else {
365 deviceVersion = CAMERA_DEVICE_API_VERSION_1_0;
366 }
367 index = mDeviceVersionMap.add(cameraId, deviceVersion);
368 }
369 assert(index != NAME_NOT_FOUND);
370 return mDeviceVersionMap[index];
371 }
372
open(const char * id,struct hw_device_t ** device)373 int CameraModule::open(const char* id, struct hw_device_t** device) {
374 int res;
375 ATRACE_BEGIN("camera_module->open");
376 res = filterOpenErrorCode(mModule->common.methods->open(&mModule->common, id, device));
377 ATRACE_END();
378 return res;
379 }
380
isOpenLegacyDefined() const381 bool CameraModule::isOpenLegacyDefined() const {
382 if (getModuleApiVersion() < CAMERA_MODULE_API_VERSION_2_3) {
383 return false;
384 }
385 return mModule->open_legacy != NULL;
386 }
387
openLegacy(const char * id,uint32_t halVersion,struct hw_device_t ** device)388 int CameraModule::openLegacy(const char* id, uint32_t halVersion, struct hw_device_t** device) {
389 int res;
390 ATRACE_BEGIN("camera_module->open_legacy");
391 res = mModule->open_legacy(&mModule->common, id, halVersion, device);
392 ATRACE_END();
393 return res;
394 }
395
getNumberOfCameras()396 int CameraModule::getNumberOfCameras() {
397 int numCameras;
398 ATRACE_BEGIN("camera_module->get_number_of_cameras");
399 numCameras = mModule->get_number_of_cameras();
400 ATRACE_END();
401 return numCameras;
402 }
403
setCallbacks(const camera_module_callbacks_t * callbacks)404 int CameraModule::setCallbacks(const camera_module_callbacks_t* callbacks) {
405 int res = OK;
406 ATRACE_BEGIN("camera_module->set_callbacks");
407 if (getModuleApiVersion() >= CAMERA_MODULE_API_VERSION_2_1) {
408 res = mModule->set_callbacks(callbacks);
409 }
410 ATRACE_END();
411 return res;
412 }
413
isVendorTagDefined() const414 bool CameraModule::isVendorTagDefined() const {
415 return mModule->get_vendor_tag_ops != NULL;
416 }
417
getVendorTagOps(vendor_tag_ops_t * ops)418 void CameraModule::getVendorTagOps(vendor_tag_ops_t* ops) {
419 if (mModule->get_vendor_tag_ops) {
420 ATRACE_BEGIN("camera_module->get_vendor_tag_ops");
421 mModule->get_vendor_tag_ops(ops);
422 ATRACE_END();
423 }
424 }
425
isSetTorchModeSupported() const426 bool CameraModule::isSetTorchModeSupported() const {
427 if (getModuleApiVersion() >= CAMERA_MODULE_API_VERSION_2_4) {
428 if (mModule->set_torch_mode == NULL) {
429 ALOGE("%s: Module 2.4 device must support set torch API!", __FUNCTION__);
430 return false;
431 }
432 return true;
433 }
434 return false;
435 }
436
setTorchMode(const char * camera_id,bool enable)437 int CameraModule::setTorchMode(const char* camera_id, bool enable) {
438 int res = INVALID_OPERATION;
439 if (mModule->set_torch_mode != NULL) {
440 ATRACE_BEGIN("camera_module->set_torch_mode");
441 res = mModule->set_torch_mode(camera_id, enable);
442 ATRACE_END();
443 }
444 return res;
445 }
446
isStreamCombinationSupported(int cameraId,camera_stream_combination_t * streams)447 int CameraModule::isStreamCombinationSupported(int cameraId, camera_stream_combination_t* streams) {
448 int res = INVALID_OPERATION;
449 if (mModule->is_stream_combination_supported != NULL) {
450 ATRACE_BEGIN("camera_module->is_stream_combination_supported");
451 res = mModule->is_stream_combination_supported(cameraId, streams);
452 ATRACE_END();
453 }
454 return res;
455 }
456
notifyDeviceStateChange(uint64_t deviceState)457 void CameraModule::notifyDeviceStateChange(uint64_t deviceState) {
458 if (getModuleApiVersion() >= CAMERA_MODULE_API_VERSION_2_5 &&
459 mModule->notify_device_state_change != NULL) {
460 ATRACE_BEGIN("camera_module->notify_device_state_change");
461 ALOGI("%s: calling notify_device_state_change with state %" PRId64, __FUNCTION__,
462 deviceState);
463 mModule->notify_device_state_change(deviceState);
464 ATRACE_END();
465 }
466 }
467
isLogicalMultiCamera(const common::helper::CameraMetadata & metadata,std::unordered_set<std::string> * physicalCameraIds)468 bool CameraModule::isLogicalMultiCamera(const common::helper::CameraMetadata& metadata,
469 std::unordered_set<std::string>* physicalCameraIds) {
470 if (physicalCameraIds == nullptr) {
471 ALOGE("%s: physicalCameraIds must not be null", __FUNCTION__);
472 return false;
473 }
474
475 bool isLogicalMultiCamera = false;
476 camera_metadata_ro_entry_t capabilities = metadata.find(ANDROID_REQUEST_AVAILABLE_CAPABILITIES);
477 for (size_t i = 0; i < capabilities.count; i++) {
478 if (capabilities.data.u8[i] ==
479 ANDROID_REQUEST_AVAILABLE_CAPABILITIES_LOGICAL_MULTI_CAMERA) {
480 isLogicalMultiCamera = true;
481 break;
482 }
483 }
484
485 if (isLogicalMultiCamera) {
486 camera_metadata_ro_entry_t entry = metadata.find(ANDROID_LOGICAL_MULTI_CAMERA_PHYSICAL_IDS);
487 const uint8_t* ids = entry.data.u8;
488 size_t start = 0;
489 for (size_t i = 0; i < entry.count; ++i) {
490 if (ids[i] == '\0') {
491 if (start != i) {
492 const char* physicalId = reinterpret_cast<const char*>(ids + start);
493 physicalCameraIds->emplace(physicalId);
494 }
495 start = i + 1;
496 }
497 }
498 }
499 return isLogicalMultiCamera;
500 }
501
filterOpenErrorCode(status_t err)502 status_t CameraModule::filterOpenErrorCode(status_t err) {
503 switch (err) {
504 case NO_ERROR:
505 case -EBUSY:
506 case -EINVAL:
507 case -EUSERS:
508 return err;
509 default:
510 break;
511 }
512 return -ENODEV;
513 }
514
removeCamera(int cameraId)515 void CameraModule::removeCamera(int cameraId) {
516 // Skip HAL1 devices which isn't cached in mCameraInfoMap and don't advertise
517 // static_camera_characteristics
518 if (getDeviceVersion(cameraId) >= CAMERA_DEVICE_API_VERSION_3_0) {
519 std::unordered_set<std::string> physicalIds;
520 camera_metadata_t* metadata = const_cast<camera_metadata_t*>(
521 mCameraInfoMap.valueFor(cameraId).static_camera_characteristics);
522 common::helper::CameraMetadata hidlMetadata(metadata);
523
524 if (isLogicalMultiCamera(hidlMetadata, &physicalIds)) {
525 for (const auto& id : physicalIds) {
526 int idInt = std::stoi(id);
527 if (mPhysicalCameraInfoMap.indexOfKey(idInt) >= 0) {
528 free_camera_metadata(mPhysicalCameraInfoMap[idInt]);
529 mPhysicalCameraInfoMap.removeItem(idInt);
530 } else {
531 ALOGE("%s: Cannot find corresponding static metadata for physical id %s",
532 __FUNCTION__, id.c_str());
533 }
534 }
535 }
536 }
537
538 mCameraInfoMap.removeItem(cameraId);
539 mDeviceVersionMap.removeItem(cameraId);
540 }
541
getModuleApiVersion() const542 uint16_t CameraModule::getModuleApiVersion() const {
543 return mModule->common.module_api_version;
544 }
545
getModuleName() const546 const char* CameraModule::getModuleName() const {
547 return mModule->common.name;
548 }
549
getHalApiVersion() const550 uint16_t CameraModule::getHalApiVersion() const {
551 return mModule->common.hal_api_version;
552 }
553
getModuleAuthor() const554 const char* CameraModule::getModuleAuthor() const {
555 return mModule->common.author;
556 }
557
getDso()558 void* CameraModule::getDso() {
559 return mModule->common.dso;
560 }
561
562 } // namespace helper
563 } // namespace common
564 } // namespace camera
565 } // namespace hardware
566 } // namespace android
567