From nobody Sun Sep 22 06:39:31 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5E73FC433EF for ; Wed, 13 Apr 2022 03:55:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232185AbiDMD53 (ORCPT ); Tue, 12 Apr 2022 23:57:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39846 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232123AbiDMD4t (ORCPT ); Tue, 12 Apr 2022 23:56:49 -0400 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 13F3662EB; Tue, 12 Apr 2022 20:54:27 -0700 (PDT) X-UUID: c80a6648214d48a4b4a5a94561bae101-20220413 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.4,REQID:239001d8-e1c8-4bf9-9c3c-a93feee27325,OB:0,LO B:0,IP:0,URL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,RULE:Release_Ham,ACTI ON:release,TS:0 X-CID-META: VersionHash:faefae9,CLOUDID:87e9f8a8-d103-4e36-82b9-b0e86991b3df,C OID:IGNORED,Recheck:0,SF:nil,TC:nil,Content:0,EDM:-3,File:nil,QS:0,BEC:nil X-UUID: c80a6648214d48a4b4a5a94561bae101-20220413 Received: from mtkexhb01.mediatek.inc [(172.21.101.102)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1656252812; Wed, 13 Apr 2022 11:54:24 +0800 Received: from mtkexhb01.mediatek.inc (172.21.101.102) by mtkmbs10n2.mediatek.inc (172.21.101.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.2.792.3; Wed, 13 Apr 2022 11:54:22 +0800 Received: from mtkcas11.mediatek.inc (172.21.101.40) by mtkexhb01.mediatek.inc (172.21.101.102) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 13 Apr 2022 11:54:21 +0800 Received: from localhost.localdomain (10.17.3.154) by mtkcas11.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Wed, 13 Apr 2022 11:54:19 +0800 From: Yunfei Dong To: Yunfei Dong , Alexandre Courbot , Nicolas Dufresne , "Hans Verkuil" , AngeloGioacchino Del Regno , Benjamin Gaignard , Tiffany Lin , Andrew-CT Chen , Mauro Carvalho Chehab , Rob Herring , Matthias Brugger , Tomasz Figa CC: George Sun , Xiaoyong Lu , Hsin-Yi Wang , Fritz Koenig , Daniel Vetter , dri-devel , Irui Wang , "Steve Cho" , , , , , , , Subject: [PATCH v4, 5/7] media: mediatek: vcodec: Different codec using different capture format Date: Wed, 13 Apr 2022 11:54:08 +0800 Message-ID: <20220413035410.29568-6-yunfei.dong@mediatek.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220413035410.29568-1-yunfei.dong@mediatek.com> References: <20220413035410.29568-1-yunfei.dong@mediatek.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Vp8 need to use MM21, but vp9 and h264 need to use HyFbc mode for mt8195. Vp8/vp9/h264 use the same MM21 format for mt8192. Signed-off-by: Yunfei Dong --- .../platform/mediatek/vcodec/mtk_vcodec_dec.c | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec.c b/driv= ers/media/platform/mediatek/vcodec/mtk_vcodec_dec.c index 3859e4c651c6..d0f2dedcc911 100644 --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec.c +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec.c @@ -35,6 +35,44 @@ mtk_vdec_find_format(struct v4l2_format *f, return NULL; } =20 +static bool mtk_vdec_get_cap_fmt(struct mtk_vcodec_ctx *ctx, int format_in= dex) +{ + const struct mtk_vcodec_dec_pdata *dec_pdata =3D ctx->dev->vdec_pdata; + const struct mtk_video_fmt *fmt; + struct mtk_q_data *q_data; + int num_frame_count =3D 0, i; + bool ret =3D true; + + for (i =3D 0; i < *dec_pdata->num_formats; i++) { + if (dec_pdata->vdec_formats[i].type !=3D MTK_FMT_FRAME) + continue; + + num_frame_count++; + } + + if (num_frame_count =3D=3D 1) + return true; + + fmt =3D &dec_pdata->vdec_formats[format_index]; + q_data =3D &ctx->q_data[MTK_Q_DATA_SRC]; + switch (q_data->fmt->fourcc) { + case V4L2_PIX_FMT_VP8_FRAME: + if (fmt->fourcc =3D=3D V4L2_PIX_FMT_MM21) + ret =3D true; + break; + case V4L2_PIX_FMT_H264_SLICE: + case V4L2_PIX_FMT_VP9_FRAME: + if (fmt->fourcc =3D=3D V4L2_PIX_FMT_MM21) + ret =3D false; + break; + default: + ret =3D true; + break; + }; + + return ret; +} + static struct mtk_q_data *mtk_vdec_get_q_data(struct mtk_vcodec_ctx *ctx, enum v4l2_buf_type type) { @@ -577,6 +615,9 @@ static int vidioc_enum_fmt(struct v4l2_fmtdesc *f, void= *priv, dec_pdata->vdec_formats[i].type !=3D MTK_FMT_FRAME) continue; =20 + if (!output_queue && !mtk_vdec_get_cap_fmt(ctx, i)) + continue; + if (j =3D=3D f->index) break; ++j; --=20 2.18.0