lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251009155251.102472-7-balamanikandan.gunasundar@microchip.com>
Date: Thu, 9 Oct 2025 21:22:39 +0530
From: Balamanikandan Gunasundar <balamanikandan.gunasundar@...rochip.com>
To: Mauro Carvalho Chehab <mchehab@...nel.org>
CC: Eugen Hristev <eugen.hristev@...aro.org>, Chas Williams
	<3chas3@...il.com>, Nicolas Ferre <nicolas.ferre@...rochip.com>, "Alexandre
 Belloni" <alexandre.belloni@...tlin.com>, Claudiu Beznea
	<claudiu.beznea@...on.dev>, Balakrishnan Sambath
	<balakrishnan.s@...rochip.com>, Hans Verkuil <hverkuil@...nel.org>, "Ricardo
 Ribalda" <ribalda@...omium.org>, Laurent Pinchart
	<laurent.pinchart+renesas@...asonboard.com>, Jacopo Mondi
	<jacopo.mondi@...asonboard.com>, Daniel Scally
	<dan.scally+renesas@...asonboard.com>, Tomi Valkeinen
	<tomi.valkeinen@...asonboard.com>, <linux-kernel@...r.kernel.org>,
	<linux-media@...r.kernel.org>, <linux-atm-general@...ts.sourceforge.net>,
	<netdev@...r.kernel.org>, <linux-arm-kernel@...ts.infradead.org>
Subject: [PATCH 06/18] media: microchip-isc: Add range based black level correction

From: Balakrishnan Sambath <balakrishnan.s@...rochip.com>

Add adaptive black level offset based on histogram minimum and pixel
statistics. Apply conservative correction for high black levels and
gentle correction for low levels to prevent overcorrection and improve
dynamic range.

Signed-off-by: Balakrishnan Sambath <balakrishnan.s@...rochip.com>
---
 .../platform/microchip/microchip-isc-base.c   | 22 ++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/microchip/microchip-isc-base.c b/drivers/media/platform/microchip/microchip-isc-base.c
index bb2dd69a83f0..2706a27a2506 100644
--- a/drivers/media/platform/microchip/microchip-isc-base.c
+++ b/drivers/media/platform/microchip/microchip-isc-base.c
@@ -1349,7 +1349,27 @@ static void isc_wb_update(struct isc_ctrls *ctrls)
 		 * we stretch this color to the full range by substracting
 		 * this value from the color component.
 		 */
-		offset[c] = ctrls->hist_minmax[c][HIST_MIN_INDEX];
+		if (hist_min > 5 && hist_min < 60 && total_pixels > 1000) {
+			/*
+			 * Basic adaptive black level offset correction
+			 * (Simplified version for kernel fallback)
+			 */
+			if (hist_min > 20)
+				/* Conservative for high levels */
+				offset[c] = hist_min - 4;
+			else if (hist_min > 10)
+				/* Moderate correction */
+				offset[c] = hist_min - 2;
+			else
+				/* Gentle correction */
+				offset[c] = hist_min - 1;
+
+			offset[c] = max(1U, offset[c]);  /* Ensure minimum of 1 */
+		} else {
+			/* Use default behavior for edge cases */
+			offset[c] = hist_min;
+		}
+
 		/*
 		 * The offset is always at least 1. If the offset is 1, we do
 		 * not need to adjust it, so our result must be zero.
-- 
2.34.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