[PATCH 00/18] media: microchip-isc: Color correction and histogram stats

Balamanikandan Gunasundar posted 18 patches 4 months ago
drivers/media/platform/microchip/Kconfig      |   2 +
drivers/media/platform/microchip/Makefile     |   2 +-
.../platform/microchip/microchip-isc-base.c   | 373 ++++++++++--
.../platform/microchip/microchip-isc-regs.h   |   3 +
.../platform/microchip/microchip-isc-stats.c  | 549 ++++++++++++++++++
.../media/platform/microchip/microchip-isc.h  |  44 +-
.../microchip/microchip-sama5d2-isc.c         |   2 +-
.../microchip/microchip-sama7g5-isc.c         |  73 ++-
drivers/media/v4l2-core/v4l2-ioctl.c          |   1 +
include/linux/atmel-isc-media.h               |  13 +
include/uapi/linux/videodev2.h                |   3 +
11 files changed, 1001 insertions(+), 64 deletions(-)
create mode 100644 drivers/media/platform/microchip/microchip-isc-stats.c
[PATCH 00/18] media: microchip-isc: Color correction and histogram stats
Posted by Balamanikandan Gunasundar 4 months ago
Hi,

This patch series has a set of enhancements to the Microchip Image Sensor
Controller driver. The objective is to expand its image processing
capabilities and to improve the colors.

This series also introduces a new stats driver that exposes the histogram
data to userspace via v4l2 controls. This allows applications such as
libcamera to access real time image statistics for advanced image
processing like automatic exposure, white balance adjustments etc.

Balakrishnan Sambath (11):
  media: microchip-isc: Enable GDC and CBC module flags for RGB formats
  media: microchip-isc: Improve histogram calculation with outlier
    rejection
  media: microchip-isc: Use channel averages for Grey World AWB
  media: microchip-isc: Add range based black level correction
  media: platform: microchip: Extend gamma table and control range
  media: platform: microchip: Add new histogram submodule
  media: microchip-isc: Register and unregister statistics device
  media: microchip-isc: Always enable histogram for all RAW formats
  media: microchip-isc: fix histogram state initialization order
  media: microchip-isc: decouple histogram cycling from AWB mode
  media: microchip-isc: enable userspace histogram statistics export

Balamanikandan Gunasundar (7):
  media: platform: microchip: set maximum resolution for sam9x7
  media: platform: microchip: Include DPC modules flags in pipeline
  media: microchip-isc: expose hue and saturation as v4l2 controls
  media: microchip-isc: Rename CBC to CBHS
  media: microchip-isc: Store histogram data of all channels
  media: videodev2.h, v4l2-ioctl: Add microchip statistics format
  media: microchip-isc: expose color correction registers as v4l2
    controls

 drivers/media/platform/microchip/Kconfig      |   2 +
 drivers/media/platform/microchip/Makefile     |   2 +-
 .../platform/microchip/microchip-isc-base.c   | 373 ++++++++++--
 .../platform/microchip/microchip-isc-regs.h   |   3 +
 .../platform/microchip/microchip-isc-stats.c  | 549 ++++++++++++++++++
 .../media/platform/microchip/microchip-isc.h  |  44 +-
 .../microchip/microchip-sama5d2-isc.c         |   2 +-
 .../microchip/microchip-sama7g5-isc.c         |  73 ++-
 drivers/media/v4l2-core/v4l2-ioctl.c          |   1 +
 include/linux/atmel-isc-media.h               |  13 +
 include/uapi/linux/videodev2.h                |   3 +
 11 files changed, 1001 insertions(+), 64 deletions(-)
 create mode 100644 drivers/media/platform/microchip/microchip-isc-stats.c

-- 
2.34.1
Re: [PATCH 00/18] media: microchip-isc: Color correction and histogram stats
Posted by Hans Verkuil 3 months ago
Hi Balamanikandan,

On 09/10/2025 17:52, Balamanikandan Gunasundar wrote:
> Hi,
> 
> This patch series has a set of enhancements to the Microchip Image Sensor
> Controller driver. The objective is to expand its image processing
> capabilities and to improve the colors.
> 
> This series also introduces a new stats driver that exposes the histogram
> data to userspace via v4l2 controls. This allows applications such as
> libcamera to access real time image statistics for advanced image
> processing like automatic exposure, white balance adjustments etc.

