← Documents Documentation/userspace-api/media/drivers/imx-uapi.rst GitHub 원문 ↗

Linux 6.18.37 · Userspace API / Media / Drivers

i.MX Video Capture Driver

i.MX Frame Interval Monitor event, control과 input-capture 측정 경로를 설명합니다.

Source pathDocumentation/userspace-api/media/drivers/imx-uapi.rst
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.

1. 요약·해설

원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.

요약·해설

imx-uapi.rst:1-125

i.MX FIM은 corrupt NTSC/PAL field가 만든 frame rolling·split image를 interval 이상으로 검출합니다. userspace는 event 뒤 stream을 재시작하며 input capture를 사용하면 EOF interrupt latency 없이 더 정확히 측정할 수 있습니다.

2. 영어 원문 전체

번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.

원문 전체 펼치기
1 .. SPDX-License-Identifier: GPL-2.0
2
3 =========================
4 i.MX Video Capture Driver
5 =========================
6
7 Events
8 ======
9
10 .. _imx_api_ipuX_csiY:
11
12 ipuX_csiY
13 ---------
14
15 This subdev can generate the following event when enabling the second
16 IDMAC source pad:
17
18 - V4L2_EVENT_IMX_FRAME_INTERVAL_ERROR
19
20 The user application can subscribe to this event from the ipuX_csiY
21 subdev node. This event is generated by the Frame Interval Monitor
22 (see below for more on the FIM).
23
24 Controls
25 ========
26
27 .. _imx_api_FIM:
28
29 Frame Interval Monitor in ipuX_csiY
30 -----------------------------------
31
32 The adv718x decoders can occasionally send corrupt fields during
33 NTSC/PAL signal re-sync (too little or too many video lines). When
34 this happens, the IPU triggers a mechanism to re-establish vertical
35 sync by adding 1 dummy line every frame, which causes a rolling effect
36 from image to image, and can last a long time before a stable image is
37 recovered. Or sometimes the mechanism doesn't work at all, causing a
38 permanent split image (one frame contains lines from two consecutive
39 captured images).
40
41 From experiment it was found that during image rolling, the frame
42 intervals (elapsed time between two EOF's) drop below the nominal
43 value for the current standard, by about one frame time (60 usec),
44 and remain at that value until rolling stops.
45
46 While the reason for this observation isn't known (the IPU dummy
47 line mechanism should show an increase in the intervals by 1 line
48 time every frame, not a fixed value), we can use it to detect the
49 corrupt fields using a frame interval monitor. If the FIM detects a
50 bad frame interval, the ipuX_csiY subdev will send the event
51 V4L2_EVENT_IMX_FRAME_INTERVAL_ERROR. Userland can register with
52 the FIM event notification on the ipuX_csiY subdev device node.
53 Userland can issue a streaming restart when this event is received
54 to correct the rolling/split image.
55
56 The ipuX_csiY subdev includes custom controls to tweak some dials for
57 FIM. If one of these controls is changed during streaming, the FIM will
58 be reset and will continue at the new settings.
59
60 - V4L2_CID_IMX_FIM_ENABLE
61
62 Enable/disable the FIM.
63
64 - V4L2_CID_IMX_FIM_NUM
65
66 How many frame interval measurements to average before comparing against
67 the nominal frame interval reported by the sensor. This can reduce noise
68 caused by interrupt latency.
69
70 - V4L2_CID_IMX_FIM_TOLERANCE_MIN
71
72 If the averaged intervals fall outside nominal by this amount, in
73 microseconds, the V4L2_EVENT_IMX_FRAME_INTERVAL_ERROR event is sent.
74
75 - V4L2_CID_IMX_FIM_TOLERANCE_MAX
76
77 If any intervals are higher than this value, those samples are
78 discarded and do not enter into the average. This can be used to
79 discard really high interval errors that might be due to interrupt
80 latency from high system load.
81
82 - V4L2_CID_IMX_FIM_NUM_SKIP
83
84 How many frames to skip after a FIM reset or stream restart before
85 FIM begins to average intervals.
86
87 - V4L2_CID_IMX_FIM_ICAP_CHANNEL / V4L2_CID_IMX_FIM_ICAP_EDGE
88
89 These controls will configure an input capture channel as the method
90 for measuring frame intervals. This is superior to the default method
91 of measuring frame intervals via EOF interrupt, since it is not subject
92 to uncertainty errors introduced by interrupt latency.
93
94 Input capture requires hardware support. A VSYNC signal must be routed
95 to one of the i.MX6 input capture channel pads.
96
97 V4L2_CID_IMX_FIM_ICAP_CHANNEL configures which i.MX6 input capture
98 channel to use. This must be 0 or 1.
99
100 V4L2_CID_IMX_FIM_ICAP_EDGE configures which signal edge will trigger
101 input capture events. By default the input capture method is disabled
102 with a value of IRQ_TYPE_NONE. Set this control to IRQ_TYPE_EDGE_RISING,
103 IRQ_TYPE_EDGE_FALLING, or IRQ_TYPE_EDGE_BOTH to enable input capture,
104 triggered on the given signal edge(s).
105
106 When input capture is disabled, frame intervals will be measured via
107 EOF interrupt.
108
109
110 File list
111 ---------
112
113 drivers/staging/media/imx/
114 include/media/imx.h
115 include/linux/imx-media.h
116
117
118 Authors
119 -------
120
121 - Steve Longerbeam <steve_longerbeam@mentor.com>
122 - Philipp Zabel <kernel@pengutronix.de>
123 - Russell King <linux@armlinux.org.uk>
124
125 Copyright (C) 2012-2017 Mentor Graphics Inc.
126

