From patchwork Thu Jun 4 09:51:01 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Milan Zamazal X-Patchwork-Id: 26842 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 2467FC328C for ; Thu, 4 Jun 2026 09:52:13 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D18EE63753; Thu, 4 Jun 2026 11:52:12 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="aBbuX2gK"; 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 2003B63748 for ; Thu, 4 Jun 2026 11:52:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1780566730; 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=/pVyXU9ODvW1xeZOT50dH3wf/Nr7GfnYPORLey+RyMY=; b=aBbuX2gKqpRAS/z0SxbucRb41H/ySombrm9dA4dxWofHT1ohtHNfZsq63znuHh/cppJbE5 vtzSY4LuIgJPHP3ee8MwejvJW4QJViya/5aTpRGVH5/tWRhEz/Rbrx0ZcuV2cIJbwLMBed CWT7KbJ2mUnIeTl9eFnrT8UbkTal6mA= Received: from mx-prod-mc-05.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-288-8r9NjJUFM0ON8lE9AP7uUA-1; Thu, 04 Jun 2026 05:52:04 -0400 X-MC-Unique: 8r9NjJUFM0ON8lE9AP7uUA-1 X-Mimecast-MFC-AGG-ID: 8r9NjJUFM0ON8lE9AP7uUA_1780566720 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 6707F19560B5; Thu, 4 Jun 2026 09:51:58 +0000 (UTC) Received: from mzamazal-thinkpadp1gen7.tpbc.com (unknown [10.44.34.156]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id D5B4E30001A1; Thu, 4 Jun 2026 09:51:56 +0000 (UTC) From: Milan Zamazal To: libcamera-devel@lists.libcamera.org Cc: Milan Zamazal , =?utf-8?b?QmFybmFiw6FzIFDFkWN6?= =?utf-8?q?e?= , johannes.goede@oss.qualcomm.com Subject: [RFC PATCH v3 15/17] libcamera: software_isp: Track statistics buffers Date: Thu, 4 Jun 2026 11:51:01 +0200 Message-ID: <20260604095105.68798-20-mzamazal@redhat.com> In-Reply-To: <20260604095105.68798-1-mzamazal@redhat.com> References: <20260604095105.68798-1-mzamazal@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: LOKtckIONx6JRPX8WUnCzWaKpwcew5WxK_qEr9jeEUM_1780566720 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 09e7833ed..f43428432 100644 --- a/src/libcamera/software_isp/debayer_egl.cpp +++ b/src/libcamera/software_isp/debayer_egl.cpp @@ -550,7 +550,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) @@ -590,7 +590,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)