{"id":14709,"url":"https://patchwork.libcamera.org/api/1.1/patches/14709/?format=json","web_url":"https://patchwork.libcamera.org/patch/14709/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/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":"<20211123123901.3199595-1-hanlinchen@chromium.org>","date":"2021-11-23T12:39:01","name":"[libcamera-devel,IPU3-IPA,v4] ipu3: Apply auto focus and send lens controls to pipeline handler","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"9d44a46815664be129bfd640a318cbdc24891787","submitter":{"id":98,"url":"https://patchwork.libcamera.org/api/1.1/people/98/?format=json","name":"Hanlin Chen","email":"hanlinchen@chromium.org"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/14709/mbox/","series":[{"id":2744,"url":"https://patchwork.libcamera.org/api/1.1/series/2744/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2744","date":"2021-11-23T12:39:01","name":"[libcamera-devel,IPU3-IPA,v4] ipu3: Apply auto focus and send lens controls to pipeline handler","version":4,"mbox":"https://patchwork.libcamera.org/series/2744/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/14709/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/14709/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 1F89EBF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 23 Nov 2021 12:39:10 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id C972460230;\n\tTue, 23 Nov 2021 13:39:09 +0100 (CET)","from mail-pg1-x52e.google.com (mail-pg1-x52e.google.com\n\t[IPv6:2607:f8b0:4864:20::52e])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 58D4E60121\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 23 Nov 2021 13:39:08 +0100 (CET)","by mail-pg1-x52e.google.com with SMTP id l190so7644681pge.7\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 23 Nov 2021 04:39:08 -0800 (PST)","from localhost ([2401:fa00:1:10:8aa3:febd:fadf:4199])\n\tby smtp.gmail.com with UTF8SMTPSA id\n\tne7sm1129281pjb.36.2021.11.23.04.39.05\n\t(version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);\n\tTue, 23 Nov 2021 04:39:06 -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=\"gy1wSt4b\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org;\n\ts=google; h=from:to:cc:subject:date:message-id:mime-version\n\t:content-transfer-encoding;\n\tbh=8v+u3e3qxxMvRsqtoHhaCV8i88G5oSYNJK31y0Kurts=;\n\tb=gy1wSt4bRvrSSw20XwwLvuOtyIEy55tC8NOtBSANWsKA4HyyfHW8vQLxpbCXWA46zd\n\tmOAbQnh4HheIqTv5QhN/XxCYwq3cx5cXrbTia9O5WLSp8Dy/8BgVOTTlTgM98o++lHrY\n\t5Ln94Q5ug4k7rfr7YExCDBPx7SY3UAqjDjLHk=","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:mime-version\n\t:content-transfer-encoding;\n\tbh=8v+u3e3qxxMvRsqtoHhaCV8i88G5oSYNJK31y0Kurts=;\n\tb=gb3+TpxbpjjfkLSvepbjDIouBsfJtrDhWsEK7A+fGpBDhplGAvz6atunw96rq5O0PY\n\tbTrp9U5BF97u95P0DayJeySyrXCQMdkXGGZrC07ZKr12H/RjMi0Boj5p6qs1Ce1H1f1l\n\t+UPTi/LmmkXzzHPG40NiEq0lEcFIUOA4d3BQwCRaAG4QCGGBV0zbWLu6pp11i/z7Oy71\n\tyvktcXqvBA/r2hjQJ4nDNDlTjyKmZeOj6CnCz0T8o1dfHsmluuzWpE6hegAPwNQllQZx\n\tBVAvF5Qtn9tzyXEq4EIABVwUtEl1Wq0CIMyA9/T5tp7WLrZocCfsmdcQt20/c18dTq/e\n\t9m+w==","X-Gm-Message-State":"AOAM533KOpc2tJZnxAUnmuqfzHIwNhYKTbVLEJCCPkWhG3R7XmOp7eFy\n\tIAhWbUKL0TCQGNDR0WaOIrSBzmQaA1ayog==","X-Google-Smtp-Source":"ABdhPJyZqpoXhhHFSyfXU6ViBsQZktedfW+MiQ3oOBfBbfdjC37NKjtMs6HBb4pAT4lZqeHHJw6wDQ==","X-Received":"by 2002:a05:6a00:216f:b0:49f:dcb7:2bf2 with SMTP id\n\tr15-20020a056a00216f00b0049fdcb72bf2mr4652228pff.19.1637671146507; \n\tTue, 23 Nov 2021 04:39:06 -0800 (PST)","From":"Han-Lin Chen <hanlinchen@chromium.org>","To":"libcamera-devel@lists.libcamera.org","Date":"Tue, 23 Nov 2021 20:39:01 +0800","Message-Id":"<20211123123901.3199595-1-hanlinchen@chromium.org>","X-Mailer":"git-send-email 2.34.0.rc2.393.gf8c9666880-goog","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [IPU3-IPA PATCH v4] ipu3: Apply auto focus and\n\tsend 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                     | 25 +++++++++++++++++++++++++\n 4 files changed, 28 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 8f60d14..7a6a1fa 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 e2b5710..1a14556 100644\n--- a/ipu3.cpp\n+++ b/ipu3.cpp\n@@ -78,6 +78,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@@ -259,6 +263,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@@ -370,11 +377,27 @@ void IPAIPU3::runAiq([[maybe_unused]] unsigned int frame)\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 \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 * position 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 usecs = std::chrono::duration_cast<std::chrono::microseconds>(time.time_since_epoch()).count();\n+\t\tlensMovementStartTime_ = usecs;\n+\t}\n+\tlensPosition_ = latestResults.af()->next_lens_position;\n }\n \n void IPAIPU3::fillParams(unsigned int frame, ipu3_uapi_params *params)\n@@ -483,6 +506,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","v4"]}