3. 한국어 전문 번역

영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.

ipuX_csiY event

1-23

i.MX Video Capture Driver의 `ipuX_csiY` sub-device는 두 번째 IDMAC source pad를 enable할 때 `V4L2_EVENT_IMX_FRAME_INTERVAL_ERROR` event를 생성할 수 있습니다.

userspace 응용 프로그램은 `ipuX_csiY` sub-device node에서 이 event를 subscribe합니다. event는 아래에 설명하는 Frame Interval Monitor(FIM)가 생성합니다.

i.MX frame interval event
항목설명
EventV4L2_EVENT_IMX_FRAME_INTERVAL_ERROR
SourceipuX_csiY Frame Interval Monitor
Condition두 번째 IDMAC source pad enable 후 bad interval 검출
SubscriptionipuX_csiY subdev node

event source와 userspace 구독 지점을 구분합니다.

.. SPDX-License-Identifier: GPL-2.0

=========================
i.MX Video Capture Driver
=========================

Events
======

.. _imx_api_ipuX_csiY:

ipuX_csiY
---------

This subdev can generate the following event when enabling the second
IDMAC source pad:

- V4L2_EVENT_IMX_FRAME_INTERVAL_ERROR

The user application can subscribe to this event from the ipuX_csiY
subdev node. This event is generated by the Frame Interval Monitor
(see below for more on the FIM).

Frame Interval Monitor와 복구

24-59

adv718x decoder는 NTSC/PAL signal을 다시 동기화할 때 video line이 너무 적거나 많은 corrupt field를 가끔 보낼 수 있습니다.

이때 IPU는 매 frame에 dummy line 하나를 추가해 vertical sync를 복구하려 합니다. 이 과정은 image가 frame마다 굴러가는 rolling effect를 만들고 안정된 image까지 오래 걸릴 수 있습니다. mechanism이 전혀 동작하지 않으면 두 연속 capture image의 line이 한 frame에 섞인 permanent split image가 생길 수 있습니다.

실험상 rolling 동안 두 EOF 사이 elapsed time인 frame interval은 current standard의 nominal value보다 frame time 하나, 약 60 μs만큼 낮아지고 rolling이 멈출 때까지 그 값에 머뭅니다.

dummy-line mechanism이라면 매 frame interval이 line time 하나씩 늘어야 하고 고정 감소가 관찰되는 이유는 알려져 있지 않지만, FIM은 이 현상을 이용해 corrupt field를 검출합니다.

bad frame interval을 검출하면 `ipuX_csiY`가 `V4L2_EVENT_IMX_FRAME_INTERVAL_ERROR`를 보냅니다. userspace는 event를 받은 뒤 streaming을 restart해 rolling 또는 split image를 바로잡을 수 있습니다.

`ipuX_csiY`는 FIM을 조정하는 custom control을 제공합니다. streaming 중 control을 바꾸면 FIM이 reset되고 새 설정으로 계속 동작합니다.

