Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp5932693pxb; Thu, 27 Jan 2022 02:47:35 -0800 (PST) X-Google-Smtp-Source: ABdhPJxOZqykqYikR2yMhWiTPjrEJfZTrAB6RH697hzoycBy+AqRLNIFWmXz18YNhltbAGfrbV3F X-Received: by 2002:a05:6402:510b:: with SMTP id m11mr2973618edd.203.1643280454853; Thu, 27 Jan 2022 02:47:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643280454; cv=none; d=google.com; s=arc-20160816; b=o/ClR4GRQlTYMmGatMz8Bo2h0GgvIoPWsrR8a/YPVZEI74DNs9ZkUGq0qox3HPy1o9 QngGe8bMGzgpO2mQKfpMwX69VId/Q3NadR3YavxTyoSIWJZ/0yxamSnJq6JQQBnBt/F4 iPJkwCKYekxjpFpvtwX8GlJadJlWytOgioKeDPUyu70GZW6tBBAsUL/F13GPE30NV06U DvVWh28IrHMDVJdi7MsYx/K/NVPpcZ8ki6k/PMVUk74i0ZHfXdbRi0z36Nsun6KjPG94 YY7Z/T/ejmGbAJcVod1Za9H/NpzYlZKB/7InL9gN1O9HhKAmV+ud0vGjGSoMa+pRYgi+ +uSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=Ki3tbpVWiEYMpuDYTaVuYUnoJkzzsKlE4zbJqbbT/u4=; b=Jnh7NvKZ88lZx6zjy5o83v/M5RjBEhZYz2b0xGICx+4IIbiCLSKp2EPg4mrZePAdpE tofbZrFe5G3E4h9UKZqimiszwzvHS70gJr5kzmpnEsIxRCg0WLCZbcTjFWgiUIo44+7Y 6lBLYMP8bp9uiIThxy48fHvIPVtB7LdPg8iNTaUAg/PnWOWTPTKCUooCzo44k06AcFCo x9hXFaeEzpHfcHpGR7pSN5tRsEU6e/L0KcuCUKGzIKU7L41AIp9Ww821V/8mxFPxqhlt X3SGwgZIC4atN31iVFNmzlRfpjaqiCNt2AHn2dzwIjHcsz7EFuwdYDw5M9D/zQGEfo30 gZVQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o16si1382647edc.133.2022.01.27.02.47.10; Thu, 27 Jan 2022 02:47:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235581AbiA0C4L (ORCPT + 99 others); Wed, 26 Jan 2022 21:56:11 -0500 Received: from mailgw01.mediatek.com ([60.244.123.138]:49400 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S235464AbiA0C4C (ORCPT ); Wed, 26 Jan 2022 21:56:02 -0500 X-UUID: 48b4037cc3fb41a1b68dbe2ae3d27dd7-20220127 X-UUID: 48b4037cc3fb41a1b68dbe2ae3d27dd7-20220127 Received: from mtkexhb02.mediatek.inc [(172.21.101.103)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1806354057; Thu, 27 Jan 2022 10:55:59 +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; Thu, 27 Jan 2022 10:55:58 +0800 Received: from mtkcas10.mediatek.inc (172.21.101.39) by mtkexhb01.mediatek.inc (172.21.101.102) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 27 Jan 2022 10:55:57 +0800 Received: from localhost.localdomain (10.17.3.154) by mtkcas10.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Thu, 27 Jan 2022 10:55:55 +0800 From: Yunfei Dong To: Yunfei Dong , Alexandre Courbot , Hans Verkuil , "Tzung-Bi Shih" , AngeloGioacchino Del Regno , Tiffany Lin , Andrew-CT Chen , Mauro Carvalho Chehab , Rob Herring , Matthias Brugger , Tomasz Figa CC: George Sun , Xiaoyong Lu , Hsin-Yi Wang , Fritz Koenig , Dafna Hirschfeld , Benjamin Gaignard , Daniel Vetter , dri-devel , Irui Wang , Steve Cho , , , , , , , Subject: [PATCH v1, 5/8] media: mtk-vcodec: Different codec using different capture format Date: Thu, 27 Jan 2022 10:55:41 +0800 Message-ID: <20220127025544.10854-6-yunfei.dong@mediatek.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220127025544.10854-1-yunfei.dong@mediatek.com> References: <20220127025544.10854-1-yunfei.dong@mediatek.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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/mtk-vcodec/mtk_vcodec_dec.c | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c index 6ad17e69e32d..f2ced0147534 100644 --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c @@ -35,6 +35,44 @@ mtk_vdec_find_format(struct v4l2_format *f, return NULL; } +static bool mtk_vdec_get_cap_fmt(struct mtk_vcodec_ctx *ctx, int format_index) +{ + const struct mtk_vcodec_dec_pdata *dec_pdata = ctx->dev->vdec_pdata; + const struct mtk_video_fmt *fmt; + struct mtk_q_data *q_data; + int num_frame_count = 0, i; + bool ret = true; + + for (i = 0; i < *dec_pdata->num_formats; i++) { + if (dec_pdata->vdec_formats[i].type != MTK_FMT_FRAME) + continue; + + num_frame_count++; + } + + if (num_frame_count == 1) + return true; + + fmt = &dec_pdata->vdec_formats[format_index]; + q_data = &ctx->q_data[MTK_Q_DATA_SRC]; + switch (q_data->fmt->fourcc) { + case V4L2_PIX_FMT_VP8_FRAME: + if (fmt->fourcc == V4L2_PIX_FMT_MM21) + ret = true; + break; + case V4L2_PIX_FMT_H264_SLICE: + case V4L2_PIX_FMT_VP9_FRAME: + if (fmt->fourcc == V4L2_PIX_FMT_MM21) + ret = false; + break; + default: + ret = true; + break; + }; + + return ret; +} + static struct mtk_q_data *mtk_vdec_get_q_data(struct mtk_vcodec_ctx *ctx, enum v4l2_buf_type type) { @@ -578,6 +616,9 @@ static int vidioc_enum_fmt(struct v4l2_fmtdesc *f, void *priv, dec_pdata->vdec_formats[i].type != MTK_FMT_FRAME) continue; + if (!output_queue && !mtk_vdec_get_cap_fmt(ctx, i)) + continue; + if (j == f->index) break; ++j; -- 2.25.1