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 v3 1/2] media: imx: remove legacy video node control and format handling
Date: Sat, 21 Nov 2026 18:21:22 +0000 [thread overview]
Message-ID: <sashiko-outbox-227243@kernel.org> (raw)
In-Reply-To: <20261121180044.424315-2-shijiaqi_develop@163.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] media: imx: capture_validate_field() mutates vdev.fmt.field
on stream start
- [Medium] media: imx: callers of imx_media_capture_device_init() still
pass legacy_api
--
commit f4224bc45a1438de57dbc43b915f511c93024a3e
Author: Jiaqi Shi <shijiaqi_develop@163.com>
media: imx: remove legacy video node control and format handling
This commit removes subdev control inheritance from capture video nodes and
switches capture format handling and initialization to source-independent
format ioctls while keeping stream-time format validation.
> diff --git a/drivers/staging/media/imx/imx-media-capture.c b/drivers/staging/media/imx/imx-media-capture.c
> index 9216a221b72f4..2e1cafc5f433e 100644
> --- a/drivers/staging/media/imx/imx-media-capture.c
> +++ b/drivers/staging/media/imx/imx-media-capture.c
[ ... ]
> @@ -566,10 +473,10 @@ static const struct v4l2_ioctl_ops capture_legacy_ioctl_ops = {
> .vidioc_enum_framesizes = capture_legacy_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 the callers of imx_media_capture_device_init() stop setting
legacy_api to true now that video node format handling is decoupled from
the source subdev?
Both in-tree callers (prp_registered() and csi_registered()) still pass
legacy_api = true, which leaves V4L2_CAP_IO_MC unset on every capture device
(so v4l_enum_fmt() zeroes f->mbus_code before calling
capture_enum_fmt_vid_cap()) and leaves capture_ioctl_ops,
capture_enum_framesizes(), and capture_subscribe_event() unused.
In addition, pairing capture_enum_fmt_vid_cap() with
capture_legacy_enum_framesizes() breaks VIDIOC_ENUM_FRAMESIZES on the IC
capture nodes: capture_enum_fmt_vid_cap() enumerates all non-IPU formats in
pixel_formats[], and capture_legacy_enum_framesizes() forwards their media
bus code (or 0 for in-memory-only formats) to prp_enum_frame_size(), which
rejects any non-IPU media bus code with -EINVAL.
> @@ -672,6 +579,44 @@ static void capture_buf_queue(struct vb2_buffer *vb)
> spin_unlock_irqrestore(&priv->q_lock, flags);
> }
>
> +static int capture_validate_field(struct capture_priv *priv,
> + const struct v4l2_mbus_framefmt *src)
> +{
> + struct v4l2_pix_format *pix = &priv->vdev.fmt;
> +
> + switch (pix->field) {
> + case V4L2_FIELD_INTERLACED:
> + switch (src->field) {
> + case V4L2_FIELD_SEQ_TB:
> + pix->field = V4L2_FIELD_INTERLACED_TB;
> + return 0;
> + case V4L2_FIELD_SEQ_BT:
> + pix->field = V4L2_FIELD_INTERLACED_BT;
> + return 0;
> + case V4L2_FIELD_INTERLACED:
> + return 0;
> + case V4L2_FIELD_INTERLACED_TB:
> + case V4L2_FIELD_INTERLACED_BT:
> + pix->field = src->field;
> + return 0;
> + default:
> + return -EPIPE;
> + }
[Severity: Medium]
Should capture_validate_field() avoid overwriting priv->vdev.fmt.field
during VIDIOC_STREAMON?
When userspace configures V4L2_FIELD_INTERLACED via VIDIOC_S_FMT,
capture_start_streaming() -> capture_validate_fmt() ->
capture_validate_field() mutates priv->vdev.fmt.field in place to
V4L2_FIELD_INTERLACED_TB or V4L2_FIELD_INTERLACED_BT. This changes the
format reported by VIDIOC_G_FMT (even if imx_media_pipeline_set_stream()
subsequently fails), and if the upstream subdev field order is later
switched between top-bottom and bottom-top without another VIDIOC_S_FMT, a
subsequent VIDIOC_STREAMON will validate against the overwritten field order
and fail with -EPIPE.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261121180044.424315-1-shijiaqi_develop@163.com?part=1
next prev parent reply other threads:[~2026-11-21 18:21 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-21 18:00 [PATCH v3 0/2] media: imx: staging cleanup and FIM export to v4l2-core Jiaqi Shi
2026-11-21 18:00 ` [PATCH v3 1/2] media: imx: remove legacy video node control and format handling Jiaqi Shi
2026-11-21 18:21 ` sashiko-bot [this message]
2026-11-21 18:00 ` [PATCH v3 2/2] media: v4l2-core: add frame interval monitor helper Jiaqi Shi
2026-11-21 18:16 ` sashiko-bot
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-227243@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