From patchwork Wed Mar 13 10:56:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 19701 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 B7D16C32C7 for ; Wed, 13 Mar 2024 10:57:15 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C101762CAC; Wed, 13 Mar 2024 11:57:12 +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="jKPZgN4U"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 9F2D462C98 for ; Wed, 13 Mar 2024 11:56:55 +0100 (CET) Received: from jasper.fritz.box (unknown [IPv6:2a00:6020:448c:6c00:9b07:31b5:38e1:e957]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 22D5CF8B; Wed, 13 Mar 2024 11:56:33 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1710327393; bh=K9QJJqMlbyeIAybLkwePUedqoG2A+3ScRBC8rZ4JR0Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jKPZgN4Ugonw4fCPLw24/V/JDbR/BC4KbZhhljNfxlSef9P4ZuxrUlJinzXzceyXW cek8MaZjPVyjZQUMMz2G+mZhM1WbQu2azNjcRF8t6PNOJzizKJeaF2et5GhSuFRukB XX5HRVkoZmtn6e+Kidbxv8EUXP46NHKl0IY/yi+Q= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Subject: [PATCH 12/12] pipeline: rkisp1: Apply initial controls Date: Wed, 13 Mar 2024 11:56:45 +0100 Message-Id: <20240313105645.120317-14-stefan.klug@ideasonboard.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240313105645.120317-1-stefan.klug@ideasonboard.com> References: <20240313105645.120317-1-stefan.klug@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" Controls passed to Camera::start() are now correctly applied. This is needed to pass the per-frame-controls test. The code uses the return value of ipa->start() to return the initial controls and pass them to the sensor instead of the setSensorControls signal because setSensorControls is asynchronous and would reach the sensor too late. Signed-off-by: Stefan Klug --- include/libcamera/ipa/rkisp1.mojom | 7 ++++++- src/ipa/rkisp1/rkisp1.cpp | 20 ++++++++++++++++---- src/libcamera/pipeline/rkisp1/rkisp1.cpp | 9 +++++++-- 3 files changed, 29 insertions(+), 7 deletions(-) diff --git a/include/libcamera/ipa/rkisp1.mojom b/include/libcamera/ipa/rkisp1.mojom index 1009e970..828308c6 100644 --- a/include/libcamera/ipa/rkisp1.mojom +++ b/include/libcamera/ipa/rkisp1.mojom @@ -13,13 +13,18 @@ struct IPAConfigInfo { libcamera.ControlInfoMap sensorControls; }; +struct StartResult { + libcamera.ControlList controls; + int32 code; +}; + interface IPARkISP1Interface { init(libcamera.IPASettings settings, uint32 hwRevision, libcamera.IPACameraSensorInfo sensorInfo, libcamera.ControlInfoMap sensorControls) => (int32 ret, libcamera.ControlInfoMap ipaControls); - start() => (int32 ret); + start(libcamera.ControlList controls) => (StartResult result); stop(); configure(IPAConfigInfo configInfo, diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp index 8780abc9..6cde23cb 100644 --- a/src/ipa/rkisp1/rkisp1.cpp +++ b/src/ipa/rkisp1/rkisp1.cpp @@ -53,7 +53,7 @@ public: const IPACameraSensorInfo &sensorInfo, const ControlInfoMap &sensorControls, ControlInfoMap *ipaControls) override; - int start() override; + void start(const ControlList &controls, StartResult *result) override; void stop() override; int configure(const IPAConfigInfo &ipaConfig, @@ -86,6 +86,7 @@ private: /* Local parameter storage */ struct IPAContext context_; + bool initialControlsDone_; }; namespace { @@ -199,11 +200,19 @@ int IPARkISP1::init(const IPASettings &settings, unsigned int hwRevision, return 0; } -int IPARkISP1::start() +void IPARkISP1::start(const ControlList &controls, StartResult *result) { - setControls(0); + initialControlsDone_ = false; + /* + * Todo: This is really shady. In order to apply the initial controls we already + * queue a request for frame 0 and return the results. + * We need to discuss the official recommendation to handle start controls + */ + queueRequest(0, controls); - return 0; + result->controls = getControls(0); + result->code = 0; + initialControlsDone_ = true; } void IPARkISP1::stop() @@ -322,6 +331,9 @@ void IPARkISP1::queueRequest(const uint32_t frame, const ControlList &controls) algo->queueRequest(context_, frame, frameContext, controls); } + if (!initialControlsDone_) + return; + /* Fast path, if we are not regulating */ if (!frameContext.agc.autoEnabled) { ControlList ctrls = getControls(frame); diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp index 3e061b52..7c68073d 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp @@ -927,13 +927,18 @@ int PipelineHandlerRkISP1::start(Camera *camera, [[maybe_unused]] const ControlL if (ret) return ret; - ret = data->ipa_->start(); - if (ret) { + ControlList ctrls; + if (!!controls) + ctrls = *controls; + ipa::rkisp1::StartResult res; + data->ipa_->start(ctrls, &res); + if (res.code) { freeBuffers(camera); LOG(RkISP1, Error) << "Failed to start IPA " << camera->id(); return ret; } + data->delayedCtrls_->reset(&res.controls); data->frame_ = 0;