Most of this series is fine, but the histogram part needs more work.

I would recommend splitting up this series in two parts: one for the
various fixes and improvements, and one for the histogram feature.

The first series with the fixes I can take easily. In fact, if you
post that this week (no later than Thursday), then I can pick it
up in time for v6.19.

As mentioned the histogram part needs more work. Mostly small stuff,
but the documentation is the major missing part.

I also want to see the output of 'v4l2-compliance -m0 -s' (i.e.
with streaming) in the cover letter of the histogram series to be
certain nothing was forgotten.

Make sure you compile v4l2-compliance straight from the git repo,
don't use a distro version since that's usually out of date.

Regards,

	Hans

> 
> Balakrishnan Sambath (11):
>   media: microchip-isc: Enable GDC and CBC module flags for RGB formats
>   media: microchip-isc: Improve histogram calculation with outlier
>     rejection
>   media: microchip-isc: Use channel averages for Grey World AWB
>   media: microchip-isc: Add range based black level correction
>   media: platform: microchip: Extend gamma table and control range
>   media: platform: microchip: Add new histogram submodule
>   media: microchip-isc: Register and unregister statistics device
>   media: microchip-isc: Always enable histogram for all RAW formats
>   media: microchip-isc: fix histogram state initialization order
>   media: microchip-isc: decouple histogram cycling from AWB mode
>   media: microchip-isc: enable userspace histogram statistics export
> 
> Balamanikandan Gunasundar (7):
>   media: platform: microchip: set maximum resolution for sam9x7
>   media: platform: microchip: Include DPC modules flags in pipeline
>   media: microchip-isc: expose hue and saturation as v4l2 controls
>   media: microchip-isc: Rename CBC to CBHS
>   media: microchip-isc: Store histogram data of all channels
>   media: videodev2.h, v4l2-ioctl: Add microchip statistics format
>   media: microchip-isc: expose color correction registers as v4l2
>     controls
> 
>  drivers/media/platform/microchip/Kconfig      |   2 +
>  drivers/media/platform/microchip/Makefile     |   2 +-
>  .../platform/microchip/microchip-isc-base.c   | 373 ++++++++++--
>  .../platform/microchip/microchip-isc-regs.h   |   3 +
>  .../platform/microchip/microchip-isc-stats.c  | 549 ++++++++++++++++++
>  .../media/platform/microchip/microchip-isc.h  |  44 +-
>  .../microchip/microchip-sama5d2-isc.c         |   2 +-
>  .../microchip/microchip-sama7g5-isc.c         |  73 ++-
>  drivers/media/v4l2-core/v4l2-ioctl.c          |   1 +
>  include/linux/atmel-isc-media.h               |  13 +
>  include/uapi/linux/videodev2.h                |   3 +
>  11 files changed, 1001 insertions(+), 64 deletions(-)
>  create mode 100644 drivers/media/platform/microchip/microchip-isc-stats.c
>
Re: [PATCH 00/18] media: microchip-isc: Color correction and histogram stats
Posted by Eugen Hristev 4 months ago
Hi Bala,

