From patchwork Wed Jul 31 18:36:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Milan Zamazal X-Patchwork-Id: 20735 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 63065BDC71 for ; Wed, 31 Jul 2024 18:36:36 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 14BDD63378; Wed, 31 Jul 2024 20:36:36 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="HHfMXpEp"; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A03336198E for ; Wed, 31 Jul 2024 20:36:33 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1722450992; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=13QK6JJ/aJcw7c2awxA4fwKa3RpFH6UUr5Y/xzcC1NE=; b=HHfMXpEppyyIocBblJP5f8kjHMLO6Mb7fIs8Ixxfpi3u4bvdsDwd4GMWGpOonxeIkEbMHl 1NbgT7f3Em+oRr1d7c3w215wmzoBcLs9tlrHNfOFgF6qf9UsoBDFJr/BAfyi+U4FgEWiZu fWMk6WMIcnPuoVDEVuhLpJBUCpGw0pU= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-166-K9P66E-YMeK5TbdOzAQ_kQ-1; Wed, 31 Jul 2024 14:36:29 -0400 X-MC-Unique: K9P66E-YMeK5TbdOzAQ_kQ-1 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 33A7F1955F3B; Wed, 31 Jul 2024 18:36:28 +0000 (UTC) Received: from nuthatch.redhat.com (unknown [10.45.224.46]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 421C4300018D; Wed, 31 Jul 2024 18:36:25 +0000 (UTC) From: Milan Zamazal To: libcamera-devel@lists.libcamera.org Cc: Milan Zamazal , Kieran Bingham , Laurent Pinchart Subject: [PATCH v3 1/3] libcamera: simple: Log a missing sensor in a better way Date: Wed, 31 Jul 2024 20:36:14 +0200 Message-ID: <20240731183616.1977348-2-mzamazal@redhat.com> In-Reply-To: <20240731183616.1977348-1-mzamazal@redhat.com> References: <20240731183616.1977348-1-mzamazal@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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" SimplePipelineHandler::match may be called several times for different pipeline configurations. Not all of these calls must succeed. For example, for TI AM69 board with a single camera attached, the following error is reported in the log even when libcamera works fine: ERROR SimplePipeline simple.cpp:1558 No sensor found This is because a sensor is found for /dev/media0 but not for /dev/media1. The error is harmless in such a case and only confuses users who may think no camera is detected at all. Let's change the error to info and add the device node to the message to indicate the error is specific to the given media only. It's up to the callers to report a fatal error condition if libcamera cannot work due to no matching pipeline configuration. Signed-off-by: Milan Zamazal Reviewed-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- src/libcamera/pipeline/simple/simple.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp index c050966a..9910900e 100644 --- a/src/libcamera/pipeline/simple/simple.cpp +++ b/src/libcamera/pipeline/simple/simple.cpp @@ -1547,10 +1547,12 @@ bool SimplePipelineHandler::match(DeviceEnumerator *enumerator) /* Locate the sensors. */ std::vector sensors = locateSensors(); if (sensors.empty()) { - LOG(SimplePipeline, Error) << "No sensor found"; + LOG(SimplePipeline, Info) << "No sensor found for " << media_->deviceNode(); return false; } + LOG(SimplePipeline, Debug) << "Sensor found for " << media_->deviceNode(); + /* * Create one camera data instance for each sensor and gather all * entities in all pipelines. From patchwork Wed Jul 31 18:36:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Milan Zamazal X-Patchwork-Id: 20736 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 2AEB1BDC71 for ; Wed, 31 Jul 2024 18:36:40 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9B16E63378; Wed, 31 Jul 2024 20:36:39 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="Sdg3aU8Y"; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id C96496336F for ; Wed, 31 Jul 2024 20:36:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1722450995; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=G+nvhr/q2i3bcN8UWFM7TpLPBnN6VVbdMXuYPjmeSOo=; b=Sdg3aU8YAT6gQrlPizKyUo54YdiwMPSpo7naPnPR9qCBpxWig90uzZc8gQv/RRteqcIIB9 LmZlDDqcHBTCpCZ3R00/xaQZ4Yat24/3eHne3xeW7SHA6RD1Vh4doLj+0Ht5PVSdlgIJZ3 hPlHNooS3AR5gvu2C/c6mQOGi1W1eds= Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-39-vgZw0ntQN8Gfh_jjJaw1mQ-1; Wed, 31 Jul 2024 14:36:31 -0400 X-MC-Unique: vgZw0ntQN8Gfh_jjJaw1mQ-1 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A2F291955D4A; Wed, 31 Jul 2024 18:36:30 +0000 (UTC) Received: from nuthatch.redhat.com (unknown [10.45.224.46]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id A0B11300018D; Wed, 31 Jul 2024 18:36:28 +0000 (UTC) From: Milan Zamazal To: libcamera-devel@lists.libcamera.org Cc: Milan Zamazal , Kieran Bingham , Laurent Pinchart Subject: [PATCH v3 2/3] libcamera: ipa_proxy: Unify configurationFile argument name Date: Wed, 31 Jul 2024 20:36:15 +0200 Message-ID: <20240731183616.1977348-3-mzamazal@redhat.com> In-Reply-To: <20240731183616.1977348-1-mzamazal@redhat.com> References: <20240731183616.1977348-1-mzamazal@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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" The argument name is different in the declaration and the definition. Let's use the same one in both, namely `name'. Signed-off-by: Milan Zamazal Reviewed-by: Laurent Pinchart Reviewed-by: Kieran Bingham --- include/libcamera/internal/ipa_proxy.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/libcamera/internal/ipa_proxy.h b/include/libcamera/internal/ipa_proxy.h index ed6a5bcf..5240f69f 100644 --- a/include/libcamera/internal/ipa_proxy.h +++ b/include/libcamera/internal/ipa_proxy.h @@ -31,7 +31,7 @@ public: bool isValid() const { return valid_; } - std::string configurationFile(const std::string &file) const; + std::string configurationFile(const std::string &name) const; protected: std::string resolvePath(const std::string &file) const; From patchwork Wed Jul 31 18:36:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Milan Zamazal X-Patchwork-Id: 20737 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 B776ABDC71 for ; Wed, 31 Jul 2024 18:36:43 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 52C026337B; Wed, 31 Jul 2024 20:36:43 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="cMTZEFNK"; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 7DE146198E for ; Wed, 31 Jul 2024 20:36:40 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1722450999; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YYuwgoj85QfR6JWuJNPLTgilIEd+iBBXF6q3nd2GZ5k=; b=cMTZEFNKeumzzw2kSOa/N+V6XLgZar/IlMiWGI6Kz0sKV3VPBW3DEpUFx69RbO+ed6+kvB Pli2X5zQgqcLWmtOAUyITv4JFx7MbnzeCDGQZe+GD4EO0p0/5LhscpgwkAom2P+sp3zGFs YGjOuQAXSZHJmmiCZRpnlL0GH32uOA0= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-187-1WrkZW9gPbuTsrhvnSf05A-1; Wed, 31 Jul 2024 14:36:33 -0400 X-MC-Unique: 1WrkZW9gPbuTsrhvnSf05A-1 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id D6FD219560AA; Wed, 31 Jul 2024 18:36:32 +0000 (UTC) Received: from nuthatch.redhat.com (unknown [10.45.224.46]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id EFB45300018D; Wed, 31 Jul 2024 18:36:30 +0000 (UTC) From: Milan Zamazal To: libcamera-devel@lists.libcamera.org Cc: Milan Zamazal , Kieran Bingham , Laurent Pinchart Subject: [PATCH v3 3/3] libcamera: ipa_proxy: Report a missing configuration as a warning Date: Wed, 31 Jul 2024 20:36:16 +0200 Message-ID: <20240731183616.1977348-4-mzamazal@redhat.com> In-Reply-To: <20240731183616.1977348-1-mzamazal@redhat.com> References: <20240731183616.1977348-1-mzamazal@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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" When the configuration file for an IPA module is missing, it is reported as an error in the log, for example: ERROR IPAProxy ipa_proxy.cpp:149 Configuration file 'imx219.yaml' not found for IPA module 'simple' This is misleading because several pipelines use uncalibrated.yaml in such a case and can continue working. And in case of software ISP, there is currently no other configuration file so the error is always reported. On the other hand, in some other cases the presence of the configuration file is required and it is an error if it is missing. Let's introduce a new optional argument to IPAProxy::configurationFile that specifies a fallback file if the requested file is not found. If the primary requested file is not found and a non-empty fallback file is specified then a warning is logged and the fallback file is looked up. If neither the fallback file can be found then only then an error is logged and the method returns an empty string. This change has also the benefit of putting the common fallback file ("uncalibrated.yaml") pattern to a single place. Signed-off-by: Milan Zamazal Reviewed-by: Laurent Pinchart Reviewed-by: Kieran Bingham --- include/libcamera/internal/ipa_proxy.h | 3 ++- src/libcamera/ipa_proxy.cpp | 22 ++++++++++++++++----- src/libcamera/pipeline/ipu3/ipu3.cpp | 5 ++--- src/libcamera/pipeline/rkisp1/rkisp1.cpp | 9 ++------- src/libcamera/software_isp/software_isp.cpp | 5 ++--- 5 files changed, 25 insertions(+), 19 deletions(-) diff --git a/include/libcamera/internal/ipa_proxy.h b/include/libcamera/internal/ipa_proxy.h index 5240f69f..0f564d99 100644 --- a/include/libcamera/internal/ipa_proxy.h +++ b/include/libcamera/internal/ipa_proxy.h @@ -31,7 +31,8 @@ public: bool isValid() const { return valid_; } - std::string configurationFile(const std::string &name) const; + std::string configurationFile(const std::string &name, + const std::string &fallbackName = std::string()) const; protected: std::string resolvePath(const std::string &file) const; diff --git a/src/libcamera/ipa_proxy.cpp b/src/libcamera/ipa_proxy.cpp index 6c17c456..69975d8f 100644 --- a/src/libcamera/ipa_proxy.cpp +++ b/src/libcamera/ipa_proxy.cpp @@ -72,6 +72,7 @@ IPAProxy::~IPAProxy() /** * \brief Retrieve the absolute path to an IPA configuration file * \param[in] name The configuration file name + * \param[in] fallbackName The name of a fallback configuration file * * This function locates the configuration file for an IPA and returns its * absolute path. It searches the following directories, in order: @@ -89,10 +90,14 @@ IPAProxy::~IPAProxy() * named after the IPA module name, as reported in IPAModuleInfo::name, and for * a file named \a name within that directory. The \a name is IPA-specific. * + * If the file named \a name is not found and \a fallbackName is non-empty then + * the whole search is repeated for \a fallbackName. + * * \return The full path to the IPA configuration file, or an empty string if * no configuration file can be found */ -std::string IPAProxy::configurationFile(const std::string &name) const +std::string IPAProxy::configurationFile(const std::string &name, + const std::string &fallbackName) const { struct stat statbuf; int ret; @@ -146,11 +151,18 @@ std::string IPAProxy::configurationFile(const std::string &name) const } } - LOG(IPAProxy, Error) - << "Configuration file '" << name - << "' not found for IPA module '" << ipaName << "'"; + if (fallbackName.empty()) { + LOG(IPAProxy, Error) + << "Configuration file '" << name + << "' not found for IPA module '" << ipaName << "'"; + return std::string(); + } - return std::string(); + LOG(IPAProxy, Warning) + << "Configuration file '" << name + << "' not found for IPA module '" << ipaName + << "', falling back to '" << fallbackName << "'"; + return configurationFile(fallbackName); } /** diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index 066fd4a2..2071c338 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -1186,9 +1186,8 @@ int IPU3CameraData::loadIPA() * The API tuning file is made from the sensor name. If the tuning file * isn't found, fall back to the 'uncalibrated' file. */ - std::string ipaTuningFile = ipa_->configurationFile(sensor->model() + ".yaml"); - if (ipaTuningFile.empty()) - ipaTuningFile = ipa_->configurationFile("uncalibrated.yaml"); + std::string ipaTuningFile = + ipa_->configurationFile(sensor->model() + ".yaml", "uncalibrated.yaml"); ret = ipa_->init(IPASettings{ ipaTuningFile, sensor->model() }, sensorInfo, sensor->controls(), &ipaControls_); diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp index 4cbf105d..eec5bf94 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp @@ -351,13 +351,8 @@ int RkISP1CameraData::loadIPA(unsigned int hwRevision) std::string ipaTuningFile; char const *configFromEnv = utils::secure_getenv("LIBCAMERA_RKISP1_TUNING_FILE"); if (!configFromEnv || *configFromEnv == '\0') { - ipaTuningFile = ipa_->configurationFile(sensor_->model() + ".yaml"); - /* - * If the tuning file isn't found, fall back to the - * 'uncalibrated' configuration file. - */ - if (ipaTuningFile.empty()) - ipaTuningFile = ipa_->configurationFile("uncalibrated.yaml"); + ipaTuningFile = + ipa_->configurationFile(sensor_->model() + ".yaml", "uncalibrated.yaml"); } else { ipaTuningFile = std::string(configFromEnv); } diff --git a/src/libcamera/software_isp/software_isp.cpp b/src/libcamera/software_isp/software_isp.cpp index c8748d88..1140372c 100644 --- a/src/libcamera/software_isp/software_isp.cpp +++ b/src/libcamera/software_isp/software_isp.cpp @@ -121,9 +121,8 @@ SoftwareIsp::SoftwareIsp(PipelineHandler *pipe, const CameraSensor *sensor) * The API tuning file is made from the sensor name. If the tuning file * isn't found, fall back to the 'uncalibrated' file. */ - std::string ipaTuningFile = ipa_->configurationFile(sensor->model() + ".yaml"); - if (ipaTuningFile.empty()) - ipaTuningFile = ipa_->configurationFile("uncalibrated.yaml"); + std::string ipaTuningFile = + ipa_->configurationFile(sensor->model() + ".yaml", "uncalibrated.yaml"); int ret = ipa_->init(IPASettings{ ipaTuningFile, sensor->model() }, debayer_->getStatsFD(),