From patchwork Thu Jun 4 09:50:53 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Milan Zamazal X-Patchwork-Id: 26832 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 E4B45C328C for ; Thu, 4 Jun 2026 09:51:47 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9BD9E63733; Thu, 4 Jun 2026 11:51:47 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="a81Vmlax"; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4F49263403 for ; Thu, 4 Jun 2026 11:51:45 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1780566704; 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=4tddGy712352sjbLd3X1jE2tUkVJDxQazhu578EYriU=; b=a81VmlaxCxdbBpthvMVe8HJ2XEyKIcHyE0soq0y0/JVuf2DPK2sXpkA1y7xFsqmjIyNHRb yQx6WspMO1eOtydQcgRImE8fdsHYBGWBt4LcfCqIx0I3EGWZJK9zBsLSdlHyNnwXcnvnE5 hzanjnk3FpeXYsrHdoKNTKwaIFmGwn8= Received: from mx-prod-mc-01.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-27-pBEYiPsfOIe74P_rUOfmgg-1; Thu, 04 Jun 2026 05:51:41 -0400 X-MC-Unique: pBEYiPsfOIe74P_rUOfmgg-1 X-Mimecast-MFC-AGG-ID: pBEYiPsfOIe74P_rUOfmgg_1780566700 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-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id F30B41956096; Thu, 4 Jun 2026 09:51:39 +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 356A430001A1; Thu, 4 Jun 2026 09:51:37 +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 07/17] libcamera: software_isp: Track unused parameters buffers Date: Thu, 4 Jun 2026 11:50:53 +0200 Message-ID: <20260604095105.68798-12-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: DkfIqckHxouaskLkK9HHUNzar5x9gCR8z5X2dQXARMw_1780566700 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 introducing a ring of parameters buffers, this patch introduces tracking of parameters buffers available for use. SoftwareIsp::availableParams_ is a vector of ids of the buffers available for use. When a fresh parameter 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. If a parameters buffer is requested but there is no free available, it is an erroneous situation. To recover from it, we have currently no better mechanism than to wait for an available buffer. Simply returning from the processing would mean the finishing signals are not called, resulting in e.g. the input buffer not being returned. This is different from the hardware pipelines, which are structured somewhat differently. We use 0 as the buffer id for now. In followup patches, we will have to make and pass a special id->buffer mapping to the IPA and debayering on initialisation. Note that the parameters buffer id is still actually unused and the only buffer currently used is still copied when passed to debayering. This patch is just preparation for followup patches that will introduce multiple buffers. Signed-off-by: Milan Zamazal --- .../internal/software_isp/software_isp.h | 3 ++- src/libcamera/software_isp/software_isp.cpp | 27 +++++++++++++++---- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/include/libcamera/internal/software_isp/software_isp.h b/include/libcamera/internal/software_isp/software_isp.h index f97d25f0a..58fb9d752 100644 --- a/include/libcamera/internal/software_isp/software_isp.h +++ b/include/libcamera/internal/software_isp/software_isp.h @@ -79,7 +79,7 @@ public: int queueBuffers(uint32_t frame, FrameBuffer *input, const std::map &outputs); - void process(uint32_t frame, FrameBuffer *input, FrameBuffer *output); + int process(uint32_t frame, FrameBuffer *input, FrameBuffer *output); Signal inputBufferReady; Signal outputBufferReady; @@ -99,6 +99,7 @@ private: Thread ispWorkerThread_; SharedMemObject sharedParams_; DebayerParams debayerParams_; + std::vector availableParams_; DmaBufAllocator dmaHeap_; bool ccmEnabled_; diff --git a/src/libcamera/software_isp/software_isp.cpp b/src/libcamera/software_isp/software_isp.cpp index 774f2bf75..d48cd00ad 100644 --- a/src/libcamera/software_isp/software_isp.cpp +++ b/src/libcamera/software_isp/software_isp.cpp @@ -185,6 +185,9 @@ bool SoftwareIsp::allocateParamsBuffers() return false; } + /* Just a single buffer for now, let's use 0 as its id. */ + availableParams_.push_back(0); + return true; } @@ -353,7 +356,12 @@ int SoftwareIsp::queueBuffers(uint32_t frame, FrameBuffer *input, for (const auto &[stream, buffer] : outputs) { queuedInputBuffers_.push_back(input); queuedOutputBuffers_.push_back(buffer); - process(frame, input, buffer); + int ret = process(frame, input, buffer); + if (ret) { + queuedInputBuffers_.pop_back(); + queuedOutputBuffers_.pop_back(); + return ret; + } } return 0; @@ -413,15 +421,23 @@ 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 */ -void SoftwareIsp::process(uint32_t frame, FrameBuffer *input, FrameBuffer *output) +int SoftwareIsp::process(uint32_t frame, FrameBuffer *input, FrameBuffer *output) { - /* \todo Provide a real value */ - constexpr uint32_t paramsBufferId = 0; + if (availableParams_.empty()) { + LOG(SoftwareIsp, Error) << "Parameters buffer underrun"; + return -EAGAIN; + } + + const uint32_t paramsBufferId = availableParams_.back(); + availableParams_.pop_back(); ipa_->computeParams(frame, paramsBufferId); debayer_->invokeMethod(&Debayer::process, ConnectionTypeQueued, frame, paramsBufferId, input, output, debayerParams_); + + return 0; } void SoftwareIsp::saveIspParams([[maybe_unused]] const uint32_t paramsBufferId) @@ -429,8 +445,9 @@ void SoftwareIsp::saveIspParams([[maybe_unused]] const uint32_t paramsBufferId) debayerParams_ = *sharedParams_; } -void SoftwareIsp::paramsBufferReady([[maybe_unused]] const uint32_t paramsBufferId) +void SoftwareIsp::paramsBufferReady(const uint32_t paramsBufferId) { + availableParams_.push_back(paramsBufferId); } void SoftwareIsp::setSensorCtrls(const ControlList &sensorControls)