From patchwork Mon Mar 27 05:53:12 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: 75221 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1297668vqo; Sun, 26 Mar 2023 23:04:12 -0700 (PDT) X-Google-Smtp-Source: AK7set/8EGviS53GkzV9L/IZN4D2HBvqHJSwMBkwsVL7hIF2pnCTPbJh+YqIbVzg8rJBmGk/Hppz X-Received: by 2002:a05:6a20:4985:b0:de:5e0b:caa8 with SMTP id fs5-20020a056a20498500b000de5e0bcaa8mr9095206pzb.52.1679897052735; Sun, 26 Mar 2023 23:04:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679897052; cv=none; d=google.com; s=arc-20160816; b=Kur/uhwkIdgzYdD/XY8j146Yuv5Eek2r5Jes5eO7nhEbyB5sP5Dok+dkH0vuiAzZBR /mtA8TJK1pZaDQZqfAsfkjZG/rD2fSudkd1aVG19/jfyn4hXiVWIzvV9Y9m8nG1XRfmL XwPTEMkuXg+QdOxeeRRUjKqQsHoJBWanEjfPbCNm6iO4okiaMpheWrLpQggWMhmt+uNE yIfww0Ogiibr/RwdPqIFhI3SxIqiYZ0kQf7T+QT2LM4g32Hx1cNPb9K1TKaQwlJW3KSp e1FvnfYYY0JXFwxxZOgNu+IJrA3FqwxGjz60KUt9C2IQaiKtdFBopb00pSYMDtGOgs59 Y3Eg== 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=kIK+VxG9R9L012B3txVH0rvn15mcAltpJ1WDR1RfE/Y=; b=x8Sb8BsQjKCnO6f8eYmToZ8nLZGeYAWNbuK1GBTj4ZwDKt439qjvrSuYv/NGKbzPxw UxyQrNvHNYERQfUAgzJ6q1gjaIoKiF6spPHE8ty46sBJNAuIgxMrglfKJLWx3thdoanw UUmOxMtWY0fgxNxwv9UJ4IFP+NyCsjC4C0h8s+slobfxkRjWxaj2vEmGJVYk9CtPLrDV WISmfg8ksXXOpCHeN6tui1liD5cetZ66dxS1zBgvXXhveqlKKPwgTWB645i91c5SZsFr s2u6zCIopQ77giyf4j6n2mnxGHyEH+LewvoG+CZrUMUSweaKPZVRrNDB3paYElsnnbpU oe3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=FuhWfPqQ; 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 a3-20020a63e843000000b0050f55427e3dsi23588992pgk.701.2023.03.26.23.03.59; Sun, 26 Mar 2023 23:04:12 -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=FuhWfPqQ; 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 S232206AbjC0FyA (ORCPT + 99 others); Mon, 27 Mar 2023 01:54:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50534 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231990AbjC0Fxn (ORCPT ); Mon, 27 Mar 2023 01:53:43 -0400 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C3E84203; Sun, 26 Mar 2023 22:53:41 -0700 (PDT) X-UUID: b559ebcccc6311edb6b9f13eb10bd0fe-20230327 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=kIK+VxG9R9L012B3txVH0rvn15mcAltpJ1WDR1RfE/Y=; b=FuhWfPqQjUe4Mwb5Kw7NOed6di3pfM2akNhaDrWjq4zWkSxxuwbgC+kp2CtBgTZZN5GgEciWmdmjoMbC4t0zW8bCAEisApjDBG9Nstey/PR6NDAIzhKpFttUIXzwh9hSTO33dvSmry22ekKxK80NJB2HwSmUpeXPGeZTLkVEOUw=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.22,REQID:94c68385-cb33-48b0-8235-09e521e14bd1,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:94c68385-cb33-48b0-8235-09e521e14bd1,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:e17c9429-564d-42d9-9875-7c868ee415ec,B ulkID:23032713533521TCNW9E,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: b559ebcccc6311edb6b9f13eb10bd0fe-20230327 Received: from mtkmbs10n1.mediatek.inc [(172.21.101.34)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 2123455163; Mon, 27 Mar 2023 13:53:33 +0800 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by mtkmbs13n2.mediatek.inc (172.21.101.108) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.25; Mon, 27 Mar 2023 13:53:32 +0800 Received: from mhfsdcap04.gcn.mediatek.inc (10.17.3.154) by mtkmbs11n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.25 via Frontend Transport; Mon, 27 Mar 2023 13:53:31 +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 v3,4/7] media: mediatek: vcodec: Get each context resolution information Date: Mon, 27 Mar 2023 13:53:12 +0800 Message-ID: <20230327055315.13936-5-yunfei.dong@mediatek.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230327055315.13936-1-yunfei.dong@mediatek.com> References: <20230327055315.13936-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?1761499731964315823?= X-GMAIL-MSGID: =?utf-8?q?1761499731964315823?= 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 | 44 +++++++++++++++++++ .../mediatek/vcodec/mtk_vcodec_dbgfs.h | 8 ++++ 2 files changed, 52 insertions(+) diff --git a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.c b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.c index 49f0891e4923..19a1dc068efd 100644 --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.c +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.c @@ -27,9 +27,53 @@ 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 = 100 * (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); + + buf[used_len + 1] = '\0'; + 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