18c2ecf20Sopenharmony_ci.. SPDX-License-Identifier: GPL-2.0 28c2ecf20Sopenharmony_ci 38c2ecf20Sopenharmony_ci========================= 48c2ecf20Sopenharmony_cii.MX Video Capture Driver 58c2ecf20Sopenharmony_ci========================= 68c2ecf20Sopenharmony_ci 78c2ecf20Sopenharmony_ciEvents 88c2ecf20Sopenharmony_ci====== 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci.. _imx_api_ipuX_csiY: 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ciipuX_csiY 138c2ecf20Sopenharmony_ci--------- 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ciThis subdev can generate the following event when enabling the second 168c2ecf20Sopenharmony_ciIDMAC source pad: 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ci- V4L2_EVENT_IMX_FRAME_INTERVAL_ERROR 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ciThe user application can subscribe to this event from the ipuX_csiY 218c2ecf20Sopenharmony_cisubdev node. This event is generated by the Frame Interval Monitor 228c2ecf20Sopenharmony_ci(see below for more on the FIM). 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_ciControls 258c2ecf20Sopenharmony_ci======== 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_ci.. _imx_api_FIM: 288c2ecf20Sopenharmony_ci 298c2ecf20Sopenharmony_ciFrame Interval Monitor in ipuX_csiY 308c2ecf20Sopenharmony_ci----------------------------------- 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_ciThe adv718x decoders can occasionally send corrupt fields during 338c2ecf20Sopenharmony_ciNTSC/PAL signal re-sync (too little or too many video lines). When 348c2ecf20Sopenharmony_cithis happens, the IPU triggers a mechanism to re-establish vertical 358c2ecf20Sopenharmony_cisync by adding 1 dummy line every frame, which causes a rolling effect 368c2ecf20Sopenharmony_cifrom image to image, and can last a long time before a stable image is 378c2ecf20Sopenharmony_cirecovered. Or sometimes the mechanism doesn't work at all, causing a 388c2ecf20Sopenharmony_cipermanent split image (one frame contains lines from two consecutive 398c2ecf20Sopenharmony_cicaptured images). 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_ciFrom experiment it was found that during image rolling, the frame 428c2ecf20Sopenharmony_ciintervals (elapsed time between two EOF's) drop below the nominal 438c2ecf20Sopenharmony_civalue for the current standard, by about one frame time (60 usec), 448c2ecf20Sopenharmony_ciand remain at that value until rolling stops. 458c2ecf20Sopenharmony_ci 468c2ecf20Sopenharmony_ciWhile the reason for this observation isn't known (the IPU dummy 478c2ecf20Sopenharmony_ciline mechanism should show an increase in the intervals by 1 line 488c2ecf20Sopenharmony_citime every frame, not a fixed value), we can use it to detect the 498c2ecf20Sopenharmony_cicorrupt fields using a frame interval monitor. If the FIM detects a 508c2ecf20Sopenharmony_cibad frame interval, the ipuX_csiY subdev will send the event 518c2ecf20Sopenharmony_ciV4L2_EVENT_IMX_FRAME_INTERVAL_ERROR. Userland can register with 528c2ecf20Sopenharmony_cithe FIM event notification on the ipuX_csiY subdev device node. 538c2ecf20Sopenharmony_ciUserland can issue a streaming restart when this event is received 548c2ecf20Sopenharmony_cito correct the rolling/split image. 558c2ecf20Sopenharmony_ci 568c2ecf20Sopenharmony_ciThe ipuX_csiY subdev includes custom controls to tweak some dials for 578c2ecf20Sopenharmony_ciFIM. If one of these controls is changed during streaming, the FIM will 588c2ecf20Sopenharmony_cibe reset and will continue at the new settings. 598c2ecf20Sopenharmony_ci 608c2ecf20Sopenharmony_ci- V4L2_CID_IMX_FIM_ENABLE 618c2ecf20Sopenharmony_ci 628c2ecf20Sopenharmony_ciEnable/disable the FIM. 638c2ecf20Sopenharmony_ci 648c2ecf20Sopenharmony_ci- V4L2_CID_IMX_FIM_NUM 658c2ecf20Sopenharmony_ci 668c2ecf20Sopenharmony_ciHow many frame interval measurements to average before comparing against 678c2ecf20Sopenharmony_cithe nominal frame interval reported by the sensor. This can reduce noise 688c2ecf20Sopenharmony_cicaused by interrupt latency. 698c2ecf20Sopenharmony_ci 708c2ecf20Sopenharmony_ci- V4L2_CID_IMX_FIM_TOLERANCE_MIN 718c2ecf20Sopenharmony_ci 728c2ecf20Sopenharmony_ciIf the averaged intervals fall outside nominal by this amount, in 738c2ecf20Sopenharmony_cimicroseconds, the V4L2_EVENT_IMX_FRAME_INTERVAL_ERROR event is sent. 748c2ecf20Sopenharmony_ci 758c2ecf20Sopenharmony_ci- V4L2_CID_IMX_FIM_TOLERANCE_MAX 768c2ecf20Sopenharmony_ci 778c2ecf20Sopenharmony_ciIf any intervals are higher than this value, those samples are 788c2ecf20Sopenharmony_cidiscarded and do not enter into the average. This can be used to 798c2ecf20Sopenharmony_cidiscard really high interval errors that might be due to interrupt 808c2ecf20Sopenharmony_cilatency from high system load. 818c2ecf20Sopenharmony_ci 828c2ecf20Sopenharmony_ci- V4L2_CID_IMX_FIM_NUM_SKIP 838c2ecf20Sopenharmony_ci 848c2ecf20Sopenharmony_ciHow many frames to skip after a FIM reset or stream restart before 858c2ecf20Sopenharmony_ciFIM begins to average intervals. 868c2ecf20Sopenharmony_ci 878c2ecf20Sopenharmony_ci- V4L2_CID_IMX_FIM_ICAP_CHANNEL / V4L2_CID_IMX_FIM_ICAP_EDGE 888c2ecf20Sopenharmony_ci 898c2ecf20Sopenharmony_ciThese controls will configure an input capture channel as the method 908c2ecf20Sopenharmony_cifor measuring frame intervals. This is superior to the default method 918c2ecf20Sopenharmony_ciof measuring frame intervals via EOF interrupt, since it is not subject 928c2ecf20Sopenharmony_cito uncertainty errors introduced by interrupt latency. 938c2ecf20Sopenharmony_ci 948c2ecf20Sopenharmony_ciInput capture requires hardware support. A VSYNC signal must be routed 958c2ecf20Sopenharmony_cito one of the i.MX6 input capture channel pads. 968c2ecf20Sopenharmony_ci 978c2ecf20Sopenharmony_ciV4L2_CID_IMX_FIM_ICAP_CHANNEL configures which i.MX6 input capture 988c2ecf20Sopenharmony_cichannel to use. This must be 0 or 1. 998c2ecf20Sopenharmony_ci 1008c2ecf20Sopenharmony_ciV4L2_CID_IMX_FIM_ICAP_EDGE configures which signal edge will trigger 1018c2ecf20Sopenharmony_ciinput capture events. By default the input capture method is disabled 1028c2ecf20Sopenharmony_ciwith a value of IRQ_TYPE_NONE. Set this control to IRQ_TYPE_EDGE_RISING, 1038c2ecf20Sopenharmony_ciIRQ_TYPE_EDGE_FALLING, or IRQ_TYPE_EDGE_BOTH to enable input capture, 1048c2ecf20Sopenharmony_citriggered on the given signal edge(s). 1058c2ecf20Sopenharmony_ci 1068c2ecf20Sopenharmony_ciWhen input capture is disabled, frame intervals will be measured via 1078c2ecf20Sopenharmony_ciEOF interrupt. 1088c2ecf20Sopenharmony_ci 1098c2ecf20Sopenharmony_ci 1108c2ecf20Sopenharmony_ciFile list 1118c2ecf20Sopenharmony_ci--------- 1128c2ecf20Sopenharmony_ci 1138c2ecf20Sopenharmony_cidrivers/staging/media/imx/ 1148c2ecf20Sopenharmony_ciinclude/media/imx.h 1158c2ecf20Sopenharmony_ciinclude/linux/imx-media.h 1168c2ecf20Sopenharmony_ci 1178c2ecf20Sopenharmony_ci 1188c2ecf20Sopenharmony_ciAuthors 1198c2ecf20Sopenharmony_ci------- 1208c2ecf20Sopenharmony_ci 1218c2ecf20Sopenharmony_ci- Steve Longerbeam <steve_longerbeam@mentor.com> 1228c2ecf20Sopenharmony_ci- Philipp Zabel <kernel@pengutronix.de> 1238c2ecf20Sopenharmony_ci- Russell King <linux@armlinux.org.uk> 1248c2ecf20Sopenharmony_ci 1258c2ecf20Sopenharmony_ciCopyright (C) 2012-2017 Mentor Graphics Inc. 126