From patchwork Tue Nov 25 16:28:21 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 25188 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 2380EC333C for ; Tue, 25 Nov 2025 16:29:23 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C7AB660AB1; Tue, 25 Nov 2025 17:29:22 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="oTcV64Eh"; 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 5348960A85 for ; Tue, 25 Nov 2025 17:29:21 +0100 (CET) Received: from ideasonboard.com (unknown [IPv6:2a00:6020:448c:6c00:bae1:340c:573c:570b]) by perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id 5571B1E2A; Tue, 25 Nov 2025 17:27:12 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1764088032; bh=klZ9dbavnx5ai/wUySH711DwmVvRN/fwBS7jblr1XFo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oTcV64Ehhu4F60PZSjei/2+2cMRzUcUaOjLXIZQHP6cu1atyibikmt4xRHWY8/+zC J7OCZ1Aq/ucn7gmEiLecT12ulZL7Ugay6UMYei2JILbORJW7QiuwVb+Hc3aUZPrOF1 O2hZ/UZcbNcWsLQoGKNXYL6mCVGT1zYz5uw9SAVU= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug , Umang Jain , Isaac Scott , Paul Elder Subject: [PATCH v3 09/29] libcamera: converter_v4l2_m2m: Add helper to apply controls Date: Tue, 25 Nov 2025 17:28:21 +0100 Message-ID: <20251125162851.2301793-10-stefan.klug@ideasonboard.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251125162851.2301793-1-stefan.klug@ideasonboard.com> References: <20251125162851.2301793-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 Reviewed-by: Isaac Scott Reviewed-by: Paul Elder --- Changes in v3: - Collected tags 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 */