[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220627112402.2332046-4-wenst@chromium.org>
Date: Mon, 27 Jun 2022 19:24:01 +0800
From: Chen-Yu Tsai <wenst@...omium.org>
To: Tiffany Lin <tiffany.lin@...iatek.com>,
Andrew-CT Chen <andrew-ct.chen@...iatek.com>,
Mauro Carvalho Chehab <mchehab@...nel.org>,
Hans Verkuil <hverkuil-cisco@...all.nl>
Cc: Nicolas Dufresne <nicolas.dufresne@...labora.com>,
Chen-Yu Tsai <wenst@...omium.org>, linux-media@...r.kernel.org,
linux-mediatek@...ts.infradead.org, linux-kernel@...r.kernel.org,
Nicolas Dufresne <nicolas@...fresne.ca>,
AngeloGioacchino Del Regno
<angelogioacchino.delregno@...labora.com>,
Yunfei Dong <yunfei.dong@...iatek.com>
Subject: [PATCH 3/4] media: mediatek: vcodec: dec: Fix resolution clamping in TRY_FMT
In commit b018be06f3c7 ("media: mediatek: vcodec: Read max resolution
from dec_capability"), TRY_FMT clamps the resolution to the maximum
that was previously set either by default 1080p or the limit set by a
previous S_FMT call. This does not make sense when doing TRY_FMT for
the output side, which may have different capabilities.
Instead, for the output side, find the maximum resolution based on the
pixel format requested. For the capture side, continue to use the
maximum resolution set by default or by a previous S_FMT call.
The maximum resolution is found from the list of per-format frame
sizes, so the patch "media: mediatek: vcodec: dec: Fix 4K frame size
enumeration" is needed.
Fixes: b018be06f3c7 ("media: mediatek: vcodec: Read max resolution from dec_capability")
Signed-off-by: Chen-Yu Tsai <wenst@...omium.org>
---
.../platform/mediatek/vcodec/mtk_vcodec_dec.c | 28 +++++++++++++++----
1 file changed, 22 insertions(+), 6 deletions(-)
diff --git a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec.c b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec.c
index f1b82d4c5be5..ea951cb3b927 100644
--- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec.c
+++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec.c
@@ -282,13 +282,29 @@ static int vidioc_try_fmt(struct mtk_vcodec_ctx *ctx, struct v4l2_format *f,
const struct mtk_video_fmt *fmt)
{
struct v4l2_pix_format_mplane *pix_fmt_mp = &f->fmt.pix_mp;
+ const struct mtk_vcodec_dec_pdata *dec_pdata = ctx->dev->vdec_pdata;
+ unsigned int max_width, max_height;
+ int i;
+
+ if (V4L2_TYPE_IS_OUTPUT(f->type)) {
+ max_width = MTK_VDEC_MAX_W;
+ max_height = MTK_VDEC_MAX_H;
+ for (i = 0; i < *dec_pdata->num_framesizes; ++i)
+ if (f->fmt.pix_mp.pixelformat == dec_pdata->vdec_framesizes[i].fourcc) {
+ max_width = dec_pdata->vdec_framesizes[i].stepwise.max_width;
+ max_height = dec_pdata->vdec_framesizes[i].stepwise.max_height;
+ }
+ } else {
+ max_width = ctx->max_width;
+ max_height = ctx->max_height;
+ }
pix_fmt_mp->field = V4L2_FIELD_NONE;
pix_fmt_mp->width =
- clamp(pix_fmt_mp->width, MTK_VDEC_MIN_W, ctx->max_width);
+ clamp(pix_fmt_mp->width, MTK_VDEC_MIN_W, max_width);
pix_fmt_mp->height =
- clamp(pix_fmt_mp->height, MTK_VDEC_MIN_H, ctx->max_height);
+ clamp(pix_fmt_mp->height, MTK_VDEC_MIN_H, max_height);
if (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
pix_fmt_mp->num_planes = 1;
@@ -306,16 +322,16 @@ static int vidioc_try_fmt(struct mtk_vcodec_ctx *ctx, struct v4l2_format *f,
tmp_h = pix_fmt_mp->height;
v4l_bound_align_image(&pix_fmt_mp->width,
MTK_VDEC_MIN_W,
- ctx->max_width, 6,
+ max_width, 6,
&pix_fmt_mp->height,
MTK_VDEC_MIN_H,
- ctx->max_height, 6, 9);
+ max_height, 6, 9);
if (pix_fmt_mp->width < tmp_w &&
- (pix_fmt_mp->width + 64) <= ctx->max_width)
+ (pix_fmt_mp->width + 64) <= max_width)
pix_fmt_mp->width += 64;
if (pix_fmt_mp->height < tmp_h &&
- (pix_fmt_mp->height + 64) <= ctx->max_height)
+ (pix_fmt_mp->height + 64) <= max_height)
pix_fmt_mp->height += 64;
mtk_v4l2_debug(0,
--
2.37.0.rc0.161.g10f37bed90-goog
Powered by blists - more mailing lists