From patchwork Wed Jul 28 07:37:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 13135 X-Patchwork-Delegate: umang.jain@ideasonboard.com Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id E8D90C322E for ; Wed, 28 Jul 2021 07:38:12 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id A2554687C9; Wed, 28 Jul 2021 09:38:12 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="GuUbzq9m"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id C5072687C3 for ; Wed, 28 Jul 2021 09:38:10 +0200 (CEST) Received: from perceval.ideasonboard.com (unknown [103.251.226.16]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id D9976EE; Wed, 28 Jul 2021 09:38:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1627457890; bh=+hpWhM0B6l16KiRLpAJrn3RoLa6bI/tUegRkklt6eCc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GuUbzq9mDSNVGaANihUHClCgGgM/8N2a33ccCTMqcwQs1ea7JFrE46hPuFwIYh4kw q4P4n1cryFLgOi0wAcsedwyAx/kbyweeX10j241bTV04T8I3RsghigkU6gKw4JGvDL ifp0k0aB9U0PCcfL3qH8gg8JiSFlsBL4nTFM8YKs= From: Umang Jain To: libcamera-devel@lists.libcamera.org Date: Wed, 28 Jul 2021 13:07:58 +0530 Message-Id: <20210728073800.93745-2-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210728073800.93745-1-umang.jain@ideasonboard.com> References: <20210728073800.93745-1-umang.jain@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 1/3] android: Instantiate CameraDevice after checking HAL config validity X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Currently CameraDevice wrapper is created first and then HAL config validity is checked. If the validity checks fail, the code path will simply return, in which case, creating CameraDevice seems a futile exercise. This patch defers the creation of CameraDevice wrapper until the HAL config validity is checked for internal cameras. This will also enable us to infer a few things beforehand, by reading the config file before creating the CameraDevice wrapper. Signed-off-by: Umang Jain Reviewed-by: Jacopo Mondi Reviewed-by: Laurent Pinchart --- src/android/camera_hal_manager.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/android/camera_hal_manager.cpp b/src/android/camera_hal_manager.cpp index 4cd67544..b364f62a 100644 --- a/src/android/camera_hal_manager.cpp +++ b/src/android/camera_hal_manager.cpp @@ -133,9 +133,6 @@ void CameraHalManager::cameraAdded(std::shared_ptr cam) } } - /* Create a CameraDevice instance to wrap the libcamera Camera. */ - std::unique_ptr camera = CameraDevice::create(id, cam); - /* * The configuration file must be valid, and contain a corresponding * entry for internal cameras. External cameras can be initialized @@ -155,6 +152,9 @@ void CameraHalManager::cameraAdded(std::shared_ptr cam) return; } + /* Create a CameraDevice instance to wrap the libcamera Camera. */ + std::unique_ptr camera = CameraDevice::create(id, cam); + int ret = camera->initialize(cameraConfigData); if (ret) { LOG(HAL, Error) << "Failed to initialize camera: " << cam->id(); From patchwork Wed Jul 28 07:37:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 13136 X-Patchwork-Delegate: umang.jain@ideasonboard.com Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id DC351C322E for ; Wed, 28 Jul 2021 07:38:15 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 74870687CC; Wed, 28 Jul 2021 09:38:15 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="iO+wfQL6"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D0C4B687CA for ; Wed, 28 Jul 2021 09:38:12 +0200 (CEST) Received: from perceval.ideasonboard.com (unknown [103.251.226.16]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id B19ADEE; Wed, 28 Jul 2021 09:38:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1627457892; bh=pmIEt7cFIA3EtG5MAG7AE3L9U4slwDXIjQrp7GmL2Xo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iO+wfQL6gLcDQaGt/7HY36wr8I28it94dUcvHXgvI9vFXSUqvj2ydthMAEE6YPrtU U/oO2E0cB8GHCsItZpK6EkCxQ7Y0D+RdJF6PX3dByvthjiJtLZDaW27TKy8uCi1ULT fK7uWiHdW0dL0D/d/0vcM2/vwzIXVJA5iS5bXFro= From: Umang Jain To: libcamera-devel@lists.libcamera.org Date: Wed, 28 Jul 2021 13:07:59 +0530 Message-Id: <20210728073800.93745-3-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210728073800.93745-1-umang.jain@ideasonboard.com> References: <20210728073800.93745-1-umang.jain@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 2/3] android: Override camera is "Internal" provided if found on HAL config X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Currently, all UVC cameras are reported with CameraLocationExternal [1] by libcamera-core, since there is no universal information or standard, to know the location of these cameras. However, in the libcamera HAL layer, we can make an informed decision whether its external or internal, simply by checking the presence of it in the HAL configuration file. If the camera is found to be present on the HAL configuration file, treat it as internal. CameraHalManager will now assign the numerical id of the camera accordingly, based on which the facing of the camera is set as well (as per the HAL config file) while initializing the CameraDevice wrapper. [1] 76809320bb1a ("libcamera: pipeline: uvcvideo: Treat all UVC cameras as external") Signed-off-by: Umang Jain Reviewed-by: Jacopo Mondi --- src/android/camera_device.cpp | 10 +++++++++- src/android/camera_hal_manager.cpp | 18 ++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index 678cde23..c7f5fc4e 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -330,7 +330,15 @@ int CameraDevice::initialize(const CameraConfigData *cameraConfigData) facing_ = CAMERA_FACING_BACK; break; case properties::CameraLocationExternal: - facing_ = CAMERA_FACING_EXTERNAL; + /* + * If the camera is 'Internal' as found by + * CameraHalManager, use its location from + * HAL config file. + */ + if (id_ < 1000 && cameraConfigData->facing != -1) + facing_ = cameraConfigData->facing; + else + facing_ = CAMERA_FACING_EXTERNAL; break; } diff --git a/src/android/camera_hal_manager.cpp b/src/android/camera_hal_manager.cpp index b364f62a..4950bd75 100644 --- a/src/android/camera_hal_manager.cpp +++ b/src/android/camera_hal_manager.cpp @@ -145,6 +145,24 @@ void CameraHalManager::cameraAdded(std::shared_ptr cam) } const CameraConfigData *cameraConfigData = halConfig_.cameraConfigData(cam->id()); + + /* + * Some cameras whose location is reported by libcamera as external may + * actually be internal to the device. This is common with UVC cameras + * that can be integrated in a laptop, but are all considered by + * libcamera as external. The true location for those cameras is + * specified in the HAL configuration file. If the camera location is + * external and a configuration entry exists for it, override the + * location. + */ + if (isCameraNew && isCameraExternal) { + if (cameraConfigData && cameraConfigData->facing != -1 && + cameraConfigData->facing != CAMERA_FACING_EXTERNAL) { + isCameraExternal = false; + id = numInternalCameras_; + } + } + if (!isCameraExternal && !cameraConfigData) { LOG(HAL, Error) << "HAL configuration entry for internal camera " From patchwork Wed Jul 28 07:38:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 13137 X-Patchwork-Delegate: umang.jain@ideasonboard.com Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 4926CC322E for ; Wed, 28 Jul 2021 07:38:17 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 04817687BD; Wed, 28 Jul 2021 09:38:17 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="d8ankLYz"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2EC57687C8 for ; Wed, 28 Jul 2021 09:38:15 +0200 (CEST) Received: from perceval.ideasonboard.com (unknown [103.251.226.16]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id BEFB5EE; Wed, 28 Jul 2021 09:38:13 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1627457895; bh=zd36AspT3EDW7cdVU2eGEo55CGEPJYe3ZrwLGQIppy4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=d8ankLYzL87zPoMZhYjx4SARYSv/wEQ7pIDS0XtdzdauEdfYdo2VFQqnSNAIn0giO YPtvZH2+vtHduPSOg53AZldA5tHfJihdwXF3/MSYMBJKYPWzs0g0u1pwqdtTmONg/e cxt+g+avXLqxNrWrPbf+xa70feTuT4utZnuU4Big= From: Umang Jain To: libcamera-devel@lists.libcamera.org Date: Wed, 28 Jul 2021 13:08:00 +0530 Message-Id: <20210728073800.93745-4-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210728073800.93745-1-umang.jain@ideasonboard.com> References: <20210728073800.93745-1-umang.jain@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 3/3] android: nautilus: Add camera HAL configuration X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Nautilus has two in-built cameras, one UVC and one attached to IPU3. Signed-off-by: Umang Jain Reviewed-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- src/android/data/nautilus/camera_hal.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 src/android/data/nautilus/camera_hal.yaml diff --git a/src/android/data/nautilus/camera_hal.yaml b/src/android/data/nautilus/camera_hal.yaml new file mode 100644 index 00000000..faddd29e --- /dev/null +++ b/src/android/data/nautilus/camera_hal.yaml @@ -0,0 +1,8 @@ +cameras: + "\\_SB_.PCI0.I2C2.CAM0": + location: back + rotation: 0 + + "\\_SB_.PCI0.XHCI.RHUB.HS09-9:1.0-04f2:b647": + location: front + rotation: 0