Show a patch.

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

{
    "id": 25539,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/25539/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/25539/",
    "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": "<20251212002937.3118-25-bryan.odonoghue@linaro.org>",
    "date": "2025-12-12T00:29:35",
    "name": "[v8,24/26] libcamera: software_isp: lut: Skip calculation lookup tables if gpuIspEnabled is true",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "d41e5eb8481fc103a2c49de9204e1adfdc672e39",
    "submitter": {
        "id": 175,
        "url": "https://patchwork.libcamera.org/api/1.1/people/175/?format=api",
        "name": "Bryan O'Donoghue",
        "email": "bryan.odonoghue@linaro.org"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/25539/mbox/",
    "series": [
        {
            "id": 5657,
            "url": "https://patchwork.libcamera.org/api/1.1/series/5657/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5657",
            "date": "2025-12-12T00:29:11",
            "name": "Add GLES 2.0 GPUISP to libcamera",
            "version": 8,
            "mbox": "https://patchwork.libcamera.org/series/5657/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/25539/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/25539/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 1CDDCBD1F1\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 12 Dec 2025 00:34:40 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id D027E61925;\n\tFri, 12 Dec 2025 01:34:39 +0100 (CET)",
            "from mail-pf1-x434.google.com (mail-pf1-x434.google.com\n\t[IPv6:2607:f8b0:4864:20::434])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id F26C06191A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 12 Dec 2025 01:34:37 +0100 (CET)",
            "by mail-pf1-x434.google.com with SMTP id\n\td2e1a72fcca58-7baf61be569so781715b3a.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 11 Dec 2025 16:34:37 -0800 (PST)",
            "from inspiron14p-linux (p99250-ipoefx.ipoe.ocn.ne.jp.\n\t[153.246.134.249]) by smtp.gmail.com with ESMTPSA id\n\t41be03b00d2f7-c0c26eb0f6bsm3317282a12.14.2025.12.11.16.34.33\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tThu, 11 Dec 2025 16:34:35 -0800 (PST)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (2048-bit key;\n\tunprotected) header.d=linaro.org header.i=@linaro.org\n\theader.b=\"N0qJADf+\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=linaro.org; s=google; t=1765499676; x=1766104476;\n\tdarn=lists.libcamera.org; \n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:from:to:cc:subject:date\n\t:message-id:reply-to;\n\tbh=0x9sYofuRKBarctBdgKuhUSV0fpuyAnEk7YI+eA7X6s=;\n\tb=N0qJADf+pAbtIGAWqHwQz6dhJafgy2ugKOqKOOuseDocugzToWSit+jC92oWIwO3Qx\n\tk+1518pgNxjZ5RiLpw2GfRnItU/afI8nr6OiriPo7QybKc5/EE8nR8Cc9KAsgUe1/jgO\n\tWJtnTUNvXLQMZlGMGIPwl3m/blZeioEbs1gaIpVrnAvZ8jRIjG2TqyLOlgDIkQivQIS8\n\tB/zWEPNmcQvAZi6ppfpdA8/jZkA2kyWl8o4Kba+CeFLty810sd+iBUeZrXCbYdgPxxMV\n\teByd9yiKCipJOH/A9bPurSe1SfLp6TU90C2IiZhrCrNbHk4QVc9FgmKgcskM7L5wqVZt\n\tTFXQ==",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1765499676; x=1766104476;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from\n\t:to:cc:subject:date:message-id:reply-to;\n\tbh=0x9sYofuRKBarctBdgKuhUSV0fpuyAnEk7YI+eA7X6s=;\n\tb=efrs88P9AX0hlFS3hpO62toVfTzfGXLAdM7Vk6t3aOIDpfXFtpX6/F+seIuuplD1MY\n\t2O26puunal1cxxgyRCeeL4z9csM3NGBYHnBa/NL1H6KMoqd3bKqpKW4oCVh2SieyoQug\n\tAi2Yid6N462yF1RrJqhO2g/SrYhhaHaIQpJGkfOW9Oawkui10iymBZ2o2+vQ2OLTvQUZ\n\tWYAyqGhkjAfao+KTWV53owPDeCMy/bHYQx2Y4M8mAeMtHfzP/e8EI5kEmNHZKt/mHJZQ\n\tpSd4Zv8Jv37zCFXZFWY2uOmgnG7uJGLlW4bIK2V/DuQYHGcZyIJWGrqwVNm1LjzY7DL0\n\t5M8w==",
        "X-Gm-Message-State": "AOJu0Yz3w1uaixdKSgAzy5tN9eLs6mrE4m9BiWZcdICtZL5iiPXJDIUr\n\tkVaTeYN98D/S3atWWX7j8rquskflyVZYLrTgyfqsYjEHkMfoaHBKokffZ3lDhHJxzp0Dlm+MZhr\n\tmFX3F",
        "X-Gm-Gg": "AY/fxX6j40SSIm15JseH6HpJMETyRFXeeMdASMohAuUZiafDaQ8WgPXBL304roddI4P\n\tL+Aiwas/d6BoDWO+qomBTzJ7uWi4g7bV6IVZnVEzUhDTDFtWujrSjOLWSROiCC06IvAvY6/lQf5\n\trOrsI0uCZT+2BEx26Qe6lZIEbw4spRZXSNO1uBA+aE2+QEJ95Hg5WNolBw7W5MvNStX36GxrAMP\n\tzA7UMyb1O6+pdHbUVgTyNyOinjgeisrSXZoYKaO5HVAWJeL/tkJY3Ho+aVh9y2lEKsoNswE4P7K\n\tl7rzRKMWo4ulxCBkwpT27VGA6zJvX/9vWtQynsa5ZNTP60WZzY8lWfNi2AjHEgeprVsUJ6SOhIK\n\ttA6YJab5b40QUCl7kgXkaP3hvcVfI7vlPgPU6FuYELvHs7fOJbDocPK0YtxIYGLdlrBy60/lLi9\n\toaPr1xVkgUJFP3/DYfDLX4vWgfULac8+OpiDUxXf19anlkvPsso/hKCgVodtK/4fRNBMsjsA==",
        "X-Google-Smtp-Source": "AGHT+IGUw1KdU7VqkmWHA9in62nj+LUg9oDUHiiMOBlLI6S7XbKMUf4eiFy+vtAOg5BVaG4tnaMPkA==",
        "X-Received": "by 2002:a05:6a21:e082:b0:366:14ac:8c67 with SMTP id\n\tadf61e73a8af0-369affed061mr301899637.61.1765499676289; \n\tThu, 11 Dec 2025 16:34:36 -0800 (PST)",
        "From": "Bryan O'Donoghue <bryan.odonoghue@linaro.org>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Cc": "pavel@ucw.cz, Bryan O'Donoghue <bryan.odonoghue@linaro.org>,\n\tMilan Zamazal <mzamazal@redhat.com>",
        "Subject": "[PATCH v8 24/26] libcamera: software_isp: lut: Skip calculation\n\tlookup tables if gpuIspEnabled is true",
        "Date": "Fri, 12 Dec 2025 00:29:35 +0000",
        "Message-ID": "<20251212002937.3118-25-bryan.odonoghue@linaro.org>",
        "X-Mailer": "git-send-email 2.52.0",
        "In-Reply-To": "<20251212002937.3118-1-bryan.odonoghue@linaro.org>",
        "References": "<20251212002937.3118-1-bryan.odonoghue@linaro.org>",
        "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": "On my reference platform Qualcomm RB5 sm8520 the qcam application CPU\noccupancy drops from ~100% to about 95% of a single core so this one change\nsheds aprox 5% CPU usage.\n\nReviewed-by: Milan Zamazal <mzamazal@redhat.com>\nSigned-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>\n---\n src/ipa/simple/algorithms/lut.cpp | 70 ++++++++++++++++---------------\n 1 file changed, 37 insertions(+), 33 deletions(-)",
    "diff": "diff --git a/src/ipa/simple/algorithms/lut.cpp b/src/ipa/simple/algorithms/lut.cpp\nindex 9aaab54f1..adf411768 100644\n--- a/src/ipa/simple/algorithms/lut.cpp\n+++ b/src/ipa/simple/algorithms/lut.cpp\n@@ -56,32 +56,34 @@ void Lut::queueRequest(typename Module::Context &context,\n \n void Lut::updateGammaTable(IPAContext &context)\n {\n-\tauto &gammaTable = context.activeState.gamma.gammaTable;\n \tconst auto blackLevel = context.activeState.blc.level;\n-\tconst unsigned int blackIndex = blackLevel * gammaTable.size() / 256;\n \tconst auto contrast = context.activeState.knobs.contrast.value_or(1.0);\n \n-\tconst float divisor = gammaTable.size() - blackIndex - 1.0;\n-\tfor (unsigned int i = blackIndex; i < gammaTable.size(); i++) {\n-\t\tdouble normalized = (i - blackIndex) / divisor;\n-\t\t/* Convert 0..2 to 0..infinity; avoid actual inifinity at tan(pi/2) */\n-\t\tdouble contrastExp = tan(std::clamp(contrast * M_PI_4, 0.0, M_PI_2 - 0.00001));\n-\t\t/* Apply simple S-curve */\n-\t\tif (normalized < 0.5)\n-\t\t\tnormalized = 0.5 * std::pow(normalized / 0.5, contrastExp);\n-\t\telse\n-\t\t\tnormalized = 1.0 - 0.5 * std::pow((1.0 - normalized) / 0.5, contrastExp);\n-\t\tgammaTable[i] = UINT8_MAX *\n-\t\t\t\tstd::pow(normalized, context.configuration.gamma);\n+\tif (!context.gpuIspEnabled) {\n+\t\tauto &gammaTable = context.activeState.gamma.gammaTable;\n+\t\tconst unsigned int blackIndex = blackLevel * gammaTable.size() / 256;\n+\t\tconst float divisor = gammaTable.size() - blackIndex - 1.0;\n+\t\tfor (unsigned int i = blackIndex; i < gammaTable.size(); i++) {\n+\t\t\tdouble normalized = (i - blackIndex) / divisor;\n+\t\t\t/* Convert 0..2 to 0..infinity; avoid actual inifinity at tan(pi/2) */\n+\t\t\tdouble contrastExp = tan(std::clamp(contrast * M_PI_4, 0.0, M_PI_2 - 0.00001));\n+\t\t\t/* Apply simple S-curve */\n+\t\t\tif (normalized < 0.5)\n+\t\t\t\tnormalized = 0.5 * std::pow(normalized / 0.5, contrastExp);\n+\t\t\telse\n+\t\t\t\tnormalized = 1.0 - 0.5 * std::pow((1.0 - normalized) / 0.5, contrastExp);\n+\t\t\tgammaTable[i] = UINT8_MAX *\n+\t\t\t\t\tstd::pow(normalized, context.configuration.gamma);\n+\t\t}\n+\t\t/*\n+\t\t * Due to CCM operations, the table lookup may reach indices below the black\n+\t\t * level. Let's set the table values below black level to the minimum\n+\t\t * non-black value to prevent problems when the minimum value is\n+\t\t * significantly non-zero (for example, when the image should be all grey).\n+\t\t */\n+\t\tstd::fill(gammaTable.begin(), gammaTable.begin() + blackIndex,\n+\t\t\t  gammaTable[blackIndex]);\n \t}\n-\t/*\n-\t * Due to CCM operations, the table lookup may reach indices below the black\n-\t * level. Let's set the table values below black level to the minimum\n-\t * non-black value to prevent problems when the minimum value is\n-\t * significantly non-zero (for example, when the image should be all grey).\n-\t */\n-\tstd::fill(gammaTable.begin(), gammaTable.begin() + blackIndex,\n-\t\t  gammaTable[blackIndex]);\n \n \tcontext.activeState.gamma.blackLevel = blackLevel;\n \tcontext.activeState.gamma.contrast = contrast;\n@@ -134,17 +136,19 @@ void Lut::prepare(IPAContext &context,\n \t\tauto &green = params->greenCcm;\n \t\tauto &blue = params->blueCcm;\n \t\tparams->ccm = ccm;\n-\t\tfor (unsigned int i = 0; i < DebayerParams::kRGBLookupSize; i++) {\n-\t\t\tred[i].r = ccmValue(i, ccm[0][0]);\n-\t\t\tred[i].g = ccmValue(i, ccm[1][0]);\n-\t\t\tred[i].b = ccmValue(i, ccm[2][0]);\n-\t\t\tgreen[i].r = ccmValue(i, ccm[0][1]);\n-\t\t\tgreen[i].g = ccmValue(i, ccm[1][1]);\n-\t\t\tgreen[i].b = ccmValue(i, ccm[2][1]);\n-\t\t\tblue[i].r = ccmValue(i, ccm[0][2]);\n-\t\t\tblue[i].g = ccmValue(i, ccm[1][2]);\n-\t\t\tblue[i].b = ccmValue(i, ccm[2][2]);\n-\t\t\tparams->gammaLut[i] = gammaTable[i / div];\n+\t\tif (!context.gpuIspEnabled) {\n+\t\t\tfor (unsigned int i = 0; i < DebayerParams::kRGBLookupSize; i++) {\n+\t\t\t\tred[i].r = ccmValue(i, ccm[0][0]);\n+\t\t\t\tred[i].g = ccmValue(i, ccm[1][0]);\n+\t\t\t\tred[i].b = ccmValue(i, ccm[2][0]);\n+\t\t\t\tgreen[i].r = ccmValue(i, ccm[0][1]);\n+\t\t\t\tgreen[i].g = ccmValue(i, ccm[1][1]);\n+\t\t\t\tgreen[i].b = ccmValue(i, ccm[2][1]);\n+\t\t\t\tblue[i].r = ccmValue(i, ccm[0][2]);\n+\t\t\t\tblue[i].g = ccmValue(i, ccm[1][2]);\n+\t\t\t\tblue[i].b = ccmValue(i, ccm[2][2]);\n+\t\t\t\tparams->gammaLut[i] = gammaTable[i / div];\n+\t\t\t}\n \t\t}\n \t}\n \n",
    "prefixes": [
        "v8",
        "24/26"
    ]
}