3. MIPI CCS camera sensor driver

The MIPI CCS camera sensor driver is a generic driver for MIPI CCS compliant camera sensors. It exposes three sub-devices representing the pixel array, the binner and the scaler.

As the capabilities of individual devices vary, the driver exposes interfaces based on the capabilities that exist in hardware.

Also see the CCS driver kernel documentation.

3.1. Pixel Array sub-device

The pixel array sub-device represents the camera sensor’s pixel matrix, as well as analogue crop functionality present in many compliant devices. The analogue crop is configured using the V4L2_SEL_TGT_CROP on the source pad (0) of the entity. The size of the pixel matrix can be obtained by getting the V4L2_SEL_TGT_NATIVE_SIZE target.

3.2. Binner

The binner sub-device represents the binning functionality on the sensor. For that purpose, selection target V4L2_SEL_TGT_COMPOSE is supported on the sink pad (0).

Additionally, if a device has no scaler or digital crop functionality, the source pad (1) exposes another digital crop selection rectangle that can only crop at the end of the lines and frames.

3.3. Scaler

The scaler sub-device represents the digital crop and scaling functionality of the sensor. The V4L2 selection target V4L2_SEL_TGT_CROP is used to configure the digital crop on the sink pad (0) when digital crop is supported. Scaling is configured using selection target V4L2_SEL_TGT_COMPOSE on the sink pad (0) as well.

Additionally, if the scaler sub-device exists, its source pad (1) exposes another digital crop selection rectangle that can only crop at the end of the lines and frames.

3.4. Digital and analogue crop

Digital crop functionality is referred to as cropping that effectively works by dropping some data on the floor. Analogue crop, on the other hand, means that the cropped information is never retrieved. In case of camera sensors, the analogue data is never read from the pixel matrix that are outside the configured selection rectangle that designates crop. The difference has an effect in device timing and likely also in power consumption.

3.5. Private controls

The MIPI CCS driver implements a number of private controls under V4L2_CID_USER_BASE_CCS to control the MIPI CCS compliant camera sensors.

3.5.1. Analogue gain model

The CCS defines an analogue gain model where the gain can be calculated using the following formula:

gain = m0 * x + c0 / (m1 * x + c1)

Either m0 or c0 will be zero. The constants that are device specific, can be obtained from the following controls:

V4L2_CID_CCS_ANALOGUE_GAIN_M0 V4L2_CID_CCS_ANALOGUE_GAIN_M1 V4L2_CID_CCS_ANALOGUE_GAIN_C0 V4L2_CID_CCS_ANALOGUE_GAIN_C1

The analogue gain (x in the formula) is controlled through V4L2_CID_ANALOGUE_GAIN in this case.

3.5.2. Alternate analogue gain model

The CCS defines another analogue gain model called alternate analogue gain. In this case, the formula to calculate actual gain consists of linear and exponential parts:

gain = linear * 2 ^ exponent

The linear and exponent factors can be set using the V4L2_CID_CCS_ANALOGUE_LINEAR_GAIN and V4L2_CID_CCS_ANALOGUE_EXPONENTIAL_GAIN controls, respectively

3.5.3. Shading correction

The CCS standard supports lens shading correction. The feature can be controlled using V4L2_CID_CCS_SHADING_CORRECTION. Additionally, the luminance correction level may be changed using V4L2_CID_CCS_LUMINANCE_CORRECTION_LEVEL, where value 0 indicates no correction and 128 indicates correcting the luminance in corners to 10 % less than in the centre.

Shading correction needs to be enabled for luminance correction level to have an effect.

3.6. Routes

The CCS driver implements one or two routes in its source sub-device (scaler sub-device if it exists for the device, otherwise binner) depending on whether the sensor supports embedded data. (All CCS compliant sensors do but the CCS driver supports preceding standards that did not require embedded data support, too.)

The first route of the CCS source sub-device is for pixel data (sink pad 0/stream 0 -> source pad 1/stream 0) and the second one is for embedded data (internal sink pad 2/stream 0 -> source pad 1/stream 1).

3.6.1. Embedded data

MIPI CCS supports generation of camera sensor embedded data. The media bus code used for this format on the internal sink pad is MEDIA_BUS_FMT_CCS_EMBEDDDED.

The bit depth of the CCS pixel data affects how the sensor will output the embedded data, adding padding to align with CSI-2 bus Data Unit for that particular bit depth. This is indicated by the generic metadata format on the source pad of the sensor’s source sub-device.

Devices supporting embedded data for bit depths greater than or equal to 16 may support more dense packing or legacy single metadata byte per data unit, or both of these. The supported embedded data formats can be enumerated and configured on stream 1 of the source pad (1) of the CCS source sub-device.

The use of the denser packing results in embedded data lines being longer than the pixel data in data units since the data units are smaller. In bytes the embedded data lines are still not longer than the image data lines.

The embedded data format is determined by the sub-device image data format configured on the source sub-device. The embedded data mbus code is only changed when the bit depth of the image data changes in the source pad of the source sub-device.

Copyright © 2020, 2024 Intel Corporation