From patchwork Thu May 21 15:59:05 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Mader X-Patchwork-Id: 26796 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 D3E31C32F4 for ; Thu, 21 May 2026 15:59:38 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 8446462FD3; Thu, 21 May 2026 17:59:38 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=collabora.com header.i=robert.mader@collabora.com header.b="ZuAqKimJ"; dkim-atps=neutral Received: from sender4-pp-f112.zoho.com (sender4-pp-f112.zoho.com [136.143.188.112]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id E7D2862FEC for ; Thu, 21 May 2026 17:59:31 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; t=1779379168; cv=none; d=zohomail.com; s=zohoarc; b=O8mxTUk8sKYUSSAPFUi8744otl+fsHGpI4txxX0E4tVkPiqA2av050p3GEugjZJZZ6sk72mdWfV1tuE3YDIF34XoponfAwazkz3sjfFY86RnqyIMo5sucZoqX6ihKwvySGeYcUZqNwnjLoW0RrD8YZcBWcspVd67HHhzKIpz0uc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779379168; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=fUuYJQIHRIATzbug2Vo9yV+BiNeQ9KLOui8BmEmgzxM=; b=KZICwWCD/h6n0Gme9wIzBsMcoHDzDh74k5r5PKh4Pn5QD1kHG6aXfSAqhgERUaaKoezU8DKjeilzeDN6PcYAlWy/Sve8l1eMF43Y5hLHSWbxpLhWjY2YlHjgxCC/6gWQgr9caT88IokEatMsuHcEncCEn3V7HJysFvtu6BlBj7c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=collabora.com; spf=pass smtp.mailfrom=robert.mader@collabora.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1779379168; s=zohomail; d=collabora.com; i=robert.mader@collabora.com; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-ID:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Message-Id:Reply-To; bh=fUuYJQIHRIATzbug2Vo9yV+BiNeQ9KLOui8BmEmgzxM=; b=ZuAqKimJLiYMTFVL5l7Iu85iIjpbWjbCel8whGld++H+RzMYw9DEwEazDMSe67lb FxVW+pYZbnc3LpKx6Ws1U5SenaiXitPROYTkGh0hkjMkKFTP6SDRrH53tMGGad832DK J91E5fG3tlphyIHfDXyxqxJBqXRNks4vSZnTRJ7Q= Received: by mx.zohomail.com with SMTPS id 1779379165474836.5361585607891; Thu, 21 May 2026 08:59:25 -0700 (PDT) From: Robert Mader To: libcamera-devel@lists.libcamera.org Cc: Robert Mader Subject: [PATCH v4 4/5] libcamera: swstats_cpu: Take MappedFrameBuffer in processFrame() Date: Thu, 21 May 2026 17:59:05 +0200 Message-ID: <20260521155906.120373-5-robert.mader@collabora.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260521155906.120373-1-robert.mader@collabora.com> References: <20260521155906.120373-1-robert.mader@collabora.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" As the only current user - DebayerEGL::process() - already has the buffer mapped. Currently this shouldn't impact performance as the kernel should already avoid remapping the dmabuf - i.e. we implicitly benefit from the fact that the mentioned function holds its mapping during the runtime of processFrame(). In a following commit DebayerEGL::process() will change in a way that would make keeping the mapping counter-intuitive. Thus this change ensures we'll not accidentally start mapping the buffer twice per frame. Signed-off-by: Robert Mader --- .../libcamera/internal/software_isp/swstats_cpu.h | 2 +- src/libcamera/software_isp/debayer_egl.cpp | 2 +- src/libcamera/software_isp/swstats_cpu.cpp | 13 +++---------- 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/include/libcamera/internal/software_isp/swstats_cpu.h b/include/libcamera/internal/software_isp/swstats_cpu.h index b5348c6fe..c9ed1d0a6 100644 --- a/include/libcamera/internal/software_isp/swstats_cpu.h +++ b/include/libcamera/internal/software_isp/swstats_cpu.h @@ -56,7 +56,7 @@ public: void setWindow(const Rectangle &window); void startFrame(uint32_t frame); void finishFrame(uint32_t frame, uint32_t bufferId); - void processFrame(uint32_t frame, uint32_t bufferId, FrameBuffer *input); + void processFrame(uint32_t frame, uint32_t bufferId, MappedFrameBuffer *input); void processLine0(uint32_t frame, unsigned int y, const uint8_t *src[], unsigned int statsBufferIndex = 0) { diff --git a/src/libcamera/software_isp/debayer_egl.cpp b/src/libcamera/software_isp/debayer_egl.cpp index 696498a58..d15f3cd48 100644 --- a/src/libcamera/software_isp/debayer_egl.cpp +++ b/src/libcamera/software_isp/debayer_egl.cpp @@ -555,7 +555,7 @@ void DebayerEGL::process(uint32_t frame, FrameBuffer *input, FrameBuffer *output metadata.planes()[0].bytesused = output->planes()[0].length; /* Calculate stats for the whole frame */ - stats_->processFrame(frame, 0, input); + stats_->processFrame(frame, 0, &in); dmaSyncers.clear(); egl_.syncOutput(); diff --git a/src/libcamera/software_isp/swstats_cpu.cpp b/src/libcamera/software_isp/swstats_cpu.cpp index 0815ec9a3..b182a1a2b 100644 --- a/src/libcamera/software_isp/swstats_cpu.cpp +++ b/src/libcamera/software_isp/swstats_cpu.cpp @@ -543,23 +543,16 @@ void SwStatsCpu::processBayerFrame2(MappedFrameBuffer &in) * * This may only be called after a successful setWindow() call. */ -void SwStatsCpu::processFrame(uint32_t frame, uint32_t bufferId, FrameBuffer *input) +void SwStatsCpu::processFrame(uint32_t frame, uint32_t bufferId, MappedFrameBuffer *input) { - if (frame % kStatPerNumFrames) { + if (!input || frame % kStatPerNumFrames) { finishFrame(frame, bufferId); return; } bench_.startFrame(); startFrame(frame); - - MappedFrameBuffer in(input, MappedFrameBuffer::MapFlag::Read); - if (!in.isValid()) { - LOG(SwStatsCpu, Error) << "mmap-ing buffer(s) failed"; - return; - } - - (this->*processFrame_)(in); + (this->*processFrame_)(*input); finishFrame(frame, bufferId); bench_.finishFrame(); }