Re: [PATCH v2,2/7] media: mediatek: vcodec: Add debug params to control different log level

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Il 22/03/23 10:46, Yunfei Dong ha scritto:
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 <yunfei.dong@xxxxxxxxxxxx>
---
  .../mediatek/vcodec/mtk_vcodec_dbgfs.c        |  2 ++
  .../mediatek/vcodec/mtk_vcodec_util.c         |  8 ++++++
  .../mediatek/vcodec/mtk_vcodec_util.h         | 25 ++++++++++++++++---
  3 files changed, 32 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..938f03cab3c9 100644
--- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_util.h
+++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_util.h
@@ -35,15 +35,34 @@ 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_info("[MTK_V4L2] level=%d %s(),%d: " fmt "\n", \

These shall still be *debug* and not *info*, even if you're controlling the
log level from debugfs, as these are anyway debugging prints which can be
automatically optimized out for a kernel build with *no debug at all*.

The loglevel control is a commodity that should be meant to avoid too much
spam for readability and/or selectively enable "components" logging, because
then there's also the tracing framework providing maximum verbosity.

Besides, I'd be happy if this finally becomes dev_dbg instead of pr_debug.

Regards,
Angelo





[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux