From patchwork Mon Jun 29 16:29:42 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= X-Patchwork-Id: 27098 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 801D3C3261 for ; Mon, 29 Jun 2026 16:31:07 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 374FA65F4E; Mon, 29 Jun 2026 18:30:58 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="r+dqhxNS"; 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 5FDDB65F2A for ; Mon, 29 Jun 2026 18:30:25 +0200 (CEST) Received: from pb-laptop.local (185.221.140.128.nat.pool.zt.hu [185.221.140.128]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 35FF31044 for ; Mon, 29 Jun 2026 18:29:42 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1782750582; bh=i6QUviw1gSUZdOE9lYq+QkoZHCUpi+dBmjZE8ArEtxY=; h=From:To:Subject:Date:In-Reply-To:References:From; b=r+dqhxNSG4j6UcsbizozS9wzlVuZYRAMymmzy87l2OgLhaQl1SD4ajQjj4ZAoKvYt Aa+AjRXy17ejbSqV9bhtSsPmeEufFbv+qT1/wp+l5Pi++QONrFjhW1ObcPCg+0DVjI 9ybLs1DPJDun4f9wH/Sd3CU9xoaltHefZU9WSiWk= From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= To: libcamera-devel@lists.libcamera.org Subject: [RFC PATCH v1 19/54] libcamera: framebuffer: request(): Move to private type Date: Mon, 29 Jun 2026 18:29:42 +0200 Message-ID: <20260629163017.863145-20-barnabas.pocze@ideasonboard.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260629163017.863145-1-barnabas.pocze@ideasonboard.com> References: <20260629163017.863145-1-barnabas.pocze@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" The `request()` is of not much interest to normal applications, mainly because the request-buffer association is removed when the buffer completes. Therefore the only place where this can actually be used is in the `bufferCompleted` signal, but the request is already provided there by other means. So move the function into the associated `Private` type. Signed-off-by: Barnabás Pőcze --- Documentation/guides/pipeline-handler.rst | 8 ++++- include/libcamera/framebuffer.h | 1 - include/libcamera/internal/framebuffer.h | 2 ++ src/libcamera/framebuffer.cpp | 33 +++++++++----------- src/libcamera/pipeline/imx8-isi/imx8-isi.cpp | 3 +- src/libcamera/pipeline/mali-c55/mali-c55.cpp | 2 +- src/libcamera/pipeline/rkisp1/rkisp1.cpp | 4 +-- src/libcamera/pipeline/simple/simple.cpp | 15 ++++----- src/libcamera/pipeline/uvcvideo/uvcvideo.cpp | 3 +- src/libcamera/pipeline/vimc/vimc.cpp | 2 +- src/libcamera/pipeline/virtual/virtual.cpp | 2 +- 11 files changed, 41 insertions(+), 34 deletions(-) diff --git a/Documentation/guides/pipeline-handler.rst b/Documentation/guides/pipeline-handler.rst index b33d8b8574..2d2231eb68 100644 --- a/Documentation/guides/pipeline-handler.rst +++ b/Documentation/guides/pipeline-handler.rst @@ -1400,12 +1400,18 @@ code-base. void VividCameraData::bufferReady(FrameBuffer *buffer) { - Request *request = buffer->request(); + Request *request = buffer->_d()->request(); pipe_->completeBuffer(request, buffer); pipe_->completeRequest(request); } +The following new include statements are needed for the above: + +.. code-block:: cpp + + #include "libcamera/internal/framebuffer.h" + Testing a pipeline handler ~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/include/libcamera/framebuffer.h b/include/libcamera/framebuffer.h index 723525d052..3ac1609f56 100644 --- a/include/libcamera/framebuffer.h +++ b/include/libcamera/framebuffer.h @@ -63,7 +63,6 @@ public: virtual ~FrameBuffer() {} Span planes() const; - Request *request() const; const FrameMetadata &metadata() const; uint64_t cookie() const; diff --git a/include/libcamera/internal/framebuffer.h b/include/libcamera/internal/framebuffer.h index 67b090fc30..7e96100b6c 100644 --- a/include/libcamera/internal/framebuffer.h +++ b/include/libcamera/internal/framebuffer.h @@ -27,7 +27,9 @@ public: Private(Span planes, uint64_t cookie = 0); virtual ~Private(); + Request *request() const { return request_; } void setRequest(Request *request) { request_ = request; } + bool isContiguous() const { return isContiguous_; } Fence *fence() const { return fence_.get(); } diff --git a/src/libcamera/framebuffer.cpp b/src/libcamera/framebuffer.cpp index 6ea4d6ea21..4f23df6482 100644 --- a/src/libcamera/framebuffer.cpp +++ b/src/libcamera/framebuffer.cpp @@ -144,6 +144,21 @@ FrameBuffer::Private::~Private() { } +/** + * \fn FrameBuffer::Private::request() + * \brief Retrieve the request this buffer belongs to + * + * The intended callers of this function are buffer completion handlers that + * need to associate a buffer to the request it belongs to. + * + * A FrameBuffer is associated to a request by Request::addBuffer() and the + * association is valid until the buffer completes. The returned request + * pointer is valid only during that interval. + * + * \return The Request the FrameBuffer belongs to, or nullptr if the buffer is + * not associated with a request + */ + /** * \fn FrameBuffer::Private::setRequest() * \brief Set the request this buffer belongs to @@ -364,24 +379,6 @@ Span FrameBuffer::planes() const return _d()->planes_; } -/** - * \brief Retrieve the request this buffer belongs to - * - * The intended callers of this function are buffer completion handlers that - * need to associate a buffer to the request it belongs to. - * - * A FrameBuffer is associated to a request by Request::addBuffer() and the - * association is valid until the buffer completes. The returned request - * pointer is valid only during that interval. - * - * \return The Request the FrameBuffer belongs to, or nullptr if the buffer is - * not associated with a request - */ -Request *FrameBuffer::request() const -{ - return _d()->request_; -} - /** * \brief Retrieve the dynamic metadata * \return Dynamic metadata for the frame contained in the buffer diff --git a/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp b/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp index 5f15fbdc08..d3f152aa1e 100644 --- a/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp +++ b/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp @@ -24,6 +24,7 @@ #include "libcamera/internal/camera.h" #include "libcamera/internal/camera_sensor.h" #include "libcamera/internal/device_enumerator.h" +#include "libcamera/internal/framebuffer.h" #include "libcamera/internal/media_device.h" #include "libcamera/internal/media_pipeline.h" #include "libcamera/internal/pipeline_handler.h" @@ -1124,7 +1125,7 @@ PipelineHandlerISI::Pipe *PipelineHandlerISI::pipeFromStream(ISICameraData *data void PipelineHandlerISI::bufferReady(FrameBuffer *buffer) { - Request *request = buffer->request(); + Request *request = buffer->_d()->request(); /* Record the sensor's timestamp in the request metadata. */ ControlList &metadata = request->_d()->metadata(); diff --git a/src/libcamera/pipeline/mali-c55/mali-c55.cpp b/src/libcamera/pipeline/mali-c55/mali-c55.cpp index b30455683e..0c7b7ed370 100644 --- a/src/libcamera/pipeline/mali-c55/mali-c55.cpp +++ b/src/libcamera/pipeline/mali-c55/mali-c55.cpp @@ -1649,7 +1649,7 @@ void PipelineHandlerMaliC55::tryComplete(MaliC55FrameInfo *info, bool cancelled) void PipelineHandlerMaliC55::imageBufferReady(FrameBuffer *buffer) { - Request *request = buffer->request(); + Request *request = buffer->_d()->request(); MaliC55FrameInfo *info = findFrameInfo(request); ASSERT(info); diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp index 4f9c0aa741..0c1e5767b4 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp @@ -1695,9 +1695,9 @@ void PipelineHandlerRkISP1::dewarpBufferReady(FrameBuffer *buffer) { ASSERT(activeCamera_); RkISP1CameraData *data = cameraData(activeCamera_); - Request *request = buffer->request(); + Request *request = buffer->_d()->request(); - RkISP1FrameInfo *info = data->frameInfo_.find(buffer->request()); + RkISP1FrameInfo *info = data->frameInfo_.find(request); if (!info) return; diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp index e26f438d9a..381f8db3ee 100644 --- a/src/libcamera/pipeline/simple/simple.cpp +++ b/src/libcamera/pipeline/simple/simple.cpp @@ -40,6 +40,7 @@ #include "libcamera/internal/delayed_controls.h" #include "libcamera/internal/device_enumerator.h" #include "libcamera/internal/formats.h" +#include "libcamera/internal/framebuffer.h" #include "libcamera/internal/global_configuration.h" #include "libcamera/internal/media_device.h" #include "libcamera/internal/pipeline_handler.h" @@ -887,7 +888,7 @@ void SimpleCameraData::imageBufferReady(FrameBuffer *buffer) if (buffer->metadata().status != FrameMetadata::FrameSuccess) { if (!useConversion_ || rawStream_) { /* No conversion, just complete the request. */ - Request *request = buffer->request(); + Request *request = buffer->_d()->request(); pipe->completeBuffer(request, buffer); SimpleFrameInfo *info = frameInfo_.find(request->sequence()); if (info) @@ -927,7 +928,7 @@ void SimpleCameraData::imageBufferReady(FrameBuffer *buffer) * \todo The sensor timestamp should be better estimated by connecting * to the V4L2Device::frameStart signal if the platform provides it. */ - Request *request = buffer->request(); + Request *request = buffer->_d()->request(); if (useConversion_ && !conversionQueue_.empty()) { const std::map &outputs = @@ -935,7 +936,7 @@ void SimpleCameraData::imageBufferReady(FrameBuffer *buffer) if (!outputs.empty()) { FrameBuffer *outputBuffer = outputs.begin()->second; if (outputBuffer) - request = outputBuffer->request(); + request = outputBuffer->_d()->request(); } } @@ -960,8 +961,8 @@ void SimpleCameraData::imageBufferReady(FrameBuffer *buffer) else /* * request->sequence() cannot be retrieved from `buffer' inside - * queueBuffers because unique_ptr's make buffer->request() invalid - * already here. + * queueBuffers because unique_ptr's make buffer->_d()->request() + * invalid already here. */ swIsp_->queueBuffers(request->sequence(), buffer, conversionQueue_.front().outputs); @@ -1005,7 +1006,7 @@ void SimpleCameraData::conversionInputDone(FrameBuffer *buffer) { if (rawStream_) { /* Complete the input buffer as with raw-only processing. */ - Request *request = buffer->request(); + Request *request = buffer->_d()->request(); if (pipe()->completeBuffer(request, buffer)) tryCompleteRequest(request); } else { @@ -1019,7 +1020,7 @@ void SimpleCameraData::conversionOutputDone(FrameBuffer *buffer) SimplePipelineHandler *pipe = SimpleCameraData::pipe(); /* Complete the buffer and the request. */ - Request *request = buffer->request(); + Request *request = buffer->_d()->request(); if (pipe->completeBuffer(request, buffer)) tryCompleteRequest(request); } diff --git a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp index 3435a76046..f8d49d9122 100644 --- a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp +++ b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp @@ -28,6 +28,7 @@ #include "libcamera/internal/camera.h" #include "libcamera/internal/device_enumerator.h" +#include "libcamera/internal/framebuffer.h" #include "libcamera/internal/media_device.h" #include "libcamera/internal/pipeline_handler.h" #include "libcamera/internal/request.h" @@ -892,7 +893,7 @@ void UVCCameraData::addControl(uint32_t cid, const ControlInfo &v4l2Info, void UVCCameraData::imageBufferReady(FrameBuffer *buffer) { - Request *request = buffer->request(); + Request *request = buffer->_d()->request(); /* \todo Use the UVC metadata to calculate a more precise timestamp */ request->_d()->metadata().set(controls::SensorTimestamp, diff --git a/src/libcamera/pipeline/vimc/vimc.cpp b/src/libcamera/pipeline/vimc/vimc.cpp index 99ae60785b..528022776e 100644 --- a/src/libcamera/pipeline/vimc/vimc.cpp +++ b/src/libcamera/pipeline/vimc/vimc.cpp @@ -601,7 +601,7 @@ void VimcCameraData::imageBufferReady(FrameBuffer *buffer) { PipelineHandlerVimc *pipe = static_cast(this->pipe()); - Request *request = buffer->request(); + Request *request = buffer->_d()->request(); /* If the buffer is cancelled force a complete of the whole request. */ if (buffer->metadata().status == FrameMetadata::FrameCancelled) { diff --git a/src/libcamera/pipeline/virtual/virtual.cpp b/src/libcamera/pipeline/virtual/virtual.cpp index a7cd76e226..f9e2cecea3 100644 --- a/src/libcamera/pipeline/virtual/virtual.cpp +++ b/src/libcamera/pipeline/virtual/virtual.cpp @@ -452,7 +452,7 @@ bool PipelineHandlerVirtual::initFrameGenerator(Camera *camera) void PipelineHandlerVirtual::bufferCompleted(FrameBuffer *buffer) { - Request *request = buffer->request(); + Request *request = buffer->_d()->request(); if (completeBuffer(request, buffer)) completeRequest(request);