Show a patch.

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

{
    "id": 23031,
    "url": "https://patchwork.libcamera.org/api/patches/23031/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/23031/",
    "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": "<20250326080034.1733385-4-paul.elder@ideasonboard.com>",
    "date": "2025-03-26T08:00:33",
    "name": "[v2,3/3] libipa: camera_sensor_helper: Fix rounding of gainCode",
    "commit_ref": null,
    "pull_url": null,
    "state": "not-applicable",
    "archived": false,
    "hash": "d4c1d24b8e9572f478e58d30c08035dbdca85ab8",
    "submitter": {
        "id": 17,
        "url": "https://patchwork.libcamera.org/api/people/17/?format=api",
        "name": "Paul Elder",
        "email": "paul.elder@ideasonboard.com"
    },
    "delegate": {
        "id": 49,
        "url": "https://patchwork.libcamera.org/api/users/49/?format=api",
        "username": "stefan",
        "first_name": "Stefan",
        "last_name": "Klug",
        "email": "stefan.klug@ideasonboard.com"
    },
    "mbox": "https://patchwork.libcamera.org/patch/23031/mbox/",
    "series": [
        {
            "id": 5081,
            "url": "https://patchwork.libcamera.org/api/series/5081/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5081",
            "date": "2025-03-26T08:00:30",
            "name": "libipa: Fix CameraSensorHelper gain helpers",
            "version": 2,
            "mbox": "https://patchwork.libcamera.org/series/5081/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/23031/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/23031/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 19D1AC323E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 26 Mar 2025 08:00:53 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id C08C268951;\n\tWed, 26 Mar 2025 09:00:52 +0100 (CET)",
            "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 14AB768951\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 26 Mar 2025 09:00:50 +0100 (CET)",
            "from neptunite.flets-east.jp (unknown\n\t[IPv6:2404:7a81:160:2100:7402:917d:ea0c:6d4c])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 224C23A4;\n\tWed, 26 Mar 2025 08:59:00 +0100 (CET)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"juz7gufD\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1742975942;\n\tbh=xflUdtGNRSQk3YX26MXTAQ20Q9y4NH0GeFwii+zNx74=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=juz7gufDvKLDfUTNTncvjzM1WrDJg00l6J1nkTlzib/JX58LyvwEOZ3FT588884Pq\n\tcyQrvrO9i+W57n/nSj+38+KKQYgQKXzkETnir94c/VZ7m2/tLjHuFEp/ay0uwRVRh+\n\trSNILWghfcAVo6gtAu7dxtkSgKXgEvg1R7Qg+KyI=",
        "From": "Paul Elder <paul.elder@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Cc": "Kieran Bingham <kieran.bingham@ideasonboard.com>,\n\tPaul Elder <paul.elder@ideasonboard.com>",
        "Subject": "[PATCH v2 3/3] libipa: camera_sensor_helper: Fix rounding of\n\tgainCode",
        "Date": "Wed, 26 Mar 2025 17:00:33 +0900",
        "Message-ID": "<20250326080034.1733385-4-paul.elder@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.47.2",
        "In-Reply-To": "<20250326080034.1733385-1-paul.elder@ideasonboard.com>",
        "References": "<20250326080034.1733385-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": "From: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\nThe implementation of gainCode for both Exponential and Linear gain\nmodels does not generate a gainCode that matches the result of the\nreverse operation.\n\nThis can be seen by converting sequential gainCodes to a gain\nand converting that back to the gainCode. The values do not\ntranslate back due to rounding errors.\n\nCorrect the rounding error and ensure that gainCode translation\nproduces accurate bi-directional conversions from the perspective\nof the gainCode.\n\nThis fixes the IMX290, IMX296, IMX327 and IMX335 which use the\nExponential gain model helpers, as well as IMX219 IMX258 and IMX477\nwhich use the Linear gain model helpers.\n\nSigned-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\nSigned-off-by: Paul Elder <paul.elder@ideasonboard.com>\n\n---\nChanges in v2:\n- recover from bitrot\n---\n src/ipa/libipa/camera_sensor_helper.cpp | 6 +++---\n 1 file changed, 3 insertions(+), 3 deletions(-)",
    "diff": "diff --git a/src/ipa/libipa/camera_sensor_helper.cpp b/src/ipa/libipa/camera_sensor_helper.cpp\nindex 7c66cd57d685..5645dd14fda3 100644\n--- a/src/ipa/libipa/camera_sensor_helper.cpp\n+++ b/src/ipa/libipa/camera_sensor_helper.cpp\n@@ -90,12 +90,12 @@ uint32_t CameraSensorHelper::gainCode(double gain) const\n \tif (auto *l = std::get_if<AnalogueGainLinear>(&gain_)) {\n \t\tASSERT(l->m0 == 0 || l->m1 == 0);\n \n-\t\treturn (l->c0 - l->c1 * gain) /\n-\t\t       (l->m1 * gain - l->m0);\n+\t\treturn std::round((l->c0 - l->c1 * gain) /\n+\t\t\t\t  (l->m1 * gain - l->m0));\n \t} else if (auto *e = std::get_if<AnalogueGainExp>(&gain_)) {\n \t\tASSERT(e->a != 0 && e->m != 0);\n \n-\t\treturn std::log2(gain / e->a) / e->m;\n+\t\treturn std::round(std::log2(gain / e->a) / e->m);\n \t} else {\n \t\tASSERT(false);\n \t\treturn 0;\n",
    "prefixes": [
        "v2",
        "3/3"
    ]
}