From patchwork Tue Jul 9 20:21:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 20643 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 7E25FBDB1C for ; Tue, 9 Jul 2024 20:22:05 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 542AD63374; Tue, 9 Jul 2024 22:22:03 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="qPoChpBm"; 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 1A750619B9 for ; Tue, 9 Jul 2024 22:22:00 +0200 (CEST) Received: from fedora.local (unknown [IPv6:2405:201:2015:f873:c173:4b:4a04:3a21]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id DD07D16D6; Tue, 9 Jul 2024 22:21:26 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1720556487; bh=BPKr1F4y983JHY2Sb7c4Kyq1guUN2+5QhNvwdihWwfY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qPoChpBm2tcIWTf+LMyMtJ/bnB/pMKDj7i3XAKV4CIB3vC++K1F81dJmQFTUWxPiG 6y7MpB+48N4L9B0qT7nK9/G+0K5zxr3bAzu1fJ6l6mJuKSJ5l3Lniz+2K8nl2v7oTR 6wMO6O2cNgA26EyCiei4rmKoONSTuxunop9Mo3Ew= From: Umang Jain To: libcamera-devel@lists.libcamera.org Cc: Umang Jain Subject: [PATCH v5 1/5] libcamera: converter: Add interface for feature flags Date: Wed, 10 Jul 2024 01:51:47 +0530 Message-ID: <20240709202151.152289-2-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240709202151.152289-1-umang.jain@ideasonboard.com> References: <20240709202151.152289-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 --- include/libcamera/internal/converter.h | 13 ++++++++++- .../internal/converter/converter_v4l2_m2m.h | 2 +- src/libcamera/converter.cpp | 22 ++++++++++++++++++- .../converter/converter_v4l2_m2m.cpp | 5 +++-- 4 files changed, 37 insertions(+), 5 deletions(-) diff --git a/include/libcamera/internal/converter.h b/include/libcamera/internal/converter.h index b51563d7..7e478356 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,8 +68,12 @@ public: const std::string &deviceNode() const { return deviceNode_; } + Features getFeatures() const { return features_; } + private: std::string deviceNode_; + + Features features_; }; class ConverterFactoryBase diff --git a/include/libcamera/internal/converter/converter_v4l2_m2m.h b/include/libcamera/internal/converter/converter_v4l2_m2m.h index b9e59899..91701dbe 100644 --- a/include/libcamera/internal/converter/converter_v4l2_m2m.h +++ b/include/libcamera/internal/converter/converter_v4l2_m2m.h @@ -35,7 +35,7 @@ class V4L2M2MDevice; class V4L2M2MConverter : public Converter { public: - V4L2M2MConverter(MediaDevice *media); + V4L2M2MConverter(MediaDevice *media, Features features = Feature::None); int loadConfiguration([[maybe_unused]] const std::string &filename) { return 0; } bool isValid() const { return m2m_ != nullptr; } diff --git a/src/libcamera/converter.cpp b/src/libcamera/converter.cpp index 2ab46133..2c3da6d4 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() @@ -163,6 +177,12 @@ Converter::~Converter() * \return The converter device node string */ +/** + * \fn Converter::getFeatures() + * \brief Gets the supported features by the converter + * \return The converter Features flag + */ + /** * \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 2e77872e..4aeb7dd9 100644 --- a/src/libcamera/converter/converter_v4l2_m2m.cpp +++ b/src/libcamera/converter/converter_v4l2_m2m.cpp @@ -191,10 +191,11 @@ void V4L2M2MConverter::V4L2M2MStream::captureBufferReady(FrameBuffer *buffer) * \fn V4L2M2MConverter::V4L2M2MConverter * \brief Construct a V4L2M2MConverter instance * \param[in] media The media device implementing the converter + * \param[in] features Features flags representing supported features */ -V4L2M2MConverter::V4L2M2MConverter(MediaDevice *media) - : Converter(media) +V4L2M2MConverter::V4L2M2MConverter(MediaDevice *media, Features features) + : Converter(media, features) { if (deviceNode().empty()) return;