From patchwork Mon Oct 21 13:37:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Milan Zamazal X-Patchwork-Id: 21718 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 8B9C7C3309 for ; Mon, 21 Oct 2024 13:37:50 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E596E65399; Mon, 21 Oct 2024 15:37:49 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="VNoeK+D/"; 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 6CCD765398 for ; Mon, 21 Oct 2024 15:37:47 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729517866; 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=/KjUV+jV2J4k0c6iGkRURF6qQjdQhvNIhS+4USjZRPw=; b=VNoeK+D/LsByMuNH5NsW+A8jfBJA9cXt577JU6Wyhh/xg6MOPrpcc7BoWKK62gd5j9jgkd i5HLe5ydaHauLrW3dwvAZP4NOo5abi6nXqlny2f/bQmK498iX+WMDSlTSOkxVXb5bdC98n hOazuEVnFpQ0l6l2tXMUFQdHu1OVRiU= 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-427--zghdlq9P0-e4RW-PQmOcA-1; Mon, 21 Oct 2024 09:37:42 -0400 X-MC-Unique: -zghdlq9P0-e4RW-PQmOcA-1 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (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 6AE401955F43; Mon, 21 Oct 2024 13:37:41 +0000 (UTC) Received: from nuthatch.redhat.com (unknown [10.45.225.218]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 4AB6819560AA; Mon, 21 Oct 2024 13:37:38 +0000 (UTC) From: Milan Zamazal To: libcamera-devel@lists.libcamera.org Cc: Milan Zamazal , robert.mader@posteo.de, kieran.bingham@ideasonboard.com, laurent.pinchart@ideasonboard.com Subject: [PATCH v5 2/3] libcamera: simple: Track requests in conversionQueue_ Date: Mon, 21 Oct 2024 15:37:17 +0200 Message-ID: <20241021133718.894374-3-mzamazal@redhat.com> In-Reply-To: <20241021133718.894374-1-mzamazal@redhat.com> References: <20241021133718.894374-1-mzamazal@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 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" Simple pipeline retrieves the requests to complete from the conversionQueue_. This patch stores the requests in conversionQueue_ explicitly. This explicit tracking is supposed to be preferred to implicit retrieval and it simplifies the completion code a bit here and in the followup patch that adds request cleanup on stop. The change as implemented assumes that all the buffers in each of the conversionQueue_ elements point to the same request, the one specified. Signed-off-by: Milan Zamazal Tested-by: Kieran Bingham Reviewed-by: Kieran Bingham Reviewed-by: Hans de Goede Reviewed-by: Laurent Pinchart --- src/libcamera/pipeline/simple/simple.cpp | 26 ++++++++++++------------ 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp index 3ddce71d3..f3a6b1635 100644 --- a/src/libcamera/pipeline/simple/simple.cpp +++ b/src/libcamera/pipeline/simple/simple.cpp @@ -282,7 +282,11 @@ public: std::unique_ptr delayedCtrls_; std::vector> conversionBuffers_; - std::queue> conversionQueue_; + struct RequestOutputs { + Request *request; + std::map outputs; + }; + std::queue conversionQueue_; bool useConversion_; std::unique_ptr converter_; @@ -813,16 +817,12 @@ void SimpleCameraData::bufferReady(FrameBuffer *buffer) if (conversionQueue_.empty()) return; - Request *request = nullptr; - for (auto &item : conversionQueue_.front()) { - FrameBuffer *outputBuffer = item.second; - request = outputBuffer->request(); - pipe->completeBuffer(request, outputBuffer); - } + Request *request = conversionQueue_.front().request; + for (auto &item : conversionQueue_.front().outputs) + pipe->completeBuffer(request, item.second); + pipe->completeRequest(request); conversionQueue_.pop(); - if (request) - pipe->completeRequest(request); return; } @@ -838,7 +838,7 @@ void SimpleCameraData::bufferReady(FrameBuffer *buffer) if (useConversion_ && !conversionQueue_.empty()) { const std::map &outputs = - conversionQueue_.front(); + conversionQueue_.front().outputs; if (!outputs.empty()) { FrameBuffer *outputBuffer = outputs.begin()->second; if (outputBuffer) @@ -862,7 +862,7 @@ void SimpleCameraData::bufferReady(FrameBuffer *buffer) } if (converter_) - converter_->queueBuffers(buffer, conversionQueue_.front()); + converter_->queueBuffers(buffer, conversionQueue_.front().outputs); else /* * request->sequence() cannot be retrieved from `buffer' inside @@ -870,7 +870,7 @@ void SimpleCameraData::bufferReady(FrameBuffer *buffer) * already here. */ swIsp_->queueBuffers(request->sequence(), buffer, - conversionQueue_.front()); + conversionQueue_.front().outputs); conversionQueue_.pop(); return; @@ -1434,7 +1434,7 @@ int SimplePipelineHandler::queueRequestDevice(Camera *camera, Request *request) } if (data->useConversion_) { - data->conversionQueue_.push(std::move(buffers)); + data->conversionQueue_.push({ .request = request, .outputs = std::move(buffers) }); if (data->swIsp_) data->swIsp_->queueRequest(request->sequence(), request->controls()); }