mtk_vcodec_util.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*
  2. * Copyright (c) 2016 MediaTek Inc.
  3. * Author: PC Chen <pc.chen@mediatek.com>
  4. * Tiffany Lin <tiffany.lin@mediatek.com>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. */
  15. #ifndef _MTK_VCODEC_UTIL_H_
  16. #define _MTK_VCODEC_UTIL_H_
  17. #include <linux/types.h>
  18. #include <linux/dma-direction.h>
  19. struct mtk_vcodec_mem {
  20. size_t size;
  21. void *va;
  22. dma_addr_t dma_addr;
  23. };
  24. struct mtk_vcodec_ctx;
  25. extern int mtk_v4l2_dbg_level;
  26. extern bool mtk_vcodec_dbg;
  27. #define DEBUG 1
  28. #if defined(DEBUG)
  29. #define mtk_v4l2_debug(level, fmt, args...) \
  30. do { \
  31. if (mtk_v4l2_dbg_level >= level) \
  32. pr_info("[MTK_V4L2] level=%d %s(),%d: " fmt "\n",\
  33. level, __func__, __LINE__, ##args); \
  34. } while (0)
  35. #define mtk_v4l2_err(fmt, args...) \
  36. pr_err("[MTK_V4L2][ERROR] %s:%d: " fmt "\n", __func__, __LINE__, \
  37. ##args)
  38. #define mtk_v4l2_debug_enter() mtk_v4l2_debug(3, "+")
  39. #define mtk_v4l2_debug_leave() mtk_v4l2_debug(3, "-")
  40. #define mtk_vcodec_debug(h, fmt, args...) \
  41. do { \
  42. if (mtk_vcodec_dbg) \
  43. pr_info("[MTK_VCODEC][%d]: %s() " fmt "\n", \
  44. ((struct mtk_vcodec_ctx *)h->ctx)->id, \
  45. __func__, ##args); \
  46. } while (0)
  47. #define mtk_vcodec_err(h, fmt, args...) \
  48. pr_err("[MTK_VCODEC][ERROR][%d]: %s() " fmt "\n", \
  49. ((struct mtk_vcodec_ctx *)h->ctx)->id, __func__, ##args)
  50. #define mtk_vcodec_debug_enter(h) mtk_vcodec_debug(h, "+")
  51. #define mtk_vcodec_debug_leave(h) mtk_vcodec_debug(h, "-")
  52. #else
  53. #define mtk_v4l2_debug(level, fmt, args...)
  54. #define mtk_v4l2_err(fmt, args...)
  55. #define mtk_v4l2_debug_enter()
  56. #define mtk_v4l2_debug_leave()
  57. #define mtk_vcodec_debug(h, fmt, args...)
  58. #define mtk_vcodec_err(h, fmt, args...)
  59. #define mtk_vcodec_debug_enter(h)
  60. #define mtk_vcodec_debug_leave(h)
  61. #endif
  62. void __iomem *mtk_vcodec_get_reg_addr(struct mtk_vcodec_ctx *data,
  63. unsigned int reg_idx);
  64. int mtk_vcodec_mem_alloc(struct mtk_vcodec_ctx *data,
  65. struct mtk_vcodec_mem *mem);
  66. void mtk_vcodec_mem_free(struct mtk_vcodec_ctx *data,
  67. struct mtk_vcodec_mem *mem);
  68. #endif /* _MTK_VCODEC_UTIL_H_ */