FIM 기반 capture 복구
NTSC/PAL 재동기화 중 corrupt fieldIPU dummy-line vertical sync mechanism 시작Frame rolling 또는 split image 발생FIM이 nominal frame interval 이탈 검출V4L2_EVENT_IMX_FRAME_INTERVAL_ERROR 전송Userspace가 streaming restart안정된 capture 복구

비정상 interval을 event와 stream restart로 복구합니다.

관찰된 FIM 징후
항목설명
정상 기준Sensor가 보고한 nominal frame interval
Rolling 관찰약 60 μs 낮은 고정 interval
Dummy-line 예상매 frame마다 약 1 line time 증가
Userspace 대응Event 수신 후 stream restart

문서의 실험 관찰과 예상 mechanism을 함께 보존합니다.

Controls
========

.. _imx_api_FIM:

Frame Interval Monitor in ipuX_csiY
-----------------------------------

The adv718x decoders can occasionally send corrupt fields during
NTSC/PAL signal re-sync (too little or too many video lines). When
this happens, the IPU triggers a mechanism to re-establish vertical
sync by adding 1 dummy line every frame, which causes a rolling effect
from image to image, and can last a long time before a stable image is
recovered. Or sometimes the mechanism doesn't work at all, causing a
permanent split image (one frame contains lines from two consecutive
captured images).

From experiment it was found that during image rolling, the frame
intervals (elapsed time between two EOF's) drop below the nominal
value for the current standard, by about one frame time (60 usec),
and remain at that value until rolling stops.

While the reason for this observation isn't known (the IPU dummy
line mechanism should show an increase in the intervals by 1 line
time every frame, not a fixed value), we can use it to detect the
corrupt fields using a frame interval monitor. If the FIM detects a
bad frame interval, the ipuX_csiY subdev will send the event
V4L2_EVENT_IMX_FRAME_INTERVAL_ERROR. Userland can register with
the FIM event notification on the ipuX_csiY subdev device node.
Userland can issue a streaming restart when this event is received
to correct the rolling/split image.

The ipuX_csiY subdev includes custom controls to tweak some dials for
FIM. If one of these controls is changed during streaming, the FIM will
be reset and will continue at the new settings.

FIM control

60-86

`V4L2_CID_IMX_FIM_ENABLE`은 FIM을 enable 또는 disable합니다.

`V4L2_CID_IMX_FIM_NUM`은 sensor가 보고한 nominal interval과 비교하기 전에 평균할 frame interval 측정 수입니다. 여러 sample 평균으로 interrupt latency가 만든 noise를 줄입니다.

`V4L2_CID_IMX_FIM_TOLERANCE_MIN`은 평균 interval이 nominal에서 이 microsecond 값만큼 벗어났을 때 frame-interval error event를 보내는 threshold입니다.

`V4L2_CID_IMX_FIM_TOLERANCE_MAX`보다 큰 개별 interval은 평균에서 버립니다. 높은 system load의 interrupt latency가 만든 매우 큰 오류 sample을 제거하는 데 사용합니다.

`V4L2_CID_IMX_FIM_NUM_SKIP`은 FIM reset 또는 stream restart 뒤 interval 평균을 시작하기 전에 건너뛸 frame 수입니다.

i.MX FIM control
항목설명
V4L2_CID_IMX_FIM_ENABLEFIM enable/disable
V4L2_CID_IMX_FIM_NUM평균할 interval sample 수
V4L2_CID_IMX_FIM_TOLERANCE_MINNominal 이탈 event threshold, μs
V4L2_CID_IMX_FIM_TOLERANCE_MAX이보다 큰 interval sample discard
V4L2_CID_IMX_FIM_NUM_SKIPReset/restart 뒤 평균 전 skip frame 수

enable, averaging, threshold, outlier와 warm-up을 각각 제어합니다.

FIM sample 처리
Reset 뒤 NUM_SKIP frame 건너뜀Frame interval 측정TOLERANCE_MAX 초과 sample discardFIM_NUM개 sample 평균Nominal과 차이를 TOLERANCE_MIN과 비교초과 시 frame interval error event

outlier를 제거하고 평균을 nominal tolerance와 비교합니다.

- V4L2_CID_IMX_FIM_ENABLE

Enable/disable the FIM.

- V4L2_CID_IMX_FIM_NUM

How many frame interval measurements to average before comparing against
the nominal frame interval reported by the sensor. This can reduce noise
caused by interrupt latency.

- V4L2_CID_IMX_FIM_TOLERANCE_MIN

