From patchwork Thu Nov 11 10:49:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hanlin Chen X-Patchwork-Id: 14549 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 B50D4BDB1C for ; Thu, 11 Nov 2021 10:49:38 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 6BC1D6036E; Thu, 11 Nov 2021 11:49:38 +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="KBwXN/cT"; dkim-atps=neutral Received: from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com [IPv6:2607:f8b0:4864:20::1032]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 9415C6035A for ; Thu, 11 Nov 2021 11:49:37 +0100 (CET) Received: by mail-pj1-x1032.google.com with SMTP id t5-20020a17090a4e4500b001a0a284fcc2so4305712pjl.2 for ; Thu, 11 Nov 2021 02:49:37 -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=wzmpKQs8eEkuk068oAnuEEo9voqG/Kew3C+UC0uQZpQ=; b=KBwXN/cTpoyYsOHIOkcTrX1I65JNVK0i+mZgRNZQPwMkX5g0kxsaQg/1JfMCkVsm32 nKDlJM1PSMq7et4mTqSGodl6pWftWant4mrXlR+ZjBgiKoCst8T3VumINi10K8IJyje6 dKJqZ+cvZSPmsTKMIDU0QhRhoME1L/hIn5o8Y= 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=wzmpKQs8eEkuk068oAnuEEo9voqG/Kew3C+UC0uQZpQ=; b=eICTRAJZ3spIK09x7LbJmjnm4kJr69UN5j2S0ERxnEhUmg2FAwqL/urcgRfYvh+tw8 ThhE+S+9yFAga0VPNsfnFr2c5wLpdROzmuuutGCIpplWnUmoTgiYK8MpaWmhwgEkZccm kAf8yhOpqAZ/3Ku12HFlKmA//AwQzgUM3rPxSLqUzWLxA5E69ULOoNUYxnu65rJloOWg 0922mXFuT2gw7fMBNvBkkgLBhU4lNs3c9YBLUkh8Q8JFek3fW96pPIre+2q7aaY/OWr8 Ty9JQhTjfkwt5U5w1lCvCqCwmwctvDLSGA8VZiZiVswgd8bCP5uMocPkqOxdYtf1H5pL U0mQ== X-Gm-Message-State: AOAM533ACAg5RdFjDx8RA/bjZksY5LZ7Qf9OeA+vhg3Ndof96BxRDNA/ pObpPW1pLwhXO1WprMwH4rcqeTAyXacZdw== X-Google-Smtp-Source: ABdhPJxqX5tGYOGr8pCL272EXzO9Zi99GecQdQzM1X/BPB8/FX6XRGcLEuq73XQPcgLspXT4kKqFvw== X-Received: by 2002:a17:90b:3848:: with SMTP id nl8mr24802999pjb.221.1636627775955; Thu, 11 Nov 2021 02:49:35 -0800 (PST) Received: from localhost ([2401:fa00:1:10:3925:da9c:3049:be7a]) by smtp.gmail.com with UTF8SMTPSA id f3sm2689644pfg.167.2021.11.11.02.49.35 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 11 Nov 2021 02:49:35 -0800 (PST) From: Han-Lin Chen To: libcamera-devel@lists.libcamera.org Date: Thu, 11 Nov 2021 18:49:06 +0800 Message-Id: <20211111104908.295992-5-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 4/6] ipu3: Apply auto focus and send lens controls to pipeline handler 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" Apply auto focus and send lens controls to pipeline handler. Signed-off-by: Han-Lin Chen Reviewed-by: Kieran Bingham --- aiq/aiq.cpp | 3 +-- aiq/aiq.h | 4 +--- aiq/aiq_input_parameters.cpp | 2 +- ipu3.cpp | 26 ++++++++++++++++++++++++++ 4 files changed, 29 insertions(+), 6 deletions(-) diff --git a/aiq/aiq.cpp b/aiq/aiq.cpp index 24c61cb..52a9c07 100644 --- a/aiq/aiq.cpp +++ b/aiq/aiq.cpp @@ -138,8 +138,7 @@ int AIQ::setStatistics(unsigned int frame, * might run asycnronously, or after receipt of statistics, with the filling * of the parameter buffer being the only part handled when called for. */ -int AIQ::run2a(unsigned int frame, AiqInputParameters ¶ms, - AiqResults &results) +int AIQ::run2a(unsigned int frame, AiqInputParameters ¶ms, AiqResults &results) { (void)frame; diff --git a/aiq/aiq.h b/aiq/aiq.h index fcd02d2..49eee2d 100644 --- a/aiq/aiq.h +++ b/aiq/aiq.h @@ -39,9 +39,7 @@ public: int setStatistics(unsigned int frame, int64_t timestamp, AiqResults &results, const ipu3_uapi_stats_3a *stats); - - int run2a(unsigned int frame, AiqInputParameters ¶ms, - AiqResults &results); + int run2a(unsigned int frame, AiqInputParameters ¶ms, AiqResults &results); private: std::string decodeError(ia_err err); diff --git a/aiq/aiq_input_parameters.cpp b/aiq/aiq_input_parameters.cpp index 46553a6..5dd2f6c 100644 --- a/aiq/aiq_input_parameters.cpp +++ b/aiq/aiq_input_parameters.cpp @@ -166,7 +166,7 @@ void AiqInputParameters::setAeAwbAfDefaults() ia_aiq_af_range_normal, ia_aiq_af_metering_mode_auto, ia_aiq_flash_mode_off, - NULL, NULL, false + &focusRect, &manualFocusParams, false }; /* GBCE Params */ diff --git a/ipu3.cpp b/ipu3.cpp index 9d07268..f38440d 100644 --- a/ipu3.cpp +++ b/ipu3.cpp @@ -77,6 +77,10 @@ private: uint32_t gain_; uint32_t minGain_; uint32_t maxGain_; + int32_t lensPosition_; + + /* Intel AF library relies on timestamp to wait for lens movement */ + uint64_t lensMovementStartTime_; /* Intel Library Instances. */ aiq::AIQ aiq_; @@ -257,6 +261,9 @@ int IPAIPU3::configure(const IPAConfigInfo &configInfo, maxGain_ = itGain->second.max().get(); gain_ = maxGain_; + lensMovementStartTime_ = 0; + lensPosition_ = 0; + int ret; ret = aiq_.configure(); @@ -383,6 +390,10 @@ void IPAIPU3::fillParams(unsigned int frame, ipu3_uapi_params *params) resultsHistory_.extendOne(); aiq::AiqResults& latestResults = resultsHistory_.latest(); + /* Todo: Refactor AiqInputParameters interface to set following parameters. */ + aiqInputParams_.afParams.lens_position = lensPosition_; + aiqInputParams_.afParams.lens_movement_start_timestamp = lensMovementStartTime_; + aiq_.run2a(frame, aiqInputParams_, latestResults); aic_.updateRuntimeParams(latestResults); aic_.run(params); @@ -390,6 +401,19 @@ void IPAIPU3::fillParams(unsigned int frame, ipu3_uapi_params *params) exposure_ = latestResults.ae()->exposures[0].sensor_exposure->coarse_integration_time; gain_ = latestResults.ae()->exposures[0].sensor_exposure->analog_gain_code_global; + /* + * Af algorithm compares the timestamp of start of lens movement and the + * that of the statistics generated to estimate whether next lens + * positon should be produced. + * Todo: Use the lens movement start time reported by the pipeline handler. + */ + if (lensPosition_ != latestResults.af()->next_lens_position) { + utils::time_point time = utils::clock::now(); + uint64_t msecs = std::chrono::duration_cast(time.time_since_epoch()).count(); + lensMovementStartTime_ = msecs; + } + lensPosition_ = latestResults.af()->next_lens_position; + setControls(frame); IPU3Action op; @@ -473,6 +497,8 @@ void IPAIPU3::setControls(unsigned int frame) op.sensorControls = sensorCtrls; + op.lensControls.set(V4L2_CID_FOCUS_ABSOLUTE, lensPosition_); + queueFrameAction.emit(frame, op); }