162306a36Sopenharmony_ci.. SPDX-License-Identifier: GPL-2.0-only OR BSD-3-Clause
262306a36Sopenharmony_ci
362306a36Sopenharmony_ci.. include:: <isonum.txt>
462306a36Sopenharmony_ci
562306a36Sopenharmony_ciMIPI CCS camera sensor driver
662306a36Sopenharmony_ci=============================
762306a36Sopenharmony_ci
862306a36Sopenharmony_ciThe MIPI CCS camera sensor driver is a generic driver for `MIPI CCS
962306a36Sopenharmony_ci<https://www.mipi.org/specifications/camera-command-set>`_ compliant
1062306a36Sopenharmony_cicamera sensors. It exposes three sub-devices representing the pixel array,
1162306a36Sopenharmony_cithe binner and the scaler.
1262306a36Sopenharmony_ci
1362306a36Sopenharmony_ciAs the capabilities of individual devices vary, the driver exposes
1462306a36Sopenharmony_ciinterfaces based on the capabilities that exist in hardware.
1562306a36Sopenharmony_ci
1662306a36Sopenharmony_ciPixel Array sub-device
1762306a36Sopenharmony_ci----------------------
1862306a36Sopenharmony_ci
1962306a36Sopenharmony_ciThe pixel array sub-device represents the camera sensor's pixel matrix, as well
2062306a36Sopenharmony_cias analogue crop functionality present in many compliant devices. The analogue
2162306a36Sopenharmony_cicrop is configured using the ``V4L2_SEL_TGT_CROP`` on the source pad (0) of the
2262306a36Sopenharmony_cientity. The size of the pixel matrix can be obtained by getting the
2362306a36Sopenharmony_ci``V4L2_SEL_TGT_NATIVE_SIZE`` target.
2462306a36Sopenharmony_ci
2562306a36Sopenharmony_ciBinner
2662306a36Sopenharmony_ci------
2762306a36Sopenharmony_ci
2862306a36Sopenharmony_ciThe binner sub-device represents the binning functionality on the sensor. For
2962306a36Sopenharmony_cithat purpose, selection target ``V4L2_SEL_TGT_COMPOSE`` is supported on the
3062306a36Sopenharmony_cisink pad (0).
3162306a36Sopenharmony_ci
3262306a36Sopenharmony_ciAdditionally, if a device has no scaler or digital crop functionality, the
3362306a36Sopenharmony_cisource pad (1) expses another digital crop selection rectangle that can only
3462306a36Sopenharmony_cicrop at the end of the lines and frames.
3562306a36Sopenharmony_ci
3662306a36Sopenharmony_ciScaler
3762306a36Sopenharmony_ci------
3862306a36Sopenharmony_ci
3962306a36Sopenharmony_ciThe scaler sub-device represents the digital crop and scaling functionality of
4062306a36Sopenharmony_cithe sensor. The V4L2 selection target ``V4L2_SEL_TGT_CROP`` is used to
4162306a36Sopenharmony_ciconfigure the digital crop on the sink pad (0) when digital crop is supported.
4262306a36Sopenharmony_ciScaling is configured using selection target ``V4L2_SEL_TGT_COMPOSE`` on the
4362306a36Sopenharmony_cisink pad (0) as well.
4462306a36Sopenharmony_ci
4562306a36Sopenharmony_ciAdditionally, if the scaler sub-device exists, its source pad (1) exposes
4662306a36Sopenharmony_cianother digital crop selection rectangle that can only crop at the end of the
4762306a36Sopenharmony_cilines and frames.
4862306a36Sopenharmony_ci
4962306a36Sopenharmony_ciDigital and analogue crop
5062306a36Sopenharmony_ci-------------------------
5162306a36Sopenharmony_ci
5262306a36Sopenharmony_ciDigital crop functionality is referred to as cropping that effectively works by
5362306a36Sopenharmony_cidropping some data on the floor. Analogue crop, on the other hand, means that
5462306a36Sopenharmony_cithe cropped information is never retrieved. In case of camera sensors, the
5562306a36Sopenharmony_cianalogue data is never read from the pixel matrix that are outside the
5662306a36Sopenharmony_ciconfigured selection rectangle that designates crop. The difference has an
5762306a36Sopenharmony_cieffect in device timing and likely also in power consumption.
5862306a36Sopenharmony_ci
5962306a36Sopenharmony_ciCCS static data
6062306a36Sopenharmony_ci---------------
6162306a36Sopenharmony_ci
6262306a36Sopenharmony_ciThe MIPI CCS driver supports CCS static data for all compliant devices,
6362306a36Sopenharmony_ciincluding not just those compliant with CCS 1.1 but also CCS 1.0 and SMIA(++).
6462306a36Sopenharmony_ciFor CCS the file names are formed as
6562306a36Sopenharmony_ci
6662306a36Sopenharmony_ci	ccs/ccs-sensor-vvvv-mmmm-rrrr.fw (sensor) and
6762306a36Sopenharmony_ci	ccs/ccs-module-vvvv-mmmm-rrrr.fw (module).
6862306a36Sopenharmony_ci
6962306a36Sopenharmony_ciFor SMIA++ compliant devices the corresponding file names are
7062306a36Sopenharmony_ci
7162306a36Sopenharmony_ci	ccs/smiapp-sensor-vv-mmmm-rr.fw (sensor) and
7262306a36Sopenharmony_ci	ccs/smiapp-module-vv-mmmm-rrrr.fw (module).
7362306a36Sopenharmony_ci
7462306a36Sopenharmony_ciFor SMIA (non-++) compliant devices the static data file name is
7562306a36Sopenharmony_ci
7662306a36Sopenharmony_ci	ccs/smia-sensor-vv-mmmm-rr.fw (sensor).
7762306a36Sopenharmony_ci
7862306a36Sopenharmony_civvvv or vv denotes MIPI and SMIA manufacturer IDs respectively, mmmm model ID
7962306a36Sopenharmony_ciand rrrr or rr revision number.
8062306a36Sopenharmony_ci
8162306a36Sopenharmony_ciRegister definition generator
8262306a36Sopenharmony_ci-----------------------------
8362306a36Sopenharmony_ci
8462306a36Sopenharmony_ciThe ccs-regs.asc file contains MIPI CCS register definitions that are used
8562306a36Sopenharmony_cito produce C source code files for definitions that can be better used by
8662306a36Sopenharmony_ciprograms written in C language. As there are many dependencies between the
8762306a36Sopenharmony_ciproduced files, please do not modify them manually as it's error-prone and
8862306a36Sopenharmony_ciin vain, but instead change the script producing them.
8962306a36Sopenharmony_ci
9062306a36Sopenharmony_ciUsage
9162306a36Sopenharmony_ci~~~~~
9262306a36Sopenharmony_ci
9362306a36Sopenharmony_ciConventionally the script is called this way to update the CCS driver
9462306a36Sopenharmony_cidefinitions:
9562306a36Sopenharmony_ci
9662306a36Sopenharmony_ci.. code-block:: none
9762306a36Sopenharmony_ci
9862306a36Sopenharmony_ci	$ Documentation/driver-api/media/drivers/ccs/mk-ccs-regs -k \
9962306a36Sopenharmony_ci		-e drivers/media/i2c/ccs/ccs-regs.h \
10062306a36Sopenharmony_ci		-L drivers/media/i2c/ccs/ccs-limits.h \
10162306a36Sopenharmony_ci		-l drivers/media/i2c/ccs/ccs-limits.c \
10262306a36Sopenharmony_ci		-c Documentation/driver-api/media/drivers/ccs/ccs-regs.asc
10362306a36Sopenharmony_ci
10462306a36Sopenharmony_ciCCS PLL calculator
10562306a36Sopenharmony_ci==================
10662306a36Sopenharmony_ci
10762306a36Sopenharmony_ciThe CCS PLL calculator is used to compute the PLL configuration, given sensor's
10862306a36Sopenharmony_cicapabilities as well as board configuration and user specified configuration. As
10962306a36Sopenharmony_cithe configuration space that encompasses all these configurations is vast, the
11062306a36Sopenharmony_ciPLL calculator isn't entirely trivial. Yet it is relatively simple to use for a
11162306a36Sopenharmony_cidriver.
11262306a36Sopenharmony_ci
11362306a36Sopenharmony_ciThe PLL model implemented by the PLL calculator corresponds to MIPI CCS 1.1.
11462306a36Sopenharmony_ci
11562306a36Sopenharmony_ci.. kernel-doc:: drivers/media/i2c/ccs-pll.h
11662306a36Sopenharmony_ci
11762306a36Sopenharmony_ci**Copyright** |copy| 2020 Intel Corporation
118