From patchwork Thu Oct 28 10:03:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hanlin Chen X-Patchwork-Id: 14394 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 27D18BF415 for ; Thu, 28 Oct 2021 10:04:03 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id CEC4F600B7; Thu, 28 Oct 2021 12:04:02 +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="RCEyaZcJ"; dkim-atps=neutral Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A223060103 for ; Thu, 28 Oct 2021 12:04:01 +0200 (CEST) Received: by mail-pj1-x102e.google.com with SMTP id ls14-20020a17090b350e00b001a00e2251c8so4262436pjb.4 for ; Thu, 28 Oct 2021 03:04:01 -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=P3cm+inl+EbpNn0pZqEsFguD4IKuCQYqm6q/3QvYvJM=; b=RCEyaZcJuxc2HJeD2iYL/xcrX4AoMuxxTSmseoskvhRhGhKDs5l/kOY8pvLBb9IZ7t lNwDm8Q9Njf3QfMl9sejBkLKMXJ/jU7r5uMbH15SN8ZBOqXgPKiLY9zJyywnXiXnT6VT Z541rfGCgbQeFhTRdi0J8xwKooK7xQF+QPOnc= 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=P3cm+inl+EbpNn0pZqEsFguD4IKuCQYqm6q/3QvYvJM=; b=NALDRLyLaiDv0ltghMeBUQJWQ7G2MEfl8+B/75w6dybKchNIDULU0xvsHtA7ECdkf7 Eprzn91EWo7CmDhCTYKbflB3helQ1uYz+mutMAjg/yYKo0tLwEKLYFQjolLVTDqRSYRW SB6qEk3i0KptUTe4PmZeVnG+2ipXdkDVQ+Sso5Pl+Pf5C6d5xqAduCWLx2vU33EmDpTr C37HQoapzq7yyVzUoqBSDVPIQg8uCowumNjb06Ywp50BALgw+GUoAqq57hNlDgiQH5ug QIJhHOLnkHqbdcngZEmjEBT/T/6gHgVAF3Q7V6uMj1Rg8CQeKXAI7K4XtElhg5aI5E4G z5sg== X-Gm-Message-State: AOAM533xNWmcjkUAWf+MPCmKc3WosePhz/HuEVNREWkFWBtCs7tyRV1q L+jVDACK0JEixcjuPl9Mk1iqoj0xYsutbFOr X-Google-Smtp-Source: ABdhPJw4rttndHgwG19pXE7nXiP5kg1yxoA4jUuO07+sXNXzFOdVTLpVf3z6cPInDJOxlsv0MHBW8A== X-Received: by 2002:a17:90a:6b0a:: with SMTP id v10mr11703821pjj.130.1635415440045; Thu, 28 Oct 2021 03:04:00 -0700 (PDT) Received: from localhost ([2401:fa00:1:10:1bc:52e7:6df5:c7cf]) by smtp.gmail.com with UTF8SMTPSA id g25sm2815924pfh.216.2021.10.28.03.03.59 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 28 Oct 2021 03:03:59 -0700 (PDT) From: Han-Lin Chen To: libcamera-devel@lists.libcamera.org Date: Thu, 28 Oct 2021 18:03:48 +0800 Message-Id: <20211028100349.1098545-5-hanlinchen@chromium.org> X-Mailer: git-send-email 2.33.1.1089.g2158813163f-goog In-Reply-To: <20211028100349.1098545-1-hanlinchen@chromium.org> References: <20211028100349.1098545-1-hanlinchen@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 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: , Cc: Han-Lin Chen 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 --- ipu3.cpp | 45 ++++++++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/ipu3.cpp b/ipu3.cpp index 45330ca..b124301 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);