{"id":11793,"url":"https://patchwork.libcamera.org/api/1.1/patches/11793/?format=json","web_url":"https://patchwork.libcamera.org/patch/11793/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20210330142113.37457-5-jacopo@jmondi.org>","date":"2021-03-30T14:21:12","name":"[libcamera-devel,v3,4/5] android: camera_device: Get properties from configuration","commit_ref":null,"pull_url":null,"state":"changes-requested","archived":false,"hash":"a43cf78cdf3af798a5093c7f0901eacd29975163","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/1.1/people/3/?format=json","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/11793/mbox/","series":[{"id":1871,"url":"https://patchwork.libcamera.org/api/1.1/series/1871/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=1871","date":"2021-03-30T14:21:08","name":"android: Introduce HAL configuration file","version":3,"mbox":"https://patchwork.libcamera.org/series/1871/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/11793/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/11793/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 6FE38C0DA3\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 30 Mar 2021 14:20:49 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 11EFF68793;\n\tTue, 30 Mar 2021 16:20:49 +0200 (CEST)","from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net\n\t[217.70.183.195])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 5CA0E6878E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 30 Mar 2021 16:20:45 +0200 (CEST)","from uno.lan (93-34-118-233.ip49.fastwebnet.it [93.34.118.233])\n\t(Authenticated sender: jacopo@jmondi.org)\n\tby relay3-d.mail.gandi.net (Postfix) with ESMTPSA id D73796000C;\n\tTue, 30 Mar 2021 14:20:44 +0000 (UTC)"],"X-Originating-IP":"93.34.118.233","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"libcamera-devel@lists.libcamera.org","Date":"Tue, 30 Mar 2021 16:21:12 +0200","Message-Id":"<20210330142113.37457-5-jacopo@jmondi.org>","X-Mailer":"git-send-email 2.30.0","In-Reply-To":"<20210330142113.37457-1-jacopo@jmondi.org>","References":"<20210330142113.37457-1-jacopo@jmondi.org>","MIME-Version":"1.0","Subject":"[libcamera-devel] [PATCH v3 4/5] android: camera_device: Get\n\tproperties from configuration","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Open the HAL configuration file in the Camera HAL manager and get\nthe camera properties for each created CameraDevice and initialize it\nwith them.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n src/android/camera_device.cpp      |  9 +++------\n src/android/camera_device.h        |  3 ++-\n src/android/camera_hal_manager.cpp | 21 +++++++++++++++++++--\n src/android/camera_hal_manager.h   |  3 +++\n 4 files changed, 27 insertions(+), 9 deletions(-)","diff":"diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp\nindex eb327978c84e..e59f25c68d6b 100644\n--- a/src/android/camera_device.cpp\n+++ b/src/android/camera_device.cpp\n@@ -6,6 +6,7 @@\n  */\n \n #include \"camera_device.h\"\n+#include \"camera_hal_config.h\"\n #include \"camera_ops.h\"\n #include \"post_processor.h\"\n \n@@ -351,7 +352,7 @@ std::unique_ptr<CameraDevice> CameraDevice::create(unsigned int id,\n  * Initialize the camera static information.\n  * This method is called before the camera device is opened.\n  */\n-int CameraDevice::initialize()\n+int CameraDevice::initialize(const CameraProps &cameraProps)\n {\n \t/* Initialize orientation and facing side of the camera. */\n \tconst ControlList &properties = camera_->properties();\n@@ -370,11 +371,7 @@ int CameraDevice::initialize()\n \t\t\tbreak;\n \t\t}\n \t} else {\n-\t\t/*\n-\t\t * \\todo Retrieve the camera location from configuration file\n-\t\t * if not available from the library.\n-\t\t */\n-\t\tfacing_ = CAMERA_FACING_FRONT;\n+\t\tfacing_ = cameraProps.facing;\n \t}\n \n \t/*\ndiff --git a/src/android/camera_device.h b/src/android/camera_device.h\nindex 11bdfec8d587..ba3ec8770e11 100644\n--- a/src/android/camera_device.h\n+++ b/src/android/camera_device.h\n@@ -29,6 +29,7 @@\n #include \"camera_worker.h\"\n #include \"jpeg/encoder.h\"\n \n+class CameraProps;\n class CameraDevice : protected libcamera::Loggable\n {\n public:\n@@ -36,7 +37,7 @@ public:\n \t\t\t\t\t\t    std::shared_ptr<libcamera::Camera> cam);\n \t~CameraDevice();\n \n-\tint initialize();\n+\tint initialize(const CameraProps &cameraProps);\n \n \tint open(const hw_module_t *hardwareModule);\n \tvoid close();\ndiff --git a/src/android/camera_hal_manager.cpp b/src/android/camera_hal_manager.cpp\nindex bf3fcda75237..a517727ea0b8 100644\n--- a/src/android/camera_hal_manager.cpp\n+++ b/src/android/camera_hal_manager.cpp\n@@ -39,13 +39,17 @@ CameraHalManager::~CameraHalManager() = default;\n \n int CameraHalManager::init()\n {\n+\tint ret = halConfig_.open();\n+\tif (ret)\n+\t\treturn ret;\n+\n \tcameraManager_ = std::make_unique<CameraManager>();\n \n \t/* Support camera hotplug. */\n \tcameraManager_->cameraAdded.connect(this, &CameraHalManager::cameraAdded);\n \tcameraManager_->cameraRemoved.connect(this, &CameraHalManager::cameraRemoved);\n \n-\tint ret = cameraManager_->start();\n+\tret = cameraManager_->start();\n \tif (ret) {\n \t\tLOG(HAL, Error) << \"Failed to start camera manager: \"\n \t\t\t\t<< strerror(-ret);\n@@ -115,9 +119,22 @@ void CameraHalManager::cameraAdded(std::shared_ptr<Camera> cam)\n \t\t}\n \t}\n \n+\t/*\n+\t * Get camera properties from the configuration file.\n+\t *\n+\t * The camera properties as recorded in the configuration file\n+\t * supplement information that cannot be retrieved from the\n+\t * libcamera::Camera at run time.\n+\t */\n+\tconst CameraProps &cameraProps = halConfig_.cameraProps(cam->id());\n+\tif (!cameraProps.valid) {\n+\t\tLOG(HAL, Error) << \"Failed to register camera: \" << cam->id();\n+\t\treturn;\n+\t}\n+\n \t/* Create a CameraDevice instance to wrap the libcamera Camera. */\n \tstd::unique_ptr<CameraDevice> camera = CameraDevice::create(id, cam);\n-\tint ret = camera->initialize();\n+\tint ret = camera->initialize(cameraProps);\n \tif (ret) {\n \t\tLOG(HAL, Error) << \"Failed to initialize camera: \" << cam->id();\n \t\treturn;\ndiff --git a/src/android/camera_hal_manager.h b/src/android/camera_hal_manager.h\nindex d9bf27989965..af1581da6579 100644\n--- a/src/android/camera_hal_manager.h\n+++ b/src/android/camera_hal_manager.h\n@@ -19,6 +19,8 @@\n \n #include <libcamera/camera_manager.h>\n \n+#include \"camera_hal_config.h\"\n+\n class CameraDevice;\n \n class CameraHalManager\n@@ -50,6 +52,7 @@ private:\n \tCameraDevice *cameraDeviceFromHalId(unsigned int id);\n \n \tstd::unique_ptr<libcamera::CameraManager> cameraManager_;\n+\tCameraHalConfig halConfig_;\n \n \tconst camera_module_callbacks_t *callbacks_;\n \tstd::vector<std::unique_ptr<CameraDevice>> cameras_;\n","prefixes":["libcamera-devel","v3","4/5"]}