Re: [PATCH 1/4] media: mediatek: vcodec: dec: Fix 4K frame size enumeration

From: Chen-Yu Tsai
Date: Mon Jun 27 2022 - 12:13:44 EST


On Mon, Jun 27, 2022 at 11:33 PM Nicolas Dufresne
<nicolas.dufresne@xxxxxxxxxxxxx> wrote:
>
> Le lundi 27 juin 2022 à 19:23 +0800, Chen-Yu Tsai a écrit :
> > This partially reverts commit b018be06f3c7 ("media: mediatek: vcodec:
> > Read max resolution from dec_capability"). In this commit, the maximum
> > resolution ended up being a function of both the firmware capability and
> > the current set format.
> >
> > However, frame size enumeration for output (coded) formats should not
> > depend on the format set, but should return supported resolutions for
> > the format requested by userspace.
> >
> > Fix this so that the driver returns the supported resolutions correctly,
> > even if the instance only has default settings, or if the output format
> > is currently set to VP8F, which does not support 4K.
> >
> > Fixes: b018be06f3c7 ("media: mediatek: vcodec: Read max resolution from dec_capability")
> > Signed-off-by: Chen-Yu Tsai <wenst@xxxxxxxxxxxx>
> > ---
> > drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec.c | 2 --
> > .../platform/mediatek/vcodec/mtk_vcodec_dec_stateless.c | 7 +++++++
> > 2 files changed, 7 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec.c b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec.c
> > index 5d6fdf18c3a6..fcb4b8131c49 100644
> > --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec.c
> > +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec.c
> > @@ -595,8 +595,6 @@ static int vidioc_enum_framesizes(struct file *file, void *priv,
> > fsize->type = V4L2_FRMSIZE_TYPE_STEPWISE;
> > fsize->stepwise = dec_pdata->vdec_framesizes[i].stepwise;
> >
> > - fsize->stepwise.max_width = ctx->max_width;
> > - fsize->stepwise.max_height = ctx->max_height;
> > mtk_v4l2_debug(1, "%x, %d %d %d %d %d %d",
> > ctx->dev->dec_capability,
> > fsize->stepwise.min_width,
> > diff --git a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_stateless.c b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_stateless.c
> > index 16d55785d84b..9a4d3e3658aa 100644
> > --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_stateless.c
> > +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_stateless.c
> > @@ -360,6 +360,13 @@ static void mtk_vcodec_add_formats(unsigned int fourcc,
> >
> > mtk_vdec_framesizes[count_framesizes].fourcc = fourcc;
> > mtk_vdec_framesizes[count_framesizes].stepwise = stepwise_fhd;
>
> While at it, can you constify stepwise_fhd, it is scary to think that someone
> could modify it and cause big headache.

I noticed that as well, but since a planned refactoring would get rid of it,
I didn't fix it in this series.

I can add a patch for that.


ChenYu

> > + if (!(ctx->dev->dec_capability & VCODEC_CAPABILITY_4K_DISABLED) &&
> > + fourcc != V4L2_PIX_FMT_VP8_FRAME) {
> > + mtk_vdec_framesizes[count_framesizes].stepwise.max_width =
> > + VCODEC_DEC_4K_CODED_WIDTH;
> > + mtk_vdec_framesizes[count_framesizes].stepwise.max_height =
> > + VCODEC_DEC_4K_CODED_HEIGHT;
> > + }
> > num_framesizes++;
> > break;
> > case V4L2_PIX_FMT_MM21:
>