Show a patch.

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

{
    "id": 18748,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/18748/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/18748/",
    "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": "<20230619060242.37020-1-umang.jain@ideasonboard.com>",
    "date": "2023-06-19T06:02:42",
    "name": "[libcamera-devel,v2] ipa: rpi: cam_helper: PDAF support for IMX519",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "1b794a0e3d2887a70f171630d8ced4767ffcdc37",
    "submitter": {
        "id": 86,
        "url": "https://patchwork.libcamera.org/api/1.1/people/86/?format=api",
        "name": "Umang Jain",
        "email": "umang.jain@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/18748/mbox/",
    "series": [
        {
            "id": 3929,
            "url": "https://patchwork.libcamera.org/api/1.1/series/3929/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3929",
            "date": "2023-06-19T06:02:42",
            "name": "[libcamera-devel,v2] ipa: rpi: cam_helper: PDAF support for IMX519",
            "version": 2,
            "mbox": "https://patchwork.libcamera.org/series/3929/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/18748/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/18748/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 B13EEBD78E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 19 Jun 2023 06:02:53 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id D102A628C3;\n\tMon, 19 Jun 2023 08:02:52 +0200 (CEST)",
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 94B2061E3F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 19 Jun 2023 08:02:50 +0200 (CEST)",
            "from umang.jainideasonboard.com (unknown [103.86.18.208])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id DC095800;\n\tMon, 19 Jun 2023 08:02:14 +0200 (CEST)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1687154572;\n\tbh=Pkmz7OVFrwG5lK3IaBw8Uz7CF55pwV1j3PT5xkAoF5k=;\n\th=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post:\n\tList-Help:List-Subscribe:From:Reply-To:Cc:From;\n\tb=O6BrE7igR7Oy1qmK/G7XDdt+1gXc5uxcVLEWeRxVVIwP1zn6iQWd5mVo5aejTEOtg\n\t9Bu9fzmPHRX6IehSODDYQlsncLhD4gEdSnF5uAitB79C6jxjYwM+FHo3H+qjzabmo6\n\tZzD3siw5BByGI0Rn1TQE0fN5IJWLrnSiMMi+EWFhJb/oH9vio/qUJ8hW878kAyxgIW\n\tTREDa69yQbzxe67h4KRZHZcKi9WYX8TEMYTsk8kBdcx8IsPo73JQDxgv+0lSu8GJvW\n\tZwYzv07558SHyEVqAIcVxbEQwRWx+c+X5rjxFfv43RT+mXeld+n8FGmtdLGQGwlMEz\n\tQWzNosWtwotKA==",
            "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1687154536;\n\tbh=Pkmz7OVFrwG5lK3IaBw8Uz7CF55pwV1j3PT5xkAoF5k=;\n\th=From:To:Cc:Subject:Date:From;\n\tb=cNbA+sCt7wl8ZUGirBusYJ/zsNbGEnfxnojhSMMEcXEGb73GdSvytXncvLsBYoIRs\n\tdZAHILtIgwmzgGaPv6bJsSxtmXXjK7H3wTYEZ6SfUsKOpiyb1MLcXH4iIqcpZvsM2h\n\tJJrgulyVhWO2ycvOJQDe3FmDis4WMn9ldEbyxbKo="
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"cNbA+sCt\"; dkim-atps=neutral",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Mon, 19 Jun 2023 11:32:42 +0530",
        "Message-Id": "<20230619060242.37020-1-umang.jain@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.39.1",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v2] ipa: rpi: cam_helper: PDAF support for\n\tIMX519",
        "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": "Umang Jain via libcamera-devel <libcamera-devel@lists.libcamera.org>",
        "Reply-To": "Umang Jain <umang.jain@ideasonboard.com>",
        "Cc": "john <john@arducam.com>",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "From: john <john@arducam.com>\n\nAdds the PDAF support for IMX519 camera module by Arducam.\n\nSigned-off-by: Umang Jain <umang.jain@ideasonboard.com>\nTested-by: Umang Jain <umang.jain@ideasonboard.com>\n---\nChanges in v2:\n- Add author's Name \"john <john@arducam.com>\"\n- Add Tested-by: tag\n\nQuestion: S-o-B by author is still missing on origin commit, should I\nexternally add it? \n---\n src/ipa/rpi/cam_helper/cam_helper_imx519.cpp | 50 ++++++++++++++++++++\n src/ipa/rpi/vc4/data/imx519.json             | 40 ++++++++++++++++\n 2 files changed, 90 insertions(+)",
    "diff": "diff --git a/src/ipa/rpi/cam_helper/cam_helper_imx519.cpp b/src/ipa/rpi/cam_helper/cam_helper_imx519.cpp\nindex c7262aa0..6d032082 100644\n--- a/src/ipa/rpi/cam_helper/cam_helper_imx519.cpp\n+++ b/src/ipa/rpi/cam_helper/cam_helper_imx519.cpp\n@@ -15,9 +15,13 @@\n \n #include <libcamera/base/log.h>\n \n+#include \"controller/pdaf_data.h\"\n+\n #include \"cam_helper.h\"\n #include \"md_parser.h\"\n \n+#define ALIGN_UP(x, a) (((x) + (a)-1) & ~(a - 1))\n+\n using namespace RPiController;\n using namespace libcamera;\n using libcamera::utils::Duration;\n@@ -66,8 +70,13 @@ private:\n \t/* Largest long exposure scale factor given as a left shift on the frame length. */\n \tstatic constexpr int longExposureShiftMax = 7;\n \n+\tstatic constexpr int pdafStatsRows = 12;\n+\tstatic constexpr int pdafStatsCols = 16;\n+\n \tvoid populateMetadata(const MdParser::RegisterMap &registers,\n \t\t\t      Metadata &metadata) const override;\n+\tstatic bool parsePdafData(const uint8_t *ptr, size_t len, unsigned bpp,\n+\t\t\t\t  PdafRegions &pdaf);\n };\n \n CamHelperImx519::CamHelperImx519()\n@@ -90,6 +99,11 @@ void CamHelperImx519::prepare(libcamera::Span<const uint8_t> buffer, Metadata &m\n \tMdParser::RegisterMap registers;\n \tDeviceStatus deviceStatus;\n \n+\tLOG(IPARPI, Debug) << \"Embedded buffer size: \" << buffer.size();\n+\n+\tsize_t bytesPerLine = (mode_.width * mode_.bitdepth) >> 3;\n+\tbytesPerLine = ALIGN_UP(bytesPerLine, 16);\n+\n \tif (metadata.get(\"device.status\", deviceStatus)) {\n \t\tLOG(IPARPI, Error) << \"DeviceStatus not found from DelayedControls\";\n \t\treturn;\n@@ -97,6 +111,14 @@ void CamHelperImx519::prepare(libcamera::Span<const uint8_t> buffer, Metadata &m\n \n \tparseEmbeddedData(buffer, metadata);\n \n+\tif (buffer.size() > 2 * bytesPerLine) {\n+\t\tPdafRegions pdaf;\n+\t\tparsePdafData(&buffer[2 * bytesPerLine],\n+\t\t\t      buffer.size() - 2 * bytesPerLine,\n+\t\t\t      mode_.bitdepth, pdaf);\n+\t\tmetadata.set(\"pdaf.data\", pdaf);\n+\t}\n+\n \t/*\n \t * The DeviceStatus struct is first populated with values obtained from\n \t * DelayedControls. If this reports frame length is > frameLengthMax,\n@@ -188,6 +210,34 @@ void CamHelperImx519::populateMetadata(const MdParser::RegisterMap &registers,\n \tmetadata.set(\"device.status\", deviceStatus);\n }\n \n+bool CamHelperImx519::parsePdafData(const uint8_t *ptr, size_t len,\n+\t\t\t\t    unsigned bpp, PdafRegions &pdaf)\n+{\n+\tsize_t step = bpp >> 1; /* bytes per PDAF grid entry */\n+\n+\tif (bpp < 10 || bpp > 12 || len < 194 * step || ptr[0] != 0 || ptr[1] >= 0x40) {\n+\t\tLOG(IPARPI, Error) << \"PDAF data in unsupported format\";\n+\t\treturn false;\n+\t}\n+\n+\tpdaf.init({ pdafStatsCols, pdafStatsRows });\n+\n+\tptr += 2 * step;\n+\tfor (unsigned i = 0; i < pdafStatsRows; ++i) {\n+\t\tfor (unsigned j = 0; j < pdafStatsCols; ++j) {\n+\t\t\tunsigned c = (ptr[0] << 3) | (ptr[1] >> 5);\n+\t\t\tint p = (((ptr[1] & 0x0F) - (ptr[1] & 0x10)) << 6) | (ptr[2] >> 2);\n+\t\t\tPdafData pdafData;\n+\t\t\tpdafData.conf = c;\n+\t\t\tpdafData.phase = c ? p : 0;\n+\t\t\tpdaf.set(libcamera::Point(j, i), { pdafData, 1, 0 });\n+\t\t\tptr += step;\n+\t\t}\n+\t}\n+\n+\treturn true;\n+}\n+\n static CamHelper *create()\n {\n \treturn new CamHelperImx519();\ndiff --git a/src/ipa/rpi/vc4/data/imx519.json b/src/ipa/rpi/vc4/data/imx519.json\nindex 1b0a7747..0733d97e 100644\n--- a/src/ipa/rpi/vc4/data/imx519.json\n+++ b/src/ipa/rpi/vc4/data/imx519.json\n@@ -350,6 +350,46 @@\n                 ]\n             }\n         },\n+        {\n+            \"rpi.af\":\n+            {\n+                \"ranges\":\n+                {\n+                    \"normal\":\n+                    {\n+                        \"min\": 0.0,\n+                        \"max\": 12.0,\n+                        \"default\": 1.0\n+                    },\n+                    \"macro\":\n+                    {\n+                        \"min\": 3.0,\n+                        \"max\": 15.0,\n+                        \"default\": 4.0\n+                    }\n+                },\n+                \"speeds\":\n+                {\n+                    \"normal\":\n+                    {\n+                        \"step_coarse\": 1.0,\n+                        \"step_fine\": 0.25,\n+                        \"contrast_ratio\": 0.75,\n+                        \"pdaf_gain\": -0.02,\n+                        \"pdaf_squelch\": 0.125,\n+                        \"max_slew\": 2.0,\n+                        \"pdaf_frames\": 20,\n+                        \"dropout_frames\": 6,\n+                        \"step_frames\": 4\n+                    }\n+                },\n+                \"conf_epsilon\": 8,\n+                \"conf_thresh\": 16,\n+                \"conf_clip\": 512,\n+                \"skip_frames\": 5,\n+                \"map\": [ 0.0, 0.0, 15.0, 4095 ]\n+            }\n+        },\n         {\n             \"rpi.ccm\":\n             {\n",
    "prefixes": [
        "libcamera-devel",
        "v2"
    ]
}