From patchwork Tue Feb 20 16:43:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Scally X-Patchwork-Id: 19514 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 55355C32C3 for ; Tue, 20 Feb 2024 16:43:30 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D54516281B; Tue, 20 Feb 2024 17:43:27 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="HAcgv9SR"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D453D61CAA for ; Tue, 20 Feb 2024 17:43:24 +0100 (CET) Received: from mail.ideasonboard.com (cpc141996-chfd3-2-0-cust928.12-3.cable.virginm.net [86.13.91.161]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 72A0F14B0; Tue, 20 Feb 2024 17:43:17 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1708447397; bh=aFGqaUW3ZkJPRpocov+lqEFRvBqZ4KIdRpuExSdhOXU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HAcgv9SRYfpx8e7GzRFGYwa881BTr4JVxHadMKpbpxvJaL8Mo6yl+GitmlQNyuhyh G5LPBmT8AD9XinF4uLSiHk8RTmO33fV+ieWGcQ938vT7FhobHxc26pH/btrqfLQLmb 53ZPaHObS+kZYyyP2Ou53NCqx+6SctiAazis8+fE= From: Daniel Scally To: libcamera-devel@lists.libcamera.org Subject: [PATCH v2 3/7] libcamera: rkisp1: Track request->sequence() instead of frame_ Date: Tue, 20 Feb 2024 16:43:13 +0000 Message-Id: <20240220164317.998477-4-dan.scally@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240220164317.998477-1-dan.scally@ideasonboard.com> References: <20240220164317.998477-1-dan.scally@ideasonboard.com> MIME-Version: 1.0 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" The rkisp1 pipeline handler currently tries to track the frame number from V4L2 to provide an index to the IPA module's FCQueue - this is not necessary, the Request's sequence does the same job perfectly well. Note that the association of controls and calculated parameters with specific frames is not affected here - the parameters are always applied based on the most recently processed statistics, and the applied controls are fetched separately using the V4L2 provided buffer->metadata().sequence, which value is also internally tracked by DelayedControls. Signed-off-by: Daniel Scally --- Changes in v2: - In statReady() I no longer used request->sequence() to fetch from delayedCtrls_ - ensuring that we only use the V4L2 reported sequence there. src/libcamera/pipeline/rkisp1/rkisp1.cpp | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp index 586b46d6..d926c83c 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp @@ -88,7 +88,7 @@ class RkISP1CameraData : public Camera::Private public: RkISP1CameraData(PipelineHandler *pipe, RkISP1MainPath *mainPath, RkISP1SelfPath *selfPath) - : Camera::Private(pipe), frame_(0), frameInfo_(pipe), + : Camera::Private(pipe), frameInfo_(pipe), mainPath_(mainPath), selfPath_(selfPath) { } @@ -100,7 +100,6 @@ public: Stream selfPathStream_; std::unique_ptr sensor_; std::unique_ptr delayedCtrls_; - unsigned int frame_; std::vector ipaBuffers_; RkISP1Frames frameInfo_; @@ -214,7 +213,7 @@ RkISP1Frames::RkISP1Frames(PipelineHandler *pipe) RkISP1FrameInfo *RkISP1Frames::create(const RkISP1CameraData *data, Request *request, bool isRaw) { - unsigned int frame = data->frame_; + unsigned int frame = request->sequence(); FrameBuffer *paramBuffer = nullptr; FrameBuffer *statBuffer = nullptr; @@ -235,6 +234,7 @@ RkISP1FrameInfo *RkISP1Frames::create(const RkISP1CameraData *data, Request *req statBuffer = pipe_->availableStatBuffers_.front(); pipe_->availableStatBuffers_.pop(); + statBuffer->_d()->setRequest(request); } FrameBuffer *mainPathBuffer = request->findBuffer(&data->mainPathStream_); @@ -935,8 +935,6 @@ int PipelineHandlerRkISP1::start(Camera *camera, [[maybe_unused]] const ControlL return ret; } - data->frame_ = 0; - if (!isRaw_) { ret = param_->streamOn(); if (ret) { @@ -1028,7 +1026,7 @@ int PipelineHandlerRkISP1::queueRequestDevice(Camera *camera, Request *request) if (!info) return -ENOENT; - data->ipa_->queueRequest(data->frame_, request->controls()); + data->ipa_->queueRequest(request->sequence(), request->controls()); if (isRaw_) { if (info->mainPathBuffer) data->mainPath_->queueBuffer(info->mainPathBuffer); @@ -1036,12 +1034,10 @@ int PipelineHandlerRkISP1::queueRequestDevice(Camera *camera, Request *request) if (data->selfPath_ && info->selfPathBuffer) data->selfPath_->queueBuffer(info->selfPathBuffer); } else { - data->ipa_->fillParamsBuffer(data->frame_, + data->ipa_->fillParamsBuffer(request->sequence(), info->paramBuffer->cookie()); } - data->frame_++; - return 0; } @@ -1276,7 +1272,8 @@ void PipelineHandlerRkISP1::bufferReady(FrameBuffer *buffer) if (isRaw_) { const ControlList &ctrls = data->delayedCtrls_->get(metadata.sequence); - data->ipa_->processStatsBuffer(info->frame, 0, ctrls); + data->ipa_->processStatsBuffer(request->sequence(), + 0, ctrls); } } else { if (isRaw_) @@ -1304,6 +1301,7 @@ void PipelineHandlerRkISP1::statReady(FrameBuffer *buffer) { ASSERT(activeCamera_); RkISP1CameraData *data = cameraData(activeCamera_); + Request *request = buffer->request(); RkISP1FrameInfo *info = data->frameInfo_.find(buffer); if (!info) @@ -1315,10 +1313,7 @@ void PipelineHandlerRkISP1::statReady(FrameBuffer *buffer) return; } - if (data->frame_ <= buffer->metadata().sequence) - data->frame_ = buffer->metadata().sequence + 1; - - data->ipa_->processStatsBuffer(info->frame, info->statBuffer->cookie(), + data->ipa_->processStatsBuffer(request->sequence(), info->statBuffer->cookie(), data->delayedCtrls_->get(buffer->metadata().sequence)); }