From patchwork Thu Oct 23 14:48:13 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 24740 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 0FD40C3331 for ; Thu, 23 Oct 2025 14:49:25 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id AB5C360811; Thu, 23 Oct 2025 16:49:24 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="Rnk0QDZh"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 43AD160803 for ; Thu, 23 Oct 2025 16:49:22 +0200 (CEST) Received: from ideasonboard.com (unknown [IPv6:2a00:6020:448c:6c00:7328:357b:4ce1:72b6]) by perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id 4E2F2EFE; Thu, 23 Oct 2025 16:47:37 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1761230857; bh=7FkM8Y3TcCjkciHfIi7EET5p0hjejxGMzSOiDuFEngA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Rnk0QDZhyoMM2QxolnXI9z16eiDPYShX9nRbW5qLf+9LdXfgBQp/P6+XaA+NT214m sEM6FVQA9oV3D1ZcJMFgSIAO963POVR4I33gGdIRPGQBE6fzPiKFeMu7fxW7e5IVuH CTRVvkEmo3yxlfXjJV2GYjntKEzqJVkyEzGW/cb4= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug , Umang Jain Subject: [PATCH v2 12/35] libcamera: converter_v4l2_m2m: Add helper to apply controls Date: Thu, 23 Oct 2025 16:48:13 +0200 Message-ID: <20251023144841.403689-13-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" From: Umang Jain Add applyControls() helper to apply controls for a stream. Signed-off-by: Umang Jain Signed-off-by: Stefan Klug --- Changes in v2: - Removed stray semicolon - Added documentation Changes in v0.9 - Include request support in applyControls --- .../internal/converter/converter_v4l2_m2m.h | 5 +++ .../converter/converter_v4l2_m2m.cpp | 34 +++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/include/libcamera/internal/converter/converter_v4l2_m2m.h b/include/libcamera/internal/converter/converter_v4l2_m2m.h index bc85bff7a07b..6d2453bb9e06 100644 --- a/include/libcamera/internal/converter/converter_v4l2_m2m.h +++ b/include/libcamera/internal/converter/converter_v4l2_m2m.h @@ -24,6 +24,7 @@ namespace libcamera { +class ControlList; class FrameBuffer; class MediaDevice; class Size; @@ -73,6 +74,8 @@ public: std::pair inputCropBounds() override { return inputCropBounds_; } std::pair inputCropBounds(const Stream *stream) override; + int applyControls(const Stream *stream, ControlList &ctrls, const V4L2Request *request = nullptr); + int allocateRequests(unsigned int count, std::vector> *requests); @@ -94,6 +97,8 @@ private: int start(); void stop(); + int applyControls(ControlList &ctrls, const V4L2Request *request = nullptr); + int queueBuffers(FrameBuffer *input, FrameBuffer *output, const V4L2Request *request = nullptr); diff --git a/src/libcamera/converter/converter_v4l2_m2m.cpp b/src/libcamera/converter/converter_v4l2_m2m.cpp index e57db8a438ab..48e49f143cf1 100644 --- a/src/libcamera/converter/converter_v4l2_m2m.cpp +++ b/src/libcamera/converter/converter_v4l2_m2m.cpp @@ -18,6 +18,7 @@ #include #include +#include #include #include #include @@ -251,6 +252,20 @@ void V4L2M2MConverter::V4L2M2MStream::captureBufferReady(FrameBuffer *buffer) converter_->outputBufferReady.emit(buffer); } +/** + * \brief Apply controls + * \param[in] ctrls The controls to apply + * \param[in] request An optional request + * + * \return 0 on success or a negative error code otherwise + * \see V4L2Device::setControls() + */ +int V4L2M2MConverter::V4L2M2MStream::applyControls(ControlList &ctrls, + const V4L2Request *request) +{ + return m2m_->capture()->setControls(&ctrls, request); +} + /* ----------------------------------------------------------------------------- * V4L2M2MConverter */ @@ -744,6 +759,25 @@ int V4L2M2MConverter::queueBuffers(FrameBuffer *input, return 0; } +/** + * \brief Apply controls + * \param[in] stream The stream on which to apply the controls + * \param[in] ctrls The controls to apply + * \param[in] request An optional request + * + * \return 0 on success or a negative error code otherwise + * \see V4L2Device::setControls() + */ +int V4L2M2MConverter::applyControls(const Stream *stream, ControlList &ctrls, + const V4L2Request *request) +{ + auto iter = streams_.find(stream); + if (iter == streams_.end()) + return -EINVAL; + + return iter->second->applyControls(ctrls, request); +} + /** * \copydoc libcamera::MediaDevice::allocateRequests */