media: mtk-vcodec: fix debugging defines
authorDafna Hirschfeld <dafna.hirschfeld@collabora.com>
Wed, 17 Nov 2021 13:06:32 +0000 (14:06 +0100)
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Tue, 30 Nov 2021 11:18:34 +0000 (12:18 +0100)
The mtk-vcodec uses some internal defined debug formats for
printing. This patch fixes some things in those defines:

1. use the 'pr_fmt' define to print function name and line.

2. remove 'if(DEBUG)' condition for the defines. This condition
prevents the debugs from being shown in case of dynamic debugs.
Instead replace 'pr_info' with 'pr_debug'

3. remove module parameters that enable/disable debug.
There is no reason for the driver to have those params. Having
those params require the user to explicitly set them when user
wants to see debug prints instead of using the global debugs
setting as expected by drivers to conform.

In addition to that, fix some warnings about debug formatting

[hverkuil: used %zu instead of %lu for sizeof() arguments]

Signed-off-by: Dafna Hirschfeld <dafna.hirschfeld@collabora.com>
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c
drivers/media/platform/mtk-vcodec/mtk_vcodec_util.c
drivers/media/platform/mtk-vcodec/mtk_vcodec_util.h
drivers/media/platform/mtk-vcodec/vdec/vdec_h264_req_if.c

index 5d72fce154d8ef3128d976cd384600f10ed46d53..40c39e1e596b939ff2658ace7d52d4fbcd8a370b 100644 (file)
@@ -28,9 +28,6 @@
 #define VDEC_IRQ_CLR   0x10
 #define VDEC_IRQ_CFG_REG       0xa4
 
