From patchwork Fri Jul 19 07:50:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Qian X-Patchwork-Id: 13736942 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 324E7C3DA59 for ; Fri, 19 Jul 2024 07:51:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:MIME-Version:Content-Type: Content-Transfer-Encoding:References:In-Reply-To:Message-ID:Date:Subject:Cc: To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=8tksjlkC2qYUPNV8qBJuLmInrtcjTgRVbapRbRxFOuM=; b=nM4BZrJam2M/K8DkNjLl63e7FM kNUNji80xtYgiYZInoaX9P5zwG8DXOuJwekSsdn9Kkc09wOMUmD4nR0bfmJmrW+NWL6ydeVh1XRWT 3Uok4svT1iFfugKEH4g2fdoyibKYvSZAebJBVDy5/h+jFgXkg+1cDMwf+GlVrSNQcD9gnKO1im3HL bNCyEj3G1piwCzdwL2XSHUW6bovp/Ew0/CVT2ZrHLC9cNClTILQttN2zvCbYx7zkR5dROXeoa1y5m iWq3xDFvj7Vp0NCoc+gazp2SDtNG185Ojtk3dcDpdQw2qCzXlwy99mu/HCbtkfLzTuFkQqdbkoI7J HoaBknTA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sUiOh-00000001xci-1Ycd; Fri, 19 Jul 2024 07:51:23 +0000 Received: from mail-westeuropeazlp170100000.outbound.protection.outlook.com ([2a01:111:f403:c201::] helo=AM0PR83CU005.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sUiOJ-00000001xUX-14zO for linux-arm-kernel@lists.infradead.org; Fri, 19 Jul 2024 07:51:00 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=N6m4E23wHOiJC35odVmp/TTvVdVwsB+4D4IBZIKmsl2TnJC6m1GRRTbrFRQlitnvjF5ZwLjcWVf6gNyZ570NoEyTXYxWa/jICqG92EFfyEbcz5oq379sBCQH78DBLjUb0ZCr5aHU2NoMIxWE00QdA26RBkSUt6DpIVzUV23peC9Y7+ufnRuZD7lm8ETn9Yvxt56yglroO74ybNvrrt58XZLVe1Plf/Fi0oxfz0+WWkGhB+dFjF71FBO37fu5T8TxktB9R2yyX3qPISPShZc3h/ub5d2jx9LY8302FSGTHcI6lPZA6DIhhgzaLHnzDcK9Upx6IVNlRCCLmTrkCDwWDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=8tksjlkC2qYUPNV8qBJuLmInrtcjTgRVbapRbRxFOuM=; b=uuOT4qu0Xoi3bhwQDv7u68och7OJLQwCGqFr7Cy/hkUmyU459y9DTqh/xuaYKNPg6E4MP3/tQeyd4KFLDE5iaS7E7Czihsotmm3X400X0dtV7U/lLgnbhANkPYVLAWqQg+5n6bXb/wEdvWe4XHucQ0OzVg5KW1KhwVhcjfhpRg/VEt4/LJrSroGqOQohC8aOBRtkhLDdFkHy3EQTGOitDbFelq6RURm8UbSdlFaGg8Vo4U6XUOg/oG15HYxIkX0D3bkxVZTv/6HkZjBY/2MlwWWyy3piMhtOp/nEWOSpVILXcQnAa8GZqEnuE1nPVwN8ibZdNyXkKzKupkDAlSF/LA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=8tksjlkC2qYUPNV8qBJuLmInrtcjTgRVbapRbRxFOuM=; b=mCceScxEamy/tBFAVu72Rpe6AUY5jujP4jkp5wgHmWt9WP803Q9BCmdeZ6miQA8GbzMbCavONR7f1xLKQDcJVGDRXffyWnwXe6uVJXONTJV6YCe6cq9kxk/SmOkbmJm2JaDJHTWRzpDgsLPR3kqLuYNijd/3TV5pYOLivBLtBYQ= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB8254.eurprd04.prod.outlook.com (2603:10a6:102:1cd::24) by VI1PR04MB6912.eurprd04.prod.outlook.com (2603:10a6:803:134::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7784.16; Fri, 19 Jul 2024 07:50:39 +0000 Received: from PAXPR04MB8254.eurprd04.prod.outlook.com ([fe80::2755:55ac:5d6f:4f87]) by PAXPR04MB8254.eurprd04.prod.outlook.com ([fe80::2755:55ac:5d6f:4f87%5]) with mapi id 15.20.7784.017; Fri, 19 Jul 2024 07:50:39 +0000 From: Ming Qian To: mchehab@kernel.org, hverkuil-cisco@xs4all.nl Cc: nicolas@ndufresne.ca, shawnguo@kernel.org, robh+dt@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, xiahong.bao@nxp.com, eagle.zhou@nxp.com, tao.jiang_2@nxp.com, ming.qian@oss.nxp.com, imx@lists.linux.dev, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH] media: amphion: Add H264 and HEVC profile and level control Date: Fri, 19 Jul 2024 16:50:07 +0900 Message-ID: <20240719075007.384342-2-ming.qian@nxp.com> X-Mailer: git-send-email 2.43.0-rc1 In-Reply-To: <20240719075007.384342-1-ming.qian@nxp.com> References: <20240719075007.384342-1-ming.qian@nxp.com> X-ClientProxiedBy: SI1PR02CA0036.apcprd02.prod.outlook.com (2603:1096:4:1f6::20) To PAXPR04MB8254.eurprd04.prod.outlook.com (2603:10a6:102:1cd::24) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8254:EE_|VI1PR04MB6912:EE_ X-MS-Office365-Filtering-Correlation-Id: 6de516a7-390a-45dd-2375-08dca7c77b54 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|7416014|376014|52116014|38350700014; X-Microsoft-Antispam-Message-Info: S+Gn+5tlkZDapFkMA64nS4EoZTo4K5ai9QmMGCEUhmQsL+/J675NH0NHgDE3wGR4dCpS8827eTgtSSTPw0i8ysS0DAlOqaUnSAem/ksrC15VfetM9KWpxmRkG9mbwiba1kzmcSAfzq6rVuTKlcxjNzsPPCJc0YFH0miwJBDoql8NoLcKJQ/e9z6irSj2ohLrmU2SMekP4HKlolC7qifn7oQUXFgzMH/ewdTqYvgtZqbSdPMQ0mVB3CjFxUqRGNl7UjLJ+7uo5wfgUq0iXaldekBP4vH/eib5DuZCvbWiV0zNAe1k9XICB0Oa8CKQQjCPnlDHqlTB4j0TvFRnvOTi5FofzKseodsyjv89bxChIjEOD7rq/xv9D0QPP+vxb8KcbKsthUstxeys2v/Z7D6CcJpDdn3AsO+fGOzy5nvKVQ6kHKuVIx4T0l2Zj4sCbsrrXcJLaknryyvvYFNB2slgULfaFufI/n0t+KsW+bYv6kaPj3WLfMrcS8wJF87HWVJQlO7q7BHQkRYFL0uW4oYaCb2U3NcMb4JaTouEx8Z7tagnvb/383RCAJdkbbKENlUl0A1ORlzQFzle8AUcAEBoMFlYjMIhDXMPyNJvD85S3S5SkI578RDvjV5VDAHSUd4v0O9K+K+PPJR/5OG/tcaYg4LxuGbIKv7WbxhxdJ3AflA3JUbVJO2kfEepvZ+GzuqG6vcMHAj4K2pMJukX9oGvidJ8nHXZ1M057WfUX0ypg96po5eTqHnzLoSsf/rqqBCV1bK3+CbSLnzxu3Th/OEDx5TRHJoL9mUklAb4S5rKK6Kaqq5FIkXv6AcSXDjSLPhYRjIEXjls6y7be6GNZuOfT4olSypw42qeqoiSuGv7Vgb2F1Dqa1D50F20Ln6JtfT7RnEB6pp+qI7fPpGS5D3aNjiUVrdEWR4cQREb1hhN1DfjTUkeHYT17WYLh4tAz43MtxwT58mrIHeASqWU0xh0vClppv3+N5RftGXs8Weu7annuhOmRpoQrqHm7nrLRD0edQrKTVCTyOcpvmSEpwi6uUnm2HKYYg68pVj6tduQJDTF0ZwyFh8gAetISQDCDJq3mSbRp6C4oEOeM/+IhZwLGbKGfoeMm71TyP7EXRBumLJ8L1Qb7FuRHfBcM5TIee6aYP5QMBh4E6L3GqZbdG/DFf/P0bzd+MyuSC/5zRUoV4uql5Mv6m2He/bVZRyapr5ZKoTOG4/fYC4fP4+8a7hTmTg+c44x6VuKLEbLRcUgT7yAxk/3YAVGmCq1BI8Z+NzSFBN/jXR/73ux9053AO6OSgI/M/fSERIE3ngx82p0wRuDe1PKDFioGgzMurKUnsHXxUjsW5fe4i4Gi91+vI7ajwRGuMGkTizNrVoyMUGzvT/f2Pg9C/EHQwvaVUVtB2tOCBXujdjuMer6tyi8EtK4VA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB8254.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(366016)(7416014)(376014)(52116014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: vK+Mk/UGUtB9U/ZtMd7Qb2sliax9p+Saqip6YH4gkeo3ax6kna3dJ62LmagXXjk3pEowwYElwlv84SpM9/h4DG9Qtjsso83TKR6HikBX8GpU0Fis8XVj7g10lm3c7yHvGkPtXfKUSBxH/F+GZAIQszgZu/Cy2nSGL3R0Cux3LZzwQwphZOuaC1ixDzg7v/XLiPEORAy6kKLd05BWSIApZDmlQOxBMEyH0MluCLnsfcT78H1rQR54dmGL3Ut9BEHyTBj+VUWDJDEgDtT+ZfJatRDdAr2JDf4bsR0zMDXbRd2B+8Pi8l2NJNSh+3/EWCDKJhw5kO4Qkqk13EewdCPv2YlRoIFgG48a4wksJ2YdPII7Y+FC90Nie0FM6Bv4KfUsJnWLdz8PA1hlmfvrQI+V0tcU2BGgJE8FhfZLsi71wMahdMQOk9SQyuYgJ7ceZKejW7qZQ99gC9YAvorsp8hDwmtNRtBVNUi9lYR8P2GC7RizXeJIyteqeLH/EJ91yKUZKj7dD1EMFLs96ietGZBxTnguGOHpScOShxidQkkbmuFnC+yIn5KGX0C1I0QmU/vjS8BHv/p4MyCusA4GS4OLpcUqR5HJx5SKjwC16BdkaEtaL/+Mg6hRIcu9lJ3DMKqokMjFnlBG0MzPPBgRzyd1vSQpvEEVoHfFngzym/sLtkJpK14k62ga56Gv0Xxx+CccxNlQBCldjqxmdio5InA/xZNHXvkDJBg+dW5yDR+JvSRYmM3lKJN6DvkZYXVhAULEVCT7RZimsImVacGtyLE2BQViZEo4lhIz6eFVn1wKumh+PikE8u8z2QvYMriTAsddbDC5L7cS3Md84OnXzc1DAh8p1KAC4zebv5iQWXI4ip7o7MFmJ0gIZjp+kM2zrhKwx1XV5YxxyCuuhYh2/Z4gG7XuqkJ2o3zzTzc12WvIihYLK4L94EOJxnvEPXbEGRPiaaC7ON+bZxbYoFsKqp6A3PLCEf8Exg7Ba/U2yV9owUhA7nzMUcNsohIh5TwKPE7+mSVhhBZVDxTtV6LElY7iDS90ErzPVWxTPm5btfKN0RU+ZleF1q0+xMMk9xGXVadgBxO5QIj2UD7Z5UqB7Dzo+4IPRaMZIRWCUZH7DBEbzMgosAF3GeOlNF+x2QvUyveeNbRgNgZwNYk8hxxwZP3QYg7Vcg1NSrlX37gRQxv3QVOENAjlnwiCQXz1HATKJmsZdCK4UNSHEQedSf5rT1onb5Aj/hV2h92QNivK4+1pfRUvUJNSzNkh0A53C79SarTyMfwfTZbecyBQMyhUWnxCetT/wJwLoGZvd47bGFTKLot5mYhCYX6frLv7qGeyK/nIWj6ewnao3cNALvNGhu2k2yErYPQQHUlRSQKAboJ5ATM6LYMqhw82sQ7WcCzypUVPty4CXMTc/utKgZ+DeJGa956V0U+bBjix3OiXiREfu9xN0loWolY8NQAFmGaA5Z7FrzGEUn+ygD3h2GVzYh4o1p8omkAIFDjCoAg3WlquH9TZoDNuPIijMTQVo0q/RwoV9DIoNkSQ6Ys8CXQfQ87mnI03LwyakHqs6NJLwF8RfrQJR02/qAzD6RvqwzvVEohx X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6de516a7-390a-45dd-2375-08dca7c77b54 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8254.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jul 2024 07:50:39.0933 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 6BRMS5lNvf56Wg4Nj+iZGusFE0O3AxhGqEdpxeyG9rT8gWgpTURxvxxBT3VyUoYeYgmvfUgqV2c5zf6adZJu4g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB6912 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240719_005059_464430_4D61EB15 X-CRM114-Status: GOOD ( 18.43 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org For format H264 and HEVC, the firmware can report the parsed profile idc and level idc to driver, there information may be useful. Implement the H264 and HEVC profile and level control to report them. Signed-off-by: Ming Qian --- drivers/media/platform/amphion/vdec.c | 60 +++++++++++++ drivers/media/platform/amphion/vpu_defs.h | 1 + drivers/media/platform/amphion/vpu_helpers.c | 93 ++++++++++++++++++++ drivers/media/platform/amphion/vpu_helpers.h | 5 ++ drivers/media/platform/amphion/vpu_malone.c | 3 +- 5 files changed, 161 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/amphion/vdec.c b/drivers/media/platform/amphion/vdec.c index ca8f7319503a..e414d1b56133 100644 --- a/drivers/media/platform/amphion/vdec.c +++ b/drivers/media/platform/amphion/vdec.c @@ -232,6 +232,36 @@ static int vdec_ctrl_init(struct vpu_inst *inst) V4L2_CID_MPEG_VIDEO_DEC_DISPLAY_DELAY_ENABLE, 0, 1, 1, 0); + v4l2_ctrl_new_std_menu(&inst->ctrl_handler, NULL, + V4L2_CID_MPEG_VIDEO_H264_PROFILE, + V4L2_MPEG_VIDEO_H264_PROFILE_MULTIVIEW_HIGH, + ~((1 << V4L2_MPEG_VIDEO_H264_PROFILE_BASELINE) | + (1 << V4L2_MPEG_VIDEO_H264_PROFILE_MAIN) | + (1 << V4L2_MPEG_VIDEO_H264_PROFILE_EXTENDED) | + (1 << V4L2_MPEG_VIDEO_H264_PROFILE_HIGH) | + (1 << V4L2_MPEG_VIDEO_H264_PROFILE_MULTIVIEW_HIGH) | + (1 << V4L2_MPEG_VIDEO_H264_PROFILE_STEREO_HIGH)), + V4L2_MPEG_VIDEO_H264_PROFILE_BASELINE); + + v4l2_ctrl_new_std_menu(&inst->ctrl_handler, NULL, + V4L2_CID_MPEG_VIDEO_H264_LEVEL, + V4L2_MPEG_VIDEO_H264_LEVEL_6_2, + 0, + V4L2_MPEG_VIDEO_H264_LEVEL_4_0); + + v4l2_ctrl_new_std_menu(&inst->ctrl_handler, NULL, + V4L2_CID_MPEG_VIDEO_HEVC_PROFILE, + V4L2_MPEG_VIDEO_HEVC_PROFILE_MAIN_10, + ~((1 << V4L2_MPEG_VIDEO_HEVC_PROFILE_MAIN) | + (1 << V4L2_MPEG_VIDEO_HEVC_PROFILE_MAIN_10)), + V4L2_MPEG_VIDEO_HEVC_PROFILE_MAIN); + + v4l2_ctrl_new_std_menu(&inst->ctrl_handler, NULL, + V4L2_CID_MPEG_VIDEO_HEVC_LEVEL, + V4L2_MPEG_VIDEO_HEVC_LEVEL_6_2, + 0, + V4L2_MPEG_VIDEO_HEVC_LEVEL_4); + ctrl = v4l2_ctrl_new_std(&inst->ctrl_handler, &vdec_ctrl_ops, V4L2_CID_MIN_BUFFERS_FOR_CAPTURE, 1, 32, 1, 2); if (ctrl) @@ -1166,6 +1196,35 @@ static void vdec_clear_slots(struct vpu_inst *inst) } } +static void vdec_update_v4l2_ctrl(struct vpu_inst *inst, u32 id, u32 val) +{ + struct v4l2_ctrl *ctrl = v4l2_ctrl_find(&inst->ctrl_handler, id); + + if (ctrl) + v4l2_ctrl_s_ctrl(ctrl, val); +} + +static void vdec_update_v4l2_profile_level(struct vpu_inst *inst, struct vpu_dec_codec_info *hdr) +{ + switch (inst->out_format.pixfmt) { + case V4L2_PIX_FMT_H264: + case V4L2_PIX_FMT_H264_MVC: + vdec_update_v4l2_ctrl(inst, V4L2_CID_MPEG_VIDEO_H264_PROFILE, + vpu_get_h264_v4l2_profile(hdr->profile_idc)); + vdec_update_v4l2_ctrl(inst, V4L2_CID_MPEG_VIDEO_H264_LEVEL, + vpu_get_h264_v4l2_level(hdr->level_idc)); + break; + case V4L2_PIX_FMT_HEVC: + vdec_update_v4l2_ctrl(inst, V4L2_CID_MPEG_VIDEO_HEVC_PROFILE, + vpu_get_hevc_v4l2_profile(hdr->profile_idc)); + vdec_update_v4l2_ctrl(inst, V4L2_CID_MPEG_VIDEO_HEVC_LEVEL, + vpu_get_hevc_v4l2_level(hdr->level_idc)); + break; + default: + return; + } +} + static void vdec_event_seq_hdr(struct vpu_inst *inst, struct vpu_dec_codec_info *hdr) { struct vdec_t *vdec = inst->priv; @@ -1189,6 +1248,7 @@ static void vdec_event_seq_hdr(struct vpu_inst *inst, struct vpu_dec_codec_info vdec_init_crop(inst); vdec_init_mbi(inst); vdec_init_dcp(inst); + vdec_update_v4l2_profile_level(inst, hdr); if (!vdec->seq_hdr_found) { vdec->seq_tag = vdec->codec_info.tag; if (vdec->is_source_changed) { diff --git a/drivers/media/platform/amphion/vpu_defs.h b/drivers/media/platform/amphion/vpu_defs.h index 428d988cf2f7..606f9d61a265 100644 --- a/drivers/media/platform/amphion/vpu_defs.h +++ b/drivers/media/platform/amphion/vpu_defs.h @@ -134,6 +134,7 @@ struct vpu_dec_codec_info { u32 decoded_height; struct v4l2_fract frame_rate; u32 dsp_asp_ratio; + u32 profile_idc; u32 level_idc; u32 bit_depth_luma; u32 bit_depth_chroma; diff --git a/drivers/media/platform/amphion/vpu_helpers.c b/drivers/media/platform/amphion/vpu_helpers.c index d12310af9ebc..108b75ceb4ae 100644 --- a/drivers/media/platform/amphion/vpu_helpers.c +++ b/drivers/media/platform/amphion/vpu_helpers.c @@ -509,3 +509,96 @@ const char *vpu_codec_state_name(enum vpu_codec_state state) } return ""; } + +struct codec_id_mapping { + u32 id; + u32 v4l2_id; +}; + +static struct codec_id_mapping h264_profiles[] = { + {66, V4L2_MPEG_VIDEO_H264_PROFILE_BASELINE}, + {77, V4L2_MPEG_VIDEO_H264_PROFILE_MAIN}, + {88, V4L2_MPEG_VIDEO_H264_PROFILE_EXTENDED}, + {100, V4L2_MPEG_VIDEO_H264_PROFILE_HIGH}, + {118, V4L2_MPEG_VIDEO_H264_PROFILE_MULTIVIEW_HIGH}, + {128, V4L2_MPEG_VIDEO_H264_PROFILE_STEREO_HIGH} +}; + +static struct codec_id_mapping h264_levels[] = { + {10, V4L2_MPEG_VIDEO_H264_LEVEL_1_0}, + {9, V4L2_MPEG_VIDEO_H264_LEVEL_1B}, + {11, V4L2_MPEG_VIDEO_H264_LEVEL_1_1}, + {12, V4L2_MPEG_VIDEO_H264_LEVEL_1_2}, + {13, V4L2_MPEG_VIDEO_H264_LEVEL_1_3}, + {20, V4L2_MPEG_VIDEO_H264_LEVEL_2_0}, + {21, V4L2_MPEG_VIDEO_H264_LEVEL_2_1}, + {22, V4L2_MPEG_VIDEO_H264_LEVEL_2_2}, + {30, V4L2_MPEG_VIDEO_H264_LEVEL_3_0}, + {31, V4L2_MPEG_VIDEO_H264_LEVEL_3_1}, + {32, V4L2_MPEG_VIDEO_H264_LEVEL_3_2}, + {40, V4L2_MPEG_VIDEO_H264_LEVEL_4_0}, + {41, V4L2_MPEG_VIDEO_H264_LEVEL_4_1}, + {42, V4L2_MPEG_VIDEO_H264_LEVEL_4_2}, + {50, V4L2_MPEG_VIDEO_H264_LEVEL_5_0}, + {51, V4L2_MPEG_VIDEO_H264_LEVEL_5_1}, + {52, V4L2_MPEG_VIDEO_H264_LEVEL_5_2}, + {60, V4L2_MPEG_VIDEO_H264_LEVEL_6_0}, + {61, V4L2_MPEG_VIDEO_H264_LEVEL_6_1}, + {62, V4L2_MPEG_VIDEO_H264_LEVEL_6_2} +}; + +static struct codec_id_mapping hevc_profiles[] = { + {1, V4L2_MPEG_VIDEO_HEVC_PROFILE_MAIN}, + {2, V4L2_MPEG_VIDEO_HEVC_PROFILE_MAIN_10} +}; + +static struct codec_id_mapping hevc_levels[] = { + {30, V4L2_MPEG_VIDEO_HEVC_LEVEL_1}, + {60, V4L2_MPEG_VIDEO_HEVC_LEVEL_2}, + {63, V4L2_MPEG_VIDEO_HEVC_LEVEL_2_1}, + {90, V4L2_MPEG_VIDEO_HEVC_LEVEL_3}, + {93, V4L2_MPEG_VIDEO_HEVC_LEVEL_3_1}, + {120, V4L2_MPEG_VIDEO_HEVC_LEVEL_4}, + {123, V4L2_MPEG_VIDEO_HEVC_LEVEL_4_1}, + {150, V4L2_MPEG_VIDEO_HEVC_LEVEL_5}, + {153, V4L2_MPEG_VIDEO_HEVC_LEVEL_5_1}, + {156, V4L2_MPEG_VIDEO_HEVC_LEVEL_5_2}, + {180, V4L2_MPEG_VIDEO_HEVC_LEVEL_6}, + {183, V4L2_MPEG_VIDEO_HEVC_LEVEL_6_1}, + {186, V4L2_MPEG_VIDEO_HEVC_LEVEL_6_2} +}; + +static u32 vpu_find_v4l2_id(u32 id, struct codec_id_mapping *array, u32 array_sz) +{ + u32 i; + + if (!array || !array_sz) + return 0; + + for (i = 0; i < array_sz; i++) { + if (id == array[i].id) + return array[i].v4l2_id; + } + + return 0; +} + +u32 vpu_get_h264_v4l2_profile(u32 idc) +{ + return vpu_find_v4l2_id(idc, h264_profiles, ARRAY_SIZE(h264_profiles)); +} + +u32 vpu_get_h264_v4l2_level(u32 idc) +{ + return vpu_find_v4l2_id(idc, h264_levels, ARRAY_SIZE(h264_levels)); +} + +u32 vpu_get_hevc_v4l2_profile(u32 idc) +{ + return vpu_find_v4l2_id(idc, hevc_profiles, ARRAY_SIZE(hevc_profiles)); +} + +u32 vpu_get_hevc_v4l2_level(u32 idc) +{ + return vpu_find_v4l2_id(idc, hevc_levels, ARRAY_SIZE(hevc_levels)); +} diff --git a/drivers/media/platform/amphion/vpu_helpers.h b/drivers/media/platform/amphion/vpu_helpers.h index 0eaddb07190d..dc5fb1ca2d33 100644 --- a/drivers/media/platform/amphion/vpu_helpers.h +++ b/drivers/media/platform/amphion/vpu_helpers.h @@ -70,4 +70,9 @@ int vpu_color_get_default(u32 primaries, u32 *ptransfers, u32 *pmatrix, u32 *pfu int vpu_find_dst_by_src(struct vpu_pair *pairs, u32 cnt, u32 src); int vpu_find_src_by_dst(struct vpu_pair *pairs, u32 cnt, u32 dst); + +u32 vpu_get_h264_v4l2_profile(u32 idc); +u32 vpu_get_h264_v4l2_level(u32 idc); +u32 vpu_get_hevc_v4l2_profile(u32 idc); +u32 vpu_get_hevc_v4l2_level(u32 idc); #endif diff --git a/drivers/media/platform/amphion/vpu_malone.c b/drivers/media/platform/amphion/vpu_malone.c index 4769c053c6c2..5c6b2a841b6f 100644 --- a/drivers/media/platform/amphion/vpu_malone.c +++ b/drivers/media/platform/amphion/vpu_malone.c @@ -889,7 +889,8 @@ static void vpu_malone_unpack_seq_hdr(struct vpu_rpc_event *pkt, info->frame_rate.numerator = 1000; info->frame_rate.denominator = pkt->data[8]; info->dsp_asp_ratio = pkt->data[9]; - info->level_idc = pkt->data[10]; + info->profile_idc = (pkt->data[10] >> 8) & 0xff; + info->level_idc = pkt->data[10] & 0xff; info->bit_depth_luma = pkt->data[13]; info->bit_depth_chroma = pkt->data[14]; info->chroma_fmt = pkt->data[15];