Show a patch.

GET /api/patches/14393/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 14393,
    "url": "https://patchwork.libcamera.org/api/patches/14393/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/14393/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/projects/1/?format=api",
        "name": "libcamera",
        "link_name": "libcamera",
        "list_id": "libcamera_core",
        "list_email": "libcamera-devel@lists.libcamera.org",
        "web_url": "",
        "scm_url": "",
        "webscm_url": ""
    },
    "msgid": "<20211028100349.1098545-4-hanlinchen@chromium.org>",
    "date": "2021-10-28T10:03:47",
    "name": "[libcamera-devel,4/6] ipu3: Apply auto focus and send lens controls to pipeline handler",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "b90a97b0580fa8b6d9eabc2501353417c305581e",
    "submitter": {
        "id": 98,
        "url": "https://patchwork.libcamera.org/api/people/98/?format=api",
        "name": "Hanlin Chen",
        "email": "hanlinchen@chromium.org"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/14393/mbox/",
    "series": [
        {
            "id": 2673,
            "url": "https://patchwork.libcamera.org/api/series/2673/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2673",
            "date": "2021-10-28T10:03:44",
            "name": "[libcamera-devel,1/6] ipu3: Use ia_aiq_frame_use_preview as default mode for AIQ",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/2673/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/14393/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/14393/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 28197BF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 28 Oct 2021 10:04:01 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id D32E3600F9;\n\tThu, 28 Oct 2021 12:04:00 +0200 (CEST)",
            "from mail-pf1-x42a.google.com (mail-pf1-x42a.google.com\n\t[IPv6:2607:f8b0:4864:20::42a])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 9C60C600B5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 28 Oct 2021 12:03:59 +0200 (CEST)",
            "by mail-pf1-x42a.google.com with SMTP id b1so1952581pfm.6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 28 Oct 2021 03:03:59 -0700 (PDT)",
            "from localhost ([2401:fa00:1:10:1bc:52e7:6df5:c7cf])\n\tby smtp.gmail.com with UTF8SMTPSA id\n\tn29sm2828130pfv.77.2021.10.28.03.03.57\n\t(version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);\n\tThu, 28 Oct 2021 03:03:57 -0700 (PDT)"
        ],
        "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=\"DawF9SR1\"; 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=fhWHJGT3GiHqLhE5ItshH8KqbE/k12uuErESYkJGWwE=;\n\tb=DawF9SR1Kv+BOseHJDO6haf90BJE/FdLX7dR9kBtcK3i1Oi2PSi9ouSbTI84yh1MQo\n\tmNtq5gPwluaTT2Z7bldvWrrZqMoedU/h06BaV6UVQXdDrcdoGdCAFEyqrizNmSnEVPVS\n\txBpDC7VBmskPc+WbUZuiCxCQ4yopjTN8wNtX8=",
        "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=fhWHJGT3GiHqLhE5ItshH8KqbE/k12uuErESYkJGWwE=;\n\tb=cqBKt0bMJ2uvKxi0R2QIIe+C3l3cpUVTqXg5J0Oik1m/I7ViTLESRWbGJBhLxkdvvj\n\tQyrQENvJqK9attkyYK4QYj7J2KEbpjL32CCmfEmal8AEX34aAis5SCJ7bUKORcI7I3U/\n\tMZoOuFcaafyICnX5DXv12GR8r0wOpmNt2yqWdHRlwqpBf7DB2oe/tjwwYWj24fErvatW\n\tkQs1UomDg+dwwdYJBYFTHE6D0ZhD7icRzmzUNWMwKidwYSK86YErHenCNCqmyMfmOsOj\n\t/TmE5uHLf7s2j3IayWk80karbbg2GBnoJpE05zuLavd2M/wA2CeIozHUPqt6HZujrQDG\n\tnmtg==",
        "X-Gm-Message-State": "AOAM533i6hUvchZE3E9tvXTgeILZE8vJFOYUqW5jyKQBWz8trvhQXbJD\n\tTHtGR5bR678qkPQN0I/B068nfBZleDQCWleU",
        "X-Google-Smtp-Source": "ABdhPJyp5qEJIh5nARascfiR0RaeU66nsXtfcKsywe2gtwI5pb7PpSJO0JuKxS5p/YMIy5FFxuFWCA==",
        "X-Received": "by 2002:a05:6a00:2181:b0:44d:c18d:7af9 with SMTP id\n\th1-20020a056a00218100b0044dc18d7af9mr3225357pfi.16.1635415437984; \n\tThu, 28 Oct 2021 03:03:57 -0700 (PDT)",
        "From": "Han-Lin Chen <hanlinchen@chromium.org>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Thu, 28 Oct 2021 18:03:47 +0800",
        "Message-Id": "<20211028100349.1098545-4-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",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH 4/6] ipu3: Apply auto focus and send lens\n\tcontrols 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>",
        "Cc": "Han-Lin Chen <hanlinchen@chromium.com>",
        "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.com>\n---\n aiq/aiq.cpp |  5 ++++-\n aiq/aiq.h   |  2 +-\n ipu3.cpp    | 27 ++++++++++++++++++++++++++-\n 3 files changed, 31 insertions(+), 3 deletions(-)",
    "diff": "diff --git a/aiq/aiq.cpp b/aiq/aiq.cpp\nindex 24c61cb..9c7f9d6 100644\n--- a/aiq/aiq.cpp\n+++ b/aiq/aiq.cpp\n@@ -139,7 +139,7 @@ int AIQ::setStatistics(unsigned int frame,\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+\t             AiqResults &results, int lensPosition, int64_t lensMovementStartTime)\n {\n \t(void)frame;\n \n@@ -157,6 +157,9 @@ int AIQ::run2a(unsigned int frame, AiqInputParameters &params,\n \tparams.saParams.awb_results = results.awb();\n \tshadingAdapterRun(params.saParams, results);\n \n+\tparams.afParams.lens_position = lensPosition;\n+\tparams.afParams.lens_movement_start_timestamp = lensMovementStartTime;\n+\n \tafRun(params.afParams, results);\n \n \treturn 0;\ndiff --git a/aiq/aiq.h b/aiq/aiq.h\nindex fcd02d2..4f5f868 100644\n--- a/aiq/aiq.h\n+++ b/aiq/aiq.h\n@@ -41,7 +41,7 @@ public:\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+\t          AiqResults &results, int lensPosition, int64_t lensMovementStartTime);\n \n private:\n \tstd::string decodeError(ia_err err);\ndiff --git a/ipu3.cpp b/ipu3.cpp\nindex b7de901..45330ca 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@@ -258,6 +262,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@@ -381,7 +388,7 @@ void IPAIPU3::fillParams(unsigned int frame, ipu3_uapi_params *params)\n \t*/\n \n \t/* Run algorithms into/using this context structure */\n-\taiq_.run2a(frame, aiqInputParams_, results_);\n+\taiq_.run2a(frame, aiqInputParams_, results_, lensPosition_, lensMovementStartTime_);\n \n \taic_.updateRuntimeParams(results_);\n \taic_.run(params);\n@@ -389,6 +396,19 @@ void IPAIPU3::fillParams(unsigned int frame, ipu3_uapi_params *params)\n \texposure_ = results_.ae()->exposures[0].sensor_exposure->coarse_integration_time;\n \tgain_ = results_.ae()->exposures[0].sensor_exposure->analog_gain_code_global;\n \n+\t/*\n+\t* Af algorithm compares the timestamp of start of lens movement start and the\n+\t* that of the statistics generated to estimate whether next lens positon\n+\t* should be produced.\n+\t* Todo: Uses the lens movement start time reported by the pipeline handler.\n+\t*/\n+\tif (lensPosition_ != results_.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_ = results_.af()->next_lens_position;\n+\n \tresultsHistory_.Push(results_);\n \n \tsetControls(frame);\n@@ -472,6 +492,11 @@ void IPAIPU3::setControls(unsigned int frame)\n \n \top.sensorControls = sensorCtrls;\n \n+\tControlList lensCtrls;\n+\tlensCtrls.set(V4L2_CID_FOCUS_ABSOLUTE, lensPosition_);\n+\n+\top.lensControls = lensCtrls;\n+\n \tqueueFrameAction.emit(frame, op);\n }\n \n",
    "prefixes": [
        "libcamera-devel",
        "4/6"
    ]
}