{"id":14549,"url":"https://patchwork.libcamera.org/api/patches/14549/?format=json","web_url":"https://patchwork.libcamera.org/patch/14549/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20211111104908.295992-5-hanlinchen@chromium.org>","date":"2021-11-11T10:49:06","name":"[libcamera-devel,IPU3-IPA,v3,4/6] ipu3: Apply auto focus and send lens controls to pipeline handler","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"162875ec5bd38874229af9d08f9972fe86053c4d","submitter":{"id":98,"url":"https://patchwork.libcamera.org/api/people/98/?format=json","name":"Hanlin Chen","email":"hanlinchen@chromium.org"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/14549/mbox/","series":[{"id":2711,"url":"https://patchwork.libcamera.org/api/series/2711/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2711","date":"2021-11-11T10:49:02","name":"*** Enhance image quality for IPU3 with Intel IPA ***","version":3,"mbox":"https://patchwork.libcamera.org/series/2711/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/14549/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/14549/checks/","tags":{},"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 B50D4BDB1C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 11 Nov 2021 10:49:38 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 6BC1D6036E;\n\tThu, 11 Nov 2021 11:49:38 +0100 (CET)","from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com\n\t[IPv6:2607:f8b0:4864:20::1032])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 9415C6035A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 11 Nov 2021 11:49:37 +0100 (CET)","by mail-pj1-x1032.google.com with SMTP id\n\tt5-20020a17090a4e4500b001a0a284fcc2so4305712pjl.2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 11 Nov 2021 02:49:37 -0800 (PST)","from localhost ([2401:fa00:1:10:3925:da9c:3049:be7a])\n\tby smtp.gmail.com with UTF8SMTPSA id\n\tf3sm2689644pfg.167.2021.11.11.02.49.35\n\t(version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);\n\tThu, 11 Nov 2021 02:49:35 -0800 (PST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=chromium.org header.i=@chromium.org\n\theader.b=\"KBwXN/cT\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org;\n\ts=google; \n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=wzmpKQs8eEkuk068oAnuEEo9voqG/Kew3C+UC0uQZpQ=;\n\tb=KBwXN/cTpoyYsOHIOkcTrX1I65JNVK0i+mZgRNZQPwMkX5g0kxsaQg/1JfMCkVsm32\n\tnKDlJM1PSMq7et4mTqSGodl6pWftWant4mrXlR+ZjBgiKoCst8T3VumINi10K8IJyje6\n\tdKJqZ+cvZSPmsTKMIDU0QhRhoME1L/hIn5o8Y=","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references:mime-version:content-transfer-encoding;\n\tbh=wzmpKQs8eEkuk068oAnuEEo9voqG/Kew3C+UC0uQZpQ=;\n\tb=eICTRAJZ3spIK09x7LbJmjnm4kJr69UN5j2S0ERxnEhUmg2FAwqL/urcgRfYvh+tw8\n\tThhE+S+9yFAga0VPNsfnFr2c5wLpdROzmuuutGCIpplWnUmoTgiYK8MpaWmhwgEkZccm\n\tkAf8yhOpqAZ/3Ku12HFlKmA//AwQzgUM3rPxSLqUzWLxA5E69ULOoNUYxnu65rJloOWg\n\t0922mXFuT2gw7fMBNvBkkgLBhU4lNs3c9YBLUkh8Q8JFek3fW96pPIre+2q7aaY/OWr8\n\tTy9JQhTjfkwt5U5w1lCvCqCwmwctvDLSGA8VZiZiVswgd8bCP5uMocPkqOxdYtf1H5pL\n\tU0mQ==","X-Gm-Message-State":"AOAM533ACAg5RdFjDx8RA/bjZksY5LZ7Qf9OeA+vhg3Ndof96BxRDNA/\n\tpObpPW1pLwhXO1WprMwH4rcqeTAyXacZdw==","X-Google-Smtp-Source":"ABdhPJxqX5tGYOGr8pCL272EXzO9Zi99GecQdQzM1X/BPB8/FX6XRGcLEuq73XQPcgLspXT4kKqFvw==","X-Received":"by 2002:a17:90b:3848:: with SMTP id\n\tnl8mr24802999pjb.221.1636627775955; \n\tThu, 11 Nov 2021 02:49:35 -0800 (PST)","From":"Han-Lin Chen <hanlinchen@chromium.org>","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","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [IPU3-IPA PATCH v3 4/6] ipu3: Apply auto focus\n\tand send lens controls to pipeline handler","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>"},"content":"Apply auto focus and send lens controls to pipeline handler.\n\nSigned-off-by: Han-Lin Chen <hanlinchen@chromium.org>\n---\n aiq/aiq.cpp                  |  3 +--\n aiq/aiq.h                    |  4 +---\n aiq/aiq_input_parameters.cpp |  2 +-\n ipu3.cpp                     | 26 ++++++++++++++++++++++++++\n 4 files changed, 29 insertions(+), 6 deletions(-)","diff":"diff --git a/aiq/aiq.cpp b/aiq/aiq.cpp\nindex 24c61cb..52a9c07 100644\n--- a/aiq/aiq.cpp\n+++ b/aiq/aiq.cpp\n@@ -138,8 +138,7 @@ int AIQ::setStatistics(unsigned int frame,\n  * might run asycnronously, or after receipt of statistics, with the filling\n  * of the parameter buffer being the only part handled when called for.\n  */\n-int AIQ::run2a(unsigned int frame, AiqInputParameters &params,\n-\t       AiqResults &results)\n+int AIQ::run2a(unsigned int frame, AiqInputParameters &params, AiqResults &results)\n {\n \t(void)frame;\n \ndiff --git a/aiq/aiq.h b/aiq/aiq.h\nindex fcd02d2..49eee2d 100644\n--- a/aiq/aiq.h\n+++ b/aiq/aiq.h\n@@ -39,9 +39,7 @@ public:\n \tint setStatistics(unsigned int frame,\n \t\t\t  int64_t timestamp, AiqResults &results,\n \t\t\t  const ipu3_uapi_stats_3a *stats);\n-\n-\tint run2a(unsigned int frame, AiqInputParameters &params,\n-\t\t  AiqResults &results);\n+\tint run2a(unsigned int frame, AiqInputParameters &params, AiqResults &results);\n \n private:\n \tstd::string decodeError(ia_err err);\ndiff --git a/aiq/aiq_input_parameters.cpp b/aiq/aiq_input_parameters.cpp\nindex 46553a6..5dd2f6c 100644\n--- a/aiq/aiq_input_parameters.cpp\n+++ b/aiq/aiq_input_parameters.cpp\n@@ -166,7 +166,7 @@ void AiqInputParameters::setAeAwbAfDefaults()\n \t\tia_aiq_af_range_normal,\n \t\tia_aiq_af_metering_mode_auto,\n \t\tia_aiq_flash_mode_off,\n-\t\tNULL, NULL, false\n+\t\t&focusRect, &manualFocusParams, false\n \t};\n \n \t/* GBCE Params */\ndiff --git a/ipu3.cpp b/ipu3.cpp\nindex 9d07268..f38440d 100644\n--- a/ipu3.cpp\n+++ b/ipu3.cpp\n@@ -77,6 +77,10 @@ private:\n \tuint32_t gain_;\n \tuint32_t minGain_;\n \tuint32_t maxGain_;\n+\tint32_t lensPosition_;\n+\n+\t/* Intel AF library relies on timestamp to wait for lens movement */\n+\tuint64_t lensMovementStartTime_;\n \n \t/* Intel Library Instances. */\n \taiq::AIQ aiq_;\n@@ -257,6 +261,9 @@ int IPAIPU3::configure(const IPAConfigInfo &configInfo,\n \tmaxGain_ = itGain->second.max().get<int32_t>();\n \tgain_ = maxGain_;\n \n+\tlensMovementStartTime_ = 0;\n+\tlensPosition_ = 0;\n+\n \tint ret;\n \n \tret = aiq_.configure();\n@@ -383,6 +390,10 @@ void IPAIPU3::fillParams(unsigned int frame, ipu3_uapi_params *params)\n \tresultsHistory_.extendOne();\n \taiq::AiqResults& latestResults = resultsHistory_.latest();\n \n+\t/* Todo: Refactor AiqInputParameters interface to set following parameters. */\n+\taiqInputParams_.afParams.lens_position = lensPosition_;\n+\taiqInputParams_.afParams.lens_movement_start_timestamp = lensMovementStartTime_;\n+\n \taiq_.run2a(frame, aiqInputParams_, latestResults);\n \taic_.updateRuntimeParams(latestResults);\n \taic_.run(params);\n@@ -390,6 +401,19 @@ void IPAIPU3::fillParams(unsigned int frame, ipu3_uapi_params *params)\n \texposure_ = latestResults.ae()->exposures[0].sensor_exposure->coarse_integration_time;\n \tgain_ = latestResults.ae()->exposures[0].sensor_exposure->analog_gain_code_global;\n \n+\t/*\n+\t * Af algorithm compares the timestamp of start of lens movement and the\n+\t * that of the statistics generated to estimate whether next lens\n+\t * positon should be produced.\n+\t * Todo: Use the lens movement start time reported by the pipeline handler.\n+\t */\n+\tif (lensPosition_ != latestResults.af()->next_lens_position) {\n+\t\tutils::time_point time = utils::clock::now();\n+\t\tuint64_t msecs = std::chrono::duration_cast<std::chrono::microseconds>(time.time_since_epoch()).count();\n+\t\tlensMovementStartTime_ = msecs;\n+\t}\n+\tlensPosition_ = latestResults.af()->next_lens_position;\n+\n \tsetControls(frame);\n \n \tIPU3Action op;\n@@ -473,6 +497,8 @@ void IPAIPU3::setControls(unsigned int frame)\n \n \top.sensorControls = sensorCtrls;\n \n+\top.lensControls.set(V4L2_CID_FOCUS_ABSOLUTE, lensPosition_);\n+\n \tqueueFrameAction.emit(frame, op);\n }\n \n","prefixes":["libcamera-devel","IPU3-IPA","v3","4/6"]}