Show a patch.

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

{
    "id": 16403,
    "url": "https://patchwork.libcamera.org/api/patches/16403/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/16403/",
    "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": "<20220628090656.19572-4-dse@thaumatec.com>",
    "date": "2022-06-28T09:06:56",
    "name": "[libcamera-devel,3/3] libcamera: rkisp1: Control the lens from IPA",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "6903d97067c2cda0192cf16decc36254ab49441e",
    "submitter": {
        "id": 126,
        "url": "https://patchwork.libcamera.org/api/people/126/?format=api",
        "name": "Daniel Semkowicz",
        "email": "dse@thaumatec.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/16403/mbox/",
    "series": [
        {
            "id": 3228,
            "url": "https://patchwork.libcamera.org/api/series/3228/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3228",
            "date": "2022-06-28T09:06:53",
            "name": "libcamera: rkisp1: Add lens control",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/3228/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/16403/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/16403/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 37B66BE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 28 Jun 2022 09:07:18 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id DB4B765636;\n\tTue, 28 Jun 2022 11:07:17 +0200 (CEST)",
            "from mail-wr1-x431.google.com (mail-wr1-x431.google.com\n\t[IPv6:2a00:1450:4864:20::431])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 719986559A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 28 Jun 2022 11:07:15 +0200 (CEST)",
            "by mail-wr1-x431.google.com with SMTP id s1so16655078wra.9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 28 Jun 2022 02:07:15 -0700 (PDT)",
            "from localhost.localdomain (ip092042140082.rev.nessus.at.\n\t[92.42.140.82]) by smtp.gmail.com with ESMTPSA id\n\tr68-20020a1c2b47000000b0039c4b518df4sm20126972wmr.5.2022.06.28.02.07.13\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 28 Jun 2022 02:07:14 -0700 (PDT)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1656407237;\n\tbh=gfzwUG83+G0yymYmH0N1alx3bx8m4CacN2rgSnexuaM=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=Ps1/izySZocKPjuNolYWOq4G3/QSTY7rFwZj9sjOgj7RK15vwKzaQC+PwEDZyBZ/X\n\tV4G7wLAnzFCC1niO5iOxM8HRjkaRFk0Xp8utubQos0jXTJyqwv7p89vrMBV7Ay839t\n\tRwfIenUaQGUwCWODNxsvdnDT4M83YXrM67G8PNKiFdVpo0UDiPrp8UTnx+Z9VOMuEM\n\tlWEMjRFtR6MWlfjY0I00ce4ZucVODTRjH8HqS6BJ+pXrEeeWyPL2RdF82taBjP7SIP\n\tGj7iQ88af6zLGpN660D9CZ7b+Y3v9aUAkwdWIAj/oqzR699qY6Hl/5g7SAX0ew8TAn\n\tgEEOQwwYS2L0g==",
            "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=thaumatec-com.20210112.gappssmtp.com; s=20210112;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=ZYSh6TtUV6Id9lYrR/VR4whhLRNG6xChpZLV3FOUjj4=;\n\tb=yHOiDYsQ/YJF9PfdUKPVbA/N2Zsp405kpkBNFoCHhxDcz/qncX14londaGcbcUcpCC\n\tail24whucfNovrfAbYlLyKeL9TQPpw2F4cWQo+RVduoAWuA5xvKZehZ+MI1b9JGzTqIE\n\tvR9huRZEkVmL97Tz2FLQNAnUmOUR74vNnTYanvgNhb3A/q1+HiwbxVgq1Tr3kYMJZDwP\n\thbSlEp39TiUQMAgrmxhfy1msp+0vZnEcxAQGhmyDlgSrkxdDZIr2bsSbBPXgV79zQ7Lv\n\thl5iGOjNaL2pcwwYEkggJFJXaGBCnehcTHOnLrWXqYgJ1k1zFWYf88S81G/2/Ayi+TXC\n\tUA9A=="
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected)\n\theader.d=thaumatec-com.20210112.gappssmtp.com\n\theader.i=@thaumatec-com.20210112.gappssmtp.com header.b=\"yHOiDYsQ\"; \n\tdkim-atps=neutral",
        "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=ZYSh6TtUV6Id9lYrR/VR4whhLRNG6xChpZLV3FOUjj4=;\n\tb=bQ57uJiQE0ASInCHtJJfXR0zBnTJZf6eKkitMKIZi5tLH/HGZ/gfH9qiwsDojmUF42\n\t2Jbo3gDbK38fxH0dP1fI3AfhVKSGd7F81YB2QMujx5sfCyWQck8Rqe2sJXCpUCdO9jaN\n\tI+nbMqYcsa0HsP2bfIg3D7TYFFnhXUH2KiJoFJsmTEOQcgSoFAI4IPhBfrh12UQLZMsv\n\t7Ka6VJo6R/4q1AZ543/M2d+PXMoyWIqr4vlM7xrMpLbmY0pg8h/MAF8D8I5c9jQnex5K\n\tERIklWoKIqYYYXXbfSwvzPcy2/R9seDiqFsVZXXtpTrOIc06NVvx5GOqThMVL9/SipjU\n\tSDVw==",
        "X-Gm-Message-State": "AJIora/VoxgtexoKXBcQV+wIO6IY/Bx/k8hYoT2B5h5bpLR+E+q2VKld\n\tDpbLzZw4BDjCQwVi+IQ4Dkg634cKA3mCvg==",
        "X-Google-Smtp-Source": "AGRyM1tTC6UUkZIFqd7NZR6fpldiQQZwEaeDHDF1Z5r8e9TvsG49JVOS2DUPNoUskBTHH/FEBckYig==",
        "X-Received": "by 2002:a5d:47aa:0:b0:21b:ad9a:d48c with SMTP id\n\t10-20020a5d47aa000000b0021bad9ad48cmr17919069wrb.610.1656407235061; \n\tTue, 28 Jun 2022 02:07:15 -0700 (PDT)",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Tue, 28 Jun 2022 11:06:56 +0200",
        "Message-Id": "<20220628090656.19572-4-dse@thaumatec.com>",
        "X-Mailer": "git-send-email 2.34.1",
        "In-Reply-To": "<20220628090656.19572-1-dse@thaumatec.com>",
        "References": "<20220628090656.19572-1-dse@thaumatec.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH 3/3] libcamera: rkisp1: Control the lens\n\tfrom IPA",
        "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>",
        "From": "Daniel Semkowicz via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>",
        "Reply-To": "Daniel Semkowicz <dse@thaumatec.com>",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "Check if lens are available and have ability to control the focus.\nConnect IPA setLensControls() signal to the pipeline slot that controls\nthe lens. If lens are valid, allow changing the focus from IPA by\nemitting signal to the pipeline.\n\nSigned-off-by: Daniel Semkowicz <dse@thaumatec.com>\n---\n include/libcamera/ipa/rkisp1.mojom       |  1 +\n src/ipa/rkisp1/ipa_context.h             |  4 +++\n src/ipa/rkisp1/rkisp1.cpp                | 36 ++++++++++++++++++++++++\n src/libcamera/pipeline/rkisp1/rkisp1.cpp |  1 +\n 4 files changed, 42 insertions(+)",
    "diff": "diff --git a/include/libcamera/ipa/rkisp1.mojom b/include/libcamera/ipa/rkisp1.mojom\nindex e3537385..ee06a6b0 100644\n--- a/include/libcamera/ipa/rkisp1.mojom\n+++ b/include/libcamera/ipa/rkisp1.mojom\n@@ -32,5 +32,6 @@ interface IPARkISP1Interface {\n interface IPARkISP1EventInterface {\n \tparamsBufferReady(uint32 frame);\n \tsetSensorControls(uint32 frame, libcamera.ControlList sensorControls);\n+\tsetLensControls(libcamera.ControlList sensorControls);\n \tmetadataReady(uint32 frame, libcamera.ControlList metadata);\n };\ndiff --git a/src/ipa/rkisp1/ipa_context.h b/src/ipa/rkisp1/ipa_context.h\nindex f387cace..4b199048 100644\n--- a/src/ipa/rkisp1/ipa_context.h\n+++ b/src/ipa/rkisp1/ipa_context.h\n@@ -41,6 +41,10 @@ struct IPASessionConfiguration {\n };\n \n struct IPAFrameContext {\n+\tstruct {\n+\t\tuint32_t focus;\n+\t} af;\n+\n \tstruct {\n \t\tuint32_t exposure;\n \t\tdouble gain;\ndiff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp\nindex 3511a054..2447f4f4 100644\n--- a/src/ipa/rkisp1/rkisp1.cpp\n+++ b/src/ipa/rkisp1/rkisp1.cpp\n@@ -7,6 +7,7 @@\n \n #include <algorithm>\n #include <math.h>\n+#include <optional>\n #include <queue>\n #include <stdint.h>\n #include <string.h>\n@@ -59,6 +60,8 @@ public:\n \tvoid processStatsBuffer(const uint32_t frame, const uint32_t bufferId,\n \t\t\t\tconst ControlList &sensorControls) override;\n private:\n+\tbool validateLensControls(const ControlInfoMap &lensControls);\n+\n \tvoid setControls(unsigned int frame);\n \tvoid prepareMetadata(unsigned int frame, unsigned int aeState);\n \n@@ -66,6 +69,7 @@ private:\n \tstd::map<unsigned int, MappedFrameBuffer> mappedBuffers_;\n \n \tControlInfoMap sensorCtrls_;\n+\tstd::optional<ControlInfoMap> lensCtrls_;\n \n \t/* Camera sensor controls. */\n \tbool autoExposure_;\n@@ -162,6 +166,14 @@ int IPARkISP1::configure([[maybe_unused]] const IPACameraSensorInfo &info,\n \t\treturn -EINVAL;\n \t}\n \n+\tauto lensControls = entityControls.find(1);\n+\tif (lensControls != entityControls.end()) {\n+\t\tif (validateLensControls(lensControls->second))\n+\t\t\tlensCtrls_ = lensControls->second;\n+\t\telse\n+\t\t\tLOG(IPARkISP1, Error) << \"Lens control validation failed.\";\n+\t}\n+\n \tautoExposure_ = true;\n \n \tint32_t minExposure = itExp->second.min().get<int32_t>();\n@@ -205,6 +217,23 @@ int IPARkISP1::configure([[maybe_unused]] const IPACameraSensorInfo &info,\n \treturn 0;\n }\n \n+bool IPARkISP1::validateLensControls(const ControlInfoMap &lensControls)\n+{\n+\tstatic const uint32_t ctrls[] = {\n+\t\tV4L2_CID_FOCUS_ABSOLUTE,\n+\t};\n+\n+\tfor (auto c : ctrls) {\n+\t\tif (lensControls.find(c) == lensControls.end()) {\n+\t\t\tLOG(IPARkISP1, Error) << \"Unable to find lens control \"\n+\t\t\t\t\t      << utils::hex(c);\n+\t\t\treturn false;\n+\t\t}\n+\t}\n+\n+\treturn true;\n+}\n+\n void IPARkISP1::mapBuffers(const std::vector<IPABuffer> &buffers)\n {\n \tfor (const IPABuffer &buffer : buffers) {\n@@ -289,6 +318,13 @@ void IPARkISP1::setControls(unsigned int frame)\n \tctrls.set(V4L2_CID_ANALOGUE_GAIN, static_cast<int32_t>(gain));\n \n \tsetSensorControls.emit(frame, ctrls);\n+\n+\tif (lensCtrls_) {\n+\t\tControlList lensCtrls(*lensCtrls_);\n+\t\tlensCtrls.set(V4L2_CID_FOCUS_ABSOLUTE,\n+\t\t\t      static_cast<int32_t>(context_.frameContext.af.focus));\n+\t\tsetLensControls.emit(lensCtrls);\n+\t}\n }\n \n void IPARkISP1::prepareMetadata(unsigned int frame, unsigned int aeState)\ndiff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\nindex 363273b2..55d3e3a9 100644\n--- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n+++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n@@ -320,6 +320,7 @@ int RkISP1CameraData::loadIPA(unsigned int hwRevision)\n \t\treturn -ENOENT;\n \n \tipa_->setSensorControls.connect(this, &RkISP1CameraData::setSensorControls);\n+\tipa_->setLensControls.connect(this, &RkISP1CameraData::setLensControls);\n \tipa_->paramsBufferReady.connect(this, &RkISP1CameraData::paramFilled);\n \tipa_->metadataReady.connect(this, &RkISP1CameraData::metadataReady);\n \n",
    "prefixes": [
        "libcamera-devel",
        "3/3"
    ]
}