From patchwork Thu Oct 23 14:48:07 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 24734 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 CA314BE080 for ; Thu, 23 Oct 2025 14:49:06 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 5E594607FE; Thu, 23 Oct 2025 16:49:06 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="hQW+jv+N"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A2ABF607ED for ; Thu, 23 Oct 2025 16:49:04 +0200 (CEST) Received: from ideasonboard.com (unknown [IPv6:2a00:6020:448c:6c00:7328:357b:4ce1:72b6]) by perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id BB2A9192B; Thu, 23 Oct 2025 16:47:19 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1761230839; bh=xBaT0D20jSTsUMVoqorXpecGMHSBSZegT7R0a+xjw0A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hQW+jv+Nk4O3vYkDuyV0h7JTrnAGihFCvxzdHvt8UwWhmaBjSnhMZH17qkNV/ub35 rlEZ1EG3xVFs6QppGxon3V/vEELk8Hw90mtOb1CyBej2rwYsAnxM9IvdiijXBIT6xM H1pHUCGL126lwSLW6jukmXDsZzd3KLOx/xEJvqvI= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug Subject: [PATCH v2 06/35] libcamera: converter: Add V4L2 request support Date: Thu, 23 Oct 2025 16:48:07 +0200 Message-ID: <20251023144841.403689-7-stefan.klug@ideasonboard.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20251023144841.403689-1-stefan.klug@ideasonboard.com> References: <20251023144841.403689-1-stefan.klug@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" Add V4L2 request support to the V4L2M2MConverter class. Extend the functions related to buffer queuing with an optional request parameter that gets passed to the lower layers. Signed-off-by: Stefan Klug --- include/libcamera/internal/converter.h | 4 +++- .../internal/converter/converter_v4l2_m2m.h | 6 ++++-- src/libcamera/converter.cpp | 3 +++ src/libcamera/converter/converter_v4l2_m2m.cpp | 12 ++++++++---- 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/include/libcamera/internal/converter.h b/include/libcamera/internal/converter.h index 4915af7ac5de..4b811686fcf6 100644 --- a/include/libcamera/internal/converter.h +++ b/include/libcamera/internal/converter.h @@ -22,6 +22,7 @@ #include #include +#include "libcamera/internal/v4l2_request.h" namespace libcamera { @@ -79,7 +80,8 @@ public: virtual void stop() = 0; virtual int queueBuffers(FrameBuffer *input, - const std::map &outputs) = 0; + const std::map &outputs, + const V4L2Request *request = nullptr) = 0; virtual int setInputCrop(const Stream *stream, Rectangle *rect) = 0; virtual std::pair inputCropBounds() = 0; diff --git a/include/libcamera/internal/converter/converter_v4l2_m2m.h b/include/libcamera/internal/converter/converter_v4l2_m2m.h index d316754040dd..1b2a88c4a608 100644 --- a/include/libcamera/internal/converter/converter_v4l2_m2m.h +++ b/include/libcamera/internal/converter/converter_v4l2_m2m.h @@ -66,7 +66,8 @@ public: Alignment align = Alignment::Down) override; int queueBuffers(FrameBuffer *input, - const std::map &outputs) override; + const std::map &outputs, + const V4L2Request *request = nullptr) override; int setInputCrop(const Stream *stream, Rectangle *rect) override; std::pair inputCropBounds() override { return inputCropBounds_; } @@ -88,7 +89,8 @@ private: int start(); void stop(); - int queueBuffers(FrameBuffer *input, FrameBuffer *output); + int queueBuffers(FrameBuffer *input, FrameBuffer *output, + const V4L2Request *request = nullptr); int setInputSelection(unsigned int target, Rectangle *rect); int getInputSelection(unsigned int target, Rectangle *rect); diff --git a/src/libcamera/converter.cpp b/src/libcamera/converter.cpp index 142fb29a1272..ec0a6db6c035 100644 --- a/src/libcamera/converter.cpp +++ b/src/libcamera/converter.cpp @@ -205,11 +205,14 @@ Converter::~Converter() * \param[in] input The frame buffer to apply the conversion * \param[out] outputs The container holding the output stream pointers and * their respective frame buffer outputs. + * \param[in] request An optional request * * This function queues the \a input frame buffer on the output streams of the * \a outputs map key and retrieve the output frame buffer indicated by the * buffer map value. * + * If \a request is provided the buffers are tied to that request. + * * \return 0 on success or a negative error code otherwise */ diff --git a/src/libcamera/converter/converter_v4l2_m2m.cpp b/src/libcamera/converter/converter_v4l2_m2m.cpp index b2bd54f368d8..ff11a9735db7 100644 --- a/src/libcamera/converter/converter_v4l2_m2m.cpp +++ b/src/libcamera/converter/converter_v4l2_m2m.cpp @@ -22,6 +22,7 @@ #include #include "libcamera/internal/media_device.h" +#include "libcamera/internal/v4l2_request.h" #include "libcamera/internal/v4l2_videodevice.h" /** @@ -197,9 +198,11 @@ void V4L2M2MConverter::V4L2M2MStream::stop() m2m_->output()->releaseBuffers(); } -int V4L2M2MConverter::V4L2M2MStream::queueBuffers(FrameBuffer *input, FrameBuffer *output) +int V4L2M2MConverter::V4L2M2MStream::queueBuffers(FrameBuffer *input, + FrameBuffer *output, + const V4L2Request *request) { - int ret = m2m_->output()->queueBuffer(input); + int ret = m2m_->output()->queueBuffer(input, request); if (ret < 0) return ret; @@ -696,7 +699,8 @@ int V4L2M2MConverter::validateOutput(StreamConfiguration *cfg, bool *adjusted, * \copydoc libcamera::Converter::queueBuffers */ int V4L2M2MConverter::queueBuffers(FrameBuffer *input, - const std::map &outputs) + const std::map &outputs, + const V4L2Request *request) { std::set outputBufs; int ret; @@ -721,7 +725,7 @@ int V4L2M2MConverter::queueBuffers(FrameBuffer *input, /* Queue the input and output buffers to all the streams. */ for (auto [stream, buffer] : outputs) { - ret = streams_.at(stream)->queueBuffers(input, buffer); + ret = streams_.at(stream)->queueBuffers(input, buffer, request); if (ret < 0) return ret; }