From patchwork Tue Sep 30 12:26:29 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 24507 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 F392FC324C for ; Tue, 30 Sep 2025 12:48:05 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 8C6526B5F0; Tue, 30 Sep 2025 14:48:05 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="Q7ZYt92d"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2FFDC62C35 for ; Tue, 30 Sep 2025 14:48:02 +0200 (CEST) Received: from ideasonboard.com (unknown [94.31.94.171]) by perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id 1E6E2220; Tue, 30 Sep 2025 14:46:33 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1759236393; bh=ArMWQcxDRD0hwuC/YGbITjh8Pirv9WLsAcSFn+8u+4M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q7ZYt92dhXHRue+xcIEftoBEOtANOYYmQHDusXNrCMKBZBn9PhlU3UKe2y7/YqKTb HnIYJhvqXL6WOudPa0oYAFaCM3jfT25URguquWg/Mi8cPhTJTE2xXiy1XuYRV9noMm bmYGIHsyIypVDFP9W1aAu2kRrPsCf+rhClcEjFbM= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug Subject: [PATCH v1 08/33] libcamera: converter_v4l2_m2m: Add suport for V4L2 requests Date: Tue, 30 Sep 2025 14:26:29 +0200 Message-ID: <20250930122726.1837524-9-stefan.klug@ideasonboard.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250930122726.1837524-1-stefan.klug@ideasonboard.com> References: <20250930122726.1837524-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 support for V4L2 reuests. Signed-off-by: Stefan Klug --- ToDo: - Fix the place where the MediaObject is acquired/released --- .../internal/converter/converter_v4l2_m2m.h | 9 ++++- .../converter/converter_v4l2_m2m.cpp | 34 ++++++++++++++++++- 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/include/libcamera/internal/converter/converter_v4l2_m2m.h b/include/libcamera/internal/converter/converter_v4l2_m2m.h index 1b2a88c4a608..3b8fc5392b7d 100644 --- a/include/libcamera/internal/converter/converter_v4l2_m2m.h +++ b/include/libcamera/internal/converter/converter_v4l2_m2m.h @@ -73,7 +73,12 @@ public: std::pair inputCropBounds() override { return inputCropBounds_; } std::pair inputCropBounds(const Stream *stream) override; -private: + int allocateRequests(unsigned int count, + std::vector> *requests); + + bool supportsRequests(); + +protected: class V4L2M2MStream : protected Loggable { public: @@ -122,6 +127,8 @@ private: std::map> streams_; std::map queue_; std::pair inputCropBounds_; + + std::shared_ptr media_; }; } /* namespace libcamera */ diff --git a/src/libcamera/converter/converter_v4l2_m2m.cpp b/src/libcamera/converter/converter_v4l2_m2m.cpp index ff11a9735db7..c6153d728c9a 100644 --- a/src/libcamera/converter/converter_v4l2_m2m.cpp +++ b/src/libcamera/converter/converter_v4l2_m2m.cpp @@ -9,6 +9,7 @@ #include "libcamera/internal/converter/converter_v4l2_m2m.h" #include +#include #include #include #include @@ -266,7 +267,7 @@ void V4L2M2MConverter::V4L2M2MStream::captureBufferReady(FrameBuffer *buffer) * \param[in] media The media device implementing the converter */ V4L2M2MConverter::V4L2M2MConverter(std::shared_ptr media) - : Converter(media) + : Converter(media), media_(media) { if (deviceNode().empty()) return; @@ -742,6 +743,37 @@ int V4L2M2MConverter::queueBuffers(FrameBuffer *input, return 0; } +/** + * \copydoc libcamera::MediaDevice::allocateRequests + */ +int V4L2M2MConverter::allocateRequests(unsigned int count, + std::vector> *requests) +{ + /* \todo The acquire() must be moved to the right place. */ + media_->acquire(); + if (!media_->busy()) + LOG(Converter, Error) + << "MediaDevice must be valid."; + int ret = media_->allocateRequests(count, requests); + media_->release(); + return ret; +} + +/** + * \copydoc libcamera::MediaDevice::supportsRequests + */ +bool V4L2M2MConverter::supportsRequests() +{ + /* \todo The acquire() must be moved to the right place. */ + media_->acquire(); + if (!media_->busy()) + LOG(Converter, Error) + << "MediaDevice must be valid."; + bool ret = media_->supportsRequests(); + media_->release(); + return ret; +} + /* * \todo This should be extended to include Feature::Flag to denote * what each converter supports feature-wise.