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