mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Balakrishnan Sambath <balakrishnan.s@microchip.com>
To: <ehristev@kernel.org>
Cc: <linux-kernel@vger.kernel.org>,
	Balakrishnan Sambath <balakrishnan.s@microchip.com>
Subject: [PATCH 03/15] media: microchip-isc: fix DPC black level scale
Date: Wed, 2 Dec 2026 12:46:09 +0530	[thread overview]
Message-ID: <20261202-isc-series-v1-v1-3-4e2f17c0271c@microchip.com> (raw)
In-Reply-To: <20261202-isc-series-v1-v1-0-4e2f17c0271c@microchip.com>

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 <balakrishnan.s@microchip.com>
---
 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


  parent reply	other threads:[~2026-12-02  7:16 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-02  7:16 [PATCH 00/15] media: microchip-isc: fix SAMA7G5 image pipeline and AWB Balakrishnan Sambath
2026-12-02  7:16 ` [PATCH 01/15] dt-bindings: media: microchip,xisc: add SAM9X7 compatible Balakrishnan Sambath
2026-12-02  7:16 ` [PATCH 02/15] media: microchip-isc: set SAM9X7 maximum resolution per SoC Balakrishnan Sambath
2026-12-02  7:16 ` Balakrishnan Sambath [this message]
2026-12-02  7:16 ` [PATCH 04/15] media: microchip-isc: enable black level correction on SAMA7G5 Balakrishnan Sambath
2026-12-02  7:16 ` [PATCH 05/15] media: microchip-isc: bypass SAMA7G5 pipeline for Bayer output Balakrishnan Sambath
2026-12-02  7:16 ` [PATCH 06/15] media: microchip-isc: add gamma 1.8 and 2.4 curves for SAMA7G5 Balakrishnan Sambath
2026-12-02  7:16 ` [PATCH 07/15] media: microchip-isc: fix CBHS register names Balakrishnan Sambath
2026-12-02  7:16 ` [PATCH 08/15] media: microchip-isc: add SAMA7G5 hue and saturation controls Balakrishnan Sambath
2026-12-02  7:16 ` [PATCH 09/15] media: microchip-isc: fix histogram bin index for AWB Balakrishnan Sambath
2026-12-02  7:16 ` [PATCH 10/15] media: microchip-isc: trim outliers in the AWB average Balakrishnan Sambath
2026-12-02  7:16 ` [PATCH 11/15] media: microchip-isc: skip AWB on near-empty channels Balakrishnan Sambath
2026-12-02  7:16 ` [PATCH 12/15] media: microchip-isc: do the AWB gain product in 64 bits Balakrishnan Sambath
2026-12-02  7:16 ` [PATCH 13/15] media: microchip-isc: smooth AWB gains with an EMA filter Balakrishnan Sambath
2026-12-02  7:16 ` [PATCH 14/15] media: microchip-isc: use an unsigned contrast range Balakrishnan Sambath
2026-12-02  7:16 ` [PATCH 15/15] media: microchip-isc: add driver documentation Balakrishnan Sambath

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261202-isc-series-v1-v1-3-4e2f17c0271c@microchip.com \
    --to=balakrishnan.s@microchip.com \
    --cc=ehristev@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®