[libcamera-devel] [RFC PATCH 3/3] android: camera_hal_manager: error on init if cameras not initialized
Paul Elder
paul.elder at ideasonboard.com
Mon Sep 30 07:35:20 CEST 2019
Return error from hal_init() if the built-in cameras have not been
initialized yet. On Chromium OS, this causes Upstart to restart the
camera service at a later time, allowing the built-in cameras to be
enumerated correctly. This fixes the problem where the camera service
is started before the camera device nodes are available.
Signed-off-by: Paul Elder <paul.elder at ideasonboard.com>
---
src/android/camera3_hal.cpp | 4 +---
src/android/camera_hal_manager.cpp | 11 ++++++++++-
2 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/src/android/camera3_hal.cpp b/src/android/camera3_hal.cpp
index 8d2629ca..9d18b999 100644
--- a/src/android/camera3_hal.cpp
+++ b/src/android/camera3_hal.cpp
@@ -56,9 +56,7 @@ static int hal_init()
{
LOG(HAL, Info) << "Initialising Android camera HAL";
- cameraManager.init();
-
- return 0;
+ return cameraManager.init();
}
/*------------------------------------------------------------------------------
diff --git a/src/android/camera_hal_manager.cpp b/src/android/camera_hal_manager.cpp
index 22f0323b..af0114fc 100644
--- a/src/android/camera_hal_manager.cpp
+++ b/src/android/camera_hal_manager.cpp
@@ -13,11 +13,14 @@
#include "camera_device.h"
#include "camera_proxy.h"
+#include "device_enumerator.h"
using namespace libcamera;
LOG_DECLARE_CATEGORY(HAL);
+static int initRet = 0;
+
/*
* \class CameraHalManager
*
@@ -49,7 +52,7 @@ int CameraHalManager::init()
MutexLocker locker(mutex_);
cv_.wait(locker);
- return 0;
+ return initRet;
}
void CameraHalManager::run()
@@ -68,6 +71,12 @@ void CameraHalManager::run()
return;
}
+ if (!DeviceEnumerator::haveExpectedCameras(cameraManager_)) {
+ LOG(HAL, Warning) << "Expected cameras not loaded";
+ initRet = -EAGAIN;
+ cv_.notify_one();
+ }
+
/*
* For each Camera registered in the system, a CameraProxy
* gets created here to wraps a camera device.
--
2.23.0
More information about the libcamera-devel
mailing list