vdec_drv_if.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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 _VDEC_DRV_IF_H_
  16. #define _VDEC_DRV_IF_H_
  17. #include "mtk_vcodec_drv.h"
  18. #include "mtk_vcodec_dec.h"
  19. #include "mtk_vcodec_util.h"
  20. /**
  21. * struct vdec_fb_status - decoder frame buffer status
  22. * @FB_ST_NORMAL : initial state
  23. * @FB_ST_DISPLAY : frmae buffer is ready to be displayed
  24. * @FB_ST_FREE : frame buffer is not used by decoder any more
  25. */
  26. enum vdec_fb_status {
  27. FB_ST_NORMAL = 0,
  28. FB_ST_DISPLAY = (1 << 0),
  29. FB_ST_FREE = (1 << 1)
  30. };
  31. /* For GET_PARAM_DISP_FRAME_BUFFER and GET_PARAM_FREE_FRAME_BUFFER,
  32. * the caller does not own the returned buffer. The buffer will not be
  33. * released before vdec_if_deinit.
  34. * GET_PARAM_DISP_FRAME_BUFFER : get next displayable frame buffer,
  35. * struct vdec_fb**
  36. * GET_PARAM_FREE_FRAME_BUFFER : get non-referenced framebuffer, vdec_fb**
  37. * GET_PARAM_PIC_INFO : get picture info, struct vdec_pic_info*
  38. * GET_PARAM_CROP_INFO : get crop info, struct v4l2_crop*
  39. * GET_PARAM_DPB_SIZE : get dpb size, unsigned int*
  40. */
  41. enum vdec_get_param_type {
  42. GET_PARAM_DISP_FRAME_BUFFER,
  43. GET_PARAM_FREE_FRAME_BUFFER,
  44. GET_PARAM_PIC_INFO,
  45. GET_PARAM_CROP_INFO,
  46. GET_PARAM_DPB_SIZE
  47. };
  48. /**
  49. * struct vdec_fb_node - decoder frame buffer node
  50. * @list : list to hold this node
  51. * @fb : point to frame buffer (vdec_fb), fb could point to frame buffer and
  52. * working buffer this is for maintain buffers in different state
  53. */
  54. struct vdec_fb_node {
  55. struct list_head list;
  56. struct vdec_fb *fb;
  57. };
  58. /**
  59. * vdec_if_init() - initialize decode driver
  60. * @ctx : [in] v4l2 context
  61. * @fourcc : [in] video format fourcc, V4L2_PIX_FMT_H264/VP8/VP9..
  62. */
  63. int vdec_if_init(struct mtk_vcodec_ctx *ctx, unsigned int fourcc);
  64. /**
  65. * vdec_if_deinit() - deinitialize decode driver
  66. * @ctx : [in] v4l2 context
  67. *
  68. */
  69. void vdec_if_deinit(struct mtk_vcodec_ctx *ctx);
  70. /**
  71. * vdec_if_decode() - trigger decode
  72. * @ctx : [in] v4l2 context
  73. * @bs : [in] input bitstream
  74. * @fb : [in] frame buffer to store decoded frame, when null menas parse
  75. * header only
  76. * @res_chg : [out] resolution change happens if current bs have different
  77. * picture width/height
  78. * Note: To flush the decoder when reaching EOF, set input bitstream as NULL.
  79. *
  80. * Return: 0 on success. -EIO on unrecoverable error.
  81. */
  82. int vdec_if_decode(struct mtk_vcodec_ctx *ctx, struct mtk_vcodec_mem *bs,
  83. struct vdec_fb *fb, bool *res_chg);
  84. /**
  85. * vdec_if_get_param() - get driver's parameter
  86. * @ctx : [in] v4l2 context
  87. * @type : [in] input parameter type
  88. * @out : [out] buffer to store query result
  89. */
  90. int vdec_if_get_param(struct mtk_vcodec_ctx *ctx, enum vdec_get_param_type type,
  91. void *out);
  92. #endif