vdec_vpu_if.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /*
  2. * Copyright (c) 2016 MediaTek Inc.
  3. * Author: PC Chen <pc.chen@mediatek.com>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License version 2 as
  7. * published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. */
  14. #ifndef _VDEC_VPU_IF_H_
  15. #define _VDEC_VPU_IF_H_
  16. #include "mtk_vpu.h"
  17. /**
  18. * struct vdec_vpu_inst - VPU instance for video codec
  19. * @ipi_id : ipi id for each decoder
  20. * @vsi : driver structure allocated by VPU side and shared to AP side
  21. * for control and info share
  22. * @failure : VPU execution result status, 0: success, others: fail
  23. * @inst_addr : VPU decoder instance address
  24. * @signaled : 1 - Host has received ack message from VPU, 0 - not received
  25. * @ctx : context for v4l2 layer integration
  26. * @dev : platform device of VPU
  27. * @wq : wait queue to wait VPU message ack
  28. * @handler : ipi handler for each decoder
  29. */
  30. struct vdec_vpu_inst {
  31. enum ipi_id id;
  32. void *vsi;
  33. int32_t failure;
  34. uint32_t inst_addr;
  35. unsigned int signaled;
  36. struct mtk_vcodec_ctx *ctx;
  37. struct platform_device *dev;
  38. wait_queue_head_t wq;
  39. ipi_handler_t handler;
  40. };
  41. /**
  42. * vpu_dec_init - init decoder instance and allocate required resource in VPU.
  43. *
  44. * @vpu: instance for vdec_vpu_inst
  45. */
  46. int vpu_dec_init(struct vdec_vpu_inst *vpu);
  47. /**
  48. * vpu_dec_start - start decoding, basically the function will be invoked once
  49. * every frame.
  50. *
  51. * @vpu : instance for vdec_vpu_inst
  52. * @data: meta data to pass bitstream info to VPU decoder
  53. * @len : meta data length
  54. */
  55. int vpu_dec_start(struct vdec_vpu_inst *vpu, uint32_t *data, unsigned int len);
  56. /**
  57. * vpu_dec_end - end decoding, basically the function will be invoked once
  58. * when HW decoding done interrupt received successfully. The
  59. * decoder in VPU will continute to do referene frame management
  60. * and check if there is a new decoded frame available to display.
  61. *
  62. * @vpu : instance for vdec_vpu_inst
  63. */
  64. int vpu_dec_end(struct vdec_vpu_inst *vpu);
  65. /**
  66. * vpu_dec_deinit - deinit decoder instance and resource freed in VPU.
  67. *
  68. * @vpu: instance for vdec_vpu_inst
  69. */
  70. int vpu_dec_deinit(struct vdec_vpu_inst *vpu);
  71. /**
  72. * vpu_dec_reset - reset decoder, use for flush decoder when end of stream or
  73. * seek. Remainig non displayed frame will be pushed to display.
  74. *
  75. * @vpu: instance for vdec_vpu_inst
  76. */
  77. int vpu_dec_reset(struct vdec_vpu_inst *vpu);
  78. /**
  79. * vpu_dec_ipi_handler - Handler for VPU ipi message.
  80. *
  81. * @data: ipi message
  82. * @len : length of ipi message
  83. * @priv: callback private data which is passed by decoder when register.
  84. */
  85. void vpu_dec_ipi_handler(void *data, unsigned int len, void *priv);
  86. #endif