From patchwork Mon Aug 12 11:50:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Milan Zamazal X-Patchwork-Id: 20888 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 D1FF2C323E for ; Mon, 12 Aug 2024 11:50:54 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 83FFE633D3; Mon, 12 Aug 2024 13:50:54 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="f+/+g8ML"; 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 94B58633D6 for ; Mon, 12 Aug 2024 13:50:44 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1723463443; 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=BhDmjC8q+iup+NUxl+/6VmxG1PqcdwEFDvjvinyQbmE=; b=f+/+g8MLZzxh0jrs4ZT2UZaZzQ3fxf38MSlZessAOXeP4VZ3DKafuZiY311G+GF+f27jq2 uQcj5tF71oB+y/uPxqaE/HlU3u7CfWXqOHqvzA20/ezv/qICcJXIZLUPQjyaeBbmgAbFZ5 W3UcHiyu7Pre7QQKYYSaFrZMLUHaBmY= 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-562-OZXEfsYwPEqFVZ0GbrEA5w-1; Mon, 12 Aug 2024 07:50:42 -0400 X-MC-Unique: OZXEfsYwPEqFVZ0GbrEA5w-1 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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 2619A1954225 for ; Mon, 12 Aug 2024 11:50:41 +0000 (UTC) Received: from nuthatch.redhat.com (unknown [10.45.225.57]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 2AD2D19772C4; Mon, 12 Aug 2024 11:50:39 +0000 (UTC) From: Milan Zamazal To: libcamera-devel@lists.libcamera.org Cc: Milan Zamazal Subject: [PATCH 14/16] libcamera: software_isp: Track statistics buffers Date: Mon, 12 Aug 2024 13:50:03 +0200 Message-ID: <20240812115009.946036-15-mzamazal@redhat.com> In-Reply-To: <20240812115009.946036-1-mzamazal@redhat.com> References: <20240812115009.946036-1-mzamazal@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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 queue 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/software_isp.cpp | 13 +++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/include/libcamera/internal/software_isp/software_isp.h b/include/libcamera/internal/software_isp/software_isp.h index a6ba4a07..5959e86e 100644 --- a/include/libcamera/internal/software_isp/software_isp.h +++ b/include/libcamera/internal/software_isp/software_isp.h @@ -102,6 +102,7 @@ private: DebayerParams debayerParams_; std::queue availableParams_; bool allocateParamsBuffers(const unsigned int bufferCount); + std::queue availableStats_; std::unique_ptr allocateStatsBuffers( std::vector &fdStats, const unsigned int bufferCount); diff --git a/src/libcamera/software_isp/software_isp.cpp b/src/libcamera/software_isp/software_isp.cpp index 1e224b6f..c4ad22be 100644 --- a/src/libcamera/software_isp/software_isp.cpp +++ b/src/libcamera/software_isp/software_isp.cpp @@ -191,6 +191,7 @@ std::unique_ptr SoftwareIsp::allocateStatsBuffers( unsigned int bufferId = shared.fd().get(); fdStats.emplace_back(shared.fd()); sharedStats->emplace(bufferId, std::move(shared)); + availableStats_.push(bufferId); } auto stats = std::make_unique(std::move(sharedStats)); @@ -413,11 +414,18 @@ void SoftwareIsp::process(uint32_t frame, FrameBuffer *input, FrameBuffer *outpu while (availableParams_.empty()) ; } + if (availableStats_.empty()) { + LOG(SoftwareIsp, Error) << "Statistics buffer underrun"; + /* Well, busy loop, but this situation shouldn't normally happen. */ + while (availableStats_.empty()) + ; + } const uint32_t paramsBufferId = availableParams_.front(); availableParams_.pop(); + const uint32_t statsBufferId = availableStats_.front(); + availableStats_.pop(); ipa_->prepare(frame, paramsBufferId); - const uint32_t statsBufferId = 0; debayer_->invokeMethod(&DebayerCpu::process, ConnectionTypeQueued, frame, statsBufferId, paramsBufferId, input, output); @@ -443,8 +451,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(statsBufferId); } void SoftwareIsp::inputReady(FrameBuffer *input)