From: Jiaqi Shi <shijiaqi_develop@163.com>
To: linux-media@vger.kernel.org, imx@lists.linux.dev,
linux-staging@lists.linux.dev
Cc: slongerbeam@gmail.com, p.zabel@pengutronix.de,
mchehab@kernel.org, gregkh@linuxfoundation.org, Frank.Li@nxp.com,
kernel@pengutronix.de, festevam@gmail.com,
Jiaqi Shi <shijiaqi_develop@163.com>
Subject: [PATCH v8 2/2] media: imx: remove frame interval monitor
Date: Tue, 1 Dec 2026 23:26:47 +0800 [thread overview]
Message-ID: <20261201152647.847238-3-shijiaqi_develop@163.com> (raw)
In-Reply-To: <20261201152647.847238-1-shijiaqi_develop@163.com>
The frame interval monitor is an i.MX-private feature that measures CSI
frame intervals using private controls and a private event. It is
disabled by default, is only wired into the CSI driver, and aside from
the driver-specific UAPI page has no documentation.
There is no evidence of a real userspace consumer, and the media
maintainer considers it dubious for v4l2-core. Remove it rather than
exporting it to the core as previously suggested in the TODO.
This drops imx-media-fim.c, the private control and event definitions in
include/linux/imx-media.h along with the include/media/imx.h wrapper, the
CSI integration, the capture event subscriptions, the driver-specific
UAPI documentation, and the remaining TODO entry.
Signed-off-by: Jiaqi Shi <shijiaqi_develop@163.com>
---
Documentation/admin-guide/media/imx.rst | 15 +-
.../userspace-api/media/drivers/imx-uapi.rst | 125 -----
.../userspace-api/media/drivers/index.rst | 1 -
MAINTAINERS | 2 -
drivers/staging/media/imx/Makefile | 2 +-
drivers/staging/media/imx/TODO | 3 -
drivers/staging/media/imx/imx-ic-prp.c | 1 -
drivers/staging/media/imx/imx-ic-prpencvf.c | 1 -
drivers/staging/media/imx/imx-media-capture.c | 17 -
drivers/staging/media/imx/imx-media-csi.c | 76 +---
drivers/staging/media/imx/imx-media-dev.c | 1 -
drivers/staging/media/imx/imx-media-fim.c | 430 ------------------
drivers/staging/media/imx/imx-media-vdic.c | 1 -
drivers/staging/media/imx/imx-media.h | 10 -
include/linux/imx-media.h | 25 -
include/media/imx.h | 11 -
16 files changed, 8 insertions(+), 713 deletions(-)
delete mode 100644 Documentation/userspace-api/media/drivers/imx-uapi.rst
delete mode 100644 drivers/staging/media/imx/TODO
delete mode 100644 drivers/staging/media/imx/imx-media-fim.c
delete mode 100644 include/linux/imx-media.h
delete mode 100644 include/media/imx.h
diff --git a/Documentation/admin-guide/media/imx.rst b/Documentation/admin-guide/media/imx.rst
index 812c6ac09ab8..b1998dcc4344 100644
--- a/Documentation/admin-guide/media/imx.rst
+++ b/Documentation/admin-guide/media/imx.rst
@@ -98,9 +98,6 @@ Some of the features of this driver include:
CSI. There is also support in the future for sending frames to the
VDIC from memory buffers via output/mem2mem devices.
-- Includes a Frame Interval Monitor (FIM) that can correct vertical sync
- problems with the ADV718x video decoders.
-
Topology
--------
@@ -220,8 +217,6 @@ or unqualified interlaced). The capture interface will enforce the same
field order as the source pad field order (interlaced-bt if source pad
is seq-bt, interlaced-tb if source pad is seq-tb).
-For events produced by ipuX_csiY, see ref:`imx_api_ipuX_csiY`.
-
Cropping in ipuX_csiY
---------------------
@@ -266,11 +261,6 @@ rate by half at the IDMAC output source pad:
media-ctl -V "'ipu1_csi0':0[fmt:UYVY2X8/640x480@1/60]"
media-ctl -V "'ipu1_csi0':2[fmt:UYVY2X8/640x480@1/30]"
-Frame Interval Monitor in ipuX_csiY
------------------------------------
-
-See ref:`imx_api_FIM`.
-
ipuX_vdic
---------
@@ -395,8 +385,7 @@ Usage Notes
-----------
Controls for pipeline entities are accessed through their subdev device
-nodes. For example, the FIM controls are available from the ipuX_csiY
-subdevs.
+nodes.
The following are specific usage notes for the Sabre* reference
boards:
@@ -690,8 +679,6 @@ File list
---------
drivers/staging/media/imx/
-include/media/imx.h
-include/linux/imx-media.h
References
----------
diff --git a/Documentation/userspace-api/media/drivers/imx-uapi.rst b/Documentation/userspace-api/media/drivers/imx-uapi.rst
deleted file mode 100644
index 8d47712dea9f..000000000000
--- a/Documentation/userspace-api/media/drivers/imx-uapi.rst
+++ /dev/null
@@ -1,125 +0,0 @@
-.. 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).
-
-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.
-
-- 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.
-
-- 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.
-
-
-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.
diff --git a/Documentation/userspace-api/media/drivers/index.rst b/Documentation/userspace-api/media/drivers/index.rst
index 8d2c489b8453..3f6b9a5ceefd 100644
--- a/Documentation/userspace-api/media/drivers/index.rst
+++ b/Documentation/userspace-api/media/drivers/index.rst
@@ -32,7 +32,6 @@ For more details see the file COPYING in the source distribution of Linux.
cx2341x-uapi
dcmipp
dw100
- imx-uapi
mali-c55
max2175
npcm-video
diff --git a/MAINTAINERS b/MAINTAINERS
index 926c9beb308a..5510bdda72e9 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -16787,8 +16787,6 @@ T: git git://linuxtv.org/media.git
F: Documentation/admin-guide/media/imx.rst
F: Documentation/devicetree/bindings/media/fsl,imx6-mipi-csi2.yaml
F: drivers/staging/media/imx/
-F: include/linux/imx-media.h
-F: include/media/imx.h
MEDIA DRIVERS FOR FREESCALE IMX7/8
M: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
diff --git a/drivers/staging/media/imx/Makefile b/drivers/staging/media/imx/Makefile
index 330e0825f506..fe2001a76f7a 100644
--- a/drivers/staging/media/imx/Makefile
+++ b/drivers/staging/media/imx/Makefile
@@ -6,7 +6,7 @@ imx6-media-objs := imx-media-dev.o imx-media-internal-sd.o \
imx-ic-common.o imx-ic-prp.o imx-ic-prpencvf.o imx-media-vdic.o \
imx-media-csc-scaler.o
-imx6-media-csi-objs := imx-media-csi.o imx-media-fim.o
+imx6-media-csi-objs := imx-media-csi.o
obj-$(CONFIG_VIDEO_IMX_MEDIA) += imx-media-common.o
obj-$(CONFIG_VIDEO_IMX_MEDIA) += imx6-media.o
diff --git a/drivers/staging/media/imx/TODO b/drivers/staging/media/imx/TODO
deleted file mode 100644
index 43cd030d4bbd..000000000000
--- a/drivers/staging/media/imx/TODO
+++ /dev/null
@@ -1,3 +0,0 @@
-
-- The Frame Interval Monitor could be exported to v4l2-core for
- general use.
diff --git a/drivers/staging/media/imx/imx-ic-prp.c b/drivers/staging/media/imx/imx-ic-prp.c
index b2c648149964..d2f54b42ebde 100644
--- a/drivers/staging/media/imx/imx-ic-prp.c
+++ b/drivers/staging/media/imx/imx-ic-prp.c
@@ -18,7 +18,6 @@
#include <media/v4l2-device.h>
#include <media/v4l2-ioctl.h>
#include <media/v4l2-subdev.h>
-#include <media/imx.h>
#include "imx-media.h"
#include "imx-ic.h"
diff --git a/drivers/staging/media/imx/imx-ic-prpencvf.c b/drivers/staging/media/imx/imx-ic-prpencvf.c
index 979d124c19ea..111b5f9fd447 100644
--- a/drivers/staging/media/imx/imx-ic-prpencvf.c
+++ b/drivers/staging/media/imx/imx-ic-prpencvf.c
@@ -19,7 +19,6 @@
#include <media/v4l2-ioctl.h>
#include <media/v4l2-mc.h>
#include <media/v4l2-subdev.h>
-#include <media/imx.h>
#include "imx-media.h"
#include "imx-ic.h"
diff --git a/drivers/staging/media/imx/imx-media-capture.c b/drivers/staging/media/imx/imx-media-capture.c
index 2bd3f336b36b..217e57532a8c 100644
--- a/drivers/staging/media/imx/imx-media-capture.c
+++ b/drivers/staging/media/imx/imx-media-capture.c
@@ -21,7 +21,6 @@
#include <media/v4l2-subdev.h>
#include <media/videobuf2-dma-contig.h>
#include <video/imx-ipu-v3.h>
-#include <media/imx.h>
#include "imx-media.h"
#define IMX_CAPTURE_NAME "imx-capture"
@@ -282,17 +281,6 @@ static int capture_g_selection(struct file *file, void *fh,
return 0;
}
-static int capture_subscribe_event(struct v4l2_fh *fh,
- const struct v4l2_event_subscription *sub)
-{
- switch (sub->type) {
- case V4L2_EVENT_IMX_FRAME_INTERVAL_ERROR:
- return v4l2_event_subscribe(fh, sub, 0, NULL);
- default:
- return -EINVAL;
- }
-}
-
static const struct v4l2_ioctl_ops capture_ioctl_ops = {
.vidioc_querycap = capture_querycap,
@@ -314,9 +302,6 @@ static const struct v4l2_ioctl_ops capture_ioctl_ops = {
.vidioc_expbuf = vb2_ioctl_expbuf,
.vidioc_streamon = vb2_ioctl_streamon,
.vidioc_streamoff = vb2_ioctl_streamoff,
-
- .vidioc_subscribe_event = capture_subscribe_event,
- .vidioc_unsubscribe_event = v4l2_event_unsubscribe,
};
/* -----------------------------------------------------------------------------
@@ -431,8 +416,6 @@ static int capture_legacy_subscribe_event(struct v4l2_fh *fh,
const struct v4l2_event_subscription *sub)
{
switch (sub->type) {
- case V4L2_EVENT_IMX_FRAME_INTERVAL_ERROR:
- return v4l2_event_subscribe(fh, sub, 0, NULL);
case V4L2_EVENT_SOURCE_CHANGE:
return v4l2_src_change_event_subscribe(fh, sub);
default:
diff --git a/drivers/staging/media/imx/imx-media-csi.c b/drivers/staging/media/imx/imx-media-csi.c
index 3392afc0f187..b8c4b70235e2 100644
--- a/drivers/staging/media/imx/imx-media-csi.c
+++ b/drivers/staging/media/imx/imx-media-csi.c
@@ -12,7 +12,6 @@
#include <linux/of_graph.h>
#include <linux/pinctrl/consumer.h>
#include <linux/platform_device.h>
-#include <media/v4l2-ctrls.h>
#include <media/v4l2-device.h>
#include <media/v4l2-event.h>
#include <media/v4l2-fwnode.h>
@@ -20,7 +19,6 @@
#include <media/v4l2-subdev.h>
#include <media/videobuf2-dma-contig.h>
#include <video/imx-ipu-v3.h>
-#include <media/imx.h>
#include "imx-media.h"
/*
@@ -62,7 +60,6 @@ struct csi_priv {
/* the video device at IDMAC output pad */
struct imx_media_video_dev *vdev;
- struct imx_media_fim *fim;
int csi_id;
int smfc_id;
@@ -102,8 +99,6 @@ struct csi_priv {
int eof_irq;
int nfb4eof_irq;
- struct v4l2_ctrl_handler ctrl_hdlr;
-
int stream_count; /* streaming counter */
u32 frame_sequence; /* frame sequence counter */
bool last_eof; /* waiting for last EOF at stream off */
@@ -308,10 +303,6 @@ static irqreturn_t csi_idmac_eof_interrupt(int irq, void *dev_id)
goto unlock;
}
- if (priv->fim)
- /* call frame interval monitor */
- imx_media_fim_eof_monitor(priv->fim, ktime_get());
-
csi_vb2_buf_done(priv);
/* select new IPU buf */
@@ -770,7 +761,7 @@ static void csi_set_src(struct csi_priv *priv,
static int csi_start(struct csi_priv *priv)
{
struct v4l2_mbus_config mbus_cfg = { .type = 0 };
- struct v4l2_fract *input_fi, *output_fi;
+ struct v4l2_fract *input_fi;
int ret;
ret = csi_get_upstream_mbus_config(priv, &mbus_cfg);
@@ -781,7 +772,6 @@ static int csi_start(struct csi_priv *priv)
}
input_fi = &priv->frame_interval[CSI_SINK_PAD];
- output_fi = &priv->frame_interval[priv->active_output_pad];
csi_set_src(priv, &mbus_cfg);
@@ -812,21 +802,14 @@ static int csi_start(struct csi_priv *priv)
if (ret)
goto idmac_stop;
- /* start the frame interval monitor */
- if (priv->fim && priv->dest == IPU_CSI_DEST_IDMAC)
- imx_media_fim_set_stream(priv->fim, output_fi, true);
-
ret = ipu_csi_enable(priv->csi);
if (ret) {
v4l2_err(&priv->sd, "CSI enable error: %d\n", ret);
- goto fim_off;
+ goto idmac_stop;
}
return 0;
-fim_off:
- if (priv->fim && priv->dest == IPU_CSI_DEST_IDMAC)
- imx_media_fim_set_stream(priv->fim, NULL, false);
idmac_stop:
if (priv->dest == IPU_CSI_DEST_IDMAC)
csi_idmac_stop(priv);
@@ -850,13 +833,8 @@ static void csi_stop(struct csi_priv *priv)
/* stop upstream */
v4l2_subdev_call(priv->src_sd, video, s_stream, 0);
- if (priv->dest == IPU_CSI_DEST_IDMAC) {
+ if (priv->dest == IPU_CSI_DEST_IDMAC)
csi_idmac_stop(priv);
-
- /* stop the frame interval monitor */
- if (priv->fim)
- imx_media_fim_set_stream(priv->fim, NULL, false);
- }
}
static const struct csi_skip_desc csi_skip[12] = {
@@ -1097,8 +1075,6 @@ static int csi_link_setup(struct media_entity *entity,
goto out;
}
} else {
- v4l2_ctrl_handler_free(&priv->ctrl_hdlr);
- v4l2_ctrl_handler_init(&priv->ctrl_hdlr, 0);
priv->sink = NULL;
/* do not apply IC burst alignment in csi_try_crop */
priv->active_output_pad = CSI_SRC_PAD_IDMAC;
@@ -1115,12 +1091,6 @@ static int csi_link_setup(struct media_entity *entity,
goto out;
}
- if (priv->fim) {
- ret = imx_media_fim_add_controls(priv->fim);
- if (ret)
- goto out;
- }
-
priv->dest = IPU_CSI_DEST_IDMAC;
} else {
if (!is_media_entity_v4l2_subdev(remote->entity)) {
@@ -1756,17 +1726,6 @@ static int csi_set_selection(struct v4l2_subdev *sd,
return ret;
}
-static int csi_subscribe_event(struct v4l2_subdev *sd, struct v4l2_fh *fh,
- struct v4l2_event_subscription *sub)
-{
- if (sub->type != V4L2_EVENT_IMX_FRAME_INTERVAL_ERROR)
- return -EINVAL;
- if (sub->id != 0)
- return -EINVAL;
-
- return v4l2_event_subscribe(fh, sub, 0, NULL);
-}
-
static int csi_registered(struct v4l2_subdev *sd)
{
struct csi_priv *priv = v4l2_get_subdevdata(sd);
@@ -1809,28 +1768,19 @@ static int csi_registered(struct v4l2_subdev *sd)
priv->compose.width = IMX_MEDIA_DEF_PIX_WIDTH;
priv->compose.height = IMX_MEDIA_DEF_PIX_HEIGHT;
- priv->fim = imx_media_fim_init(&priv->sd);
- if (IS_ERR(priv->fim)) {
- ret = PTR_ERR(priv->fim);
- goto put_csi;
- }
-
priv->vdev = imx_media_capture_device_init(priv->sd.dev, &priv->sd,
CSI_SRC_PAD_IDMAC, true, false);
if (IS_ERR(priv->vdev)) {
ret = PTR_ERR(priv->vdev);
- goto free_fim;
+ goto put_csi;
}
ret = imx_media_capture_device_register(priv->vdev, 0);
if (ret)
- goto free_fim;
+ goto put_csi;
return 0;
-free_fim:
- if (priv->fim)
- imx_media_fim_free(priv->fim);
put_csi:
ipu_csi_put(priv->csi);
return ret;
@@ -1842,9 +1792,6 @@ static void csi_unregistered(struct v4l2_subdev *sd)
imx_media_capture_device_unregister(priv->vdev);
- if (priv->fim)
- imx_media_fim_free(priv->fim);
-
if (priv->csi)
ipu_csi_put(priv->csi);
}
@@ -1877,11 +1824,6 @@ static const struct media_entity_operations csi_entity_ops = {
.get_fwnode_pad = csi_get_fwnode_pad,
};
-static const struct v4l2_subdev_core_ops csi_core_ops = {
- .subscribe_event = csi_subscribe_event,
- .unsubscribe_event = v4l2_event_subdev_unsubscribe,
-};
-
static const struct v4l2_subdev_video_ops csi_video_ops = {
.s_stream = csi_s_stream,
};
@@ -1900,7 +1842,6 @@ static const struct v4l2_subdev_pad_ops csi_pad_ops = {
};
static const struct v4l2_subdev_ops csi_subdev_ops = {
- .core = &csi_core_ops,
.video = &csi_video_ops,
.pad = &csi_pad_ops,
};
@@ -2011,7 +1952,7 @@ static int imx_csi_probe(struct platform_device *pdev)
priv->sd.dev = &pdev->dev;
priv->sd.fwnode = of_fwnode_handle(pdata->of_node);
priv->sd.owner = THIS_MODULE;
- priv->sd.flags = V4L2_SUBDEV_FL_HAS_DEVNODE | V4L2_SUBDEV_FL_HAS_EVENTS;
+ priv->sd.flags = V4L2_SUBDEV_FL_HAS_DEVNODE;
priv->sd.grp_id = priv->csi_id ?
IMX_MEDIA_GRP_ID_IPU_CSI1 : IMX_MEDIA_GRP_ID_IPU_CSI0;
imx_media_grp_id_to_sd_name(priv->sd.name, sizeof(priv->sd.name),
@@ -2028,9 +1969,6 @@ static int imx_csi_probe(struct platform_device *pdev)
mutex_init(&priv->lock);
- v4l2_ctrl_handler_init(&priv->ctrl_hdlr, 0);
- priv->sd.ctrl_handler = &priv->ctrl_hdlr;
-
/*
* The IPUv3 driver did not assign an of_node to this
* device. As a result, pinctrl does not automatically
@@ -2057,7 +1995,6 @@ static int imx_csi_probe(struct platform_device *pdev)
v4l2_async_nf_unregister(&priv->notifier);
v4l2_async_nf_cleanup(&priv->notifier);
free:
- v4l2_ctrl_handler_free(&priv->ctrl_hdlr);
mutex_destroy(&priv->lock);
return ret;
}
@@ -2067,7 +2004,6 @@ static void imx_csi_remove(struct platform_device *pdev)
struct v4l2_subdev *sd = platform_get_drvdata(pdev);
struct csi_priv *priv = sd_to_dev(sd);
- v4l2_ctrl_handler_free(&priv->ctrl_hdlr);
mutex_destroy(&priv->lock);
v4l2_async_nf_unregister(&priv->notifier);
v4l2_async_nf_cleanup(&priv->notifier);
diff --git a/drivers/staging/media/imx/imx-media-dev.c b/drivers/staging/media/imx/imx-media-dev.c
index a8f39319bd8a..287c9b97f9ad 100644
--- a/drivers/staging/media/imx/imx-media-dev.c
+++ b/drivers/staging/media/imx/imx-media-dev.c
@@ -8,7 +8,6 @@
#include <linux/platform_device.h>
#include <media/v4l2-async.h>
#include <media/v4l2-event.h>
-#include <media/imx.h>
#include "imx-media.h"
static inline struct imx_media_dev *notifier2dev(struct v4l2_async_notifier *n)
diff --git a/drivers/staging/media/imx/imx-media-fim.c b/drivers/staging/media/imx/imx-media-fim.c
deleted file mode 100644
index 9e9bacf9dcec..000000000000
--- a/drivers/staging/media/imx/imx-media-fim.c
+++ /dev/null
@@ -1,430 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-/*
- * Frame Interval Monitor.
- *
- * Copyright (c) 2016 Mentor Graphics Inc.
- */
-#include <linux/delay.h>
-#include <linux/irq.h>
-#include <linux/module.h>
-#include <linux/platform_device.h>
-#include <linux/slab.h>
-#include <linux/spinlock.h>
-#include <media/v4l2-ctrls.h>
-#include <media/v4l2-subdev.h>
-#include <media/imx.h>
-#include "imx-media.h"
-
-enum {
- FIM_CL_ENABLE = 0,
- FIM_CL_NUM,
- FIM_CL_TOLERANCE_MIN,
- FIM_CL_TOLERANCE_MAX,
- FIM_CL_NUM_SKIP,
- FIM_NUM_CONTROLS,
-};
-
-enum {
- FIM_CL_ICAP_EDGE = 0,
- FIM_CL_ICAP_CHANNEL,
- FIM_NUM_ICAP_CONTROLS,
-};
-
-#define FIM_CL_ENABLE_DEF 0 /* FIM disabled by default */
-#define FIM_CL_NUM_DEF 8 /* average 8 frames */
-#define FIM_CL_NUM_SKIP_DEF 2 /* skip 2 frames after restart */
-#define FIM_CL_TOLERANCE_MIN_DEF 50 /* usec */
-#define FIM_CL_TOLERANCE_MAX_DEF 0 /* no max tolerance (unbounded) */
-
-struct imx_media_fim {
- /* the owning subdev of this fim instance */
- struct v4l2_subdev *sd;
-
- /* FIM's control handler */
- struct v4l2_ctrl_handler ctrl_handler;
-
- /* control clusters */
- struct v4l2_ctrl *ctrl[FIM_NUM_CONTROLS];
- struct v4l2_ctrl *icap_ctrl[FIM_NUM_ICAP_CONTROLS];
-
- spinlock_t lock; /* protect control values */
-
- /* current control values */
- bool enabled;
- int num_avg;
- int num_skip;
- unsigned long tolerance_min; /* usec */
- unsigned long tolerance_max; /* usec */
- /* input capture method of measuring FI */
- int icap_channel;
- int icap_flags;
-
- int counter;
- ktime_t last_ts;
- unsigned long sum; /* usec */
- unsigned long nominal; /* usec */
-
- struct completion icap_first_event;
- bool stream_on;
-};
-
-static bool icap_enabled(struct imx_media_fim *fim)
-{
- return fim->icap_flags != IRQ_TYPE_NONE;
-}
-
-static void update_fim_nominal(struct imx_media_fim *fim,
- const struct v4l2_fract *fi)
-{
- if (fi->denominator == 0) {
- dev_dbg(fim->sd->dev, "no frame interval, FIM disabled\n");
- fim->enabled = false;
- return;
- }
-
- fim->nominal = DIV_ROUND_CLOSEST_ULL(1000000ULL * (u64)fi->numerator,
- fi->denominator);
-
- dev_dbg(fim->sd->dev, "FI=%lu usec\n", fim->nominal);
-}
-
-static void reset_fim(struct imx_media_fim *fim, bool curval)
-{
- struct v4l2_ctrl *icap_chan = fim->icap_ctrl[FIM_CL_ICAP_CHANNEL];
- struct v4l2_ctrl *icap_edge = fim->icap_ctrl[FIM_CL_ICAP_EDGE];
- struct v4l2_ctrl *en = fim->ctrl[FIM_CL_ENABLE];
- struct v4l2_ctrl *num = fim->ctrl[FIM_CL_NUM];
- struct v4l2_ctrl *skip = fim->ctrl[FIM_CL_NUM_SKIP];
- struct v4l2_ctrl *tol_min = fim->ctrl[FIM_CL_TOLERANCE_MIN];
- struct v4l2_ctrl *tol_max = fim->ctrl[FIM_CL_TOLERANCE_MAX];
-
- if (curval) {
- fim->enabled = en->cur.val;
- fim->icap_flags = icap_edge->cur.val;
- fim->icap_channel = icap_chan->cur.val;
- fim->num_avg = num->cur.val;
- fim->num_skip = skip->cur.val;
- fim->tolerance_min = tol_min->cur.val;
- fim->tolerance_max = tol_max->cur.val;
- } else {
- fim->enabled = en->val;
- fim->icap_flags = icap_edge->val;
- fim->icap_channel = icap_chan->val;
- fim->num_avg = num->val;
- fim->num_skip = skip->val;
- fim->tolerance_min = tol_min->val;
- fim->tolerance_max = tol_max->val;
- }
-
- /* disable tolerance range if max <= min */
- if (fim->tolerance_max <= fim->tolerance_min)
- fim->tolerance_max = 0;
-
- /* num_skip must be >= 1 if input capture not used */
- if (!icap_enabled(fim))
- fim->num_skip = max_t(int, fim->num_skip, 1);
-
- fim->counter = -fim->num_skip;
- fim->sum = 0;
-}
-
-static void send_fim_event(struct imx_media_fim *fim, unsigned long error)
-{
- static const struct v4l2_event ev = {
- .type = V4L2_EVENT_IMX_FRAME_INTERVAL_ERROR,
- };
-
- v4l2_subdev_notify_event(fim->sd, &ev);
-}
-
-/*
- * Monitor an averaged frame interval. If the average deviates too much
- * from the nominal frame rate, send the frame interval error event. The
- * frame intervals are averaged in order to quiet noise from
- * (presumably random) interrupt latency.
- */
-static void frame_interval_monitor(struct imx_media_fim *fim,
- ktime_t timestamp)
-{
- long long interval, error;
- unsigned long error_avg;
- bool send_event = false;
-
- if (!fim->enabled || ++fim->counter <= 0)
- goto out_update_ts;
-
- /* max error is less than l00µs, so use 32-bit division or fail */
- interval = ktime_to_ns(ktime_sub(timestamp, fim->last_ts));
- error = abs(interval - NSEC_PER_USEC * (u64)fim->nominal);
- if (error > U32_MAX)
- error = U32_MAX;
- else
- error = abs((u32)error / NSEC_PER_USEC);
-
- if (fim->tolerance_max && error >= fim->tolerance_max) {
- dev_dbg(fim->sd->dev,
- "FIM: %llu ignored, out of tolerance bounds\n",
- error);
- fim->counter--;
- goto out_update_ts;
- }
-
- fim->sum += error;
-
- if (fim->counter == fim->num_avg) {
- error_avg = DIV_ROUND_CLOSEST(fim->sum, fim->num_avg);
-
- if (error_avg > fim->tolerance_min)
- send_event = true;
-
- dev_dbg(fim->sd->dev, "FIM: error: %lu usec%s\n",
- error_avg, send_event ? " (!!!)" : "");
-
- fim->counter = 0;
- fim->sum = 0;
- }
-
-out_update_ts:
- fim->last_ts = timestamp;
- if (send_event)
- send_fim_event(fim, error_avg);
-}
-
-/*
- * In case we are monitoring the first frame interval after streamon
- * (when fim->num_skip = 0), we need a valid fim->last_ts before we
- * can begin. This only applies to the input capture method. It is not
- * possible to accurately measure the first FI after streamon using the
- * EOF method, so fim->num_skip minimum is set to 1 in that case, so this
- * function is a noop when the EOF method is used.
- */
-static void fim_acquire_first_ts(struct imx_media_fim *fim)
-{
- unsigned long ret;
-
- if (!fim->enabled || fim->num_skip > 0)
- return;
-
- ret = wait_for_completion_timeout(&fim->icap_first_event,
- msecs_to_jiffies(IMX_MEDIA_EOF_TIMEOUT));
- if (ret == 0)
- v4l2_warn(fim->sd, "wait first icap event timeout\n");
-}
-
-/* FIM Controls */
-static int fim_s_ctrl(struct v4l2_ctrl *ctrl)
-{
- struct imx_media_fim *fim = container_of(ctrl->handler,
- struct imx_media_fim,
- ctrl_handler);
- unsigned long flags;
- int ret = 0;
-
- spin_lock_irqsave(&fim->lock, flags);
-
- switch (ctrl->id) {
- case V4L2_CID_IMX_FIM_ENABLE:
- break;
- case V4L2_CID_IMX_FIM_ICAP_EDGE:
- if (fim->stream_on)
- ret = -EBUSY;
- break;
- default:
- ret = -EINVAL;
- }
-
- if (!ret)
- reset_fim(fim, false);
-
- spin_unlock_irqrestore(&fim->lock, flags);
- return ret;
-}
-
-static const struct v4l2_ctrl_ops fim_ctrl_ops = {
- .s_ctrl = fim_s_ctrl,
-};
-
-static const struct v4l2_ctrl_config fim_ctrl[] = {
- [FIM_CL_ENABLE] = {
- .ops = &fim_ctrl_ops,
- .id = V4L2_CID_IMX_FIM_ENABLE,
- .name = "FIM Enable",
- .type = V4L2_CTRL_TYPE_BOOLEAN,
- .def = FIM_CL_ENABLE_DEF,
- .min = 0,
- .max = 1,
- .step = 1,
- },
- [FIM_CL_NUM] = {
- .ops = &fim_ctrl_ops,
- .id = V4L2_CID_IMX_FIM_NUM,
- .name = "FIM Num Average",
- .type = V4L2_CTRL_TYPE_INTEGER,
- .def = FIM_CL_NUM_DEF,
- .min = 1, /* no averaging */
- .max = 64, /* average 64 frames */
- .step = 1,
- },
- [FIM_CL_TOLERANCE_MIN] = {
- .ops = &fim_ctrl_ops,
- .id = V4L2_CID_IMX_FIM_TOLERANCE_MIN,
- .name = "FIM Tolerance Min",
- .type = V4L2_CTRL_TYPE_INTEGER,
- .def = FIM_CL_TOLERANCE_MIN_DEF,
- .min = 2,
- .max = 200,
- .step = 1,
- },
- [FIM_CL_TOLERANCE_MAX] = {
- .ops = &fim_ctrl_ops,
- .id = V4L2_CID_IMX_FIM_TOLERANCE_MAX,
- .name = "FIM Tolerance Max",
- .type = V4L2_CTRL_TYPE_INTEGER,
- .def = FIM_CL_TOLERANCE_MAX_DEF,
- .min = 0,
- .max = 500,
- .step = 1,
- },
- [FIM_CL_NUM_SKIP] = {
- .ops = &fim_ctrl_ops,
- .id = V4L2_CID_IMX_FIM_NUM_SKIP,
- .name = "FIM Num Skip",
- .type = V4L2_CTRL_TYPE_INTEGER,
- .def = FIM_CL_NUM_SKIP_DEF,
- .min = 0, /* skip no frames */
- .max = 256, /* skip 256 frames */
- .step = 1,
- },
-};
-
-static const struct v4l2_ctrl_config fim_icap_ctrl[] = {
- [FIM_CL_ICAP_EDGE] = {
- .ops = &fim_ctrl_ops,
- .id = V4L2_CID_IMX_FIM_ICAP_EDGE,
- .name = "FIM Input Capture Edge",
- .type = V4L2_CTRL_TYPE_INTEGER,
- .def = IRQ_TYPE_NONE, /* input capture disabled by default */
- .min = IRQ_TYPE_NONE,
- .max = IRQ_TYPE_EDGE_BOTH,
- .step = 1,
- },
- [FIM_CL_ICAP_CHANNEL] = {
- .ops = &fim_ctrl_ops,
- .id = V4L2_CID_IMX_FIM_ICAP_CHANNEL,
- .name = "FIM Input Capture Channel",
- .type = V4L2_CTRL_TYPE_INTEGER,
- .def = 0,
- .min = 0,
- .max = 1,
- .step = 1,
- },
-};
-
-static int init_fim_controls(struct imx_media_fim *fim)
-{
- struct v4l2_ctrl_handler *hdlr = &fim->ctrl_handler;
- int i, ret;
-
- v4l2_ctrl_handler_init(hdlr, FIM_NUM_CONTROLS + FIM_NUM_ICAP_CONTROLS);
-
- for (i = 0; i < FIM_NUM_CONTROLS; i++)
- fim->ctrl[i] = v4l2_ctrl_new_custom(hdlr,
- &fim_ctrl[i],
- NULL);
- for (i = 0; i < FIM_NUM_ICAP_CONTROLS; i++)
- fim->icap_ctrl[i] = v4l2_ctrl_new_custom(hdlr,
- &fim_icap_ctrl[i],
- NULL);
- if (hdlr->error) {
- ret = hdlr->error;
- goto err_free;
- }
-
- v4l2_ctrl_cluster(FIM_NUM_CONTROLS, fim->ctrl);
- v4l2_ctrl_cluster(FIM_NUM_ICAP_CONTROLS, fim->icap_ctrl);
-
- return 0;
-err_free:
- v4l2_ctrl_handler_free(hdlr);
- return ret;
-}
-
-/*
- * Monitor frame intervals via EOF interrupt. This method is
- * subject to uncertainty errors introduced by interrupt latency.
- *
- * This is a noop if the Input Capture method is being used, since
- * the frame_interval_monitor() is called by the input capture event
- * callback handler in that case.
- */
-void imx_media_fim_eof_monitor(struct imx_media_fim *fim, ktime_t timestamp)
-{
- unsigned long flags;
-
- spin_lock_irqsave(&fim->lock, flags);
-
- if (!icap_enabled(fim))
- frame_interval_monitor(fim, timestamp);
-
- spin_unlock_irqrestore(&fim->lock, flags);
-}
-
-/* Called by the subdev in its s_stream callback */
-void imx_media_fim_set_stream(struct imx_media_fim *fim,
- const struct v4l2_fract *fi,
- bool on)
-{
- unsigned long flags;
-
- v4l2_ctrl_lock(fim->ctrl[FIM_CL_ENABLE]);
-
- if (fim->stream_on == on)
- goto out;
-
- if (on) {
- spin_lock_irqsave(&fim->lock, flags);
- reset_fim(fim, true);
- update_fim_nominal(fim, fi);
- spin_unlock_irqrestore(&fim->lock, flags);
-
- if (icap_enabled(fim))
- fim_acquire_first_ts(fim);
- }
-
- fim->stream_on = on;
-out:
- v4l2_ctrl_unlock(fim->ctrl[FIM_CL_ENABLE]);
-}
-
-int imx_media_fim_add_controls(struct imx_media_fim *fim)
-{
- /* add the FIM controls to the calling subdev ctrl handler */
- return v4l2_ctrl_add_handler(fim->sd->ctrl_handler,
- &fim->ctrl_handler, NULL, true);
-}
-
-/* Called by the subdev in its subdev registered callback */
-struct imx_media_fim *imx_media_fim_init(struct v4l2_subdev *sd)
-{
- struct imx_media_fim *fim;
- int ret;
-
- fim = devm_kzalloc(sd->dev, sizeof(*fim), GFP_KERNEL);
- if (!fim)
- return ERR_PTR(-ENOMEM);
-
- fim->sd = sd;
-
- spin_lock_init(&fim->lock);
-
- ret = init_fim_controls(fim);
- if (ret)
- return ERR_PTR(ret);
-
- return fim;
-}
-
-void imx_media_fim_free(struct imx_media_fim *fim)
-{
- v4l2_ctrl_handler_free(&fim->ctrl_handler);
-}
diff --git a/drivers/staging/media/imx/imx-media-vdic.c b/drivers/staging/media/imx/imx-media-vdic.c
index 8dcbb6fe7649..a4f70a9e5ebc 100644
--- a/drivers/staging/media/imx/imx-media-vdic.c
+++ b/drivers/staging/media/imx/imx-media-vdic.c
@@ -9,7 +9,6 @@
#include <media/v4l2-ioctl.h>
#include <media/v4l2-mc.h>
#include <media/v4l2-subdev.h>
-#include <media/imx.h>
#include "imx-media.h"
/*
diff --git a/drivers/staging/media/imx/imx-media.h b/drivers/staging/media/imx/imx-media.h
index c09546fcf080..c641ba6757a3 100644
--- a/drivers/staging/media/imx/imx-media.h
+++ b/drivers/staging/media/imx/imx-media.h
@@ -234,16 +234,6 @@ struct imx_media_dev *imx_media_dev_init(struct device *dev,
int imx_media_dev_notifier_register(struct imx_media_dev *imxmd,
const struct v4l2_async_notifier_operations *ops);
-/* imx-media-fim.c */
-struct imx_media_fim;
-void imx_media_fim_eof_monitor(struct imx_media_fim *fim, ktime_t timestamp);
-void imx_media_fim_set_stream(struct imx_media_fim *fim,
- const struct v4l2_fract *frame_interval,
- bool on);
-int imx_media_fim_add_controls(struct imx_media_fim *fim);
-struct imx_media_fim *imx_media_fim_init(struct v4l2_subdev *sd);
-void imx_media_fim_free(struct imx_media_fim *fim);
-
/* imx-media-internal-sd.c */
int imx_media_register_ipu_internal_subdevs(struct imx_media_dev *imxmd,
struct v4l2_subdev *csi);
diff --git a/include/linux/imx-media.h b/include/linux/imx-media.h
deleted file mode 100644
index e017e1779118..000000000000
--- a/include/linux/imx-media.h
+++ /dev/null
@@ -1,25 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-/*
- * Copyright (c) 2014-2017 Mentor Graphics Inc.
- */
-
-#ifndef __LINUX_IMX_MEDIA_H__
-#define __LINUX_IMX_MEDIA_H__
-
-/*
- * events from the subdevs
- */
-#define V4L2_EVENT_IMX_CLASS V4L2_EVENT_PRIVATE_START
-#define V4L2_EVENT_IMX_FRAME_INTERVAL_ERROR (V4L2_EVENT_IMX_CLASS + 1)
-
-enum imx_ctrl_id {
- V4L2_CID_IMX_FIM_ENABLE = (V4L2_CID_USER_IMX_BASE + 0),
- V4L2_CID_IMX_FIM_NUM,
- V4L2_CID_IMX_FIM_TOLERANCE_MIN,
- V4L2_CID_IMX_FIM_TOLERANCE_MAX,
- V4L2_CID_IMX_FIM_NUM_SKIP,
- V4L2_CID_IMX_FIM_ICAP_EDGE,
- V4L2_CID_IMX_FIM_ICAP_CHANNEL,
-};
-
-#endif
diff --git a/include/media/imx.h b/include/media/imx.h
deleted file mode 100644
index 5f14acdd7f4b..000000000000
--- a/include/media/imx.h
+++ /dev/null
@@ -1,11 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-/*
- * Copyright (c) 2014-2017 Mentor Graphics Inc.
- */
-
-#ifndef __MEDIA_IMX_H__
-#define __MEDIA_IMX_H__
-
-#include <linux/imx-media.h>
-
-#endif
--
2.53.0
prev parent reply other threads:[~2026-12-01 15:27 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-01 15:26 [PATCH v8 0/2] media: imx: staging cleanup and remove frame interval monitor Jiaqi Shi
2026-12-01 15:26 ` [PATCH v8 1/2] media: imx: remove legacy video node control and format handling Jiaqi Shi
2026-12-01 16:21 ` Frank Li
2026-12-01 15:26 ` Jiaqi Shi [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261201152647.847238-3-shijiaqi_develop@163.com \
--to=shijiaqi_develop@163.com \
--cc=Frank.Li@nxp.com \
--cc=festevam@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=imx@lists.linux.dev \
--cc=kernel@pengutronix.de \
--cc=linux-media@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=mchehab@kernel.org \
--cc=p.zabel@pengutronix.de \
--cc=slongerbeam@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox