From patchwork Tue Apr 4 08:10:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?WXVuZmVpIERvbmcgKOiRo+S6kemjnik=?= X-Patchwork-Id: 78907 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2861847vqo; Tue, 4 Apr 2023 01:25:35 -0700 (PDT) X-Google-Smtp-Source: AKy350ZbnUP3Pa5jWbjlbZDaPkN2AbP929MY3B7Uzip7bCN9WYUjKw5eUucB5O8UTmJAYEOQNkBd X-Received: by 2002:a17:90b:4d8c:b0:23d:31c3:c9a4 with SMTP id oj12-20020a17090b4d8c00b0023d31c3c9a4mr1924472pjb.26.1680596735301; Tue, 04 Apr 2023 01:25:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680596735; cv=none; d=google.com; s=arc-20160816; b=Zcd56q+vyciJGdCKm34FQn+NkTXHFRec3Wgv39mw923RCEd8U9m438NciMzhCjOqCV cxOPUvG80t8iPJtXvnaGdc4wg6JCin5JUsVOU4xFPANcMQxXVureECj3qlF/FQWndcIw Vby1JWpnMJg4rcsjI7aUvJ3ub/g+s2eWMbbVoMQtXo7EjzgQ5LGycmfBotlVXEzekvpU z2J0XY3LsZODNPClD3uvdyx1qsxjkalLJWws/4PrADLikEtmVgUTBPTxrBOTbsJzay0n 9hR5G/RQkg1w1h/dDo7npRyzhteeUWcbBpVHLCEhSrx7T1aDCh6Z7JBvdLxks/wbZyfc uMPA== 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 :dkim-signature; bh=IJOiME8dMOPVoTI1ck1Te/eVNRuI+6VwnTkMEeScbMk=; b=TUpZlxpHKXEOQ+KykrXu9/jAjWDTZ8gxFIbPhgsocrzbQSfCxWm04ceCvakPMrltWU SzFR2ieXNzTUEqwJ0mdVCmobJ4w/+tuOF+C4Ak5QIv3BD7yOmyM4SzpMRiaZsj0S6WLQ T5yY2Y+sSJl5Z5Afjd5EranGaLI1dbW4jKwRwP/SGgcSOb8ez9JVW5ALk7YEPn03gUZ2 rcESd/9hisqsabyypqpCuND0PraP+o8qH9jbui+9myiysC4Q41U9XU/Up8cXsaz2rcpM buY/enehBl93oYajEjl3756jcAVJCIRlj6gCdSlhBgbsCzi+XWEX2fXhZ77Kkv+4UbE6 xV6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b="jtGA/Uo+"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lp9-20020a17090b4a8900b002400ccce5fesi10095043pjb.68.2023.04.04.01.25.22; Tue, 04 Apr 2023 01:25:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b="jtGA/Uo+"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234071AbjDDILY (ORCPT + 99 others); Tue, 4 Apr 2023 04:11:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43984 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233473AbjDDILT (ORCPT ); Tue, 4 Apr 2023 04:11:19 -0400 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 415261BD4; Tue, 4 Apr 2023 01:11:12 -0700 (PDT) X-UUID: 3f3e98e4d2c011eda9a90f0bb45854f4-20230404 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=IJOiME8dMOPVoTI1ck1Te/eVNRuI+6VwnTkMEeScbMk=; b=jtGA/Uo+gsUBz6Dei8S4ah+0ttnKAc2SfTH9wYx5hNAKcTEYd9En5ioLUUNDdjVNW80WeUtOhFuep0vWD+DSSze6vUnYJILKPPrZr4VJxJWzLvcve8TxTYlZQF+8lT2M+WZXsWvJ71SY5F/qjpuLv7QYmdzxkG9lsdN/vfdIPnQ=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.22,REQID:a0087220-223f-4d92-8cad-cfe572104132,IP:0,U RL:0,TC:0,Content:-25,EDM:0,RT:0,SF:95,FILE:0,BULK:0,RULE:Release_Ham,ACTI ON:release,TS:70 X-CID-INFO: VERSION:1.1.22,REQID:a0087220-223f-4d92-8cad-cfe572104132,IP:0,URL :0,TC:0,Content:-25,EDM:0,RT:0,SF:95,FILE:0,BULK:0,RULE:Spam_GS981B3D,ACTI ON:quarantine,TS:70 X-CID-META: VersionHash:120426c,CLOUDID:7388552a-564d-42d9-9875-7c868ee415ec,B ulkID:230404161107S59K7EBT,BulkQuantity:0,Recheck:0,SF:38|29|28|17|19|48,T C:nil,Content:0,EDM:-3,IP:nil,URL:11|1,File:nil,Bulk:nil,QS:nil,BEC:nil,CO L:0,OSI:0,OSA:0,AV:0 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-UUID: 3f3e98e4d2c011eda9a90f0bb45854f4-20230404 Received: from mtkmbs13n1.mediatek.inc [(172.21.101.193)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 417048511; Tue, 04 Apr 2023 16:11:05 +0800 Received: from mtkmbs13n1.mediatek.inc (172.21.101.193) by mtkmbs10n2.mediatek.inc (172.21.101.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.25; Tue, 4 Apr 2023 16:11:04 +0800 Received: from mhfsdcap04.gcn.mediatek.inc (10.17.3.154) by mtkmbs13n1.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.25 via Frontend Transport; Tue, 4 Apr 2023 16:11:03 +0800 From: Yunfei Dong To: Yunfei Dong , Chen-Yu Tsai , Nicolas Dufresne , Hans Verkuil , AngeloGioacchino Del Regno , Benjamin Gaignard , =?utf-8?q?N=C3=ADcolas?= =?utf-8?q?_F_=2E_R_=2E_A_=2E_Prado?= CC: Matthias Brugger , Hsin-Yi Wang , Fritz Koenig , Daniel Vetter , Steve Cho , , , , , , Subject: [PATCH v4,1/8] media: mediatek: vcodec: Add debugfs interface to get debug information Date: Tue, 4 Apr 2023 16:10:55 +0800 Message-ID: <20230404081102.30713-2-yunfei.dong@mediatek.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230404081102.30713-1-yunfei.dong@mediatek.com> References: <20230404081102.30713-1-yunfei.dong@mediatek.com> MIME-Version: 1.0 X-MTK: N X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, T_SPF_TEMPERROR,UNPARSEABLE_RELAY autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1762233402027592806?= X-GMAIL-MSGID: =?utf-8?q?1762233402027592806?= This will be useful when debugging specific issues related to kernel in running status. Signed-off-by: Yunfei Dong Reviewed-by: AngeloGioacchino Del Regno --- .../media/platform/mediatek/vcodec/Makefile | 6 ++++ .../mediatek/vcodec/mtk_vcodec_dbgfs.c | 33 +++++++++++++++++++ .../mediatek/vcodec/mtk_vcodec_dbgfs.h | 32 ++++++++++++++++++ .../mediatek/vcodec/mtk_vcodec_dec_drv.c | 2 ++ .../platform/mediatek/vcodec/mtk_vcodec_drv.h | 4 +++ 5 files changed, 77 insertions(+) create mode 100644 drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.c create mode 100644 drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.h diff --git a/drivers/media/platform/mediatek/vcodec/Makefile b/drivers/media/platform/mediatek/vcodec/Makefile index 93e7a343b5b0..f6b750cf7077 100644 --- a/drivers/media/platform/mediatek/vcodec/Makefile +++ b/drivers/media/platform/mediatek/vcodec/Makefile @@ -44,3 +44,9 @@ endif ifneq ($(CONFIG_VIDEO_MEDIATEK_VCODEC_SCP),) mtk-vcodec-common-y += mtk_vcodec_fw_scp.o endif + +ifneq ($(CONFIG_DEBUG_FS),) +obj-$(CONFIG_VIDEO_MEDIATEK_VCODEC) += mtk-vcodec-dbgfs.o + +mtk-vcodec-dbgfs-y := mtk_vcodec_dbgfs.o +endif \ No newline at end of file diff --git a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.c b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.c new file mode 100644 index 000000000000..fb9edd379af5 --- /dev/null +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.c @@ -0,0 +1,33 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2023 MediaTek Inc. + * Author: Yunfei Dong + */ + +#include + +#include "mtk_vcodec_dbgfs.h" +#include "mtk_vcodec_drv.h" +#include "mtk_vcodec_util.h" + +void mtk_vcodec_dbgfs_init(struct mtk_vcodec_dev *vcodec_dev) +{ + struct dentry *vcodec_root; + + vcodec_dev->dbgfs.vcodec_root = debugfs_create_dir("vcodec-dec", NULL); + if (IS_ERR(vcodec_dev->dbgfs.vcodec_root)) + dev_err(&vcodec_dev->plat_dev->dev, "create vcodec dir err:%d\n", + IS_ERR(vcodec_dev->dbgfs.vcodec_root)); + + vcodec_root = vcodec_dev->dbgfs.vcodec_root; +} +EXPORT_SYMBOL_GPL(mtk_vcodec_dbgfs_init); + +void mtk_vcodec_dbgfs_deinit(struct mtk_vcodec_dev *vcodec_dev) +{ + debugfs_remove_recursive(vcodec_dev->dbgfs.vcodec_root); +} +EXPORT_SYMBOL_GPL(mtk_vcodec_dbgfs_deinit); + +MODULE_LICENSE("GPL v2"); +MODULE_DESCRIPTION("Mediatek video codec driver"); diff --git a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.h b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.h new file mode 100644 index 000000000000..5eec2211cbbe --- /dev/null +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.h @@ -0,0 +1,32 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (c) 2023 MediaTek Inc. + * Author: Yunfei Dong + */ + +#ifndef __MTK_VCODEC_DBGFS_H__ +#define __MTK_VCODEC_DBGFS_H__ + +struct mtk_vcodec_dev; + +/** + * struct mtk_vcodec_dbgfs - dbgfs information + * @vcodec_root: vcodec dbgfs entry + */ +struct mtk_vcodec_dbgfs { + struct dentry *vcodec_root; +}; + +#if defined(CONFIG_DEBUG_FS) +void mtk_vcodec_dbgfs_init(struct mtk_vcodec_dev *vcodec_dev); +void mtk_vcodec_dbgfs_deinit(struct mtk_vcodec_dev *vcodec_dev); +#else +static inline void mtk_vcodec_dbgfs_init(struct mtk_vcodec_dev *vcodec_dev) +{ +} + +static inline void mtk_vcodec_dbgfs_deinit(struct mtk_vcodec_dev *vcodec_dev) +{ +} +#endif +#endif diff --git a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_drv.c b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_drv.c index 174a6eec2f54..de29b1fb0436 100644 --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_drv.c +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_drv.c @@ -431,6 +431,7 @@ static int mtk_vcodec_probe(struct platform_device *pdev) mtk_v4l2_debug(0, "media registered as /dev/media%d", vfd_dec->minor); } + mtk_vcodec_dbgfs_init(dev); mtk_v4l2_debug(0, "decoder registered as /dev/video%d", vfd_dec->minor); return 0; @@ -505,6 +506,7 @@ static int mtk_vcodec_dec_remove(struct platform_device *pdev) if (dev->vfd_dec) video_unregister_device(dev->vfd_dec); + mtk_vcodec_dbgfs_deinit(dev); v4l2_device_unregister(&dev->v4l2_dev); if (!dev->vdec_pdata->is_subdev_supported) pm_runtime_disable(dev->pm.dev); diff --git a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_drv.h b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_drv.h index 9acab54fd650..a7e8bb3608ac 100644 --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_drv.h +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_drv.h @@ -16,6 +16,7 @@ #include #include +#include "mtk_vcodec_dbgfs.h" #include "mtk_vcodec_util.h" #include "vdec_msg_queue.h" @@ -470,6 +471,7 @@ struct mtk_vcodec_enc_pdata { * @dec_active_cnt: used to mark whether need to record register value * @vdec_racing_info: record register value * @dec_racing_info_mutex: mutex lock used for inner racing mode + * @dbgfs: debug log related information */ struct mtk_vcodec_dev { struct v4l2_device v4l2_dev; @@ -520,6 +522,8 @@ struct mtk_vcodec_dev { u32 vdec_racing_info[132]; /* Protects access to vdec_racing_info data */ struct mutex dec_racing_info_mutex; + + struct mtk_vcodec_dbgfs dbgfs; }; static inline struct mtk_vcodec_ctx *fh_to_ctx(struct v4l2_fh *fh) From patchwork Tue Apr 4 08:10:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?WXVuZmVpIERvbmcgKOiRo+S6kemjnik=?= X-Patchwork-Id: 78912 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2862315vqo; Tue, 4 Apr 2023 01:26:34 -0700 (PDT) X-Google-Smtp-Source: AKy350a9W0Vvl7ks8F879zdDJW+E/p6MiEGDjfOBavWd6dpQnuN0Y4EyGJBHK9rIozGZFz5IZlpm X-Received: by 2002:a17:90b:33ce:b0:233:a6b7:3770 with SMTP id lk14-20020a17090b33ce00b00233a6b73770mr2061274pjb.14.1680596794489; Tue, 04 Apr 2023 01:26:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680596794; cv=none; d=google.com; s=arc-20160816; b=hYkz7rBpTHM/pXVfKV/Au0d19Akwck0ZIhWJ08rlE/AvtH+Ildz6Z0wHBZIys3YKtb 8iGAcOZW5xRw4IJK7zjM8BbHTQSqTZkyoBky4WR4/+xfhk27w6ZaUxAhH3eBkuPudJPz fDCZmr+sLbFovbyVxNEhJrWpzrsSU/J0VvdjsjEh0hv9EvqRb7lH4AcaLCHCcok0jsTK HDwflk2935kZm7UL+U95W0I803nJQsQIzIStVAWYo8T375T03GyQO+lpwnxOf77IpFeE 59I2CYnyK29q2Lmxs6cZKlAvgrAH7sOn+JmEahBhdI/WMpuwmNaAKBlEtMZkGoqjV+2l M/UA== 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 :dkim-signature; bh=Mi6bDKZ6UsCy6bGsJ6TOr2TnUx3aUYpyfS8ZUumFnpE=; b=EWo8m27jWopItRM7gXfEGaD23P3nTPSmoI/wLoSL0byumIMzHDw02rGMpTVKemcIzq dGKT6+a6PweKN4xyD0NQsNJ4DYdFQzy2JNDZZRzZtKrFwZwGk4ZiPCfU0BFmPXzcyGNw KuE4uWbsus3yeAs3b+IYw0/4odcbRI80NCISLaUoFL2JctidmG0seby8j85iIpqZQltG wM/fAQlxLSARnI21MkhHabFjAaSHErZXDbN1sAwXiSsS21ZQFOd7oV8WnXzo8FBpUGfF Xsb36nPg0AlF2iGj+PvnmDqL7mw9lW+TqxjbgbFugO3sO1+mNI7jWYwmsVZQ/ilhLLt6 39bA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=p7QStzpC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x6-20020a17090a8a8600b002339ac5a127si14486083pjn.139.2023.04.04.01.26.22; Tue, 04 Apr 2023 01:26:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=p7QStzpC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234095AbjDDILl (ORCPT + 99 others); Tue, 4 Apr 2023 04:11:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44000 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233935AbjDDILU (ORCPT ); Tue, 4 Apr 2023 04:11:20 -0400 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0EE7B1BE6; Tue, 4 Apr 2023 01:11:14 -0700 (PDT) X-UUID: 40312e06d2c011edb6b9f13eb10bd0fe-20230404 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=Mi6bDKZ6UsCy6bGsJ6TOr2TnUx3aUYpyfS8ZUumFnpE=; b=p7QStzpCpIlBttQuyparTiV5SB2UkkzYcPrYUapHF3yzUKIOIf15QRAIb72ZPKAiLs4XD8aM/SLrcLbiyfpv0fOzh9Vu3i+kCTXsl+tBl6MSfaeVbUXwXcl3HhON3mwwWMz1q+lfikiC8QMddZGKTPjDhbwDHhC4XEzawIXJ7Go=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.22,REQID:91a2093a-41c1-49cf-b5af-fb29e97ce0be,IP:0,U RL:0,TC:0,Content:-25,EDM:-30,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACT ION:release,TS:-55 X-CID-META: VersionHash:120426c,CLOUDID:e7b236b5-beed-4dfc-bd9c-e1b22fa6ccc4,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:2,IP:nil,UR L:0,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV:0 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-UUID: 40312e06d2c011edb6b9f13eb10bd0fe-20230404 Received: from mtkmbs13n2.mediatek.inc [(172.21.101.108)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 60458757; Tue, 04 Apr 2023 16:11:07 +0800 Received: from mtkmbs13n1.mediatek.inc (172.21.101.193) 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.1118.25; Tue, 4 Apr 2023 16:11:05 +0800 Received: from mhfsdcap04.gcn.mediatek.inc (10.17.3.154) by mtkmbs13n1.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.25 via Frontend Transport; Tue, 4 Apr 2023 16:11:04 +0800 From: Yunfei Dong To: Yunfei Dong , Chen-Yu Tsai , Nicolas Dufresne , Hans Verkuil , AngeloGioacchino Del Regno , Benjamin Gaignard , =?utf-8?q?N=C3=ADcolas?= =?utf-8?q?_F_=2E_R_=2E_A_=2E_Prado?= CC: Matthias Brugger , Hsin-Yi Wang , Fritz Koenig , Daniel Vetter , Steve Cho , , , , , , Subject: [PATCH v4,2/8] media: mediatek: vcodec: Add debug params to control different log level Date: Tue, 4 Apr 2023 16:10:56 +0800 Message-ID: <20230404081102.30713-3-yunfei.dong@mediatek.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230404081102.30713-1-yunfei.dong@mediatek.com> References: <20230404081102.30713-1-yunfei.dong@mediatek.com> MIME-Version: 1.0 X-MTK: N X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS, UNPARSEABLE_RELAY autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1762233464619639743?= X-GMAIL-MSGID: =?utf-8?q?1762233464619639743?= Add parameter mtk_vcodec_dbg to open each codec log. Add parameter mtk_v4l2_dbg_level to open each instance log according to the parameter value. Signed-off-by: Yunfei Dong Reviewed-by: AngeloGioacchino Del Regno --- .../mediatek/vcodec/mtk_vcodec_dbgfs.c | 2 ++ .../mediatek/vcodec/mtk_vcodec_util.c | 8 ++++++ .../mediatek/vcodec/mtk_vcodec_util.h | 26 ++++++++++++++++--- 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.c b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.c index fb9edd379af5..b5093e4e4aa2 100644 --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.c +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.c @@ -20,6 +20,8 @@ void mtk_vcodec_dbgfs_init(struct mtk_vcodec_dev *vcodec_dev) IS_ERR(vcodec_dev->dbgfs.vcodec_root)); vcodec_root = vcodec_dev->dbgfs.vcodec_root; + debugfs_create_x32("mtk_v4l2_dbg_level", 0644, vcodec_root, &mtk_v4l2_dbg_level); + debugfs_create_x32("mtk_vcodec_dbg", 0644, vcodec_root, &mtk_vcodec_dbg); } EXPORT_SYMBOL_GPL(mtk_vcodec_dbgfs_init); diff --git a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_util.c b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_util.c index ace78c4b5b9e..f214e6f67005 100644 --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_util.c +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_util.c @@ -13,6 +13,14 @@ #include "mtk_vcodec_drv.h" #include "mtk_vcodec_util.h" +#if defined(CONFIG_DEBUG_FS) +int mtk_vcodec_dbg; +EXPORT_SYMBOL(mtk_vcodec_dbg); + +int mtk_v4l2_dbg_level; +EXPORT_SYMBOL(mtk_v4l2_dbg_level); +#endif + void __iomem *mtk_vcodec_get_reg_addr(struct mtk_vcodec_ctx *data, unsigned int reg_idx) { diff --git a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_util.h b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_util.h index 71956627a0e2..587aa817e7f4 100644 --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_util.h +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_util.h @@ -35,15 +35,35 @@ struct mtk_vcodec_dev; pr_err("[MTK_VCODEC][ERROR][%d]: " fmt "\n", \ ((struct mtk_vcodec_ctx *)(h)->ctx)->id, ##args) +#if defined(CONFIG_DEBUG_FS) +extern int mtk_v4l2_dbg_level; +extern int mtk_vcodec_dbg; -#define mtk_v4l2_debug(level, fmt, args...) pr_debug(fmt, ##args) +#define mtk_v4l2_debug(level, fmt, args...) \ + do { \ + if (mtk_v4l2_dbg_level >= level) \ + pr_debug("[MTK_V4L2] %s, %d: " fmt "\n", \ + __func__, __LINE__, ##args); \ + } while (0) -#define mtk_v4l2_debug_enter() mtk_v4l2_debug(3, "+") -#define mtk_v4l2_debug_leave() mtk_v4l2_debug(3, "-") +#define mtk_vcodec_debug(h, fmt, args...) \ + do { \ + if (mtk_vcodec_dbg) \ + dev_dbg(&(((struct mtk_vcodec_ctx *)(h)->ctx)->dev->plat_dev->dev), \ + "[MTK_VCODEC][%d]: %s, %d " fmt "\n", \ + ((struct mtk_vcodec_ctx *)(h)->ctx)->id, \ + __func__, __LINE__, ##args); \ + } while (0) +#else +#define mtk_v4l2_debug(level, fmt, args...) pr_debug(fmt, ##args) #define mtk_vcodec_debug(h, fmt, args...) \ pr_debug("[MTK_VCODEC][%d]: " fmt "\n", \ ((struct mtk_vcodec_ctx *)(h)->ctx)->id, ##args) +#endif + +#define mtk_v4l2_debug_enter() mtk_v4l2_debug(3, "+") +#define mtk_v4l2_debug_leave() mtk_v4l2_debug(3, "-") #define mtk_vcodec_debug_enter(h) mtk_vcodec_debug(h, "+") #define mtk_vcodec_debug_leave(h) mtk_vcodec_debug(h, "-") From patchwork Tue Apr 4 08:10:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?WXVuZmVpIERvbmcgKOiRo+S6kemjnik=?= X-Patchwork-Id: 78909 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2861983vqo; Tue, 4 Apr 2023 01:25:53 -0700 (PDT) X-Google-Smtp-Source: AKy350YplgcBMcXiIK8m8T2etAj13XKs5sIwKz3vrolg1W8x+tIJn9GOaec9nGzM/Lrg9luJdL/R X-Received: by 2002:aa7:9887:0:b0:62e:32c:b579 with SMTP id r7-20020aa79887000000b0062e032cb579mr1374772pfl.12.1680596753036; Tue, 04 Apr 2023 01:25:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680596753; cv=none; d=google.com; s=arc-20160816; b=yB4v8FO7C+WSFdwA9VXZByPX7VIiyBtrY61Zz0OyhgI4jmY29IhDiD/Ed65eyFmBZW u9XgnsnNGNiDMbV/nXo/6yJs9cyQeXIXdIvP5WA1w5xAMT0y3ny5J/sRC8w8Il5dfFBA /lL68HoE+pyQPsXw/B6+IgK3CDVpECdCeYo1xTWP7eY4c6ozbZgwbnlP7fGXCudinZ4T zxSYhVbb8iGWTkg2acjMdXQxENpVlTc4+4EUDCRaNQkk+mHmYT7Acz4uLVBhRiOBwzvF 6jm1eDZ/LxR4239StEAIYqEQrShkMP30Kx1Li90BC6jI+VvOS8nPK8iZ+dkvF3Gyz1mm S6Ew== 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 :dkim-signature; bh=SiqXSE1ikGuN2kujDRHrLA7wvGLfjhDFl2RImkb91go=; b=R06h/yrZDZcU+gLNL40l7fQKJHoxp19R9es8BNtx7XmAzmHanwb0pWxAFGG5CLlEI6 AJN59UOCm/t2dao2ISDjr6QOOUJ4E5IK0rVu3BJVocsXqWkfg1Tj+gh1uRaxYqS0IC3v O6Zr03kbejx4hxFpt77dhEx7dsajPfqb9wBKE1N6axJI533AIkU2zohGQSHBrBus0a63 Zpha7MfOo7FdZVRZDtkDC0lfxjJkrah7/AVGqW9cvpwvkvNso3JF1H/xopvCB2e7LTAK t8Wp2rkcM/pn+4qjuCXCGlcNY//MNzPW0je8JWxZsM2ZjjqlCM3ywxH/BTtzfBpfxGpz r0NQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b="SO6tbhz/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y4-20020aa79424000000b00625ebc3b265si10229116pfo.241.2023.04.04.01.25.39; Tue, 04 Apr 2023 01:25:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b="SO6tbhz/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234099AbjDDILo (ORCPT + 99 others); Tue, 4 Apr 2023 04:11:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44012 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233991AbjDDILU (ORCPT ); Tue, 4 Apr 2023 04:11:20 -0400 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1AB7E1BEF; Tue, 4 Apr 2023 01:11:15 -0700 (PDT) X-UUID: 40c6cd3ad2c011eda9a90f0bb45854f4-20230404 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=SiqXSE1ikGuN2kujDRHrLA7wvGLfjhDFl2RImkb91go=; b=SO6tbhz/mpf/30Wieaajx+aeBiwEflu+XbunP2NeTQt5d3RXV4v7y8bBZ+q72KdnOhxKFtOMJKd2gqlsnxvj7SiGvYOz9piuiD0pTMbxD9DfcZTpNFIfQbQofDN9lsYn1LkRY/BgeBF2quDocD7e9g2XVs9P1QRQH6FItAQkhAY=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.22,REQID:379385c6-dbd2-46e9-b5fe-7ec6c258b5a0,IP:0,U RL:0,TC:0,Content:-5,EDM:0,RT:0,SF:95,FILE:0,BULK:0,RULE:Release_Ham,ACTIO N:release,TS:90 X-CID-INFO: VERSION:1.1.22,REQID:379385c6-dbd2-46e9-b5fe-7ec6c258b5a0,IP:0,URL :0,TC:0,Content:-5,EDM:0,RT:0,SF:95,FILE:0,BULK:0,RULE:Spam_GS981B3D,ACTIO N:quarantine,TS:90 X-CID-META: VersionHash:120426c,CLOUDID:ae88552a-564d-42d9-9875-7c868ee415ec,B ulkID:230404161110V2SGYDN0,BulkQuantity:0,Recheck:0,SF:38|29|28|17|19|48,T C:nil,Content:0,EDM:-3,IP:nil,URL:0,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0 ,OSI:0,OSA:0,AV:0 X-CID-BVR: 0,NGT X-CID-BAS: 0,NGT,0,_ X-UUID: 40c6cd3ad2c011eda9a90f0bb45854f4-20230404 Received: from mtkmbs13n1.mediatek.inc [(172.21.101.193)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 314086191; Tue, 04 Apr 2023 16:11:08 +0800 Received: from mtkmbs13n1.mediatek.inc (172.21.101.193) by mtkmbs10n2.mediatek.inc (172.21.101.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.25; Tue, 4 Apr 2023 16:11:06 +0800 Received: from mhfsdcap04.gcn.mediatek.inc (10.17.3.154) by mtkmbs13n1.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.25 via Frontend Transport; Tue, 4 Apr 2023 16:11:05 +0800 From: Yunfei Dong To: Yunfei Dong , Chen-Yu Tsai , Nicolas Dufresne , Hans Verkuil , AngeloGioacchino Del Regno , Benjamin Gaignard , =?utf-8?q?N=C3=ADcolas?= =?utf-8?q?_F_=2E_R_=2E_A_=2E_Prado?= CC: Matthias Brugger , Hsin-Yi Wang , Fritz Koenig , Daniel Vetter , Steve Cho , , , , , , Subject: [PATCH v4,3/8] media: mediatek: vcodec: Add a debugfs file to get different useful information Date: Tue, 4 Apr 2023 16:10:57 +0800 Message-ID: <20230404081102.30713-4-yunfei.dong@mediatek.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230404081102.30713-1-yunfei.dong@mediatek.com> References: <20230404081102.30713-1-yunfei.dong@mediatek.com> MIME-Version: 1.0 X-MTK: N X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS, UNPARSEABLE_RELAY autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1762233420861752714?= X-GMAIL-MSGID: =?utf-8?q?1762233420861752714?= In oder to get each instance information according to test command, adding one file node "vdec". Can use echo command to set different string value as 'echo -picinfo > vdec'. Signed-off-by: Yunfei Dong --- .../mediatek/vcodec/mtk_vcodec_dbgfs.c | 64 +++++++++++++++++++ .../mediatek/vcodec/mtk_vcodec_dbgfs.h | 31 +++++++++ .../mediatek/vcodec/mtk_vcodec_dec_drv.c | 2 + 3 files changed, 97 insertions(+) diff --git a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.c b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.c index b5093e4e4aa2..4aade064af96 100644 --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.c +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.c @@ -10,6 +10,64 @@ #include "mtk_vcodec_drv.h" #include "mtk_vcodec_util.h" +static ssize_t mtk_vdec_dbgfs_write(struct file *filp, const char __user *ubuf, + size_t count, loff_t *ppos) +{ + struct mtk_vcodec_dev *vcodec_dev = filp->private_data; + struct mtk_vcodec_dbgfs *dbgfs = &vcodec_dev->dbgfs; + int len; + + mutex_lock(&dbgfs->dbgfs_lock); + len = simple_write_to_buffer(dbgfs->dbgfs_buf, sizeof(dbgfs->dbgfs_buf), + ppos, ubuf, count); + mutex_unlock(&dbgfs->dbgfs_lock); + if (len > 0) + return count; + + return len; +} + +static const struct file_operations vdec_fops = { + .open = simple_open, + .write = mtk_vdec_dbgfs_write, +}; + +void mtk_vcodec_dbgfs_create(struct mtk_vcodec_ctx *ctx) +{ + struct mtk_vcodec_dbgfs_inst *dbgfs_inst; + struct mtk_vcodec_dev *vcodec_dev = ctx->dev; + + dbgfs_inst = kzalloc(sizeof(*dbgfs_inst), GFP_KERNEL); + if (!dbgfs_inst) + return; + + list_add_tail(&dbgfs_inst->node, &vcodec_dev->dbgfs.dbgfs_head); + + vcodec_dev->dbgfs.inst_count++; + + dbgfs_inst->inst_id = ctx->id; + dbgfs_inst->vcodec_ctx = ctx; +} +EXPORT_SYMBOL_GPL(mtk_vcodec_dbgfs_create); + +void mtk_vcodec_dbgfs_remove(struct mtk_vcodec_dev *vcodec_dev, int ctx_id) +{ + struct mtk_vcodec_dbgfs_inst *dbgfs_inst; + + list_for_each_entry(dbgfs_inst, &vcodec_dev->dbgfs.dbgfs_head, node) { + if (dbgfs_inst && dbgfs_inst->inst_id == ctx_id) { + vcodec_dev->dbgfs.inst_count--; + break; + } + } + + if (dbgfs_inst) { + list_del(&dbgfs_inst->node); + kfree(dbgfs_inst); + } +} +EXPORT_SYMBOL_GPL(mtk_vcodec_dbgfs_remove); + void mtk_vcodec_dbgfs_init(struct mtk_vcodec_dev *vcodec_dev) { struct dentry *vcodec_root; @@ -22,6 +80,12 @@ void mtk_vcodec_dbgfs_init(struct mtk_vcodec_dev *vcodec_dev) vcodec_root = vcodec_dev->dbgfs.vcodec_root; debugfs_create_x32("mtk_v4l2_dbg_level", 0644, vcodec_root, &mtk_v4l2_dbg_level); debugfs_create_x32("mtk_vcodec_dbg", 0644, vcodec_root, &mtk_vcodec_dbg); + + vcodec_dev->dbgfs.inst_count = 0; + + INIT_LIST_HEAD(&vcodec_dev->dbgfs.dbgfs_head); + debugfs_create_file("vdec", 0200, vcodec_root, vcodec_dev, &vdec_fops); + mutex_init(&vcodec_dev->dbgfs.dbgfs_lock); } EXPORT_SYMBOL_GPL(mtk_vcodec_dbgfs_init); diff --git a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.h b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.h index 5eec2211cbbe..9df760475684 100644 --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.h +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.h @@ -8,19 +8,50 @@ #define __MTK_VCODEC_DBGFS_H__ struct mtk_vcodec_dev; +struct mtk_vcodec_ctx; + +/** + * struct mtk_vcodec_dbgfs_inst - debugfs information for each inst + * @node: list node for each inst + * @vcodec_ctx: struct mtk_vcodec_ctx + * @inst_id: index of the context that the same with ctx->id + */ +struct mtk_vcodec_dbgfs_inst { + struct list_head node; + struct mtk_vcodec_ctx *vcodec_ctx; + int inst_id; +}; /** * struct mtk_vcodec_dbgfs - dbgfs information + * @dbgfs_head: list head used to link each instance * @vcodec_root: vcodec dbgfs entry + * @dbgfs_lock: dbgfs lock used to protect dbgfs_buf + * @dbgfs_buf: dbgfs buf used to store dbgfs cmd + * @inst_count: the count of total instance */ struct mtk_vcodec_dbgfs { + struct list_head dbgfs_head; struct dentry *vcodec_root; + struct mutex dbgfs_lock; + char dbgfs_buf[1024]; + int inst_count; }; #if defined(CONFIG_DEBUG_FS) +void mtk_vcodec_dbgfs_create(struct mtk_vcodec_ctx *ctx); +void mtk_vcodec_dbgfs_remove(struct mtk_vcodec_dev *vcodec_dev, int ctx_id); void mtk_vcodec_dbgfs_init(struct mtk_vcodec_dev *vcodec_dev); void mtk_vcodec_dbgfs_deinit(struct mtk_vcodec_dev *vcodec_dev); #else +static inline void mtk_vcodec_dbgfs_create(struct mtk_vcodec_ctx *ctx) +{ +} + +static inline void mtk_vcodec_dbgfs_remove(struct mtk_vcodec_dev *vcodec_dev, int ctx_id) +{ +} + static inline void mtk_vcodec_dbgfs_init(struct mtk_vcodec_dev *vcodec_dev) { } diff --git a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_drv.c b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_drv.c index de29b1fb0436..8c2443a18f5e 100644 --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_drv.c +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_drv.c @@ -215,6 +215,7 @@ static int fops_vcodec_open(struct file *file) ctx->dev->vdec_pdata->init_vdec_params(ctx); list_add(&ctx->list, &dev->ctx_list); + mtk_vcodec_dbgfs_create(ctx); mutex_unlock(&dev->dev_mutex); mtk_v4l2_debug(0, "%s decoder [%d]", dev_name(&dev->plat_dev->dev), @@ -256,6 +257,7 @@ static int fops_vcodec_release(struct file *file) v4l2_fh_exit(&ctx->fh); v4l2_ctrl_handler_free(&ctx->ctrl_hdl); + mtk_vcodec_dbgfs_remove(dev, ctx->id); list_del_init(&ctx->list); kfree(ctx); mutex_unlock(&dev->dev_mutex); From patchwork Tue Apr 4 08:10:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?WXVuZmVpIERvbmcgKOiRo+S6kemjnik=?= X-Patchwork-Id: 78905 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2857294vqo; Tue, 4 Apr 2023 01:15:15 -0700 (PDT) X-Google-Smtp-Source: AKy350YzynVrE6JVJSS0lx70VbkUPyP97NmKb3dZUm3xCnWvH97HfEqyMrwZ21BeaKeIzC6ehjuC X-Received: by 2002:a17:906:c9cb:b0:870:b950:18d4 with SMTP id hk11-20020a170906c9cb00b00870b95018d4mr1293742ejb.5.1680596114868; Tue, 04 Apr 2023 01:15:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680596114; cv=none; d=google.com; s=arc-20160816; b=C/TfemKt580/jHRofHkhGhn3Ok2pmK0+NjKLhiNCmsgwQXy+voQCTY1m34BCyITCFY 0hctgo2FbeXDmyi8reGxk0A0mxnNPaHJYOEcyXX+slJWgIvGuuk06IAxUw5ycSo/AC/F 2YJNFtwsmQcT0Fls1o9aiiHTYuq6rWeDStlI3k2U0Muc9iAz0eOtjNczEN2AuQfsm3Ap VvmPQQzdwOmyecSj3BeJ8Kh9IxrF4cSjrx7Q78F/2+yXYmR+TXIIG3SHn28UeAw5OKwG EehjpMjjA69ZiQ9q1Z2fIKACJ4P3QEiFE4WmTbHArynNMbUZkFPSW4yuzXw8hhKKnfiB EysQ== 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 :dkim-signature; bh=/DpYTGcQ4lnUwscOLctMZmlL/GOb9LIojGcT0W09m4o=; b=a5u3xpCk1rHxk7f9mJbAmMbRuDfdMrPxAJwi/ISyjChmRl2eRSe0tD30RqfD9Gnvq+ VzLujMy/i2mUj7bjhV7w4L8kILoFoMnfYiXAaLflnTaqng4CBibv0ysGG1fsmuHwgyQQ dT7ZKav+tS0o1+6YfYaVNnS3bYd3mgDXvvFk2Gd1m8GlZDAkS893j9Q0Ph4BCIc4kCMF LqPQu0kPkdWsTpddcqVTkg06BOJKja+pvf/xXXbbg+xlrmIKdN9Vp3sxdQmtGxr1J3hw VWmFHTIiRSRqtp1bKf30Wgs8WzI4EmjbsqJk/NQ71mctguDDQRtU/NJHxCFeIkrPzzY5 fyYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=j6TcfuZN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y25-20020a056402135900b004acd9e5c891si594816edw.375.2023.04.04.01.14.51; Tue, 04 Apr 2023 01:15:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=j6TcfuZN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234066AbjDDIL3 (ORCPT + 99 others); Tue, 4 Apr 2023 04:11:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43994 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233615AbjDDILU (ORCPT ); Tue, 4 Apr 2023 04:11:20 -0400 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E4C51BE8; Tue, 4 Apr 2023 01:11:14 -0700 (PDT) X-UUID: 41606c74d2c011eda9a90f0bb45854f4-20230404 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=/DpYTGcQ4lnUwscOLctMZmlL/GOb9LIojGcT0W09m4o=; b=j6TcfuZN547YzbYdqEc16FNvtH++qM3pGP1uW70TlLCiKu5FBtxSRJb7VejsnTjwLnygmDCdiZNojf2Gl6d0kbqM3eXT05WeVz6ycc0jjWRQPe5rBByjTDCXThe8jMzI8u9SRq57vDdqBoCH55rl6KeeO/xNbt0nlgznSZqJQ4Q=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.22,REQID:c388e56b-83b3-4d44-b5e3-8b9468dbd270,IP:0,U RL:0,TC:0,Content:-25,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTIO N:release,TS:-25 X-CID-META: VersionHash:120426c,CLOUDID:f4b236b5-beed-4dfc-bd9c-e1b22fa6ccc4,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:-3,IP:nil,U RL:0,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV:0 X-CID-BVR: 0,NGT X-CID-BAS: 0,NGT,0,_ X-UUID: 41606c74d2c011eda9a90f0bb45854f4-20230404 Received: from mtkmbs13n2.mediatek.inc [(172.21.101.108)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 61081210; Tue, 04 Apr 2023 16:11:09 +0800 Received: from mtkmbs13n1.mediatek.inc (172.21.101.193) by mtkmbs13n1.mediatek.inc (172.21.101.193) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.25; Tue, 4 Apr 2023 16:11:07 +0800 Received: from mhfsdcap04.gcn.mediatek.inc (10.17.3.154) by mtkmbs13n1.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.25 via Frontend Transport; Tue, 4 Apr 2023 16:11:06 +0800 From: Yunfei Dong To: Yunfei Dong , Chen-Yu Tsai , Nicolas Dufresne , Hans Verkuil , AngeloGioacchino Del Regno , Benjamin Gaignard , =?utf-8?q?N=C3=ADcolas?= =?utf-8?q?_F_=2E_R_=2E_A_=2E_Prado?= CC: Matthias Brugger , Hsin-Yi Wang , Fritz Koenig , Daniel Vetter , Steve Cho , , , , , , Subject: [PATCH v4,4/8] media: mediatek: vcodec: Get each context resolution information Date: Tue, 4 Apr 2023 16:10:58 +0800 Message-ID: <20230404081102.30713-5-yunfei.dong@mediatek.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230404081102.30713-1-yunfei.dong@mediatek.com> References: <20230404081102.30713-1-yunfei.dong@mediatek.com> MIME-Version: 1.0 X-MTK: N X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, T_SPF_TEMPERROR,UNPARSEABLE_RELAY autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1762232751815553979?= X-GMAIL-MSGID: =?utf-8?q?1762232751815553979?= Will store the string to temp buffer like "echo '-picinfo' > vdec" when user want to get needed information. Then getting debug information using command 'cat vdec' calling mtk_vdec_dbgfs_read to analysis the temp buffer. Signed-off-by: Yunfei Dong --- .../mediatek/vcodec/mtk_vcodec_dbgfs.c | 42 +++++++++++++++++++ .../mediatek/vcodec/mtk_vcodec_dbgfs.h | 8 ++++ 2 files changed, 50 insertions(+) diff --git a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.c b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.c index 4aade064af96..a47005e0bc16 100644 --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.c +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.c @@ -27,9 +27,51 @@ static ssize_t mtk_vdec_dbgfs_write(struct file *filp, const char __user *ubuf, return len; } +static ssize_t mtk_vdec_dbgfs_read(struct file *filp, char __user *ubuf, + size_t count, loff_t *ppos) +{ + struct mtk_vcodec_dev *vcodec_dev = filp->private_data; + struct mtk_vcodec_dbgfs *dbgfs = &vcodec_dev->dbgfs; + struct mtk_vcodec_dbgfs_inst *dbgfs_inst; + struct mtk_vcodec_ctx *ctx; + int total_len = 200 * (dbgfs->inst_count == 0 ? 1 : dbgfs->inst_count); + int used_len = 0, curr_len, ret; + bool dbgfs_index[MTK_VDEC_DBGFS_MAX] = {0}; + char *buf = kmalloc(total_len, GFP_KERNEL); + + if (!buf) + return -ENOMEM; + + if (strstr(dbgfs->dbgfs_buf, "-picinfo")) + dbgfs_index[MTK_VDEC_DBGFS_PICINFO] = true; + + mutex_lock(&dbgfs->dbgfs_lock); + list_for_each_entry(dbgfs_inst, &dbgfs->dbgfs_head, node) { + ctx = dbgfs_inst->vcodec_ctx; + + curr_len = snprintf(buf + used_len, total_len - used_len, + "inst[%d]:\n ", ctx->id); + used_len += curr_len; + + if (dbgfs_index[MTK_VDEC_DBGFS_PICINFO]) { + curr_len = snprintf(buf + used_len, total_len - used_len, + "\treal(%dx%d)=>align(%dx%d)\n", + ctx->picinfo.pic_w, ctx->picinfo.pic_h, + ctx->picinfo.buf_w, ctx->picinfo.buf_h); + used_len += curr_len; + } + } + mutex_unlock(&dbgfs->dbgfs_lock); + + ret = simple_read_from_buffer(ubuf, count, ppos, buf, used_len); + kfree(buf); + return ret; +} + static const struct file_operations vdec_fops = { .open = simple_open, .write = mtk_vdec_dbgfs_write, + .read = mtk_vdec_dbgfs_read, }; void mtk_vcodec_dbgfs_create(struct mtk_vcodec_ctx *ctx) diff --git a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.h b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.h index 9df760475684..da61b2dffe29 100644 --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.h +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.h @@ -10,6 +10,14 @@ struct mtk_vcodec_dev; struct mtk_vcodec_ctx; +/* + * enum mtk_vdec_dbgfs_log_index - used to get different debug information + */ +enum mtk_vdec_dbgfs_log_index { + MTK_VDEC_DBGFS_PICINFO, + MTK_VDEC_DBGFS_MAX, +}; + /** * struct mtk_vcodec_dbgfs_inst - debugfs information for each inst * @node: list node for each inst From patchwork Tue Apr 4 08:10:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?WXVuZmVpIERvbmcgKOiRo+S6kemjnik=?= X-Patchwork-Id: 78910 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2862095vqo; Tue, 4 Apr 2023 01:26:08 -0700 (PDT) X-Google-Smtp-Source: AKy350bxOBCtIoDWQsWSXk31MrH8c89GZ/yUnPdpJRSwnMiZV9KupcE/gcZz05ticknKQMboYQg7 X-Received: by 2002:a17:90a:c90e:b0:23c:ffd2:6502 with SMTP id v14-20020a17090ac90e00b0023cffd26502mr2015100pjt.12.1680596768340; Tue, 04 Apr 2023 01:26:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680596768; cv=none; d=google.com; s=arc-20160816; b=k9WPb4MtWqHcwU80RMRrcisg2P5WrCHm5AHdSJQxKlJkfFR8Xu6+NB2QJ3qYEogLr/ /DxKZlbpvaBRkvc6RHrcRGYx+Bi1/Ty60MIdi3f8CxjvZ7tMupDydLAMhDlAwV3r3CsT mrwLjst3Ui23+ANW6lXkVuZibiDtRX10hm9mJQqXJasRNJuMFRbnPotD8buojGvFuLZr PzOaevRRU9cyoIi0cNUzr8s0CIdEi1YEXUzTD7mVFzqxCBoaukaN2w+btLrdbGgm2E9E jn0bcenamTUa09NDur4ZRaijKO/vzD+OIt8/E4Sxm6iM7teT/06USlW5JX7F94gW8uIR JJ5Q== 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 :dkim-signature; bh=+WMGmVQcIEvCROoJ0Bhy2AlAHGZNSoBKJ5AiqWuyauI=; b=q3FKK0S+Ns7RAxduhgmkYjKF6j9+i6EKQqBXJGbuf56njLWV9Nv1LVfOGdTqXkI5KE Q3YbgssbbY/Ugwe+oDxrwKjOi8le7XYt0OL9I86fJIR/CoaaOACF9Ja7nj+VnC6MOpLZ YjufAQYMQYo3yob4gfUOkPkmIH5lk9j3Gyjv1+GfiSpLkDomq2+IOVb28+3QPGJXb9vq cP6KjM9+nYCUbql780OAQMhis8vS/SsHjVvKsLsCUUlQRBOoo20iO7vrIStp3oYhB7hF 5MCq5rMaD2SFBzURQiYkwW5wl/a8Y7/vBpnmkdjCRoeVepG9nqivYOfO1556THK4EM8d AfpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=iwhRmxzf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id il17-20020a17090b165100b0023d23393339si548517pjb.117.2023.04.04.01.25.55; Tue, 04 Apr 2023 01:26:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=iwhRmxzf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233983AbjDDILv (ORCPT + 99 others); Tue, 4 Apr 2023 04:11:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234062AbjDDILX (ORCPT ); Tue, 4 Apr 2023 04:11:23 -0400 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 13ADB1BF3; Tue, 4 Apr 2023 01:11:17 -0700 (PDT) X-UUID: 41f12f3ed2c011edb6b9f13eb10bd0fe-20230404 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=+WMGmVQcIEvCROoJ0Bhy2AlAHGZNSoBKJ5AiqWuyauI=; b=iwhRmxzf50nZScRixD1glUQD+6hjGL8fCLxd9AuS/WDstZsce6JiulhIzGx6QsK46+iqjA9ERUjN3pZqF9GKjQQ4kYIi9qmqb58lM0I/JgTkC6kBrf+H55rnA1rGUpqBhturLQC9sLbHHvc3D/L32BD9aSge4K3XcO2oOPtNmWM=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.22,REQID:8151d5c9-8809-4d0c-95a5-bee15c1c703f,IP:0,U RL:0,TC:0,Content:-25,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTIO N:release,TS:-25 X-CID-META: VersionHash:120426c,CLOUDID:5671c4f7-ddba-41c3-91d9-10eeade8eac7,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:-3,IP:nil,U RL:0,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV:0 X-CID-BVR: 0,NGT X-CID-BAS: 0,NGT,0,_ X-UUID: 41f12f3ed2c011edb6b9f13eb10bd0fe-20230404 Received: from mtkmbs10n2.mediatek.inc [(172.21.101.183)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1384212795; Tue, 04 Apr 2023 16:11:10 +0800 Received: from mtkmbs13n1.mediatek.inc (172.21.101.193) by mtkmbs10n2.mediatek.inc (172.21.101.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.25; Tue, 4 Apr 2023 16:11:08 +0800 Received: from mhfsdcap04.gcn.mediatek.inc (10.17.3.154) by mtkmbs13n1.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.25 via Frontend Transport; Tue, 4 Apr 2023 16:11:07 +0800 From: Yunfei Dong To: Yunfei Dong , Chen-Yu Tsai , Nicolas Dufresne , Hans Verkuil , AngeloGioacchino Del Regno , Benjamin Gaignard , =?utf-8?q?N=C3=ADcolas?= =?utf-8?q?_F_=2E_R_=2E_A_=2E_Prado?= CC: Matthias Brugger , Hsin-Yi Wang , Fritz Koenig , Daniel Vetter , Steve Cho , , , , , , Subject: [PATCH v4,5/8] media: mediatek: vcodec: Get each instance format type Date: Tue, 4 Apr 2023 16:10:59 +0800 Message-ID: <20230404081102.30713-6-yunfei.dong@mediatek.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230404081102.30713-1-yunfei.dong@mediatek.com> References: <20230404081102.30713-1-yunfei.dong@mediatek.com> MIME-Version: 1.0 X-MTK: N X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, T_SPF_TEMPERROR,UNPARSEABLE_RELAY autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1762233437147588659?= X-GMAIL-MSGID: =?utf-8?q?1762233437147588659?= Adding echo command to get capture and output queue format type of each instance:"echo '-format' > vdec", not current hardware supported. Signed-off-by: Yunfei Dong --- .../mediatek/vcodec/mtk_vcodec_dbgfs.c | 48 +++++++++++++++++++ .../mediatek/vcodec/mtk_vcodec_dbgfs.h | 1 + 2 files changed, 49 insertions(+) diff --git a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.c b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.c index a47005e0bc16..b2b69c3400d4 100644 --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.c +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.c @@ -10,6 +10,48 @@ #include "mtk_vcodec_drv.h" #include "mtk_vcodec_util.h" +static void mtk_vdec_dbgfs_get_format_type(struct mtk_vcodec_ctx *ctx, char *buf, + int *used, int total) +{ + int curr_len; + + switch (ctx->current_codec) { + case V4L2_PIX_FMT_H264_SLICE: + curr_len = snprintf(buf + *used, total - *used, + "\toutput format: h264 slice\n"); + break; + case V4L2_PIX_FMT_VP8_FRAME: + curr_len = snprintf(buf + *used, total - *used, + "\toutput format: vp8 slice\n"); + break; + case V4L2_PIX_FMT_VP9_FRAME: + curr_len = snprintf(buf + *used, total - *used, + "\toutput format: vp9 slice\n"); + break; + default: + curr_len = snprintf(buf + *used, total - *used, + "\tunsupported output format: 0x%x\n", + ctx->current_codec); + } + *used += curr_len; + + switch (ctx->capture_fourcc) { + case V4L2_PIX_FMT_MM21: + curr_len = snprintf(buf + *used, total - *used, + "\tcapture format: MM21\n"); + break; + case V4L2_PIX_FMT_MT21C: + curr_len = snprintf(buf + *used, total - *used, + "\tcapture format: MT21C\n"); + break; + default: + curr_len = snprintf(buf + *used, total - *used, + "\tunsupported capture format: 0x%x\n", + ctx->capture_fourcc); + } + *used += curr_len; +} + static ssize_t mtk_vdec_dbgfs_write(struct file *filp, const char __user *ubuf, size_t count, loff_t *ppos) { @@ -45,6 +87,9 @@ static ssize_t mtk_vdec_dbgfs_read(struct file *filp, char __user *ubuf, if (strstr(dbgfs->dbgfs_buf, "-picinfo")) dbgfs_index[MTK_VDEC_DBGFS_PICINFO] = true; + if (strstr(dbgfs->dbgfs_buf, "-format")) + dbgfs_index[MTK_VDEC_DBGFS_FORMAT] = true; + mutex_lock(&dbgfs->dbgfs_lock); list_for_each_entry(dbgfs_inst, &dbgfs->dbgfs_head, node) { ctx = dbgfs_inst->vcodec_ctx; @@ -60,6 +105,9 @@ static ssize_t mtk_vdec_dbgfs_read(struct file *filp, char __user *ubuf, ctx->picinfo.buf_w, ctx->picinfo.buf_h); used_len += curr_len; } + + if (dbgfs_index[MTK_VDEC_DBGFS_FORMAT]) + mtk_vdec_dbgfs_get_format_type(ctx, buf, &used_len, total_len); } mutex_unlock(&dbgfs->dbgfs_lock); diff --git a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.h b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.h index da61b2dffe29..b0bdb84a46df 100644 --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.h +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.h @@ -15,6 +15,7 @@ struct mtk_vcodec_ctx; */ enum mtk_vdec_dbgfs_log_index { MTK_VDEC_DBGFS_PICINFO, + MTK_VDEC_DBGFS_FORMAT, MTK_VDEC_DBGFS_MAX, }; From patchwork Tue Apr 4 08:11:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?WXVuZmVpIERvbmcgKOiRo+S6kemjnik=?= X-Patchwork-Id: 78906 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2861829vqo; Tue, 4 Apr 2023 01:25:33 -0700 (PDT) X-Google-Smtp-Source: AKy350aXRxaJX5cwVXuyOBk2e+4aLUOA0OjKnaIkawR4BedbhzmKEMGAqamBuOCUInqYiDjWRW5a X-Received: by 2002:a05:6a20:4b1d:b0:cc:ce95:7db5 with SMTP id fp29-20020a056a204b1d00b000ccce957db5mr1154211pzb.57.1680596733078; Tue, 04 Apr 2023 01:25:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680596733; cv=none; d=google.com; s=arc-20160816; b=SRPFiSXh7frt2MLHPcMefwHr5Ck1/uJfCYEh5S72/7KgxMirIwPDQnCUfZTu/Sd0vR Hrr0YD9hQkJtvyoNdUeuK7ZjmiLoaqdRDjdeR024LX6wt8hL7l8U7lVydERi1h9uXrLH cVVXV0AQOuZc6oSYPZ3rulHHHhf8GPV1M2awL9rGntJiBVX8rZwc3i4nLAXUx8v0wmtA BUShow/Fr2h39SGLCxNFwhMoqznlg02OsgAZ/rYQ3jdGbpR8afh5iYGyl66fwdO5EI32 0T6e4jSLZnkO9cxWMS3KW5h6GiIhjXAXnGF5DaC9qAj5/G8tx/KqyiDp6hqvTIUK3/Ka gsOw== 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 :dkim-signature; bh=Jzczl02MH2JKJBzD38hbYqMpw1wcvmgiWusiDGGF/AI=; b=JEjcjOlZ+4ileYkYqhmncH7AdoI+Ttu9nYc32JSTQ2yBuENiy7+YCQwjhAy1kx6Ntp jX07N95msgvSt1b8b9bICCusMBIHDGKHmeLzP4aXkqTw7iGnh2nVYNT9jAfuR52sNgt5 xOXa+GHjF0DX3elHHn7RU5F0K2ROJdrxpw+i1K8iux5MrBa/S31/2LTB0eLK69PSiN9h pbJDjVoutZazI/lWp8V2tIDNOLmSyHpsns6IGqmgQqkAnufCEl5vnqW69WrM4G6RCprj /qPjcaAAeNWwLsK98zSaZwGUHR42bT697rHaco3+GVTCwfYWrhCwS2wetqogXP0AcZhr /qHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=ak8pc5l3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x22-20020aa79ad6000000b00627fbc1cb02si10154689pfp.338.2023.04.04.01.25.19; Tue, 04 Apr 2023 01:25:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=ak8pc5l3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233913AbjDDILs (ORCPT + 99 others); Tue, 4 Apr 2023 04:11:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43994 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234043AbjDDILV (ORCPT ); Tue, 4 Apr 2023 04:11:21 -0400 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 12B9A1BF5; Tue, 4 Apr 2023 01:11:18 -0700 (PDT) X-UUID: 428e1f06d2c011edb6b9f13eb10bd0fe-20230404 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=Jzczl02MH2JKJBzD38hbYqMpw1wcvmgiWusiDGGF/AI=; b=ak8pc5l3A6QAbUy8Rv1zy37s0bK3nVcrC9ScUkv6YjOEegrPVVNLz//mYeC6U37B8Sx2sBNH+ujmfBZoEEfgRreP6mTUQiAFZBCu5+PflmtokcgLUzfGmebsEl2yhws/1WhqlT6R6PzHWxLT4KWGLs5130r31H3Dhx8m6+AfXC8=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.22,REQID:d44242c3-15b6-4c73-93d9-9215c3169f25,IP:0,U RL:0,TC:0,Content:-25,EDM:0,RT:0,SF:95,FILE:0,BULK:0,RULE:Release_Ham,ACTI ON:release,TS:70 X-CID-INFO: VERSION:1.1.22,REQID:d44242c3-15b6-4c73-93d9-9215c3169f25,IP:0,URL :0,TC:0,Content:-25,EDM:0,RT:0,SF:95,FILE:0,BULK:0,RULE:Spam_GS981B3D,ACTI ON:quarantine,TS:70 X-CID-META: VersionHash:120426c,CLOUDID:5771c4f7-ddba-41c3-91d9-10eeade8eac7,B ulkID:230404161112X7OZLT5J,BulkQuantity:1,Recheck:0,SF:38|29|28|17|19|48,T C:nil,Content:0,EDM:-3,IP:nil,URL:0,File:nil,Bulk:40,QS:nil,BEC:nil,COL:0, OSI:0,OSA:0,AV:0 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-UUID: 428e1f06d2c011edb6b9f13eb10bd0fe-20230404 Received: from mtkmbs13n1.mediatek.inc [(172.21.101.193)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 2136963564; Tue, 04 Apr 2023 16:11:11 +0800 Received: from mtkmbs13n1.mediatek.inc (172.21.101.193) by mtkmbs13n1.mediatek.inc (172.21.101.193) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.25; Tue, 4 Apr 2023 16:11:09 +0800 Received: from mhfsdcap04.gcn.mediatek.inc (10.17.3.154) by mtkmbs13n1.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.25 via Frontend Transport; Tue, 4 Apr 2023 16:11:08 +0800 From: Yunfei Dong To: Yunfei Dong , Chen-Yu Tsai , Nicolas Dufresne , Hans Verkuil , AngeloGioacchino Del Regno , Benjamin Gaignard , =?utf-8?q?N=C3=ADcolas?= =?utf-8?q?_F_=2E_R_=2E_A_=2E_Prado?= CC: Matthias Brugger , Hsin-Yi Wang , Fritz Koenig , Daniel Vetter , Steve Cho , , , , , , Subject: [PATCH v4,6/8] media: mediatek: vcodec: Change dbgfs interface to support encode Date: Tue, 4 Apr 2023 16:11:00 +0800 Message-ID: <20230404081102.30713-7-yunfei.dong@mediatek.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230404081102.30713-1-yunfei.dong@mediatek.com> References: <20230404081102.30713-1-yunfei.dong@mediatek.com> MIME-Version: 1.0 X-MTK: N X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS, UNPARSEABLE_RELAY autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1762233400123164539?= X-GMAIL-MSGID: =?utf-8?q?1762233400123164539?= Extend dbgfs init interface to support encode and create encode dbgfs file. Signed-off-by: Yunfei Dong Reviewed-by: AngeloGioacchino Del Regno --- .../media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.c | 9 +++++++-- .../media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.h | 4 ++-- .../media/platform/mediatek/vcodec/mtk_vcodec_dec_drv.c | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.c b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.c index b2b69c3400d4..237d0dc8a1fc 100644 --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.c +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.c @@ -158,11 +158,14 @@ void mtk_vcodec_dbgfs_remove(struct mtk_vcodec_dev *vcodec_dev, int ctx_id) } EXPORT_SYMBOL_GPL(mtk_vcodec_dbgfs_remove); -void mtk_vcodec_dbgfs_init(struct mtk_vcodec_dev *vcodec_dev) +void mtk_vcodec_dbgfs_init(struct mtk_vcodec_dev *vcodec_dev, bool is_encode) { struct dentry *vcodec_root; - vcodec_dev->dbgfs.vcodec_root = debugfs_create_dir("vcodec-dec", NULL); + if (is_encode) + vcodec_dev->dbgfs.vcodec_root = debugfs_create_dir("vcodec-enc", NULL); + else + vcodec_dev->dbgfs.vcodec_root = debugfs_create_dir("vcodec-dec", NULL); if (IS_ERR(vcodec_dev->dbgfs.vcodec_root)) dev_err(&vcodec_dev->plat_dev->dev, "create vcodec dir err:%d\n", IS_ERR(vcodec_dev->dbgfs.vcodec_root)); @@ -172,6 +175,8 @@ void mtk_vcodec_dbgfs_init(struct mtk_vcodec_dev *vcodec_dev) debugfs_create_x32("mtk_vcodec_dbg", 0644, vcodec_root, &mtk_vcodec_dbg); vcodec_dev->dbgfs.inst_count = 0; + if (is_encode) + return; INIT_LIST_HEAD(&vcodec_dev->dbgfs.dbgfs_head); debugfs_create_file("vdec", 0200, vcodec_root, vcodec_dev, &vdec_fops); diff --git a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.h b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.h index b0bdb84a46df..ba43518d0fcb 100644 --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.h +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.h @@ -50,7 +50,7 @@ struct mtk_vcodec_dbgfs { #if defined(CONFIG_DEBUG_FS) void mtk_vcodec_dbgfs_create(struct mtk_vcodec_ctx *ctx); void mtk_vcodec_dbgfs_remove(struct mtk_vcodec_dev *vcodec_dev, int ctx_id); -void mtk_vcodec_dbgfs_init(struct mtk_vcodec_dev *vcodec_dev); +void mtk_vcodec_dbgfs_init(struct mtk_vcodec_dev *vcodec_dev, bool is_encode); void mtk_vcodec_dbgfs_deinit(struct mtk_vcodec_dev *vcodec_dev); #else static inline void mtk_vcodec_dbgfs_create(struct mtk_vcodec_ctx *ctx) @@ -61,7 +61,7 @@ static inline void mtk_vcodec_dbgfs_remove(struct mtk_vcodec_dev *vcodec_dev, in { } -static inline void mtk_vcodec_dbgfs_init(struct mtk_vcodec_dev *vcodec_dev) +static inline void mtk_vcodec_dbgfs_init(struct mtk_vcodec_dev *vcodec_dev, bool is_encode) { } diff --git a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_drv.c b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_drv.c index 8c2443a18f5e..bba7b932f4fa 100644 --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_drv.c +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_drv.c @@ -433,7 +433,7 @@ static int mtk_vcodec_probe(struct platform_device *pdev) mtk_v4l2_debug(0, "media registered as /dev/media%d", vfd_dec->minor); } - mtk_vcodec_dbgfs_init(dev); + mtk_vcodec_dbgfs_init(dev, false); mtk_v4l2_debug(0, "decoder registered as /dev/video%d", vfd_dec->minor); return 0; From patchwork Tue Apr 4 08:11:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?WXVuZmVpIERvbmcgKOiRo+S6kemjnik=?= X-Patchwork-Id: 78913 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2862394vqo; Tue, 4 Apr 2023 01:26:45 -0700 (PDT) X-Google-Smtp-Source: AKy350bIMMv3fyvBsRF29XVWzhGZi5I97XuGDcL1FR1AU7t59iko1YVWqlfwrF/DPyjeNMfcwXrc X-Received: by 2002:aa7:978e:0:b0:625:7acb:bf0e with SMTP id o14-20020aa7978e000000b006257acbbf0emr1457736pfp.19.1680596805257; Tue, 04 Apr 2023 01:26:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680596805; cv=none; d=google.com; s=arc-20160816; b=QsQupMlGhbgxMRKaeiYO8kdiHE5p3FjMtSlq7S3UM+B/r43J/r+hTSiBFRZCbDsy70 vft3Ab/XKBi1m0+6j6eIWuSoLHbq8mw8jwdWcj2EGTuJ9tJhhcpbzIO63UH6m8w/Kk+Z 9xuUvz0vxd/bdBMeDWiQ3itXIFX28GQDlQarzlYz+hYVroqwx9d9nFEis6YCB7H+gXKW 5R+Ktr+iod8jyC3H6mVEYYdG7nFSaVhXs50c+zM1mqSzKcEcte0PvMtPMW6++aUnQibY kkATFLiXKA6JMpCEo0tqPlnZgHfntL/X63p23E50L1uTrjn+Zjz8H/F5jWpr4YQ3Doo3 OYHA== 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 :dkim-signature; bh=JCkSPuVB7jjpM1tcjroiT32LNNZFYGfyhbRU02y5/BA=; b=Hu5EXnmhyEW5+Kk2JUnYOF29VUuoh5I7ryn1Cx5Sf9NlSTA8SVLHq9eU4VJRHFYxMW r1kds9NMV7m2Qs8roTgAOAMD1xiiq8NU9LkMfhdiRbqivEtXtNvoNj6qD/bHnLfkzIk0 MlcJZMa9IOJekMFuYfPq3EtvgcKGs72HV4zNDSvLP289WFAoLPDme83UG1CwcXWcPh+E /+0DrC2wIIcw6qbFeeQXh18KkACJ8EoijlLl0jtPNmMBZOOlsCDuM/Ff8n6eLqOXd3nN RPa9nj+xrGSOEyc51WK/n9q1Fg4anIQozJkAcxG33F2o3n7fBYrOXMSNlnwqXWYwWKWk aU2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=KKeJcqPj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x24-20020a63db58000000b00513b3372e2asi9851077pgi.598.2023.04.04.01.26.32; Tue, 04 Apr 2023 01:26:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=KKeJcqPj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234117AbjDDILg (ORCPT + 99 others); Tue, 4 Apr 2023 04:11:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44002 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233856AbjDDILU (ORCPT ); Tue, 4 Apr 2023 04:11:20 -0400 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1B0911BF4; Tue, 4 Apr 2023 01:11:17 -0700 (PDT) X-UUID: 4322a95ad2c011eda9a90f0bb45854f4-20230404 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=JCkSPuVB7jjpM1tcjroiT32LNNZFYGfyhbRU02y5/BA=; b=KKeJcqPj95qUpl+nPHLTQM2ZwFEbGC2rQy4XKXs+ZxzeN5RYBr9rnz7nfPiACtLDFrvq3xzjxkupe4X7oZhApGb7ZFWhi4YtZejJjZkJycvMi9UlRg9mnB+baxmMQqGPZO52N8KGpq/k74TzOnNDQretjzOGXDOHuMijIbuhVxM=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.22,REQID:6b71ef57-bbea-48e5-874b-ac85a0189c20,IP:0,U RL:0,TC:0,Content:-5,EDM:0,RT:0,SF:95,FILE:0,BULK:0,RULE:Release_Ham,ACTIO N:release,TS:90 X-CID-INFO: VERSION:1.1.22,REQID:6b71ef57-bbea-48e5-874b-ac85a0189c20,IP:0,URL :0,TC:0,Content:-5,EDM:0,RT:0,SF:95,FILE:0,BULK:0,RULE:Spam_GS981B3D,ACTIO N:quarantine,TS:90 X-CID-META: VersionHash:120426c,CLOUDID:f188552a-564d-42d9-9875-7c868ee415ec,B ulkID:2304041611139C8JVOKX,BulkQuantity:0,Recheck:0,SF:38|29|28|17|19|48,T C:nil,Content:0,EDM:-3,IP:nil,URL:11|1,File:nil,Bulk:nil,QS:nil,BEC:nil,CO L:0,OSI:0,OSA:0,AV:0 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-UUID: 4322a95ad2c011eda9a90f0bb45854f4-20230404 Received: from mtkmbs10n1.mediatek.inc [(172.21.101.34)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1551253555; Tue, 04 Apr 2023 16:11:12 +0800 Received: from mtkmbs13n1.mediatek.inc (172.21.101.193) by mtkmbs10n2.mediatek.inc (172.21.101.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.25; Tue, 4 Apr 2023 16:11:10 +0800 Received: from mhfsdcap04.gcn.mediatek.inc (10.17.3.154) by mtkmbs13n1.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.25 via Frontend Transport; Tue, 4 Apr 2023 16:11:09 +0800 From: Yunfei Dong To: Yunfei Dong , Chen-Yu Tsai , Nicolas Dufresne , Hans Verkuil , AngeloGioacchino Del Regno , Benjamin Gaignard , =?utf-8?q?N=C3=ADcolas?= =?utf-8?q?_F_=2E_R_=2E_A_=2E_Prado?= CC: Matthias Brugger , Hsin-Yi Wang , Fritz Koenig , Daniel Vetter , Steve Cho , , , , , , Subject: [PATCH v4,7/8] media: mediatek: vcodec: Add encode to support dbgfs Date: Tue, 4 Apr 2023 16:11:01 +0800 Message-ID: <20230404081102.30713-8-yunfei.dong@mediatek.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230404081102.30713-1-yunfei.dong@mediatek.com> References: <20230404081102.30713-1-yunfei.dong@mediatek.com> MIME-Version: 1.0 X-MTK: N X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS, UNPARSEABLE_RELAY autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1762233475617547713?= X-GMAIL-MSGID: =?utf-8?q?1762233475617547713?= Add encode to support dbgfs. Signed-off-by: Yunfei Dong Reviewed-by: AngeloGioacchino Del Regno --- drivers/media/platform/mediatek/vcodec/mtk_vcodec_enc_drv.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_enc_drv.c b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_enc_drv.c index 9095186d5495..6961f66b5693 100644 --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_enc_drv.c +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_enc_drv.c @@ -353,6 +353,7 @@ static int mtk_vcodec_probe(struct platform_device *pdev) goto err_enc_reg; } + mtk_vcodec_dbgfs_init(dev, true); mtk_v4l2_debug(0, "encoder %d registered as /dev/video%d", dev->venc_pdata->core_id, vfd_enc->num); @@ -463,6 +464,7 @@ static int mtk_vcodec_enc_remove(struct platform_device *pdev) if (dev->vfd_enc) video_unregister_device(dev->vfd_enc); + mtk_vcodec_dbgfs_deinit(dev); v4l2_device_unregister(&dev->v4l2_dev); pm_runtime_disable(dev->pm.dev); mtk_vcodec_fw_release(dev->fw_handler); From patchwork Tue Apr 4 08:11:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?WXVuZmVpIERvbmcgKOiRo+S6kemjnik=?= X-Patchwork-Id: 78911 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2862182vqo; Tue, 4 Apr 2023 01:26:17 -0700 (PDT) X-Google-Smtp-Source: AKy350a7W2OyrbTYa3PqCYBtXkJk2VzJIpPtoLBbmXluUVdpTyL2Axzmi7UnCnGveTSkJucY9dJS X-Received: by 2002:a17:902:fb0f:b0:1a1:85d4:a775 with SMTP id le15-20020a170902fb0f00b001a185d4a775mr1909160plb.29.1680596777677; Tue, 04 Apr 2023 01:26:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680596777; cv=none; d=google.com; s=arc-20160816; b=RBaNQ/LpwYQYq7StswhefIi7TMUuz4AzlsN8aD9PMjsZ5wSEvIr7omFHbX292tUn2X G80A9DKQpPa0xPPBdRuxzkUJLWZcfmOO2/rTMySQgM8L3Viv9EO3lYWls5yumz2xddya 4cRL2vMPt/Rnb+gt2iNiMfCAjHjMUTSXRfpqnDl+wx3wNqiCzsap1DWAGqGBlBIGm3C3 WzwynVP+1IX9fiHu8VqKJ80TJ832So+6m93WTktgspyNDjclacNqbIIOoJ8i/8CxvphV AFGKHP1cajgsUB9gbOtIlxVeXSQYB3nHVcrEcYM2CwGcM+dLLxBeiG9OyT5Dx7uyvicK tQ5g== 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 :dkim-signature; bh=3wEaoqC2uVpKwjysc4h3Pq7cma8qpw1BEVmgLuijeno=; b=jkLL++3zr5WoNQhDoiEaqyfuV9bE1j430mI3dyAzvIEFXZO4EuIdVo6jgm+Z51gOBJ 8i0+IxzaJLFvXisHuAVqTblTdNwiHaK0alP6J8h41GvXL++LAdJwOuMKNn0nbsDjExQN UOu38VMWeOZ7N/sIkSUez9hqCqkb6ulQx0NiGCYlvvxzRihYk9y57dzsAhbgN0vlGOVe kWJACfb8bv84xjTp6fAIVwddeOyYmY4oudpCG6la7CfLpfSwwhVOLbWDUgJp2XqMVp7m +ZpBc1mIxakBqk9OxXzyCjWWQgTQym8sFSiil5FZhn858Xj1Eg3vI2aUSzNI21BcOWg5 8+eA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=W3GQevhl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t185-20020a6381c2000000b00513237b6b61si10055189pgd.562.2023.04.04.01.26.04; Tue, 04 Apr 2023 01:26:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=W3GQevhl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234142AbjDDILq (ORCPT + 99 others); Tue, 4 Apr 2023 04:11:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44016 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234030AbjDDILU (ORCPT ); Tue, 4 Apr 2023 04:11:20 -0400 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1975D1BFB; Tue, 4 Apr 2023 01:11:18 -0700 (PDT) X-UUID: 43bd0ea0d2c011eda9a90f0bb45854f4-20230404 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=3wEaoqC2uVpKwjysc4h3Pq7cma8qpw1BEVmgLuijeno=; b=W3GQevhlAUOI5S+n+w7D+Sjrncv4HztBIvMS87QwGcbuOhhauh2Wayfr+Um+1uTDl/WzdYlaLfo+TTpXtbe1IYFnKmQ4CS85tH4mvDBOZIjj9qdJmXOse0iVhlCfS8a8es5OSrTsn/FR05Wl6HNMtSp++HSB6rseQ5I1CVbVCYw=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.22,REQID:dbaaf889-9cf7-4ae0-8196-cbdfb40883aa,IP:0,U RL:0,TC:0,Content:-5,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION :release,TS:-5 X-CID-META: VersionHash:120426c,CLOUDID:3cb336b5-beed-4dfc-bd9c-e1b22fa6ccc4,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:-3,IP:nil,U RL:0,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV:0 X-CID-BVR: 0,NGT X-CID-BAS: 0,NGT,0,_ X-UUID: 43bd0ea0d2c011eda9a90f0bb45854f4-20230404 Received: from mtkmbs11n2.mediatek.inc [(172.21.101.187)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 2043590714; Tue, 04 Apr 2023 16:11:13 +0800 Received: from mtkmbs13n1.mediatek.inc (172.21.101.193) by mtkmbs11n2.mediatek.inc (172.21.101.187) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.25; Tue, 4 Apr 2023 16:11:11 +0800 Received: from mhfsdcap04.gcn.mediatek.inc (10.17.3.154) by mtkmbs13n1.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.25 via Frontend Transport; Tue, 4 Apr 2023 16:11:10 +0800 From: Yunfei Dong To: Yunfei Dong , Chen-Yu Tsai , Nicolas Dufresne , Hans Verkuil , AngeloGioacchino Del Regno , Benjamin Gaignard , =?utf-8?q?N=C3=ADcolas?= =?utf-8?q?_F_=2E_R_=2E_A_=2E_Prado?= CC: Matthias Brugger , Hsin-Yi Wang , Fritz Koenig , Daniel Vetter , Steve Cho , , , , , , Subject: [PATCH v4,8/8] media: mediatek: vcodec: Add dbgfs help function Date: Tue, 4 Apr 2023 16:11:02 +0800 Message-ID: <20230404081102.30713-9-yunfei.dong@mediatek.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230404081102.30713-1-yunfei.dong@mediatek.com> References: <20230404081102.30713-1-yunfei.dong@mediatek.com> MIME-Version: 1.0 X-MTK: N X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS, UNPARSEABLE_RELAY autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1762233446871285808?= X-GMAIL-MSGID: =?utf-8?q?1762233446871285808?= Getting dbgfs help information with command "echo -help > vdec". Signed-off-by: Yunfei Dong --- .../mediatek/vcodec/mtk_vcodec_dbgfs.c | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.c b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.c index 237d0dc8a1fc..2372fc449b45 100644 --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.c +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.c @@ -52,6 +52,23 @@ static void mtk_vdec_dbgfs_get_format_type(struct mtk_vcodec_ctx *ctx, char *buf *used += curr_len; } +static void mtk_vdec_dbgfs_get_help(char *buf, int *used, int total) +{ + int curr_len; + + curr_len = snprintf(buf + *used, total - *used, + "help: (1: echo -'info' > vdec 2: cat vdec)\n"); + *used += curr_len; + + curr_len = snprintf(buf + *used, total - *used, + "\t-picinfo: get resolution\n"); + *used += curr_len; + + curr_len = snprintf(buf + *used, total - *used, + "\t-format: get output & capture queue format\n"); + *used += curr_len; +} + static ssize_t mtk_vdec_dbgfs_write(struct file *filp, const char __user *ubuf, size_t count, loff_t *ppos) { @@ -84,6 +101,11 @@ static ssize_t mtk_vdec_dbgfs_read(struct file *filp, char __user *ubuf, if (!buf) return -ENOMEM; + if (strstr(dbgfs->dbgfs_buf, "-help")) { + mtk_vdec_dbgfs_get_help(buf, &used_len, total_len); + goto read_buffer; + } + if (strstr(dbgfs->dbgfs_buf, "-picinfo")) dbgfs_index[MTK_VDEC_DBGFS_PICINFO] = true; @@ -110,7 +132,7 @@ static ssize_t mtk_vdec_dbgfs_read(struct file *filp, char __user *ubuf, mtk_vdec_dbgfs_get_format_type(ctx, buf, &used_len, total_len); } mutex_unlock(&dbgfs->dbgfs_lock); - +read_buffer: ret = simple_read_from_buffer(ubuf, count, ppos, buf, used_len); kfree(buf); return ret;