From: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
To: Vikash Garodia <vikash.garodia@oss.qualcomm.com>,
Dikshita Agarwal <dikshita.agarwal@oss.qualcomm.com>,
Abhinav Kumar <abhinav.kumar@linux.dev>,
Bryan O'Donoghue <bod@kernel.org>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Hans Verkuil <hverkuil+cisco@kernel.org>
Cc: linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH v2 04/13] media: iris: size QC08C buffers to fit field-coded pictures
Date: Fri, 04 Dec 2026 20:24:45 +0200 [thread overview]
Message-ID: <20261204-iris-vp8-v2-4-462f9b48d246@oss.qualcomm.com> (raw)
In-Reply-To: <20261204-iris-vp8-v2-0-462f9b48d246@oss.qualcomm.com>
Decoding interlaced content faults in the IOMMU: the firmware writes past
the end of a reconstruction (DPB) buffer. iris_yuv_buffer_size_qc08c()
lays a UBWC NV12 buffer out as one frame, but for field pictures the
hardware stores the two fields separately, each with its planes and
metadata aligned on its own, which takes more space at most sizes.
Size the buffer as the downstream driver does for both directions: up to
1920x1088, take the larger two-field layout, otherwise one frame.
Fixes: cfd71b14b0d6 ("media: iris: Add support for QC08C format for decoder")
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
---
drivers/media/platform/qcom/iris/iris_buffer.c | 53 +++++++++++++++++---------
1 file changed, 34 insertions(+), 19 deletions(-)
diff --git a/drivers/media/platform/qcom/iris/iris_buffer.c b/drivers/media/platform/qcom/iris/iris_buffer.c
index eb8de60c1177..b5588fd8997e 100644
--- a/drivers/media/platform/qcom/iris/iris_buffer.c
+++ b/drivers/media/platform/qcom/iris/iris_buffer.c
@@ -228,40 +228,55 @@ static u32 iris_yuv_buffer_size_p010(struct iris_inst *inst)
*
* Note: All the alignments are hardware requirements.
*/
-static u32 iris_yuv_buffer_size_qc08c(struct iris_inst *inst)
+static u32 iris_yuv_planes_size_qc08c(u32 width, u32 height)
{
u32 y_plane, uv_plane, y_stride, uv_stride;
u32 uv_meta_stride, uv_meta_plane;
u32 y_meta_stride, y_meta_plane;
- struct v4l2_format *f = NULL;
+ u32 uv_height = DIV_ROUND_UP(height, 2);
- if (inst->domain == DECODER)
- f = inst->fmt_dst;
- else
- f = inst->fmt_src;
-
- y_meta_stride = ALIGN(DIV_ROUND_UP(f->fmt.pix_mp.width, META_STRIDE_ALIGNED >> 1),
+ y_meta_stride = ALIGN(DIV_ROUND_UP(width, META_STRIDE_ALIGNED >> 1),
META_STRIDE_ALIGNED);
- y_meta_plane = y_meta_stride * ALIGN(DIV_ROUND_UP(f->fmt.pix_mp.height,
- META_SCANLINE_ALIGNED >> 1),
+ y_meta_plane = y_meta_stride * ALIGN(DIV_ROUND_UP(height, META_SCANLINE_ALIGNED >> 1),
META_SCANLINE_ALIGNED);
y_meta_plane = ALIGN(y_meta_plane, PIXELS_4K);
- y_stride = ALIGN(f->fmt.pix_mp.width, Y_STRIDE_ALIGN);
- y_plane = ALIGN(y_stride * ALIGN(f->fmt.pix_mp.height, Y_SCANLINE_ALIGN), PIXELS_4K);
+ y_stride = ALIGN(width, Y_STRIDE_ALIGN);
+ y_plane = ALIGN(y_stride * ALIGN(height, Y_SCANLINE_ALIGN), PIXELS_4K);
- uv_meta_stride = ALIGN(DIV_ROUND_UP(f->fmt.pix_mp.width / 2, META_STRIDE_ALIGNED >> 2),
+ uv_meta_stride = ALIGN(DIV_ROUND_UP(width / 2, META_STRIDE_ALIGNED >> 2),
META_STRIDE_ALIGNED);
- uv_meta_plane = uv_meta_stride * ALIGN(DIV_ROUND_UP(f->fmt.pix_mp.height / 2,
- META_SCANLINE_ALIGNED >> 1),
+ uv_meta_plane = uv_meta_stride * ALIGN(DIV_ROUND_UP(uv_height, META_SCANLINE_ALIGNED >> 1),
META_SCANLINE_ALIGNED);
uv_meta_plane = ALIGN(uv_meta_plane, PIXELS_4K);
- uv_stride = ALIGN(f->fmt.pix_mp.width, UV_STRIDE_ALIGN);
- uv_plane = ALIGN(uv_stride * ALIGN(f->fmt.pix_mp.height / 2, UV_SCANLINE_ALIGN_QC08C),
- PIXELS_4K);
+ uv_stride = ALIGN(width, UV_STRIDE_ALIGN);
+ uv_plane = ALIGN(uv_stride * ALIGN(uv_height, UV_SCANLINE_ALIGN_QC08C), PIXELS_4K);
- return ALIGN(y_meta_plane + y_plane + uv_meta_plane + uv_plane, PIXELS_4K);
+ return y_meta_plane + y_plane + uv_meta_plane + uv_plane;
+}
+
+static u32 iris_yuv_buffer_size_qc08c(struct iris_inst *inst)
+{
+ struct v4l2_format *f;
+ u32 width, height;
+
+ if (inst->domain == DECODER)
+ f = inst->fmt_dst;
+ else
+ f = inst->fmt_src;
+
+ width = f->fmt.pix_mp.width;
+ height = f->fmt.pix_mp.height;
+
+ /*
+ * Up to 1080p the buffer must also fit two separately aligned fields,
+ * which is larger than one frame.
+ */
+ if (width <= 1920 && height <= 1920 && width * height <= 1920 * 1088)
+ return 2 * iris_yuv_planes_size_qc08c(width, DIV_ROUND_UP(height, 2));
+
+ return iris_yuv_planes_size_qc08c(width, height);
}
/*
--
2.47.3
next prev parent reply other threads:[~2026-12-04 18:25 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 18:24 [PATCH v2 00/13] media: iris: enable VP8, MPEG1/MPEG2 and interlaced MPEG2 support Dmitry Baryshkov
2026-12-04 18:24 ` [PATCH v2 01/13] media: iris: apply the capture buffer minimum in queue_setup Dmitry Baryshkov
2026-12-04 18:24 ` [PATCH v2 02/13] media: iris: translate Gen1 profile/level to HFI enumerants Dmitry Baryshkov
2026-12-04 18:24 ` [PATCH v2 03/13] media: iris: default the Gen1 encoder level to a usable value Dmitry Baryshkov
2026-12-04 18:24 ` Dmitry Baryshkov [this message]
2026-12-04 18:24 ` [PATCH v2 05/13] media: iris: split Gen2 firmware data for vpu2-generation SoCs Dmitry Baryshkov
2026-12-04 18:24 ` [PATCH v2 06/13] media: iris: move the decode format list into the firmware data Dmitry Baryshkov
2026-12-04 18:24 ` [PATCH v2 07/13] media: iris: support read-only controls Dmitry Baryshkov
2026-12-04 18:24 ` [PATCH v2 08/13] media: iris: add VP8 decode support on Gen1 firmware Dmitry Baryshkov
2026-12-04 18:24 ` [PATCH v2 09/13] media: iris: add MPEG1 and MPEG2 " Dmitry Baryshkov
2026-12-04 18:24 ` [PATCH v2 10/13] media: iris: support interlaced MPEG2 content Dmitry Baryshkov
2026-12-04 18:24 ` [PATCH v2 11/13] media: iris: move the encode format list into the firmware data Dmitry Baryshkov
2026-12-04 18:24 ` [PATCH v2 12/13] media: iris: accept gen1 encoder output at a non-zero offset Dmitry Baryshkov
2026-12-04 18:24 ` [PATCH v2 13/13] media: iris: add VP8 encode support on Gen1 firmware Dmitry Baryshkov
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=20261204-iris-vp8-v2-4-462f9b48d246@oss.qualcomm.com \
--to=dmitry.baryshkov@oss.qualcomm.com \
--cc=abhinav.kumar@linux.dev \
--cc=bod@kernel.org \
--cc=dikshita.agarwal@oss.qualcomm.com \
--cc=hverkuil+cisco@kernel.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@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
all inboxes | Powered by JetHome®