Show a patch.

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

{
    "id": 19859,
    "url": "https://patchwork.libcamera.org/api/patches/19859/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/19859/",
    "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": "<20240405145335.3010479-4-paul.elder@ideasonboard.com>",
    "date": "2024-04-05T14:53:33",
    "name": "[3/5] utils: libtuning: modules: Add skeletal CCM module",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "b40f7c0b5c5426be9d77d35eb4a4d4e59ae6df85",
    "submitter": {
        "id": 17,
        "url": "https://patchwork.libcamera.org/api/people/17/?format=api",
        "name": "Paul Elder",
        "email": "paul.elder@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/19859/mbox/",
    "series": [
        {
            "id": 4252,
            "url": "https://patchwork.libcamera.org/api/series/4252/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4252",
            "date": "2024-04-05T14:53:30",
            "name": "utils: tuning: Add AGC and CCM",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/4252/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/19859/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/19859/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 54FC2C32C9\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri,  5 Apr 2024 14:53:57 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 629CB63367;\n\tFri,  5 Apr 2024 16:53:56 +0200 (CEST)",
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 5BCD763360\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  5 Apr 2024 16:53:52 +0200 (CEST)",
            "from pyrite.hamster-moth.ts.net (h175-177-049-156.catv02.itscom.jp\n\t[175.177.49.156])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 9A1EAC8A;\n\tFri,  5 Apr 2024 16:53:12 +0200 (CEST)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"nc6rmt/l\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1712328793;\n\tbh=WlEblNyqFiTKnAv2U4pHvcqgYkOcud2LwqO0qLrNoRc=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=nc6rmt/lna9MoSNlZH8evaP6vy8PMGRNm+ZhwuN+blWyDSbmUzMELc6eP7Ug+T99W\n\tPTJYZ/lakqTiqlKmBMx5F19sfA1Z+w8u8Yua3eYUrwhae03K8Jte352sYi6EMymTkV\n\tJeko33TTnYH57F8JsvRNrXEcS9Nh+1ynTpJO0Nm0=",
        "From": "Paul Elder <paul.elder@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Cc": "Paul Elder <paul.elder@ideasonboard.com>",
        "Subject": "[PATCH 3/5] utils: libtuning: modules: Add skeletal CCM module",
        "Date": "Fri,  5 Apr 2024 23:53:33 +0900",
        "Message-Id": "<20240405145335.3010479-4-paul.elder@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.39.2",
        "In-Reply-To": "<20240405145335.3010479-1-paul.elder@ideasonboard.com>",
        "References": "<20240405145335.3010479-1-paul.elder@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "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": "Add a skeletal CCM module just so that we can have some CCM tuning\nvalues that we can use to test during development of CCM in the IPAs. As\nrkisp1 is the main target, we only add support for rkisp1 for now.\n\nThe parameters are mostly copied from the hardcoded values in ctt,\nexcept for the metering modes.\n\nAs CCM is called CTK (for crosstalk) in rkisp1, that is the name that\nwill be used for rkisp1.\n\nSigned-off-by: Paul Elder <paul.elder@ideasonboard.com>\n---\n .../tuning/libtuning/modules/ccm/__init__.py  |  6 ++\n utils/tuning/libtuning/modules/ccm/ccm.py     | 22 ++++++\n utils/tuning/libtuning/modules/ccm/rkisp1.py  | 75 +++++++++++++++++++\n 3 files changed, 103 insertions(+)\n create mode 100644 utils/tuning/libtuning/modules/ccm/__init__.py\n create mode 100644 utils/tuning/libtuning/modules/ccm/ccm.py\n create mode 100644 utils/tuning/libtuning/modules/ccm/rkisp1.py",
    "diff": "diff --git a/utils/tuning/libtuning/modules/ccm/__init__.py b/utils/tuning/libtuning/modules/ccm/__init__.py\nnew file mode 100644\nindex 00000000..a06c356c\n--- /dev/null\n+++ b/utils/tuning/libtuning/modules/ccm/__init__.py\n@@ -0,0 +1,6 @@\n+# SPDX-License-Identifier: GPL-2.0-or-later\n+#\n+# Copyright (C) 2024, Paul Elder <paul.elder@ideasonboard.com>\n+\n+from libtuning.modules.ccm.ccm import CCM\n+from libtuning.modules.ccm.rkisp1 import CTKRkISP1\ndiff --git a/utils/tuning/libtuning/modules/ccm/ccm.py b/utils/tuning/libtuning/modules/ccm/ccm.py\nnew file mode 100644\nindex 00000000..7ddf0a8c\n--- /dev/null\n+++ b/utils/tuning/libtuning/modules/ccm/ccm.py\n@@ -0,0 +1,22 @@\n+# SPDX-License-Identifier: BSD-2-Clause\n+#\n+# Copyright (C) 2019, Raspberry Pi Ltd\n+# Copyright (C) 2024, Paul Elder <paul.elder@ideasonboard.com>\n+\n+from ..module import Module\n+\n+import libtuning as lt\n+import libtuning.utils as utils\n+\n+import numpy as np\n+\n+class CCM(Module):\n+    type = 'ccm'\n+    hr_name = 'CCM (Base)'\n+    out_name = 'GenericCCM'\n+\n+    def __init__(self, *,\n+                 debug: list):\n+        super().__init__()\n+\n+        self.debug = debug\ndiff --git a/utils/tuning/libtuning/modules/ccm/rkisp1.py b/utils/tuning/libtuning/modules/ccm/rkisp1.py\nnew file mode 100644\nindex 00000000..5a6caea8\n--- /dev/null\n+++ b/utils/tuning/libtuning/modules/ccm/rkisp1.py\n@@ -0,0 +1,75 @@\n+# SPDX-License-Identifier: BSD-2-Clause\n+#\n+# Copyright (C) 2019, Raspberry Pi Ltd\n+# Copyright (C) 2024, Paul Elder <paul.elder@ideasonboard.com>\n+#\n+# rkisp1.py - Ctk module for tuning rkisp1\n+\n+from .ccm import CCM\n+\n+import libtuning as lt\n+import libtuning.utils as utils\n+\n+from numbers import Number\n+import numpy as np\n+\n+class CTKRkISP1(CCM):\n+    hr_name = 'Crosstalk Correction (RkISP1)'\n+    out_name = 'Ctk'\n+    # \\todo Not sure if this is useful. Probably will remove later.\n+    compatible = ['rkisp1']\n+\n+    def __init__(self, **kwargs):\n+        super().__init__(**kwargs)\n+\n+    # We don't actually need anything from the config file\n+    def validate_config(self, config: dict) -> bool:\n+        return True\n+\n+    def _float_to_fixed_4_7(self, d):\n+        mask = 0xf\n+        whole = int(d) & mask\n+\n+        fractional = d % 1\n+        frac = 0\n+        for i in range(0, 7):\n+            fractional *= 2\n+            frac <<= 1\n+            frac |= int(fractional) & 0x1\n+\n+        return (whole << 7) | frac\n+\n+    def _generate_ctms(self) -> dict:\n+        ctms = {\n+                '2860': [ 2.12089, -0.52461, -0.59629,\n+                         -0.85342,  2.80445, -0.95103,\n+                         -0.26897, -1.14788,  2.41685 ],\n+                '2960': [ 2.26962, -0.54174, -0.72789,\n+                         -0.77008,  2.60271, -0.83262,\n+                         -0.26036, -1.51254,  2.77289 ],\n+                '3603': [ 2.18644, -0.66148, -0.52496,\n+                         -0.77828,  2.69474, -0.91645,\n+                         -0.25239, -0.83059,  2.08298 ],\n+                '4650': [ 2.18174, -0.70887, -0.47287,\n+                         -0.70196,  2.76426, -1.06231,\n+                         -0.25157, -0.71978,  1.97135 ],\n+                '5858': [ 2.32392, -0.88421, -0.43971,\n+                         -0.63821,  2.58348, -0.94527,\n+                         -0.28541, -0.54112,  1.82653 ],\n+                '7580': [ 2.21175, -0.53242, -0.67933,\n+                         -0.57875,  3.07922, -1.50047,\n+                         -0.27709, -0.73338,  2.01048 ],\n+                }\n+\n+        ret = {}\n+        for ct in ctms:\n+            ret[ct] = [self._float_to_fixed_4_7(weight) for weight in ctms[ct]]\n+        return ret\n+\n+    def process(self, config: dict, images: list, outputs: dict) -> dict:\n+        output = {}\n+\n+        output['ctms'] = self._generate_ctms()\n+        # \\todo Debug functionality\n+\n+        return output\n",
    "prefixes": [
        "3/5"
    ]
}