summaryrefslogtreecommitdiff
path: root/src/android/camera_hal_manager.cpp
diff options
context:
space:
mode:
authorJacopo Mondi <jacopo@jmondi.org>2021-03-10 16:19:33 +0100
committerJacopo Mondi <jacopo@jmondi.org>2021-05-25 15:22:10 +0200
commit9133c5b2cc8403ca02a525845ed52bb2547bc377 (patch)
treedfe12eef0b59748f8be5f2f61106c325b5a5fdcf /src/android/camera_hal_manager.cpp
parent07c2a4257d9ef3bae35af1848f9f36ac8ce8044d (diff)
android: camera_device: Get properties from configuration
Open the HAL configuration file in the Camera HAL manager and get the camera properties for each created CameraDevice and initialize it with them. Signed-off-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
Diffstat (limited to 'src/android/camera_hal_manager.cpp')
-rw-r--r--src/android/camera_hal_manager.cpp33
1 files changed, 32 insertions, 1 deletions
diff --git a/src/android/camera_hal_manager.cpp b/src/android/camera_hal_manager.cpp
index bf3fcda7..f5b86974 100644
--- a/src/android/camera_hal_manager.cpp
+++ b/src/android/camera_hal_manager.cpp
@@ -41,6 +41,15 @@ int CameraHalManager::init()
{
cameraManager_ = std::make_unique<CameraManager>();
+ /*
+ * If the configuration file is not available the HAL only supports
+ * external cameras. If it exists but it's not valid then error out.
+ */
+ if (halConfig_.exists() && !halConfig_.isValid()) {
+ LOG(HAL, Error) << "HAL configuration file is not valid";
+ return -EINVAL;
+ }
+
/* Support camera hotplug. */
cameraManager_->cameraAdded.connect(this, &CameraHalManager::cameraAdded);
cameraManager_->cameraRemoved.connect(this, &CameraHalManager::cameraRemoved);
@@ -100,6 +109,8 @@ void CameraHalManager::cameraAdded(std::shared_ptr<Camera> cam)
auto iter = cameraIdsMap_.find(cam->id());
if (iter != cameraIdsMap_.end()) {
id = iter->second;
+ if (id >= firstExternalCameraId_)
+ isCameraExternal = true;
} else {
isCameraNew = true;
@@ -117,7 +128,27 @@ void CameraHalManager::cameraAdded(std::shared_ptr<Camera> cam)
/* Create a CameraDevice instance to wrap the libcamera Camera. */
std::unique_ptr<CameraDevice> camera = CameraDevice::create(id, cam);
- int ret = camera->initialize();
+
+ /*
+ * The configuration file must be valid, and contain a corresponding
+ * entry for internal cameras. External cameras can be initialized
+ * without configuration file.
+ */
+ if (!isCameraExternal && !halConfig_.exists()) {
+ LOG(HAL, Error)
+ << "HAL configuration file is mandatory for internal cameras";
+ return;
+ }
+
+ const CameraConfigData *cameraConfigData = halConfig_.cameraConfigData(cam->id());
+ if (!isCameraExternal && !cameraConfigData) {
+ LOG(HAL, Error)
+ << "HAL configuration entry for internal camera "
+ << cam->id() << " is missing";
+ return;
+ }
+
+ int ret = camera->initialize(cameraConfigData);
if (ret) {
LOG(HAL, Error) << "Failed to initialize camera: " << cam->id();
return;