From: Christian Cortner <ccortner@gmail.com>
To: Bryan O'Donoghue <bod@kernel.org>,
Vikash Garodia <vikash.garodia@oss.qualcomm.com>,
Dikshita Agarwal <dikshita.agarwal@oss.qualcomm.com>
Cc: Abhinav Kumar <abhinav.kumar@linux.dev>,
Birk Skyum <birk.skyum@pm.me>,
linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org
Subject: [RFC PATCH v2 2/4] media: iris: Update the CAPTURE stride and size on S_FMT(OUTPUT)
Date: Tue, 27 Oct 2026 22:43:33 -0500 [thread overview]
Message-ID: <20261028034335.26075-3-ccortner@gmail.com> (raw)
In-Reply-To: <20261028034335.26075-1-ccortner@gmail.com>
S_FMT(OUTPUT) updates the CAPTURE width and height but not
bytesperline and sizeimage, which keep the values of the previous
format. With a 640x360 stream, REQBUFS(CAPTURE) then allocates buffers
that iris_vb2_buf_prepare() rejects with -EINVAL.
Move the CAPTURE format rules of S_FMT(CAPTURE) into a helper and use
it for S_FMT(OUTPUT) as well.
Fixes: 8aadfd445373 ("media: iris: Update CAPTURE format info based on OUTPUT format")
Cc: stable@vger.kernel.org
Assisted-by: LLM sparse smatch
---
drivers/media/platform/qcom/iris/iris_vdec.c | 61 +++++++++++---------
1 file changed, 33 insertions(+), 28 deletions(-)
diff --git a/drivers/media/platform/qcom/iris/iris_vdec.c b/drivers/media/platform/qcom/iris/iris_vdec.c
index 0dd33ff447bb..472e8e50830d 100644
--- a/drivers/media/platform/qcom/iris/iris_vdec.c
+++ b/drivers/media/platform/qcom/iris/iris_vdec.c
@@ -212,6 +212,35 @@ int iris_vdec_try_fmt(struct iris_inst *inst, struct v4l2_format *f)
return 0;
}
+static void iris_vdec_set_capture_size(struct iris_inst *inst, u32 width,
+ u32 height)
+{
+ struct v4l2_pix_format_mplane *pix_mp = &inst->fmt_dst->fmt.pix_mp;
+ struct iris_buffers *bufs = &inst->buffers[BUF_OUTPUT];
+
+ switch (pix_mp->pixelformat) {
+ case V4L2_PIX_FMT_P010:
+ pix_mp->width = ALIGN(width, 128);
+ pix_mp->height = ALIGN(height, 32);
+ pix_mp->plane_fmt[0].bytesperline = ALIGN(width * 2, 256);
+ break;
+ case V4L2_PIX_FMT_QC10C:
+ pix_mp->width = roundup(width, 192);
+ pix_mp->height = ALIGN(height, 16);
+ pix_mp->plane_fmt[0].bytesperline = ALIGN(width * 4 / 3, 256);
+ break;
+ case V4L2_PIX_FMT_NV12:
+ case V4L2_PIX_FMT_QC08C:
+ pix_mp->width = ALIGN(width, 128);
+ pix_mp->height = ALIGN(height, 32);
+ pix_mp->plane_fmt[0].bytesperline = ALIGN(width, 128);
+ break;
+ }
+ pix_mp->plane_fmt[0].sizeimage = iris_get_buffer_size(inst, BUF_OUTPUT);
+ bufs->min_count = iris_vpu_buf_count(inst, BUF_OUTPUT);
+ bufs->size = pix_mp->plane_fmt[0].sizeimage;
+}
+
int iris_vdec_s_fmt(struct iris_inst *inst, struct v4l2_format *f)
{
struct v4l2_format *fmt, *output_fmt;
@@ -263,10 +292,8 @@ int iris_vdec_s_fmt(struct iris_inst *inst, struct v4l2_format *f)
output_fmt->fmt.pix_mp.quantization = f->fmt.pix_mp.quantization;
/* Update capture format based on new ip w/h */
- output_fmt->fmt.pix_mp.width = ALIGN(f->fmt.pix_mp.width, 128);
- output_fmt->fmt.pix_mp.height = ALIGN(f->fmt.pix_mp.height, 32);
- inst->buffers[BUF_OUTPUT].min_count = iris_vpu_buf_count(inst, BUF_OUTPUT);
- inst->buffers[BUF_OUTPUT].size = iris_get_buffer_size(inst, BUF_OUTPUT);
+ iris_vdec_set_capture_size(inst, f->fmt.pix_mp.width,
+ f->fmt.pix_mp.height);
inst->crop.left = 0;
inst->crop.top = 0;
@@ -281,30 +308,8 @@ int iris_vdec_s_fmt(struct iris_inst *inst, struct v4l2_format *f)
fmt->type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
fmt->fmt.pix_mp.pixelformat = f->fmt.pix_mp.pixelformat;
fmt->fmt.pix_mp.num_planes = 1;
- switch (f->fmt.pix_mp.pixelformat) {
- case V4L2_PIX_FMT_P010:
- fmt->fmt.pix_mp.width = ALIGN(f->fmt.pix_mp.width, 128);
- fmt->fmt.pix_mp.height = ALIGN(f->fmt.pix_mp.height, 32);
- fmt->fmt.pix_mp.plane_fmt[0].bytesperline =
- ALIGN(f->fmt.pix_mp.width * 2, 256);
- break;
- case V4L2_PIX_FMT_QC10C:
- fmt->fmt.pix_mp.width = roundup(f->fmt.pix_mp.width, 192);
- fmt->fmt.pix_mp.height = ALIGN(f->fmt.pix_mp.height, 16);
- fmt->fmt.pix_mp.plane_fmt[0].bytesperline =
- ALIGN(f->fmt.pix_mp.width * 4 / 3, 256);
- break;
- case V4L2_PIX_FMT_NV12:
- case V4L2_PIX_FMT_QC08C:
- fmt->fmt.pix_mp.width = ALIGN(f->fmt.pix_mp.width, 128);
- fmt->fmt.pix_mp.height = ALIGN(f->fmt.pix_mp.height, 32);
- fmt->fmt.pix_mp.plane_fmt[0].bytesperline =
- ALIGN(f->fmt.pix_mp.width, 128);
- break;
- }
- fmt->fmt.pix_mp.plane_fmt[0].sizeimage = iris_get_buffer_size(inst, BUF_OUTPUT);
- inst->buffers[BUF_OUTPUT].min_count = iris_vpu_buf_count(inst, BUF_OUTPUT);
- inst->buffers[BUF_OUTPUT].size = fmt->fmt.pix_mp.plane_fmt[0].sizeimage;
+ iris_vdec_set_capture_size(inst, f->fmt.pix_mp.width,
+ f->fmt.pix_mp.height);
inst->crop.top = 0;
inst->crop.left = 0;
--
2.56.0
next prev parent reply other threads:[~2026-10-28 3:43 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <-D3aZIsoO4_H5CdnB-7Co7GWmm5F9FuU6aFuhXWogBXhfqNOaqC2Y8tkBxT9ljDcy84UAX1jmUWGl7NtGUG6Mg==@protonmail.internalid>
2026-10-28 3:43 ` [RFC PATCH v2 0/4] media: iris: decoder fixes for resolution changes Christian Cortner
2026-10-28 3:43 ` [RFC PATCH v2 1/4] media: iris: Don't flag an empty source change LAST buffer as an error Christian Cortner
2026-10-28 3:43 ` Christian Cortner [this message]
2026-10-28 3:43 ` [RFC PATCH v2 3/4] media: iris: Signal V4L2_EVENT_EOS only at the end of a drain Christian Cortner
2026-10-28 3:43 ` [RFC PATCH v2 4/4] media: iris: Let a resolution change drain before stopping CAPTURE Christian Cortner
2026-10-28 10:00 ` [RFC PATCH v2 0/4] media: iris: decoder fixes for resolution changes Bryan O'Donoghue
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=20261028034335.26075-3-ccortner@gmail.com \
--to=ccortner@gmail.com \
--cc=abhinav.kumar@linux.dev \
--cc=birk.skyum@pm.me \
--cc=bod@kernel.org \
--cc=dikshita.agarwal@oss.qualcomm.com \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=vikash.garodia@oss.qualcomm.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