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