Last edited one day ago

How to integrate a new sensor driver for IQ Tuning Tool

Applicable for STM32MP21x lines, STM32MP23x lines, STM32MP25x lines


1. Overview[edit | edit source]

This article explains how to integrate a new image sensor for use with STM32 ISP IQTune[1] on STM32 MPU devices.

STM32 ISP IQTune is based on libcamera®[2]. Therefore, the sensor driver must work with the Linux media stack and expose the controls and capabilities that libcamera and its STM32 MPU ISP pipeline expect.

2. Pixel format selection by libcamera[edit | edit source]

The libcamera DCMIPP pipeline handler selects a pixel format that both the sensor and the DCMIPP can use. The pipeline tries to ensure that all output format requests are possible.

When a format is requested as part of a dump profile, the sensor must also be able to output the corresponding MBUS format. libcamera then uses this format as the input for all other pipelines in use.

If the dump profile is not used, the DCMIPP pipeline handler selects a sensor-supported format based on the DCMIPP input capabilities, in the following order of preference:

  • Any of the four variants of RAW Bayer format, from 14 bits to 8 bits
  • RGB565 or RGB888
  • Any of the four variants of 16-bit YUV
  • Monochrome format, from 8 bits to 12 bits

3. Mandatory libcamera sensor controls[edit | edit source]

For RAW Bayer sensors, libcamera requires the sensor V4L2 subdevice driver to support the following five V4L2 controls:

  • V4L2_CID_EXPOSURE
  • V4L2_CID_VBLANK
  • V4L2_CID_HBLANK
  • V4L2_CID_ANALOGUE_GAIN
  • V4L2_CID_PIXEL_RATE

Refer to the Linux kernel documentation for details about how to implement these controls and what they represent.

4. Sensor controls used by libcamera DCMIPP IPA[edit | edit source]

As part of the actions that the algorithms in libcamera perform for the DCMIPP, the image processing algorithms (IPA) also control sensor exposure and analogue gain. For this purpose, and only if the control exists, the IPA first ensures that automatic exposure is disabled by using the optional V4L2_CID_EXPOSURE_AUTO control. The IPA then applies settings through the V4L2_CID_EXPOSURE and V4L2_CID_ANALOGUE_GAIN controls of the sensor.

5. References[edit | edit source]