提交 9b2279e4 编写于 作者: P Philipp Zabel 提交者: Zheng Zengkai

media: coda: limit frame interval enumeration to supported encoder frame sizes

stable inclusion
from stable-v5.10.121
commit f3915b46651a771f1f421cc1004198caa45f63e7
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I5L6CQ

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=f3915b46651a771f1f421cc1004198caa45f63e7

--------------------------------

[ Upstream commit 67e33dd9 ]

Let VIDIOC_ENUM_FRAMEINTERVALS return -EINVAL if userspace queries
frame intervals for frame sizes unsupported by the encoder. Fixes the
following v4l2-compliance failure:

		fail: v4l2-test-formats.cpp(123): found frame intervals for invalid size 47x16
		fail: v4l2-test-formats.cpp(282): node->codec_mask & STATEFUL_ENCODER
	test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: FAIL

[hverkuil: drop incorrect 'For decoder devices, return -ENOTTY.' in the commit log]
Signed-off-by: NPhilipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: NHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: NMauro Carvalho Chehab <mchehab@kernel.org>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
Acked-by: NXie XiuQi <xiexiuqi@huawei.com>
上级 f1365381
...@@ -1318,7 +1318,8 @@ static int coda_enum_frameintervals(struct file *file, void *fh, ...@@ -1318,7 +1318,8 @@ static int coda_enum_frameintervals(struct file *file, void *fh,
struct v4l2_frmivalenum *f) struct v4l2_frmivalenum *f)
{ {
struct coda_ctx *ctx = fh_to_ctx(fh); struct coda_ctx *ctx = fh_to_ctx(fh);
int i; struct coda_q_data *q_data;
const struct coda_codec *codec;
if (f->index) if (f->index)
return -EINVAL; return -EINVAL;
...@@ -1327,12 +1328,19 @@ static int coda_enum_frameintervals(struct file *file, void *fh, ...@@ -1327,12 +1328,19 @@ static int coda_enum_frameintervals(struct file *file, void *fh,
if (!ctx->vdoa && f->pixel_format == V4L2_PIX_FMT_YUYV) if (!ctx->vdoa && f->pixel_format == V4L2_PIX_FMT_YUYV)
return -EINVAL; return -EINVAL;
for (i = 0; i < CODA_MAX_FORMATS; i++) { if (coda_format_normalize_yuv(f->pixel_format) == V4L2_PIX_FMT_YUV420) {
if (f->pixel_format == ctx->cvd->src_formats[i] || q_data = get_q_data(ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE);
f->pixel_format == ctx->cvd->dst_formats[i]) codec = coda_find_codec(ctx->dev, f->pixel_format,
break; q_data->fourcc);
} else {
codec = coda_find_codec(ctx->dev, V4L2_PIX_FMT_YUV420,
f->pixel_format);
} }
if (i == CODA_MAX_FORMATS) if (!codec)
return -EINVAL;
if (f->width < MIN_W || f->width > codec->max_w ||
f->height < MIN_H || f->height > codec->max_h)
return -EINVAL; return -EINVAL;
f->type = V4L2_FRMIVAL_TYPE_CONTINUOUS; f->type = V4L2_FRMIVAL_TYPE_CONTINUOUS;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册