Linux kernel and device drivers for NXP i.MX platforms
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Jiaqi Shi" <shijiaqi_develop@163.com>, imx@lists.linux.dev
Cc: Frank.Li@kernel.org, media-ci@linuxtv.org
Subject: Re: [PATCH v5 1/2] media: imx: remove legacy video node control and format handling
Date: Sun, 22 Nov 2026 01:52:51 +0000	[thread overview]
Message-ID: <sashiko-outbox-227635@kernel.org> (raw)
In-Reply-To: <20261122012905.436504-2-shijiaqi_develop@163.com>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] media: imx: capture_enum_framesizes() allows Bayer formats on
  IC nodes
- [Medium] media: imx: callers of imx_media_capture_device_init() still
  pass legacy_api
--

commit f8bbc2bd5d6e37d94f858bc1efd4d148595db2f1
Author: Jiaqi Shi <shijiaqi_develop@163.com>

media: imx: remove legacy video node control and format handling

This commit removes subdevice control inheritance on capture video nodes
and switches capture format ioctls and initial format setup to be
independent of the connected source subdevice's active format.

> diff --git a/drivers/staging/media/imx/imx-media-capture.c b/drivers/staging/media/imx/imx-media-capture.c
> index 9216a221b72f4..0003c20bb610d 100644
> --- a/drivers/staging/media/imx/imx-media-capture.c
> +++ b/drivers/staging/media/imx/imx-media-capture.c
[ ... ]
> @@ -93,8 +93,12 @@ static int capture_querycap(struct file *file, void *fh,
>  static int capture_enum_fmt_vid_cap(struct file *file, void *fh,
>  				    struct v4l2_fmtdesc *f)
>  {
> +	struct capture_priv *priv = video_drvdata(file);
> +	enum imx_pixfmt_sel fmt_sel = priv->ic_route ? PIXFMT_SEL_YUV_RGB :
> +							 PIXFMT_SEL_ANY;
> +
>  	return imx_media_enum_pixel_formats(&f->pixelformat, f->index,
> -					    PIXFMT_SEL_ANY, f->mbus_code);
> +					    fmt_sel, f->mbus_code);
>  }
[ ... ]
> @@ -563,13 +437,13 @@ static int capture_legacy_subscribe_event(struct v4l2_fh *fh,
>  static const struct v4l2_ioctl_ops capture_legacy_ioctl_ops = {
>  	.vidioc_querycap		= capture_querycap,
>  
> -	.vidioc_enum_framesizes		= capture_legacy_enum_framesizes,
> +	.vidioc_enum_framesizes		= capture_enum_framesizes,
>  	.vidioc_enum_frameintervals	= capture_legacy_enum_frameintervals,
>  
> -	.vidioc_enum_fmt_vid_cap	= capture_legacy_enum_fmt_vid_cap,
> +	.vidioc_enum_fmt_vid_cap	= capture_enum_fmt_vid_cap,
>  	.vidioc_g_fmt_vid_cap		= capture_g_fmt_vid_cap,
> -	.vidioc_try_fmt_vid_cap		= capture_legacy_try_fmt_vid_cap,
> -	.vidioc_s_fmt_vid_cap		= capture_legacy_s_fmt_vid_cap,
> +	.vidioc_try_fmt_vid_cap		= capture_try_fmt_vid_cap,
> +	.vidioc_s_fmt_vid_cap		= capture_s_fmt_vid_cap,

[Severity: Medium]
Should capture_enum_framesizes() and capture_legacy_enum_frameintervals()
also filter pixel formats using priv->ic_route ? PIXFMT_SEL_YUV_RGB :
PIXFMT_SEL_ANY?

capture_enum_fmt_vid_cap() and __capture_try_fmt() restrict IC capture
nodes (ipuX_ic_prpenc and ipuX_ic_prpvf) to PIXFMT_SEL_YUV_RGB, but
capture_enum_framesizes() and capture_legacy_enum_frameintervals() still
look up the format with PIXFMT_SEL_ANY:

drivers/staging/media/imx/imx-media-capture.c:capture_enum_framesizes() {
	if (fsize->index > 0)
		return -EINVAL;

	cc = imx_media_find_pixel_format(fsize->pixel_format, PIXFMT_SEL_ANY);
	if (!cc)
		return -EINVAL;
    ...
}

As a result, VIDIOC_ENUM_FRAMESIZES on IC capture nodes now succeeds for
Bayer and greyscale formats that VIDIOC_ENUM_FMT does not enumerate and
VIDIOC_TRY_FMT rejects.

[ ... ]

> @@ -960,7 +863,7 @@ EXPORT_SYMBOL_GPL(imx_media_capture_device_unregister);
>  
>  struct imx_media_video_dev *
>  imx_media_capture_device_init(struct device *dev, struct v4l2_subdev *src_sd,
> -			      int pad, bool legacy_api)
> +			      int pad, bool legacy_api, bool ic_route)
>  {
>  	struct capture_priv *priv;
>  	struct video_device *vfd;
> @@ -974,7 +877,7 @@ imx_media_capture_device_init(struct device *dev, struct v4l2_subdev *src_sd,
>  	priv->src_sd = src_sd;
>  	priv->src_sd_pad = pad;
>  	priv->dev = dev;
> -	priv->legacy_api = legacy_api;
> +	priv->ic_route = ic_route;

[Severity: Medium]
Should prp_registered() and csi_registered() stop passing legacy_api = true
to imx_media_capture_device_init(), or should legacy_api be removed?

Both callers still pass true, so imx_media_capture_device_init() never sets
V4L2_CAP_IO_MC in vfd->device_caps and always selects
capture_legacy_ioctl_ops, leaving capture_ioctl_ops unreachable.  Without
V4L2_CAP_IO_MC, v4l_enum_fmt() in v4l2-core clears f->mbus_code before
calling capture_enum_fmt_vid_cap(), which disables mbus_code format
filtering, and capture_legacy_enum_frameintervals() remains coupled to the
connected subdev's active format (or fails with -ENOIOCTLCMD on IC capture
nodes because prp_pad_ops does not implement enum_frame_interval).

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261122012905.436504-1-shijiaqi_develop@163.com?part=1

  reply	other threads:[~2026-11-22  1:52 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-22  1:29 [PATCH v5 0/2] media: imx: staging cleanup and FIM export to v4l2-core Jiaqi Shi
2026-11-22  1:29 ` [PATCH v5 1/2] media: imx: remove legacy video node control and format handling Jiaqi Shi
2026-11-22  1:52   ` sashiko-bot [this message]
2026-11-22  1:29 ` [PATCH v5 2/2] media: v4l2-core: add frame interval monitor helper Jiaqi Shi

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=sashiko-outbox-227635@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Frank.Li@kernel.org \
    --cc=imx@lists.linux.dev \
    --cc=media-ci@linuxtv.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=shijiaqi_develop@163.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