[{"id":20668,"web_url":"https://patchwork.libcamera.org/comment/20668/","msgid":"<163597845561.1378115.15300505868946374061@Monstersaurus>","date":"2021-11-03T22:27:35","subject":"Re: [libcamera-devel] [PATCH v2 5/6] ipu3: Run AIQ for the first\n\tframe to avoid blanking","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Han-Lin Chen (2021-10-29 13:00:00)\n> The start() function set the first exposure time and analog gain to maximum.\n> In result, the first frame might be over bright and the user may see a\n> bright blank when changing the camera in application. Run AIQ to get an\n> initial exposure time and analog gain in start() to smooth the AE\n> process.\n\nSplitting the AIQ run to it's own function looks a lot better too\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n> Signed-off-by: Han-Lin Chen <hanlinchen@chromium.org>\n> ---\n>  ipu3.cpp | 45 ++++++++++++++++++++++++++-------------------\n>  1 file changed, 26 insertions(+), 19 deletions(-)\n> \n> diff --git a/ipu3.cpp b/ipu3.cpp\n> index c2dc754..2232e07 100644\n> --- a/ipu3.cpp\n> +++ b/ipu3.cpp\n> @@ -56,6 +56,7 @@ private:\n>                             const ControlInfoMap &sensorControls,\n>                             ControlInfoMap *ipaControls);\n>         void processControls(unsigned int frame, const ControlList &metadata);\n> +       void runAiq(unsigned int frame);\n>         void fillParams(unsigned int frame, ipu3_uapi_params *params);\n>         void parseStatistics(unsigned int frame,\n>                              int64_t frameTimestamp,\n> @@ -221,6 +222,7 @@ int IPAIPU3::init(const IPASettings &settings,\n>  \n>  int IPAIPU3::start()\n>  {\n> +       runAiq(0);\n>         setControls(0);\n>  \n>         return 0;\n> @@ -370,29 +372,11 @@ void IPAIPU3::processControls([[maybe_unused]] unsigned int frame,\n>         /* \\todo Start processing for 'frame' based on 'controls'. */\n>  }\n>  \n> -void IPAIPU3::fillParams(unsigned int frame, ipu3_uapi_params *params)\n> +void IPAIPU3::runAiq(unsigned int frame)\n>  {\n> -       /* Prepare parameters buffer. */\n> -       memset(params, 0, sizeof(*params));\n> -\n> -       /*\n> -       * Call into the AIQ object, and set up the library with any requested\n> -       * controls or settings from the incoming request.\n> -       *\n> -       * (statistics are fed into the library as a separate event\n> -       *  when available)\n> -       *\n> -       * - Run algorithms\n> -       *\n> -       * - Fill params buffer with the results of the algorithms.\n> -       */\n> -\n>         /* Run algorithms into/using this context structure */\n>         aiq_.run2a(frame, aiqInputParams_, results_, lensPosition_, lensMovementStartTime_);\n>  \n> -       aic_.updateRuntimeParams(results_);\n> -       aic_.run(params);\n> -\n>         exposure_ = results_.ae()->exposures[0].sensor_exposure->coarse_integration_time;\n>         gain_ = results_.ae()->exposures[0].sensor_exposure->analog_gain_code_global;\n>  \n> @@ -410,6 +394,29 @@ void IPAIPU3::fillParams(unsigned int frame, ipu3_uapi_params *params)\n>         lensPosition_ = results_.af()->next_lens_position;\n>  \n>         resultsHistory_.Push(results_);\n> +}\n> +\n> +void IPAIPU3::fillParams(unsigned int frame, ipu3_uapi_params *params)\n> +{\n> +       /* Prepare parameters buffer. */\n> +       memset(params, 0, sizeof(*params));\n> +\n> +       /*\n> +       * Call into the AIQ object, and set up the library with any requested\n> +       * controls or settings from the incoming request.\n> +       *\n> +       * (statistics are fed into the library as a separate event\n> +       *  when available)\n> +       *\n> +       * - Run algorithms\n> +       *\n> +       * - Fill params buffer with the results of the algorithms.\n> +       */\n> +\n> +       runAiq(frame);\n> +\n> +       aic_.updateRuntimeParams(results_);\n> +       aic_.run(params);\n>  \n>         setControls(frame);\n>  \n> -- \n> 2.33.1.1089.g2158813163f-goog\n>","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 590EFBF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  3 Nov 2021 22:27:41 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id B56CB600BF;\n\tWed,  3 Nov 2021 23:27:40 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id B65AA600B5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  3 Nov 2021 23:27:38 +0100 (CET)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 4E3DD501;\n\tWed,  3 Nov 2021 23:27:38 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"PpXvknFa\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1635978458;\n\tbh=lOkEqMNXtKU1GRDJfa0SNUnk2oivvyEMvDWS9w3rdiM=;\n\th=In-Reply-To:References:Subject:From:To:Date:From;\n\tb=PpXvknFa4FSTd1UOpkrHn4nsi5URTdfCGB0N1lIZc/q0F4zdXk/kewU/t+B2+AwTk\n\twtfT7xoMuwPR56AsjywxHIon/MvKWIfGS5UkEP+X5/9kVY/nY14DKOnIh3oZpw9kdj\n\taESE8hXHkMRGy0+g81sjL5KCYwUhIgslHre48A0k=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20211029120001.2469018-5-hanlinchen@chromium.org>","References":"<20211029120001.2469018-1-hanlinchen@chromium.org>\n\t<20211029120001.2469018-5-hanlinchen@chromium.org>","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","To":"Han-Lin Chen <hanlinchen@chromium.org>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Wed, 03 Nov 2021 22:27:35 +0000","Message-ID":"<163597845561.1378115.15300505868946374061@Monstersaurus>","User-Agent":"alot/0.9.1","Subject":"Re: [libcamera-devel] [PATCH v2 5/6] ipu3: Run AIQ for the first\n\tframe to avoid blanking","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]