mtk_vcodec_dec.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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_DEC_H_
  16. #define _MTK_VCODEC_DEC_H_
  17. #include <media/videobuf2-core.h>
  18. #include <media/videobuf2-v4l2.h>
  19. #define VCODEC_CAPABILITY_4K_DISABLED 0x10
  20. #define VCODEC_DEC_4K_CODED_WIDTH 4096U
  21. #define VCODEC_DEC_4K_CODED_HEIGHT 2304U
  22. #define MTK_VDEC_MAX_W 2048U
  23. #define MTK_VDEC_MAX_H 1088U
  24. #define MTK_VDEC_IRQ_STATUS_DEC_SUCCESS 0x10000
  25. /**
  26. * struct vdec_fb - decoder frame buffer
  27. * @base_y : Y plane memory info
  28. * @base_c : C plane memory info
  29. * @status : frame buffer status (vdec_fb_status)
  30. */
  31. struct vdec_fb {
  32. struct mtk_vcodec_mem base_y;
  33. struct mtk_vcodec_mem base_c;
  34. unsigned int status;
  35. };
  36. /**
  37. * struct mtk_video_dec_buf - Private data related to each VB2 buffer.
  38. * @b: VB2 buffer
  39. * @list: link list
  40. * @used: Capture buffer contain decoded frame data and keep in
  41. * codec data structure
  42. * @ready_to_display: Capture buffer not display yet
  43. * @queued_in_vb2: Capture buffer is queue in vb2
  44. * @queued_in_v4l2: Capture buffer is in v4l2 driver, but not in vb2
  45. * queue yet
  46. * @lastframe: Intput buffer is last buffer - EOS
  47. * @error: An unrecoverable error occurs on this buffer.
  48. * @frame_buffer: Decode status, and buffer information of Capture buffer
  49. *
  50. * Note : These status information help us track and debug buffer state
  51. */
  52. struct mtk_video_dec_buf {
  53. struct vb2_v4l2_buffer vb;
  54. struct list_head list;
  55. bool used;
  56. bool ready_to_display;
  57. bool queued_in_vb2;
  58. bool queued_in_v4l2;
  59. bool lastframe;
  60. bool error;
  61. struct vdec_fb frame_buffer;
  62. };
  63. extern const struct v4l2_ioctl_ops mtk_vdec_ioctl_ops;
  64. extern const struct v4l2_m2m_ops mtk_vdec_m2m_ops;
  65. /*
  66. * mtk_vdec_lock/mtk_vdec_unlock are for ctx instance to
  67. * get/release lock before/after access decoder hw.
  68. * mtk_vdec_lock get decoder hw lock and set curr_ctx
  69. * to ctx instance that get lock
  70. */
  71. void mtk_vdec_unlock(struct mtk_vcodec_ctx *ctx);
  72. void mtk_vdec_lock(struct mtk_vcodec_ctx *ctx);
  73. int mtk_vcodec_dec_queue_init(void *priv, struct vb2_queue *src_vq,
  74. struct vb2_queue *dst_vq);
  75. void mtk_vcodec_dec_set_default_params(struct mtk_vcodec_ctx *ctx);
  76. void mtk_vcodec_dec_release(struct mtk_vcodec_ctx *ctx);
  77. int mtk_vcodec_dec_ctrls_setup(struct mtk_vcodec_ctx *ctx);
  78. #endif /* _MTK_VCODEC_DEC_H_ */