hfi.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. /*
  2. * Copyright (c) 2012-2016, The Linux Foundation. All rights reserved.
  3. * Copyright (C) 2017 Linaro Ltd.
  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 and
  7. * only version 2 as 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. */
  15. #ifndef __HFI_H__
  16. #define __HFI_H__
  17. #include <linux/interrupt.h>
  18. #include "hfi_helper.h"
  19. #define VIDC_SESSION_TYPE_VPE 0
  20. #define VIDC_SESSION_TYPE_ENC 1
  21. #define VIDC_SESSION_TYPE_DEC 2
  22. #define VIDC_RESOURCE_NONE 0
  23. #define VIDC_RESOURCE_OCMEM 1
  24. #define VIDC_RESOURCE_VMEM 2
  25. struct hfi_buffer_desc {
  26. u32 buffer_type;
  27. u32 buffer_size;
  28. u32 num_buffers;
  29. u32 device_addr;
  30. u32 extradata_addr;
  31. u32 extradata_size;
  32. u32 response_required;
  33. };
  34. struct hfi_frame_data {
  35. u32 buffer_type;
  36. u32 device_addr;
  37. u32 extradata_addr;
  38. u64 timestamp;
  39. u32 flags;
  40. u32 offset;
  41. u32 alloc_len;
  42. u32 filled_len;
  43. u32 mark_target;
  44. u32 mark_data;
  45. u32 clnt_data;
  46. u32 extradata_size;
  47. };
  48. union hfi_get_property {
  49. struct hfi_profile_level profile_level;
  50. struct hfi_buffer_requirements bufreq[HFI_BUFFER_TYPE_MAX];
  51. };
  52. /* HFI events */
  53. #define EVT_SYS_EVENT_CHANGE 1
  54. #define EVT_SYS_WATCHDOG_TIMEOUT 2
  55. #define EVT_SYS_ERROR 3
  56. #define EVT_SESSION_ERROR 4
  57. /* HFI event callback structure */
  58. struct hfi_event_data {
  59. u32 error;
  60. u32 height;
  61. u32 width;
  62. u32 event_type;
  63. u32 packet_buffer;
  64. u32 extradata_buffer;
  65. u32 tag;
  66. u32 profile;
  67. u32 level;
  68. /* the following properties start appear from v4 onwards */
  69. u32 bit_depth;
  70. u32 pic_struct;
  71. u32 colour_space;
  72. u32 entropy_mode;
  73. u32 buf_count;
  74. struct {
  75. u32 left, top;
  76. u32 width, height;
  77. } input_crop;
  78. };
  79. /* define core states */
  80. #define CORE_UNINIT 0
  81. #define CORE_INIT 1
  82. /* define instance states */
  83. #define INST_UNINIT 2
  84. #define INST_INIT 3
  85. #define INST_LOAD_RESOURCES 4
  86. #define INST_START 5
  87. #define INST_STOP 6
  88. #define INST_RELEASE_RESOURCES 7
  89. struct venus_core;
  90. struct venus_inst;
  91. struct hfi_core_ops {
  92. void (*event_notify)(struct venus_core *core, u32 event);
  93. };
  94. struct hfi_inst_ops {
  95. void (*buf_done)(struct venus_inst *inst, unsigned int buf_type,
  96. u32 tag, u32 bytesused, u32 data_offset, u32 flags,
  97. u32 hfi_flags, u64 timestamp_us);
  98. void (*event_notify)(struct venus_inst *inst, u32 event,
  99. struct hfi_event_data *data);
  100. };
  101. struct hfi_ops {
  102. int (*core_init)(struct venus_core *core);
  103. int (*core_deinit)(struct venus_core *core);
  104. int (*core_ping)(struct venus_core *core, u32 cookie);
  105. int (*core_trigger_ssr)(struct venus_core *core, u32 trigger_type);
  106. int (*session_init)(struct venus_inst *inst, u32 session_type,
  107. u32 codec);
  108. int (*session_end)(struct venus_inst *inst);
  109. int (*session_abort)(struct venus_inst *inst);
  110. int (*session_flush)(struct venus_inst *inst, u32 flush_mode);
  111. int (*session_start)(struct venus_inst *inst);
  112. int (*session_stop)(struct venus_inst *inst);
  113. int (*session_continue)(struct venus_inst *inst);
  114. int (*session_etb)(struct venus_inst *inst, struct hfi_frame_data *fd);
  115. int (*session_ftb)(struct venus_inst *inst, struct hfi_frame_data *fd);
  116. int (*session_set_buffers)(struct venus_inst *inst,
  117. struct hfi_buffer_desc *bd);
  118. int (*session_unset_buffers)(struct venus_inst *inst,
  119. struct hfi_buffer_desc *bd);
  120. int (*session_load_res)(struct venus_inst *inst);
  121. int (*session_release_res)(struct venus_inst *inst);
  122. int (*session_parse_seq_hdr)(struct venus_inst *inst, u32 seq_hdr,
  123. u32 seq_hdr_len);
  124. int (*session_get_seq_hdr)(struct venus_inst *inst, u32 seq_hdr,
  125. u32 seq_hdr_len);
  126. int (*session_set_property)(struct venus_inst *inst, u32 ptype,
  127. void *pdata);
  128. int (*session_get_property)(struct venus_inst *inst, u32 ptype);
  129. int (*resume)(struct venus_core *core);
  130. int (*suspend)(struct venus_core *core);
  131. /* interrupt operations */
  132. irqreturn_t (*isr)(struct venus_core *core);
  133. irqreturn_t (*isr_thread)(struct venus_core *core);
  134. };
  135. int hfi_create(struct venus_core *core, const struct hfi_core_ops *ops);
  136. void hfi_destroy(struct venus_core *core);
  137. int hfi_core_init(struct venus_core *core);
  138. int hfi_core_deinit(struct venus_core *core, bool blocking);
  139. int hfi_core_suspend(struct venus_core *core);
  140. int hfi_core_resume(struct venus_core *core, bool force);
  141. int hfi_core_trigger_ssr(struct venus_core *core, u32 type);
  142. int hfi_core_ping(struct venus_core *core);
  143. int hfi_session_create(struct venus_inst *inst, const struct hfi_inst_ops *ops);
  144. void hfi_session_destroy(struct venus_inst *inst);
  145. int hfi_session_init(struct venus_inst *inst, u32 pixfmt);
  146. int hfi_session_deinit(struct venus_inst *inst);
  147. int hfi_session_start(struct venus_inst *inst);
  148. int hfi_session_stop(struct venus_inst *inst);
  149. int hfi_session_continue(struct venus_inst *inst);
  150. int hfi_session_abort(struct venus_inst *inst);
  151. int hfi_session_load_res(struct venus_inst *inst);
  152. int hfi_session_unload_res(struct venus_inst *inst);
  153. int hfi_session_flush(struct venus_inst *inst);
  154. int hfi_session_set_buffers(struct venus_inst *inst,
  155. struct hfi_buffer_desc *bd);
  156. int hfi_session_unset_buffers(struct venus_inst *inst,
  157. struct hfi_buffer_desc *bd);
  158. int hfi_session_get_property(struct venus_inst *inst, u32 ptype,
  159. union hfi_get_property *hprop);
  160. int hfi_session_set_property(struct venus_inst *inst, u32 ptype, void *pdata);
  161. int hfi_session_process_buf(struct venus_inst *inst, struct hfi_frame_data *f);
  162. irqreturn_t hfi_isr_thread(int irq, void *dev_id);
  163. irqreturn_t hfi_isr(int irq, void *dev);
  164. #endif