From patchwork Fri Jul 29 03:51:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Irui Wang X-Patchwork-Id: 12931898 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 EC020C19F2A for ; Fri, 29 Jul 2022 03:51:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234133AbiG2Dvo (ORCPT ); Thu, 28 Jul 2022 23:51:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49814 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234127AbiG2Dvl (ORCPT ); Thu, 28 Jul 2022 23:51:41 -0400 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE7D07CB5B; Thu, 28 Jul 2022 20:51:39 -0700 (PDT) X-UUID: 7b8fb5f6b6054ae9b4b432e5ec5e4d5b-20220729 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.8,REQID:a50d1b30-8045-4e09-b1df-05fae615385b,OB:0,LO B:0,IP:0,URL:0,TC:0,Content:-5,EDM:0,RT:0,SF:0,FILE:0,RULE:Release_Ham,ACT ION:release,TS:-5 X-CID-META: VersionHash:0f94e32,CLOUDID:d1a6a5d0-841b-4e95-ad42-8f86e18f54fc,C OID:IGNORED,Recheck:0,SF:nil,TC:nil,Content:0,EDM:-3,IP:nil,URL:0,File:nil ,QS:nil,BEC:nil,COL:0 X-UUID: 7b8fb5f6b6054ae9b4b432e5ec5e4d5b-20220729 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 924437438; Fri, 29 Jul 2022 11:51:33 +0800 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by mtkmbs11n1.mediatek.inc (172.21.101.185) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.792.15; Fri, 29 Jul 2022 11:51:31 +0800 Received: from localhost.localdomain (10.17.3.154) by mtkmbs11n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.792.15 via Frontend Transport; Fri, 29 Jul 2022 11:51:30 +0800 From: Irui Wang To: Hans Verkuil , , Rob Herring , Mauro Carvalho Chehab , Matthias Brugger , Alexandre Courbot , Tiffany Lin , Andrew-CT Chen , Tzung-Bi Shih , Tomasz Figa , CC: Maoguang Meng , Longfei Wang , Yunfei Dong , Irui Wang , , , , , , Subject: [PATCH v5, 0/8] Support H264 multi-core encoder on MT8195 Date: Fri, 29 Jul 2022 11:51:21 +0800 Message-ID: <20220729035129.3634-1-irui.wang@mediatek.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org MT8195 has two H264 encoder hardware, named core0 and core1, this two cores can encode two input frames separately at the same time to achieve higher performance. This series of patches are used to enable the two H264 encoder cores, the difference between encoding process before and after enable two cores is just like as below: As-Is: Synchronous V4L2_VIDIOC_QBUF#0 --> device_run(triger encoder) --> wait encoder IRQ --> encoding done with result --> job_finish V4l2_VIDIOC_QBUF#1 --> device_run(triger encoder) --> wait encoder IRQ --> encoding done with result --> job_finish ... To-Be: Asynchronous V4L2_VIDIOC_QBUF#0 --> device_run(triger encoder) --> job_finish ..V4l2_VIDIOC_QBUF#1 --> device_run(triger encoder) --> job_finish (venc core0 may encode done here, done the encoding result to client) V4L2_VIDIOC_QBUF#2 --> device_run(triger encoder) --> job_finish. --- changes compared with v4: - reabse to the newer linux media stage tree. - remove "mediatek,venc-multi-core" property since sub-device can be probed by of_platform_populate api directly. - some modifications for patch v4's review comments. changes compared with v3: - rebase to the newer linux media stage. - add a capability to indicate scp firmware support multi-core. - probe core0 as main device, core1 as sub-device. changes compared with v2: - update venc core dt-bindings, add two new properties for current usage. - parse venc multi_core mode from device tree. - rebase to the newer linux media stage. changes compared with v1: - of_platform_populate was used in place of the component framework. - new yaml file for venc cores. - some modifications for patch v1's review comments. --- Irui Wang (8): dt-bindings: media: mediatek: vcodec: Adds encoder cores dt-bindings for mt8195 media: mediatek: vcodec: Enable venc dual core usage media: mediatek: vcodec: Refactor venc power manage function media: mediatek: vcodec: Add more extra processing for multi-core encoding media: mediatek: vcodec: Add venc power on/off function media: mediatek: vcodec: Refactor encoder clock on/off function media: mediatek: vcodec: Add multi-core encoding process media: mediatek: vcodec: Return encoding result in asynchronous mode .../media/mediatek,vcodec-encoder-core.yaml | 218 ++++++++++++++++ .../media/mediatek,vcodec-encoder.yaml | 1 - .../media/platform/mediatek/vcodec/Makefile | 4 +- .../platform/mediatek/vcodec/mtk_vcodec_drv.h | 28 +- .../platform/mediatek/vcodec/mtk_vcodec_enc.c | 113 ++++++-- .../platform/mediatek/vcodec/mtk_vcodec_enc.h | 11 +- .../mediatek/vcodec/mtk_vcodec_enc_drv.c | 44 +++- .../mediatek/vcodec/mtk_vcodec_enc_hw.c | 156 +++++++++++ .../mediatek/vcodec/mtk_vcodec_enc_hw.h | 34 +++ .../mediatek/vcodec/mtk_vcodec_enc_pm.c | 178 +++++++++++-- .../mediatek/vcodec/mtk_vcodec_enc_pm.h | 11 +- .../mediatek/vcodec/mtk_vcodec_util.c | 19 ++ .../mediatek/vcodec/mtk_vcodec_util.h | 3 + .../mediatek/vcodec/venc/venc_h264_if.c | 243 ++++++++++++++---- .../mediatek/vcodec/venc/venc_vp8_if.c | 3 +- .../platform/mediatek/vcodec/venc_drv_if.c | 75 ++++-- .../platform/mediatek/vcodec/venc_drv_if.h | 6 + .../platform/mediatek/vcodec/venc_vpu_if.c | 9 +- .../platform/mediatek/vcodec/venc_vpu_if.h | 3 +- 19 files changed, 1028 insertions(+), 131 deletions(-) create mode 100644 Documentation/devicetree/bindings/media/mediatek,vcodec-encoder-core.yaml create mode 100644 drivers/media/platform/mediatek/vcodec/mtk_vcodec_enc_hw.c create mode 100644 drivers/media/platform/mediatek/vcodec/mtk_vcodec_enc_hw.h