How to use the DCMIPP ISP

Revision as of 16:34, 19 October 2023 by Registered User (→‎The available controls)
Applicable for STM32MP25x lines

1. Article purpose[edit source]

This article explains how to control the ISP block available within the DCMIPP via the kernel Video4Linux2 (V4L2) framework in Linux® OS context.

Warning white.png Warning
The software topology and controls related to the ISP are subject to modifications between the BETA and MM

2. Short description of DCMIPP ISP[edit source]

2.1. Block diagram[edit source]

Block diagram of DCMIPP ISP Block

The DCMIPP ISP capabilities, instantiated once but common to pipe1 and 2, are the following:

  • Statistic removal: to remove unused metadata (like statistics) from received pictures.
  • Bad-pixel removal: automatic detection and correction of bad pixels from sensor Array.
  • Decimation: one pixel every 1/2/4/8, allows to fit the max 2688 pixels.
  • Black level correction: correct black level on each pixels on R/G/B
  • Exposure control: amplifies the exposure from 0.0 to 255.99x
  • Demosaicing: converts RawBayer to RGB, supports NIR patterns (2x2, 4x4).
  • Statistics extract: average R,G,B,L values, dynamic bins.
  • Color conversion: color conversion with flexible (fully programmable coefficients)
  • Contrast:to enhance the contrast, via luminance.

2.2. The software topology[edit source]

The graph above shows the full media-controller topology of the DCMIPP, including the ISP sub-device dcmipp_main_isp.

In order to match with expected V4L2 mbus format handling, some of the features are controlled via relying on subdev pads formats while some others are implemented via V4L2 subdev controls done directly the dcmipp_main_isp subdev.

Feature / Block Mapping into dcmipp_main_isp
Statistic removal crop selection (only top,height fields valids) on the pad[0] (SINK)
Decimation compose selection on the pad[0] (SINK)
Demosaicing Demosaicing is automatically enabled if the ISP block input format (mbus format on pad[0] (SINK) is a RAW format
Color Conversion Depending on the pad[1] (SOURCE) format, color conversion is used to convert from RGB to YUV color format

2.3. The available controls[edit source]

Further controls are available and applicable on the dcmipp_main_isp subdev:

  • demosaicing_peak / demosaicing_horizontal_line / demosaicing_vertical_line / demosaicing_edge: control of the strength of the demosaicing algorithms. Please refer to the refman in order to get more detail about the implemented demosaicing algorithms.
  • blacklevel_rgb: unique value to be applied for all R/G/B components for blacklevel compensation
  • bad_pixel_control: control of the strength of the bad pixels detection algorithm
  • bad_pixel_count: returns the amount of bad pixels detected within the last frame handled by the ISP block

Exposure / contrast and color conversion blocks requires more informations so controls below must provided using specific structures

  • isp_exposure_block_control: this control is used to apply settings into the exposure block via the struct v4l2_ctrl_isp_exposure below matching the parameters required by the HW block and described within the RefMan.
/**
 * struct v4l2_ctrl_isp_exposure - Exposure Block control within an ISP
 *
 * @enable: boolean indicating if the exposure compensation should be enabled or not
 * @shift_R: shift for RED component
 * @mult_R: multiply for RED component
 * @shift_G: shift for GREEN component
 * @mult_G: multiply for GREEN component
 * @shift_B: shift for BLUE component
 * @mult_B: multiply for BLUE component
 */
struct v4l2_ctrl_isp_exposure {
        bool enable;
        __u8 shift_R;
        __u8 mult_R;
        __u8 shift_G;
        __u8 mult_G;
        __u8 shift_B;
        __u8 mult_B;
};
  • isp_contrast_block_control: this control is used to apply settings into the contrast block via the struct v4l2_ctrl_isp_contrast below matching the parameters required by the HW block and described within the RefMan.
/**
 * struct v4l2_ctrl_isp_contrast - Contrast Block control within an ISP
 *
 * @enable: boolean indicating if the contrast compensation should be enabled or not
 * @lum: luminance increase value table (9 * 8 bits)
 */
struct v4l2_ctrl_isp_contrast {
        bool enable;
        __u8 lum[9];
};
  • isp_color_conversion_block_cont: this control is used to apply settings into the color conversion block via the struct v4l2_ctrl_isp_color_conv below matching the parameters required by the HW block and described within the RefMan. If used, it will override the color conversion settings done automatically by the subdev based on sink & source formats.
/**
 * struct v4l2_ctrl_isp_color_conv - Color Conversion parameters within an ISP
 *
 * @enable: boolean indicating if the color conversion should be enabled or not
 * @clamping: boolean indicating if the converted color shall be clamped or not
 * @clamping_as_rgb: boolean indicating if the clamping applies to RGB color space (YUV otherwise)
 * @coeff: color conversion coefficients of the matrix (RGB 3x3 + 1 offset column)
 */
struct v4l2_ctrl_isp_color_conv {
        bool enable;
        bool clamping;
        bool clamping_as_rgb;
        __u16 coeff[3][4];
};

2.4. The statistic extraction[edit source]

3. Use case examples[edit source]

3.1. Adusting a control[edit source]

4. Debug[edit source]