162306a36Sopenharmony_ci.. SPDX-License-Identifier: GPL-2.0
262306a36Sopenharmony_ci
362306a36Sopenharmony_ci.. include:: <isonum.txt>
462306a36Sopenharmony_ci
562306a36Sopenharmony_ciQualcomm Camera Subsystem driver
662306a36Sopenharmony_ci================================
762306a36Sopenharmony_ci
862306a36Sopenharmony_ciIntroduction
962306a36Sopenharmony_ci------------
1062306a36Sopenharmony_ci
1162306a36Sopenharmony_ciThis file documents the Qualcomm Camera Subsystem driver located under
1262306a36Sopenharmony_cidrivers/media/platform/qcom/camss.
1362306a36Sopenharmony_ci
1462306a36Sopenharmony_ciThe current version of the driver supports the Camera Subsystem found on
1562306a36Sopenharmony_ciQualcomm MSM8916/APQ8016 and MSM8996/APQ8096 processors.
1662306a36Sopenharmony_ci
1762306a36Sopenharmony_ciThe driver implements V4L2, Media controller and V4L2 subdev interfaces.
1862306a36Sopenharmony_ciCamera sensor using V4L2 subdev interface in the kernel is supported.
1962306a36Sopenharmony_ci
2062306a36Sopenharmony_ciThe driver is implemented using as a reference the Qualcomm Camera Subsystem
2162306a36Sopenharmony_cidriver for Android as found in Code Linaro [#f1]_ [#f2]_.
2262306a36Sopenharmony_ci
2362306a36Sopenharmony_ci
2462306a36Sopenharmony_ciQualcomm Camera Subsystem hardware
2562306a36Sopenharmony_ci----------------------------------
2662306a36Sopenharmony_ci
2762306a36Sopenharmony_ciThe Camera Subsystem hardware found on 8x16 / 8x96 processors and supported by
2862306a36Sopenharmony_cithe driver consists of:
2962306a36Sopenharmony_ci
3062306a36Sopenharmony_ci- 2 / 3 CSIPHY modules. They handle the Physical layer of the CSI2 receivers.
3162306a36Sopenharmony_ci  A separate camera sensor can be connected to each of the CSIPHY module;
3262306a36Sopenharmony_ci- 2 / 4 CSID (CSI Decoder) modules. They handle the Protocol and Application
3362306a36Sopenharmony_ci  layer of the CSI2 receivers. A CSID can decode data stream from any of the
3462306a36Sopenharmony_ci  CSIPHY. Each CSID also contains a TG (Test Generator) block which can generate
3562306a36Sopenharmony_ci  artificial input data for test purposes;
3662306a36Sopenharmony_ci- ISPIF (ISP Interface) module. Handles the routing of the data streams from
3762306a36Sopenharmony_ci  the CSIDs to the inputs of the VFE;
3862306a36Sopenharmony_ci- 1 / 2 VFE (Video Front End) module(s). Contain a pipeline of image processing
3962306a36Sopenharmony_ci  hardware blocks. The VFE has different input interfaces. The PIX (Pixel) input
4062306a36Sopenharmony_ci  interface feeds the input data to the image processing pipeline. The image
4162306a36Sopenharmony_ci  processing pipeline contains also a scale and crop module at the end. Three
4262306a36Sopenharmony_ci  RDI (Raw Dump Interface) input interfaces bypass the image processing
4362306a36Sopenharmony_ci  pipeline. The VFE also contains the AXI bus interface which writes the output
4462306a36Sopenharmony_ci  data to memory.
4562306a36Sopenharmony_ci
4662306a36Sopenharmony_ci
4762306a36Sopenharmony_ciSupported functionality
4862306a36Sopenharmony_ci-----------------------
4962306a36Sopenharmony_ci
5062306a36Sopenharmony_ciThe current version of the driver supports:
5162306a36Sopenharmony_ci
5262306a36Sopenharmony_ci- Input from camera sensor via CSIPHY;
5362306a36Sopenharmony_ci- Generation of test input data by the TG in CSID;
5462306a36Sopenharmony_ci- RDI interface of VFE
5562306a36Sopenharmony_ci
5662306a36Sopenharmony_ci  - Raw dump of the input data to memory.
5762306a36Sopenharmony_ci
5862306a36Sopenharmony_ci    Supported formats:
5962306a36Sopenharmony_ci
6062306a36Sopenharmony_ci    - YUYV/UYVY/YVYU/VYUY (packed YUV 4:2:2 - V4L2_PIX_FMT_YUYV /
6162306a36Sopenharmony_ci      V4L2_PIX_FMT_UYVY / V4L2_PIX_FMT_YVYU / V4L2_PIX_FMT_VYUY);
6262306a36Sopenharmony_ci    - MIPI RAW8 (8bit Bayer RAW - V4L2_PIX_FMT_SRGGB8 /
6362306a36Sopenharmony_ci      V4L2_PIX_FMT_SGRBG8 / V4L2_PIX_FMT_SGBRG8 / V4L2_PIX_FMT_SBGGR8);
6462306a36Sopenharmony_ci    - MIPI RAW10 (10bit packed Bayer RAW - V4L2_PIX_FMT_SBGGR10P /
6562306a36Sopenharmony_ci      V4L2_PIX_FMT_SGBRG10P / V4L2_PIX_FMT_SGRBG10P / V4L2_PIX_FMT_SRGGB10P /
6662306a36Sopenharmony_ci      V4L2_PIX_FMT_Y10P);
6762306a36Sopenharmony_ci    - MIPI RAW12 (12bit packed Bayer RAW - V4L2_PIX_FMT_SRGGB12P /
6862306a36Sopenharmony_ci      V4L2_PIX_FMT_SGBRG12P / V4L2_PIX_FMT_SGRBG12P / V4L2_PIX_FMT_SRGGB12P).
6962306a36Sopenharmony_ci    - (8x96 only) MIPI RAW14 (14bit packed Bayer RAW - V4L2_PIX_FMT_SRGGB14P /
7062306a36Sopenharmony_ci      V4L2_PIX_FMT_SGBRG14P / V4L2_PIX_FMT_SGRBG14P / V4L2_PIX_FMT_SRGGB14P).
7162306a36Sopenharmony_ci
7262306a36Sopenharmony_ci  - (8x96 only) Format conversion of the input data.
7362306a36Sopenharmony_ci
7462306a36Sopenharmony_ci    Supported input formats:
7562306a36Sopenharmony_ci
7662306a36Sopenharmony_ci    - MIPI RAW10 (10bit packed Bayer RAW - V4L2_PIX_FMT_SBGGR10P / V4L2_PIX_FMT_Y10P).
7762306a36Sopenharmony_ci
7862306a36Sopenharmony_ci    Supported output formats:
7962306a36Sopenharmony_ci
8062306a36Sopenharmony_ci    - Plain16 RAW10 (10bit unpacked Bayer RAW - V4L2_PIX_FMT_SBGGR10 / V4L2_PIX_FMT_Y10).
8162306a36Sopenharmony_ci
8262306a36Sopenharmony_ci- PIX interface of VFE
8362306a36Sopenharmony_ci
8462306a36Sopenharmony_ci  - Format conversion of the input data.
8562306a36Sopenharmony_ci
8662306a36Sopenharmony_ci    Supported input formats:
8762306a36Sopenharmony_ci
8862306a36Sopenharmony_ci    - YUYV/UYVY/YVYU/VYUY (packed YUV 4:2:2 - V4L2_PIX_FMT_YUYV /
8962306a36Sopenharmony_ci      V4L2_PIX_FMT_UYVY / V4L2_PIX_FMT_YVYU / V4L2_PIX_FMT_VYUY).
9062306a36Sopenharmony_ci
9162306a36Sopenharmony_ci    Supported output formats:
9262306a36Sopenharmony_ci
9362306a36Sopenharmony_ci    - NV12/NV21 (two plane YUV 4:2:0 - V4L2_PIX_FMT_NV12 / V4L2_PIX_FMT_NV21);
9462306a36Sopenharmony_ci    - NV16/NV61 (two plane YUV 4:2:2 - V4L2_PIX_FMT_NV16 / V4L2_PIX_FMT_NV61).
9562306a36Sopenharmony_ci    - (8x96 only) YUYV/UYVY/YVYU/VYUY (packed YUV 4:2:2 - V4L2_PIX_FMT_YUYV /
9662306a36Sopenharmony_ci      V4L2_PIX_FMT_UYVY / V4L2_PIX_FMT_YVYU / V4L2_PIX_FMT_VYUY).
9762306a36Sopenharmony_ci
9862306a36Sopenharmony_ci  - Scaling support. Configuration of the VFE Encoder Scale module
9962306a36Sopenharmony_ci    for downscalling with ratio up to 16x.
10062306a36Sopenharmony_ci
10162306a36Sopenharmony_ci  - Cropping support. Configuration of the VFE Encoder Crop module.
10262306a36Sopenharmony_ci
10362306a36Sopenharmony_ci- Concurrent and independent usage of two (8x96: three) data inputs -
10462306a36Sopenharmony_ci  could be camera sensors and/or TG.
10562306a36Sopenharmony_ci
10662306a36Sopenharmony_ci
10762306a36Sopenharmony_ciDriver Architecture and Design
10862306a36Sopenharmony_ci------------------------------
10962306a36Sopenharmony_ci
11062306a36Sopenharmony_ciThe driver implements the V4L2 subdev interface. With the goal to model the
11162306a36Sopenharmony_cihardware links between the modules and to expose a clean, logical and usable
11262306a36Sopenharmony_ciinterface, the driver is split into V4L2 sub-devices as follows (8x16 / 8x96):
11362306a36Sopenharmony_ci
11462306a36Sopenharmony_ci- 2 / 3 CSIPHY sub-devices - each CSIPHY is represented by a single sub-device;
11562306a36Sopenharmony_ci- 2 / 4 CSID sub-devices - each CSID is represented by a single sub-device;
11662306a36Sopenharmony_ci- 2 / 4 ISPIF sub-devices - ISPIF is represented by a number of sub-devices
11762306a36Sopenharmony_ci  equal to the number of CSID sub-devices;
11862306a36Sopenharmony_ci- 4 / 8 VFE sub-devices - VFE is represented by a number of sub-devices equal to
11962306a36Sopenharmony_ci  the number of the input interfaces (3 RDI and 1 PIX for each VFE).
12062306a36Sopenharmony_ci
12162306a36Sopenharmony_ciThe considerations to split the driver in this particular way are as follows:
12262306a36Sopenharmony_ci
12362306a36Sopenharmony_ci- representing CSIPHY and CSID modules by a separate sub-device for each module
12462306a36Sopenharmony_ci  allows to model the hardware links between these modules;
12562306a36Sopenharmony_ci- representing VFE by a separate sub-devices for each input interface allows
12662306a36Sopenharmony_ci  to use the input interfaces concurrently and independently as this is
12762306a36Sopenharmony_ci  supported by the hardware;
12862306a36Sopenharmony_ci- representing ISPIF by a number of sub-devices equal to the number of CSID
12962306a36Sopenharmony_ci  sub-devices allows to create linear media controller pipelines when using two
13062306a36Sopenharmony_ci  cameras simultaneously. This avoids branches in the pipelines which otherwise
13162306a36Sopenharmony_ci  will require a) userspace and b) media framework (e.g. power on/off
13262306a36Sopenharmony_ci  operations) to  make assumptions about the data flow from a sink pad to a
13362306a36Sopenharmony_ci  source pad on a single media entity.
13462306a36Sopenharmony_ci
13562306a36Sopenharmony_ciEach VFE sub-device is linked to a separate video device node.
13662306a36Sopenharmony_ci
13762306a36Sopenharmony_ciThe media controller pipeline graph is as follows (with connected two / three
13862306a36Sopenharmony_ciOV5645 camera sensors):
13962306a36Sopenharmony_ci
14062306a36Sopenharmony_ci.. _qcom_camss_graph:
14162306a36Sopenharmony_ci
14262306a36Sopenharmony_ci.. kernel-figure:: qcom_camss_graph.dot
14362306a36Sopenharmony_ci    :alt:   qcom_camss_graph.dot
14462306a36Sopenharmony_ci    :align: center
14562306a36Sopenharmony_ci
14662306a36Sopenharmony_ci    Media pipeline graph 8x16
14762306a36Sopenharmony_ci
14862306a36Sopenharmony_ci.. kernel-figure:: qcom_camss_8x96_graph.dot
14962306a36Sopenharmony_ci    :alt:   qcom_camss_8x96_graph.dot
15062306a36Sopenharmony_ci    :align: center
15162306a36Sopenharmony_ci
15262306a36Sopenharmony_ci    Media pipeline graph 8x96
15362306a36Sopenharmony_ci
15462306a36Sopenharmony_ci
15562306a36Sopenharmony_ciImplementation
15662306a36Sopenharmony_ci--------------
15762306a36Sopenharmony_ci
15862306a36Sopenharmony_ciRuntime configuration of the hardware (updating settings while streaming) is
15962306a36Sopenharmony_cinot required to implement the currently supported functionality. The complete
16062306a36Sopenharmony_ciconfiguration on each hardware module is applied on STREAMON ioctl based on
16162306a36Sopenharmony_cithe current active media links, formats and controls set.
16262306a36Sopenharmony_ci
16362306a36Sopenharmony_ciThe output size of the scaler module in the VFE is configured with the actual
16462306a36Sopenharmony_cicompose selection rectangle on the sink pad of the 'msm_vfe0_pix' entity.
16562306a36Sopenharmony_ci
16662306a36Sopenharmony_ciThe crop output area of the crop module in the VFE is configured with the actual
16762306a36Sopenharmony_cicrop selection rectangle on the source pad of the 'msm_vfe0_pix' entity.
16862306a36Sopenharmony_ci
16962306a36Sopenharmony_ci
17062306a36Sopenharmony_ciDocumentation
17162306a36Sopenharmony_ci-------------
17262306a36Sopenharmony_ci
17362306a36Sopenharmony_ciAPQ8016 Specification:
17462306a36Sopenharmony_cihttps://developer.qualcomm.com/download/sd410/snapdragon-410-processor-device-specification.pdf
17562306a36Sopenharmony_ciReferenced 2016-11-24.
17662306a36Sopenharmony_ci
17762306a36Sopenharmony_ciAPQ8096 Specification:
17862306a36Sopenharmony_cihttps://developer.qualcomm.com/download/sd820e/qualcomm-snapdragon-820e-processor-apq8096sge-device-specification.pdf
17962306a36Sopenharmony_ciReferenced 2018-06-22.
18062306a36Sopenharmony_ci
18162306a36Sopenharmony_ciReferences
18262306a36Sopenharmony_ci----------
18362306a36Sopenharmony_ci
18462306a36Sopenharmony_ci.. [#f1] https://git.codelinaro.org/clo/la/kernel/msm-3.10/
18562306a36Sopenharmony_ci.. [#f2] https://git.codelinaro.org/clo/la/kernel/msm-3.18/
186