On 10/9/25 18:52, Balamanikandan Gunasundar wrote:
> Hi,
> 
> This patch series has a set of enhancements to the Microchip Image Sensor
> Controller driver. The objective is to expand its image processing
> capabilities and to improve the colors.
> 
> This series also introduces a new stats driver that exposes the histogram
> data to userspace via v4l2 controls. This allows applications such as
> libcamera to access real time image statistics for advanced image
> processing like automatic exposure, white balance adjustments etc.
> 
> Balakrishnan Sambath (11):
>   media: microchip-isc: Enable GDC and CBC module flags for RGB formats
>   media: microchip-isc: Improve histogram calculation with outlier
>     rejection
>   media: microchip-isc: Use channel averages for Grey World AWB
>   media: microchip-isc: Add range based black level correction
>   media: platform: microchip: Extend gamma table and control range
>   media: platform: microchip: Add new histogram submodule
>   media: microchip-isc: Register and unregister statistics device
>   media: microchip-isc: Always enable histogram for all RAW formats
>   media: microchip-isc: fix histogram state initialization order
>   media: microchip-isc: decouple histogram cycling from AWB mode
>   media: microchip-isc: enable userspace histogram statistics export
> 
> Balamanikandan Gunasundar (7):
>   media: platform: microchip: set maximum resolution for sam9x7
>   media: platform: microchip: Include DPC modules flags in pipeline
>   media: microchip-isc: expose hue and saturation as v4l2 controls
>   media: microchip-isc: Rename CBC to CBHS
>   media: microchip-isc: Store histogram data of all channels
>   media: videodev2.h, v4l2-ioctl: Add microchip statistics format
>   media: microchip-isc: expose color correction registers as v4l2
>     controls
> 
>  drivers/media/platform/microchip/Kconfig      |   2 +
>  drivers/media/platform/microchip/Makefile     |   2 +-
>  .../platform/microchip/microchip-isc-base.c   | 373 ++++++++++--
>  .../platform/microchip/microchip-isc-regs.h   |   3 +
>  .../platform/microchip/microchip-isc-stats.c  | 549 ++++++++++++++++++
>  .../media/platform/microchip/microchip-isc.h  |  44 +-
>  .../microchip/microchip-sama5d2-isc.c         |   2 +-
>  .../microchip/microchip-sama7g5-isc.c         |  73 ++-
>  drivers/media/v4l2-core/v4l2-ioctl.c          |   1 +
>  include/linux/atmel-isc-media.h               |  13 +
>  include/uapi/linux/videodev2.h                |   3 +
>  11 files changed, 1001 insertions(+), 64 deletions(-)
>  create mode 100644 drivers/media/platform/microchip/microchip-isc-stats.c
> 

This looks interesting.
I would like to see the compliance tool output for more platforms
(sama7g5, sama5d2, and the new sam9x7), also the media-ctl -p , to see
the topology with your new driver.

Thanks,
Eugen
Re: [PATCH 00/18] media: microchip-isc: Color correction and histogram stats
Posted by Kieran Bingham 4 months ago
Quoting Eugen Hristev (2025-10-09 21:11:17)
> Hi Bala,
> 
> On 10/9/25 18:52, Balamanikandan Gunasundar wrote:
> > Hi,
> > 
> > This patch series has a set of enhancements to the Microchip Image Sensor
> > Controller driver. The objective is to expand its image processing
> > capabilities and to improve the colors.
> > 
> > This series also introduces a new stats driver that exposes the histogram
> > data to userspace via v4l2 controls. This allows applications such as
> > libcamera to access real time image statistics for advanced image
> > processing like automatic exposure, white balance adjustments etc.

How much data do you anticipate to be passing through controls? (What
can the hardware provide in total if we look at the bigger picture to
support the full device?)

For all other ISPs we've been working towards using structured parameter
buffers to pass data - and we've been making that format extensible,
which I think could also be a design that can apply to statistics.

This would greatly reduce the overhead of managing 'one control per
value' ... or things like passing large tables (like a lens shading
table perhaps) through controls.

--
Kieran

