From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=68.232.153.233 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796195777; b=nSezfWhCAhDBHawEuObzJjkPfkob0vNObMwTqu42XuXCokXOFnKCLcgpwLNN+0dfVKOi +Y2B5df3180Pw03zpedB+Tj1La8vMOz8AiVqOfmvtiJzE60WzEpC6iI4/Eegf92zLQdkS +gGrZ/BR5Sx87yv7uRE+V4Pfn3KUXqmiviMRcDN1X0oRUPK2op39srWvTQwfJf9VWoDWj IXiJBC4baB/oLVaQkr/rNoo51RStJWNXoBoEYLsQU4oTl/LZZ8lBLB8DGiR3B6pJ5bZAM xUwSW3rt/agd2oprtfr8zx5bKVz3e1TnbnT86DUWwhZ4S+jrsWYEeT7D0Afa1w3n/og== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796195777; h=DMARC-Filter:DKIM-Signature:X-CSE-ConnectionGUID:X-CSE-MsgGUID: X-IronPort-AV:X-Amp-Result:Received:Received:Received:From:Date: Subject:MIME-Version:Content-Type:Content-Transfer-Encoding: Message-ID:References:In-Reply-To:To:CC:X-Mailer; bh=NzZLpB1yDnVmNS+V6qneKQpEmzrG1wNIIyC66DoyytE=; b=L6wHJIGJngwOMYP6/TlhrNoeTRJWg4sisrxgaszQm8/EAlDxPYfK8q3EPfKRKgAEa+jB R2MmQHRh/9FzKieTJz8Fg2p1h+kKh5NjIPy5P3rSX749uWYffixmOLcS8ndWhwYjDecGx O4iJMHpiYnIQl1/KDMKKDng1TAXDzr0CJiP3rCNVnjdNwrWP6RslDe/fY9RU+xen0RSx/ O/VAa7R+Jgj8i0Egek8BFD4oR6nC7yBsQKDEGq6FkAVgdp9b9TTK0TvHGXD0SI2oZ1HOh G3BJmEpLd9D1vENkRegvkVKpFm/ORbJ1w/70W/2jmbix/UNmyYBjSKgHsVLlbA0n9mA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=microchip.com; spf=pass smtp.mailfrom=microchip.com; dkim=pass header.d=microchip.com header.i=@microchip.com header.a=rsa-sha256 header.s=mchp header.b=wJhOxlag; arc=none smtp.remote-ip=68.232.153.233 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D540D606A68A for ; Wed, 2 Dec 2026 07:16:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org D540D606A68A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=microchip.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=microchip.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=microchip.com header.i=@microchip.com header.a=rsa-sha256 header.s=mchp header.b=wJhOxlag DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1796195777; x=1827731777; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=nSxd4kZJUxVrWTD4LVGv5nSWTVbxaW5MIMn4xnKDlfM=; b=wJhOxlagxibVEAl5A2tDRDcZHPFwvoPrWKxTOxg+UY2pJjNHrEPuL4R6 W+OfqWHj7B+b5sU7PbJAy+uSy/FUuyiZV5oOrYWdUL1TDZcX/4KZ+ehJF JqIQbdeNajdoGX1KyZcn6J4l3DA/SCx5bduwOucyQn96oevcXRjFapN9J sHWnMQaTK3wj4ThBExiqQlVhB3ejKgh9TaQaE7ZBnffF3HFly5Haf69ZB bUlFKVwYM7sjSKilyo5B8CIZHuABTq6k+wtDq+oH+FaPP54477g9QvWfP NukjQ2YEwrF5sx67FoH64YtRgxnILbkCcht7urKr0uioZUuHx9Pun7/Sp Q==; X-CSE-ConnectionGUID: dpTxfcnPTRu7MBdnmSS5Ag== X-CSE-MsgGUID: +wmrjBw9QvSoG7xgrnnuVw== X-IronPort-AV: E=Sophos;i="6.27,246,1787036400"; d="scan'208";a="298747263" X-Amp-Result: SKIPPED(no attachment in message) Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa5.microchip.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 02 Dec 2026 00:16:17 -0700 Received: from chn-vm-ex01.mchp-main.com (10.10.85.143) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.58; Wed, 2 Dec 2026 00:16:16 -0700 Received: from [127.0.0.1] (10.10.85.11) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server id 15.1.2507.58 via Frontend Transport; Wed, 2 Dec 2026 00:16:14 -0700 From: Balakrishnan Sambath Date: Wed, 2 Dec 2026 12:46:09 +0530 Subject: [PATCH 03/15] media: microchip-isc: fix DPC black level scale X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-ID: <20261202-isc-series-v1-v1-3-4e2f17c0271c@microchip.com> References: <20261202-isc-series-v1-v1-0-4e2f17c0271c@microchip.com> In-Reply-To: <20261202-isc-series-v1-v1-0-4e2f17c0271c@microchip.com> To: CC: , Balakrishnan Sambath X-Mailer: b4 0.14.3 isc_sama7g5_config_dpc() programmed a fixed BLOFF of 64, the black level of a 10-bit sensor. Derive it from pfe_cfg0_bps instead, giving 16 at 8 bits, 64 at 10 bits and 256 at 12 bits. Black level correction is not enabled yet, so no output changes until the next patch. BLOFST is 9 bits at ISC_DPC_CFG bits 31 to 23 (SAM9X7 DS60001813E section 52.7.16, same layout in the SAMA7G5 datasheet). The old ISC_DPC_CFG_BLOFF_MASK, GENMASK(31, 24), wrote twice the intended value, so 10 bits programmed 128 instead of 64. The 12-bit case is no longer capped at 255. Signed-off-by: Balakrishnan Sambath --- drivers/media/platform/microchip/microchip-isc-regs.h | 4 ++-- drivers/media/platform/microchip/microchip-sama7g5-isc.c | 10 +++++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/media/platform/microchip/microchip-isc-regs.h b/drivers/media/platform/microchip/microchip-isc-regs.h index fe145b142b82..91ad94dcc162 100644 --- a/drivers/media/platform/microchip/microchip-isc-regs.h +++ b/drivers/media/platform/microchip/microchip-isc-regs.h @@ -114,8 +114,8 @@ #define ISC_DPC_CFG_GDCCLP_SHIFT 20 #define ISC_DPC_CFG_GDCCLP_MASK GENMASK(22, 20) -#define ISC_DPC_CFG_BLOFF_SHIFT 24 -#define ISC_DPC_CFG_BLOFF_MASK GENMASK(31, 24) +#define ISC_DPC_CFG_BLOFF_SHIFT 23 +#define ISC_DPC_CFG_BLOFF_MASK GENMASK(31, 23) #define ISC_DPC_CFG_BAYCFG_SHIFT 0 #define ISC_DPC_CFG_BAYCFG_MASK GENMASK(1, 0) diff --git a/drivers/media/platform/microchip/microchip-sama7g5-isc.c b/drivers/media/platform/microchip/microchip-sama7g5-isc.c index 6403d2d43864..1a69e77fac2b 100644 --- a/drivers/media/platform/microchip/microchip-sama7g5-isc.c +++ b/drivers/media/platform/microchip/microchip-sama7g5-isc.c @@ -300,9 +300,17 @@ static void isc_sama7g5_config_dpc(struct isc_device *isc) { u32 bay_cfg = isc->config.sd_format->cfa_baycfg; struct regmap *regmap = isc->regmap; + u32 bloff; + + /* + * The black level is 1/16 of full scale, 64 at 10 bits. The BPS + * code counts down from 4 at 8 bits to 0 at 12 bits, so the level + * is 256 >> code, 16 at 8 bits up to 256 at 12 bits. + */ + bloff = 256u >> isc->config.sd_format->pfe_cfg0_bps; regmap_update_bits(regmap, ISC_DPC_CFG, ISC_DPC_CFG_BLOFF_MASK, - (64 << ISC_DPC_CFG_BLOFF_SHIFT)); + (bloff << ISC_DPC_CFG_BLOFF_SHIFT)); regmap_update_bits(regmap, ISC_DPC_CFG, ISC_DPC_CFG_BAYCFG_MASK, (bay_cfg << ISC_DPC_CFG_BAYCFG_SHIFT)); } -- 2.34.1