From patchwork Tue Mar 19 12:05:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 19756 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 90D0FC32CB for ; Tue, 19 Mar 2024 12:05:48 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 3041E63075; Tue, 19 Mar 2024 13:05:48 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="XkLeYQyy"; 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 9CBE462CA7 for ; Tue, 19 Mar 2024 13:05:31 +0100 (CET) Received: from jasper.fritz.box (unknown [IPv6:2a00:6020:448c:6c00:1478:344b:8fcb:baf5]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id ED148F02; Tue, 19 Mar 2024 13:05:04 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1710849905; bh=j0qVsA7Ec5j4cYznYL9ApPVX34uJ15f5sSF/tB0rpSw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XkLeYQyyIJPVtLtIxhBYuusqkoKU57B19AaqzDMz9x6x9iV3lYN1BTk9qR60ijiYB pOAOg+Ik3FzQm6+v1LWaQQVb6Akv4zPYK0EM2RdDkUEgdGjzrbsJHq20xlg1Be7WFG 1+CFOB7rdqKb6haFKXXD33Qs+Vs88GQIl8SfuMcM= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug Subject: [PATCH v3 16/16] pipeline: rkisp1: Apply initial controls Date: Tue, 19 Mar 2024 13:05:17 +0100 Message-Id: <20240319120517.362082-17-stefan.klug@ideasonboard.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240319120517.362082-1-stefan.klug@ideasonboard.com> References: <20240319120517.362082-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 | 21 ++++++++++++++++----- src/libcamera/pipeline/rkisp1/rkisp1.cpp | 9 +++++++-- 3 files changed, 29 insertions(+), 8 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 240e11e6..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,12 +200,19 @@ int IPARkISP1::init(const IPASettings &settings, unsigned int hwRevision, return 0; } -int IPARkISP1::start() +void IPARkISP1::start(const ControlList &controls, StartResult *result) { - ControlList ctrls = getControls(0); - setSensorControls.emit(0, ctrls); + 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() @@ -323,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 ab452d8f..fec3c58b 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;