> > 
> > Balakrishnan Sambath (11):
> >   media: microchip-isc: Enable GDC and CBC module flags for RGB formats
> >   media: microchip-isc: Improve histogram calculation with outlier
> >     rejection
> >   media: microchip-isc: Use channel averages for Grey World AWB
> >   media: microchip-isc: Add range based black level correction
> >   media: platform: microchip: Extend gamma table and control range
> >   media: platform: microchip: Add new histogram submodule
> >   media: microchip-isc: Register and unregister statistics device
> >   media: microchip-isc: Always enable histogram for all RAW formats
> >   media: microchip-isc: fix histogram state initialization order
> >   media: microchip-isc: decouple histogram cycling from AWB mode
> >   media: microchip-isc: enable userspace histogram statistics export
> > 
> > Balamanikandan Gunasundar (7):
> >   media: platform: microchip: set maximum resolution for sam9x7
> >   media: platform: microchip: Include DPC modules flags in pipeline
> >   media: microchip-isc: expose hue and saturation as v4l2 controls
> >   media: microchip-isc: Rename CBC to CBHS
> >   media: microchip-isc: Store histogram data of all channels
> >   media: videodev2.h, v4l2-ioctl: Add microchip statistics format
> >   media: microchip-isc: expose color correction registers as v4l2
> >     controls
> > 
> >  drivers/media/platform/microchip/Kconfig      |   2 +
> >  drivers/media/platform/microchip/Makefile     |   2 +-
> >  .../platform/microchip/microchip-isc-base.c   | 373 ++++++++++--
> >  .../platform/microchip/microchip-isc-regs.h   |   3 +
> >  .../platform/microchip/microchip-isc-stats.c  | 549 ++++++++++++++++++
> >  .../media/platform/microchip/microchip-isc.h  |  44 +-
> >  .../microchip/microchip-sama5d2-isc.c         |   2 +-
> >  .../microchip/microchip-sama7g5-isc.c         |  73 ++-
> >  drivers/media/v4l2-core/v4l2-ioctl.c          |   1 +
> >  include/linux/atmel-isc-media.h               |  13 +
> >  include/uapi/linux/videodev2.h                |   3 +
> >  11 files changed, 1001 insertions(+), 64 deletions(-)
> >  create mode 100644 drivers/media/platform/microchip/microchip-isc-stats.c
> > 
> 
> This looks interesting.
> I would like to see the compliance tool output for more platforms
> (sama7g5, sama5d2, and the new sam9x7), also the media-ctl -p , to see
> the topology with your new driver.
> 
> Thanks,
> Eugen
Re: [PATCH 00/18] media: microchip-isc: Color correction and histogram stats
Posted by Laurent Pinchart 4 months ago
On Fri, Oct 10, 2025 at 09:21:51AM +0100, Kieran Bingham wrote:
> Quoting Eugen Hristev (2025-10-09 21:11:17)
> > On 10/9/25 18:52, Balamanikandan Gunasundar wrote:
> > > Hi,
> > > 
> > > This patch series has a set of enhancements to the Microchip Image Sensor
> > > Controller driver. The objective is to expand its image processing
> > > capabilities and to improve the colors.
> > > 
> > > This series also introduces a new stats driver that exposes the histogram
> > > data to userspace via v4l2 controls. This allows applications such as
> > > libcamera to access real time image statistics for advanced image
> > > processing like automatic exposure, white balance adjustments etc.
> 
> How much data do you anticipate to be passing through controls? (What
> can the hardware provide in total if we look at the bigger picture to
> support the full device?)
> 
> For all other ISPs we've been working towards using structured parameter
> buffers to pass data - and we've been making that format extensible,
> which I think could also be a design that can apply to statistics.
> 
> This would greatly reduce the overhead of managing 'one control per
> value' ... or things like passing large tables (like a lens shading
> table perhaps) through controls.

V4L2 is standardizing on parameter buffers and statistics buffers for
ISPs. Using the same mechanism here will keep the driver in line with
other ISPs, which will help in userspace too.

> > > 
> > > Balakrishnan Sambath (11):
> > >   media: microchip-isc: Enable GDC and CBC module flags for RGB formats
> > >   media: microchip-isc: Improve histogram calculation with outlier
> > >     rejection
> > >   media: microchip-isc: Use channel averages for Grey World AWB
> > >   media: microchip-isc: Add range based black level correction
> > >   media: platform: microchip: Extend gamma table and control range
> > >   media: platform: microchip: Add new histogram submodule
> > >   media: microchip-isc: Register and unregister statistics device
> > >   media: microchip-isc: Always enable histogram for all RAW formats
> > >   media: microchip-isc: fix histogram state initialization order
> > >   media: microchip-isc: decouple histogram cycling from AWB mode
> > >   media: microchip-isc: enable userspace histogram statistics export
> > > 
> > > Balamanikandan Gunasundar (7):
> > >   media: platform: microchip: set maximum resolution for sam9x7
> > >   media: platform: microchip: Include DPC modules flags in pipeline
> > >   media: microchip-isc: expose hue and saturation as v4l2 controls
> > >   media: microchip-isc: Rename CBC to CBHS
> > >   media: microchip-isc: Store histogram data of all channels
> > >   media: videodev2.h, v4l2-ioctl: Add microchip statistics format
> > >   media: microchip-isc: expose color correction registers as v4l2
> > >     controls
> > > 
> > >  drivers/media/platform/microchip/Kconfig      |   2 +
> > >  drivers/media/platform/microchip/Makefile     |   2 +-
> > >  .../platform/microchip/microchip-isc-base.c   | 373 ++++++++++--
> > >  .../platform/microchip/microchip-isc-regs.h   |   3 +
> > >  .../platform/microchip/microchip-isc-stats.c  | 549 ++++++++++++++++++
> > >  .../media/platform/microchip/microchip-isc.h  |  44 +-
> > >  .../microchip/microchip-sama5d2-isc.c         |   2 +-
> > >  .../microchip/microchip-sama7g5-isc.c         |  73 ++-
> > >  drivers/media/v4l2-core/v4l2-ioctl.c          |   1 +
> > >  include/linux/atmel-isc-media.h               |  13 +
> > >  include/uapi/linux/videodev2.h                |   3 +
> > >  11 files changed, 1001 insertions(+), 64 deletions(-)
> > >  create mode 100644 drivers/media/platform/microchip/microchip-isc-stats.c
> > 
> > This looks interesting.
> > I would like to see the compliance tool output for more platforms
> > (sama7g5, sama5d2, and the new sam9x7), also the media-ctl -p , to see
> > the topology with your new driver.

