[{"id":30547,"web_url":"https://patchwork.libcamera.org/comment/30547/","msgid":"<20240802193616.GD2725@pendragon.ideasonboard.com>","date":"2024-08-02T19:36:16","subject":"Re: [PATCH v6 1/5] libcamera: converter: Add interface for feature\n\tflags","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Umang,\n\nThank you for the patch.\n\nOn Fri, Jul 26, 2024 at 05:17:11PM +0530, Umang Jain wrote:\n> This patch intends to extend the converter interface to have feature\n> flags, which enables each converter to expose the set of features\n> it supports.\n\nMaking the interface more generic and more widely usable sounds very\ngood to me.\n\n> Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>\n> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>\n> ---\n>  include/libcamera/internal/converter.h        | 13 ++++++++++-\n>  .../internal/converter/converter_v4l2_m2m.h   |  2 +-\n>  src/libcamera/converter.cpp                   | 22 ++++++++++++++++++-\n>  .../converter/converter_v4l2_m2m.cpp          |  5 +++--\n>  4 files changed, 37 insertions(+), 5 deletions(-)\n> \n> diff --git a/include/libcamera/internal/converter.h b/include/libcamera/internal/converter.h\n> index b51563d7..652ff519 100644\n> --- a/include/libcamera/internal/converter.h\n> +++ b/include/libcamera/internal/converter.h\n> @@ -17,6 +17,7 @@\n>  #include <vector>\n>  \n>  #include <libcamera/base/class.h>\n> +#include <libcamera/base/flags.h>\n>  #include <libcamera/base/signal.h>\n>  \n>  #include <libcamera/geometry.h>\n> @@ -32,7 +33,13 @@ struct StreamConfiguration;\n>  class Converter\n>  {\n>  public:\n> -\tConverter(MediaDevice *media);\n> +\tenum class Feature {\n> +\t\tNone = 0,\n> +\t};\n> +\n> +\tusing Features = Flags<Feature>;\n> +\n> +\tConverter(MediaDevice *media, Features features = Feature::None);\n>  \tvirtual ~Converter();\n>  \n>  \tvirtual int loadConfiguration(const std::string &filename) = 0;\n> @@ -61,8 +68,12 @@ public:\n>  \n>  \tconst std::string &deviceNode() const { return deviceNode_; }\n>  \n> +\tFeatures features() const { return features_; }\n> +\n>  private:\n>  \tstd::string deviceNode_;\n> +\n> +\tFeatures features_;\n>  };\n>  \n>  class ConverterFactoryBase\n> diff --git a/include/libcamera/internal/converter/converter_v4l2_m2m.h b/include/libcamera/internal/converter/converter_v4l2_m2m.h\n> index b9e59899..91701dbe 100644\n> --- a/include/libcamera/internal/converter/converter_v4l2_m2m.h\n> +++ b/include/libcamera/internal/converter/converter_v4l2_m2m.h\n> @@ -35,7 +35,7 @@ class V4L2M2MDevice;\n>  class V4L2M2MConverter : public Converter\n>  {\n>  public:\n> -\tV4L2M2MConverter(MediaDevice *media);\n> +\tV4L2M2MConverter(MediaDevice *media, Features features = Feature::None);\n>  \n>  \tint loadConfiguration([[maybe_unused]] const std::string &filename) { return 0; }\n>  \tbool isValid() const { return m2m_ != nullptr; }\n> diff --git a/src/libcamera/converter.cpp b/src/libcamera/converter.cpp\n> index 2ab46133..e2dbf5e0 100644\n> --- a/src/libcamera/converter.cpp\n> +++ b/src/libcamera/converter.cpp\n> @@ -34,14 +34,27 @@ LOG_DEFINE_CATEGORY(Converter)\n>   * parameters from the same input stream.\n>   */\n>  \n> +/**\n> + * \\enum Converter::Feature\n> + * \\brief Specify the features supported by the converter\n> + * \\var Converter::Feature::None\n> + * \\brief No extra features supported by the converter\n> + */\n> +\n> +/**\n> + * \\typedef Converter::Features\n> + * \\brief A bitwise combination of features supported by the converter\n> + */\n> +\n>  /**\n>   * \\brief Construct a Converter instance\n>   * \\param[in] media The media device implementing the converter\n> + * \\param[in] features Features flags representing supported features\n>   *\n>   * This searches for the entity implementing the data streaming function in the\n>   * media graph entities and use its device node as the converter device node.\n>   */\n> -Converter::Converter(MediaDevice *media)\n> +Converter::Converter(MediaDevice *media, Features features)\n>  {\n>  \tconst std::vector<MediaEntity *> &entities = media->entities();\n>  \tauto it = std::find_if(entities.begin(), entities.end(),\n> @@ -56,6 +69,7 @@ Converter::Converter(MediaDevice *media)\n>  \t}\n>  \n>  \tdeviceNode_ = (*it)->deviceNode();\n> +\tfeatures_ = features;\n>  }\n>  \n>  Converter::~Converter()\n> @@ -163,6 +177,12 @@ Converter::~Converter()\n>   * \\return The converter device node string\n>   */\n>  \n> +/**\n> + * \\fn Converter::features()\n> + * \\brief Gets the supported features by the converter\n\n * \\brief Get the features supported by the converter\n\nOverall this looks fine, so\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nbut I may come back to this patch as I read the rest of the series.\n\n> + * \\return The converter Features flags\n> + */\n> +\n>  /**\n>   * \\class ConverterFactoryBase\n>   * \\brief Base class for converter factories\n> diff --git a/src/libcamera/converter/converter_v4l2_m2m.cpp b/src/libcamera/converter/converter_v4l2_m2m.cpp\n> index 2e77872e..4aeb7dd9 100644\n> --- a/src/libcamera/converter/converter_v4l2_m2m.cpp\n> +++ b/src/libcamera/converter/converter_v4l2_m2m.cpp\n> @@ -191,10 +191,11 @@ void V4L2M2MConverter::V4L2M2MStream::captureBufferReady(FrameBuffer *buffer)\n>   * \\fn V4L2M2MConverter::V4L2M2MConverter\n>   * \\brief Construct a V4L2M2MConverter instance\n>   * \\param[in] media The media device implementing the converter\n> + * \\param[in] features Features flags representing supported features\n>   */\n>  \n> -V4L2M2MConverter::V4L2M2MConverter(MediaDevice *media)\n> -\t: Converter(media)\n> +V4L2M2MConverter::V4L2M2MConverter(MediaDevice *media, Features features)\n> +\t: Converter(media, features)\n>  {\n>  \tif (deviceNode().empty())\n>  \t\treturn;","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 8B20CC323E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri,  2 Aug 2024 19:36:40 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id C853563370;\n\tFri,  2 Aug 2024 21:36:39 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id BEBD46336B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  2 Aug 2024 21:36:37 +0200 (CEST)","from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi\n\t[81.175.209.231])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id EBAEE524;\n\tFri,  2 Aug 2024 21:35:47 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"e2xiVLf6\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1722627348;\n\tbh=PLdZVVkbHE6w10sUgpfT+QejQHCOM9uffEsuuViAvuc=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=e2xiVLf6+kpDEXd4xxc2gHKUVzJ4wIHVzfh1q6hC6iAJDoqmM8FedZbpoWldzeb6v\n\tfkugfxwc2PfikoixynHugXh2c7TIiAjtx0OIctY/qztFQgiRjWKg83ecpD8zdyVsBC\n\tuFbFldifRd6O4UMkxQ5USfN2WHNg15YPsfghOQwc=","Date":"Fri, 2 Aug 2024 22:36:16 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Umang Jain <umang.jain@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org,\n\tKieran Bingham <kieran.bingham@ideasonboard.com>,\n\tPaul Elder <paul.elder@ideasonboard.com>","Subject":"Re: [PATCH v6 1/5] libcamera: converter: Add interface for feature\n\tflags","Message-ID":"<20240802193616.GD2725@pendragon.ideasonboard.com>","References":"<20240726114715.226468-1-umang.jain@ideasonboard.com>\n\t<20240726114715.226468-2-umang.jain@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20240726114715.226468-2-umang.jain@ideasonboard.com>","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]