1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Copyright (c) 2016 MediaTek Inc.
4 * Author: PC Chen <pc.chen@mediatek.com>
5 * Tiffany Lin <tiffany.lin@mediatek.com>
8 #ifndef _MTK_VCODEC_UTIL_H_
9 #define _MTK_VCODEC_UTIL_H_
11 #include <linux/types.h>
12 #include <linux/dma-direction.h>
14 struct mtk_vcodec_mem {
20 struct mtk_vcodec_fb {
25 struct mtk_vcodec_ctx;
26 struct mtk_vcodec_dev;
29 #define pr_fmt(fmt) "%s(),%d: " fmt, __func__, __LINE__
31 #define mtk_v4l2_err(fmt, args...) \
32 pr_err("[MTK_V4L2][ERROR] " fmt "\n", ##args)
34 #define mtk_vcodec_err(h, fmt, args...) \
35 pr_err("[MTK_VCODEC][ERROR][%d]: " fmt "\n", \
36 ((struct mtk_vcodec_ctx *)(h)->ctx)->id, ##args)
38 #if defined(CONFIG_DEBUG_FS)
39 extern int mtk_v4l2_dbg_level;
40 extern int mtk_vcodec_dbg;
42 #define mtk_v4l2_debug(level, fmt, args...) \
44 if (mtk_v4l2_dbg_level >= (level)) \
45 pr_debug("[MTK_V4L2] %s, %d: " fmt "\n", \
46 __func__, __LINE__, ##args); \
49 #define mtk_vcodec_debug(h, fmt, args...) \
52 dev_dbg(&(((struct mtk_vcodec_ctx *)(h)->ctx)->dev->plat_dev->dev), \
53 "[MTK_VCODEC][%d]: %s, %d " fmt "\n", \
54 ((struct mtk_vcodec_ctx *)(h)->ctx)->id, \
55 __func__, __LINE__, ##args); \
58 #define mtk_v4l2_debug(level, fmt, args...) pr_debug(fmt, ##args)
60 #define mtk_vcodec_debug(h, fmt, args...) \
61 pr_debug("[MTK_VCODEC][%d]: " fmt "\n", \
62 ((struct mtk_vcodec_ctx *)(h)->ctx)->id, ##args)
65 #define mtk_v4l2_debug_enter() mtk_v4l2_debug(3, "+")
66 #define mtk_v4l2_debug_leave() mtk_v4l2_debug(3, "-")
68 #define mtk_vcodec_debug_enter(h) mtk_vcodec_debug(h, "+")
69 #define mtk_vcodec_debug_leave(h) mtk_vcodec_debug(h, "-")
71 void __iomem *mtk_vcodec_get_reg_addr(struct mtk_vcodec_ctx *data,
72 unsigned int reg_idx);
73 int mtk_vcodec_mem_alloc(struct mtk_vcodec_ctx *data,
74 struct mtk_vcodec_mem *mem);
75 void mtk_vcodec_mem_free(struct mtk_vcodec_ctx *data,
76 struct mtk_vcodec_mem *mem);
77 void mtk_vcodec_set_curr_ctx(struct mtk_vcodec_dev *vdec_dev,
78 struct mtk_vcodec_ctx *ctx, int hw_idx);
79 struct mtk_vcodec_ctx *mtk_vcodec_get_curr_ctx(struct mtk_vcodec_dev *vdec_dev,
81 void *mtk_vcodec_get_hw_dev(struct mtk_vcodec_dev *dev, int hw_idx);
83 #endif /* _MTK_VCODEC_UTIL_H_ */