// SPDX-License-Identifier: Apache-2.0
//
+soong_config_module_type {
+ name: "extra_ids",
+ module_type: "cc_defaults",
+ config_namespace: "samsungCameraVars",
+ value_variables: ["extra_ids"],
+ properties: ["cppflags"],
+}
+
+extra_ids {
+ name: "extra_id_defaults",
+ soong_config_variables: {
+ extra_ids: {
+ cppflags: ["-DEXTRA_IDS=%s"],
+ },
+ },
+}
+
cc_binary {
name: "android.hardware.camera.provider-service.samsung",
- defaults: ["samsung_camera3_defaults"],
+ defaults: [
+ "extra_id_defaults",
+ "samsung_camera3_defaults"
+ ],
init_rc: ["android.hardware.camera.provider-service.samsung.rc"],
vintf_fragments: ["android.hardware.camera.provider-service.samsung.xml"],
vendor: true,
CameraProvider::~CameraProvider() {}
+bool CameraProvider::initCamera(int id) {
+ struct camera_info info;
+ auto rc = mModule->getCameraInfo(id, &info);
+ if (rc != NO_ERROR) {
+ ALOGE("%s: Camera info query failed!", __func__);
+ return true;
+ }
+
+ if (checkCameraVersion(id, info) != OK) {
+ ALOGE("%s: Camera version check failed!", __func__);
+ return true;
+ }
+
+ char cameraId[kMaxCameraIdLen];
+ snprintf(cameraId, sizeof(cameraId), "%d", id);
+ std::string cameraIdStr(cameraId);
+ mCameraStatusMap[cameraIdStr] = CAMERA_DEVICE_STATUS_PRESENT;
+
+ addDeviceNames(id);
+
+ return false;
+}
+
bool CameraProvider::initialize() {
camera_module_t* rawModule;
int err = hw_get_module(CAMERA_HARDWARE_MODULE_ID, (const hw_module_t**)&rawModule);
mNumberOfLegacyCameras = mModule->getNumberOfCameras();
for (int i = 0; i < mNumberOfLegacyCameras; i++) {
- struct camera_info info;
- auto rc = mModule->getCameraInfo(i, &info);
- if (rc != NO_ERROR) {
- ALOGE("%s: Camera info query failed!", __func__);
+ if (initCamera(i)) {
mModule.clear();
return true;
}
-
- if (checkCameraVersion(i, info) != OK) {
- ALOGE("%s: Camera version check failed!", __func__);
+ }
+ std::vector<int> extraIDs = {
+#ifdef EXTRA_IDS
+ EXTRA_IDS
+#endif
+ };
+ for (int i : extraIDs) {
+ if (initCamera(i)) {
mModule.clear();
return true;
+ } else {
+ mNumberOfLegacyCameras++;
}
-
- char cameraId[kMaxCameraIdLen];
- snprintf(cameraId, sizeof(cameraId), "%d", i);
- std::string cameraIdStr(cameraId);
- mCameraStatusMap[cameraIdStr] = CAMERA_DEVICE_STATUS_PRESENT;
-
- addDeviceNames(i);
}
return false; // mInitFailed
-soong_config_module_type {
- name: "extra_ids",
- module_type: "cc_defaults",
- config_namespace: "samsungCameraVars",
- value_variables: ["extra_ids"],
- properties: ["cppflags"],
-}
-
-extra_ids {
- name: "extra_id_defaults",
- soong_config_variables: {
- extra_ids: {
- cppflags: ["-DEXTRA_IDS=%s"],
- },
- },
-}
-
cc_library_shared {
name: "android.hardware.camera.provider@2.5-legacy.samsung",
defaults: ["extra_id_defaults"],