{"id":26376,"url":"https://patchwork.libcamera.org/api/1.1/patches/26376/?format=json","web_url":"https://patchwork.libcamera.org/patch/26376/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20260326164241.4212-1-david.plowman@raspberrypi.com>","date":"2026-03-26T16:40:39","name":"[v1] ipa: rpi: Fix gamma lookup table generation for PiSP platform","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"369e3adb69ff32e07a9a3d6079f21d0f9274a8ca","submitter":{"id":42,"url":"https://patchwork.libcamera.org/api/1.1/people/42/?format=json","name":"David Plowman","email":"david.plowman@raspberrypi.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/26376/mbox/","series":[{"id":5851,"url":"https://patchwork.libcamera.org/api/1.1/series/5851/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=5851","date":"2026-03-26T16:40:39","name":"[v1] ipa: rpi: Fix gamma lookup table generation for PiSP platform","version":1,"mbox":"https://patchwork.libcamera.org/series/5851/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/26376/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/26376/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 3A3EABDCBD\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 26 Mar 2026 16:42:47 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 6F6A962857;\n\tThu, 26 Mar 2026 17:42:46 +0100 (CET)","from mail-wr1-x436.google.com (mail-wr1-x436.google.com\n\t[IPv6:2a00:1450:4864:20::436])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 94D0762781\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 26 Mar 2026 17:42:44 +0100 (CET)","by mail-wr1-x436.google.com with SMTP id\n\tffacd0b85a97d-439b94a19fdso1134253f8f.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 26 Mar 2026 09:42:44 -0700 (PDT)","from davidp-pi5.pitowers.org\n\t([2a00:1098:3142:1f:88ea:c658:5b20:5e46])\n\tby smtp.gmail.com with ESMTPSA id\n\tffacd0b85a97d-43b9194311asm10645942f8f.10.2026.03.26.09.42.43\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tThu, 26 Mar 2026 09:42:43 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key;\n\tunprotected) header.d=raspberrypi.com header.i=@raspberrypi.com\n\theader.b=\"OZVjvdLS\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google; t=1774543364; x=1775148164;\n\tdarn=lists.libcamera.org; \n\th=content-transfer-encoding:mime-version:message-id:date:subject:cc\n\t:to:from:from:to:cc:subject:date:message-id:reply-to;\n\tbh=nuYRDSgG0GT1fzVy5Qr5oT0sDbFnzsGae5sS6qP+qNU=;\n\tb=OZVjvdLS8j49M2bhjPhjyw6/LmvS13RvU7Ml7sZsq+/C24kcWCAZNUvZXYGx32FiNj\n\txoZS9belajjADMOhnUM4pQKKHuHWOd8JHyQFml77BSw9Mi4n3b4R9OtAsMq28QWx3DYN\n\td5tJSARn4uToD+VxADhyO1C6ywzGbF5XAdhs0iPH+k20dDKk04awz6pZT1G4XLmmsQ7r\n\txiN3bJMAnzF7U7XsFYuzfrm9f4MDKqQe9y/WCc5ZUsrVBCdnz4S/YJW4eQPnFLnZCdKa\n\tFalBFd67RDqGxKD4POaitYk+hd36VVgRF02abbaODP4geBp7LwsbC9rixkvKGIjASpgQ\n\tUdAg==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20251104; t=1774543364; x=1775148164;\n\th=content-transfer-encoding:mime-version:message-id:date:subject:cc\n\t:to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date\n\t:message-id:reply-to;\n\tbh=nuYRDSgG0GT1fzVy5Qr5oT0sDbFnzsGae5sS6qP+qNU=;\n\tb=Eh9boYmi8MRxVAhROgJaJYyZGLGa5rUsbgTjqbSZsQ3Q7cKUSevx9OHdEFZw/qu8z2\n\t7/QfS2Zkt2jZYunvElvj3mnhhOZY1krHP2RyTWUdk8IQcCaZKuF27Yz4G8ITpW353TUr\n\tqzGhM+TLtXruk/Dq28L3+OcsLowq1mdtP4z9/VtVIuPN1UxdzLZT9D0kvkjP0SfN4/PL\n\tHJNvUY5LFxou1U+1T9aQkkqpMGS+bqitDHec6ywNRQo6YW65HvTqCWwpwUNOYxvel1kB\n\tLGV4nyARbZX+X/nDvf2DhqLgB8JCsKC14rQwzArKwBDEwg74n1jnsqKUXuQUd6k+vTNE\n\t0bSw==","X-Gm-Message-State":"AOJu0YyQRpgTQ2Sn//2UFY7C1FaKFOlhhYymkoKAtPL6OccG+6V0SsBC\n\tX8XQK58dg/AnvB0wUMAoOgIezNuVq+XsvVtvoQFtKaCvzWeHDrGOiCLTeeFokqUfEC8lZYh70wj\n\t7G9B4","X-Gm-Gg":"ATEYQzw6kDSH9KyWReyEQl1jKYUD8hsm3Ja0nfPSk/aiA36LVywpfmVCi+lveNGvlq8\n\tq/aYzeKjxVP/64cZvHdL627sFEUXHw5l0RyYj0weL7ZZ2aXrKDwxKbUBfSaC1AH1gkGZUOUodoH\n\ttVP16KS/r/0M2dXJsSoHCYHkbR0W9/JSWO0zFtRXdo0wy2NgqP1rRw2e/RbWHfYxlBWWciRRALt\n\twAtwi/NZlc9fyIYBMV1U1gW4JPxc1WLvom1bLhi74mN88hvghsueo9iQR6EikMjJids3Bfgb678\n\t8pToAQUS4iFJiEGFZXqKDD0JlwNkisxwG1sWUQr8Ss5B8QFmQKtwkzAjKJiEs6bTKtcXSk6FDKM\n\tbkuAUkUF/eDyiH+3343u0qe3M9FtZBaluLBdb1+NSvkSvcb+OmQ83wfxbpwRnTfkrJR5vpdkCfO\n\tcck+G0IVKb3zMxGNsCB8Y4mF9RduyxMf8tfsVtL0jEz1bzxa2wkHHkY8Na2XgAT/B2p1p+T01bn\n\tZI58R7L74TzHDygG6EFmWkwZKwSE2gg9hxV930ihnPxBhACV91i","X-Received":"by 2002:a05:6000:400c:b0:43b:4077:c18b with SMTP id\n\tffacd0b85a97d-43b88a1e36bmr12684317f8f.46.1774543363710; \n\tThu, 26 Mar 2026 09:42:43 -0700 (PDT)","From":"David Plowman <david.plowman@raspberrypi.com>","To":"libcamera-devel@lists.libcamera.org","Cc":"David Plowman <david.plowman@raspberrypi.com>","Subject":"[PATCH v1] ipa: rpi: Fix gamma lookup table generation for PiSP\n\tplatform","Date":"Thu, 26 Mar 2026 16:40:39 +0000","Message-ID":"<20260326164241.4212-1-david.plowman@raspberrypi.com>","X-Mailer":"git-send-email 2.47.3","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":"generateLut was failing to fill in the final slope value, meaning that\nfully saturated pixels would full slightly short (the slope of the\nfinal piecewise linear segment would default to zero).\n\nThe loop is slightly reorganised to fix the problem.\n\nSigned-off-by: David Plowman <david.plowman@raspberrypi.com>\n---\n src/ipa/rpi/pisp/pisp.cpp | 42 +++++++++++++++++----------------------\n 1 file changed, 18 insertions(+), 24 deletions(-)","diff":"diff --git a/src/ipa/rpi/pisp/pisp.cpp b/src/ipa/rpi/pisp/pisp.cpp\nindex ec7593ff..851f9b30 100644\n--- a/src/ipa/rpi/pisp/pisp.cpp\n+++ b/src/ipa/rpi/pisp/pisp.cpp\n@@ -80,36 +80,30 @@ int generateLut(const ipa::Pwl &pwl, uint32_t *lut, std::size_t lutSize,\n \tif (pwl.empty())\n \t\treturn -EINVAL;\n \n-\tint lastY = 0;\n+\tint nextY = 0;\n \tfor (unsigned int i = 0; i < lutSize; i++) {\n-\t\tint x, y;\n-\t\tif (i < 32)\n-\t\t\tx = i * 512;\n-\t\telse if (i < 48)\n-\t\t\tx = (i - 32) * 1024 + 16384;\n+\t\tunsigned int nextI = i + 1;\n+\n+\t\tint nextX;\n+\t\tif (nextI < 32)\n+\t\t\tnextX = nextI * 512;\n+\t\telse if (nextI < 48)\n+\t\t\tnextX = (nextI - 32) * 1024 + 16384;\n \t\telse\n-\t\t\tx = std::min(65535u, (i - 48) * 2048 + 32768);\n+\t\t\tnextX = std::min(65535u, (nextI - 48) * 2048 + 32768);\n \n-\t\ty = pwl.eval(x);\n-\t\tif (y < 0 || (i && y < lastY)) {\n-\t\t\tLOG(IPARPI, Error)\n-\t\t\t\t<< \"Malformed PWL for Gamma, disabling!\";\n-\t\t\treturn -1;\n-\t\t}\n+\t\tint y = nextY;\n+\t\tnextY = pwl.eval(nextX);\n \n-\t\tif (i) {\n-\t\t\tunsigned int slope = y - lastY;\n-\t\t\tif (slope >= (1u << SlopeBits)) {\n-\t\t\t\tslope = (1u << SlopeBits) - 1;\n-\t\t\t\tLOG(IPARPI, Info)\n-\t\t\t\t\t<< (\"Maximum Gamma slope exceeded, adjusting!\");\n-\t\t\t\ty = lastY + slope;\n-\t\t\t}\n-\t\t\tlut[i - 1] |= slope << PosBits;\n+\t\tunsigned int slope = nextY - y;\n+\t\tif (slope >= (1u << SlopeBits)) {\n+\t\t\tslope = (1u << SlopeBits) - 1;\n+\t\t\tLOG(IPARPI, Info)\n+\t\t\t\t<< (\"Maximum Gamma slope exceeded, adjusting!\");\n+\t\t\tnextY = y + slope;\n \t\t}\n \n-\t\tlut[i] = y;\n-\t\tlastY = y;\n+\t\tlut[i] = y | (slope << PosBits);\n \t}\n \n \treturn 0;\n","prefixes":["v1"]}