{"id":19164,"url":"https://patchwork.libcamera.org/api/patches/19164/?format=json","web_url":"https://patchwork.libcamera.org/patch/19164/","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":"<20231020084002.30665-4-naush@raspberrypi.com>","date":"2023-10-20T08:39:59","name":"[libcamera-devel,v1,3/6] ipa: rpi: agc: Allow AGC channels to avoid using \"fast desaturation\"","commit_ref":"edb48a1337114e0b92caa54598397ce69c63a528","pull_url":null,"state":"accepted","archived":false,"hash":"4af447b955d806124064f0a46a4abd677645509a","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/19164/mbox/","series":[{"id":4054,"url":"https://patchwork.libcamera.org/api/series/4054/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=4054","date":"2023-10-20T08:39:56","name":"Raspberry Pi: Preliminary PiSP support (round 2)","version":1,"mbox":"https://patchwork.libcamera.org/series/4054/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/19164/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/19164/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 AC460C32B6\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 20 Oct 2023 08:40:34 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id BCA9762987;\n\tFri, 20 Oct 2023 10:40:32 +0200 (CEST)","from mail-wr1-x432.google.com (mail-wr1-x432.google.com\n\t[IPv6:2a00:1450:4864:20::432])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id ECF7D62984\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 20 Oct 2023 10:40:29 +0200 (CEST)","by mail-wr1-x432.google.com with SMTP id\n\tffacd0b85a97d-32dbbf3c782so992820f8f.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 20 Oct 2023 01:40:29 -0700 (PDT)","from localhost.localdomain ([93.93.133.154])\n\tby smtp.gmail.com with ESMTPSA id\n\tr3-20020adff103000000b0032d9337e7d1sm1213356wro.11.2023.10.20.01.40.28\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tFri, 20 Oct 2023 01:40:28 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1697791232;\n\tbh=O4EfPYpoC00m4LTRVzGgk9BD6iEN24IqpLUu8p8OkxY=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=xN53IYytQYZ4xUH8ikmz8UkBedqWG4lcjZdPGmPAC2y6gp6FWh+13+WL8+//ewqyu\n\tZSQuGKgr1GjIk0JM52mG+1y3noMv6K8DOH4j0+M+D6T4mghKRVHlKpqeAQ36wWj2f0\n\tOO3A1UZcWyjifP6WrII9qEFwlZU6pmzmcZ46KGTfhkVLtYjOgey2nH4DeFA8SrGzeR\n\tgf2KjMpFgQRDPIbXlh4LBu5EWWci/+CfpGjKAVpBYTWPC2xl5uKquZbpynxVO7ZfGw\n\tB/PAfDzaeptDJeDpVfpnMEDAGuSE3azushlkMid7oL6iNq5Z66DiC28l8cUX0djac1\n\t3sdcd5LzcOxXQ==","v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google; t=1697791229; x=1698396029;\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=Q4kaeNRdLIkQc2M7j/gKLsUZmKM45BzBHk+4nObYgw8=;\n\tb=Gu+RZyUPk4ANqoOFkzWA3PveDthywZerhOT07j/BHuKYcuVTjHBTNhRZlmUFGQZB1v\n\t+NqGgQP2yH7vEbTCAimqfBOrtPP0MCwl/L5oJYadNeWYhiRixxb/92hnHyWskuMy1p5M\n\ttvYUCpRlW/+jEvxbLdZVfo8Q+lLzPWX2WCEmyzrIjpzYG37HUPx1Qh5Vu6plDQtY8EY/\n\tEvFfjuPleyWOHh/+5PkZnCJqyDeCgZBCQbmy0afgqy1l/hZsLF91j+WfpW0uPfnd3Ubm\n\thPWGFX59XZiY5E4VzcdprVk4e9rPW//AyPyOt4HCLwCpmh/tltBgJfIoGMZ1tl6EAAXb\n\tA9Ow=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"Gu+RZyUP\"; dkim-atps=neutral","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1697791229; x=1698396029;\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=Q4kaeNRdLIkQc2M7j/gKLsUZmKM45BzBHk+4nObYgw8=;\n\tb=iykpwBGSCT1qVffIBaSKwlM3qrE3T10qTil+hiwPJxUEBfR2Io9vAe53vOFZdg3rqR\n\tifPu3SfP+EPWLXW6lJADO37JRdAbafMVPFj2tEskq+bD1rGGXin+eCtAhPLceoEWGOFr\n\t+V/A7SSCyPGve3DOQNg9pG0DOqAF7ahxgxPUzCRsARpREtlKHj7DPYX/VV1cg7yQEcDq\n\tm1R0lyI7rMTWCfTrxusd/26La7Z8jdgYV0CM0JrD6VdVYZg5hpTC3bQ9SkekH59dUXrS\n\tuAtMt8sbbAB/b9p8YDPpccI+nqrX91i5FdgL6+slGz8TaOno3q7xQ0UF+sAWyYO8fgkb\n\td8oA==","X-Gm-Message-State":"AOJu0YxmnKBsJheH2qvXn2P5Oh9JRdsFXZGDSuHk9NN03kGpE5jtvoM2\n\tYeWQkskbGRKFx1ohwcVBWb0QcWUmPTxKWfJkkKTtkw==","X-Google-Smtp-Source":"AGHT+IEd0EofWbyecqtYAN7ea7OjImBfMEXKE/z25K8Toj8u+pgb7DTHIrQDup9AcWrX1kQGi4ClbA==","X-Received":"by 2002:adf:ec49:0:b0:32d:c705:3e5 with SMTP id\n\tw9-20020adfec49000000b0032dc70503e5mr3909683wrn.15.1697791229046; \n\tFri, 20 Oct 2023 01:40:29 -0700 (PDT)","To":"libcamera-devel@lists.libcamera.org","Date":"Fri, 20 Oct 2023 09:39:59 +0100","Message-Id":"<20231020084002.30665-4-naush@raspberrypi.com>","X-Mailer":"git-send-email 2.34.1","In-Reply-To":"<20231020084002.30665-1-naush@raspberrypi.com>","References":"<20231020084002.30665-1-naush@raspberrypi.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v1 3/6] ipa: rpi: agc: Allow AGC channels\n\tto avoid using \"fast desaturation\"","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>","From":"Naushir Patuck via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Naushir Patuck <naush@raspberrypi.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"From: David Plowman <david.plowman@raspberrypi.com>\n\n\"Fast desaturation\" is a technique that can help the AGC algorithm to\ndesaturate images more quickly when they are very\nover-exposed. However, it uses digital gain to do this which can\nconfuse our HDR techniques. Therefore make it optional.\n\nSigned-off-by: David Plowman <david.plowman@raspberrypi.com>\nReviewed-by: Naushir Patuck <naush@raspberrypi.com>\n---\n src/ipa/rpi/controller/rpi/agc_channel.cpp | 8 ++++++--\n src/ipa/rpi/controller/rpi/agc_channel.h   | 1 +\n 2 files changed, 7 insertions(+), 2 deletions(-)","diff":"diff --git a/src/ipa/rpi/controller/rpi/agc_channel.cpp b/src/ipa/rpi/controller/rpi/agc_channel.cpp\nindex 1e7eae06d425..3efb6482b67f 100644\n--- a/src/ipa/rpi/controller/rpi/agc_channel.cpp\n+++ b/src/ipa/rpi/controller/rpi/agc_channel.cpp\n@@ -253,6 +253,8 @@ int AgcConfig::read(const libcamera::YamlObject &params)\n \n \tstableRegion = params[\"stable_region\"].get<double>(0.02);\n \n+\tdesaturate = params[\"desaturate\"].get<int>(1);\n+\n \treturn 0;\n }\n \n@@ -860,8 +862,10 @@ bool AgcChannel::applyDigitalGain(double gain, double targetY, bool channelBound\n \t * quickly (and we then approach the correct value more quickly from\n \t * below).\n \t */\n-\tbool desaturate = !channelBound &&\n-\t\t\t  targetY > config_.fastReduceThreshold && gain < sqrt(targetY);\n+\tbool desaturate = false;\n+\tif (config_.desaturate)\n+\t\tdesaturate = !channelBound &&\n+\t\t\t     targetY > config_.fastReduceThreshold && gain < sqrt(targetY);\n \tif (desaturate)\n \t\tdg /= config_.fastReduceThreshold;\n \tLOG(RPiAgc, Debug) << \"Digital gain \" << dg << \" desaturate? \" << desaturate;\ndiff --git a/src/ipa/rpi/controller/rpi/agc_channel.h b/src/ipa/rpi/controller/rpi/agc_channel.h\nindex c1808422498a..4cf7233eef25 100644\n--- a/src/ipa/rpi/controller/rpi/agc_channel.h\n+++ b/src/ipa/rpi/controller/rpi/agc_channel.h\n@@ -76,6 +76,7 @@ struct AgcConfig {\n \tlibcamera::utils::Duration defaultExposureTime;\n \tdouble defaultAnalogueGain;\n \tdouble stableRegion;\n+\tbool desaturate;\n };\n \n class AgcChannel\n","prefixes":["libcamera-devel","v1","3/6"]}