* [PATCH 01/15] dt-bindings: media: microchip,xisc: add SAM9X7 compatible
2026-12-02 7:16 [PATCH 00/15] media: microchip-isc: fix SAMA7G5 image pipeline and AWB Balakrishnan Sambath
@ 2026-12-02 7:16 ` Balakrishnan Sambath
2026-12-02 7:16 ` [PATCH 02/15] media: microchip-isc: set SAM9X7 maximum resolution per SoC Balakrishnan Sambath
` (13 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: Balakrishnan Sambath @ 2026-12-02 7:16 UTC (permalink / raw)
To: ehristev; +Cc: linux-kernel, Balakrishnan Sambath
The SAM9X7 XISC is the same block as the SAMA7G5 one with a smaller
maximum frame size, 2560x1920 (DS60001813C, section 50.2). Add
microchip,sam9x7-isc and keep microchip,sama7g5-isc as the fallback, so
existing SAMA7G5 device trees and drivers keep binding.
Signed-off-by: Balakrishnan Sambath <balakrishnan.s@microchip.com>
---
Documentation/devicetree/bindings/media/microchip,xisc.yaml | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/Documentation/devicetree/bindings/media/microchip,xisc.yaml b/Documentation/devicetree/bindings/media/microchip,xisc.yaml
index 6a9e56c486c2..d68aaf121bf8 100644
--- a/Documentation/devicetree/bindings/media/microchip,xisc.yaml
+++ b/Documentation/devicetree/bindings/media/microchip,xisc.yaml
@@ -22,7 +22,11 @@ description: |
properties:
compatible:
- const: microchip,sama7g5-isc
+ oneOf:
+ - const: microchip,sama7g5-isc
+ - items:
+ - const: microchip,sam9x7-isc
+ - const: microchip,sama7g5-isc
reg:
maxItems: 1
--
2.34.1
^ permalink raw reply [flat|nested] 16+ messages in thread* [PATCH 02/15] media: microchip-isc: set SAM9X7 maximum resolution per SoC
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 ` Balakrishnan Sambath
2026-12-02 7:16 ` [PATCH 03/15] media: microchip-isc: fix DPC black level scale Balakrishnan Sambath
` (12 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: Balakrishnan Sambath @ 2026-12-02 7:16 UTC (permalink / raw)
To: ehristev; +Cc: linux-kernel, Balamanikandan Gunasundar, Balakrishnan Sambath
SAM9X7 shares the XISC with SAMA7G5 but supports at most 2560x1920
(DS60001813C, section 50.2), where SAMA7G5 allows 3264x2464.
Take the limits from the matched compatible with
of_device_get_match_data() instead of of_machine_is_compatible(), which
only looks at the root node and is not how the device is identified.
Co-developed-by: Balamanikandan Gunasundar <balamanikandan.gunasundar@microchip.com>
Signed-off-by: Balamanikandan Gunasundar <balamanikandan.gunasundar@microchip.com>
Signed-off-by: Balakrishnan Sambath <balakrishnan.s@microchip.com>
---
.../platform/microchip/microchip-sama7g5-isc.c | 29 ++++++++++++++++++----
1 file changed, 24 insertions(+), 5 deletions(-)
diff --git a/drivers/media/platform/microchip/microchip-sama7g5-isc.c b/drivers/media/platform/microchip/microchip-sama7g5-isc.c
index f5968e3b388d..6403d2d43864 100644
--- a/drivers/media/platform/microchip/microchip-sama7g5-isc.c
+++ b/drivers/media/platform/microchip/microchip-sama7g5-isc.c
@@ -35,6 +35,7 @@
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/of.h>
+#include <linux/of_device.h>
#include <linux/of_graph.h>
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
@@ -53,8 +54,20 @@
#include "microchip-isc-regs.h"
#include "microchip-isc.h"
-#define ISC_SAMA7G5_MAX_SUPPORT_WIDTH 3264
-#define ISC_SAMA7G5_MAX_SUPPORT_HEIGHT 2464
+struct isc_xisc_data {
+ u32 max_width;
+ u32 max_height;
+};
+
+static const struct isc_xisc_data isc_sama7g5_data = {
+ .max_width = 3264,
+ .max_height = 2464,
+};
+
+static const struct isc_xisc_data isc_sam9x7_data = {
+ .max_width = 2560,
+ .max_height = 1920,
+};
#define ISC_SAMA7G5_PIPELINE \
(WB_ENABLE | CFA_ENABLE | CC_ENABLE | GAM_ENABLES | CSC_ENABLE | \
@@ -403,6 +416,7 @@ static int microchip_xisc_probe(struct platform_device *pdev)
struct isc_device *isc;
void __iomem *io_base;
struct isc_subdev_entity *subdev_entity;
+ const struct isc_xisc_data *data;
int irq;
int ret;
u32 ver;
@@ -450,8 +464,12 @@ static int microchip_xisc_probe(struct platform_device *pdev)
isc->gamma_table = isc_sama7g5_gamma_table;
isc->gamma_max = 0;
- isc->max_width = ISC_SAMA7G5_MAX_SUPPORT_WIDTH;
- isc->max_height = ISC_SAMA7G5_MAX_SUPPORT_HEIGHT;
+ data = of_device_get_match_data(dev);
+ if (!data)
+ return dev_err_probe(dev, -ENODEV, "no match data\n");
+
+ isc->max_width = data->max_width;
+ isc->max_height = data->max_height;
isc->config_dpc = isc_sama7g5_config_dpc;
isc->config_csc = isc_sama7g5_config_csc;
@@ -626,7 +644,8 @@ static const struct dev_pm_ops microchip_xisc_dev_pm_ops = {
#if IS_ENABLED(CONFIG_OF)
static const struct of_device_id microchip_xisc_of_match[] = {
- { .compatible = "microchip,sama7g5-isc" },
+ { .compatible = "microchip,sama7g5-isc", .data = &isc_sama7g5_data },
+ { .compatible = "microchip,sam9x7-isc", .data = &isc_sam9x7_data },
{ }
};
MODULE_DEVICE_TABLE(of, microchip_xisc_of_match);
--
2.34.1
^ permalink raw reply [flat|nested] 16+ messages in thread* [PATCH 03/15] media: microchip-isc: fix DPC black level scale
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
2026-12-02 7:16 ` [PATCH 04/15] media: microchip-isc: enable black level correction on SAMA7G5 Balakrishnan Sambath
` (11 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: Balakrishnan Sambath @ 2026-12-02 7:16 UTC (permalink / raw)
To: ehristev; +Cc: linux-kernel, Balakrishnan Sambath
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
^ permalink raw reply [flat|nested] 16+ messages in thread* [PATCH 04/15] media: microchip-isc: enable black level correction on SAMA7G5
2026-12-02 7:16 [PATCH 00/15] media: microchip-isc: fix SAMA7G5 image pipeline and AWB Balakrishnan Sambath
` (2 preceding siblings ...)
2026-12-02 7:16 ` [PATCH 03/15] media: microchip-isc: fix DPC black level scale Balakrishnan Sambath
@ 2026-12-02 7:16 ` Balakrishnan Sambath
2026-12-02 7:16 ` [PATCH 05/15] media: microchip-isc: bypass SAMA7G5 pipeline for Bayer output Balakrishnan Sambath
` (10 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: Balakrishnan Sambath @ 2026-12-02 7:16 UTC (permalink / raw)
To: ehristev; +Cc: linux-kernel, Balamanikandan Gunasundar, Balakrishnan Sambath
isc_try_configure_pipeline() selects DPC_BLCENABLE for raw Bayer input,
but ISC_SAMA7G5_PIPELINE does not include it, so
isc_sama7g5_adapt_pipeline() always masks it off and black level
correction never runs. Add DPC_BLCENABLE to the mask.
Raw capture now has the black level subtracted. The offset programmed in
ISC_DPC_CFG.BLOFF is 16 at 8 bits, 64 at 10 bits and 256 at 12 bits.
Co-developed-by: Balamanikandan Gunasundar <balamanikandan.gunasundar@microchip.com>
Signed-off-by: Balamanikandan Gunasundar <balamanikandan.gunasundar@microchip.com>
Signed-off-by: Balakrishnan Sambath <balakrishnan.s@microchip.com>
---
drivers/media/platform/microchip/microchip-sama7g5-isc.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/media/platform/microchip/microchip-sama7g5-isc.c b/drivers/media/platform/microchip/microchip-sama7g5-isc.c
index 1a69e77fac2b..6950509372a5 100644
--- a/drivers/media/platform/microchip/microchip-sama7g5-isc.c
+++ b/drivers/media/platform/microchip/microchip-sama7g5-isc.c
@@ -70,8 +70,8 @@ static const struct isc_xisc_data isc_sam9x7_data = {
};
#define ISC_SAMA7G5_PIPELINE \
- (WB_ENABLE | CFA_ENABLE | CC_ENABLE | GAM_ENABLES | CSC_ENABLE | \
- CBC_ENABLE | SUB422_ENABLE | SUB420_ENABLE)
+ (DPC_BLCENABLE | WB_ENABLE | CFA_ENABLE | CC_ENABLE | GAM_ENABLES | \
+ CSC_ENABLE | CBC_ENABLE | SUB422_ENABLE | SUB420_ENABLE)
/* This is a list of the formats that the ISC can *output* */
static const struct isc_format sama7g5_controller_formats[] = {
--
2.34.1
^ permalink raw reply [flat|nested] 16+ messages in thread* [PATCH 05/15] media: microchip-isc: bypass SAMA7G5 pipeline for Bayer output
2026-12-02 7:16 [PATCH 00/15] media: microchip-isc: fix SAMA7G5 image pipeline and AWB Balakrishnan Sambath
` (3 preceding siblings ...)
2026-12-02 7:16 ` [PATCH 04/15] media: microchip-isc: enable black level correction on SAMA7G5 Balakrishnan Sambath
@ 2026-12-02 7:16 ` 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
` (9 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: Balakrishnan Sambath @ 2026-12-02 7:16 UTC (permalink / raw)
To: ehristev; +Cc: linux-kernel, Balamanikandan Gunasundar, Balakrishnan Sambath
The default case of isc_try_configure_pipeline() selects WB_ENABLE and
DPC_BLCENABLE for raw Bayer input, so a Bayer output no longer carries the
sensor data a software ISP expects.
Clear bits_pipeline in isc_sama7g5_adapt_pipeline() for the outputs flagged
raw, the 8, 10 and 12 bit SBGGR, SGBRG, SGRBG and SRGGB formats. The
default case is shared with SAMA5D2 and SAM9X60, so it stays as is. Y10 is
not flagged raw and keeps WB and black level correction like GREY and Y16.
The histogram and awb_work are armed from ctrls.awb and the sensor mbus
code only. Also test WB_ENABLE in bits_pipeline, else the HISDONE interrupt
keeps firing per frame with the WB stage bypassed. Keep the one-shot
do_white_balance button inactive in that case as well.
Co-developed-by: Balamanikandan Gunasundar <balamanikandan.gunasundar@microchip.com>
Signed-off-by: Balamanikandan Gunasundar <balamanikandan.gunasundar@microchip.com>
Signed-off-by: Balakrishnan Sambath <balakrishnan.s@microchip.com>
---
drivers/media/platform/microchip/microchip-isc-base.c | 7 +++++--
drivers/media/platform/microchip/microchip-sama7g5-isc.c | 12 ++++++++++++
2 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/drivers/media/platform/microchip/microchip-isc-base.c b/drivers/media/platform/microchip/microchip-isc-base.c
index 963d5fd53b58..4cbdc43da715 100644
--- a/drivers/media/platform/microchip/microchip-isc-base.c
+++ b/drivers/media/platform/microchip/microchip-isc-base.c
@@ -316,8 +316,9 @@ static int isc_configure(struct isc_device *isc)
/*
* The current implemented histogram is available for RAW R, B, GB, GR
* channels. We need to check if sensor is outputting RAW BAYER
+ * and that the pipeline still has the WB stage.
*/
- if (isc->ctrls.awb &&
+ if (isc->ctrls.awb && (pipeline & WB_ENABLE) &&
ISC_IS_FORMAT_RAW(isc->config.sd_format->mbus_code))
isc_set_histogram(isc, true);
else
@@ -387,7 +388,8 @@ static int isc_start_streaming(struct vb2_queue *vq, unsigned int count)
spin_unlock_irqrestore(&isc->dma_queue_lock, flags);
/* if we streaming from RAW, we can do one-shot white balance adj */
- if (ISC_IS_FORMAT_RAW(isc->config.sd_format->mbus_code))
+ if (ISC_IS_FORMAT_RAW(isc->config.sd_format->mbus_code) &&
+ (isc->config.bits_pipeline & WB_ENABLE))
v4l2_ctrl_activate(isc->do_wb_ctrl, true);
return 0;
@@ -1539,6 +1541,7 @@ static int isc_s_awb_ctrl(struct v4l2_ctrl *ctrl)
/* if we have autowhitebalance on, start histogram procedure */
if (ctrls->awb == ISC_WB_AUTO &&
+ (isc->config.bits_pipeline & WB_ENABLE) &&
vb2_is_streaming(&isc->vb2_vidq) &&
ISC_IS_FORMAT_RAW(isc->config.sd_format->mbus_code))
isc_set_histogram(isc, true);
diff --git a/drivers/media/platform/microchip/microchip-sama7g5-isc.c b/drivers/media/platform/microchip/microchip-sama7g5-isc.c
index 6950509372a5..80bd0fd3716d 100644
--- a/drivers/media/platform/microchip/microchip-sama7g5-isc.c
+++ b/drivers/media/platform/microchip/microchip-sama7g5-isc.c
@@ -335,6 +335,18 @@ static void isc_sama7g5_config_rlp(struct isc_device *isc)
static void isc_sama7g5_adapt_pipeline(struct isc_device *isc)
{
+ const struct isc_format *fmt;
+ u32 i;
+
+ for (i = 0; i < isc->controller_formats_size; i++) {
+ fmt = &isc->controller_formats[i];
+ if (fmt->fourcc == isc->try_config.fourcc && fmt->raw) {
+ /* Bayer out reaches the software ISP unmodified */
+ isc->try_config.bits_pipeline = 0x0;
+ return;
+ }
+ }
+
isc->try_config.bits_pipeline &= ISC_SAMA7G5_PIPELINE;
}
--
2.34.1
^ permalink raw reply [flat|nested] 16+ messages in thread* [PATCH 06/15] media: microchip-isc: add gamma 1.8 and 2.4 curves for SAMA7G5
2026-12-02 7:16 [PATCH 00/15] media: microchip-isc: fix SAMA7G5 image pipeline and AWB Balakrishnan Sambath
` (4 preceding siblings ...)
2026-12-02 7:16 ` [PATCH 05/15] media: microchip-isc: bypass SAMA7G5 pipeline for Bayer output Balakrishnan Sambath
@ 2026-12-02 7:16 ` Balakrishnan Sambath
2026-12-02 7:16 ` [PATCH 07/15] media: microchip-isc: fix CBHS register names Balakrishnan Sambath
` (8 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: Balakrishnan Sambath @ 2026-12-02 7:16 UTC (permalink / raw)
To: ehristev; +Cc: linux-kernel, Balamanikandan Gunasundar, Balakrishnan Sambath
Add 1/2.4 and 1/1.8 tables after the existing 1/2.2 one in
isc_sama7g5_gamma_table and set gamma_max to 2, so V4L2_CID_GAMMA
selects 0 (1/2.2), 1 (1/2.4) or 2 (1/1.8).
1/2.2 stays at index 0 because gamma_max was 0 before, so an explicit
gamma of 0 keeps its curve.
The control default was gamma_max, which would now pick 1/1.8 on SAMA7G5.
Add gamma_def to struct isc_device and set it to 0 on SAMA7G5 and 2 on
SAMA5D2, so the default stays 1/2.2 on both.
Co-developed-by: Balamanikandan Gunasundar <balamanikandan.gunasundar@microchip.com>
Signed-off-by: Balamanikandan Gunasundar <balamanikandan.gunasundar@microchip.com>
Signed-off-by: Balakrishnan Sambath <balakrishnan.s@microchip.com>
---
.../media/platform/microchip/microchip-isc-base.c | 2 +-
drivers/media/platform/microchip/microchip-isc.h | 2 ++
.../platform/microchip/microchip-sama5d2-isc.c | 1 +
.../platform/microchip/microchip-sama7g5-isc.c | 33 ++++++++++++++++++++--
4 files changed, 34 insertions(+), 4 deletions(-)
diff --git a/drivers/media/platform/microchip/microchip-isc-base.c b/drivers/media/platform/microchip/microchip-isc-base.c
index 4cbdc43da715..86f0eb86b76d 100644
--- a/drivers/media/platform/microchip/microchip-isc-base.c
+++ b/drivers/media/platform/microchip/microchip-isc-base.c
@@ -1656,7 +1656,7 @@ static int isc_ctrl_init(struct isc_device *isc)
v4l2_ctrl_new_std(hdl, ops, V4L2_CID_BRIGHTNESS, -1024, 1023, 1, 0);
v4l2_ctrl_new_std(hdl, ops, V4L2_CID_GAMMA, 0, isc->gamma_max, 1,
- isc->gamma_max);
+ isc->gamma_def);
isc->awb_ctrl = v4l2_ctrl_new_std(hdl, &isc_awb_ops,
V4L2_CID_AUTO_WHITE_BALANCE,
0, 1, 1, 1);
diff --git a/drivers/media/platform/microchip/microchip-isc.h b/drivers/media/platform/microchip/microchip-isc.h
index d7bcd74efff9..31d9cf84b318 100644
--- a/drivers/media/platform/microchip/microchip-isc.h
+++ b/drivers/media/platform/microchip/microchip-isc.h
@@ -243,6 +243,7 @@ enum isc_scaler_pads {
* @gamma_table: pointer to the table with gamma values, has
* gamma_max sets of GAMMA_ENTRIES entries each
* @gamma_max: maximum number of sets of inside the gamma_table
+ * @gamma_def: default set inside the gamma_table
*
* @max_width: maximum frame width, dependent on the internal RAM
* @max_height: maximum frame height, dependent on the internal RAM
@@ -345,6 +346,7 @@ struct isc_device {
/* pointer to the defined gamma table */
const u32 (*gamma_table)[GAMMA_ENTRIES];
u32 gamma_max;
+ u32 gamma_def;
u32 max_width;
u32 max_height;
diff --git a/drivers/media/platform/microchip/microchip-sama5d2-isc.c b/drivers/media/platform/microchip/microchip-sama5d2-isc.c
index 5e41eee45dbd..a93f95434270 100644
--- a/drivers/media/platform/microchip/microchip-sama5d2-isc.c
+++ b/drivers/media/platform/microchip/microchip-sama5d2-isc.c
@@ -460,6 +460,7 @@ static int microchip_isc_probe(struct platform_device *pdev)
isc->gamma_table = isc_sama5d2_gamma_table;
isc->gamma_max = 2;
+ isc->gamma_def = 2;
isc->max_width = ISC_SAMA5D2_MAX_SUPPORT_WIDTH;
isc->max_height = ISC_SAMA5D2_MAX_SUPPORT_HEIGHT;
diff --git a/drivers/media/platform/microchip/microchip-sama7g5-isc.c b/drivers/media/platform/microchip/microchip-sama7g5-isc.c
index 80bd0fd3716d..415c58c42614 100644
--- a/drivers/media/platform/microchip/microchip-sama7g5-isc.c
+++ b/drivers/media/platform/microchip/microchip-sama7g5-isc.c
@@ -350,9 +350,9 @@ static void isc_sama7g5_adapt_pipeline(struct isc_device *isc)
isc->try_config.bits_pipeline &= ISC_SAMA7G5_PIPELINE;
}
-/* Gamma table with gamma 1/2.2 */
+/* Gamma tables with gamma values 0.45(Default), 0.42, 0.56 */
static const u32 isc_sama7g5_gamma_table[][GAMMA_ENTRIES] = {
- /* index 0 --> gamma bipartite */
+ /* index 0 --> gamma bipartite 1/2.2(=0.45) */
{
0x780, 0x3c02c0, 0x520200, 0x6201c0, 0x700180, 0x7c0160,
0x870140, 0x910120, 0x9a0100, 0xa20100, 0xaa0100, 0xb200e0,
@@ -365,6 +365,32 @@ static const u32 isc_sama7g5_gamma_table[][GAMMA_ENTRIES] = {
0x3130028, 0x3270026, 0x33a0024, 0x34c0024, 0x35e0024, 0x3700022,
0x3810022, 0x3920020, 0x3a20022, 0x3b3001e, 0x3c20020, 0x3d2001e,
0x3e1001e, 0x3f0001e, 0x3ff001c, 0x40d001c },
+ /* index 1 --> gamma bipartite 1/2.4(=0.42) */
+ {
+ 0x960, 0x4b0300, 0x630260, 0x7601c0, 0x8401a0, 0x910180,
+ 0x9d0160, 0xa80120, 0xb10120, 0xba0120, 0xc30100, 0xcb0100,
+ 0xd300e0, 0xda00e0, 0xe100e0, 0xe800c0, 0xee00c0, 0xf400c0,
+ 0xfa00c0, 0x10000a0, 0x10500c0, 0x10b00a0, 0x11000a0, 0x11500a0,
+ 0x11a00a0, 0x11f00a0, 0x12400a0, 0x12900a0, 0x12e00a0, 0x13300a0,
+ 0x1380080, 0x13c00a0, 0x1410072, 0x17a0060, 0x1aa0054, 0x1d4004a,
+ 0x1f90044, 0x21b003e, 0x23a003a, 0x2570036, 0x2720032, 0x28b0030,
+ 0x2a3002e, 0x2ba002c, 0x2d0002c, 0x2e60028, 0x2fa0028, 0x30e0026,
+ 0x3210024, 0x3330024, 0x3450022, 0x3560022, 0x3670020, 0x3770020,
+ 0x387001e, 0x396001e, 0x3a5001c, 0x3b3001c, 0x3c1001c, 0x3cf001c,
+ 0x3dd001c, 0x3eb001c, 0x3f9001c, 0x407001c },
+ /* index 2 --> gamma bipartite 1/1.8(=0.56) */
+ {
+ 0x400, 0x2001e0, 0x2f0180, 0x3b0140, 0x450120, 0x4e0120,
+ 0x5700e0, 0x5e0100, 0x6600c0, 0x6c00e0, 0x7300c0, 0x7900c0,
+ 0x7f00c0, 0x8500c0, 0x8b00a0, 0x9000a0, 0x9500a0, 0x9a00a0,
+ 0x9f00a0, 0xa400a0, 0xa900a0, 0xae0080, 0xb200a0, 0xb70080,
+ 0xbb0080, 0xbf0080, 0xc300a0, 0xc80080, 0xcc0080, 0xd00080,
+ 0xd40060, 0xd70080, 0xdb0070, 0x113005e, 0x1420056, 0x16d004e,
+ 0x1940048, 0x1b80044, 0x1da0040, 0x1fa003c, 0x218003a, 0x2350038,
+ 0x2510036, 0x26c0034, 0x2860034, 0x2a00030, 0x2b80030, 0x2d0002e,
+ 0x2e7002e, 0x2fe002c, 0x314002c, 0x32a002a, 0x33f002a, 0x3540028,
+ 0x3680028, 0x37c0028, 0x3900026, 0x3a30026, 0x3b60026, 0x3c90024,
+ 0x3db0024, 0x3ed0024, 0x3ff0024, 0x4110024 },
};
static int xisc_parse_dt(struct device *dev, struct isc_device *isc)
@@ -482,7 +508,8 @@ static int microchip_xisc_probe(struct platform_device *pdev)
}
isc->gamma_table = isc_sama7g5_gamma_table;
- isc->gamma_max = 0;
+ isc->gamma_max = 2;
+ isc->gamma_def = 0;
data = of_device_get_match_data(dev);
if (!data)
--
2.34.1
^ permalink raw reply [flat|nested] 16+ messages in thread* [PATCH 07/15] media: microchip-isc: fix CBHS register names
2026-12-02 7:16 [PATCH 00/15] media: microchip-isc: fix SAMA7G5 image pipeline and AWB Balakrishnan Sambath
` (5 preceding siblings ...)
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 ` Balakrishnan Sambath
2026-12-02 7:16 ` [PATCH 08/15] media: microchip-isc: add SAMA7G5 hue and saturation controls Balakrishnan Sambath
` (7 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: Balakrishnan Sambath @ 2026-12-02 7:16 UTC (permalink / raw)
To: ehristev; +Cc: linux-kernel, Balakrishnan Sambath
ISC_CBCHS_HUE and ISC_CBCHS_SAT name the SAMA7G5 hue and saturation
registers with an extra C that no datasheet uses. The SAM9X7 datasheet
(DS60001813E, sections 52.7.59 to 52.7.63) and the SAMA7G5 preliminary
datasheet name the CBHS block ISC_CBHS_CFG, ISC_CBHS_BRIGHT,
ISC_CBHS_CONT, ISC_CBHS_HUE and ISC_CBHS_SAT.
Rename the two defines to the datasheet spelling. The offsets and the
writes in isc_sama7g5_config_cbc() do not change.
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 | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/media/platform/microchip/microchip-isc-regs.h b/drivers/media/platform/microchip/microchip-isc-regs.h
index 91ad94dcc162..f9bc76c6f35d 100644
--- a/drivers/media/platform/microchip/microchip-isc-regs.h
+++ b/drivers/media/platform/microchip/microchip-isc-regs.h
@@ -275,9 +275,9 @@
#define ISC_CBC_CONTRAST_MASK GENMASK(11, 0)
/* Hue Register */
-#define ISC_CBCHS_HUE 0x4e0
+#define ISC_CBHS_HUE 0x4e0
/* Saturation Register */
-#define ISC_CBCHS_SAT 0x4e4
+#define ISC_CBHS_SAT 0x4e4
/* Offset for SUB422 register specific to sama5d2 product */
#define ISC_SAMA5D2_SUB422_OFFSET 0
diff --git a/drivers/media/platform/microchip/microchip-sama7g5-isc.c b/drivers/media/platform/microchip/microchip-sama7g5-isc.c
index 415c58c42614..f182e19a5519 100644
--- a/drivers/media/platform/microchip/microchip-sama7g5-isc.c
+++ b/drivers/media/platform/microchip/microchip-sama7g5-isc.c
@@ -268,8 +268,8 @@ static void isc_sama7g5_config_cbc(struct isc_device *isc)
regmap_write(regmap, ISC_CBC_BRIGHT + isc->offsets.cbc, isc->ctrls.brightness);
regmap_write(regmap, ISC_CBC_CONTRAST + isc->offsets.cbc, isc->ctrls.contrast);
/* Configure Hue and Saturation as neutral midpoint */
- regmap_write(regmap, ISC_CBCHS_HUE, 0);
- regmap_write(regmap, ISC_CBCHS_SAT, (1 << 4));
+ regmap_write(regmap, ISC_CBHS_HUE, 0);
+ regmap_write(regmap, ISC_CBHS_SAT, (1 << 4));
}
static void isc_sama7g5_config_cc(struct isc_device *isc)
--
2.34.1
^ permalink raw reply [flat|nested] 16+ messages in thread* [PATCH 08/15] media: microchip-isc: add SAMA7G5 hue and saturation controls
2026-12-02 7:16 [PATCH 00/15] media: microchip-isc: fix SAMA7G5 image pipeline and AWB Balakrishnan Sambath
` (6 preceding siblings ...)
2026-12-02 7:16 ` [PATCH 07/15] media: microchip-isc: fix CBHS register names Balakrishnan Sambath
@ 2026-12-02 7:16 ` Balakrishnan Sambath
2026-12-02 7:16 ` [PATCH 09/15] media: microchip-isc: fix histogram bin index for AWB Balakrishnan Sambath
` (6 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: Balakrishnan Sambath @ 2026-12-02 7:16 UTC (permalink / raw)
To: ehristev; +Cc: linux-kernel, Balamanikandan Gunasundar, Balakrishnan Sambath
The SAMA7G5 CBHS stage adds hue (ISC_CBHS_HUE, 9 bits, 0 to 359 degrees)
and saturation (ISC_CBHS_SAT, unsigned 8.4, 16 is unity). Add V4L2_CID_HUE
and V4L2_CID_SATURATION when has_cbhs is set, and program them from
isc_sama7g5_config_cbc() instead of the neutral 0 and 16.
Negative hue is wrapped to 0 to 359 before it is written. The register is
unsigned, so writing -30 directly would program 482 degrees.
On SAMA7G5 only, mark the CBC controls inactive when the pipeline has no
CBC_ENABLE stage, and hue and saturation also when the output format
carries no chroma. Other variants keep their controls always active. The
flags follow the pipeline validated at stream start, so all four stay
active until the first start.
Co-developed-by: Balamanikandan Gunasundar <balamanikandan.gunasundar@microchip.com>
Signed-off-by: Balamanikandan Gunasundar <balamanikandan.gunasundar@microchip.com>
Signed-off-by: Balakrishnan Sambath <balakrishnan.s@microchip.com>
---
.../media/platform/microchip/microchip-isc-base.c | 60 ++++++++++++++++++++--
.../media/platform/microchip/microchip-isc-regs.h | 15 ++++--
drivers/media/platform/microchip/microchip-isc.h | 12 +++++
.../platform/microchip/microchip-sama5d2-isc.c | 3 +-
.../platform/microchip/microchip-sama7g5-isc.c | 9 ++--
5 files changed, 85 insertions(+), 14 deletions(-)
diff --git a/drivers/media/platform/microchip/microchip-isc-base.c b/drivers/media/platform/microchip/microchip-isc-base.c
index 86f0eb86b76d..3e18933230b8 100644
--- a/drivers/media/platform/microchip/microchip-isc-base.c
+++ b/drivers/media/platform/microchip/microchip-isc-base.c
@@ -869,6 +869,39 @@ static int isc_try_configure_pipeline(struct isc_device *isc)
return 0;
}
+static bool isc_format_has_chroma(u32 fourcc)
+{
+ switch (fourcc) {
+ case V4L2_PIX_FMT_YUV420:
+ case V4L2_PIX_FMT_YUV422P:
+ case V4L2_PIX_FMT_YUYV:
+ case V4L2_PIX_FMT_UYVY:
+ case V4L2_PIX_FMT_VYUY:
+ return true;
+ default:
+ return false;
+ }
+}
+
+/* Hue and saturation need chroma, so they stay inactive for RGB output */
+static void isc_update_cbc_ctrl_activity(struct isc_device *isc)
+{
+ bool cbc_active = isc->config.bits_pipeline & CBC_ENABLE;
+ bool chroma_active = cbc_active && isc_format_has_chroma(isc->config.fourcc);
+
+ /* Controls of the other ISC variants stay always active */
+ if (!isc->has_cbhs)
+ return;
+
+ /* Activation sends events, which walk the subscriber list */
+ v4l2_ctrl_lock(isc->brightness_ctrl);
+ v4l2_ctrl_activate(isc->brightness_ctrl, cbc_active);
+ v4l2_ctrl_activate(isc->contrast_ctrl, cbc_active);
+ v4l2_ctrl_activate(isc->hue_ctrl, chroma_active);
+ v4l2_ctrl_activate(isc->sat_ctrl, chroma_active);
+ v4l2_ctrl_unlock(isc->brightness_ctrl);
+}
+
static int isc_try_fmt(struct isc_device *isc, struct v4l2_format *f)
{
struct v4l2_pix_format *pixfmt = &f->fmt.pix;
@@ -999,6 +1032,7 @@ static int isc_link_validate(struct media_link *link)
return ret;
isc->config = isc->try_config;
+ isc_update_cbc_ctrl_activity(isc);
dev_dbg(isc->dev, "New ISC configuration in place\n");
@@ -1457,9 +1491,7 @@ static int isc_s_ctrl(struct v4l2_ctrl *ctrl)
struct isc_device, ctrls.handler);
struct isc_ctrls *ctrls = &isc->ctrls;
- if (ctrl->flags & V4L2_CTRL_FLAG_INACTIVE)
- return 0;
-
+ /* Keep values set while inactive, they are programmed on activation */
switch (ctrl->id) {
case V4L2_CID_BRIGHTNESS:
ctrls->brightness = ctrl->val & ISC_CBC_BRIGHT_MASK;
@@ -1467,6 +1499,15 @@ static int isc_s_ctrl(struct v4l2_ctrl *ctrl)
case V4L2_CID_CONTRAST:
ctrls->contrast = ctrl->val & ISC_CBC_CONTRAST_MASK;
break;
+ case V4L2_CID_HUE:
+ if (isc->has_cbhs)
+ ctrls->hue = (ctrl->val + 360) % 360;
+ break;
+ case V4L2_CID_SATURATION:
+ /* Q4 fixed-point written straight to the register */
+ if (isc->has_cbhs)
+ ctrls->saturation = ctrl->val & ISC_CBHS_SAT_MASK;
+ break;
case V4L2_CID_GAMMA:
ctrls->gamma_index = ctrl->val;
break;
@@ -1653,8 +1694,17 @@ static int isc_ctrl_init(struct isc_device *isc)
isc->config_ctrls(isc, ops);
ctrls->brightness = 0;
-
- v4l2_ctrl_new_std(hdl, ops, V4L2_CID_BRIGHTNESS, -1024, 1023, 1, 0);
+ ctrls->saturation = 16;
+
+ isc->brightness_ctrl = v4l2_ctrl_new_std(hdl, ops, V4L2_CID_BRIGHTNESS,
+ -1024, 1023, 1, 0);
+ if (isc->has_cbhs) {
+ isc->hue_ctrl = v4l2_ctrl_new_std(hdl, ops, V4L2_CID_HUE,
+ -180, 180, 1, 0);
+ isc->sat_ctrl = v4l2_ctrl_new_std(hdl, ops,
+ V4L2_CID_SATURATION,
+ 0, 4095, 1, 16);
+ }
v4l2_ctrl_new_std(hdl, ops, V4L2_CID_GAMMA, 0, isc->gamma_max, 1,
isc->gamma_def);
isc->awb_ctrl = v4l2_ctrl_new_std(hdl, &isc_awb_ops,
diff --git a/drivers/media/platform/microchip/microchip-isc-regs.h b/drivers/media/platform/microchip/microchip-isc-regs.h
index f9bc76c6f35d..daf01afd440c 100644
--- a/drivers/media/platform/microchip/microchip-isc-regs.h
+++ b/drivers/media/platform/microchip/microchip-isc-regs.h
@@ -274,10 +274,17 @@
#define ISC_CBC_CONTRAST 0x000003c0
#define ISC_CBC_CONTRAST_MASK GENMASK(11, 0)
-/* Hue Register */
-#define ISC_CBHS_HUE 0x4e0
-/* Saturation Register */
-#define ISC_CBHS_SAT 0x4e4
+/*
+ * XISC CBHS block. CBC brightness and contrast reach it through
+ * ISC_SAMA7G5_CBC_OFFSET. HUE and SAT are absolute, no offset.
+ */
+
+/* Hue is unsigned 9-bit, 0 to 359 degrees */
+#define ISC_CBHS_HUE 0x4e0
+
+/* Saturation is unsigned 8.4 fixed-point, 16 is unity gain */
+#define ISC_CBHS_SAT 0x4e4
+#define ISC_CBHS_SAT_MASK GENMASK(11, 0)
/* Offset for SUB422 register specific to sama5d2 product */
#define ISC_SAMA5D2_SUB422_OFFSET 0
diff --git a/drivers/media/platform/microchip/microchip-isc.h b/drivers/media/platform/microchip/microchip-isc.h
index 31d9cf84b318..ccb566e5e627 100644
--- a/drivers/media/platform/microchip/microchip-isc.h
+++ b/drivers/media/platform/microchip/microchip-isc.h
@@ -141,6 +141,8 @@ struct isc_ctrls {
u32 brightness;
u32 contrast;
+ u32 hue;
+ u32 saturation;
u8 gamma_index;
#define ISC_WB_NONE 0
#define ISC_WB_AUTO 1
@@ -226,6 +228,11 @@ enum isc_scaler_pads {
*
* @ctrls: holds information about ISC controls
* @do_wb_ctrl: control regarding the DO_WHITE_BALANCE button
+ * @has_cbhs: the CBC stage also has hue and saturation
+ * @brightness_ctrl: brightness control
+ * @contrast_ctrl: contrast control
+ * @hue_ctrl: hue control, only if @has_cbhs
+ * @sat_ctrl: saturation control, only if @has_cbhs
* @awb_work: workqueue reference for autowhitebalance histogram
* analysis
*
@@ -347,6 +354,11 @@ struct isc_device {
const u32 (*gamma_table)[GAMMA_ENTRIES];
u32 gamma_max;
u32 gamma_def;
+ bool has_cbhs;
+ struct v4l2_ctrl *brightness_ctrl;
+ struct v4l2_ctrl *contrast_ctrl;
+ struct v4l2_ctrl *hue_ctrl;
+ struct v4l2_ctrl *sat_ctrl;
u32 max_width;
u32 max_height;
diff --git a/drivers/media/platform/microchip/microchip-sama5d2-isc.c b/drivers/media/platform/microchip/microchip-sama5d2-isc.c
index a93f95434270..ef2a0e6d7167 100644
--- a/drivers/media/platform/microchip/microchip-sama5d2-isc.c
+++ b/drivers/media/platform/microchip/microchip-sama5d2-isc.c
@@ -265,7 +265,8 @@ static void isc_sama5d2_config_ctrls(struct isc_device *isc,
ctrls->contrast = 256;
- v4l2_ctrl_new_std(hdl, ops, V4L2_CID_CONTRAST, -2048, 2047, 1, 256);
+ isc->contrast_ctrl = v4l2_ctrl_new_std(hdl, ops, V4L2_CID_CONTRAST,
+ -2048, 2047, 1, 256);
}
static void isc_sama5d2_config_dpc(struct isc_device *isc)
diff --git a/drivers/media/platform/microchip/microchip-sama7g5-isc.c b/drivers/media/platform/microchip/microchip-sama7g5-isc.c
index f182e19a5519..aec88775d09d 100644
--- a/drivers/media/platform/microchip/microchip-sama7g5-isc.c
+++ b/drivers/media/platform/microchip/microchip-sama7g5-isc.c
@@ -267,9 +267,8 @@ static void isc_sama7g5_config_cbc(struct isc_device *isc)
/* Configure what is set via v4l2 ctrls */
regmap_write(regmap, ISC_CBC_BRIGHT + isc->offsets.cbc, isc->ctrls.brightness);
regmap_write(regmap, ISC_CBC_CONTRAST + isc->offsets.cbc, isc->ctrls.contrast);
- /* Configure Hue and Saturation as neutral midpoint */
- regmap_write(regmap, ISC_CBHS_HUE, 0);
- regmap_write(regmap, ISC_CBHS_SAT, (1 << 4));
+ regmap_write(regmap, ISC_CBHS_HUE, isc->ctrls.hue);
+ regmap_write(regmap, ISC_CBHS_SAT, isc->ctrls.saturation);
}
static void isc_sama7g5_config_cc(struct isc_device *isc)
@@ -293,7 +292,8 @@ static void isc_sama7g5_config_ctrls(struct isc_device *isc,
ctrls->contrast = 16;
- v4l2_ctrl_new_std(hdl, ops, V4L2_CID_CONTRAST, -2048, 2047, 1, 16);
+ isc->contrast_ctrl = v4l2_ctrl_new_std(hdl, ops, V4L2_CID_CONTRAST,
+ -2048, 2047, 1, 16);
}
static void isc_sama7g5_config_dpc(struct isc_device *isc)
@@ -510,6 +510,7 @@ static int microchip_xisc_probe(struct platform_device *pdev)
isc->gamma_table = isc_sama7g5_gamma_table;
isc->gamma_max = 2;
isc->gamma_def = 0;
+ isc->has_cbhs = true;
data = of_device_get_match_data(dev);
if (!data)
--
2.34.1
^ permalink raw reply [flat|nested] 16+ messages in thread* [PATCH 09/15] media: microchip-isc: fix histogram bin index for AWB
2026-12-02 7:16 [PATCH 00/15] media: microchip-isc: fix SAMA7G5 image pipeline and AWB Balakrishnan Sambath
` (7 preceding siblings ...)
2026-12-02 7:16 ` [PATCH 08/15] media: microchip-isc: add SAMA7G5 hue and saturation controls Balakrishnan Sambath
@ 2026-12-02 7:16 ` Balakrishnan Sambath
2026-12-02 7:16 ` [PATCH 10/15] media: microchip-isc: trim outliers in the AWB average Balakrishnan Sambath
` (5 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: Balakrishnan Sambath @ 2026-12-02 7:16 UTC (permalink / raw)
To: ehristev; +Cc: linux-kernel, Balakrishnan Sambath
isc_hist_count() advances hist_entry after each use, so for i = 1..511
it pairs bin i - 1 with weight i. The weighted sum, min and max all come
out one bin high.
Index hist_entry[i] directly so each bin carries its own weight. The
loop still stops short of the last bin, the most white pixels, as the
old comment says. min is now the raw bin, so isc_wb_update() uses it as
the offset without the old minus one.
Fixes: 93d4a26c3dab ("[media] atmel-isc: add the isc pipeline function")
Signed-off-by: Balakrishnan Sambath <balakrishnan.s@microchip.com>
---
.../media/platform/microchip/microchip-isc-base.c | 21 ++++++++++-----------
1 file changed, 10 insertions(+), 11 deletions(-)
diff --git a/drivers/media/platform/microchip/microchip-isc-base.c b/drivers/media/platform/microchip/microchip-isc-base.c
index 3e18933230b8..b2c19879e1c6 100644
--- a/drivers/media/platform/microchip/microchip-isc-base.c
+++ b/drivers/media/platform/microchip/microchip-isc-base.c
@@ -1277,6 +1277,7 @@ static void isc_hist_count(struct isc_device *isc, u32 *min, u32 *max)
struct isc_ctrls *ctrls = &isc->ctrls;
u32 *hist_count = &ctrls->hist_count[ctrls->hist_id];
u32 *hist_entry = &ctrls->hist_entry[0];
+ bool seen = false;
u32 i;
*min = 0;
@@ -1290,17 +1291,17 @@ static void isc_hist_count(struct isc_device *isc, u32 *min, u32 *max)
* we deliberately ignore the end of the histogram,
* the most white pixels
*/
- for (i = 1; i < HIST_ENTRIES; i++) {
- if (*hist_entry && !*min)
+ for (i = 0; i < HIST_ENTRIES - 1; i++) {
+ if (!hist_entry[i])
+ continue;
+ if (!seen) {
*min = i;
- if (*hist_entry)
- *max = i;
- *hist_count += i * (*hist_entry++);
+ seen = true;
+ }
+ *max = i;
+ *hist_count += i * hist_entry[i];
}
- if (!*min)
- *min = 1;
-
dev_dbg(isc->dev, "isc wb: hist_id %u, hist_count %u",
ctrls->hist_id, *hist_count);
}
@@ -1338,15 +1339,13 @@ static void isc_wb_update(struct isc_ctrls *ctrls)
*/
offset[c] = ctrls->hist_minmax[c][HIST_MIN_INDEX];
/*
- * 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.
* the offset is computed in a histogram on 9 bits (0..512)
* but the offset in register is based on
* 12 bits pipeline (0..4096).
* we need to shift with the 3 bits that the histogram is
* ignoring
*/
- ctrls->offset[c] = (offset[c] - 1) << 3;
+ ctrls->offset[c] = offset[c] << 3;
/*
* the offset is then taken and converted to 2's complements,
--
2.34.1
^ permalink raw reply [flat|nested] 16+ messages in thread* [PATCH 10/15] media: microchip-isc: trim outliers in the AWB average
2026-12-02 7:16 [PATCH 00/15] media: microchip-isc: fix SAMA7G5 image pipeline and AWB Balakrishnan Sambath
` (8 preceding siblings ...)
2026-12-02 7:16 ` [PATCH 09/15] media: microchip-isc: fix histogram bin index for AWB Balakrishnan Sambath
@ 2026-12-02 7:16 ` Balakrishnan Sambath
2026-12-02 7:16 ` [PATCH 11/15] media: microchip-isc: skip AWB on near-empty channels Balakrishnan Sambath
` (4 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: Balakrishnan Sambath @ 2026-12-02 7:16 UTC (permalink / raw)
To: ehristev; +Cc: linux-kernel, Balakrishnan Sambath
Skip the darkest and brightest 2% of each channel histogram
(ISC_AWB_OUTLIER_DIV) when picking min and max, so a few hot or dark
pixels no longer set the stretch range.
Keep the mean over the remaining bins in ctrls->channel_avg[] in place
of the raw sum, hist_count[]. The pixel count left after the trim
differs per channel, so the raw sums no longer compare across channels.
An empty histogram reports a zero mean, so the null green check in
isc_wb_update() still returns early and the gains stay as they are.
The trim counts bins 0 to 510 only, the last bin stays out as before, so
the outlier budget is taken from the same count. When the bins above min
fit in the budget, max settles on min and the mean is that bin.
Signed-off-by: Balakrishnan Sambath <balakrishnan.s@microchip.com>
---
.../media/platform/microchip/microchip-isc-base.c | 78 +++++++++++++++-------
drivers/media/platform/microchip/microchip-isc.h | 2 +-
2 files changed, 54 insertions(+), 26 deletions(-)
diff --git a/drivers/media/platform/microchip/microchip-isc-base.c b/drivers/media/platform/microchip/microchip-isc-base.c
index b2c19879e1c6..2787de606b4a 100644
--- a/drivers/media/platform/microchip/microchip-isc-base.c
+++ b/drivers/media/platform/microchip/microchip-isc-base.c
@@ -40,6 +40,9 @@
(((mbus_code) == MEDIA_BUS_FMT_Y10_1X10) | \
(((mbus_code) == MEDIA_BUS_FMT_Y8_1X8)))
+/* Skip the darkest and brightest 2% of the histogram as outliers */
+#define ISC_AWB_OUTLIER_DIV 50
+
static inline void isc_update_v4l2_ctrls(struct isc_device *isc)
{
struct isc_ctrls *ctrls = &isc->ctrls;
@@ -1275,41 +1278,66 @@ static void isc_hist_count(struct isc_device *isc, u32 *min, u32 *max)
{
struct regmap *regmap = isc->regmap;
struct isc_ctrls *ctrls = &isc->ctrls;
- u32 *hist_count = &ctrls->hist_count[ctrls->hist_id];
u32 *hist_entry = &ctrls->hist_entry[0];
- bool seen = false;
+ u64 weighted_sum = 0;
+ u32 cumulative, outlier;
+ u32 total_pixels = 0;
+ u32 pixels = 0;
u32 i;
- *min = 0;
- *max = HIST_ENTRIES;
-
regmap_bulk_read(regmap, ISC_HIS_ENTRY + isc->offsets.his_entry,
hist_entry, HIST_ENTRIES);
- *hist_count = 0;
- /*
- * we deliberately ignore the end of the histogram,
- * the most white pixels
- */
+ /* The last bin, the most white pixels, is deliberately left out */
+ for (i = 0; i < HIST_ENTRIES - 1; i++)
+ total_pixels += hist_entry[i];
+
+ /* No pixels, a zero average leaves the gains alone */
+ if (!total_pixels) {
+ ctrls->channel_avg[ctrls->hist_id] = 0;
+ *min = 0;
+ *max = HIST_ENTRIES - 2;
+ return;
+ }
+
+ outlier = total_pixels / ISC_AWB_OUTLIER_DIV;
+
+ /* The effective minimum skips the dark outliers */
+ cumulative = 0;
for (i = 0; i < HIST_ENTRIES - 1; i++) {
- if (!hist_entry[i])
- continue;
- if (!seen) {
- *min = i;
- seen = true;
- }
- *max = i;
- *hist_count += i * hist_entry[i];
+ cumulative += hist_entry[i];
+ if (cumulative > outlier)
+ break;
+ }
+ *min = i;
+
+ /* The maximum skips the bright ones and stops at the minimum */
+ cumulative = 0;
+ for (i = HIST_ENTRIES - 2; i > *min; i--) {
+ cumulative += hist_entry[i];
+ if (cumulative > outlier)
+ break;
}
+ *max = i;
- dev_dbg(isc->dev, "isc wb: hist_id %u, hist_count %u",
- ctrls->hist_id, *hist_count);
+ for (i = *min; i <= *max; i++) {
+ pixels += hist_entry[i];
+ weighted_sum += (u64)i * hist_entry[i];
+ }
+
+ /* The minimum bin is occupied, so pixels is never zero */
+ ctrls->channel_avg[ctrls->hist_id] = div_u64(weighted_sum, pixels);
+
+ dev_dbg(isc->dev,
+ "isc wb: hist_id %u, avg %u, range [%u,%u], total %u\n",
+ ctrls->hist_id, ctrls->channel_avg[ctrls->hist_id],
+ *min, *max, total_pixels);
}
static void isc_wb_update(struct isc_ctrls *ctrls)
{
struct isc_device *isc = container_of(ctrls, struct isc_device, ctrls);
- u32 *hist_count = &ctrls->hist_count[0];
+ u32 *channel_avg = &ctrls->channel_avg[0];
u32 c, offset[4];
u64 avg = 0;
/* We compute two gains, stretch gain and grey world gain */
@@ -1321,8 +1349,8 @@ static void isc_wb_update(struct isc_ctrls *ctrls)
* Thus we want to keep Green as fixed and adjust only Red/Blue
* Compute the average of the both green channels first
*/
- avg = (u64)hist_count[ISC_HIS_CFG_MODE_GR] +
- (u64)hist_count[ISC_HIS_CFG_MODE_GB];
+ avg = (u64)channel_avg[ISC_HIS_CFG_MODE_GR] +
+ (u64)channel_avg[ISC_HIS_CFG_MODE_GB];
avg >>= 1;
dev_dbg(isc->dev, "isc wb: green components average %llu\n", avg);
@@ -1372,8 +1400,8 @@ static void isc_wb_update(struct isc_ctrls *ctrls)
* If it happens that the component is zero, use the
* fixed point value : 1.0 gain.
*/
- if (hist_count[c])
- gw_gain[c] = div_u64(avg << 9, hist_count[c]);
+ if (channel_avg[c])
+ gw_gain[c] = div_u64(avg << 9, channel_avg[c]);
else
gw_gain[c] = 1 << 9;
diff --git a/drivers/media/platform/microchip/microchip-isc.h b/drivers/media/platform/microchip/microchip-isc.h
index ccb566e5e627..1784c0089296 100644
--- a/drivers/media/platform/microchip/microchip-isc.h
+++ b/drivers/media/platform/microchip/microchip-isc.h
@@ -154,12 +154,12 @@ struct isc_ctrls {
s32 offset[HIST_BAYER];
u32 hist_entry[HIST_ENTRIES];
- u32 hist_count[HIST_BAYER];
u8 hist_id;
u8 hist_stat;
#define HIST_MIN_INDEX 0
#define HIST_MAX_INDEX 1
u32 hist_minmax[HIST_BAYER][2];
+ u32 channel_avg[HIST_BAYER];
};
#define ISC_PIPE_LINE_NODE_NUM 15
--
2.34.1
^ permalink raw reply [flat|nested] 16+ messages in thread* [PATCH 11/15] media: microchip-isc: skip AWB on near-empty channels
2026-12-02 7:16 [PATCH 00/15] media: microchip-isc: fix SAMA7G5 image pipeline and AWB Balakrishnan Sambath
` (9 preceding siblings ...)
2026-12-02 7:16 ` [PATCH 10/15] media: microchip-isc: trim outliers in the AWB average Balakrishnan Sambath
@ 2026-12-02 7:16 ` Balakrishnan Sambath
2026-12-02 7:16 ` [PATCH 12/15] media: microchip-isc: do the AWB gain product in 64 bits Balakrishnan Sambath
` (3 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: Balakrishnan Sambath @ 2026-12-02 7:16 UTC (permalink / raw)
To: ehristev; +Cc: linux-kernel, Balakrishnan Sambath
A channel with only a few pixels left after the trim gives a noisy min,
max and mean, which swings the gains on dark or flat frames.
Track the kept pixel count in ctrls->total_pixels[]. Leave a channel at
offset 0 and gain 1.0 (1 << 9) when it has fewer than frame_pixels / 64
pixels, 64 at least. Leave all gains alone when either green channel is
under the limit, as the green average is the reference for R and B.
Signed-off-by: Balakrishnan Sambath <balakrishnan.s@microchip.com>
---
drivers/media/platform/microchip/microchip-isc-base.c | 19 +++++++++++++++++++
drivers/media/platform/microchip/microchip-isc.h | 1 +
2 files changed, 20 insertions(+)
diff --git a/drivers/media/platform/microchip/microchip-isc-base.c b/drivers/media/platform/microchip/microchip-isc-base.c
index 2787de606b4a..491f710fe08d 100644
--- a/drivers/media/platform/microchip/microchip-isc-base.c
+++ b/drivers/media/platform/microchip/microchip-isc-base.c
@@ -1295,6 +1295,7 @@ static void isc_hist_count(struct isc_device *isc, u32 *min, u32 *max)
/* No pixels, a zero average leaves the gains alone */
if (!total_pixels) {
ctrls->channel_avg[ctrls->hist_id] = 0;
+ ctrls->total_pixels[ctrls->hist_id] = 0;
*min = 0;
*max = HIST_ENTRIES - 2;
return;
@@ -1326,6 +1327,7 @@ static void isc_hist_count(struct isc_device *isc, u32 *min, u32 *max)
}
/* The minimum bin is occupied, so pixels is never zero */
+ ctrls->total_pixels[ctrls->hist_id] = pixels;
ctrls->channel_avg[ctrls->hist_id] = div_u64(weighted_sum, pixels);
dev_dbg(isc->dev,
@@ -1339,6 +1341,7 @@ static void isc_wb_update(struct isc_ctrls *ctrls)
struct isc_device *isc = container_of(ctrls, struct isc_device, ctrls);
u32 *channel_avg = &ctrls->channel_avg[0];
u32 c, offset[4];
+ u32 min_pixels;
u64 avg = 0;
/* We compute two gains, stretch gain and grey world gain */
u32 s_gain[4], gw_gain[4];
@@ -1359,7 +1362,23 @@ static void isc_wb_update(struct isc_ctrls *ctrls)
if (!avg)
return;
+ /* A channel under 1/64 of the frame, 64 pixels at least, is noise */
+ min_pixels = max(isc->fmt.fmt.pix.width * isc->fmt.fmt.pix.height >> 6,
+ 64u);
+
+ /* A noisy green skews the average the other gains aim for */
+ if (ctrls->total_pixels[ISC_HIS_CFG_MODE_GR] < min_pixels ||
+ ctrls->total_pixels[ISC_HIS_CFG_MODE_GB] < min_pixels)
+ return;
+
for (c = ISC_HIS_CFG_MODE_GR; c <= ISC_HIS_CFG_MODE_B; c++) {
+ /* Leave the channel neutral, no offset and a gain of 1.0 */
+ if (ctrls->total_pixels[c] < min_pixels) {
+ ctrls->offset[c] = 0;
+ ctrls->gain[c] = 1 << 9;
+ continue;
+ }
+
/*
* the color offset is the minimum value of the histogram.
* we stretch this color to the full range by substracting
diff --git a/drivers/media/platform/microchip/microchip-isc.h b/drivers/media/platform/microchip/microchip-isc.h
index 1784c0089296..2c3efd2fc56e 100644
--- a/drivers/media/platform/microchip/microchip-isc.h
+++ b/drivers/media/platform/microchip/microchip-isc.h
@@ -160,6 +160,7 @@ struct isc_ctrls {
#define HIST_MAX_INDEX 1
u32 hist_minmax[HIST_BAYER][2];
u32 channel_avg[HIST_BAYER];
+ u32 total_pixels[HIST_BAYER];
};
#define ISC_PIPE_LINE_NODE_NUM 15
--
2.34.1
^ permalink raw reply [flat|nested] 16+ messages in thread* [PATCH 12/15] media: microchip-isc: do the AWB gain product in 64 bits
2026-12-02 7:16 [PATCH 00/15] media: microchip-isc: fix SAMA7G5 image pipeline and AWB Balakrishnan Sambath
` (10 preceding siblings ...)
2026-12-02 7:16 ` [PATCH 11/15] media: microchip-isc: skip AWB on near-empty channels Balakrishnan Sambath
@ 2026-12-02 7:16 ` Balakrishnan Sambath
2026-12-02 7:16 ` [PATCH 13/15] media: microchip-isc: smooth AWB gains with an EMA filter Balakrishnan Sambath
` (2 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: Balakrishnan Sambath @ 2026-12-02 7:16 UTC (permalink / raw)
To: ehristev; +Cc: linux-kernel, Balakrishnan Sambath
s_gain and gw_gain are Q9, so their product is Q18 and can wrap a u32
on a strong stretch with a large grey world gain. Multiply in u64 and
clamp the Q9 result to GENMASK(12, 0), the width of the gain field.
Signed-off-by: Balakrishnan Sambath <balakrishnan.s@microchip.com>
---
drivers/media/platform/microchip/microchip-isc-base.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/drivers/media/platform/microchip/microchip-isc-base.c b/drivers/media/platform/microchip/microchip-isc-base.c
index 491f710fe08d..a767dfc719f3 100644
--- a/drivers/media/platform/microchip/microchip-isc-base.c
+++ b/drivers/media/platform/microchip/microchip-isc-base.c
@@ -1428,11 +1428,9 @@ static void isc_wb_update(struct isc_ctrls *ctrls)
"isc wb: component %d, s_gain %u, gw_gain %u\n",
c, s_gain[c], gw_gain[c]);
/* multiply both gains and adjust for decimals */
- ctrls->gain[c] = s_gain[c] * gw_gain[c];
- ctrls->gain[c] >>= 9;
-
- /* make sure we are not out of range */
- ctrls->gain[c] = clamp_val(ctrls->gain[c], 0, GENMASK(12, 0));
+ /* the product of two Q9 gains can exceed 32 bits */
+ ctrls->gain[c] = min_t(u64, ((u64)s_gain[c] * gw_gain[c]) >> 9,
+ GENMASK(12, 0));
dev_dbg(isc->dev, "isc wb: component %d, final gain %u\n",
c, ctrls->gain[c]);
--
2.34.1
^ permalink raw reply [flat|nested] 16+ messages in thread* [PATCH 13/15] media: microchip-isc: smooth AWB gains with an EMA filter
2026-12-02 7:16 [PATCH 00/15] media: microchip-isc: fix SAMA7G5 image pipeline and AWB Balakrishnan Sambath
` (11 preceding siblings ...)
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 ` 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
14 siblings, 0 replies; 16+ messages in thread
From: Balakrishnan Sambath @ 2026-12-02 7:16 UTC (permalink / raw)
To: ehristev; +Cc: linux-kernel, Balakrishnan Sambath
The grey world gains are recomputed from every histogram and follow
sensor noise from frame to frame. Filter them with an exponential moving
average, gain_smooth = (3 * gain_smooth + gain + 2) / 4 (alpha = 0.25),
and write the result to ctrls->gain[]. Only ISC_WB_AUTO filters. One-time
white balance and a channel held neutral load gain_smooth[] directly.
Manual gains are written to ctrls->gain[] only, so seed gain_smooth[]
from them when AWB is switched on. Otherwise the filter would start from
the last automatic result. Take awb_mutex before the mode and the manual
gains are written, so the AWB work cannot interleave with the seed.
Signed-off-by: Balakrishnan Sambath <balakrishnan.s@microchip.com>
---
.../media/platform/microchip/microchip-isc-base.c | 37 ++++++++++++++++++----
drivers/media/platform/microchip/microchip-isc.h | 1 +
2 files changed, 32 insertions(+), 6 deletions(-)
diff --git a/drivers/media/platform/microchip/microchip-isc-base.c b/drivers/media/platform/microchip/microchip-isc-base.c
index a767dfc719f3..f40088246651 100644
--- a/drivers/media/platform/microchip/microchip-isc-base.c
+++ b/drivers/media/platform/microchip/microchip-isc-base.c
@@ -86,6 +86,7 @@ static inline void isc_reset_awb_ctrls(struct isc_device *isc)
for (c = ISC_HIS_CFG_MODE_GR; c <= ISC_HIS_CFG_MODE_B; c++) {
/* gains have a fixed point at 9 decimals */
isc->ctrls.gain[c] = 1 << 9;
+ isc->ctrls.gain_smooth[c] = 1 << 9;
/* offsets are in 2's complements */
isc->ctrls.offset[c] = 0;
}
@@ -1342,6 +1343,7 @@ static void isc_wb_update(struct isc_ctrls *ctrls)
u32 *channel_avg = &ctrls->channel_avg[0];
u32 c, offset[4];
u32 min_pixels;
+ u32 gain;
u64 avg = 0;
/* We compute two gains, stretch gain and grey world gain */
u32 s_gain[4], gw_gain[4];
@@ -1376,6 +1378,7 @@ static void isc_wb_update(struct isc_ctrls *ctrls)
if (ctrls->total_pixels[c] < min_pixels) {
ctrls->offset[c] = 0;
ctrls->gain[c] = 1 << 9;
+ ctrls->gain_smooth[c] = 1 << 9;
continue;
}
@@ -1428,12 +1431,22 @@ static void isc_wb_update(struct isc_ctrls *ctrls)
"isc wb: component %d, s_gain %u, gw_gain %u\n",
c, s_gain[c], gw_gain[c]);
/* multiply both gains and adjust for decimals */
- /* the product of two Q9 gains can exceed 32 bits */
- ctrls->gain[c] = min_t(u64, ((u64)s_gain[c] * gw_gain[c]) >> 9,
- GENMASK(12, 0));
+ /* Clamp before smoothing so one outlier cannot saturate it */
+ gain = min_t(u64, ((u64)s_gain[c] * gw_gain[c]) >> 9,
+ GENMASK(12, 0));
- dev_dbg(isc->dev, "isc wb: component %d, final gain %u\n",
- c, ctrls->gain[c]);
+ /* 1/4 EMA, +2 rounds to nearest. Only auto AWB filters */
+ if (ctrls->awb != ISC_WB_AUTO)
+ ctrls->gain_smooth[c] = gain;
+ else
+ ctrls->gain_smooth[c] =
+ (3 * ctrls->gain_smooth[c] + gain + 2) / 4;
+
+ ctrls->gain[c] = ctrls->gain_smooth[c];
+
+ dev_dbg(isc->dev,
+ "isc wb: component %d, gain %u, smooth %u\n",
+ c, gain, ctrls->gain_smooth[c]);
}
}
@@ -1463,7 +1476,10 @@ static void isc_awb_work(struct work_struct *w)
if (hist_id != ISC_HIS_CFG_MODE_B) {
hist_id++;
} else {
+ /* gain_smooth is also seeded from the control path */
+ mutex_lock(&isc->awb_mutex);
isc_wb_update(ctrls);
+ mutex_unlock(&isc->awb_mutex);
hist_id = ISC_HIS_CFG_MODE_GR;
}
@@ -1571,12 +1587,17 @@ static int isc_s_awb_ctrl(struct v4l2_ctrl *ctrl)
struct isc_device *isc = container_of(ctrl->handler,
struct isc_device, ctrls.handler);
struct isc_ctrls *ctrls = &isc->ctrls;
+ bool was_auto;
if (ctrl->flags & V4L2_CTRL_FLAG_INACTIVE)
return 0;
switch (ctrl->id) {
case V4L2_CID_AUTO_WHITE_BALANCE:
+ /* The AWB work reads the mode and the gains under this mutex */
+ mutex_lock(&isc->awb_mutex);
+ was_auto = ctrls->awb == ISC_WB_AUTO;
+
if (ctrl->val == 1)
ctrls->awb = ISC_WB_AUTO;
else
@@ -1601,7 +1622,11 @@ static int isc_s_awb_ctrl(struct v4l2_ctrl *ctrl)
if (ctrl->cluster[ISC_CTRL_GB_OFF]->is_new)
ctrls->offset[ISC_HIS_CFG_MODE_GB] = isc->gb_off_ctrl->val;
- mutex_lock(&isc->awb_mutex);
+ /* Start the EMA from the gains in use, not the last AWB run */
+ if (!was_auto && ctrls->awb == ISC_WB_AUTO)
+ memcpy(ctrls->gain_smooth, ctrls->gain,
+ sizeof(ctrls->gain_smooth));
+
if (vb2_is_streaming(&isc->vb2_vidq) && !isc->stop) {
unsigned long flags;
diff --git a/drivers/media/platform/microchip/microchip-isc.h b/drivers/media/platform/microchip/microchip-isc.h
index 2c3efd2fc56e..b17a216ca109 100644
--- a/drivers/media/platform/microchip/microchip-isc.h
+++ b/drivers/media/platform/microchip/microchip-isc.h
@@ -151,6 +151,7 @@ struct isc_ctrls {
/* one for each component : GR, R, GB, B */
u32 gain[HIST_BAYER];
+ u32 gain_smooth[HIST_BAYER];
s32 offset[HIST_BAYER];
u32 hist_entry[HIST_ENTRIES];
--
2.34.1
^ permalink raw reply [flat|nested] 16+ messages in thread* [PATCH 14/15] media: microchip-isc: use an unsigned contrast range
2026-12-02 7:16 [PATCH 00/15] media: microchip-isc: fix SAMA7G5 image pipeline and AWB Balakrishnan Sambath
` (12 preceding siblings ...)
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 ` Balakrishnan Sambath
2026-12-02 7:16 ` [PATCH 15/15] media: microchip-isc: add driver documentation Balakrishnan Sambath
14 siblings, 0 replies; 16+ messages in thread
From: Balakrishnan Sambath @ 2026-12-02 7:16 UTC (permalink / raw)
To: ehristev; +Cc: linux-kernel, Balakrishnan Sambath
ISC_CBC_CONTRAST holds an unsigned 12-bit value (CONTRAST bits 11 to 0,
ISC_CBC_CONTRAST_MASK), but V4L2_CID_CONTRAST was registered as
-2048..2047 on both SAMA5D2 and SAMA7G5. A negative value is masked
into the upper half of the field, so contrast=-1 programs 0xfff and
the frame clips to white. Register the control as 0..4095 on both.
The defaults stay at 256 on SAMA5D2 (DS60001476B, section 52.6.44)
and 16 on SAMA7G5. On sama7g5ek with an imx219 at 640x480 YUYV the mean
luma of a fixed scene is 33.3, 67.9 and 134.8 at 4, 8 and 16, and every
pixel clips at 256. The SAMA7G5 (section 43.7.61) and SAM9X7 (section
52.7.61) datasheets describe the field as 0-4-8, which does not match
this scale. The SAMA5D2 unity value of 256 is datasheet-only and has
not been measured on hardware.
VIDIOC_QUERYCTRL now reports a minimum of 0 and a maximum of 4095
instead of -2048 and 2047. The V4L2 core clamps a negative request to 0
where the old range let it through to the register.
Signed-off-by: Balakrishnan Sambath <balakrishnan.s@microchip.com>
---
drivers/media/platform/microchip/microchip-sama5d2-isc.c | 2 +-
drivers/media/platform/microchip/microchip-sama7g5-isc.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/media/platform/microchip/microchip-sama5d2-isc.c b/drivers/media/platform/microchip/microchip-sama5d2-isc.c
index ef2a0e6d7167..7e5187fed363 100644
--- a/drivers/media/platform/microchip/microchip-sama5d2-isc.c
+++ b/drivers/media/platform/microchip/microchip-sama5d2-isc.c
@@ -266,7 +266,7 @@ static void isc_sama5d2_config_ctrls(struct isc_device *isc,
ctrls->contrast = 256;
isc->contrast_ctrl = v4l2_ctrl_new_std(hdl, ops, V4L2_CID_CONTRAST,
- -2048, 2047, 1, 256);
+ 0, 4095, 1, 256);
}
static void isc_sama5d2_config_dpc(struct isc_device *isc)
diff --git a/drivers/media/platform/microchip/microchip-sama7g5-isc.c b/drivers/media/platform/microchip/microchip-sama7g5-isc.c
index aec88775d09d..cc65db891ec7 100644
--- a/drivers/media/platform/microchip/microchip-sama7g5-isc.c
+++ b/drivers/media/platform/microchip/microchip-sama7g5-isc.c
@@ -293,7 +293,7 @@ static void isc_sama7g5_config_ctrls(struct isc_device *isc,
ctrls->contrast = 16;
isc->contrast_ctrl = v4l2_ctrl_new_std(hdl, ops, V4L2_CID_CONTRAST,
- -2048, 2047, 1, 16);
+ 0, 4095, 1, 16);
}
static void isc_sama7g5_config_dpc(struct isc_device *isc)
--
2.34.1
^ permalink raw reply [flat|nested] 16+ messages in thread* [PATCH 15/15] media: microchip-isc: add driver documentation
2026-12-02 7:16 [PATCH 00/15] media: microchip-isc: fix SAMA7G5 image pipeline and AWB Balakrishnan Sambath
` (13 preceding siblings ...)
2026-12-02 7:16 ` [PATCH 14/15] media: microchip-isc: use an unsigned contrast range Balakrishnan Sambath
@ 2026-12-02 7:16 ` Balakrishnan Sambath
14 siblings, 0 replies; 16+ messages in thread
From: Balakrishnan Sambath @ 2026-12-02 7:16 UTC (permalink / raw)
To: ehristev; +Cc: linux-kernel, Balakrishnan Sambath
Document the V4L2 controls and the pipeline modes of the ISC on SAMA5D2
and the XISC on SAMA7G5 and SAM9X7, and add the page to MAINTAINERS.
Signed-off-by: Balakrishnan Sambath <balakrishnan.s@microchip.com>
---
.../userspace-api/media/drivers/index.rst | 1 +
.../userspace-api/media/drivers/microchip-isc.rst | 70 ++++++++++++++++++++++
MAINTAINERS | 1 +
3 files changed, 72 insertions(+)
diff --git a/Documentation/userspace-api/media/drivers/index.rst b/Documentation/userspace-api/media/drivers/index.rst
index 8d2c489b8453..a447331b7e2f 100644
--- a/Documentation/userspace-api/media/drivers/index.rst
+++ b/Documentation/userspace-api/media/drivers/index.rst
@@ -35,6 +35,7 @@ For more details see the file COPYING in the source distribution of Linux.
imx-uapi
mali-c55
max2175
+ microchip-isc
npcm-video
omap3isp-uapi
thp7312
diff --git a/Documentation/userspace-api/media/drivers/microchip-isc.rst b/Documentation/userspace-api/media/drivers/microchip-isc.rst
new file mode 100644
index 000000000000..ac898c9933f9
--- /dev/null
+++ b/Documentation/userspace-api/media/drivers/microchip-isc.rst
@@ -0,0 +1,70 @@
+.. SPDX-License-Identifier: GPL-2.0
+
+Microchip ISC/XISC Driver
+=========================
+
+The Image Sensor Controller (ISC) on SAMA5D2 and eXtended ISC (XISC) on
+SAMA7G5/SAM9X7 provide camera capture with hardware image processing.
+
+Supported Hardware
+------------------
+
+========== ========== ============== ================ ===============
+SoC Controller Max Resolution Interface Hue/Saturation
+========== ========== ============== ================ ===============
+SAMA5D2 ISC 2592x1944 12-bit parallel No
+SAMA7G5 XISC 3264x2464 12-bit + CSI-2 Yes
+SAM9X7 XISC 2560x1920 12-bit + CSI-2 Yes
+========== ========== ============== ================ ===============
+
+SAM9X7 shares the XISC pipeline with SAMA7G5 but is limited to 2560 pixels
+horizontally.
+
+Controls
+--------
+
+Standard V4L2 controls:
+
+* ``V4L2_CID_BRIGHTNESS``: -1024..1023, default 0
+* ``V4L2_CID_CONTRAST``: 0..4095, default 256 (ISC), 16 (XISC)
+* ``V4L2_CID_GAMMA``: 0..2 selects a preset curve, default 2 (ISC) or 0
+ (XISC), both 1/2.2. The curve order differs per variant: ISC gives 1/1.8,
+ 1/2.0, 1/2.2 and XISC gives 1/2.2, 1/2.4, 1/1.8
+* ``V4L2_CID_AUTO_WHITE_BALANCE``: Enable kernel Grey World AWB
+* ``V4L2_CID_DO_WHITE_BALANCE``: Trigger one-shot AWB
+
+SAMA7G5/SAM9X7 add:
+
+* ``V4L2_CID_HUE``: -180..180 degrees
+* ``V4L2_CID_SATURATION``: 0..4095, default 16 (8.4 fixed point, 16 is unity gain)
+
+Custom controls (defined in ``atmel-isc-media.h``):
+
+* ``ISC_CID_R_GAIN``, ``ISC_CID_B_GAIN``, ``ISC_CID_GR_GAIN``,
+ ``ISC_CID_GB_GAIN``: WB gains, 0..8191, Q2.9 (512 = 1.0x)
+* ``ISC_CID_R_OFFSET``, ``ISC_CID_B_OFFSET``, ``ISC_CID_GR_OFFSET``,
+ ``ISC_CID_GB_OFFSET``: WB offsets, -4095..4095
+
+Pipeline
+--------
+
+Pipeline modules: DPC -> WB -> CFA -> CC -> GAM -> VHXS -> CSC -> CBC/CBHS -> SUB
+
+* DPC: Black level subtraction scaled to the sensor bit depth (XISC only)
+* WB: White Balance gains/offsets
+* CFA: Color Filter Array interpolation (demosaic)
+* CC: Color Correction matrix
+* GAM: Gamma correction (preset)
+* VHXS: Vertical and horizontal scaler (XISC only)
+* CSC: Color Space Conversion (RGB to YCbCr)
+* CBC: Contrast/Brightness (ISC only)
+* CBHS: Contrast/Brightness/Hue/Saturation (XISC only)
+* SUB: Chroma subsampling (4:2:2, 4:2:0)
+
+Pipeline usage depends on input and output formats:
+
+* Raw Bayer input, RGB output: DPC, WB, CFA, CC, GAM
+* Raw Bayer input, YUV output: Full pipeline including CSC, CBHS/CBC, SUB
+* Raw Bayer input, raw Bayer output: pipeline bypassed on XISC, delivering
+ unmodified sensor data for a software ISP. The ISC keeps WB enabled
+* Non-RAW input (YUV/RGB sensor): Pipeline bypassed
diff --git a/MAINTAINERS b/MAINTAINERS
index 70b6a8d49c01..a6af841e695a 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -18194,6 +18194,7 @@ L: linux-media@vger.kernel.org
S: Supported
F: Documentation/devicetree/bindings/media/atmel,isc.yaml
F: Documentation/devicetree/bindings/media/microchip,xisc.yaml
+F: Documentation/userspace-api/media/drivers/microchip-isc.rst
F: drivers/media/platform/microchip/microchip-isc*
F: drivers/media/platform/microchip/microchip-sama*-isc*
F: include/linux/atmel-isc-media.h
--
2.34.1
^ permalink raw reply [flat|nested] 16+ messages in thread