msm_vidc.h 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. #ifndef _MSM_VIDC_H_
  2. #define _MSM_VIDC_H_
  3. #ifdef __KERNEL__
  4. #include <linux/poll.h>
  5. #include <linux/videodev2.h>
  6. enum core_id {
  7. MSM_VIDC_CORE_VENUS = 0,
  8. MSM_VIDC_CORE_Q6,
  9. MSM_VIDC_CORES_MAX,
  10. };
  11. enum session_type {
  12. MSM_VIDC_ENCODER = 0,
  13. MSM_VIDC_DECODER,
  14. MSM_VIDC_MAX_DEVICES,
  15. };
  16. /* NOTE: if you change this enum you MUST update the
  17. * "buffer-type-tz-usage-table" for any affected target
  18. * in arch/arm/boot/dts/<arch>.dtsi
  19. */
  20. enum hal_buffer {
  21. HAL_BUFFER_INPUT = 0x1,
  22. HAL_BUFFER_OUTPUT = 0x2,
  23. HAL_BUFFER_OUTPUT2 = 0x4,
  24. HAL_BUFFER_EXTRADATA_INPUT = 0x8,
  25. HAL_BUFFER_EXTRADATA_OUTPUT = 0x10,
  26. HAL_BUFFER_EXTRADATA_OUTPUT2 = 0x20,
  27. HAL_BUFFER_INTERNAL_SCRATCH = 0x40,
  28. HAL_BUFFER_INTERNAL_SCRATCH_1 = 0x80,
  29. HAL_BUFFER_INTERNAL_SCRATCH_2 = 0x100,
  30. HAL_BUFFER_INTERNAL_PERSIST = 0x200,
  31. HAL_BUFFER_INTERNAL_PERSIST_1 = 0x400,
  32. HAL_BUFFER_INTERNAL_CMD_QUEUE = 0x800,
  33. };
  34. struct msm_smem {
  35. int mem_type;
  36. size_t size;
  37. void *kvaddr;
  38. unsigned long device_addr;
  39. u32 flags;
  40. void *smem_priv;
  41. enum hal_buffer buffer_type;
  42. };
  43. enum smem_cache_ops {
  44. SMEM_CACHE_CLEAN,
  45. SMEM_CACHE_INVALIDATE,
  46. SMEM_CACHE_CLEAN_INVALIDATE,
  47. };
  48. void *msm_vidc_open(int core_id, int session_type);
  49. int msm_vidc_close(void *instance);
  50. int msm_vidc_suspend(int core_id);
  51. int msm_vidc_querycap(void *instance, struct v4l2_capability *cap);
  52. int msm_vidc_enum_fmt(void *instance, struct v4l2_fmtdesc *f);
  53. int msm_vidc_s_fmt(void *instance, struct v4l2_format *f);
  54. int msm_vidc_g_fmt(void *instance, struct v4l2_format *f);
  55. int msm_vidc_s_ctrl(void *instance, struct v4l2_control *a);
  56. int msm_vidc_s_ext_ctrl(void *instance, struct v4l2_ext_controls *a);
  57. int msm_vidc_g_ctrl(void *instance, struct v4l2_control *a);
  58. int msm_vidc_reqbufs(void *instance, struct v4l2_requestbuffers *b);
  59. int msm_vidc_prepare_buf(void *instance, struct v4l2_buffer *b);
  60. int msm_vidc_release_buffers(void *instance, int buffer_type);
  61. int msm_vidc_qbuf(void *instance, struct v4l2_buffer *b);
  62. int msm_vidc_dqbuf(void *instance, struct v4l2_buffer *b);
  63. int msm_vidc_streamon(void *instance, enum v4l2_buf_type i);
  64. int msm_vidc_streamoff(void *instance, enum v4l2_buf_type i);
  65. int msm_vidc_decoder_cmd(void *instance, struct v4l2_decoder_cmd *dec);
  66. int msm_vidc_encoder_cmd(void *instance, struct v4l2_encoder_cmd *enc);
  67. int msm_vidc_poll(void *instance, struct file *filp,
  68. struct poll_table_struct *pt);
  69. int msm_vidc_get_iommu_domain_partition(void *instance, u32 flags,
  70. enum v4l2_buf_type, int *domain, int *partition);
  71. int msm_vidc_subscribe_event(void *instance,
  72. struct v4l2_event_subscription *sub);
  73. int msm_vidc_unsubscribe_event(void *instance,
  74. struct v4l2_event_subscription *sub);
  75. int msm_vidc_dqevent(void *instance, struct v4l2_event *event);
  76. int msm_vidc_wait(void *instance);
  77. int msm_vidc_s_parm(void *instance, struct v4l2_streamparm *a);
  78. int msm_vidc_enum_framesizes(void *instance, struct v4l2_frmsizeenum *fsize);
  79. struct msm_smem *msm_vidc_smem_alloc(void *instance,
  80. size_t size, u32 align, u32 flags,
  81. enum hal_buffer buffer_type, int map_kernel);
  82. void msm_vidc_smem_free(void *instance, struct msm_smem *mem);
  83. int msm_vidc_smem_cache_operations(void *instance,
  84. struct msm_smem *mem, enum smem_cache_ops);
  85. struct msm_smem *msm_vidc_smem_user_to_kernel(void *instance,
  86. int fd, u32 offset, enum hal_buffer buffer_type);
  87. int msm_vidc_smem_get_domain_partition(void *instance,
  88. u32 flags, enum hal_buffer buffer_type,
  89. int *domain_num, int *partition_num);
  90. void *msm_vidc_smem_get_client(void *instance);
  91. #endif
  92. struct msm_vidc_extradata_header {
  93. unsigned int size;
  94. unsigned int:32; /** Keeping binary compatibility */
  95. unsigned int:32; /* with firmware and OpenMAX IL **/
  96. unsigned int type; /* msm_vidc_extradata_type */
  97. unsigned int data_size;
  98. unsigned char data[1];
  99. };
  100. struct msm_vidc_interlace_payload {
  101. unsigned int format;
  102. };
  103. struct msm_vidc_framerate_payload {
  104. unsigned int frame_rate;
  105. };
  106. struct msm_vidc_ts_payload {
  107. unsigned int timestamp_lo;
  108. unsigned int timestamp_hi;
  109. };
  110. struct msm_vidc_concealmb_payload {
  111. unsigned int num_mbs;
  112. };
  113. struct msm_vidc_recoverysei_payload {
  114. unsigned int flags;
  115. };
  116. struct msm_vidc_aspect_ratio_payload {
  117. unsigned int size;
  118. unsigned int version;
  119. unsigned int port_index;
  120. unsigned int aspect_width;
  121. unsigned int aspect_height;
  122. };
  123. struct msm_vidc_mpeg2_seqdisp_payload {
  124. unsigned int video_format;
  125. bool color_descp;
  126. unsigned int color_primaries;
  127. unsigned int transfer_char;
  128. unsigned int matrix_coeffs;
  129. unsigned int disp_width;
  130. unsigned int disp_height;
  131. };
  132. struct msm_vidc_panscan_window {
  133. unsigned int panscan_height_offset;
  134. unsigned int panscan_width_offset;
  135. unsigned int panscan_window_width;
  136. unsigned int panscan_window_height;
  137. };
  138. struct msm_vidc_panscan_window_payload {
  139. unsigned int num_panscan_windows;
  140. struct msm_vidc_panscan_window wnd[1];
  141. };
  142. struct msm_vidc_s3d_frame_packing_payload {
  143. unsigned int fpa_id;
  144. unsigned int cancel_flag;
  145. unsigned int fpa_type;
  146. unsigned int quin_cunx_flag;
  147. unsigned int content_interprtation_type;
  148. unsigned int spatial_flipping_flag;
  149. unsigned int frame0_flipped_flag;
  150. unsigned int field_views_flag;
  151. unsigned int current_frame_is_frame0_flag;
  152. unsigned int frame0_self_contained_flag;
  153. unsigned int frame1_self_contained_flag;
  154. unsigned int frame0_graid_pos_x;
  155. unsigned int frame0_graid_pos_y;
  156. unsigned int frame1_graid_pos_x;
  157. unsigned int frame1_graid_pos_y;
  158. unsigned int fpa_reserved_byte;
  159. unsigned int fpa_repetition_period;
  160. unsigned int fpa_extension_flag;
  161. };
  162. struct msm_vidc_frame_qp_payload {
  163. unsigned int frame_qp;
  164. };
  165. struct msm_vidc_frame_bits_info_payload {
  166. unsigned int frame_bits;
  167. unsigned int header_bits;
  168. };
  169. struct msm_vidc_stream_userdata_payload {
  170. unsigned int type;
  171. unsigned int data[1];
  172. };
  173. enum msm_vidc_extradata_type {
  174. EXTRADATA_NONE = 0x00000000,
  175. EXTRADATA_MB_QUANTIZATION = 0x00000001,
  176. EXTRADATA_INTERLACE_VIDEO = 0x00000002,
  177. EXTRADATA_VC1_FRAMEDISP = 0x00000003,
  178. EXTRADATA_VC1_SEQDISP = 0x00000004,
  179. EXTRADATA_TIMESTAMP = 0x00000005,
  180. EXTRADATA_S3D_FRAME_PACKING = 0x00000006,
  181. EXTRADATA_FRAME_RATE = 0x00000007,
  182. EXTRADATA_PANSCAN_WINDOW = 0x00000008,
  183. EXTRADATA_RECOVERY_POINT_SEI = 0x00000009,
  184. EXTRADATA_MPEG2_SEQDISP = 0x0000000D,
  185. EXTRADATA_STREAM_USERDATA = 0x0000000E,
  186. EXTRADATA_FRAME_QP = 0x0000000F,
  187. EXTRADATA_FRAME_BITS_INFO = 0x00000010,
  188. EXTRADATA_MULTISLICE_INFO = 0x7F100000,
  189. EXTRADATA_NUM_CONCEALED_MB = 0x7F100001,
  190. EXTRADATA_INDEX = 0x7F100002,
  191. EXTRADATA_ASPECT_RATIO = 0x7F100003,
  192. EXTRADATA_METADATA_FILLER = 0x7FE00002,
  193. MSM_VIDC_EXTRADATA_METADATA_LTR = 0x7F100004,
  194. EXTRADATA_METADATA_MBI = 0x7F100005,
  195. };
  196. enum msm_vidc_interlace_type {
  197. INTERLACE_FRAME_PROGRESSIVE = 0x01,
  198. INTERLACE_INTERLEAVE_FRAME_TOPFIELDFIRST = 0x02,
  199. INTERLACE_INTERLEAVE_FRAME_BOTTOMFIELDFIRST = 0x04,
  200. INTERLACE_FRAME_TOPFIELDFIRST = 0x08,
  201. INTERLACE_FRAME_BOTTOMFIELDFIRST = 0x10,
  202. };
  203. enum msm_vidc_recovery_sei {
  204. FRAME_RECONSTRUCTION_INCORRECT = 0x0,
  205. FRAME_RECONSTRUCTION_CORRECT = 0x01,
  206. FRAME_RECONSTRUCTION_APPROXIMATELY_CORRECT = 0x02,
  207. };
  208. enum msm_vidc_userdata_type {
  209. MSM_VIDC_USERDATA_TYPE_FRAME = 0x1,
  210. MSM_VIDC_USERDATA_TYPE_TOP_FIELD = 0x2,
  211. MSM_VIDC_USERDATA_TYPE_BOTTOM_FIELD = 0x3,
  212. };
  213. #endif