From patchwork Tue Feb 25 15:06:09 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Milan Zamazal X-Patchwork-Id: 22860 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 77AD1BDB1C for ; Tue, 25 Feb 2025 15:06:41 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0187568725; Tue, 25 Feb 2025 16:06:41 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="WVOXxAKR"; 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 8968668715 for ; Tue, 25 Feb 2025 16:06:38 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1740495997; 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=H32qMEkJX+61AWPrMY3td75sqtOqZS2G4yStvM1eI64=; b=WVOXxAKR3ZNPaHpH+4AX7Vd2dGBGXY7pVkDpx1dWG9Sf/Aj6i/I8qurMypSOnph3dvUK3V 9QgNY0H2/0vcObRXYxMiUF4Kur+hD+mqDQMVEXqlu6b/w0GFlTNObkf00R4IczTehznCG7 SjcPGqqOoU/xiPvXFNvkkki13izepCM= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-602-XGv5gjWwO2yKETv080uwwQ-1; Tue, 25 Feb 2025 10:06:32 -0500 X-MC-Unique: XGv5gjWwO2yKETv080uwwQ-1 X-Mimecast-MFC-AGG-ID: XGv5gjWwO2yKETv080uwwQ_1740495991 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 3A7AE1801A1A; Tue, 25 Feb 2025 15:06:31 +0000 (UTC) Received: from mzamazal-thinkpadp1gen7.tpbc.com (unknown [10.45.224.119]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 3770B1800357; Tue, 25 Feb 2025 15:06:28 +0000 (UTC) From: Milan Zamazal To: libcamera-devel@lists.libcamera.org Cc: Milan Zamazal , Stanislaw Gruszka , Laurent Pinchart , Kieran Bingham Subject: [PATCH v3 3/6] libcamera: software_isp: Handle queued input buffers on stop Date: Tue, 25 Feb 2025 16:06:09 +0100 Message-ID: <20250225150614.20195-4-mzamazal@redhat.com> In-Reply-To: <20250225150614.20195-1-mzamazal@redhat.com> References: <20250225150614.20195-1-mzamazal@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: Tdg03x3KHUi8xdNfxQIMtjve8qglk2IATtXL29MbVLs_1740495991 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" When SoftwareIsp stops, input and output buffers queued to it may not yet be fully processed. They will be eventually returned but stop means stop, there should be no processing related actions invoked afterwards. Let's stop forwarding processed input buffers from SoftwareIsp slots when SoftwareIsp is stopped. Let's track the queued input buffers and return them back for capture in SoftwareIsp::stop(). The returned input buffers are marked as canceled. This is not necessary at the moment but it gives the pipeline handlers chance to deal with this if they need to. Signed-off-by: Milan Zamazal Reviewed-by: Laurent Pinchart Reviewed-by: Kieran Bingham --- .../internal/software_isp/software_isp.h | 1 + src/libcamera/software_isp/software_isp.cpp | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/include/libcamera/internal/software_isp/software_isp.h b/include/libcamera/internal/software_isp/software_isp.h index 5073ce7a..400a4dc5 100644 --- a/include/libcamera/internal/software_isp/software_isp.h +++ b/include/libcamera/internal/software_isp/software_isp.h @@ -102,6 +102,7 @@ private: std::unique_ptr ipa_; bool running_; + std::deque queuedInputBuffers_; std::deque queuedOutputBuffers_; }; diff --git a/src/libcamera/software_isp/software_isp.cpp b/src/libcamera/software_isp/software_isp.cpp index 140cddf3..beac66fc 100644 --- a/src/libcamera/software_isp/software_isp.cpp +++ b/src/libcamera/software_isp/software_isp.cpp @@ -303,6 +303,8 @@ int SoftwareIsp::queueBuffers(uint32_t frame, FrameBuffer *input, return -EINVAL; } + queuedInputBuffers_.push_back(input); + for (auto iter = outputs.begin(); iter != outputs.end(); iter++) { FrameBuffer *const buffer = iter->second; queuedOutputBuffers_.push_back(buffer); @@ -329,6 +331,9 @@ int SoftwareIsp::start() /** * \brief Stops the Software ISP streaming operation + * + * All pending buffers are returned back as canceled before this method + * finishes. */ void SoftwareIsp::stop() { @@ -344,6 +349,13 @@ void SoftwareIsp::stop() outputBufferReady.emit(buffer); } queuedOutputBuffers_.clear(); + + for (auto buffer : queuedInputBuffers_) { + FrameMetadata &metadata = buffer->_d()->metadata(); + metadata.status = FrameMetadata::FrameCancelled; + inputBufferReady.emit(buffer); + } + queuedInputBuffers_.clear(); } /** @@ -377,7 +389,11 @@ void SoftwareIsp::statsReady(uint32_t frame, uint32_t bufferId) void SoftwareIsp::inputReady(FrameBuffer *input) { - inputBufferReady.emit(input); + if (running_) { + ASSERT(queuedInputBuffers_.front() == input); + queuedInputBuffers_.pop_front(); + inputBufferReady.emit(input); + } } void SoftwareIsp::outputReady(FrameBuffer *output)