From patchwork Fri Jul 30 11:01:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 13169 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 60B84C3230 for ; Fri, 30 Jul 2021 11:02:12 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 15FE5687C8; Fri, 30 Jul 2021 13:02: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="L3oUyYyc"; 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 ED3E9687BF for ; Fri, 30 Jul 2021 13:02:10 +0200 (CEST) Received: from perceval.ideasonboard.com (unknown [103.251.226.16]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 6B80989B; Fri, 30 Jul 2021 13:02:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1627642930; bh=aavVY4kACPTGiXnaPm6mlUVAsx88hWGbVfYt3rGXubw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=L3oUyYycfvsM+4qZg0nWXddiNG/vEqyZTCpOUpYHsAY38wefMrDtEzMuU8wYAtB35 n1lKFyZRaHEKU+a8PrtCs3a9GG1TGMsAsR2IbwK0iY5VxrIQ4MHCqxGbqvmUJiQgWz gofFmSyKbt2jky4Irtwn5Tka5CfRjWSxobA+s+wo= From: Umang Jain To: libcamera-devel@lists.libcamera.org Date: Fri, 30 Jul 2021 16:31:51 +0530 Message-Id: <20210730110154.181370-2-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210730110154.181370-1-umang.jain@ideasonboard.com> References: <20210730110154.181370-1-umang.jain@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 1/4] 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 Reviewed-by: Paul Elder --- 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 Fri Jul 30 11:01:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 13170 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 C8EF8C3230 for ; Fri, 30 Jul 2021 11:02:14 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 828EC687C5; Fri, 30 Jul 2021 13:02:14 +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="I8mQ0X9q"; 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 05D9C687BF for ; Fri, 30 Jul 2021 13:02:13 +0200 (CEST) Received: from perceval.ideasonboard.com (unknown [103.251.226.16]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id F3D2C89B; Fri, 30 Jul 2021 13:02:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1627642932; bh=zHHmGKmppvYvtnQwAHMpoVH/is8FPSbYqQfLb7uHY1Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=I8mQ0X9qGOUT1g5v1jV1JIUAf1KeST7hVjFjrrIeEgGllvFnTrBy/IN8bAhzddUD2 LADCK/fCCAu1ImDyxOARgp+VCZIuMoE7AMD4CxfuKKLG+oLWyBxXoyQ32fsodT5y5u scIyAh7i00CcLaeuGWBcmUMNzyQow/gwBJzAg+sY= From: Umang Jain To: libcamera-devel@lists.libcamera.org Date: Fri, 30 Jul 2021 16:31:52 +0530 Message-Id: <20210730110154.181370-3-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210730110154.181370-1-umang.jain@ideasonboard.com> References: <20210730110154.181370-1-umang.jain@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 2/4] android: Disallow external location in 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" Error out on any camera's location if set to "external", in the HAL configuration file. The HAL configuration file is only meant for the integrated cameras present on the system. Signed-off-by: Umang Jain Reviewed-by: Laurent Pinchart Reviewed-by: Paul Elder Reviewed-by: Jacopo Mondi --- src/android/camera_hal_config.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/android/camera_hal_config.cpp b/src/android/camera_hal_config.cpp index 833cf4ba..7126aba4 100644 --- a/src/android/camera_hal_config.cpp +++ b/src/android/camera_hal_config.cpp @@ -127,8 +127,6 @@ int CameraHalConfig::Private::parseCameraLocation(CameraConfigData *cameraConfig cameraConfigData->facing = CAMERA_FACING_FRONT; else if (location == "back") cameraConfigData->facing = CAMERA_FACING_BACK; - else if (location == "external") - cameraConfigData->facing = CAMERA_FACING_EXTERNAL; else return -EINVAL; From patchwork Fri Jul 30 11:01:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 13171 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 4A126C3230 for ; Fri, 30 Jul 2021 11:02:17 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D331D687C6; Fri, 30 Jul 2021 13:02:16 +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="a2kH8pqH"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 11594687C2 for ; Fri, 30 Jul 2021 13:02:15 +0200 (CEST) Received: from perceval.ideasonboard.com (unknown [103.251.226.16]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 0BD7D89B; Fri, 30 Jul 2021 13:02:13 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1627642934; bh=Db5/8D5FU9e30rF0XzEswne1fH4C/SxWsdukfN6bL/Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=a2kH8pqHicbKstmTqZVe88WW6GPtuaAZENorOhGEymRAiiXlfJPxL0XUqfO7jCaSb cCxsycdNWIdXomb4MYO1OJ5TReaMl9mSKIiY1p19Cr/8ThnD9qQJrjLQWyNWTK+GWg I5uPqcxMJbcT++cHbbBqN6FzJl809gHwV+ZzhZ5k= From: Umang Jain To: libcamera-devel@lists.libcamera.org Date: Fri, 30 Jul 2021 16:31:53 +0530 Message-Id: <20210730110154.181370-4-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210730110154.181370-1-umang.jain@ideasonboard.com> References: <20210730110154.181370-1-umang.jain@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 3/4] android: Override camera as "Internal" provided found in 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 in 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 Reviewed-by: Laurent Pinchart --- src/android/camera_device.cpp | 13 ++++++++++++- src/android/camera_hal_manager.cpp | 17 +++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index 678cde23..394ebc84 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -330,7 +330,18 @@ int CameraDevice::initialize(const CameraConfigData *cameraConfigData) facing_ = CAMERA_FACING_BACK; break; case properties::CameraLocationExternal: - facing_ = CAMERA_FACING_EXTERNAL; + /* + * If the camera is reported as external, but + * the CameraHalManager has overriden it, use + * what is reported in the configuration file. + * This typically happens for UVC cameras + * reported as 'External' by libcamera but + * installed in fixed position on the device. + */ + 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..cce98fad 100644 --- a/src/android/camera_hal_manager.cpp +++ b/src/android/camera_hal_manager.cpp @@ -145,6 +145,23 @@ 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 are integrated in a laptop. In that case the real location + * should be specified in the configuration file. + * + * If the camera location is external and a configuration + * entry exists for it, override its location. + */ + if (isCameraNew && isCameraExternal) { + if (cameraConfigData && cameraConfigData->facing != -1) { + isCameraExternal = false; + id = numInternalCameras_; + } + } + if (!isCameraExternal && !cameraConfigData) { LOG(HAL, Error) << "HAL configuration entry for internal camera " From patchwork Fri Jul 30 11:01:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 13172 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 70D19C3230 for ; Fri, 30 Jul 2021 11:02:19 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2BDF9687C5; Fri, 30 Jul 2021 13:02:19 +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="bco1sgT1"; 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 6C570687C3 for ; Fri, 30 Jul 2021 13:02:17 +0200 (CEST) Received: from perceval.ideasonboard.com (unknown [103.251.226.16]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id E00D389B; Fri, 30 Jul 2021 13:02:15 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1627642937; bh=zd36AspT3EDW7cdVU2eGEo55CGEPJYe3ZrwLGQIppy4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bco1sgT13K7Y1KrnhZkJTprT97X1fwoJoVayLAP0fbj4tirsy8/WlJ5JEdZhmDlob Goy1l+JUx1wZDLckW4LZT9+FSYr4LbsNkRebo23GN/ObEd5jTEn1Mun2cDRblb1WIO FrMgegI3BQ+81ERHZXfYLKgdZJKtChrf7pBPyuEI= From: Umang Jain To: libcamera-devel@lists.libcamera.org Date: Fri, 30 Jul 2021 16:31:54 +0530 Message-Id: <20210730110154.181370-5-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210730110154.181370-1-umang.jain@ideasonboard.com> References: <20210730110154.181370-1-umang.jain@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 4/4] 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 Reviewed-by: Paul Elder --- 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