From patchwork Mon Jun 8 15:03:44 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Milan Zamazal X-Patchwork-Id: 26858 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 ADAD9C328C for ; Mon, 8 Jun 2026 15:04:42 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 668F861F2B; Mon, 8 Jun 2026 17:04:42 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="KNzLYBwn"; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id CC8AE61F00 for ; Mon, 8 Jun 2026 17:04:40 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1780931079; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=m+olcwCj5Ulh/lBxoFrBk2sY2gZlONais/vMZvoQpzI=; b=KNzLYBwnhb1SJGDZrhVcKZR8mwdgPAnfe1aWLrzBZwUf3/JW87wgfJL54TV/95cvEAaUB6 jAz0HpW1yDbJxoXWUQkNH/knEvKbDEH/09Mh9BOiLpSM5QC5q2iEDUWOhuE8UqMtSK4HzG OhtQYjtznDFGBQhz2GgSNgux+MuKmDo= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-64-fhUOWtPbM7msSJ-ckZ2T-A-1; Mon, 08 Jun 2026 11:04:35 -0400 X-MC-Unique: fhUOWtPbM7msSJ-ckZ2T-A-1 X-Mimecast-MFC-AGG-ID: fhUOWtPbM7msSJ-ckZ2T-A_1780931074 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 2ADB81956060; Mon, 8 Jun 2026 15:04:34 +0000 (UTC) Received: from mzamazal-thinkpadp1gen7.tpbc.com (unknown [10.44.48.51]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 199E51800361; Mon, 8 Jun 2026 15:04:31 +0000 (UTC) From: Milan Zamazal To: libcamera-devel@lists.libcamera.org Cc: Milan Zamazal , Kieran Bingham , =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= , johannes.goede@oss.qualcomm.com Subject: [RFC PATCH v4 15/17] libcamera: software_isp: Track statistics buffers Date: Mon, 8 Jun 2026 17:03:44 +0200 Message-ID: <20260608150349.134371-16-mzamazal@redhat.com> In-Reply-To: <20260608150349.134371-1-mzamazal@redhat.com> References: <20260608150349.134371-1-mzamazal@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: lCiaCTHW3Rgud8tl8nFKjE6lEeSqI-pqzNQSO67aUAE_1780931074 X-Mimecast-Originator: redhat.com content-type: text/plain; charset="US-ASCII"; x-default=true 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 a preparation for passing the shared statistics buffers to IPA, this patch introduces tracking statistics buffer ids. SofwareIsp::availableStats_ is a vector of ids of the buffers available for use. When a fresh statistics buffer is needed, its id is retrieved from there and once the buffer is no longer needed, it's put back there, in a method invoked by a signal. This is similar to what the hardware pipelines do. We use buffers' file descriptors as buffer ids. The statistics buffers will be shared with the IPA, SwIspStats and debayering and we need their common identification everywhere. The buffer file descriptors are shared unchanged so they can be used for the purpose, avoiding a need to pass a special mapping to the IPA and debayering on initialization. Note that the statistics buffer id is still actually unused, this will be changed once the buffers are shared with the IPA. Signed-off-by: Milan Zamazal --- .../libcamera/internal/software_isp/software_isp.h | 1 + src/libcamera/software_isp/debayer_egl.cpp | 4 ++-- src/libcamera/software_isp/software_isp.cpp | 14 +++++++++++--- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/include/libcamera/internal/software_isp/software_isp.h b/include/libcamera/internal/software_isp/software_isp.h index 451596163..24eeaeb86 100644 --- a/include/libcamera/internal/software_isp/software_isp.h +++ b/include/libcamera/internal/software_isp/software_isp.h @@ -105,6 +105,7 @@ private: Thread ispWorkerThread_; std::map> sharedParams_; std::vector availableParams_; + std::vector availableStats_; DmaBufAllocator dmaHeap_; bool ccmEnabled_; diff --git a/src/libcamera/software_isp/debayer_egl.cpp b/src/libcamera/software_isp/debayer_egl.cpp index aacaaa66e..f5a74637d 100644 --- a/src/libcamera/software_isp/debayer_egl.cpp +++ b/src/libcamera/software_isp/debayer_egl.cpp @@ -559,7 +559,7 @@ int DebayerEGL::debayerGPU(FrameBuffer *input, FrameBuffer *output, const Debaye } void DebayerEGL::process(uint32_t frame, - [[maybe_unused]] const uint32_t statsBufferId, + const uint32_t statsBufferId, const uint32_t paramsBufferId, FrameBuffer *input, FrameBuffer *output) @@ -599,7 +599,7 @@ void DebayerEGL::process(uint32_t frame, inDmaSyncer.emplace(input->planes()[0].fd, DmaSyncer::SyncType::Read); inMapped.emplace(input, MappedFrameBuffer::MapFlag::Read); } - stats_->processFrame(frame, 0, inMapped.value()); + stats_->processFrame(frame, statsBufferId, inMapped.value()); } inDmaSyncer.reset(); diff --git a/src/libcamera/software_isp/software_isp.cpp b/src/libcamera/software_isp/software_isp.cpp index c4da647e8..2a019e6bc 100644 --- a/src/libcamera/software_isp/software_isp.cpp +++ b/src/libcamera/software_isp/software_isp.cpp @@ -225,6 +225,7 @@ std::unique_ptr SoftwareIsp::allocateStatsBuffers( fdStats[bufferId] = shared.fd(); sharedStats->emplace(bufferId, std::move(shared)); + availableStats_.push_back(bufferId); } auto stats = std::make_unique(cm, std::move(sharedStats)); @@ -463,7 +464,8 @@ void SoftwareIsp::stop() * \param[in] frame The frame number * \param[in] input The input framebuffer * \param[out] output The framebuffer to write the processed frame to - * \return 0 on success, -EAGAIN if a parameter buffer underrun occurs + * \return 0 on success, -EAGAIN if a parameter or statistics buffer underrun + * occurs */ int SoftwareIsp::process(uint32_t frame, FrameBuffer *input, FrameBuffer *output) { @@ -471,11 +473,16 @@ int SoftwareIsp::process(uint32_t frame, FrameBuffer *input, FrameBuffer *output LOG(SoftwareIsp, Error) << "Parameters buffer underrun"; return -EAGAIN; } + if (availableStats_.empty()) { + LOG(SoftwareIsp, Error) << "Statistics buffer underrun"; + return -EAGAIN; + } const uint32_t paramsBufferId = availableParams_.back(); availableParams_.pop_back(); + const uint32_t statsBufferId = availableStats_.back(); + availableStats_.pop_back(); ipa_->computeParams(frame, paramsBufferId); - const uint32_t statsBufferId = 0; debayer_->invokeMethod(&Debayer::process, ConnectionTypeQueued, frame, statsBufferId, paramsBufferId, input, output); @@ -498,8 +505,9 @@ void SoftwareIsp::statsReady(uint32_t frame, const uint32_t statsBufferId) ispStatsReady.emit(frame, statsBufferId); } -void SoftwareIsp::statsProcessed([[maybe_unused]] const uint32_t statsBufferId) +void SoftwareIsp::statsProcessed(const uint32_t statsBufferId) { + availableStats_.push_back(statsBufferId); } void SoftwareIsp::inputReady(FrameBuffer *input)