요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.
1. 요약·해설
원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.
2. 영어 원문 전체
번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.
원문 전체 펼치기
.. SPDX-License-Identifier: GPL-2.0
.. include:: <isonum.txt>
Qualcomm Camera Subsystem driver
================================
Introduction
------------
This file documents the Qualcomm Camera Subsystem driver located under
drivers/media/platform/qcom/camss.
The current version of the driver supports the Camera Subsystem found on
Qualcomm MSM8916/APQ8016 and MSM8996/APQ8096 processors.
The driver implements V4L2, Media controller and V4L2 subdev interfaces.
Camera sensor using V4L2 subdev interface in the kernel is supported.
The driver is implemented using as a reference the Qualcomm Camera Subsystem
driver for Android as found in Code Linaro [#f1]_ [#f2]_.
Qualcomm Camera Subsystem hardware
----------------------------------
The Camera Subsystem hardware found on 8x16 / 8x96 processors and supported by
the driver consists of:
- 2 / 3 CSIPHY modules. They handle the Physical layer of the CSI2 receivers.
A separate camera sensor can be connected to each of the CSIPHY module;
- 2 / 4 CSID (CSI Decoder) modules. They handle the Protocol and Application
layer of the CSI2 receivers. A CSID can decode data stream from any of the
CSIPHY. Each CSID also contains a TG (Test Generator) block which can generate
artificial input data for test purposes;
- ISPIF (ISP Interface) module. Handles the routing of the data streams from
the CSIDs to the inputs of the VFE;
- 1 / 2 VFE (Video Front End) module(s). Contain a pipeline of image processing
hardware blocks. The VFE has different input interfaces. The PIX (Pixel) input
interface feeds the input data to the image processing pipeline. The image
processing pipeline contains also a scale and crop module at the end. Three
RDI (Raw Dump Interface) input interfaces bypass the image processing
pipeline. The VFE also contains the AXI bus interface which writes the output
data to memory.
Supported functionality
-----------------------
The current version of the driver supports:
- Input from camera sensor via CSIPHY;
- Generation of test input data by the TG in CSID;
- RDI interface of VFE
- Raw dump of the input data to memory.
Supported formats:
- YUYV/UYVY/YVYU/VYUY (packed YUV 4:2:2 - V4L2_PIX_FMT_YUYV /
V4L2_PIX_FMT_UYVY / V4L2_PIX_FMT_YVYU / V4L2_PIX_FMT_VYUY);
- MIPI RAW8 (8bit Bayer RAW - V4L2_PIX_FMT_SRGGB8 /
V4L2_PIX_FMT_SGRBG8 / V4L2_PIX_FMT_SGBRG8 / V4L2_PIX_FMT_SBGGR8);
- MIPI RAW10 (10bit packed Bayer RAW - V4L2_PIX_FMT_SBGGR10P /
V4L2_PIX_FMT_SGBRG10P / V4L2_PIX_FMT_SGRBG10P / V4L2_PIX_FMT_SRGGB10P /
V4L2_PIX_FMT_Y10P);
- MIPI RAW12 (12bit packed Bayer RAW - V4L2_PIX_FMT_SRGGB12P /
V4L2_PIX_FMT_SGBRG12P / V4L2_PIX_FMT_SGRBG12P / V4L2_PIX_FMT_SRGGB12P).
- (8x96 only) MIPI RAW14 (14bit packed Bayer RAW - V4L2_PIX_FMT_SRGGB14P /
V4L2_PIX_FMT_SGBRG14P / V4L2_PIX_FMT_SGRBG14P / V4L2_PIX_FMT_SRGGB14P).
- (8x96 only) Format conversion of the input data.
Supported input formats:
- MIPI RAW10 (10bit packed Bayer RAW - V4L2_PIX_FMT_SBGGR10P / V4L2_PIX_FMT_Y10P).
Supported output formats:
- Plain16 RAW10 (10bit unpacked Bayer RAW - V4L2_PIX_FMT_SBGGR10 / V4L2_PIX_FMT_Y10).
- PIX interface of VFE
- Format conversion of the input data.
Supported input formats:
- YUYV/UYVY/YVYU/VYUY (packed YUV 4:2:2 - V4L2_PIX_FMT_YUYV /
V4L2_PIX_FMT_UYVY / V4L2_PIX_FMT_YVYU / V4L2_PIX_FMT_VYUY).
Supported output formats:
- NV12/NV21 (two plane YUV 4:2:0 - V4L2_PIX_FMT_NV12 / V4L2_PIX_FMT_NV21);
- NV16/NV61 (two plane YUV 4:2:2 - V4L2_PIX_FMT_NV16 / V4L2_PIX_FMT_NV61).
- (8x96 only) YUYV/UYVY/YVYU/VYUY (packed YUV 4:2:2 - V4L2_PIX_FMT_YUYV /
V4L2_PIX_FMT_UYVY / V4L2_PIX_FMT_YVYU / V4L2_PIX_FMT_VYUY).
- Scaling support. Configuration of the VFE Encoder Scale module
for downscalling with ratio up to 16x.
- Cropping support. Configuration of the VFE Encoder Crop module.
- Concurrent and independent usage of two (8x96: three) data inputs -
could be camera sensors and/or TG.
Driver Architecture and Design
------------------------------
The driver implements the V4L2 subdev interface. With the goal to model the
hardware links between the modules and to expose a clean, logical and usable
interface, the driver is split into V4L2 sub-devices as follows (8x16 / 8x96):
- 2 / 3 CSIPHY sub-devices - each CSIPHY is represented by a single sub-device;
- 2 / 4 CSID sub-devices - each CSID is represented by a single sub-device;
- 2 / 4 ISPIF sub-devices - ISPIF is represented by a number of sub-devices
equal to the number of CSID sub-devices;
- 4 / 8 VFE sub-devices - VFE is represented by a number of sub-devices equal to
the number of the input interfaces (3 RDI and 1 PIX for each VFE).
The considerations to split the driver in this particular way are as follows:
- representing CSIPHY and CSID modules by a separate sub-device for each module
allows to model the hardware links between these modules;
- representing VFE by a separate sub-devices for each input interface allows
to use the input interfaces concurrently and independently as this is
supported by the hardware;
- representing ISPIF by a number of sub-devices equal to the number of CSID
sub-devices allows to create linear media controller pipelines when using two
cameras simultaneously. This avoids branches in the pipelines which otherwise
will require a) userspace and b) media framework (e.g. power on/off
operations) to make assumptions about the data flow from a sink pad to a
source pad on a single media entity.
Each VFE sub-device is linked to a separate video device node.
The media controller pipeline graph is as follows (with connected two / three
OV5645 camera sensors):
.. _qcom_camss_graph:
.. kernel-figure:: qcom_camss_graph.dot
:alt: qcom_camss_graph.dot
:align: center
Media pipeline graph 8x16
.. kernel-figure:: qcom_camss_8x96_graph.dot
:alt: qcom_camss_8x96_graph.dot
:align: center
Media pipeline graph 8x96
Implementation
--------------
Runtime configuration of the hardware (updating settings while streaming) is
not required to implement the currently supported functionality. The complete
configuration on each hardware module is applied on STREAMON ioctl based on
the current active media links, formats and controls set.
The output size of the scaler module in the VFE is configured with the actual
compose selection rectangle on the sink pad of the 'msm_vfe0_pix' entity.
The crop output area of the crop module in the VFE is configured with the actual
crop selection rectangle on the source pad of the 'msm_vfe0_pix' entity.
Documentation
-------------
APQ8016 Specification:
https://developer.qualcomm.com/download/sd410/snapdragon-410-processor-device-specification.pdf
Referenced 2016-11-24.
APQ8096 Specification:
https://developer.qualcomm.com/download/sd820e/qualcomm-snapdragon-820e-processor-apq8096sge-device-specification.pdf
Referenced 2018-06-22.
References
----------
.. [#f1] https://git.codelinaro.org/clo/la/kernel/msm-3.10/
.. [#f2] https://git.codelinaro.org/clo/la/kernel/msm-3.18/
3. 한국어 전문 번역
영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.
Qualcomm Camera Subsystem 드라이버
1-23이 문서는 GPL-2.0 라이선스를 따르며 `drivers/media/platform/qcom/camss`의 Qualcomm Camera Subsystem(CAMSS) 드라이버를 설명합니다.
현재 드라이버는 Qualcomm MSM8916/APQ8016 및 MSM8996/APQ8096 processor의 Camera Subsystem을 지원합니다. V4L2, Media Controller, V4L2 subdev interface를 구현하며 kernel의 V4L2 subdev interface를 사용하는 camera sensor를 지원합니다.
구현은 Code Linaro에서 제공된 Android용 Qualcomm Camera Subsystem 드라이버를 참고했습니다.
CAMSS hardware block
24-468x16과 8x96에서 드라이버가 지원하는 Camera Subsystem은 다음 block으로 구성됩니다. 아래 수량은 `8x16 / 8x96` 순서입니다.
| Block | 8x16 | 8x96 | 역할 |
|---|---|---|---|
| CSIPHY | 2 | 3 | CSI2 receiver의 Physical layer |
| CSID | 2 | 4 | CSI2 Protocol/Application layer와 TG(Test Generator) |
| ISPIF | 1 module | 1 module | CSID stream을 VFE input으로 route |
| VFE | 1 | 2 | PIX image pipeline, 3 RDI, AXI memory output |
각 CSIPHY에는 별도 camera sensor를 연결할 수 있고, 각 CSID는 어느 CSIPHY의 stream이든 decode할 수 있습니다. CSID의 TG는 시험용 인공 입력 데이터를 생성합니다.
VFE의 PIX input은 scale과 crop을 포함한 image-processing pipeline으로 데이터를 보내며, 세 RDI input은 이 pipeline을 우회합니다. AXI bus interface는 결과를 memory에 기록합니다.
RDI 기능과 format
47-81드라이버는 CSIPHY를 통한 camera sensor 입력, CSID TG의 test 입력, VFE RDI interface를 지원합니다. RDI는 입력 데이터를 memory로 raw dump하며 8x96에서는 RAW10을 Plain16 RAW10으로 변환할 수도 있습니다.
| 동작 | Format | V4L2 symbol | 지원 SoC |
|---|---|---|---|
| Raw dump | YUYV/UYVY/YVYU/VYUY | V4L2_PIX_FMT_YUYV / V4L2_PIX_FMT_UYVY / V4L2_PIX_FMT_YVYU / V4L2_PIX_FMT_VYUY | 8x16, 8x96 |
| Raw dump | MIPI RAW8 | V4L2_PIX_FMT_SRGGB8 / V4L2_PIX_FMT_SGRBG8 / V4L2_PIX_FMT_SGBRG8 / V4L2_PIX_FMT_SBGGR8 | 8x16, 8x96 |
| Raw dump | MIPI RAW10 | V4L2_PIX_FMT_SBGGR10P / V4L2_PIX_FMT_SGBRG10P / V4L2_PIX_FMT_SGRBG10P / V4L2_PIX_FMT_SRGGB10P / V4L2_PIX_FMT_Y10P | 8x16, 8x96 |
| Raw dump | MIPI RAW12 | V4L2_PIX_FMT_SRGGB12P / V4L2_PIX_FMT_SGBRG12P / V4L2_PIX_FMT_SGRBG12P / V4L2_PIX_FMT_SRGGB12P | 8x16, 8x96 |
| Raw dump | MIPI RAW14 | V4L2_PIX_FMT_SRGGB14P / V4L2_PIX_FMT_SGBRG14P / V4L2_PIX_FMT_SGRBG14P / V4L2_PIX_FMT_SRGGB14P | 8x96 only |
| Format conversion | MIPI RAW10 → Plain16 RAW10 | V4L2_PIX_FMT_SBGGR10P / V4L2_PIX_FMT_Y10P → V4L2_PIX_FMT_SBGGR10 / V4L2_PIX_FMT_Y10 | 8x96 only |
RAW12와 RAW14 symbol 목록은 원문의 표기를 그대로 보존했습니다. 각 목록에서 `V4L2_PIX_FMT_SRGGB12P`와 `V4L2_PIX_FMT_SRGGB14P`가 반복됩니다.
PIX 변환·scale·crop
82-106VFE PIX interface는 packed YUV 4:2:2 입력을 two-plane YUV 4:2:0 또는 4:2:2로 변환합니다. 8x96에서는 packed YUV 4:2:2 출력도 지원합니다.
| 방향 | Format | V4L2 symbol | 지원 SoC |
|---|---|---|---|
| Input | YUYV/UYVY/YVYU/VYUY | V4L2_PIX_FMT_YUYV / V4L2_PIX_FMT_UYVY / V4L2_PIX_FMT_YVYU / V4L2_PIX_FMT_VYUY | 8x16, 8x96 |
| Output | NV12/NV21 | V4L2_PIX_FMT_NV12 / V4L2_PIX_FMT_NV21 | 8x16, 8x96 |
| Output | NV16/NV61 | V4L2_PIX_FMT_NV16 / V4L2_PIX_FMT_NV61 | 8x16, 8x96 |
| Output | YUYV/UYVY/YVYU/VYUY | V4L2_PIX_FMT_YUYV / V4L2_PIX_FMT_UYVY / V4L2_PIX_FMT_YVYU / V4L2_PIX_FMT_VYUY | 8x96 only |
VFE Encoder Scale module은 최대 16x downscaling을 지원하고 VFE Encoder Crop module은 cropping을 수행합니다. Camera sensor와 TG를 조합해 8x16에서는 2개, 8x96에서는 3개 입력을 동시에 독립적으로 사용할 수 있습니다.
V4L2 subdev 분할
107-120Hardware link를 정확히 model하고 논리적이며 사용하기 쉬운 interface를 제공하기 위해 드라이버를 다음 V4L2 sub-device로 분할합니다. 수량은 `8x16 / 8x96` 순서입니다.
| Sub-device | 8x16 | 8x96 | 분할 기준 |
|---|---|---|---|
| CSIPHY | 2 | 3 | Hardware module마다 하나 |
| CSID | 2 | 4 | Hardware module마다 하나 |
| ISPIF | 2 | 4 | CSID subdev 수와 동일 |
| VFE | 4 | 8 | VFE마다 3 RDI + 1 PIX input |
분할 설계의 이유
121-139- CSIPHY와 CSID module마다 별도 sub-device를 두어 module 사이 hardware link를 model합니다.
- VFE input interface마다 별도 sub-device를 두어 hardware가 지원하는 동시·독립 사용을 노출합니다.
- CSID 수와 같은 수의 ISPIF sub-device를 두어 카메라 두 대를 동시에 사용할 때 linear Media Controller pipeline을 만듭니다.
Linear pipeline은 하나의 media entity에서 sink pad부터 source pad까지 data flow를 userspace와 media framework의 power on/off 동작이 추측해야 하는 branch 구조를 피합니다. 각 VFE sub-device는 별도 video device node에 연결됩니다.
8x16과 8x96 media graph
140-154원문 DOT graph는 8x16에서 OV5645 camera sensor 두 대, 8x96에서 세 대를 연결한 Media Controller pipeline을 보여 줍니다. Dashed link는 선택 가능한 내부 route이고, 각 VFE input에서 video node로 가는 link는 실제 output 경로입니다.
두 sensor stream은 어느 CSID·ISPIF 경로로도 route할 수 있고, VFE0의 RDI0-2 또는 PIX input이 각각 `/dev/video0-3`에 연결됩니다.
세 sensor와 네 CSID·ISPIF route가 VFE0·VFE1의 8개 input sub-device를 거쳐 `/dev/video0-7`에 독립적으로 연결됩니다.
STREAMON 시점 설정
155-169현재 지원 기능에는 streaming 도중 설정을 갱신하는 runtime configuration이 필요하지 않습니다. 각 hardware module의 전체 설정은 현재 active media link, format, control을 기준으로 `STREAMON` `ioctl` 시점에 적용됩니다.
VFE scaler output size는 `msm_vfe0_pix` entity sink pad의 실제 compose selection rectangle로 설정합니다. Crop module의 output area는 같은 entity source pad의 실제 crop selection rectangle로 설정합니다.
사양서와 참고 구현
170-185SoC 사양서와 구현 참고 자료는 다음과 같습니다.
- APQ8016 Specification — referenced 2016-11-24
https://developer.qualcomm.com/download/sd410/snapdragon-410-processor-device-specification.pdf - APQ8096 Specification — referenced 2018-06-22
https://developer.qualcomm.com/download/sd820e/qualcomm-snapdragon-820e-processor-apq8096sge-device-specification.pdf - Code Linaro Qualcomm kernel msm-3.10
https://git.codelinaro.org/clo/la/kernel/msm-3.10/ - Code Linaro Qualcomm kernel msm-3.18
https://git.codelinaro.org/clo/la/kernel/msm-3.18/
CAMSS 구성 비교
qcom_camss.rst:1-185CAMSS는 CSI2 sensor 또는 TG 입력을 CSIPHY와 CSID에서 받아 ISPIF로 route한 뒤 VFE의 RDI raw path 또는 PIX processing path를 거쳐 memory에 기록합니다. 8x96은 8x16보다 더 많은 receiver와 VFE를 제공하고 일부 추가 format 변환을 지원합니다.