From patchwork Fri Oct 20 08:39:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 19164 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id AC460C32B6 for ; Fri, 20 Oct 2023 08:40:34 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id BCA9762987; Fri, 20 Oct 2023 10:40:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1697791232; bh=O4EfPYpoC00m4LTRVzGgk9BD6iEN24IqpLUu8p8OkxY=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=xN53IYytQYZ4xUH8ikmz8UkBedqWG4lcjZdPGmPAC2y6gp6FWh+13+WL8+//ewqyu ZSQuGKgr1GjIk0JM52mG+1y3noMv6K8DOH4j0+M+D6T4mghKRVHlKpqeAQ36wWj2f0 OO3A1UZcWyjifP6WrII9qEFwlZU6pmzmcZ46KGTfhkVLtYjOgey2nH4DeFA8SrGzeR gf2KjMpFgQRDPIbXlh4LBu5EWWci/+CfpGjKAVpBYTWPC2xl5uKquZbpynxVO7ZfGw B/PAfDzaeptDJeDpVfpnMEDAGuSE3azushlkMid7oL6iNq5Z66DiC28l8cUX0djac1 3sdcd5LzcOxXQ== Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id ECF7D62984 for ; Fri, 20 Oct 2023 10:40:29 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="Gu+RZyUP"; dkim-atps=neutral Received: by mail-wr1-x432.google.com with SMTP id ffacd0b85a97d-32dbbf3c782so992820f8f.1 for ; Fri, 20 Oct 2023 01:40:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1697791229; x=1698396029; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Q4kaeNRdLIkQc2M7j/gKLsUZmKM45BzBHk+4nObYgw8=; b=Gu+RZyUPk4ANqoOFkzWA3PveDthywZerhOT07j/BHuKYcuVTjHBTNhRZlmUFGQZB1v +NqGgQP2yH7vEbTCAimqfBOrtPP0MCwl/L5oJYadNeWYhiRixxb/92hnHyWskuMy1p5M tvYUCpRlW/+jEvxbLdZVfo8Q+lLzPWX2WCEmyzrIjpzYG37HUPx1Qh5Vu6plDQtY8EY/ EvFfjuPleyWOHh/+5PkZnCJqyDeCgZBCQbmy0afgqy1l/hZsLF91j+WfpW0uPfnd3Ubm hPWGFX59XZiY5E4VzcdprVk4e9rPW//AyPyOt4HCLwCpmh/tltBgJfIoGMZ1tl6EAAXb A9Ow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697791229; x=1698396029; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Q4kaeNRdLIkQc2M7j/gKLsUZmKM45BzBHk+4nObYgw8=; b=iykpwBGSCT1qVffIBaSKwlM3qrE3T10qTil+hiwPJxUEBfR2Io9vAe53vOFZdg3rqR ifPu3SfP+EPWLXW6lJADO37JRdAbafMVPFj2tEskq+bD1rGGXin+eCtAhPLceoEWGOFr +V/A7SSCyPGve3DOQNg9pG0DOqAF7ahxgxPUzCRsARpREtlKHj7DPYX/VV1cg7yQEcDq m1R0lyI7rMTWCfTrxusd/26La7Z8jdgYV0CM0JrD6VdVYZg5hpTC3bQ9SkekH59dUXrS uAtMt8sbbAB/b9p8YDPpccI+nqrX91i5FdgL6+slGz8TaOno3q7xQ0UF+sAWyYO8fgkb d8oA== X-Gm-Message-State: AOJu0YxmnKBsJheH2qvXn2P5Oh9JRdsFXZGDSuHk9NN03kGpE5jtvoM2 YeWQkskbGRKFx1ohwcVBWb0QcWUmPTxKWfJkkKTtkw== X-Google-Smtp-Source: AGHT+IEd0EofWbyecqtYAN7ea7OjImBfMEXKE/z25K8Toj8u+pgb7DTHIrQDup9AcWrX1kQGi4ClbA== X-Received: by 2002:adf:ec49:0:b0:32d:c705:3e5 with SMTP id w9-20020adfec49000000b0032dc70503e5mr3909683wrn.15.1697791229046; Fri, 20 Oct 2023 01:40:29 -0700 (PDT) Received: from localhost.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id r3-20020adff103000000b0032d9337e7d1sm1213356wro.11.2023.10.20.01.40.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Oct 2023 01:40:28 -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 Subject: [libcamera-devel] [PATCH v1 3/6] ipa: rpi: agc: Allow AGC channels to avoid using "fast desaturation" X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Naushir Patuck via libcamera-devel From: Naushir Patuck Reply-To: Naushir Patuck Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" From: David Plowman "Fast desaturation" is a technique that can help the AGC algorithm to desaturate images more quickly when they are very over-exposed. However, it uses digital gain to do this which can confuse our HDR techniques. Therefore make it optional. Signed-off-by: David Plowman Reviewed-by: Naushir Patuck --- src/ipa/rpi/controller/rpi/agc_channel.cpp | 8 ++++++-- src/ipa/rpi/controller/rpi/agc_channel.h | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/ipa/rpi/controller/rpi/agc_channel.cpp b/src/ipa/rpi/controller/rpi/agc_channel.cpp index 1e7eae06d425..3efb6482b67f 100644 --- a/src/ipa/rpi/controller/rpi/agc_channel.cpp +++ b/src/ipa/rpi/controller/rpi/agc_channel.cpp @@ -253,6 +253,8 @@ int AgcConfig::read(const libcamera::YamlObject ¶ms) stableRegion = params["stable_region"].get(0.02); + desaturate = params["desaturate"].get(1); + return 0; } @@ -860,8 +862,10 @@ bool AgcChannel::applyDigitalGain(double gain, double targetY, bool channelBound * quickly (and we then approach the correct value more quickly from * below). */ - bool desaturate = !channelBound && - targetY > config_.fastReduceThreshold && gain < sqrt(targetY); + bool desaturate = false; + if (config_.desaturate) + desaturate = !channelBound && + targetY > config_.fastReduceThreshold && gain < sqrt(targetY); if (desaturate) dg /= config_.fastReduceThreshold; LOG(RPiAgc, Debug) << "Digital gain " << dg << " desaturate? " << desaturate; diff --git a/src/ipa/rpi/controller/rpi/agc_channel.h b/src/ipa/rpi/controller/rpi/agc_channel.h index c1808422498a..4cf7233eef25 100644 --- a/src/ipa/rpi/controller/rpi/agc_channel.h +++ b/src/ipa/rpi/controller/rpi/agc_channel.h @@ -76,6 +76,7 @@ struct AgcConfig { libcamera::utils::Duration defaultExposureTime; double defaultAnalogueGain; double stableRegion; + bool desaturate; }; class AgcChannel