From patchwork Mon Jun 7 12:35:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Michel Hautbois X-Patchwork-Id: 12501 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 117F8C3206 for ; Mon, 7 Jun 2021 12:35:41 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2748568928; Mon, 7 Jun 2021 14:35:40 +0200 (CEST) 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="YAa+rGa1"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A3A0C602A7 for ; Mon, 7 Jun 2021 14:35:38 +0200 (CEST) Received: from tatooine.ideasonboard.com (unknown [IPv6:2a01:e0a:169:7140:b035:2cc2:4506:d7d3]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 525BDE04; Mon, 7 Jun 2021 14:35:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1623069338; bh=vGypoHQDA7k+uHeBZo5sgiKPxCqMYf0iCN7RUIo1YCE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YAa+rGa1kb69HjNze578j7tISEOZBq3yd6DwNzR+28oNLilfrk2HZrdufVq6C03eK YpKlE/mF7HTKjZh69Qro4iTaoStkMTNSwhs6xcu8LN86SBr0SguQKwQ7/3bucuQdqC /Yq7hFhyJSU444mXtV+P7RpeGIYcghmTJBt0UmyY= From: Jean-Michel Hautbois To: libcamera-devel@lists.libcamera.org Date: Mon, 7 Jun 2021 14:35:33 +0200 Message-Id: <20210607123533.51198-2-jeanmichel.hautbois@ideasonboard.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210607123533.51198-1-jeanmichel.hautbois@ideasonboard.com> References: <20210607123533.51198-1-jeanmichel.hautbois@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 2/2] ipa: ipu3: Initialize CameraSensorHelper at IPU3 init stage 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" In order for the CameraSensorHelper to be instantianted, we need to find its factory using the camera sensor model name stored in IPASettings::sensorModel. As we don't need to do it at each configure call (the sensor is not changing in-between), implement the init call in IPAIPU3 to do that. Signed-off-by: Jean-Michel Hautbois --- src/ipa/ipu3/ipu3.cpp | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/src/ipa/ipu3/ipu3.cpp b/src/ipa/ipu3/ipu3.cpp index 700a5660..7b0d66ea 100644 --- a/src/ipa/ipu3/ipu3.cpp +++ b/src/ipa/ipu3/ipu3.cpp @@ -19,10 +19,12 @@ #include #include "libcamera/internal/buffer.h" +#include "libcamera/internal/camera_sensor_properties.h" #include "libcamera/internal/log.h" #include "ipu3_agc.h" #include "ipu3_awb.h" +#include "libipa/camera_sensor_helper.h" static constexpr uint32_t kMaxCellWidthPerSet = 160; static constexpr uint32_t kMaxCellHeightPerSet = 56; @@ -36,10 +38,7 @@ namespace ipa::ipu3 { class IPAIPU3 : public IPAIPU3Interface { public: - int init([[maybe_unused]] const IPASettings &settings) override - { - return 0; - } + int init(const IPASettings &settings) override; int start() override; void stop() override {} @@ -75,6 +74,8 @@ private: std::unique_ptr awbAlgo_; /* Interface to the AEC/AGC algorithm */ std::unique_ptr agcAlgo_; + /* Interface to the Camera Helper */ + std::unique_ptr camHelper_; /* Local parameter storage */ struct ipu3_uapi_params params_; @@ -82,6 +83,31 @@ private: struct ipu3_uapi_grid_config bdsGrid_; }; +int IPAIPU3::init(const IPASettings &settings) +{ + std::vector &factories = + CameraSensorHelperFactory::factories(); + + for (CameraSensorHelperFactory *factory : factories) { + LOG(IPAIPU3, Debug) + << "Found registered camera sensor helper '" + << factory->name() << "'"; + + std::unique_ptr camHelper = factory->create(); + + if (camHelper->name() != settings.sensorModel) + continue; + + LOG(IPAIPU3, Debug) + << "Camera sensor helper \"" << factory->name() + << "\" matched"; + + camHelper_ = std::move(camHelper); + } + + return 0; +} + int IPAIPU3::start() { setControls(0);