From patchwork Thu Sep 26 09:36:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 21377 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 295B6C3257 for ; Thu, 26 Sep 2024 09:36:39 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B32D46350E; Thu, 26 Sep 2024 11:36:38 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="e0clTj3/"; 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 3A93E634FB for ; Thu, 26 Sep 2024 11:36:35 +0200 (CEST) Received: from localhost.localdomain (unknown [IPv6:2405:201:2015:f873:55f8:639e:8e9f:12ec]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 40C67D80; Thu, 26 Sep 2024 11:35:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1727343307; bh=S99GqCK6+UJwt8YdATcB/WOR56/UU/5GwdyfW01ZR4o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=e0clTj3/1ojM+uGZZqyKL1Sac9DTxgHZmy6LQuArRTtIY+JO6XzFIk/gVFzPcdj5b PEn8EWitlUrI2gNxE/I4zzVGpRaVlpWNoXkyBdByEFvk91O3sFRRXGpy/Hfn4R05OX iTg3bcaE00wz8wM2W6JliewvqPsrtm8tJwC/IxL0= From: Umang Jain To: libcamera-devel@lists.libcamera.org Cc: Laurent Pinchart , Stefan Klug , Umang Jain , Kieran Bingham , Paul Elder Subject: [PATCH v8 1/4] libcamera: converter: Add interface for feature flags Date: Thu, 26 Sep 2024 15:06:20 +0530 Message-ID: <20240926093623.94136-2-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240926093623.94136-1-umang.jain@ideasonboard.com> References: <20240926093623.94136-1-umang.jain@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" This patch intends to extend the converter interface to have feature flags, which enables each converter to expose the set of features it supports. Signed-off-by: Umang Jain Reviewed-by: Kieran Bingham Reviewed-by: Paul Elder Reviewed-by: Laurent Pinchart --- include/libcamera/internal/converter.h | 14 +++++++++- src/libcamera/converter.cpp | 27 ++++++++++++++++++- .../converter/converter_v4l2_m2m.cpp | 4 +++ 3 files changed, 43 insertions(+), 2 deletions(-) diff --git a/include/libcamera/internal/converter.h b/include/libcamera/internal/converter.h index b51563d7..6623de4d 100644 --- a/include/libcamera/internal/converter.h +++ b/include/libcamera/internal/converter.h @@ -17,6 +17,7 @@ #include #include +#include #include #include @@ -32,7 +33,13 @@ struct StreamConfiguration; class Converter { public: - Converter(MediaDevice *media); + enum class Feature { + None = 0, + }; + + using Features = Flags; + + Converter(MediaDevice *media, Features features = Feature::None); virtual ~Converter(); virtual int loadConfiguration(const std::string &filename) = 0; @@ -61,6 +68,11 @@ public: const std::string &deviceNode() const { return deviceNode_; } + Features features() const { return features_; } + +protected: + Features features_; + private: std::string deviceNode_; }; diff --git a/src/libcamera/converter.cpp b/src/libcamera/converter.cpp index 8237998f..d7bb7273 100644 --- a/src/libcamera/converter.cpp +++ b/src/libcamera/converter.cpp @@ -34,14 +34,27 @@ LOG_DEFINE_CATEGORY(Converter) * parameters from the same input stream. */ +/** + * \enum Converter::Feature + * \brief Specify the features supported by the converter + * \var Converter::Feature::None + * \brief No extra features supported by the converter + */ + +/** + * \typedef Converter::Features + * \brief A bitwise combination of features supported by the converter + */ + /** * \brief Construct a Converter instance * \param[in] media The media device implementing the converter + * \param[in] features Features flags representing supported features * * This searches for the entity implementing the data streaming function in the * media graph entities and use its device node as the converter device node. */ -Converter::Converter(MediaDevice *media) +Converter::Converter(MediaDevice *media, Features features) { const std::vector &entities = media->entities(); auto it = std::find_if(entities.begin(), entities.end(), @@ -56,6 +69,7 @@ Converter::Converter(MediaDevice *media) } deviceNode_ = (*it)->deviceNode(); + features_ = features; } Converter::~Converter() @@ -157,12 +171,23 @@ Converter::~Converter() * \brief A signal emitted on each frame buffer completion of the output queue */ +/** + * \var Converter::features_ + * \brief Stores the features supported by the converter + */ + /** * \fn Converter::deviceNode() * \brief The converter device node attribute accessor * \return The converter device node string */ +/** + * \fn Converter::features() + * \brief Retrieve the features supported by the converter + * \return The converter Features flags + */ + /** * \class ConverterFactoryBase * \brief Base class for converter factories diff --git a/src/libcamera/converter/converter_v4l2_m2m.cpp b/src/libcamera/converter/converter_v4l2_m2m.cpp index e4f656da..4f3e8ce4 100644 --- a/src/libcamera/converter/converter_v4l2_m2m.cpp +++ b/src/libcamera/converter/converter_v4l2_m2m.cpp @@ -446,6 +446,10 @@ int V4L2M2MConverter::queueBuffers(FrameBuffer *input, return 0; } +/* + * \todo: This should be extended to include Feature::Flag to denote + * what each converter supports feature-wise. + */ static std::initializer_list compatibles = { "mtk-mdp", "pxp",