-- 
Regards,

Laurent Pinchart
Re: [PATCH 00/18] media: microchip-isc: Color correction and histogram stats
Posted by Hans Verkuil 3 months ago
On 09/10/2025 17:52, Balamanikandan Gunasundar wrote:
> Hi,
> 
> This patch series has a set of enhancements to the Microchip Image Sensor
> Controller driver. The objective is to expand its image processing
> capabilities and to improve the colors.
> 
> This series also introduces a new stats driver that exposes the histogram
> data to userspace via v4l2 controls. This allows applications such as
> libcamera to access real time image statistics for advanced image
> processing like automatic exposure, white balance adjustments etc.

Note that bisect of this series failed: some patches seem to have dependencies
on later patches, which is obviously wrong. Make sure you double check that
for v2.

The documentation also fails to build since there is no documentation for the
new meta format, but I already commented on that.

Regards,

	Hans

> 
> Balakrishnan Sambath (11):
>   media: microchip-isc: Enable GDC and CBC module flags for RGB formats
>   media: microchip-isc: Improve histogram calculation with outlier
>     rejection
>   media: microchip-isc: Use channel averages for Grey World AWB
>   media: microchip-isc: Add range based black level correction
>   media: platform: microchip: Extend gamma table and control range
>   media: platform: microchip: Add new histogram submodule
>   media: microchip-isc: Register and unregister statistics device
>   media: microchip-isc: Always enable histogram for all RAW formats
>   media: microchip-isc: fix histogram state initialization order
>   media: microchip-isc: decouple histogram cycling from AWB mode
>   media: microchip-isc: enable userspace histogram statistics export
> 
> Balamanikandan Gunasundar (7):
>   media: platform: microchip: set maximum resolution for sam9x7
>   media: platform: microchip: Include DPC modules flags in pipeline
>   media: microchip-isc: expose hue and saturation as v4l2 controls
>   media: microchip-isc: Rename CBC to CBHS
>   media: microchip-isc: Store histogram data of all channels
>   media: videodev2.h, v4l2-ioctl: Add microchip statistics format
>   media: microchip-isc: expose color correction registers as v4l2
>     controls
> 
>  drivers/media/platform/microchip/Kconfig      |   2 +
>  drivers/media/platform/microchip/Makefile     |   2 +-
>  .../platform/microchip/microchip-isc-base.c   | 373 ++++++++++--
>  .../platform/microchip/microchip-isc-regs.h   |   3 +
>  .../platform/microchip/microchip-isc-stats.c  | 549 ++++++++++++++++++
>  .../media/platform/microchip/microchip-isc.h  |  44 +-
>  .../microchip/microchip-sama5d2-isc.c         |   2 +-
>  .../microchip/microchip-sama7g5-isc.c         |  73 ++-
>  drivers/media/v4l2-core/v4l2-ioctl.c          |   1 +
>  include/linux/atmel-isc-media.h               |  13 +
>  include/uapi/linux/videodev2.h                |   3 +
>  11 files changed, 1001 insertions(+), 64 deletions(-)
>  create mode 100644 drivers/media/platform/microchip/microchip-isc-stats.c
>