[PATCH 13/18] media: microchip-isc: Store histogram data of all channels

Balamanikandan Gunasundar
2025-10-09T15:55:29Z

Store the histogram data for all 4 channels(R, B, GR, GB). The data of each
channel is available on one interrupt. We need 4 interrupt cycles to get
all four channels. Store all the channels in a 2D array. This data is later
passed to the application buffer when it requests for a dequeue.

Signed-off-by: Balamanikandan Gunasundar <balamanikandan.gunasundar@microchip.com>
---
drivers/media/platform/microchip/microchip-isc-base.c | 2 +-
drivers/media/platform/microchip/microchip-isc-stats.c | 2 +-
drivers/media/platform/microchip/microchip-isc.h | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/media/platform/microchip/microchip-isc-base.c b/drivers/media/platform/microchip/microchip-isc-base.c
index e9bd191f042b..6651be6fcb57 100644
--- a/drivers/media/platform/microchip/microchip-isc-base.c
+++ b/drivers/media/platform/microchip/microchip-isc-base.c
@@ -1225,7 +1225,7 @@ 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];
+ u32 *hist_entry = &ctrls->hist_entry[ctrls->hist_id][0];
u32 i;

*min = 0;
diff --git a/drivers/media/platform/microchip/microchip-isc-stats.c b/drivers/media/platform/microchip/microchip-isc-stats.c
index d7813c9d95ac..1f3d1ea75005 100644
--- a/drivers/media/platform/microchip/microchip-isc-stats.c
+++ b/drivers/media/platform/microchip/microchip-isc-stats.c
@@ -298,7 +298,7 @@ static void isc_stats_fill_data(struct isc_stats *stats,

/* Copy existing histogram data from AWB work function */
for (c = 0; c < HIST_BAYER; c++) {
- memcpy(pbuf->hist[c].hist_bins, isc->full_hist_data[c],
+ memcpy(pbuf->hist[c].hist_bins, &isc->ctrls.hist_entry[0][c],
sizeof(pbuf->hist[c].hist_bins));

pbuf->hist[c].hist_min = ctrls->hist_minmax[c][HIST_MIN_INDEX];
diff --git a/drivers/media/platform/microchip/microchip-isc.h b/drivers/media/platform/microchip/microchip-isc.h
index 35dfd2501ea2..fcb20669ef69 100644
--- a/drivers/media/platform/microchip/microchip-isc.h
+++ b/drivers/media/platform/microchip/microchip-isc.h
@@ -151,7 +151,7 @@ struct isc_ctrls {
u32 gain[HIST_BAYER];
s32 offset[HIST_BAYER];

- u32 hist_entry[HIST_ENTRIES];
+ u32 hist_entry[HIST_BAYER][HIST_ENTRIES];
u32 hist_count[HIST_BAYER];
u8 hist_id;
u8 hist_stat;
--
2.34.1