{"id":24561,"url":"https://patchwork.libcamera.org/api/patches/24561/?format=json","web_url":"https://patchwork.libcamera.org/patch/24561/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/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":"<20251003121821.659081-5-naush@raspberrypi.com>","date":"2025-10-03T12:15:55","name":"[v2,4/4] ipa: rpi: pisp: Allow an initial decompand curve to be set on the FE","commit_ref":"b320b20db7f014564e987704b31838c9b0ad688c","pull_url":null,"state":"accepted","archived":false,"hash":"3ce0050bfe066de16de11f0310960fa9799775d9","submitter":{"id":34,"url":"https://patchwork.libcamera.org/api/people/34/?format=json","name":"Naushir Patuck","email":"naush@raspberrypi.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/24561/mbox/","series":[{"id":5477,"url":"https://patchwork.libcamera.org/api/series/5477/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=5477","date":"2025-10-03T12:15:51","name":"Raspberry Pi: Decompanding support","version":2,"mbox":"https://patchwork.libcamera.org/series/5477/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/24561/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/24561/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 B4EFDC324C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri,  3 Oct 2025 12:18:41 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 1EEBB6B5AA;\n\tFri,  3 Oct 2025 14:18:39 +0200 (CEST)","from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com\n\t[IPv6:2a00:1450:4864:20::32c])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 89F9B6B605\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  3 Oct 2025 14:18:33 +0200 (CEST)","by mail-wm1-x32c.google.com with SMTP id\n\t5b1f17b1804b1-46e38c21fafso4055545e9.2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 03 Oct 2025 05:18:33 -0700 (PDT)","from NAUSH-P-DELL.pitowers.org ([93.93.133.154])\n\tby smtp.gmail.com with ESMTPSA id\n\tffacd0b85a97d-4255d8f02a8sm7812529f8f.39.2025.10.03.05.18.32\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tFri, 03 Oct 2025 05:18:32 -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=\"QJEDlvE7\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google; t=1759493913; x=1760098713;\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=I7DihWxCBk0ycoGsfleZNkucjNC5ge4C2YuX1MZttNY=;\n\tb=QJEDlvE7jOKo7IZz96Rybb8xNtDIJ+SzkhsFuDabTDe5aCsZYJjqbnjgiuMG8/l1rf\n\tzAq6kJ3+SutCQ5a28AZJm9BI43cWoxxzK9QnWfTUo5U5NXrpB44IFWLOl9wMoZNiaCMc\n\tqsd+gEtWSKVzOceYbJflPSlBlStnXMuN1yWnXzkSw66pJYYTJPViowBn6ElCxx59Pvrx\n\t2SF5JI5VMuN03O2BzqPhPb0HMvp3FO26Wc9mrMx00ub5dekcgNsrNsQ6Hp71Dzi1MTH8\n\tPLvG7kVh3XzFbbO/kf3ZI0Z0j+6bLTUzAtPTWRjLWwEUZ8vwptLnx5yxjI+TiMqGs8Ub\n\txNKQ==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1759493913; x=1760098713;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc\n\t:subject:date:message-id:reply-to;\n\tbh=I7DihWxCBk0ycoGsfleZNkucjNC5ge4C2YuX1MZttNY=;\n\tb=oWkKGrX8497kGcw/+b9WSuwaJQ0p2FpHMmfmFTUU36ctOIihfwLWFr1PVv1zQrbexk\n\tLDMfc22gbvIlohSh641F/NzYbV62DWUfzDjV4ZMOC1PbIAfTNy8oWnTjCEp2Z+ggU3bd\n\t+AFKUKAwUq99FCBWQbCkCzOOVslfduEj3tsD5ZSP5kXbUCw15u4JdapVqUWRVA/A9fDn\n\ttdstG/nJ/wOHXy6cWBKduvjPv4C7BzuV3wbXzh78UgbWOnLx2YgjYLdfUivbcvcQ2JyZ\n\tDsVXzP/jaXmSuDcAVH2wVuFfButWgyhlramLERihhdNJf5k7z0a/gG6w+npgasB1LPF/\n\tkxug==","X-Gm-Message-State":"AOJu0YwEi7WVE16sRBWn5fe1//lYSHTCrT2hHExiC3zb5dxug29Ojdsb\n\tLWSGr7N18TKwbJFzx3nhmjoI7tYLy9oizqWumAb9coiluuoqDU6TLzOSIfUE46qlf0TNljkv18x\n\t/epFc","X-Gm-Gg":"ASbGnctkq056eqRuIU4Os6zKJ6HZdkBeUhdV6OJcJla87PJsw68zXXk3hWIJ4ysTjvD\n\tHdb4ZcYoW4sAcAfBXrqvnm+Wzx9HVJouNr3VBhOGH8OqfUeNiygl78n6Jv7+Fr7r/pO2MvPgQSq\n\tF9EEx/9K+1CYdun7skadMNerJ7GOrXppPxZQhWzQNbZb4NN+6dxGVlvCKE5eQ/GmQF9wgnI28UE\n\tbK1OAjMTsOjXs1Y4Y11jhxTsznQY4MbSnl2GoKvTGSvEcjZm8H+xuz92+GsaZh59a2Le1a6bfgU\n\tou5yVudVvuF59piYNMyWXmCAzJRcJI9f1LgAk14MyfD9Pj0Eqq/Sohd1OP5ajqWTDkJ3t6X9Saf\n\tyfCOJ5Ui6NYaujqRYNb40pUTnF0U7M7abgeUCgxsf8Kx/fALo6omhjMMq30qNTSarQw==","X-Google-Smtp-Source":"AGHT+IHpQKvzmqrsiedJfORZYzWOTQuFiX20v6FQir53p0Dn0Gro1xjnak3/xHWTcjL463wE6Vl+eg==","X-Received":"by 2002:a05:600c:3510:b0:45d:f7df:270b with SMTP id\n\t5b1f17b1804b1-46e710b22c1mr11106185e9.0.1759493912657; \n\tFri, 03 Oct 2025 05:18:32 -0700 (PDT)","From":"Naushir Patuck <naush@raspberrypi.com>","To":"libcamera-devel@lists.libcamera.org","Cc":"David Plowman <david.plowman@raspberrypi.com>,\n\tNick Hollinghurst <nick.hollinghurst@raspberrypi.com>,\n\tNaushir Patuck <naush@raspberrypi.com>","Subject":"[PATCH v2 4/4] ipa: rpi: pisp: Allow an initial decompand curve to\n\tbe set on the FE","Date":"Fri,  3 Oct 2025 13:15:55 +0100","Message-ID":"<20251003121821.659081-5-naush@raspberrypi.com>","X-Mailer":"git-send-email 2.43.0","In-Reply-To":"<20251003121821.659081-1-naush@raspberrypi.com>","References":"<20251003121821.659081-1-naush@raspberrypi.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":"In the current code, decompand will only set a curve in the prepare\nphase, which will only run after 1-2 frames pass through the FE. This\nis fixed by adding an initialValues() member function to the decompand\nalgorithm, which will be called in the IPA before we start the hardware\nstreaming.\n\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\nTested-by: Nick Hollinghurst <nick.hollinghurst@raspberrypi.com>\n---\n src/ipa/rpi/controller/decompand_algorithm.h |  2 ++\n src/ipa/rpi/controller/rpi/decompand.cpp     |  8 ++++++++\n src/ipa/rpi/controller/rpi/decompand.h       |  1 +\n src/ipa/rpi/pisp/pisp.cpp                    | 15 +++++++++++++++\n 4 files changed, 26 insertions(+)","diff":"diff --git a/src/ipa/rpi/controller/decompand_algorithm.h b/src/ipa/rpi/controller/decompand_algorithm.h\nindex f19f8c109323..6d2467490106 100644\n--- a/src/ipa/rpi/controller/decompand_algorithm.h\n+++ b/src/ipa/rpi/controller/decompand_algorithm.h\n@@ -19,6 +19,8 @@ public:\n \t\t: Algorithm(controller)\n \t{\n \t}\n+\t/* A decompand algorithm must provide the following: */\n+\tvirtual void initialValues(libcamera::ipa::Pwl &decompandCurve) = 0;\n };\n \n } /* namespace RPiController */\ndiff --git a/src/ipa/rpi/controller/rpi/decompand.cpp b/src/ipa/rpi/controller/rpi/decompand.cpp\nindex 5b4c2e5524af..2d457926c060 100644\n--- a/src/ipa/rpi/controller/rpi/decompand.cpp\n+++ b/src/ipa/rpi/controller/rpi/decompand.cpp\n@@ -39,6 +39,14 @@ void Decompand::switchMode(CameraMode const &cameraMode,\n \tmode_ = cameraMode;\n }\n \n+void Decompand::initialValues(libcamera::ipa::Pwl &decompandCurve)\n+{\n+\tif (config_.bitdepth == 0 || mode_.bitdepth == config_.bitdepth) {\n+\t\tdecompandCurve = config_.decompandCurve;\n+\t} else\n+\t\tdecompandCurve = {};\n+}\n+\n void Decompand::prepare(Metadata *imageMetadata)\n {\n \tDecompandStatus decompandStatus;\ndiff --git a/src/ipa/rpi/controller/rpi/decompand.h b/src/ipa/rpi/controller/rpi/decompand.h\nindex 0f2a9b3bbdc4..6db779c359a8 100644\n--- a/src/ipa/rpi/controller/rpi/decompand.h\n+++ b/src/ipa/rpi/controller/rpi/decompand.h\n@@ -20,6 +20,7 @@ public:\n \tint read(const libcamera::YamlObject &params) override;\n \tvoid initialise() override;\n \tvoid switchMode(CameraMode const &cameraMode, Metadata *metadata) override;\n+\tvoid initialValues(libcamera::ipa::Pwl &decompandCurve) override;\n \tvoid prepare(Metadata *imageMetadata) override;\n \n private:\ndiff --git a/src/ipa/rpi/pisp/pisp.cpp b/src/ipa/rpi/pisp/pisp.cpp\nindex f5be39aca5ee..01baebcd2bb6 100644\n--- a/src/ipa/rpi/pisp/pisp.cpp\n+++ b/src/ipa/rpi/pisp/pisp.cpp\n@@ -32,6 +32,7 @@\n #include \"controller/cac_status.h\"\n #include \"controller/ccm_status.h\"\n #include \"controller/contrast_status.h\"\n+#include \"controller/decompand_algorithm.h\"\n #include \"controller/decompand_status.h\"\n #include \"controller/denoise_algorithm.h\"\n #include \"controller/denoise_status.h\"\n@@ -335,6 +336,20 @@ int32_t IpaPiSP::platformStart([[maybe_unused]] const ControlList &controls,\n \t/* Cause the stitch block to be reset correctly. */\n \tlastStitchHdrStatus_ = HdrStatus();\n \n+\t/* Setup a default decompand curve on startup if needed. */\n+\tRPiController::DecompandAlgorithm *decompand = dynamic_cast<RPiController::DecompandAlgorithm *>(\n+\t\tcontroller_.getAlgorithm(\"decompand\"));\n+\tif (decompand) {\n+\t\tstd::scoped_lock<FrontEnd> l(*fe_);\n+\t\tpisp_fe_global_config feGlobal;\n+\t\tDecompandStatus decompandStatus;\n+\n+\t\tfe_->GetGlobal(feGlobal);\n+\t\tdecompand->initialValues(decompandStatus.decompandCurve);\n+\t\tapplyDecompand(&decompandStatus, feGlobal);\n+\t\tfe_->SetGlobal(feGlobal);\n+\t}\n+\n \treturn 0;\n }\n \n","prefixes":["v2","4/4"]}