1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* 3 * Copyright (c) 2016 MediaTek Inc. 4 * Author: PC Chen <pc.chen@mediatek.com> 5 * Tiffany Lin <tiffany.lin@mediatek.com> 6 */ 7 8 #ifndef _MTK_VCODEC_UTIL_H_ 9 #define _MTK_VCODEC_UTIL_H_ 10 11 #include <linux/types.h> 12 #include <linux/dma-direction.h> 13 14 struct mtk_vcodec_mem { 15 size_t size; 16 void *va; 17 dma_addr_t dma_addr; 18 }; 19 20 struct mtk_vcodec_fb { 21 size_t size; 22 dma_addr_t dma_addr; 23 }; 24 25 struct mtk_vcodec_ctx; 26 struct mtk_vcodec_dev; 27 28 #undef pr_fmt 29 #define pr_fmt(fmt) "%s(),%d: " fmt, __func__, __LINE__ 30 31 #define mtk_v4l2_err(fmt, args...) \ 32 pr_err("[MTK_V4L2][ERROR] " fmt "\n", ##args) 33 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) 37 38 39 #define mtk_v4l2_debug(level, fmt, args...) pr_debug(fmt, ##args) 40 41 #define mtk_v4l2_debug_enter() mtk_v4l2_debug(3, "+") 42 #define mtk_v4l2_debug_leave() mtk_v4l2_debug(3, "-") 43 44 #define mtk_vcodec_debug(h, fmt, args...) \ 45 pr_debug("[MTK_VCODEC][%d]: " fmt "\n", \ 46 ((struct mtk_vcodec_ctx *)(h)->ctx)->id, ##args) 47 48 #define mtk_vcodec_debug_enter(h) mtk_vcodec_debug(h, "+") 49 #define mtk_vcodec_debug_leave(h) mtk_vcodec_debug(h, "-") 50 51 void __iomem *mtk_vcodec_get_reg_addr(struct mtk_vcodec_ctx *data, 52 unsigned int reg_idx); 53 int mtk_vcodec_mem_alloc(struct mtk_vcodec_ctx *data, 54 struct mtk_vcodec_mem *mem); 55 void mtk_vcodec_mem_free(struct mtk_vcodec_ctx *data, 56 struct mtk_vcodec_mem *mem); 57 void mtk_vcodec_set_curr_ctx(struct mtk_vcodec_dev *vdec_dev, 58 struct mtk_vcodec_ctx *ctx, int hw_idx); 59 struct mtk_vcodec_ctx *mtk_vcodec_get_curr_ctx(struct mtk_vcodec_dev *vdec_dev, 60 unsigned int hw_idx); 61 void *mtk_vcodec_get_hw_dev(struct mtk_vcodec_dev *dev, int hw_idx); 62 63 #endif /* _MTK_VCODEC_UTIL_H_ */ 64