From patchwork Wed Jul 17 10:09:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 20688 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 AF96FBDB1C for ; Wed, 17 Jul 2024 10:09:39 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E97D263375; Wed, 17 Jul 2024 12:09:32 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="AhPT1u5U"; 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 C7C5163371 for ; Wed, 17 Jul 2024 12:09:27 +0200 (CEST) Received: from uno.LocalDomain (93-61-96-190.ip145.fastwebnet.it [93.61.96.190]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id D3CF4836; Wed, 17 Jul 2024 12:08:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1721210930; bh=kcOAEenvH7G/QTCGDRqLsI+p61DJqTiO4QTbx/2+Xbg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AhPT1u5U+lgCRV0cDyWXLdcmWVGvEYO53DicEw8jM5bActGCKyQ8354nq+biXw/ZF TjDyUxFD+wHqdN43l8ZrAeOTW74NnsbkWSAbEx5Pa98QIm3RgU6PKeybLPnJjqnZcL fUBTxT4bfVS4UXiy/gUx6q9rSKJK4JkNYy1FIMVI= From: Jacopo Mondi To: Umang Jain , libcamera-devel@lists.libcamera.org Cc: Jacopo Mondi Subject: [RFC 2/9] fixup: Add Features at Converter registration time Date: Wed, 17 Jul 2024 12:09:05 +0200 Message-ID: <20240717100913.16640-3-jacopo.mondi@ideasonboard.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240717100913.16640-1-jacopo.mondi@ideasonboard.com> References: <20240717100913.16640-1-jacopo.mondi@ideasonboard.com> MIME-Version: 1.0 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" Signed-off-by: Jacopo Mondi --- include/libcamera/internal/converter.h | 23 +++++++++++++---------- src/libcamera/converter.cpp | 10 ++++++---- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/include/libcamera/internal/converter.h b/include/libcamera/internal/converter.h index 7e4783566a44..ead465170d01 100644 --- a/include/libcamera/internal/converter.h +++ b/include/libcamera/internal/converter.h @@ -39,7 +39,7 @@ public: using Features = Flags; - Converter(MediaDevice *media, Features features = Feature::None); + Converter(MediaDevice *media, Features features); virtual ~Converter(); virtual int loadConfiguration(const std::string &filename) = 0; @@ -68,21 +68,22 @@ public: const std::string &deviceNode() const { return deviceNode_; } - Features getFeatures() const { return features_; } + Features features() const { return features_; } private: std::string deviceNode_; - Features features_; }; class ConverterFactoryBase { public: - ConverterFactoryBase(const std::string name, std::initializer_list compatibles); + ConverterFactoryBase(const std::string name, std::initializer_list compatibles, + Converter::Features feat); virtual ~ConverterFactoryBase() = default; const std::vector &compatibles() const { return compatibles_; } + const Converter::Features features() const { return features_; } static std::unique_ptr create(MediaDevice *media); static std::vector &factories(); @@ -93,28 +94,30 @@ private: static void registerType(ConverterFactoryBase *factory); - virtual std::unique_ptr createInstance(MediaDevice *media) const = 0; + virtual std::unique_ptr createInstance(MediaDevice *media, Converter::Features feat) const = 0; std::string name_; std::vector compatibles_; + Converter::Features features_; }; template class ConverterFactory : public ConverterFactoryBase { public: - ConverterFactory(const char *name, std::initializer_list compatibles) - : ConverterFactoryBase(name, compatibles) + ConverterFactory(const char *name, std::initializer_list compatibles, Converter::Features feat) + : ConverterFactoryBase(name, compatibles, feat) { } - std::unique_ptr createInstance(MediaDevice *media) const override + std::unique_ptr createInstance(MediaDevice *media, Converter::Features feat) const override { - return std::make_unique<_Converter>(media); + return std::make_unique<_Converter>(media, feat); } }; #define REGISTER_CONVERTER(name, converter, compatibles) \ - static ConverterFactory global_##converter##Factory(name, compatibles); + static ConverterFactory global_##converter##Factory(name, compatibles, \ + Converter::Feature::None); } /* namespace libcamera */ diff --git a/src/libcamera/converter.cpp b/src/libcamera/converter.cpp index 2c3da6d4502b..dcbc442ccf68 100644 --- a/src/libcamera/converter.cpp +++ b/src/libcamera/converter.cpp @@ -178,7 +178,7 @@ Converter::~Converter() */ /** - * \fn Converter::getFeatures() + * \fn Converter::features() * \brief Gets the supported features by the converter * \return The converter Features flag */ @@ -209,8 +209,10 @@ Converter::~Converter() * The factory \a compatibles holds a list of driver names implementing a generic * subsystem without any personalizations. */ -ConverterFactoryBase::ConverterFactoryBase(const std::string name, std::initializer_list compatibles) - : name_(name), compatibles_(compatibles) +ConverterFactoryBase::ConverterFactoryBase(const std::string name, + std::initializer_list compatibles, + Converter::Features feat) + : name_(name), compatibles_(compatibles), features_(feat) { registerType(this); } @@ -247,7 +249,7 @@ std::unique_ptr ConverterFactoryBase::create(MediaDevice *media) << factory->name_ << " factory with " << (it == compatibles.end() ? "no" : media->driver()) << " alias."; - std::unique_ptr converter = factory->createInstance(media); + std::unique_ptr converter = factory->createInstance(media, factory->features()); if (converter->isValid()) return converter; }