mtk_vcodec_util.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. struct mtk_vcodec_dev;
  26. extern int mtk_v4l2_dbg_level;
  27. extern bool mtk_vcodec_dbg;
  28. #define DEBUG 1
  29. #if defined(DEBUG)
  30. #define mtk_v4l2_debug(level, fmt, args...) \
  31. do { \
  32. if (mtk_v4l2_dbg_level >= level) \
  33. pr_info("[MTK_V4L2] level=%d %s(),%d: " fmt "\n",\
  34. level, __func__, __LINE__, ##args); \
  35. } while (0)
  36. #define mtk_v4l2_err(fmt, args...) \
  37. pr_err("[MTK_V4L2][ERROR] %s:%d: " fmt "\n", __func__, __LINE__, \
  38. ##args)
  39. #define mtk_v4l2_debug_enter() mtk_v4l2_debug(3, "+")
  40. #define mtk_v4l2_debug_leave() mtk_v4l2_debug(3, "-")
  41. #define mtk_vcodec_debug(h, fmt, args...) \
  42. do { \
  43. if (mtk_vcodec_dbg) \
  44. pr_info("[MTK_VCODEC][%d]: %s() " fmt "\n", \
  45. ((struct mtk_vcodec_ctx *)h->ctx)->id, \
  46. __func__, ##args); \
  47. } while (0)
  48. #define mtk_vcodec_err(h, fmt, args...) \
  49. pr_err("[MTK_VCODEC][ERROR][%d]: %s() " fmt "\n", \
  50. ((struct mtk_vcodec_ctx *)h->ctx)->id, __func__, ##args)
  51. #define mtk_vcodec_debug_enter(h) mtk_vcodec_debug(h, "+")
  52. #define mtk_vcodec_debug_leave(h) mtk_vcodec_debug(h, "-")
  53. #else
  54. #define mtk_v4l2_debug(level, fmt, args...)
  55. #define mtk_v4l2_err(fmt, args...)
  56. #define mtk_v4l2_debug_enter()
  57. #define mtk_v4l2_debug_leave()
  58. #define mtk_vcodec_debug(h, fmt, args...)
  59. #define mtk_vcodec_err(h, fmt, args...)
  60. #define mtk_vcodec_debug_enter(h)
  61. #define mtk_vcodec_debug_leave(h)
  62. #endif
  63. void __iomem *mtk_vcodec_get_reg_addr(struct mtk_vcodec_ctx *data,
  64. unsigned int reg_idx);
  65. int mtk_vcodec_mem_alloc(struct mtk_vcodec_ctx *data,
  66. struct mtk_vcodec_mem *mem);
  67. void mtk_vcodec_mem_free(struct mtk_vcodec_ctx *data,
  68. struct mtk_vcodec_mem *mem);
  69. void mtk_vcodec_set_curr_ctx(struct mtk_vcodec_dev *dev,
  70. struct mtk_vcodec_ctx *ctx);
  71. struct mtk_vcodec_ctx *mtk_vcodec_get_curr_ctx(struct mtk_vcodec_dev *dev);
  72. #endif /* _MTK_VCODEC_UTIL_H_ */