-module_param(mtk_v4l2_dbg_level, int, 0644);
-module_param(mtk_vcodec_dbg, bool, 0644);
-
 /* Wake up context wait_queue */
 static void wake_up_ctx(struct mtk_vcodec_ctx *ctx)
 {
index fa7b495c778b2a9639f38b43260ff27e3791be9b..aeaecb8d416e30b2b7143cc6bb68f372fd8da667 100644 (file)
@@ -23,9 +23,6 @@
 #include "mtk_vcodec_util.h"
 #include "mtk_vcodec_fw.h"
 
-module_param(mtk_v4l2_dbg_level, int, S_IRUGO | S_IWUSR);
-module_param(mtk_vcodec_dbg, bool, S_IRUGO | S_IWUSR);
-
 static const struct mtk_video_fmt mtk_video_formats_output[] = {
        {
                .fourcc = V4L2_PIX_FMT_NV12M,
index ac5973b6735f169321608aa4bcc5dd517156ac29..5bac820a47fc45e5b480a107336bf97f73e9aef9 100644 (file)
 #include "mtk_vcodec_drv.h"
 #include "mtk_vcodec_util.h"
 
-/* For encoder, this will enable logs in venc/*/
-bool mtk_vcodec_dbg;
-EXPORT_SYMBOL(mtk_vcodec_dbg);
-
-/* The log level of v4l2 encoder or decoder driver.
- * That is, files under mtk-vcodec/.
- */
-int mtk_v4l2_dbg_level;
-EXPORT_SYMBOL(mtk_v4l2_dbg_level);
-
 void __iomem *mtk_vcodec_get_reg_addr(struct mtk_vcodec_ctx *data,
                                        unsigned int reg_idx)
 {
index b999d7b84ed18d0d6bf753758ec89137f42e8e08..87c3d6d4bfa77a37eaf56dd89b360945881f71eb 100644 (file)
@@ -25,54 +25,29 @@ struct mtk_vcodec_fb {
 struct mtk_vcodec_ctx;
 struct mtk_vcodec_dev;
 
-extern int mtk_v4l2_dbg_level;
-extern bool mtk_vcodec_dbg;
-
+#undef pr_fmt
+#define pr_fmt(fmt) "%s(),%d: " fmt, __func__, __LINE__
 
 #define mtk_v4l2_err(fmt, args...)                \
-       pr_err("[MTK_V4L2][ERROR] %s:%d: " fmt "\n", __func__, __LINE__, \
-              ##args)
-
-#define mtk_vcodec_err(h, fmt, args...)                                        \
-       pr_err("[MTK_VCODEC][ERROR][%d]: %s() " fmt "\n",               \
-              ((struct mtk_vcodec_ctx *)h->ctx)->id, __func__, ##args)
+       pr_err("[MTK_V4L2][ERROR] " fmt "\n", ##args)
 
+#define mtk_vcodec_err(h, fmt, args...)                                \
+       pr_err("[MTK_VCODEC][ERROR][%d]: " fmt "\n",            \
+              ((struct mtk_vcodec_ctx *)(h)->ctx)->id, ##args)
 
-#if defined(DEBUG)
 
-#define mtk_v4l2_debug(level, fmt, args...)                             \
-       do {                                                             \
-               if (mtk_v4l2_dbg_level >= level)                         \
-                       pr_info("[MTK_V4L2] level=%d %s(),%d: " fmt "\n",\
-                               level, __func__, __LINE__, ##args);      \
-       } while (0)
+#define mtk_v4l2_debug(level, fmt, args...) pr_debug(fmt, ##args)
 
 #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)                                     \
-                       pr_info("[MTK_VCODEC][%d]: %s() " fmt "\n",     \
-                               ((struct mtk_vcodec_ctx *)h->ctx)->id, \
-                               __func__, ##args);                      \
-       } while (0)
+#define mtk_vcodec_debug(h, fmt, args...)                      \
+       pr_debug("[MTK_VCODEC][%d]: " fmt "\n",                 \
+               ((struct mtk_vcodec_ctx *)(h)->ctx)->id, ##args)
 
 #define mtk_vcodec_debug_enter(h)  mtk_vcodec_debug(h, "+")
 #define mtk_vcodec_debug_leave(h)  mtk_vcodec_debug(h, "-")
 
-#else
-
-#define mtk_v4l2_debug(level, fmt, args...) {}
-#define mtk_v4l2_debug_enter() {}
-#define mtk_v4l2_debug_leave() {}
-
-#define mtk_vcodec_debug(h, fmt, args...) {}
-#define mtk_vcodec_debug_enter(h) {}
-#define mtk_vcodec_debug_leave(h) {}
-
-#endif
-
 void __iomem *mtk_vcodec_get_reg_addr(struct mtk_vcodec_ctx *data,
                                unsigned int reg_idx);
 int mtk_vcodec_mem_alloc(struct mtk_vcodec_ctx *data,
index 5a7eefe639a8199dcc959999793145d06d4d8526..fada4d1467030e3731d598b7177f28ca9da12dd7 100644 (file)
@@ -527,7 +527,7 @@ static int alloc_mv_buf(struct vdec_h264_slice_inst *inst,
        struct mtk_vcodec_mem *mem = NULL;
        unsigned int buf_sz = get_mv_buf_size(pic->buf_w, pic->buf_h);
 
-       mtk_v4l2_debug(3, "size = 0x%lx", buf_sz);
+       mtk_v4l2_debug(3, "size = 0x%x", buf_sz);
        for (i = 0; i < H264_MAX_MV_NUM; i++) {
                mem = &inst->mv_buf[i];
                if (mem->va)
@@ -637,7 +637,7 @@ static int vdec_h264_slice_init(struct mtk_vcodec_ctx *ctx)
        if (err)
                goto error_deinit;
 
-       mtk_vcodec_debug(inst, "struct size = %d,%d,%d,%d\n",
+       mtk_vcodec_debug(inst, "struct size = %zu,%zu,%zu,%zu\n",
                         sizeof(struct mtk_h264_sps_param),
                         sizeof(struct mtk_h264_pps_param),
                         sizeof(struct mtk_h264_dec_slice_param),