요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.
1. 요약·해설
원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.
2. 영어 원문 전체
번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.
원문 전체 펼치기
.. SPDX-License-Identifier: GPL-2.0
.. _media_using_camera_sensor_drivers:
Using camera sensor drivers
===========================
This section describes common practices for how the V4L2 sub-device interface is
used to control the camera sensor drivers.
You may also find :ref:`media_writing_camera_sensor_drivers` useful.
Sensor internal pipeline configuration
--------------------------------------
Camera sensors have an internal processing pipeline including cropping and
binning functionality. The sensor drivers belong to two distinct classes, freely
configurable and register list-based drivers, depending on how the driver
configures this functionality.
Freely configurable camera sensor drivers
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Freely configurable camera sensor drivers expose the device's internal
processing pipeline as one or more sub-devices with different cropping and
scaling configurations. The output size of the device is the result of a series
of cropping and scaling operations from the device's pixel array's size.
An example of such a driver is the CCS driver.
Register list-based drivers
~~~~~~~~~~~~~~~~~~~~~~~~~~~
Register list-based drivers generally, instead of able to configure the device
they control based on user requests, are limited to a number of preset
configurations that combine a number of different parameters that on hardware
level are independent. How a driver picks such configuration is based on the
format set on a source pad at the end of the device's internal pipeline.
Most sensor drivers are implemented this way.
Frame interval configuration
----------------------------
There are two different methods for obtaining possibilities for different frame
intervals as well as configuring the frame interval. Which one to implement
depends on the type of the device.
Raw camera sensors
~~~~~~~~~~~~~~~~~~
Instead of a high level parameter such as frame interval, the frame interval is
a result of the configuration of a number of camera sensor implementation
specific parameters. Luckily, these parameters tend to be the same for more or
less all modern raw camera sensors.
The frame interval is calculated using the following equation::
frame interval = (analogue crop width + horizontal blanking) *
(analogue crop height + vertical blanking) / pixel rate
The formula is bus independent and is applicable for raw timing parameters on
large variety of devices beyond camera sensors. Devices that have no analogue
crop, use the full source image size, i.e. pixel array size.
Horizontal and vertical blanking are specified by ``V4L2_CID_HBLANK`` and
``V4L2_CID_VBLANK``, respectively. The unit of the ``V4L2_CID_HBLANK`` control
is pixels and the unit of the ``V4L2_CID_VBLANK`` is lines. The pixel rate in
the sensor's **pixel array** is specified by ``V4L2_CID_PIXEL_RATE`` in the same
sub-device. The unit of that control is pixels per second.
Register list-based drivers need to implement read-only sub-device nodes for the
purpose. Devices that are not register list based need these to configure the
device's internal processing pipeline.
The first entity in the linear pipeline is the pixel array. The pixel array may
be followed by other entities that are there to allow configuring binning,
skipping, scaling or digital crop, see :ref:`VIDIOC_SUBDEV_G_SELECTION
<VIDIOC_SUBDEV_G_SELECTION>`.
USB cameras etc. devices
~~~~~~~~~~~~~~~~~~~~~~~~
USB video class hardware, as well as many cameras offering a similar higher
level interface natively, generally use the concept of frame interval (or frame
rate) on device level in firmware or hardware. This means lower level controls
implemented by raw cameras may not be used on uAPI (or even kAPI) to control the
frame interval on these devices.
Rotation, orientation and flipping
----------------------------------
Some systems have the camera sensor mounted upside down compared to its natural
mounting rotation. In such cases, drivers shall expose the information to
userspace with the :ref:`V4L2_CID_CAMERA_SENSOR_ROTATION
<v4l2-camera-sensor-rotation>` control.
Sensor drivers shall also report the sensor's mounting orientation with the
:ref:`V4L2_CID_CAMERA_SENSOR_ORIENTATION <v4l2-camera-sensor-orientation>`.
Sensor drivers that have any vertical or horizontal flips embedded in the
register programming sequences shall initialize the :ref:`V4L2_CID_HFLIP
<v4l2-cid-hflip>` and :ref:`V4L2_CID_VFLIP <v4l2-cid-vflip>` controls with the
values programmed by the register sequences. The default values of these
controls shall be 0 (disabled). Especially these controls shall not be inverted,
independently of the sensor's mounting rotation.
3. 한국어 전문 번역
영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.
V4L2 sub-device 관행
1-12이 문서는 V4L2 sub-device interface로 camera sensor driver를 제어할 때의 공통 관행을 설명합니다.
driver 구현 측면은 `media_writing_camera_sensor_drivers` 문서도 함께 참고할 수 있습니다.
.. SPDX-License-Identifier: GPL-2.0
.. _media_using_camera_sensor_drivers:
Using camera sensor drivers
===========================
This section describes common practices for how the V4L2 sub-device interface is
used to control the camera sensor drivers.
You may also find :ref:`media_writing_camera_sensor_drivers` useful.
Sensor internal pipeline 구성
13-41camera sensor 내부에는 crop과 binning을 포함한 processing pipeline이 있습니다. 이 기능을 구성하는 방식에 따라 driver는 freely configurable과 register list-based 두 부류로 나뉩니다.
freely configurable driver는 내부 pipeline을 서로 다른 crop·scale 구성을 가진 하나 이상의 sub-device로 노출합니다. 최종 output size는 pixel array size에서 시작해 일련의 crop과 scaling을 적용한 결과입니다.
CCS driver가 freely configurable 방식의 예입니다.
register list-based driver는 사용자의 각 요청에 맞춰 독립적인 hardware parameter를 자유롭게 조합하지 못하고, 여러 parameter를 묶은 제한된 preset configuration 중 하나를 사용합니다.
driver는 device internal pipeline 끝의 source pad에 설정된 format을 기준으로 preset을 고릅니다. 대부분의 sensor driver가 이 방식으로 구현됩니다.
pipeline 자유도와 format 선택 지점을 비교합니다.
output size는 pixel array에 연속 변환을 적용한 결과입니다.
Sensor internal pipeline configuration
--------------------------------------
Camera sensors have an internal processing pipeline including cropping and
binning functionality. The sensor drivers belong to two distinct classes, freely
configurable and register list-based drivers, depending on how the driver
configures this functionality.
Freely configurable camera sensor drivers
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Freely configurable camera sensor drivers expose the device's internal
processing pipeline as one or more sub-devices with different cropping and
scaling configurations. The output size of the device is the result of a series
of cropping and scaling operations from the device's pixel array's size.
An example of such a driver is the CCS driver.
Register list-based drivers
~~~~~~~~~~~~~~~~~~~~~~~~~~~
Register list-based drivers generally, instead of able to configure the device
they control based on user requests, are limited to a number of preset
configurations that combine a number of different parameters that on hardware
level are independent. How a driver picks such configuration is based on the
format set on a source pad at the end of the device's internal pipeline.
Most sensor drivers are implemented this way.
Raw camera의 frame interval
42-80frame interval의 가능한 값 조회와 설정에는 두 방식이 있으며 device 유형에 따라 구현 방식을 선택합니다.
raw camera sensor에서는 frame interval이 하나의 high-level parameter가 아니라 sensor 구현별 여러 parameter 조합의 결과입니다. 다행히 현대 raw sensor의 핵심 parameter는 대체로 같습니다.
계산식은 `frame interval = (analogue crop width + horizontal blanking) * (analogue crop height + vertical blanking) / pixel rate`입니다.
이 식은 bus와 무관하며 camera sensor를 넘어 raw timing parameter를 사용하는 다양한 device에 적용됩니다. analogue crop이 없는 device는 전체 source image, 즉 pixel array size를 사용합니다.
horizontal blanking은 `V4L2_CID_HBLANK`로 pixel 단위, vertical blanking은 `V4L2_CID_VBLANK`로 line 단위 지정합니다. sensor pixel array의 pixel rate는 같은 sub-device의 `V4L2_CID_PIXEL_RATE`이며 단위는 pixels per second입니다.
register list-based driver는 이 값을 제공할 read-only sub-device node를 구현해야 합니다. 그 밖의 device는 이 control들로 internal processing pipeline을 구성합니다.
linear pipeline의 첫 entity는 pixel array입니다. 뒤에 binning, skipping, scaling 또는 digital crop을 구성하는 entity가 올 수 있으며 selection은 `VIDIOC_SUBDEV_G_SELECTION`을 사용합니다.
각 control의 단위와 수식 역할을 보존합니다.
total line length와 frame height를 pixel rate로 나눕니다.
Frame interval configuration
----------------------------
There are two different methods for obtaining possibilities for different frame
intervals as well as configuring the frame interval. Which one to implement
depends on the type of the device.
Raw camera sensors
~~~~~~~~~~~~~~~~~~
Instead of a high level parameter such as frame interval, the frame interval is
a result of the configuration of a number of camera sensor implementation
specific parameters. Luckily, these parameters tend to be the same for more or
less all modern raw camera sensors.
The frame interval is calculated using the following equation::
frame interval = (analogue crop width + horizontal blanking) *
(analogue crop height + vertical blanking) / pixel rate
The formula is bus independent and is applicable for raw timing parameters on
large variety of devices beyond camera sensors. Devices that have no analogue
crop, use the full source image size, i.e. pixel array size.
Horizontal and vertical blanking are specified by ``V4L2_CID_HBLANK`` and
``V4L2_CID_VBLANK``, respectively. The unit of the ``V4L2_CID_HBLANK`` control
is pixels and the unit of the ``V4L2_CID_VBLANK`` is lines. The pixel rate in
the sensor's **pixel array** is specified by ``V4L2_CID_PIXEL_RATE`` in the same
sub-device. The unit of that control is pixels per second.
Register list-based drivers need to implement read-only sub-device nodes for the
purpose. Devices that are not register list based need these to configure the
device's internal processing pipeline.
The first entity in the linear pipeline is the pixel array. The pixel array may
be followed by other entities that are there to allow configuring binning,
skipping, scaling or digital crop, see :ref:`VIDIOC_SUBDEV_G_SELECTION
<VIDIOC_SUBDEV_G_SELECTION>`.
USB camera 등의 frame interval
81-89USB Video Class hardware와 비슷한 high-level interface를 자체 제공하는 camera는 firmware 또는 hardware device level에서 frame interval이나 frame rate 개념을 직접 사용합니다.
따라서 raw camera의 low-level timing control은 이런 device의 frame interval을 제어하는 uAPI나 kAPI에 사용되지 않을 수 있습니다.
device가 raw timing을 노출하는지 high-level rate를 제공하는지에 따라 달라집니다.
USB cameras etc. devices
~~~~~~~~~~~~~~~~~~~~~~~~
USB video class hardware, as well as many cameras offering a similar higher
level interface natively, generally use the concept of frame interval (or frame
rate) on device level in firmware or hardware. This means lower level controls
implemented by raw cameras may not be used on uAPI (or even kAPI) to control the
frame interval on these devices.
Rotation, orientation과 flip
90-106system에 camera sensor가 자연스러운 mounting rotation과 비교해 거꾸로 장착될 수 있습니다. driver는 `V4L2_CID_CAMERA_SENSOR_ROTATION` control로 이 회전 정보를 userspace에 노출해야 합니다.
sensor의 mounting orientation도 `V4L2_CID_CAMERA_SENSOR_ORIENTATION`으로 보고해야 합니다.
register programming sequence에 vertical 또는 horizontal flip이 포함된 driver는 실제로 programming한 값으로 `V4L2_CID_HFLIP`과 `V4L2_CID_VFLIP`을 초기화해야 합니다.
두 flip control의 default는 0(disabled)이어야 하며 sensor mounting rotation과 관계없이 control 의미를 반전해서는 안 됩니다.
물리 장착 정보와 pixel flip 상태를 별도로 보고합니다.
장착 회전과 image flip control은 서로 독립적으로 해석합니다.
Rotation, orientation and flipping
----------------------------------
Some systems have the camera sensor mounted upside down compared to its natural
mounting rotation. In such cases, drivers shall expose the information to
userspace with the :ref:`V4L2_CID_CAMERA_SENSOR_ROTATION
<v4l2-camera-sensor-rotation>` control.
Sensor drivers shall also report the sensor's mounting orientation with the
:ref:`V4L2_CID_CAMERA_SENSOR_ORIENTATION <v4l2-camera-sensor-orientation>`.
Sensor drivers that have any vertical or horizontal flips embedded in the
register programming sequences shall initialize the :ref:`V4L2_CID_HFLIP
<v4l2-cid-hflip>` and :ref:`V4L2_CID_VFLIP <v4l2-cid-vflip>` controls with the
values programmed by the register sequences. The default values of these
controls shall be 0 (disabled). Especially these controls shall not be inverted,
independently of the sensor's mounting rotation.
요약·해설
camera-sensor.rst:1-106raw sensor의 frame interval은 crop·blanking·pixel rate에서 계산하고, high-level camera는 device-level frame rate를 사용할 수 있습니다. mounting rotation과 flip control은 독립적으로 보고해야 합니다.