From patchwork Tue Aug 2 00:13:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 16892 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 4A912C3275 for ; Tue, 2 Aug 2022 00:13:38 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7694363312; Tue, 2 Aug 2022 02:13:37 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1659399217; bh=pTlqja1EK/d7Tx2BNyPYNEqqEp8tjkAwmKc8tVVLl5A=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=OyGqwRRKGF0w8z4OggQaHjEDDVAe/pF7v2niNZuma7+aaaXUz2th2NCq0t3pzu+dL EIlZBcuGYs+EM/uv82sXYp7E0J8Uca/TgBx6AUV26uTGflJmlGUSjBhEGOyySvZhZb SAl+PxP4oWwyXrDySlQk0Li6sSJ63uvdw+eJl9Sbm6M3G25y2whxicL6oCxJjajNBc 3efBgP296tRZr08pGJOiCEZk1QkkK3/tThJbkCWCnvLA/gPjZcIv7Y2ujMGxk0oe2I UBjTkGlYJwKL309KKiFGbv59kVvNCUWp1+TFz038U0gd9OfQ2FpDeT8683Hhhf6nM+ 2T+6MeCToYR+Q== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 832AF61FAE for ; Tue, 2 Aug 2022 02:13:35 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="lsK5+dZj"; dkim-atps=neutral Received: from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id C624D25B; Tue, 2 Aug 2022 02:13:34 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1659399215; bh=pTlqja1EK/d7Tx2BNyPYNEqqEp8tjkAwmKc8tVVLl5A=; h=From:To:Cc:Subject:Date:From; b=lsK5+dZjveg279Lp5R9Ed39UKAVIqLi+NglNCgaOb6uKDG7WpDZ0aSjO/lds+aJY5 TDBYpKwvaslNGYgVACcd9n2pVoni6Tlm7p+drHwYoyFhoRlhzZXk3QFV45fepw5eaF dIYtlc+ci3mYK99vr4rIdiYPJ+hED+m/FtJrXSTw= To: libcamera-devel@lists.libcamera.org Date: Tue, 2 Aug 2022 03:13:30 +0300 Message-Id: <20220802001330.17073-1-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH] pipeline: rkisp1: Move ControlInfoMap to IPA module 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: , X-Patchwork-Original-From: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Currently the pipeline handler advertises controls handled by the IPA from a ControlInfoMap it manually constructs. This is wrong, as the IPA module is the component that knows what controls it supports. Fix this by moving the ControlInfoMap construction to the IPA module, and pass it to the pipeline handler as a return value from the IPA init() function. Signed-off-by: Laurent Pinchart Reviewed-by: Umang Jain Reviewed-by: Paul Elder Reviewed-by: Florian Sylvestre --- include/libcamera/ipa/rkisp1.mojom | 2 +- src/ipa/rkisp1/rkisp1.cpp | 30 ++++++++++++++++++++--- src/libcamera/pipeline/rkisp1/rkisp1.cpp | 31 ++---------------------- 3 files changed, 30 insertions(+), 33 deletions(-) diff --git a/include/libcamera/ipa/rkisp1.mojom b/include/libcamera/ipa/rkisp1.mojom index e35373852b7c..eaf3955e4096 100644 --- a/include/libcamera/ipa/rkisp1.mojom +++ b/include/libcamera/ipa/rkisp1.mojom @@ -11,7 +11,7 @@ import "include/libcamera/ipa/core.mojom"; interface IPARkISP1Interface { init(libcamera.IPASettings settings, uint32 hwRevision) - => (int32 ret); + => (int32 ret, libcamera.ControlInfoMap ipaControls); start() => (int32 ret); stop(); diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp index e5010f6ab629..52f7143980fe 100644 --- a/src/ipa/rkisp1/rkisp1.cpp +++ b/src/ipa/rkisp1/rkisp1.cpp @@ -46,7 +46,8 @@ namespace ipa::rkisp1 { class IPARkISP1 : public IPARkISP1Interface, public Module { public: - int init(const IPASettings &settings, unsigned int hwRevision) override; + int init(const IPASettings &settings, unsigned int hwRevision, + ControlInfoMap *ipaControls) override; int start() override; void stop() override {} @@ -89,12 +90,27 @@ private: struct IPAContext context_; }; +namespace { + +/* List of controls handled by the RkISP1 IPA */ +const ControlInfoMap::Map rkisp1Controls{ + { &controls::AeEnable, ControlInfo(false, true) }, + { &controls::Brightness, ControlInfo(-1.0f, 0.993f) }, + { &controls::Contrast, ControlInfo(0.0f, 1.993f) }, + { &controls::Saturation, ControlInfo(0.0f, 1.993f) }, + { &controls::Sharpness, ControlInfo(0.0f, 10.0f, 1.0f) }, + { &controls::draft::NoiseReductionMode, ControlInfo(controls::draft::NoiseReductionModeValues) }, +}; + +} /* namespace */ + std::string IPARkISP1::logPrefix() const { return "rkisp1"; } -int IPARkISP1::init(const IPASettings &settings, unsigned int hwRevision) +int IPARkISP1::init(const IPASettings &settings, unsigned int hwRevision, + ControlInfoMap *ipaControls) { /* \todo Add support for other revisions */ switch (hwRevision) { @@ -156,7 +172,15 @@ int IPARkISP1::init(const IPASettings &settings, unsigned int hwRevision) return -EINVAL; } - return createAlgorithms(context_, (*data)["algorithms"]); + int ret = createAlgorithms(context_, (*data)["algorithms"]); + if (ret) + return ret; + + /* Return the controls handled by the IPA. */ + ControlInfoMap::Map ctrlMap = rkisp1Controls; + *ipaControls = ControlInfoMap(std::move(ctrlMap), controls::controls); + + return 0; } int IPARkISP1::start() diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp index de687f4dc6b0..932873329e89 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp @@ -344,7 +344,8 @@ int RkISP1CameraData::loadIPA(unsigned int hwRevision) ipaTuningFile = std::string(configFromEnv); } - int ret = ipa_->init({ ipaTuningFile, sensor_->model() }, hwRevision); + int ret = ipa_->init({ ipaTuningFile, sensor_->model() }, hwRevision, + &controlInfo_); if (ret < 0) { LOG(RkISP1, Error) << "IPA initialization failure"; return ret; @@ -967,34 +968,6 @@ int PipelineHandlerRkISP1::createCamera(MediaEntity *sensor) std::make_unique(this, &mainPath_, hasSelfPath_ ? &selfPath_ : nullptr); - ControlInfoMap::Map ctrls; - ctrls.emplace(std::piecewise_construct, - std::forward_as_tuple(&controls::Sharpness), - std::forward_as_tuple(0.0f, 10.0f, 1.0f)); - - ctrls.emplace(std::piecewise_construct, - std::forward_as_tuple(&controls::Brightness), - std::forward_as_tuple(-1.0f, 0.993f)); - - ctrls.emplace(std::piecewise_construct, - std::forward_as_tuple(&controls::Contrast), - std::forward_as_tuple(0.0f, 1.993f)); - - ctrls.emplace(std::piecewise_construct, - std::forward_as_tuple(&controls::Saturation), - std::forward_as_tuple(0.0f, 1.993f)); - - ctrls.emplace(std::piecewise_construct, - std::forward_as_tuple(&controls::draft::NoiseReductionMode), - std::forward_as_tuple(controls::draft::NoiseReductionModeValues)); - - ctrls.emplace(std::piecewise_construct, - std::forward_as_tuple(&controls::AeEnable), - std::forward_as_tuple(false, true)); - - data->controlInfo_ = ControlInfoMap(std::move(ctrls), - controls::controls); - data->sensor_ = std::make_unique(sensor); ret = data->sensor_->init(); if (ret)