{"id":24552,"url":"https://patchwork.libcamera.org/api/1.1/patches/24552/?format=json","web_url":"https://patchwork.libcamera.org/patch/24552/","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":"<20251002133523.293413-5-naush@raspberrypi.com>","date":"2025-10-02T13:26:07","name":"[v1,4/4] ipa: rpi: pisp: Allow an initial decompand curve to be set on the FE","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"3ce0050bfe066de16de11f0310960fa9799775d9","submitter":{"id":34,"url":"https://patchwork.libcamera.org/api/1.1/people/34/?format=json","name":"Naushir Patuck","email":"naush@raspberrypi.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/24552/mbox/","series":[{"id":5474,"url":"https://patchwork.libcamera.org/api/1.1/series/5474/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=5474","date":"2025-10-02T13:26:03","name":"Raspberry Pi: Decompanding support","version":1,"mbox":"https://patchwork.libcamera.org/series/5474/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/24552/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/24552/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 42017C328C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  2 Oct 2025 13:35:41 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 985506B615;\n\tThu,  2 Oct 2025 15:35:39 +0200 (CEST)","from mail-wm1-x330.google.com (mail-wm1-x330.google.com\n\t[IPv6:2a00:1450:4864:20::330])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 1FF326B5F9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  2 Oct 2025 15:35:33 +0200 (CEST)","by mail-wm1-x330.google.com with SMTP id\n\t5b1f17b1804b1-45a1b0ce15fso690175e9.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 02 Oct 2025 06:35:33 -0700 (PDT)","from NAUSH-P-DELL.pitowers.org ([93.93.133.154])\n\tby smtp.gmail.com with ESMTPSA id\n\t5b1f17b1804b1-46e6918bdebsm40396015e9.9.2025.10.02.06.35.31\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tThu, 02 Oct 2025 06:35:31 -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=\"ESd4XYu/\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google; t=1759412132; x=1760016932;\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=Xh7vT5smofoDWv6eoWK8ZtPETUG17hmhKYV54w92rXI=;\n\tb=ESd4XYu/ae9+XlIMsUGyvWLWi3HEsQZkywbiYMFpp2ID/RTMPKjof3WLJ5MbIgU78N\n\tfFhP0oq4emY/t4ao0JUyjFw+FjFax42OLmIJwIzw/gzcwmAVYxDAGqiiBlDzPELlgi2K\n\tx0jG46h04bdeN3KsGBXjFr71Qjh9BBq+iGZB28aE4DWGbg7x7nfgJXOYslFACuHCzgOo\n\toNPFZUswgYPO4UXDDHcdUkjSOAwNgaPJXssLqIsoLXH1/Es9bUTzxPEsZ2Ff2bc6Yblo\n\tmQMzzW5ptZkotHJCEMfJf5VaOENr/zIUESGevFknZ7Q8bvMQ6nj1tH04vCkRKzwuXAWO\n\t/cnw==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1759412132; x=1760016932;\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=Xh7vT5smofoDWv6eoWK8ZtPETUG17hmhKYV54w92rXI=;\n\tb=FTCgGHwEX7dKM5TkkroT+U3pRVvmPn+PKFacHdzFIk4WgH3fnl845QXgkTil0ipNrp\n\tBWrKYS8VksiHKli6Axd3X+X7MxQ0h4uE/UOH6GjiEBPm7hY45auDAsVe8X1OBE0kE7qV\n\tOdVFXjb/fL4pqBWEDJfqt+bl/cYYY5rjERMCBirwATufszXp0A9AGpm4hu4fnWnfMPqO\n\tlc7I3roJ+WKmhaG8xy1zoEGHbyxH9JOT7ykuFHSw7JLeh4dTMAMaL4kSESNQhC16ztui\n\tps6E75AVx6sYMJgFgarvwKNBvOJ7ReXgP40t/HLzT8TSI11/5hiNlLAR4egiIk9ArnN1\n\t/KxA==","X-Gm-Message-State":"AOJu0YwQPiZgQw4aM3QEuS9MY0Ead6zM2eeF6FxiYZk3xzgkcoG6kwRK\n\t9+xn7atu6QnUe4MCe5dtKRbE8QmegKsrYUpOLkRVKxKvRXlH44vgmPzuJBFcda0XynSeU6GRJml\n\tX0JDU","X-Gm-Gg":"ASbGncupirG1jAA+Mhh+bgcr8d79kvpEFJiWzarJcQjZ4BXbJTa4b2//OXq8ZvINIWt\n\tTh5WqcWmMA+hcD0xLz8AbLY1zEXZgwlyy2PL7YTWXze5ZP6JYMZZKVLFtGJEZTu7kZw8Vefkp8R\n\tSYKOi5By0udTG6ONky7KCYuNNav8cXybGsWUQGn7IKpd9pYHEIqU0fYElCg37KyIJ9dfie0rWWl\n\t/fP+y4AXoEbeAyEgLjQUFA9mAJiMA+NF826/nkBCa2sngpenFRmvY52hMp92/bienw0fiNEmR5P\n\tBWtAIX2ZwyYJpKKhyDUotBvciM60lcg8T7Xca5Q6doeHi0+H9gNaFIsScuHnM3c2MMzksSz8SiJ\n\tOjgQXOQBiqYFA7zYbdAc9VIz1k9Fj6G0DlQjpowwalfhpcfvuQYmz2gMbVFh6XfKX4Q==","X-Google-Smtp-Source":"AGHT+IESYDyvTST5yH8XdBP+8u4JtabcdFNz3aKpmfK9U+lSFwxjKnlC1CuX1lTzBc4c8WecqC1Bzw==","X-Received":"by 2002:a05:600c:4fd4:b0:468:7a5a:14cc with SMTP id\n\t5b1f17b1804b1-46e61263eb4mr29697955e9.3.1759412132294; \n\tThu, 02 Oct 2025 06:35: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 v1 4/4] ipa: rpi: pisp: Allow an initial decompand curve to\n\tbe set on the FE","Date":"Thu,  2 Oct 2025 14:26:07 +0100","Message-ID":"<20251002133523.293413-5-naush@raspberrypi.com>","X-Mailer":"git-send-email 2.43.0","In-Reply-To":"<20251002133523.293413-1-naush@raspberrypi.com>","References":"<20251002133523.293413-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>\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 b450436806e1..2c3bf7ee4d11 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([[maybe_unused]] 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 321a561ab141..2c44b09e4192 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 03c6c47c1bd9..134fc5aab12d 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":["v1","4/4"]}