From patchwork Fri Oct 29 12:00:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hanlin Chen X-Patchwork-Id: 14421 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 B5134BDB1C for ; Fri, 29 Oct 2021 12:00:17 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 71368600C4; Fri, 29 Oct 2021 14:00:17 +0200 (CEST) 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="d9+o9rDf"; dkim-atps=neutral Received: from mail-pg1-x52b.google.com (mail-pg1-x52b.google.com [IPv6:2607:f8b0:4864:20::52b]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 384CA600B8 for ; Fri, 29 Oct 2021 14:00:15 +0200 (CEST) Received: by mail-pg1-x52b.google.com with SMTP id f5so9651646pgc.12 for ; Fri, 29 Oct 2021 05:00:15 -0700 (PDT) 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=JIW54wwtEbmae2rJT2JySJLiLDfh8qO7VcEWNSqs6/M=; b=d9+o9rDfXPduJSFS+4RJsy16BxJxk2RjT9c48uTBBWYS1v2PHmf7tqlw0NT/hRJCkR t6GrzbQSguV5Z/OuflsyBX0N7gOBrmANF/iohpCW2tjqHF01M8WyaoLVQHXbAlwiKX3K rd5t9oaLh0iZXy7+mvDINx/mb6YEXqCH3Ll7Y= 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=JIW54wwtEbmae2rJT2JySJLiLDfh8qO7VcEWNSqs6/M=; b=Yq8SMjP3d6MIyBSGEIfOt1hRMZIICCsYJKXPLpGOMn4yQiJl2ItcQm12zqroTc94Yf J+4R041qR6Rd+V5VDrHHuox06kLm4dKMx1xQglk5OTi0mdwTzL1U8u8T97aQmWIQcH5x li6E0ca81eVJhCe8MssY6tjKflX5swV3W6lCa+8AiMjvR2n4sDc8hK8s66yWyr0/iLNc XsDaxTk+AjTgn9QXeAARjBN5Sokzvvn0qtZZGU3bElu8eB/eqdKEAox6525jhvPp6XB1 ZVEoaP8Je9eaXvqkrVXQg+GYoKuTIDjOJFhG6GvNibzjxoP8EoCnWbbNnsfSDl6MCN+b jLgQ== X-Gm-Message-State: AOAM533lt/QD8zn9NPuu6m50as1tF3fw5xSnhgXEH6fo9OV1Lu3ylxqL tV8hR4ncGMqYHkya7jw2PtNgEnU76nfow0La X-Google-Smtp-Source: ABdhPJy2QrjFQY3GcLHjq6Zl7E24fYjqNvo08F6ZrpAVq5zsK0zC8zGY01zV6GNKV527xts5iRBkfQ== X-Received: by 2002:a05:6a00:23d5:b0:47c:236d:65b4 with SMTP id g21-20020a056a0023d500b0047c236d65b4mr10297906pfc.52.1635508813340; Fri, 29 Oct 2021 05:00:13 -0700 (PDT) Received: from localhost ([2401:fa00:1:10:35fe:d53b:684:b538]) by smtp.gmail.com with UTF8SMTPSA id v2sm5516063pga.57.2021.10.29.05.00.12 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 29 Oct 2021 05:00:13 -0700 (PDT) From: Han-Lin Chen To: libcamera-devel@lists.libcamera.org Date: Fri, 29 Oct 2021 20:00:00 +0800 Message-Id: <20211029120001.2469018-5-hanlinchen@chromium.org> X-Mailer: git-send-email 2.33.1.1089.g2158813163f-goog In-Reply-To: <20211029120001.2469018-1-hanlinchen@chromium.org> References: <20211029120001.2469018-1-hanlinchen@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 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 | 45 ++++++++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/ipu3.cpp b/ipu3.cpp index c2dc754..2232e07 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, @@ -221,6 +222,7 @@ int IPAIPU3::init(const IPASettings &settings, int IPAIPU3::start() { + runAiq(0); setControls(0); return 0; @@ -370,29 +372,11 @@ 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(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 */ aiq_.run2a(frame, aiqInputParams_, results_, lensPosition_, lensMovementStartTime_); - aic_.updateRuntimeParams(results_); - aic_.run(params); - exposure_ = results_.ae()->exposures[0].sensor_exposure->coarse_integration_time; gain_ = results_.ae()->exposures[0].sensor_exposure->analog_gain_code_global; @@ -410,6 +394,29 @@ void IPAIPU3::fillParams(unsigned int frame, ipu3_uapi_params *params) lensPosition_ = results_.af()->next_lens_position; resultsHistory_.Push(results_); +} + +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); + + aic_.updateRuntimeParams(results_); + aic_.run(params); setControls(frame);