1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16#ifndef _MTK_VCODEC_UTIL_H_
17#define _MTK_VCODEC_UTIL_H_
18
19#include <linux/types.h>
20#include <linux/dma-direction.h>
21
22struct mtk_vcodec_mem {
23 size_t size;
24 void *va;
25 dma_addr_t dma_addr;
26};
27
28struct mtk_vcodec_ctx;
29struct mtk_vcodec_dev;
30
31extern int mtk_v4l2_dbg_level;
32extern bool mtk_vcodec_dbg;
33
34
35#define mtk_v4l2_err(fmt, args...) \
36 pr_err("[MTK_V4L2][ERROR] %s:%d: " fmt "\n", __func__, __LINE__, \
37 ##args)
38
39#define mtk_vcodec_err(h, fmt, args...) \
40 pr_err("[MTK_VCODEC][ERROR][%d]: %s() " fmt "\n", \
41 ((struct mtk_vcodec_ctx *)h->ctx)->id, __func__, ##args)
42
43
44#if defined(DEBUG)
45
46#define mtk_v4l2_debug(level, fmt, args...) \
47 do { \
48 if (mtk_v4l2_dbg_level >= level) \
49 pr_info("[MTK_V4L2] level=%d %s(),%d: " fmt "\n",\
50 level, __func__, __LINE__, ##args); \
51 } while (0)
52
53#define mtk_v4l2_debug_enter() mtk_v4l2_debug(3, "+")
54#define mtk_v4l2_debug_leave() mtk_v4l2_debug(3, "-")
55
56#define mtk_vcodec_debug(h, fmt, args...) \
57 do { \
58 if (mtk_vcodec_dbg) \
59 pr_info("[MTK_VCODEC][%d]: %s() " fmt "\n", \
60 ((struct mtk_vcodec_ctx *)h->ctx)->id, \
61 __func__, ##args); \
62 } while (0)
63
64#define mtk_vcodec_debug_enter(h) mtk_vcodec_debug(h, "+")
65#define mtk_vcodec_debug_leave(h) mtk_vcodec_debug(h, "-")
66
67#else
68
69#define mtk_v4l2_debug(level, fmt, args...) {}
70#define mtk_v4l2_debug_enter() {}
71#define mtk_v4l2_debug_leave() {}
72
73#define mtk_vcodec_debug(h, fmt, args...) {}
74#define mtk_vcodec_debug_enter(h) {}
75#define mtk_vcodec_debug_leave(h) {}
76
77#endif
78
79void __iomem *mtk_vcodec_get_reg_addr(struct mtk_vcodec_ctx *data,
80 unsigned int reg_idx);
81int mtk_vcodec_mem_alloc(struct mtk_vcodec_ctx *data,
82 struct mtk_vcodec_mem *mem);
83void mtk_vcodec_mem_free(struct mtk_vcodec_ctx *data,
84 struct mtk_vcodec_mem *mem);
85void mtk_vcodec_set_curr_ctx(struct mtk_vcodec_dev *dev,
86 struct mtk_vcodec_ctx *ctx);
87struct mtk_vcodec_ctx *mtk_vcodec_get_curr_ctx(struct mtk_vcodec_dev *dev);
88
89#endif
90