Show a patch.

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

{
    "id": 14809,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/14809/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/14809/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/1.1/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": "<20211126113027.3280009-1-hanlinchen@chromium.org>",
    "date": "2021-11-26T11:30:27",
    "name": "[libcamera-devel,IPU3-IPA,v5] ipu3: Apply auto focus and send lens controls to pipeline handler",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "9b27bb71568ecf97b6126baee7c388f4e7544e8d",
    "submitter": {
        "id": 98,
        "url": "https://patchwork.libcamera.org/api/1.1/people/98/?format=api",
        "name": "Hanlin Chen",
        "email": "hanlinchen@chromium.org"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/14809/mbox/",
    "series": [
        {
            "id": 2763,
            "url": "https://patchwork.libcamera.org/api/1.1/series/2763/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2763",
            "date": "2021-11-26T11:30:27",
            "name": "[libcamera-devel,IPU3-IPA,v5] ipu3: Apply auto focus and send lens controls to pipeline handler",
            "version": 5,
            "mbox": "https://patchwork.libcamera.org/series/2763/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/14809/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/14809/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 258B0BF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 26 Nov 2021 11:30:35 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id D0801604FD;\n\tFri, 26 Nov 2021 12:30:34 +0100 (CET)",
            "from mail-pg1-x52d.google.com (mail-pg1-x52d.google.com\n\t[IPv6:2607:f8b0:4864:20::52d])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id A50CD6011E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 26 Nov 2021 12:30:33 +0100 (CET)",
            "by mail-pg1-x52d.google.com with SMTP id 71so7901879pgb.4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 26 Nov 2021 03:30:33 -0800 (PST)",
            "from localhost ([2401:fa00:1:10:a0de:e637:c058:6824])\n\tby smtp.gmail.com with UTF8SMTPSA id\n\tmm22sm5280014pjb.28.2021.11.26.03.30.30\n\t(version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);\n\tFri, 26 Nov 2021 03:30:31 -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=\"BAB9H+vE\"; 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=4wdN+JubTQyq72Sw7tfQAAl0btZplbUm+C7gcfqYipI=;\n\tb=BAB9H+vEyeZHorB/LQsTwQWrpvGMEITENg5NNXdvywjKH+XVWwu9c56MzoYzyFjqcE\n\tJVmrwHADLZyF8qsYisiIjFXLrBN2DwQ8HUlI3wZBHYXjyt6msguz2ts5WgHz1och7ZDJ\n\thiAcUuKsia+heeooLrhdndWiSZ0ULv6DYJqSM=",
        "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=4wdN+JubTQyq72Sw7tfQAAl0btZplbUm+C7gcfqYipI=;\n\tb=Ci0VCmFSNYDsOvsdReF7+ajF8EOXjT8izdtRwJIHIx33abM9PY/7JXgKL0EHCyihBQ\n\tVVXnmKlz405Y4FDUzUhDL0LHA9zQ6GKZJl35xdB1eC5CgFrGkn7l/px0aUdFjg6UVR5t\n\tEYyfJddHyQv9R2zyVLHOh1keXgZfCdHnPPoUT7hk5P5BTNAA4Vovi+hNj0PDx/0Ahl4/\n\tTaYC8SV+YFILxhl2XpN2jyD+GINhpzEGcrE5QjirUMVj8njXq92uDW81iVC5UPZu4Fbm\n\tPEurCGbKoaDUvc+3xjBBPFPXwC1lIciKmFLOQSO6tm7Hw4zd058eqOih367CcSbFXjaA\n\tY+Sg==",
        "X-Gm-Message-State": "AOAM531wLYxQMSAVpHgK4l8KRFbKnME9XR1Uh9YPNJWQDRSAkE7cZh6S\n\tFs5LFMKMnmFsnIORb7+qoM0uannlxvnASQ==",
        "X-Google-Smtp-Source": "ABdhPJxEoxhh5Rf0vQSr/Rpf1VAsPaiNbEB1LSstF4NwJAeyz0van4vWoHxg2nGovSpP97lkJbRLKQ==",
        "X-Received": "by 2002:a63:1842:: with SMTP id 2mr7003883pgy.555.1637926231680; \n\tFri, 26 Nov 2021 03:30:31 -0800 (PST)",
        "From": "Han-Lin Chen <hanlinchen@chromium.org>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Fri, 26 Nov 2021 19:30:27 +0800",
        "Message-Id": "<20211126113027.3280009-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 v5] 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>\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\nReviewed-by: Umang Jain <umang.jain@ideasonboard.com>\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..6ab86e0 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 the lens movement and\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",
        "v5"
    ]
}