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 1/3] media: imx: remove legacy video node control and format handling
Date: Sat, 21 Nov 2026 14:40:51 +0000 [thread overview]
Message-ID: <sashiko-outbox-227100@kernel.org> (raw)
In-Reply-To: <20261121141412.319802-2-shijiaqi_develop@163.com>
Thank you for your contribution! Sashiko AI review found 5 potential
issues to consider:
- [High] media: imx: unresolved default colorimetry and field in
capture_init_format()
- [High] media: imx: insufficient pixel format validation in
capture_validate_fmt()
- [High] media: imx: unclamped dimensions in __capture_try_fmt() cause
divide-by-zero
- [Medium] media: imx: callers of imx_media_capture_device_init() still
set legacy_api
- [Low] media: imx: outdated v4l2-ctl format examples in
Documentation/admin-guide
--
commit 91db31570bbb5c6e57f4f438a93a25e73be6926a
Author: Jiaqi Shi <shijiaqi_develop@163.com>
media: imx: remove legacy video node control and format handling
This commit removes V4L2 control inheritance from pipeline subdevices to
capture video nodes and switches capture video nodes to source-independent
format initialization and format ioctls.
> diff --git a/Documentation/admin-guide/media/imx.rst b/Documentation/admin-guide/media/imx.rst
> index bb68100d8acba..b1c5fecfaef74 100644
> --- a/Documentation/admin-guide/media/imx.rst
> +++ b/Documentation/admin-guide/media/imx.rst
> @@ -394,13 +394,9 @@ scaling up to 1024x1024, CSC, flip, and rotation:
> Usage Notes
> -----------
>
> -To aid in configuration and for backward compatibility with V4L2
> -applications that access controls only from video device nodes, the
> -capture device interfaces inherit controls from the active entities
> -in the current pipeline, so controls can be accessed either directly
> -from the subdev or from the active capture device interface. For
> -example, the FIM controls are available either from the ipuX_csiY
> -subdevs or from the active capture device.
> +Controls for pipeline entities are accessed through their subdev device
> +nodes. For example, the FIM controls are available from the ipuX_csiY
> +subdevs.
[Severity: Low]
Should the v4l2-ctl --set-fmt-video examples later in this document also
be updated to specify width and height when the upstream subdev pad is not
640x480?
Because capture nodes now initialize to 640x480 and VIDIOC_S_FMT no longer
inherits dimensions from the source subdev, the 720x480, 720x576, and
800x600 pipeline examples that only pass field= or pixelformat=RGB3 leave
the capture node at 640x480 and fail in capture_validate_fmt() with -EPIPE
at stream start.
[ ... ]
> diff --git a/drivers/staging/media/imx/imx-media-capture.c b/drivers/staging/media/imx/imx-media-capture.c
> index 9216a221b72f4..93d05cd967980 100644
> --- a/drivers/staging/media/imx/imx-media-capture.c
> +++ b/drivers/staging/media/imx/imx-media-capture.c
[ ... ]
> @@ -566,10 +432,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: High]
Does capture_validate_fmt() allow incompatible pixel formats on the video
node now that capture_s_fmt_vid_cap() accepts any PIXFMT_SEL_ANY format?
Previously, capture_legacy_s_fmt_vid_cap() called capture_find_format()
with both fmt_src->format.code and pixfmt->pixelformat, which rejected
Bayer formats on IPU internal links and required an exact format match on
non-IPU passthrough links. Now capture_validate_fmt() is the only check,
and it only compares the two-value colorspace enum:
drivers/staging/media/imx/imx-media-capture.c:capture_validate_fmt() {
...
cc = capture_find_format(fmt_src.format.code, 0);
if (!cc || priv->vdev.cc->cs != cc->cs)
return -EPIPE;
...
}
Because all RGB, Bayer, and greyscale formats share IPUV3_COLORSPACE_RGB
and all YUV formats share IPUV3_COLORSPACE_YUV, mismatched formats pass
validation. On a CSI passthrough link, configuring an 8-bpp or 12-bpp
format on the video node while the source subdev outputs a 16-bpp format
with the same colorspace programs 16-bpp IDMAC DMA transfers into buffers
sized for 8 or 12 bpp, overflowing the DMA buffer. On an IPU internal RGB
link, V4L2_PIX_FMT_Y10 or V4L2_PIX_FMT_Y12 reaches the default WARN_ON(1)
in ipu_cpmem_set_image(), while 8-bpp Bayer or greyscale formats cause
ipu_cpmem_set_fmt() to fail with its return value ignored, leaving the
CPMEM BPP field at 0 (32 bpp) for 8-bpp buffers.
Passing priv->vdev.fmt.pixelformat instead of 0 to capture_find_format()
in capture_validate_fmt() would restore the format check.
[Severity: High]
Can VIDIOC_S_FMT followed by VIDIOC_REQBUFS trigger a divide-by-zero in
capture_queue_setup()?
capture_legacy_s_fmt_vid_cap() previously took width and height from the
source subdev, where dimensions were already clamped to non-zero hardware
bounds. capture_s_fmt_vid_cap() instead passes the user's unclamped
width and height through __capture_try_fmt() to
imx_media_mbus_fmt_to_pix_fmt(), so width = 0 or height = 0 sets
priv->vdev.fmt.sizeimage to 0. A subsequent VIDIOC_REQBUFS or
VIDIOC_CREATE_BUFS then divides by pix->sizeimage:
drivers/staging/media/imx/imx-media-capture.c:capture_queue_setup() {
...
count = min_t(__u32, VID_MEM_LIMIT / pix->sizeimage, count);
...
}
[ ... ]
> @@ -869,36 +735,21 @@ void imx_media_capture_device_error(struct imx_media_video_dev *vdev)
> }
> EXPORT_SYMBOL_GPL(imx_media_capture_device_error);
>
> -static int capture_init_format(struct capture_priv *priv)
> +static void capture_init_format(struct capture_priv *priv)
> {
> - struct v4l2_subdev_format fmt_src = {
> - .pad = priv->src_sd_pad,
> - .which = V4L2_SUBDEV_FORMAT_ACTIVE,
> - };
> struct imx_media_video_dev *vdev = &priv->vdev;
> - int ret;
> -
> - if (priv->legacy_api) {
> - ret = v4l2_subdev_call(priv->src_sd, pad, get_fmt, NULL,
> - &fmt_src);
> - if (ret) {
> - dev_err(priv->dev, "failed to get source format\n");
> - return ret;
> - }
> - } else {
> - fmt_src.format.code = MEDIA_BUS_FMT_UYVY8_2X8;
> - fmt_src.format.width = IMX_MEDIA_DEF_PIX_WIDTH;
> - fmt_src.format.height = IMX_MEDIA_DEF_PIX_HEIGHT;
> - }
> + struct v4l2_mbus_framefmt fmt_src = {
> + .code = MEDIA_BUS_FMT_UYVY8_2X8,
> + .width = IMX_MEDIA_DEF_PIX_WIDTH,
> + .height = IMX_MEDIA_DEF_PIX_HEIGHT,
> + };
>
> - imx_media_mbus_fmt_to_pix_fmt(&vdev->fmt, &fmt_src.format, NULL);
> - vdev->compose.width = fmt_src.format.width;
> - vdev->compose.height = fmt_src.format.height;
> + imx_media_mbus_fmt_to_pix_fmt(&vdev->fmt, &fmt_src, NULL);
> + vdev->compose.width = fmt_src.width;
> + vdev->compose.height = fmt_src.height;
>
> vdev->cc = imx_media_find_pixel_format(vdev->fmt.pixelformat,
> PIXFMT_SEL_ANY);
> -
> - return 0;
> }
[Severity: High]
Does leaving fmt_src.field and the colorimetry members zero-initialized in
capture_init_format() and __capture_try_fmt() break IC color space
conversion at stream start?
Previously, vdev->fmt was initialized and updated from the source subdev's
active format, which imx_media_init_mbus_fmt() and
imx_media_try_colorimetry() populated with V4L2_FIELD_NONE and resolved
colorimetry values (such as V4L2_YCBCR_ENC_601 and
V4L2_QUANTIZATION_LIM_RANGE). Now fmt_src leaves field as V4L2_FIELD_ANY
(0) and ycbcr_enc and quantization as DEFAULT (0), and __capture_try_fmt()
also passes zeroed values through without resolving them.
When streaming starts on an IC capture node (ipuX_ic_prpenc or
ipuX_ic_prpvf), prp_setup_norotation() and prp_setup_rotation() pass
vdev->fmt.ycbcr_enc and vdev->fmt.quantization to ipu_ic_calc_csc() ->
calc_csc_coeffs(), which rejects V4L2_YCBCR_ENC_DEFAULT with -ENOTSUPP
whenever YUV-to-RGB or RGB-to-YUV conversion is needed:
drivers/gpu/ipu-v3/ipu-ic-csc.c:calc_csc_coeffs() {
...
switch (csc->out_cs.enc) {
case V4L2_YCBCR_ENC_601:
params_tbl = (csc->in_cs.cs == IPUV3_COLORSPACE_YUV) ?
yuv2rgb_601 : rgb2yuv_601;
break;
case V4L2_YCBCR_ENC_709:
params_tbl = (csc->in_cs.cs == IPUV3_COLORSPACE_YUV) ?
yuv2rgb_709 : rgb2yuv_709;
break;
default:
return -ENOTSUPP;
}
...
}
On default YUV-to-YUV IC captures, V4L2_QUANTIZATION_DEFAULT also maps to
full range instead of limited range, programming the yuvl2yuvf range
expansion CSC matrix instead of an identity pass-through.
[ ... ]
> @@ -974,7 +823,6 @@ 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;
[Severity: Medium]
Should prp_registered() and csi_registered() stop setting legacy_api = true
(or should legacy_api be removed altogether)?
Both callers of imx_media_capture_device_init() still pass legacy_api =
true, which leaves V4L2_CAP_IO_MC unset on every capture device, keeps
capture_ioctl_ops unused, and keeps capture_legacy_enum_framesizes() active.
Without V4L2_CAP_IO_MC, v4l_enum_fmt() in the V4L2 core zeroes
f->mbus_code before calling capture_enum_fmt_vid_cap(), and on
ipuX_ic_prpenc/prpvf capture nodes capture_legacy_enum_framesizes() passes
non-IPU mbus codes to prp_enum_frame_size(), which rejects 22 of the 23
enumerated pixel formats with -EINVAL.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261121141412.319802-1-shijiaqi_develop@163.com?part=1
next prev parent reply other threads:[~2026-11-21 14:40 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-21 14:14 [PATCH 0/3] media: imx: staging cleanup and FIM export to v4l2-core Jiaqi Shi
2026-11-21 14:14 ` [PATCH 1/3] media: imx: remove legacy video node control and format handling Jiaqi Shi
2026-11-21 14:40 ` sashiko-bot [this message]
2026-11-21 14:14 ` [PATCH 2/3] media: v4l2-core: add frame interval monitor helper Jiaqi Shi
2026-11-21 14:27 ` sashiko-bot
2026-11-21 14:14 ` [PATCH 3/3] media: imx: allow setting FIM input capture channel Jiaqi Shi
2026-11-21 14:24 ` 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-227100@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