[PATCH v1 04/13] media: tegra-video: vi: Drop subdevice passthrough and input ioctls

From: Svyatoslav Ryhel

Date: Wed Nov 25 2026 - 06:08:48 EST


Drop V4L2 video device ioctl callbacks in tegra_channel_ioctl_ops that
simply proxy stream parameters, frame intervals, selection, EDID, or DV
timings to the remote source subdevice, along with the single-input
enumeration and selection stubs, as part of moving the driver to a
media-controller pipeline model.

Signed-off-by: Svyatoslav Ryhel <clamor95@xxxxxxxxx>
---
.../media/platform/nvidia/tegra-video/vi.c | 299 ------------------
1 file changed, 299 deletions(-)

diff --git a/drivers/media/platform/nvidia/tegra-video/vi.c b/drivers/media/platform/nvidia/tegra-video/vi.c
index 4753ca89666ae..376f53f44b90d 100644
--- a/drivers/media/platform/nvidia/tegra-video/vi.c
+++ b/drivers/media/platform/nvidia/tegra-video/vi.c
@@ -308,26 +308,6 @@ static int tegra_channel_querycap(struct file *file, void *fh,
return 0;
}

-static int tegra_channel_g_parm(struct file *file, void *fh,
- struct v4l2_streamparm *a)
-{
- struct tegra_vi_channel *chan = video_drvdata(file);
- struct v4l2_subdev *subdev;
-
- subdev = tegra_channel_get_remote_source_subdev(chan);
- return v4l2_g_parm_cap(&chan->video, subdev, a);
-}
-
-static int tegra_channel_s_parm(struct file *file, void *fh,
- struct v4l2_streamparm *a)
-{
- struct tegra_vi_channel *chan = video_drvdata(file);
- struct v4l2_subdev *subdev;
-
- subdev = tegra_channel_get_remote_source_subdev(chan);
- return v4l2_s_parm_cap(&chan->video, subdev, a);
-}
-
static int tegra_channel_enum_framesizes(struct file *file, void *fh,
struct v4l2_frmsizeenum *sizes)
{
@@ -358,38 +338,6 @@ static int tegra_channel_enum_framesizes(struct file *file, void *fh,
return 0;
}

-static int tegra_channel_enum_frameintervals(struct file *file, void *fh,
- struct v4l2_frmivalenum *ivals)
-{
- int ret;
- struct tegra_vi_channel *chan = video_drvdata(file);
- struct v4l2_subdev *subdev;
- const struct tegra_video_format *fmtinfo;
- struct v4l2_subdev_frame_interval_enum fie = {
- .index = ivals->index,
- .width = ivals->width,
- .height = ivals->height,
- .which = V4L2_SUBDEV_FORMAT_ACTIVE,
- };
-
- fmtinfo = tegra_get_format_by_fourcc(chan->vi, ivals->pixel_format);
- if (!fmtinfo)
- return -EINVAL;
-
- fie.code = fmtinfo->code;
-
- subdev = tegra_channel_get_remote_source_subdev(chan);
- ret = v4l2_subdev_call(subdev, pad, enum_frame_interval, NULL, &fie);
- if (ret)
- return ret;
-
- ivals->type = V4L2_FRMIVAL_TYPE_DISCRETE;
- ivals->discrete.numerator = fie.interval.numerator;
- ivals->discrete.denominator = fie.interval.denominator;
-
- return 0;
-}
-
static int tegra_channel_enum_format(struct file *file, void *fh,
struct v4l2_fmtdesc *f)
{
@@ -601,203 +549,6 @@ tegra_channel_subscribe_event(struct v4l2_fh *fh,
return v4l2_ctrl_subscribe_event(fh, sub);
}

-static int tegra_channel_g_selection(struct file *file, void *priv,
- struct v4l2_selection *sel)
-{
- struct tegra_vi_channel *chan = video_drvdata(file);
- struct v4l2_subdev *subdev;
- struct v4l2_subdev_format fmt = {
- .which = V4L2_SUBDEV_FORMAT_ACTIVE,
- };
- struct v4l2_subdev_selection sdsel = {
- .which = V4L2_SUBDEV_FORMAT_ACTIVE,
- .target = sel->target,
- };
- int ret;
-
- subdev = tegra_channel_get_remote_source_subdev(chan);
- if (!v4l2_subdev_has_op(subdev, pad, get_selection))
- return -ENOTTY;
-
- if (sel->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
- return -EINVAL;
- /*
- * Try the get selection operation and fallback to get format if not
- * implemented.
- */
- ret = v4l2_subdev_call(subdev, pad, get_selection, NULL, NULL, &sdsel);
- if (!ret)
- sel->r = sdsel.r;
- if (ret != -ENOIOCTLCMD)
- return ret;
-
- ret = v4l2_subdev_call(subdev, pad, get_fmt, NULL, &fmt);
- if (ret < 0)
- return ret;
-
- sel->r.left = 0;
- sel->r.top = 0;
- sel->r.width = fmt.format.width;
- sel->r.height = fmt.format.height;
-
- return 0;
-}
-
-static int tegra_channel_s_selection(struct file *file, void *fh,
- struct v4l2_selection *sel)
-{
- struct tegra_vi_channel *chan = video_drvdata(file);
- struct v4l2_subdev *subdev;
- int ret;
- struct v4l2_subdev_selection sdsel = {
- .which = V4L2_SUBDEV_FORMAT_ACTIVE,
- .target = sel->target,
- .flags = sel->flags,
- .r = sel->r,
- };
-
- subdev = tegra_channel_get_remote_source_subdev(chan);
- if (!v4l2_subdev_has_op(subdev, pad, set_selection))
- return -ENOTTY;
-
- if (sel->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
- return -EINVAL;
-
- if (vb2_is_busy(&chan->queue))
- return -EBUSY;
-
- ret = v4l2_subdev_call(subdev, pad, set_selection, NULL, NULL, &sdsel);
- if (!ret) {
- sel->r = sdsel.r;
- /*
- * Subdev active format resolution may have changed during
- * set selection operation. So, update channel format to
- * the sub-device active format.
- */
- return tegra_channel_set_subdev_active_fmt(chan);
- }
-
- return ret;
-}
-
-static int tegra_channel_g_edid(struct file *file, void *fh,
- struct v4l2_edid *edid)
-{
- struct tegra_vi_channel *chan = video_drvdata(file);
- struct v4l2_subdev *subdev;
-
- subdev = tegra_channel_get_remote_source_subdev(chan);
- if (!v4l2_subdev_has_op(subdev, pad, get_edid))
- return -ENOTTY;
-
- return v4l2_subdev_call(subdev, pad, get_edid, edid);
-}
-
-static int tegra_channel_s_edid(struct file *file, void *fh,
- struct v4l2_edid *edid)
-{
- struct tegra_vi_channel *chan = video_drvdata(file);
- struct v4l2_subdev *subdev;
-
- subdev = tegra_channel_get_remote_source_subdev(chan);
- if (!v4l2_subdev_has_op(subdev, pad, set_edid))
- return -ENOTTY;
-
- return v4l2_subdev_call(subdev, pad, set_edid, edid);
-}
-
-static int tegra_channel_g_dv_timings(struct file *file, void *fh,
- struct v4l2_dv_timings *timings)
-{
- struct tegra_vi_channel *chan = video_drvdata(file);
- struct v4l2_subdev *subdev;
-
- subdev = tegra_channel_get_remote_source_subdev(chan);
- if (!v4l2_subdev_has_op(subdev, pad, g_dv_timings))
- return -ENOTTY;
-
- return v4l2_device_call_until_err(chan->video.v4l2_dev, 0,
- pad, g_dv_timings, 0, timings);
-}
-
-static int tegra_channel_s_dv_timings(struct file *file, void *fh,
- struct v4l2_dv_timings *timings)
-{
- struct tegra_vi_channel *chan = video_drvdata(file);
- struct v4l2_subdev *subdev;
- struct v4l2_bt_timings *bt = &timings->bt;
- struct v4l2_dv_timings curr_timings;
- int ret;
-
- subdev = tegra_channel_get_remote_source_subdev(chan);
- if (!v4l2_subdev_has_op(subdev, pad, s_dv_timings))
- return -ENOTTY;
-
- ret = tegra_channel_g_dv_timings(file, fh, &curr_timings);
- if (ret)
- return ret;
-
- if (v4l2_match_dv_timings(timings, &curr_timings, 0, false))
- return 0;
-
- if (vb2_is_busy(&chan->queue))
- return -EBUSY;
-
- ret = v4l2_device_call_until_err(chan->video.v4l2_dev, 0,
- pad, s_dv_timings, 0, timings);
- if (ret)
- return ret;
-
- chan->format.width = bt->width;
- chan->format.height = bt->height;
- chan->format.bytesperline = bt->width * chan->fmtinfo->bpp;
- chan->format.sizeimage = chan->format.bytesperline * bt->height;
- chan->vi->ops->vi_fmt_align(&chan->format, chan->fmtinfo->bpp);
- tegra_channel_update_gangports(chan);
-
- return 0;
-}
-
-static int tegra_channel_query_dv_timings(struct file *file, void *fh,
- struct v4l2_dv_timings *timings)
-{
- struct tegra_vi_channel *chan = video_drvdata(file);
- struct v4l2_subdev *subdev;
-
- subdev = tegra_channel_get_remote_source_subdev(chan);
- if (!v4l2_subdev_has_op(subdev, pad, query_dv_timings))
- return -ENOTTY;
-
- return v4l2_device_call_until_err(chan->video.v4l2_dev, 0,
- pad, query_dv_timings, 0, timings);
-}
-
-static int tegra_channel_enum_dv_timings(struct file *file, void *fh,
- struct v4l2_enum_dv_timings *timings)
-{
- struct tegra_vi_channel *chan = video_drvdata(file);
- struct v4l2_subdev *subdev;
-
- subdev = tegra_channel_get_remote_source_subdev(chan);
- if (!v4l2_subdev_has_op(subdev, pad, enum_dv_timings))
- return -ENOTTY;
-
- return v4l2_subdev_call(subdev, pad, enum_dv_timings, timings);
-}
-
-static int tegra_channel_dv_timings_cap(struct file *file, void *fh,
- struct v4l2_dv_timings_cap *cap)
-{
- struct tegra_vi_channel *chan = video_drvdata(file);
- struct v4l2_subdev *subdev;
-
- subdev = tegra_channel_get_remote_source_subdev(chan);
- if (!v4l2_subdev_has_op(subdev, pad, dv_timings_cap))
- return -ENOTTY;
-
- return v4l2_subdev_call(subdev, pad, dv_timings_cap, cap);
-}
-
static int tegra_channel_log_status(struct file *file, void *fh)
{
struct tegra_vi_channel *chan = video_drvdata(file);
@@ -807,54 +558,13 @@ static int tegra_channel_log_status(struct file *file, void *fh)
return 0;
}

-static int tegra_channel_enum_input(struct file *file, void *fh,
- struct v4l2_input *inp)
-{
- struct tegra_vi_channel *chan = video_drvdata(file);
- struct v4l2_subdev *subdev;
-
- if (inp->index)
- return -EINVAL;
-
- inp->type = V4L2_INPUT_TYPE_CAMERA;
- subdev = tegra_channel_get_remote_source_subdev(chan);
- strscpy(inp->name, subdev->name, sizeof(inp->name));
- if (v4l2_subdev_has_op(subdev, pad, dv_timings_cap))
- inp->capabilities = V4L2_IN_CAP_DV_TIMINGS;
-
- return 0;
-}
-
-static int tegra_channel_g_input(struct file *file, void *priv,
- unsigned int *i)
-{
- *i = 0;
-
- return 0;
-}
-
-static int tegra_channel_s_input(struct file *file, void *priv,
- unsigned int input)
-{
- if (input > 0)
- return -EINVAL;
-
- return 0;
-}
-
static const struct v4l2_ioctl_ops tegra_channel_ioctl_ops = {
.vidioc_querycap = tegra_channel_querycap,
- .vidioc_g_parm = tegra_channel_g_parm,
- .vidioc_s_parm = tegra_channel_s_parm,
.vidioc_enum_framesizes = tegra_channel_enum_framesizes,
- .vidioc_enum_frameintervals = tegra_channel_enum_frameintervals,
.vidioc_enum_fmt_vid_cap = tegra_channel_enum_format,
.vidioc_g_fmt_vid_cap = tegra_channel_get_format,
.vidioc_s_fmt_vid_cap = tegra_channel_set_format,
.vidioc_try_fmt_vid_cap = tegra_channel_try_format,
- .vidioc_enum_input = tegra_channel_enum_input,
- .vidioc_g_input = tegra_channel_g_input,
- .vidioc_s_input = tegra_channel_s_input,
.vidioc_reqbufs = vb2_ioctl_reqbufs,
.vidioc_prepare_buf = vb2_ioctl_prepare_buf,
.vidioc_querybuf = vb2_ioctl_querybuf,
@@ -866,15 +576,6 @@ static const struct v4l2_ioctl_ops tegra_channel_ioctl_ops = {
.vidioc_streamoff = vb2_ioctl_streamoff,
.vidioc_subscribe_event = tegra_channel_subscribe_event,
.vidioc_unsubscribe_event = v4l2_event_unsubscribe,
- .vidioc_g_selection = tegra_channel_g_selection,
- .vidioc_s_selection = tegra_channel_s_selection,
- .vidioc_g_edid = tegra_channel_g_edid,
- .vidioc_s_edid = tegra_channel_s_edid,
- .vidioc_g_dv_timings = tegra_channel_g_dv_timings,
- .vidioc_s_dv_timings = tegra_channel_s_dv_timings,
- .vidioc_query_dv_timings = tegra_channel_query_dv_timings,
- .vidioc_enum_dv_timings = tegra_channel_enum_dv_timings,
- .vidioc_dv_timings_cap = tegra_channel_dv_timings_cap,
.vidioc_log_status = tegra_channel_log_status,
};

--
2.53.0