[v8,0/6] libcamera: software_isp: Add support for raw monochrome formats
mbox series

Message ID 20261129152416.174279-1-alain.cousinie@laposte.net
Headers show
Series
  • libcamera: software_isp: Add support for raw monochrome formats
Related show

Message

Alain CousiniƩ Nov. 29, 2026, 3:24 p.m. UTC
This series adds support for raw monochrome formats to the software
ISP, in both the CPU debayer and the GPU (EGL) debayer. A monochrome
sensor has no colour channels: debayering becomes a grey-level
conversion, the colour correction matrix (CCM) is skipped and the
statistics are computed directly on the pixel values.

Supported formats: R8, R10, R12, R16 (unpacked), R10 and R12 (CSI-2
packed).

Changes from v7 to v8 (following Milan's review):
- A single mono.frag, reusing identity.vert, replaces mono.vert and the
  two monochrome fragment shaders, as discussed in v6. The LSB_SIZE and
  LSB_MASK_VAL defines are gone.
- GPU: width_ is used as the shader stride for packed formats, as for
  the Bayer shaders, and the CCM uniform is set whenever the shader
  declares it.
- SoftwareIsp no longer forces ccmEnabled_ and lscEnabled_: only the CCM
  is skipped for monochrome, Bayer is untouched.
- R14 support is dropped, as DRM_FORMAT_R14 does not exist in the Linux
  kernel headers. It can be added if the kernel evolves.
- The commit messages explain each change.

Test status:
- Real hardware: OmniVision OG0VA1B sensor (monochrome, 640x480, Y10
  only, supported by the og0ve1b driver in Linux 7.4) on Intel IPU6.
- Other formats (R8, R10P, R12, R12P, R16): patch 6 converts the real
  R10 stream on the fly to the format selected by
  LIBCAMERA_SOFTISP_SIM_MONO, so the whole chain (capture, stats,
  debayer) runs on each layout. I checked with qcam that each format
  works, with both the CPU and the GPU debayers.
- Not tested on real hardware: packed formats, R8, R12 and R16. Tests on
  other monochrome sensors would be very welcome.

Patch 6 is a test patch, not meant to be merged.

Known difference between CPU and GPU when the output is smaller than
the input.
The CPU debayer crops a centred area of the image, at the native
resolution (window_). The GPU debayer sets the projection with a scale
factor equal to the ratio between the output size and the native size
from sizes(): it resizes the whole image. With the same configuration,
the visible field therefore differs: on a 640x480 monochrome sensor
with a 320x240 output (qcam -s width=320,height=240), the GPU shows the
whole scene reduced by half, while the CPU shows the central half at the
native size.
This projection code is not modified by the series. I am leaving this
behaviour as it is.

---

Alain CousiniƩ (6):
  libcamera: software_isp: Add support for monochrome formats - Shader
  libcamera: software_isp: Add support for monochrome formats - Stats
  libcamera: software_isp: Add support for monochrome formats - CPU
  libcamera: software_isp: Add support for monochrome formats - GPU
  libcamera: software_isp: Add support for monochrome formats - SOFT
  libcamera: software_isp: Add support for monochrome formats - TEST NO PROD

 .../internal/software_isp/swstats_cpu.h       |  13 ++
 src/libcamera/pipeline/simple/simple.cpp      |   6 +-
 src/libcamera/shaders/meson.build             |   1 +
 src/libcamera/shaders/mono.frag               | 168 ++++++++++++++
 src/libcamera/software_isp/debayer.cpp        | 205 +++++++++++++++++-
 src/libcamera/software_isp/debayer.h          |  18 ++
 src/libcamera/software_isp/debayer_cpu.cpp    | 178 ++++++++++++++-
 src/libcamera/software_isp/debayer_cpu.h      |  19 ++
 src/libcamera/software_isp/debayer_egl.cpp    |  88 +++++++-
 src/libcamera/software_isp/software_isp.cpp   |  13 +-
 src/libcamera/software_isp/swstats_cpu.cpp    | 184 ++++++++++++++++
 11 files changed, 875 insertions(+), 18 deletions(-)
 create mode 100644 src/libcamera/shaders/mono.frag