[{"id":17478,"web_url":"https://patchwork.libcamera.org/comment/17478/","msgid":"<YL9K9e0qH6YlTnHW@pendragon.ideasonboard.com>","date":"2021-06-08T10:48:21","subject":"Re: [libcamera-devel] [PATCH 2/2] ipa: ipu3: Initialize\n\tCameraSensorHelper at IPU3 init stage","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Jean-Michel,\n\nThank you for the patch.\n\nOn Mon, Jun 07, 2021 at 02:35:33PM +0200, Jean-Michel Hautbois wrote:\n> In order for the CameraSensorHelper to be instantianted, we need to find\n> its factory using the camera sensor model name stored in\n> IPASettings::sensorModel. As we don't need to do it at each configure\n> call (the sensor is not changing in-between), implement the init call in\n> IPAIPU3 to do that.\n> \n> Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>\n> ---\n>  src/ipa/ipu3/ipu3.cpp | 34 ++++++++++++++++++++++++++++++----\n>  1 file changed, 30 insertions(+), 4 deletions(-)\n> \n> diff --git a/src/ipa/ipu3/ipu3.cpp b/src/ipa/ipu3/ipu3.cpp\n> index 700a5660..7b0d66ea 100644\n> --- a/src/ipa/ipu3/ipu3.cpp\n> +++ b/src/ipa/ipu3/ipu3.cpp\n> @@ -19,10 +19,12 @@\n>  #include <libcamera/request.h>\n>  \n>  #include \"libcamera/internal/buffer.h\"\n> +#include \"libcamera/internal/camera_sensor_properties.h\"\n>  #include \"libcamera/internal/log.h\"\n>  \n>  #include \"ipu3_agc.h\"\n>  #include \"ipu3_awb.h\"\n> +#include \"libipa/camera_sensor_helper.h\"\n>  \n>  static constexpr uint32_t kMaxCellWidthPerSet = 160;\n>  static constexpr uint32_t kMaxCellHeightPerSet = 56;\n> @@ -36,10 +38,7 @@ namespace ipa::ipu3 {\n>  class IPAIPU3 : public IPAIPU3Interface\n>  {\n>  public:\n> -\tint init([[maybe_unused]] const IPASettings &settings) override\n> -\t{\n> -\t\treturn 0;\n> -\t}\n> +\tint init(const IPASettings &settings) override;\n>  \tint start() override;\n>  \tvoid stop() override {}\n>  \n> @@ -75,6 +74,8 @@ private:\n>  \tstd::unique_ptr<IPU3Awb> awbAlgo_;\n>  \t/* Interface to the AEC/AGC algorithm */\n>  \tstd::unique_ptr<IPU3Agc> agcAlgo_;\n> +\t/* Interface to the Camera Helper */\n> +\tstd::unique_ptr<CameraSensorHelper> camHelper_;\n>  \n>  \t/* Local parameter storage */\n>  \tstruct ipu3_uapi_params params_;\n> @@ -82,6 +83,31 @@ private:\n>  \tstruct ipu3_uapi_grid_config bdsGrid_;\n>  };\n>  \n> +int IPAIPU3::init(const IPASettings &settings)\n> +{\n> +\tstd::vector<CameraSensorHelperFactory *> &factories =\n> +\t\tCameraSensorHelperFactory::factories();\n> +\n> +\tfor (CameraSensorHelperFactory *factory : factories) {\n> +\t\tLOG(IPAIPU3, Debug)\n> +\t\t\t<< \"Found registered camera sensor helper '\"\n> +\t\t\t<< factory->name() << \"'\";\n\nIf you want debug messages to tell what helpers are available, I'd print\none in CameraSensorHelperFactory::registerType(). I however expect to\nhave lots of helpers, so that may flood the log. I'd drop it.\n\n> +\n> +\t\tstd::unique_ptr<CameraSensorHelper> camHelper = factory->create();\n> +\n> +\t\tif (camHelper->name() != settings.sensorModel)\n> +\t\t\tcontinue;\n\nWhy do you create an instance of each helper just to test the name, when\nyou have the name available in the factory ? The\nCameraSensorHelper::name() can then be dropped.\n\n> +\n> +\t\tLOG(IPAIPU3, Debug)\n> +\t\t\t<< \"Camera sensor helper \\\"\" << factory->name()\n> +\t\t\t<< \"\\\" matched\";\n\nThis can be dropped.\n\n> +\n> +\t\tcamHelper_ = std::move(camHelper);\n> +\t}\n\nNone of this is specific to the IPU3, it should be moved to the\nCameraSensorHelperFactory class. I'd move it to\nCameraSensorFactory::create() and make that function static.\n\n> +\n> +\treturn 0;\n\nWhere's the rrror handling when no helper is found ?\n\n> +}\n> +\n>  int IPAIPU3::start()\n>  {\n>  \tsetControls(0);","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 6334DC3206\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  8 Jun 2021 10:48:39 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 85F45602A7;\n\tTue,  8 Jun 2021 12:48:38 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id F31746029F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  8 Jun 2021 12:48:37 +0200 (CEST)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 63BA23E6;\n\tTue,  8 Jun 2021 12:48:37 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"JpOHzLBF\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1623149317;\n\tbh=kcagW77DTNV3QsH04XspWSzDWwBQXdDW27w1kgEjFlM=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=JpOHzLBF6NQQ0xlkqkSQLROnlvyNhbMoBONZFhLmulU6xAcSYuZPAx+NWML/w5+jH\n\tEASRuSLFkIU9wa3lqNGRED3LAkziU5+ZorE+w8ynL0zUpEZEsrIjKfTbSqmKF950Oo\n\t4xKAeGxQEPGkAFm4GbSqlOXJgtO4lP8vaeeGoVG0=","Date":"Tue, 8 Jun 2021 13:48:21 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>","Message-ID":"<YL9K9e0qH6YlTnHW@pendragon.ideasonboard.com>","References":"<20210607123533.51198-1-jeanmichel.hautbois@ideasonboard.com>\n\t<20210607123533.51198-2-jeanmichel.hautbois@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20210607123533.51198-2-jeanmichel.hautbois@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH 2/2] ipa: ipu3: Initialize\n\tCameraSensorHelper at IPU3 init stage","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]