If the averaged intervals fall outside nominal by this amount, in
microseconds, the V4L2_EVENT_IMX_FRAME_INTERVAL_ERROR event is sent.

- V4L2_CID_IMX_FIM_TOLERANCE_MAX

If any intervals are higher than this value, those samples are
discarded and do not enter into the average. This can be used to
discard really high interval errors that might be due to interrupt
latency from high system load.

- V4L2_CID_IMX_FIM_NUM_SKIP

How many frames to skip after a FIM reset or stream restart before
FIM begins to average intervals.

Input capture와 EOF 측정

87-109

`V4L2_CID_IMX_FIM_ICAP_CHANNEL`과 `V4L2_CID_IMX_FIM_ICAP_EDGE`는 frame interval 측정에 사용할 input capture channel을 구성합니다.

input capture는 EOF interrupt 방식과 달리 interrupt latency가 불확실성을 더하지 않아 더 정확합니다. hardware 지원이 필요하고 VSYNC signal을 i.MX6 input capture channel pad 중 하나로 route해야 합니다.

`V4L2_CID_IMX_FIM_ICAP_CHANNEL`은 channel 0 또는 1을 선택합니다.

`V4L2_CID_IMX_FIM_ICAP_EDGE`는 capture event를 trigger할 signal edge를 정합니다. 기본값 `IRQ_TYPE_NONE`은 input capture를 disable합니다. `IRQ_TYPE_EDGE_RISING`, `IRQ_TYPE_EDGE_FALLING`, `IRQ_TYPE_EDGE_BOTH`로 해당 edge를 enable합니다.

input capture가 disabled이면 EOF interrupt로 frame interval을 측정합니다.

FIM input capture 설정
항목설명
V4L2_CID_IMX_FIM_ICAP_CHANNEL0 또는 1
IRQ_TYPE_NONEInput capture disabled, EOF fallback
IRQ_TYPE_EDGE_RISINGRising edge capture
IRQ_TYPE_EDGE_FALLINGFalling edge capture
IRQ_TYPE_EDGE_BOTH양 edge capture

channel과 trigger edge가 hardware timestamp path를 선택합니다.

Frame interval 측정 경로
VSYNC route와 hardware support 확인ICAP channel 0/1 선택ICAP edge 선택Edge가 NONE이면 EOF interrupt 측정그 밖에는 input capture event 측정측정 interval을 FIM 평균기로 전달

input capture가 enable됐는지에 따라 timestamp source가 달라집니다.

- V4L2_CID_IMX_FIM_ICAP_CHANNEL / V4L2_CID_IMX_FIM_ICAP_EDGE

These controls will configure an input capture channel as the method
for measuring frame intervals. This is superior to the default method
of measuring frame intervals via EOF interrupt, since it is not subject
to uncertainty errors introduced by interrupt latency.

Input capture requires hardware support. A VSYNC signal must be routed
to one of the i.MX6 input capture channel pads.

V4L2_CID_IMX_FIM_ICAP_CHANNEL configures which i.MX6 input capture
channel to use. This must be 0 or 1.

V4L2_CID_IMX_FIM_ICAP_EDGE configures which signal edge will trigger
input capture events. By default the input capture method is disabled
with a value of IRQ_TYPE_NONE. Set this control to IRQ_TYPE_EDGE_RISING,
IRQ_TYPE_EDGE_FALLING, or IRQ_TYPE_EDGE_BOTH to enable input capture,
triggered on the given signal edge(s).

When input capture is disabled, frame intervals will be measured via
EOF interrupt.

Source file과 저자

110-125

관련 source path는 `drivers/staging/media/imx/`, `include/media/imx.h`, `include/linux/imx-media.h`입니다.

저자는 Steve Longerbeam, Philipp Zabel, Russell King이며 Copyright 2012–2017 Mentor Graphics Inc.입니다.

i.MX media source
항목설명
Driverdrivers/staging/media/imx/
Media headerinclude/media/imx.h
Linux headerinclude/linux/imx-media.h

driver implementation과 public header 위치를 보존합니다.

File list
---------

drivers/staging/media/imx/
include/media/imx.h
include/linux/imx-media.h


Authors
-------

- Steve Longerbeam <steve_longerbeam@mentor.com>
- Philipp Zabel <kernel@pengutronix.de>
- Russell King <linux@armlinux.org.uk>

Copyright (C) 2012-2017 Mentor Graphics Inc.