Show a patch.

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

{
    "id": 14708,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/14708/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/14708/",
    "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": "<20211123123751.3194696-5-hanlinchen@chromium.org>",
    "date": "2021-11-23T12:37:51",
    "name": "[libcamera-devel,v4,4/4] ipu3: ipa: Allow IPA to apply controls to the lens device",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "56209e877401e220c612772ada3f8a396f3e871e",
    "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/14708/mbox/",
    "series": [
        {
            "id": 2743,
            "url": "https://patchwork.libcamera.org/api/1.1/series/2743/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2743",
            "date": "2021-11-23T12:37:47",
            "name": "Introduce Lens class and apply auto focus on ipu3",
            "version": 4,
            "mbox": "https://patchwork.libcamera.org/series/2743/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/14708/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/14708/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 824BEBF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 23 Nov 2021 12:38:13 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 3422B60394;\n\tTue, 23 Nov 2021 13:38:13 +0100 (CET)",
            "from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com\n\t[IPv6:2607:f8b0:4864:20::62d])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 9B0C86022F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 23 Nov 2021 13:38:10 +0100 (CET)",
            "by mail-pl1-x62d.google.com with SMTP id o14so16957256plg.5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 23 Nov 2021 04:38:10 -0800 (PST)",
            "from localhost ([2401:fa00:1:10:8aa3:febd:fadf:4199])\n\tby smtp.gmail.com with UTF8SMTPSA id\n\tu22sm12985033pfi.187.2021.11.23.04.38.07\n\t(version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);\n\tTue, 23 Nov 2021 04:38:08 -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=\"Jpc+N5kE\"; 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=Wts5FaHlWgEzLQTSI6cOeLZs+nV4J2NqWI0WqjNYSw0=;\n\tb=Jpc+N5kEEAjvEjqBdv6M8m8udGp0Yh1GtoVksxOz/hjsVKYTfcYUbm34H41YQ7e/ok\n\tTPvnRQDwAa6xlbfFpkrwG0nVDNxIbiLQKciOpfzFBQYErPfn8JE3ktsMKz15hGCbtxYS\n\tyxF8RIltZarHtC1yd5kPGQ2u91Sruar4z4cec=",
        "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=Wts5FaHlWgEzLQTSI6cOeLZs+nV4J2NqWI0WqjNYSw0=;\n\tb=Vgl5VrAvZnUFw9Yil+DULrrsKkPmbt5okIOo2HPw502xQNfGYf79rfU3wxl8cP21n7\n\t3JUqgXsxwgzpNiGsTAiQPgvJny/H2ZUdnDxWW05GjRpCCMD4uEdD2tKhZSSPtkwARicf\n\tUzqx/T7jubJsfKSC1b73CSqu8UIISSRpqbrWGDt9REVWtBaGeCBwfl9RFzacCpjUZxM1\n\tkMuI9SJB/gI+YL5bJjtxxTJBXbXBq/3/EQ4MYdPhBo0yWHnHqDy1Xs+loJrOc4qldpg9\n\tVE09dO4MbT7g/8jV86dnQCXSk8vdnCe8t2C/RlcCSShEM9x6d+8XTWhCim3CgyNGyizl\n\tYJrA==",
        "X-Gm-Message-State": "AOAM5339tZ7Yydzp06yaQEL72oX2I07ohwrLo59Cp0z93eajeobkE6o0\n\tNXHE1xrP82DtPh5i6NgLWAY+PQ2pl7d+lg==",
        "X-Google-Smtp-Source": "ABdhPJwSd7bDO0VT8HpIVGKDTP47XCLN4FTTe/oknQvbGhl2ucYdUzu+pjEIzeFOBAPmVCkh2wAyLg==",
        "X-Received": "by 2002:a17:90a:e60b:: with SMTP id\n\tj11mr2542259pjy.52.1637671088458; \n\tTue, 23 Nov 2021 04:38:08 -0800 (PST)",
        "From": "Han-Lin Chen <hanlinchen@chromium.org>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Tue, 23 Nov 2021 20:37:51 +0800",
        "Message-Id": "<20211123123751.3194696-5-hanlinchen@chromium.org>",
        "X-Mailer": "git-send-email 2.34.0.rc2.393.gf8c9666880-goog",
        "In-Reply-To": "<20211123123751.3194696-1-hanlinchen@chromium.org>",
        "References": "<20211123123751.3194696-1-hanlinchen@chromium.org>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v4 4/4] ipu3: ipa: Allow IPA to apply\n\tcontrols to the lens device",
        "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": "Allow IPA to apply controls to the lens device.\n\nSigned-off-by: Han-Lin Chen <hanlinchen@chromium.org>\n---\n src/libcamera/pipeline/ipu3/cio2.cpp | 29 ++++++++++++++++++++++++++++\n src/libcamera/pipeline/ipu3/cio2.h   |  3 +++\n src/libcamera/pipeline/ipu3/ipu3.cpp | 12 ++++++++++--\n 3 files changed, 42 insertions(+), 2 deletions(-)",
    "diff": "diff --git a/src/libcamera/pipeline/ipu3/cio2.cpp b/src/libcamera/pipeline/ipu3/cio2.cpp\nindex 59dda56b..59b2f586 100644\n--- a/src/libcamera/pipeline/ipu3/cio2.cpp\n+++ b/src/libcamera/pipeline/ipu3/cio2.cpp\n@@ -16,6 +16,7 @@\n #include <libcamera/geometry.h>\n #include <libcamera/stream.h>\n \n+#include \"libcamera/internal/camera_lens.h\"\n #include \"libcamera/internal/camera_sensor.h\"\n #include \"libcamera/internal/framebuffer.h\"\n #include \"libcamera/internal/media_device.h\"\n@@ -159,6 +160,34 @@ int CIO2Device::init(const MediaDevice *media, unsigned int index)\n \t\treturn -EINVAL;\n \t}\n \n+\t/*\n+\t * \\todo Read the lens model from the sensor itself or from a device\n+\t * database. For now use default values taken from ChromeOS database.\n+\t */\n+\tstatic std::unordered_map<std::string, std::string> sensorLens = {\n+\t\t{ \"ov13858\", \"dw9714\" },\n+\t\t{ \"imx258\", \"dw9807\" },\n+\t\t{ \"imx355\", \"ak7375\" }\n+\t};\n+\n+\tauto it = sensorLens.find(sensor_->model());\n+\tif (it != sensorLens.end()) {\n+\t\tconst std::vector<MediaEntity *> &entities = media->entities();\n+\t\tfor (auto ent : entities) {\n+\t\t\tif (ent->function() == MEDIA_ENT_F_LENS) {\n+\t\t\t\tlens_ = std::make_unique<CameraLens>(ent);\n+\t\t\t\tret = lens_->init();\n+\t\t\t\tif (!ret && lens_->model() == it->second) {\n+\t\t\t\t\tbreak;\n+\t\t\t\t}\n+\t\t\t\tlens_.reset();\n+\t\t\t}\n+\t\t\tif (!lens_)\n+\t\t\t\tLOG(IPU3, Warning) << \"Lens device \"\n+\t\t\t\t\t\t   << it->second << \" not found\";\n+\t\t}\n+\t}\n+\n \t/*\n \t * \\todo Define when to open and close video device nodes, as they\n \t * might impact on power consumption.\ndiff --git a/src/libcamera/pipeline/ipu3/cio2.h b/src/libcamera/pipeline/ipu3/cio2.h\nindex ba8f0052..635566c8 100644\n--- a/src/libcamera/pipeline/ipu3/cio2.h\n+++ b/src/libcamera/pipeline/ipu3/cio2.h\n@@ -18,6 +18,7 @@\n \n namespace libcamera {\n \n+class CameraLens;\n class CameraSensor;\n class FrameBuffer;\n class MediaDevice;\n@@ -52,6 +53,7 @@ public:\n \tint stop();\n \n \tCameraSensor *sensor() { return sensor_.get(); }\n+\tCameraLens *lens() { return lens_.get(); }\n \tconst CameraSensor *sensor() const { return sensor_.get(); }\n \n \tFrameBuffer *queueBuffer(Request *request, FrameBuffer *rawBuffer);\n@@ -67,6 +69,7 @@ private:\n \tvoid cio2BufferReady(FrameBuffer *buffer);\n \n \tstd::unique_ptr<CameraSensor> sensor_;\n+\tstd::unique_ptr<CameraLens> lens_;\n \tstd::unique_ptr<V4L2Subdevice> csi2_;\n \tstd::unique_ptr<V4L2VideoDevice> output_;\n \ndiff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\nindex c65afdb2..6e04ec8f 100644\n--- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n+++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n@@ -24,6 +24,7 @@\n #include <libcamera/stream.h>\n \n #include \"libcamera/internal/camera.h\"\n+#include \"libcamera/internal/camera_lens.h\"\n #include \"libcamera/internal/camera_sensor.h\"\n #include \"libcamera/internal/delayed_controls.h\"\n #include \"libcamera/internal/device_enumerator.h\"\n@@ -1238,8 +1239,15 @@ void IPU3CameraData::queueFrameAction(unsigned int id,\n {\n \tswitch (action.op) {\n \tcase ipa::ipu3::ActionSetSensorControls: {\n-\t\tconst ControlList &controls = action.sensorControls;\n-\t\tdelayedCtrls_->push(controls);\n+\t\tconst ControlList &sensorControls = action.sensorControls;\n+\t\tdelayedCtrls_->push(sensorControls);\n+\n+\t\tconst ControlList lensControls = action.lensControls;\n+\t\tconst ControlValue &focusValue =\n+\t\t\tlensControls.get(V4L2_CID_FOCUS_ABSOLUTE);\n+\t\tif (!focusValue.isNone() && cio2_.lens())\n+\t\t\tcio2_.lens()->setFocusPostion(focusValue.get<int32_t>());\n+\n \t\tbreak;\n \t}\n \tcase ipa::ipu3::ActionParamFilled: {\n",
    "prefixes": [
        "libcamera-devel",
        "v4",
        "4/4"
    ]
}