venc_ipi_msg.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. /*
  2. * Copyright (c) 2016 MediaTek Inc.
  3. * Author: Jungchang Tsao <jungchang.tsao@mediatek.com>
  4. * Daniel Hsiao <daniel.hsiao@mediatek.com>
  5. * Tiffany Lin <tiffany.lin@mediatek.com>
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify
  9. * it under the terms of the GNU General Public License version 2 as
  10. * published by the Free Software Foundation.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. */
  17. #ifndef _VENC_IPI_MSG_H_
  18. #define _VENC_IPI_MSG_H_
  19. #define AP_IPIMSG_VENC_BASE 0xC000
  20. #define VPU_IPIMSG_VENC_BASE 0xD000
  21. /**
  22. * enum venc_ipi_msg_id - message id between AP and VPU
  23. * (ipi stands for inter-processor interrupt)
  24. * @AP_IPIMSG_ENC_XXX: AP to VPU cmd message id
  25. * @VPU_IPIMSG_ENC_XXX_DONE: VPU ack AP cmd message id
  26. */
  27. enum venc_ipi_msg_id {
  28. AP_IPIMSG_ENC_INIT = AP_IPIMSG_VENC_BASE,
  29. AP_IPIMSG_ENC_SET_PARAM,
  30. AP_IPIMSG_ENC_ENCODE,
  31. AP_IPIMSG_ENC_DEINIT,
  32. VPU_IPIMSG_ENC_INIT_DONE = VPU_IPIMSG_VENC_BASE,
  33. VPU_IPIMSG_ENC_SET_PARAM_DONE,
  34. VPU_IPIMSG_ENC_ENCODE_DONE,
  35. VPU_IPIMSG_ENC_DEINIT_DONE,
  36. };
  37. /**
  38. * struct venc_ap_ipi_msg_init - AP to VPU init cmd structure
  39. * @msg_id: message id (AP_IPIMSG_XXX_ENC_INIT)
  40. * @reserved: reserved for future use. vpu is running in 32bit. Without
  41. * this reserved field, if kernel run in 64bit. this struct size
  42. * will be different between kernel and vpu
  43. * @venc_inst: AP encoder instance
  44. * (struct venc_vp8_inst/venc_h264_inst *)
  45. */
  46. struct venc_ap_ipi_msg_init {
  47. uint32_t msg_id;
  48. uint32_t reserved;
  49. uint64_t venc_inst;
  50. };
  51. /**
  52. * struct venc_ap_ipi_msg_set_param - AP to VPU set_param cmd structure
  53. * @msg_id: message id (AP_IPIMSG_XXX_ENC_SET_PARAM)
  54. * @vpu_inst_addr: VPU encoder instance addr
  55. * (struct venc_vp8_vsi/venc_h264_vsi *)
  56. * @param_id: parameter id (venc_set_param_type)
  57. * @data_item: number of items in the data array
  58. * @data[8]: data array to store the set parameters
  59. */
  60. struct venc_ap_ipi_msg_set_param {
  61. uint32_t msg_id;
  62. uint32_t vpu_inst_addr;
  63. uint32_t param_id;
  64. uint32_t data_item;
  65. uint32_t data[8];
  66. };
  67. /**
  68. * struct venc_ap_ipi_msg_enc - AP to VPU enc cmd structure
  69. * @msg_id: message id (AP_IPIMSG_XXX_ENC_ENCODE)
  70. * @vpu_inst_addr: VPU encoder instance addr
  71. * (struct venc_vp8_vsi/venc_h264_vsi *)
  72. * @bs_mode: bitstream mode for h264
  73. * (H264_BS_MODE_SPS/H264_BS_MODE_PPS/H264_BS_MODE_FRAME)
  74. * @input_addr: pointer to input image buffer plane
  75. * @bs_addr: pointer to output bit stream buffer
  76. * @bs_size: bit stream buffer size
  77. */
  78. struct venc_ap_ipi_msg_enc {
  79. uint32_t msg_id;
  80. uint32_t vpu_inst_addr;
  81. uint32_t bs_mode;
  82. uint32_t input_addr[3];
  83. uint32_t bs_addr;
  84. uint32_t bs_size;
  85. };
  86. /**
  87. * struct venc_ap_ipi_msg_deinit - AP to VPU deinit cmd structure
  88. * @msg_id: message id (AP_IPIMSG_XXX_ENC_DEINIT)
  89. * @vpu_inst_addr: VPU encoder instance addr
  90. * (struct venc_vp8_vsi/venc_h264_vsi *)
  91. */
  92. struct venc_ap_ipi_msg_deinit {
  93. uint32_t msg_id;
  94. uint32_t vpu_inst_addr;
  95. };
  96. /**
  97. * enum venc_ipi_msg_status - VPU ack AP cmd status
  98. */
  99. enum venc_ipi_msg_status {
  100. VENC_IPI_MSG_STATUS_OK,
  101. VENC_IPI_MSG_STATUS_FAIL,
  102. };
  103. /**
  104. * struct venc_vpu_ipi_msg_common - VPU ack AP cmd common structure
  105. * @msg_id: message id (VPU_IPIMSG_XXX_DONE)
  106. * @status: cmd status (venc_ipi_msg_status)
  107. * @venc_inst: AP encoder instance (struct venc_vp8_inst/venc_h264_inst *)
  108. */
  109. struct venc_vpu_ipi_msg_common {
  110. uint32_t msg_id;
  111. uint32_t status;
  112. uint64_t venc_inst;
  113. };
  114. /**
  115. * struct venc_vpu_ipi_msg_init - VPU ack AP init cmd structure
  116. * @msg_id: message id (VPU_IPIMSG_XXX_ENC_SET_PARAM_DONE)
  117. * @status: cmd status (venc_ipi_msg_status)
  118. * @venc_inst: AP encoder instance (struct venc_vp8_inst/venc_h264_inst *)
  119. * @vpu_inst_addr: VPU encoder instance addr
  120. * (struct venc_vp8_vsi/venc_h264_vsi *)
  121. * @reserved: reserved for future use. vpu is running in 32bit. Without
  122. * this reserved field, if kernel run in 64bit. this struct size
  123. * will be different between kernel and vpu
  124. */
  125. struct venc_vpu_ipi_msg_init {
  126. uint32_t msg_id;
  127. uint32_t status;
  128. uint64_t venc_inst;
  129. uint32_t vpu_inst_addr;
  130. uint32_t reserved;
  131. };
  132. /**
  133. * struct venc_vpu_ipi_msg_set_param - VPU ack AP set_param cmd structure
  134. * @msg_id: message id (VPU_IPIMSG_XXX_ENC_SET_PARAM_DONE)
  135. * @status: cmd status (venc_ipi_msg_status)
  136. * @venc_inst: AP encoder instance (struct venc_vp8_inst/venc_h264_inst *)
  137. * @param_id: parameter id (venc_set_param_type)
  138. * @data_item: number of items in the data array
  139. * @data[6]: data array to store the return result
  140. */
  141. struct venc_vpu_ipi_msg_set_param {
  142. uint32_t msg_id;
  143. uint32_t status;
  144. uint64_t venc_inst;
  145. uint32_t param_id;
  146. uint32_t data_item;
  147. uint32_t data[6];
  148. };
  149. /**
  150. * enum venc_ipi_msg_enc_state - Type of encode state
  151. * VEN_IPI_MSG_ENC_STATE_FRAME: one frame being encoded
  152. * VEN_IPI_MSG_ENC_STATE_PART: bit stream buffer full
  153. * VEN_IPI_MSG_ENC_STATE_SKIP: encoded skip frame
  154. * VEN_IPI_MSG_ENC_STATE_ERROR: encounter error
  155. */
  156. enum venc_ipi_msg_enc_state {
  157. VEN_IPI_MSG_ENC_STATE_FRAME,
  158. VEN_IPI_MSG_ENC_STATE_PART,
  159. VEN_IPI_MSG_ENC_STATE_SKIP,
  160. VEN_IPI_MSG_ENC_STATE_ERROR,
  161. };
  162. /**
  163. * struct venc_vpu_ipi_msg_enc - VPU ack AP enc cmd structure
  164. * @msg_id: message id (VPU_IPIMSG_XXX_ENC_ENCODE_DONE)
  165. * @status: cmd status (venc_ipi_msg_status)
  166. * @venc_inst: AP encoder instance (struct venc_vp8_inst/venc_h264_inst *)
  167. * @state: encode state (venc_ipi_msg_enc_state)
  168. * @is_key_frm: whether the encoded frame is key frame
  169. * @bs_size: encoded bitstream size
  170. * @reserved: reserved for future use. vpu is running in 32bit. Without
  171. * this reserved field, if kernel run in 64bit. this struct size
  172. * will be different between kernel and vpu
  173. */
  174. struct venc_vpu_ipi_msg_enc {
  175. uint32_t msg_id;
  176. uint32_t status;
  177. uint64_t venc_inst;
  178. uint32_t state;
  179. uint32_t is_key_frm;
  180. uint32_t bs_size;
  181. uint32_t reserved;
  182. };
  183. /**
  184. * struct venc_vpu_ipi_msg_deinit - VPU ack AP deinit cmd structure
  185. * @msg_id: message id (VPU_IPIMSG_XXX_ENC_DEINIT_DONE)
  186. * @status: cmd status (venc_ipi_msg_status)
  187. * @venc_inst: AP encoder instance (struct venc_vp8_inst/venc_h264_inst *)
  188. */
  189. struct venc_vpu_ipi_msg_deinit {
  190. uint32_t msg_id;
  191. uint32_t status;
  192. uint64_t venc_inst;
  193. };
  194. #endif /* _VENC_IPI_MSG_H_ */