From patchwork Thu Nov 11 10:49:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hanlin Chen X-Patchwork-Id: 14550 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 6210EBDB1C for ; Thu, 11 Nov 2021 10:49:41 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 14CD760345; Thu, 11 Nov 2021 11:49:41 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="Qcp/FlbC"; dkim-atps=neutral Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B8E2760345 for ; Thu, 11 Nov 2021 11:49:39 +0100 (CET) Received: by mail-pj1-x102f.google.com with SMTP id p18-20020a17090ad31200b001a78bb52876so4109072pju.3 for ; Thu, 11 Nov 2021 02:49:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=C3gXGHepNdq76R5E/Cgv2uleOXsTZATDjAvBWpSPQLE=; b=Qcp/FlbCbiaOLXm1XbFNSV7gvEa71pIuKl4DXIBJvGIMVd0Jfyeb89y7bSTXQteALT uKT2wTzKtBV4lIQ+NeYghz/j0OI7bG3VakoiNJpizV18pCPNMWla93Ae+dqlvhN2kNVG uApEZGrmMfsDz1N7aru5HwOLm0x4lhQH7FEKI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=C3gXGHepNdq76R5E/Cgv2uleOXsTZATDjAvBWpSPQLE=; b=g/RLeBakrAmFvzXPB/GlNqmGvh2zdTC5LyP2O/BJGa6kfjUI0Cq930yXV3aR+JStSN hrycml+1fMgJh8sI9CUbc4oSUKSgRxQ+abaENymOpz5gf/6EKopvvFX3D/erJZzNExEq 8jY1sZTAIvMz0S3f8USF234BvolLUNnE+lXeEChIaP6qP5JEpYpgKt7x7YuGBDk7+aeC DwyOqWNtDcA85SLnjVnHWgPAE792EZ9liFxXwBclDjPI7j2MDrtxqWDMrCQUpINMel/y Gl4yU0FtjcRpQJ+fuwLLAUFFsbjrb69gZpLX5kYAguMDGR9Qc+Po78BVWqRpKJ4JZO3W /zpw== X-Gm-Message-State: AOAM532V+/YCnbkqu55uSJnMc+npiKQ79ZAOyQ1RaiFZlMU+G0FKWKy9 qMzABDYIEXc3nzPWnRWeaQz8CI+I+SnS7w== X-Google-Smtp-Source: ABdhPJyDw2xrwudaiNBEt+Mwc9VKGhN7BmiLc6de1F01yEzhREUZ+PCqBBOWtovlDV1VYRXCgeDcyQ== X-Received: by 2002:a17:902:b08a:b0:142:51be:57e2 with SMTP id p10-20020a170902b08a00b0014251be57e2mr6514684plr.53.1636627778137; Thu, 11 Nov 2021 02:49:38 -0800 (PST) Received: from localhost ([2401:fa00:1:10:3925:da9c:3049:be7a]) by smtp.gmail.com with UTF8SMTPSA id h18sm2868775pfh.172.2021.11.11.02.49.37 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 11 Nov 2021 02:49:37 -0800 (PST) From: Han-Lin Chen To: libcamera-devel@lists.libcamera.org Date: Thu, 11 Nov 2021 18:49:07 +0800 Message-Id: <20211111104908.295992-6-hanlinchen@chromium.org> X-Mailer: git-send-email 2.34.0.rc1.387.gb447b232ab-goog In-Reply-To: <20211111104908.295992-1-hanlinchen@chromium.org> References: <20211111104908.295992-1-hanlinchen@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [IPU3-IPA PATCH v3 5/6] ipu3: Run AIQ for the first frame to avoid blanking 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" The start() function set the first exposure time and analog gain to maximum. In result, the first frame might be over bright and the user may see a bright blank when changing the camera in application. Run AIQ to get an initial exposure time and analog gain in start() to smooth the AE process. Signed-off-by: Han-Lin Chen Reviewed-by: Kieran Bingham --- ipu3.cpp | 44 ++++++++++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/ipu3.cpp b/ipu3.cpp index f38440d..ffa78b3 100644 --- a/ipu3.cpp +++ b/ipu3.cpp @@ -56,6 +56,7 @@ private: const ControlInfoMap &sensorControls, ControlInfoMap *ipaControls); void processControls(unsigned int frame, const ControlList &metadata); + void runAiq(unsigned int frame); void fillParams(unsigned int frame, ipu3_uapi_params *params); void parseStatistics(unsigned int frame, int64_t frameTimestamp, @@ -220,6 +221,7 @@ int IPAIPU3::init(const IPASettings &settings, int IPAIPU3::start() { + runAiq(0); setControls(0); return 0; @@ -369,23 +371,8 @@ void IPAIPU3::processControls([[maybe_unused]] unsigned int frame, /* \todo Start processing for 'frame' based on 'controls'. */ } -void IPAIPU3::fillParams(unsigned int frame, ipu3_uapi_params *params) +void IPAIPU3::runAiq([[maybe_unused]] unsigned int frame) { - /* Prepare parameters buffer. */ - memset(params, 0, sizeof(*params)); - - /* - * Call into the AIQ object, and set up the library with any requested - * controls or settings from the incoming request. - * - * (statistics are fed into the library as a separate event - * when available) - * - * - Run algorithms - * - * - Fill params buffer with the results of the algorithms. - */ - /* Run algorithms into/using this context structure */ resultsHistory_.extendOne(); aiq::AiqResults& latestResults = resultsHistory_.latest(); @@ -395,8 +382,6 @@ void IPAIPU3::fillParams(unsigned int frame, ipu3_uapi_params *params) aiqInputParams_.afParams.lens_movement_start_timestamp = lensMovementStartTime_; aiq_.run2a(frame, aiqInputParams_, latestResults); - aic_.updateRuntimeParams(latestResults); - aic_.run(params); exposure_ = latestResults.ae()->exposures[0].sensor_exposure->coarse_integration_time; gain_ = latestResults.ae()->exposures[0].sensor_exposure->analog_gain_code_global; @@ -413,6 +398,29 @@ void IPAIPU3::fillParams(unsigned int frame, ipu3_uapi_params *params) lensMovementStartTime_ = msecs; } lensPosition_ = latestResults.af()->next_lens_position; +} + +void IPAIPU3::fillParams(unsigned int frame, ipu3_uapi_params *params) +{ + /* Prepare parameters buffer. */ + memset(params, 0, sizeof(*params)); + + /* + * Call into the AIQ object, and set up the library with any requested + * controls or settings from the incoming request. + * + * (statistics are fed into the library as a separate event + * when available) + * + * - Run algorithms + * + * - Fill params buffer with the results of the algorithms. + */ + runAiq(frame); + + aiq::AiqResults& latestResults = resultsHistory_.latest(); + aic_.updateRuntimeParams(latestResults); + aic_.run(params); setControls(frame);