[{"id":21061,"web_url":"https://patchwork.libcamera.org/comment/21061/","msgid":"<163733999312.1089182.14964661939045703662@Monstersaurus>","date":"2021-11-19T16:39:53","subject":"Re: [libcamera-devel] [IPU3-IPA PATCH v3 5/6] ipu3: Run AIQ for the\n\tfirst frame 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-11-11 10:49:07)\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> \n> Signed-off-by: Han-Lin Chen <hanlinchen@chromium.org>\n> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> ---\n>  ipu3.cpp | 44 ++++++++++++++++++++++++++------------------\n>  1 file changed, 26 insertions(+), 18 deletions(-)\n> \n> diff --git a/ipu3.cpp b/ipu3.cpp\n> index f38440d..ffa78b3 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> @@ -220,6 +221,7 @@ int IPAIPU3::init(const IPASettings &settings,\n>  \n>  int IPAIPU3::start()\n>  {\n> +       runAiq(0);\n>         setControls(0);\n>  \n>         return 0;\n> @@ -369,23 +371,8 @@ 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([[maybe_unused]] 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>         resultsHistory_.extendOne();\n>         aiq::AiqResults& latestResults = resultsHistory_.latest();\n> @@ -395,8 +382,6 @@ void IPAIPU3::fillParams(unsigned int frame, ipu3_uapi_params *params)\n>         aiqInputParams_.afParams.lens_movement_start_timestamp = lensMovementStartTime_;\n>  \n>         aiq_.run2a(frame, aiqInputParams_, latestResults);\n> -       aic_.updateRuntimeParams(latestResults);\n> -       aic_.run(params);\n>  \n>         exposure_ = latestResults.ae()->exposures[0].sensor_exposure->coarse_integration_time;\n>         gain_ = latestResults.ae()->exposures[0].sensor_exposure->analog_gain_code_global;\n> @@ -413,6 +398,29 @@ void IPAIPU3::fillParams(unsigned int frame, ipu3_uapi_params *params)\n>                 lensMovementStartTime_ = msecs;\n>         }\n>         lensPosition_ = latestResults.af()->next_lens_position;\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\nMinor: The indentation is wrong here, but it was in the original. Could\nbe fixed while applying.\n\nIf I can fix the apply issues from leaving the lens change out, I'll\nmerge this one too with the indentation fixed. It doesn't look like\nthere would be any trouble to fix this up now.\n\n\n\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> +       runAiq(frame);\n> +\n> +       aiq::AiqResults& latestResults = resultsHistory_.latest();\n> +       aic_.updateRuntimeParams(latestResults);\n> +       aic_.run(params);\n>  \n>         setControls(frame);\n>  \n> -- \n> 2.34.0.rc1.387.gb447b232ab-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 7B78ABF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 19 Nov 2021 16:39:58 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 8281D60371;\n\tFri, 19 Nov 2021 17:39:57 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 81517600B5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 19 Nov 2021 17:39:55 +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 DA9671C19;\n\tFri, 19 Nov 2021 17:39:54 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"TFlO6azX\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1637339994;\n\tbh=/gIsDzsI6xs8FJMMdES7bxacsXAdC0GlTdfE6yqqQyA=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=TFlO6azXrLPDkv9nhidt8ahn2o8QtC1LQAfNiiL//USsC1smUazplT+f9HNuc8m9Z\n\tpqs924uVxlmYu3gKX8lz8hSIS/L+r2W3YTFCQqh7sZ0/fwz60R0tU86wzbfT8P5EjR\n\toEgo0hR64kSuH9hXdqaLwCXSXmjoWp88bUJHe2HI=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20211111104908.295992-6-hanlinchen@chromium.org>","References":"<20211111104908.295992-1-hanlinchen@chromium.org>\n\t<20211111104908.295992-6-hanlinchen@chromium.org>","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","To":"Han-Lin Chen <hanlinchen@chromium.org>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Fri, 19 Nov 2021 16:39:53 +0000","Message-ID":"<163733999312.1089182.14964661939045703662@Monstersaurus>","User-Agent":"alot/0.10","Subject":"Re: [libcamera-devel] [IPU3-IPA PATCH v3 5/6] ipu3: Run AIQ for the\n\tfirst frame 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>"}}]