From patchwork Fri Aug 15 11:33:53 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 24131 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 857D7BEFBE for ; Fri, 15 Aug 2025 11:34:28 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E7C806925E; Fri, 15 Aug 2025 13:34:23 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="Ef4jFpon"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id DE45861443 for ; Fri, 15 Aug 2025 13:34:21 +0200 (CEST) Received: from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi [81.175.209.231]) by perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id E1287605; Fri, 15 Aug 2025 13:33:26 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1755257607; bh=yRAxsrQ6ipP0IxLlpZKKaiJQ3ujWO9s1cmAAiPwGlHE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ef4jFponHfCvA9TDD0+VJYHW1YKB/qIZ5xas87iWkHQicXo3Zb0RMHCpzMnmTZRZm tEivEKNIosLkt5rgthOQ4RU28mCS6U7N5WkC3BFz8ksqDlTcGR87Cg+VLHbfN5qkYY kz05fbWhhjx0amyHTImgQ9yj1Nz/NsNf2Ho3JPsc= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Cc: =?utf-8?q?Daniel_R=C3=A1kos?= Subject: [PATCH v2 1/8] libcamera: v4l2_videodevice: Avoid repeated calls to FrameBuffer::planes() Date: Fri, 15 Aug 2025 14:33:53 +0300 Message-ID: <20250815113400.20623-2-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.49.1 In-Reply-To: <20250815113400.20623-1-laurent.pinchart@ideasonboard.com> References: <20250815113400.20623-1-laurent.pinchart@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 V4L2VideoDevice::dequeueBuffer() calls buffer->planes() multiple times. Store the planes array in a local variable to make this more efficient. Signed-off-by: Laurent Pinchart Reviewed-by: Barnabás Pőcze Reviewed-by: Jacopo Mondi --- src/libcamera/v4l2_videodevice.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp index 5b3530b4e542..ba1889a939cb 100644 --- a/src/libcamera/v4l2_videodevice.cpp +++ b/src/libcamera/v4l2_videodevice.cpp @@ -1909,9 +1909,10 @@ FrameBuffer *V4L2VideoDevice::dequeueBuffer() } metadata.sequence -= firstFrame_.value(); + const std::vector &framebufferPlanes = buffer->planes(); unsigned int numV4l2Planes = multiPlanar ? buf.length : 1; - if (numV4l2Planes != buffer->planes().size()) { + if (numV4l2Planes != framebufferPlanes.size()) { /* * If we have a multi-planar buffer with a V4L2 * single-planar format, split the V4L2 buffer across @@ -1921,7 +1922,7 @@ FrameBuffer *V4L2VideoDevice::dequeueBuffer() if (numV4l2Planes != 1) { LOG(V4L2, Error) << "Invalid number of planes (" << numV4l2Planes - << " != " << buffer->planes().size() << ")"; + << " != " << framebufferPlanes.size() << ")"; metadata.status = FrameMetadata::FrameError; return buffer; @@ -1938,12 +1939,12 @@ FrameBuffer *V4L2VideoDevice::dequeueBuffer() : buf.bytesused; unsigned int remaining = bytesused; - for (auto [i, plane] : utils::enumerate(buffer->planes())) { + for (auto [i, plane] : utils::enumerate(framebufferPlanes)) { if (!remaining) { LOG(V4L2, Error) << "Dequeued buffer (" << bytesused << " bytes) too small for plane lengths " - << utils::join(buffer->planes(), "/", + << utils::join(framebufferPlanes, "/", [](const FrameBuffer::Plane &p) { return p.length; }); From patchwork Fri Aug 15 11:33:54 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 24132 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 1AD7ABEFBE for ; Fri, 15 Aug 2025 11:34:31 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 65DC869261; Fri, 15 Aug 2025 13:34:29 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="rXTOHjo/"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id C1AAC6925D for ; Fri, 15 Aug 2025 13:34:23 +0200 (CEST) Received: from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi [81.175.209.231]) by perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id 6EF52605; Fri, 15 Aug 2025 13:33:28 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1755257608; bh=YxKBMPcQIEiYdrAAYSJTEHk9022hAOmoGqLHiRAhLC8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rXTOHjo/3zmuk85RA+cc+ZE3BAq0dq/1/JgVv0p4whdsDZTVdnGiWzDk2L/h7ST66 LT51LNUERiLs1I3IOIKk8YnIe0dVTCX8MW3ZUUvqN/EhGAyY4cwjGB1JLfZIJZ3++h 3y6c6fOyeOjQSVV8HYa7mJmjxFO4y7ymokZMRDEM= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Cc: =?utf-8?q?Daniel_R=C3=A1kos?= Subject: [PATCH v2 2/8] pipeline: ipu3: Drop unneeded forward declarations Date: Fri, 15 Aug 2025 14:33:54 +0300 Message-ID: <20250815113400.20623-3-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.49.1 In-Reply-To: <20250815113400.20623-1-laurent.pinchart@ideasonboard.com> References: <20250815113400.20623-1-laurent.pinchart@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" Multiple classes are forward-declared in frames.h, without being used in that header file. Drop the unneeded forward declarations. Signed-off-by: Laurent Pinchart Reviewed-by: Barnabás Pőcze Reviewed-by: Jacopo Mondi --- src/libcamera/pipeline/ipu3/frames.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/libcamera/pipeline/ipu3/frames.h b/src/libcamera/pipeline/ipu3/frames.h index 1cabd0e64d6e..36a23b9b198e 100644 --- a/src/libcamera/pipeline/ipu3/frames.h +++ b/src/libcamera/pipeline/ipu3/frames.h @@ -19,11 +19,7 @@ namespace libcamera { class FrameBuffer; -class IPAProxy; -class PipelineHandler; class Request; -class V4L2VideoDevice; -struct IPABuffer; class IPU3Frames { From patchwork Fri Aug 15 11:33:55 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 24133 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 A431EBEFBE for ; Fri, 15 Aug 2025 11:34:32 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0FDE869263; Fri, 15 Aug 2025 13:34:32 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="jeZgBCYk"; 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 01EFA61443 for ; Fri, 15 Aug 2025 13:34:25 +0200 (CEST) Received: from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi [81.175.209.231]) by perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id 02AC2605; Fri, 15 Aug 2025 13:33:29 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1755257610; bh=nsbVr4+Y4gYjD5ICyepngMpK8g6aNzDw3bHDF/himBE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jeZgBCYkCKUM/gl1kbjFpqo+6cvZhTadxbC3QbKlDkQUaOcb6tj/oY+hEUKAJyc3d 6snGoZQ/7EXwBsOAdL8U0d8dS/dn7QKa9dRTzdio7gmV9lKxpreSR1hGadJu+HUE8s +tpHshIXByeGZSlCl2n8mF5v44WUtDFq18aG7uhg= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Cc: =?utf-8?q?Daniel_R=C3=A1kos?= Subject: [PATCH v2 3/8] pipeline: rkisp1: Replace error handling gotos with utils::exit_scope Date: Fri, 15 Aug 2025 14:33:55 +0300 Message-ID: <20250815113400.20623-4-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.49.1 In-Reply-To: <20250815113400.20623-1-laurent.pinchart@ideasonboard.com> References: <20250815113400.20623-1-laurent.pinchart@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" Use utils::exit_scope in PipelineHandlerRkISP1::allocateBuffers() to avoid gotos for error handling. Signed-off-by: Laurent Pinchart Reviewed-by: Barnabás Pőcze Reviewed-by: Jacopo Mondi --- src/libcamera/pipeline/rkisp1/rkisp1.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp index 81370f4cdcba..55d7d4442caf 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp @@ -1002,21 +1002,27 @@ int PipelineHandlerRkISP1::allocateBuffers(Camera *camera) unsigned int ipaBufferId = 1; int ret; + auto errorCleanup = utils::scope_exit{ [&]() { + paramBuffers_.clear(); + statBuffers_.clear(); + mainPathBuffers_.clear(); + } }; + if (!isRaw_) { ret = param_->allocateBuffers(kRkISP1MinBufferCount, ¶mBuffers_); if (ret < 0) - goto error; + return ret; ret = stat_->allocateBuffers(kRkISP1MinBufferCount, &statBuffers_); if (ret < 0) - goto error; + return ret; } /* If the dewarper is being used, allocate internal buffers for ISP. */ if (useDewarper_) { ret = mainPath_.exportBuffers(kRkISP1MinBufferCount, &mainPathBuffers_); if (ret < 0) - goto error; + return ret; for (std::unique_ptr &buffer : mainPathBuffers_) availableMainPathBuffers_.push(buffer.get()); @@ -1038,14 +1044,8 @@ int PipelineHandlerRkISP1::allocateBuffers(Camera *camera) data->ipa_->mapBuffers(data->ipaBuffers_); + errorCleanup.release(); return 0; - -error: - paramBuffers_.clear(); - statBuffers_.clear(); - mainPathBuffers_.clear(); - - return ret; } int PipelineHandlerRkISP1::freeBuffers(Camera *camera) From patchwork Fri Aug 15 11:33:56 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 24134 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 F3D1ABEFBE for ; Fri, 15 Aug 2025 11:34:34 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7363D6925D; Fri, 15 Aug 2025 13:34:34 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="LA7ihypI"; 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 A370269257 for ; Fri, 15 Aug 2025 13:34:26 +0200 (CEST) Received: from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi [81.175.209.231]) by perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id 9A71B63B; Fri, 15 Aug 2025 13:33:31 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1755257611; bh=R+akpr3BA09U9c5eXYOfZHxCa4barmtuykPCYQuuVC8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LA7ihypIGQgFNWvMAnKNcHI2ILeUi4H1y6sSL7Boig6ZrDCayPqVToibtYsGwR0Pn Ms7ItwOVEivGFUlWaksVDszneEP4fRBcBzAA+RusKRhVPdHZHFduH09+p8W88sAVVC QFMQOysHY1vTfvbAYBjyQuVTmxyl9ZMhsHewuRlw= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Cc: =?utf-8?q?Daniel_R=C3=A1kos?= Subject: [PATCH v2 4/8] pipeline: rpi: Use structured bindings in range-based for loop Date: Fri, 15 Aug 2025 14:33:56 +0300 Message-ID: <20250815113400.20623-5-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.49.1 In-Reply-To: <20250815113400.20623-1-laurent.pinchart@ideasonboard.com> References: <20250815113400.20623-1-laurent.pinchart@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" Simplify a range-based for loop by replacing an iterator with structure bindings. This makes the code easier to read. Signed-off-by: Laurent Pinchart Reviewed-by: Barnabás Pőcze Reviewed-by: Jacopo Mondi --- src/libcamera/pipeline/rpi/common/pipeline_base.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp index 563df198e6e4..09d30f34d9b7 100644 --- a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp +++ b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp @@ -882,10 +882,10 @@ void PipelineHandlerBase::mapBuffers(Camera *camera, const BufferMap &buffers, u * This will allow us to identify buffers passed between the pipeline * handler and the IPA. */ - for (auto const &it : buffers) { - bufferIds.push_back(IPABuffer(mask | it.first, - it.second.buffer->planes())); - data->bufferIds_.insert(mask | it.first); + for (auto const &[id, buffer] : buffers) { + bufferIds.push_back(IPABuffer(mask | id, + buffer.buffer->planes())); + data->bufferIds_.insert(mask | id); } data->ipa_->mapBuffers(bufferIds); From patchwork Fri Aug 15 11:33:57 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 24135 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 F37E4BEFBE for ; Fri, 15 Aug 2025 11:34:37 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B1EF86925D; Fri, 15 Aug 2025 13:34:37 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="bEFX2zPp"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 71D8169251 for ; Fri, 15 Aug 2025 13:34:28 +0200 (CEST) Received: from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi [81.175.209.231]) by perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id 70E1C63B; Fri, 15 Aug 2025 13:33:33 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1755257613; bh=yZc1jB0bY0Wa6dNl9pZAzm5dpSoIOCPGERzEMBhYw4Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bEFX2zPpByIgHxY1rEEyPuQeTavjJgrfbLJAZM3BUgYxA5rRdeGPXi46Sya5PA7by gDf9kd3Y+CWnayN8o9J6SDeZublCfncYmsAMsqD8kpJhptvMTY16NecPCIBboL4aMT NF4kfmVAns5sCnwM1xqK2kplT0xP0oPUPq7HWLBY= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Cc: =?utf-8?q?Daniel_R=C3=A1kos?= Subject: [PATCH v2 5/8] pipelines: Use lambda functions to factor out buffer mapping code Date: Fri, 15 Aug 2025 14:33:57 +0300 Message-ID: <20250815113400.20623-6-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.49.1 In-Reply-To: <20250815113400.20623-1-laurent.pinchart@ideasonboard.com> References: <20250815113400.20623-1-laurent.pinchart@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" Multiple pipeline handlers duplicate code related to mapping params and stats buffers to IPA modules. Factor out the code to lambda functions to share it between the two buffer types. Signed-off-by: Laurent Pinchart Reviewed-by: Barnabás Pőcze Reviewed-by: Jacopo Mondi --- src/libcamera/pipeline/ipu3/ipu3.cpp | 16 +++++++------ src/libcamera/pipeline/mali-c55/mali-c55.cpp | 24 ++++++++++---------- src/libcamera/pipeline/rkisp1/rkisp1.cpp | 22 +++++++++--------- 3 files changed, 32 insertions(+), 30 deletions(-) diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index ad20810e6a26..7ae85e5063db 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -678,15 +678,17 @@ int PipelineHandlerIPU3::allocateBuffers(Camera *camera) /* Map buffers to the IPA. */ unsigned int ipaBufferId = 1; - for (const std::unique_ptr &buffer : imgu->paramBuffers_) { + auto pushBuffer = [&](std::vector &buffers, + const std::unique_ptr &buffer) { buffer->setCookie(ipaBufferId++); - ipaBuffers_.emplace_back(buffer->cookie(), buffer->planes()); - } + buffers.emplace_back(buffer->cookie(), buffer->planes()); + }; - for (const std::unique_ptr &buffer : imgu->statBuffers_) { - buffer->setCookie(ipaBufferId++); - ipaBuffers_.emplace_back(buffer->cookie(), buffer->planes()); - } + for (const std::unique_ptr &buffer : imgu->paramBuffers_) + pushBuffer(ipaBuffers_, buffer); + + for (const std::unique_ptr &buffer : imgu->statBuffers_) + pushBuffer(ipaBuffers_, buffer); data->ipa_->mapBuffers(ipaBuffers_); diff --git a/src/libcamera/pipeline/mali-c55/mali-c55.cpp b/src/libcamera/pipeline/mali-c55/mali-c55.cpp index 76341ed3f363..f03a03fef35c 100644 --- a/src/libcamera/pipeline/mali-c55/mali-c55.cpp +++ b/src/libcamera/pipeline/mali-c55/mali-c55.cpp @@ -1133,27 +1133,27 @@ int PipelineHandlerMaliC55::allocateBuffers(Camera *camera) data->dsStream_.configuration().bufferCount, }); + auto pushBuffer = [&](std::queue &queue, + std::vector &buffers, + const std::unique_ptr &buffer) { + buffer->setCookie(ipaBufferId++); + buffers.emplace_back(buffer->cookie(), buffer->planes()); + queue.push(buffer.get()); + }; + ret = stats_->allocateBuffers(bufferCount, &statsBuffers_); if (ret < 0) return ret; - for (std::unique_ptr &buffer : statsBuffers_) { - buffer->setCookie(ipaBufferId++); - data->ipaStatBuffers_.emplace_back(buffer->cookie(), - buffer->planes()); - availableStatsBuffers_.push(buffer.get()); - } + for (std::unique_ptr &buffer : statsBuffers_) + pushBuffer(availableStatsBuffers_, data->ipaStatBuffers_, buffer); ret = params_->allocateBuffers(bufferCount, ¶msBuffers_); if (ret < 0) return ret; - for (std::unique_ptr &buffer : paramsBuffers_) { - buffer->setCookie(ipaBufferId++); - data->ipaParamBuffers_.emplace_back(buffer->cookie(), - buffer->planes()); - availableParamsBuffers_.push(buffer.get()); - } + for (std::unique_ptr &buffer : paramsBuffers_) + pushBuffer(availableParamsBuffers_, data->ipaParamBuffers_, buffer); if (data->ipa_) { data->ipa_->mapBuffers(data->ipaStatBuffers_, true); diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp index 55d7d4442caf..99347c9f6258 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp @@ -1028,19 +1028,19 @@ int PipelineHandlerRkISP1::allocateBuffers(Camera *camera) availableMainPathBuffers_.push(buffer.get()); } - for (std::unique_ptr &buffer : paramBuffers_) { + auto pushBuffer = [&](std::vector &buffers, + std::queue &queue, + const std::unique_ptr &buffer) { buffer->setCookie(ipaBufferId++); - data->ipaBuffers_.emplace_back(buffer->cookie(), - buffer->planes()); - availableParamBuffers_.push(buffer.get()); - } + buffers.emplace_back(buffer->cookie(), buffer->planes()); + queue.push(buffer.get()); + }; - for (std::unique_ptr &buffer : statBuffers_) { - buffer->setCookie(ipaBufferId++); - data->ipaBuffers_.emplace_back(buffer->cookie(), - buffer->planes()); - availableStatBuffers_.push(buffer.get()); - } + for (std::unique_ptr &buffer : paramBuffers_) + pushBuffer(data->ipaBuffers_, availableParamBuffers_, buffer); + + for (std::unique_ptr &buffer : statBuffers_) + pushBuffer(data->ipaBuffers_, availableStatBuffers_, buffer); data->ipa_->mapBuffers(data->ipaBuffers_); From patchwork Fri Aug 15 11:33:58 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 24136 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 AC612BEFBE for ; Fri, 15 Aug 2025 11:34:39 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id DD5A16926D; Fri, 15 Aug 2025 13:34:38 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="LiFqUjbW"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 1165269264 for ; Fri, 15 Aug 2025 13:34:30 +0200 (CEST) Received: from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi [81.175.209.231]) by perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id EE8B76A8; Fri, 15 Aug 2025 13:33:34 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1755257615; bh=PqXjuEd/eETxliLeoxxBIFcSSeAUo4EyKWgToqjiTes=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LiFqUjbWT5k6FCvcXZe3sS4pax4F6nad0+pq4aNChAB2XCjM8LHogGSUgzgTM4cz7 qy7uRoLpbhlIZhBa96yeJbfvF2W1J/C7owatQ0OwtYVkX44G4rLp6rURcHvyzbXPvs QtBonsfqLnyIjohqSUDlIU8l1KS8F5UwfD0/a1Tg= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Cc: =?utf-8?q?Daniel_R=C3=A1kos?= Subject: [PATCH v2 6/8] utils: codegen: ipc: Optimize constructors of IPA interface structures Date: Fri, 15 Aug 2025 14:33:58 +0300 Message-ID: <20250815113400.20623-7-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.49.1 In-Reply-To: <20250815113400.20623-1-laurent.pinchart@ideasonboard.com> References: <20250815113400.20623-1-laurent.pinchart@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" IPA interface structures store copies of data. For members that are not PODs, such as vectors or strings, the constructors take const references to a container class storing the data, and copies it internally. This is inefficient if the caller constructs the container for the sole purpose of passing it to the IPA interface structure constructor, as it forces a copy of the data. Replace the const reference argument with a plain instance, and move it in the constructor. This allows getting rid of the data copy if the caller uses std::move(). Signed-off-by: Laurent Pinchart --- .../generators/libcamera_templates/definition_functions.tmpl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/utils/codegen/ipc/generators/libcamera_templates/definition_functions.tmpl b/utils/codegen/ipc/generators/libcamera_templates/definition_functions.tmpl index 8b8509f3ded6..31c70e152d4f 100644 --- a/utils/codegen/ipc/generators/libcamera_templates/definition_functions.tmpl +++ b/utils/codegen/ipc/generators/libcamera_templates/definition_functions.tmpl @@ -36,12 +36,12 @@ public: {{struct.mojom_name}}( {%- for field in struct.fields -%} -{{"const " if not field|is_pod}}{{field|name}} {{"&" if not field|is_pod}}_{{field.mojom_name}}{{", " if not loop.last}} +{{field|name}} _{{field.mojom_name}}{{", " if not loop.last}} {%- endfor -%} ) : {%- for field in struct.fields -%} -{{" " if loop.first}}{{field.mojom_name}}(_{{field.mojom_name}}){{", " if not loop.last}} +{{" " if loop.first}}{{field.mojom_name}}({{"std::move(" if not field|is_pod}}_{{field.mojom_name}}{{")" if not field|is_pod}}){{", " if not loop.last}} {%- endfor %} { } From patchwork Fri Aug 15 11:33:59 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 24137 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 8AA05BEFBE for ; Fri, 15 Aug 2025 11:34:41 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id A04FE69251; Fri, 15 Aug 2025 13:34:40 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="GSePDtPM"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 9230061443 for ; Fri, 15 Aug 2025 13:34:31 +0200 (CEST) Received: from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi [81.175.209.231]) by perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id 8728E6A8; Fri, 15 Aug 2025 13:33:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1755257616; bh=y38SG3xNuZuULB3Zxaqk+jL2f/qgvZPgeeC1na8h2yc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GSePDtPMoLW5x1uTl9WKnPCRZ9fQG8F0LAf9LitKtQkj7BE6u1vwwI8QVla45K0QH cD6AN22hgD3L6Jxt/deayzqOTVtDDvFm1Ek+jMiw0GEWrky/MbT+aHx2M57wtnm0gP dIJ3yCVXHBHSm3gOD/KTNK6047s/hspO8+nTCuKU= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Cc: =?utf-8?q?Daniel_R=C3=A1kos?= Subject: [PATCH v2 7/8] apps: cam: drm: Drop unneeded local variable Date: Fri, 15 Aug 2025 14:33:59 +0300 Message-ID: <20250815113400.20623-8-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.49.1 In-Reply-To: <20250815113400.20623-1-laurent.pinchart@ideasonboard.com> References: <20250815113400.20623-1-laurent.pinchart@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 planes variable in the Device::createFrameBuffer() function is a reference to buffer.planes() that is only used as a range initializer in a range-based for loop. Use buffer.planes() directly and drop the variable. Signed-off-by: Laurent Pinchart Reviewed-by: Barnabás Pőcze Reviewed-by: Jacopo Mondi --- src/apps/cam/drm.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/apps/cam/drm.cpp b/src/apps/cam/drm.cpp index f4b47097649a..8e2dfd9a64e4 100644 --- a/src/apps/cam/drm.cpp +++ b/src/apps/cam/drm.cpp @@ -659,10 +659,8 @@ std::unique_ptr Device::createFrameBuffer( uint32_t offsets[4] = {}; int ret; - const std::vector &planes = buffer.planes(); - unsigned int i = 0; - for (const libcamera::FrameBuffer::Plane &plane : planes) { + for (const libcamera::FrameBuffer::Plane &plane : buffer.planes()) { int fd = plane.fd.get(); uint32_t handle; From patchwork Fri Aug 15 11:34:00 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 24138 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 A6ABEBEFBE for ; Fri, 15 Aug 2025 11:34:42 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 1787169267; Fri, 15 Aug 2025 13:34:42 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="Ykyv9KBr"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 1536369267 for ; Fri, 15 Aug 2025 13:34:33 +0200 (CEST) Received: from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi [81.175.209.231]) by perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id 12BE1605; Fri, 15 Aug 2025 13:33:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1755257618; bh=8DnZOUdaaa39MSpmMhZLYsOmSaGOlnlLPO8R75YQZDc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ykyv9KBr3H+vJsz6qhf4bTyaphAkn1Afcv7gq74FsZQLUStNJbD+dqkAnic5ND4xZ sdQRTw7IdaCbDuiiZHy2WyTeod8Fu/EoBnWGI5A2qC6Z80JUOn/Dz++xQuUyLi7cbv UUmEdsCPOchE9W9CV9GCrDAfIjwLaSowU2JIExnw= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Cc: =?utf-8?q?Daniel_R=C3=A1kos?= Subject: [PATCH v2 8/8] libcamera: framebuffer: Replace vector with span in constructor Date: Fri, 15 Aug 2025 14:34:00 +0300 Message-ID: <20250815113400.20623-9-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.49.1 In-Reply-To: <20250815113400.20623-1-laurent.pinchart@ideasonboard.com> References: <20250815113400.20623-1-laurent.pinchart@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 FrameBuffer constructor takes a list of planes as an std::vector. The caller may stores the planes in a different type of container, resulting in the needless allocation of a temporary vector. Replace it with a span. Suggested-by: Daniel Rákos Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham Reviewed-by: Barnabás Pőcze --- include/libcamera/framebuffer.h | 4 ++-- include/libcamera/internal/framebuffer.h | 3 ++- src/android/mm/cros_frame_buffer_allocator.cpp | 2 +- src/android/mm/generic_frame_buffer_allocator.cpp | 2 +- src/libcamera/framebuffer.cpp | 10 +++++----- src/libcamera/pipeline/ipu3/ipu3.cpp | 5 ++++- src/libcamera/pipeline/mali-c55/mali-c55.cpp | 5 ++++- src/libcamera/pipeline/rkisp1/rkisp1.cpp | 5 ++++- src/libcamera/pipeline/rpi/common/pipeline_base.cpp | 6 ++++-- src/libcamera/pipeline/vimc/vimc.cpp | 5 ++++- src/libcamera/pipeline/virtual/virtual.cpp | 3 ++- src/libcamera/v4l2_videodevice.cpp | 6 +++--- 12 files changed, 36 insertions(+), 20 deletions(-) diff --git a/include/libcamera/framebuffer.h b/include/libcamera/framebuffer.h index e83825b466aa..723525d05294 100644 --- a/include/libcamera/framebuffer.h +++ b/include/libcamera/framebuffer.h @@ -58,11 +58,11 @@ public: unsigned int length; }; - FrameBuffer(const std::vector &planes, unsigned int cookie = 0); + FrameBuffer(Span planes, unsigned int cookie = 0); FrameBuffer(std::unique_ptr d); virtual ~FrameBuffer() {} - const std::vector &planes() const; + Span planes() const; Request *request() const; const FrameMetadata &metadata() const; diff --git a/include/libcamera/internal/framebuffer.h b/include/libcamera/internal/framebuffer.h index 97b49d42063f..67b090fc307f 100644 --- a/include/libcamera/internal/framebuffer.h +++ b/include/libcamera/internal/framebuffer.h @@ -12,6 +12,7 @@ #include #include +#include #include #include @@ -23,7 +24,7 @@ class FrameBuffer::Private : public Extensible::Private LIBCAMERA_DECLARE_PUBLIC(FrameBuffer) public: - Private(const std::vector &planes, uint64_t cookie = 0); + Private(Span planes, uint64_t cookie = 0); virtual ~Private(); void setRequest(Request *request) { request_ = request; } diff --git a/src/android/mm/cros_frame_buffer_allocator.cpp b/src/android/mm/cros_frame_buffer_allocator.cpp index 264c0d481272..7ec116e1500d 100644 --- a/src/android/mm/cros_frame_buffer_allocator.cpp +++ b/src/android/mm/cros_frame_buffer_allocator.cpp @@ -29,7 +29,7 @@ class CrosFrameBufferData : public FrameBuffer::Private public: CrosFrameBufferData(cros::ScopedBufferHandle scopedHandle, - const std::vector &planes) + Span planes) : FrameBuffer::Private(planes), scopedHandle_(std::move(scopedHandle)) { } diff --git a/src/android/mm/generic_frame_buffer_allocator.cpp b/src/android/mm/generic_frame_buffer_allocator.cpp index 79625a9a3c75..25ad6b035e73 100644 --- a/src/android/mm/generic_frame_buffer_allocator.cpp +++ b/src/android/mm/generic_frame_buffer_allocator.cpp @@ -35,7 +35,7 @@ class GenericFrameBufferData : public FrameBuffer::Private public: GenericFrameBufferData(struct alloc_device_t *allocDevice, buffer_handle_t handle, - const std::vector &planes) + Span planes) : FrameBuffer::Private(planes), allocDevice_(allocDevice), handle_(handle) { diff --git a/src/libcamera/framebuffer.cpp b/src/libcamera/framebuffer.cpp index 219db50d6527..765dab95a843 100644 --- a/src/libcamera/framebuffer.cpp +++ b/src/libcamera/framebuffer.cpp @@ -130,9 +130,9 @@ LOG_DEFINE_CATEGORY(Buffer) * \param[in] planes The frame memory planes * \param[in] cookie Cookie */ -FrameBuffer::Private::Private(const std::vector &planes, uint64_t cookie) - : planes_(planes), cookie_(cookie), request_(nullptr), - isContiguous_(true) +FrameBuffer::Private::Private(Span planes, uint64_t cookie) + : planes_(planes.begin(), planes.end()), cookie_(cookie), + request_(nullptr), isContiguous_(true) { metadata_.planes_.resize(planes_.size()); } @@ -315,7 +315,7 @@ ino_t fileDescriptorInode(const SharedFD &fd) * \param[in] planes The frame memory planes * \param[in] cookie Cookie */ -FrameBuffer::FrameBuffer(const std::vector &planes, unsigned int cookie) +FrameBuffer::FrameBuffer(Span planes, unsigned int cookie) : FrameBuffer(std::make_unique(planes, cookie)) { } @@ -365,7 +365,7 @@ FrameBuffer::FrameBuffer(std::unique_ptr d) * \brief Retrieve the static plane descriptors * \return Array of plane descriptors */ -const std::vector &FrameBuffer::planes() const +Span FrameBuffer::planes() const { return _d()->planes_; } diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index 7ae85e5063db..a147af2291a3 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -680,8 +680,11 @@ int PipelineHandlerIPU3::allocateBuffers(Camera *camera) auto pushBuffer = [&](std::vector &buffers, const std::unique_ptr &buffer) { + Span planes = buffer->planes(); + buffer->setCookie(ipaBufferId++); - buffers.emplace_back(buffer->cookie(), buffer->planes()); + buffers.emplace_back(buffer->cookie(), + std::vector{ planes.begin(), planes.end() }); }; for (const std::unique_ptr &buffer : imgu->paramBuffers_) diff --git a/src/libcamera/pipeline/mali-c55/mali-c55.cpp b/src/libcamera/pipeline/mali-c55/mali-c55.cpp index f03a03fef35c..2e9fad3285b9 100644 --- a/src/libcamera/pipeline/mali-c55/mali-c55.cpp +++ b/src/libcamera/pipeline/mali-c55/mali-c55.cpp @@ -1136,8 +1136,11 @@ int PipelineHandlerMaliC55::allocateBuffers(Camera *camera) auto pushBuffer = [&](std::queue &queue, std::vector &buffers, const std::unique_ptr &buffer) { + Span planes = buffer->planes(); + buffer->setCookie(ipaBufferId++); - buffers.emplace_back(buffer->cookie(), buffer->planes()); + buffers.emplace_back(buffer->cookie(), + std::vector{ planes.begin(), planes.end() }); queue.push(buffer.get()); }; diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp index 99347c9f6258..d5972b0e7e93 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp @@ -1031,8 +1031,11 @@ int PipelineHandlerRkISP1::allocateBuffers(Camera *camera) auto pushBuffer = [&](std::vector &buffers, std::queue &queue, const std::unique_ptr &buffer) { + Span planes = buffer->planes(); + buffer->setCookie(ipaBufferId++); - buffers.emplace_back(buffer->cookie(), buffer->planes()); + buffers.emplace_back(buffer->cookie(), + std::vector{ planes.begin(), planes.end() }); queue.push(buffer.get()); }; diff --git a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp index 09d30f34d9b7..c209aa596311 100644 --- a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp +++ b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp @@ -883,8 +883,10 @@ void PipelineHandlerBase::mapBuffers(Camera *camera, const BufferMap &buffers, u * handler and the IPA. */ for (auto const &[id, buffer] : buffers) { - bufferIds.push_back(IPABuffer(mask | id, - buffer.buffer->planes())); + Span planes = buffer.buffer->planes(); + + bufferIds.emplace_back(mask | id, + std::vector{ planes.begin(), planes.end() }); data->bufferIds_.insert(mask | id); } diff --git a/src/libcamera/pipeline/vimc/vimc.cpp b/src/libcamera/pipeline/vimc/vimc.cpp index 07273bd2b6c3..5022101505a1 100644 --- a/src/libcamera/pipeline/vimc/vimc.cpp +++ b/src/libcamera/pipeline/vimc/vimc.cpp @@ -363,8 +363,11 @@ int PipelineHandlerVimc::start(Camera *camera, [[maybe_unused]] const ControlLis /* Map the mock IPA buffers to VIMC IPA to exercise IPC code paths. */ std::vector ipaBuffers; for (auto [i, buffer] : utils::enumerate(data->mockIPABufs_)) { + Span planes = buffer->planes(); + buffer->setCookie(i + 1); - ipaBuffers.emplace_back(buffer->cookie(), buffer->planes()); + ipaBuffers.emplace_back(buffer->cookie(), + std::vector{ planes.begin(), planes.end() }); } data->ipa_->mapBuffers(ipaBuffers); diff --git a/src/libcamera/pipeline/virtual/virtual.cpp b/src/libcamera/pipeline/virtual/virtual.cpp index 049ebcba58ec..f9538129c956 100644 --- a/src/libcamera/pipeline/virtual/virtual.cpp +++ b/src/libcamera/pipeline/virtual/virtual.cpp @@ -315,7 +315,8 @@ int PipelineHandlerVirtual::queueRequestDevice([[maybe_unused]] Camera *camera, fmd.sequence = streamConfig.seq++; fmd.timestamp = timestamp; - for (const auto [i, p] : utils::enumerate(buffer->planes())) + Span planes = buffer->planes(); + for (const auto [i, p] : utils::enumerate(planes)) fmd.planes()[i].bytesused = p.length; found = true; diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp index ba1889a939cb..7b48d911db73 100644 --- a/src/libcamera/v4l2_videodevice.cpp +++ b/src/libcamera/v4l2_videodevice.cpp @@ -288,7 +288,7 @@ V4L2BufferCache::Entry::Entry(bool free, uint64_t lastUsed, const FrameBuffer &b bool V4L2BufferCache::Entry::operator==(const FrameBuffer &buffer) const { - const std::vector &planes = buffer.planes(); + Span planes = buffer.planes(); if (planes_.size() != planes.size()) return false; @@ -1676,7 +1676,7 @@ int V4L2VideoDevice::queueBuffer(FrameBuffer *buffer) buf.field = V4L2_FIELD_NONE; bool multiPlanar = V4L2_TYPE_IS_MULTIPLANAR(buf.type); - const std::vector &planes = buffer->planes(); + Span planes = buffer->planes(); const unsigned int numV4l2Planes = format_.planesCount; /* @@ -1909,7 +1909,7 @@ FrameBuffer *V4L2VideoDevice::dequeueBuffer() } metadata.sequence -= firstFrame_.value(); - const std::vector &framebufferPlanes = buffer->planes(); + Span framebufferPlanes = buffer->planes(); unsigned int numV4l2Planes = multiPlanar ? buf.length : 1; if (numV4l2Planes != framebufferPlanes.size()) {