msm_vidc_inst.h 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2020-2021,, The Linux Foundation. All rights reserved.
  4. */
  5. /* Copyright (c) 2022. Qualcomm Innovation Center, Inc. All rights reserved. */
  6. #ifndef _MSM_VIDC_INST_H_
  7. #define _MSM_VIDC_INST_H_
  8. #include "msm_vidc_internal.h"
  9. #include "msm_vidc_memory.h"
  10. #include "hfi_property.h"
  11. struct msm_vidc_inst;
  12. #define call_session_op(c, op, ...) \
  13. (((c) && (c)->session_ops && (c)->session_ops->op) ? \
  14. ((c)->session_ops->op(__VA_ARGS__)) : 0)
  15. struct msm_vidc_session_ops {
  16. u64 (*calc_freq)(struct msm_vidc_inst *inst, u32 data_size);
  17. int (*calc_bw)(struct msm_vidc_inst *inst,
  18. struct vidc_bus_vote_data* vote_data);
  19. int (*decide_work_route)(struct msm_vidc_inst *inst);
  20. int (*decide_work_mode)(struct msm_vidc_inst *inst);
  21. int (*decide_quality_mode)(struct msm_vidc_inst *inst);
  22. int (*buffer_size)(struct msm_vidc_inst *inst, enum msm_vidc_buffer_type type);
  23. int (*min_count)(struct msm_vidc_inst *inst, enum msm_vidc_buffer_type type);
  24. int (*extra_count)(struct msm_vidc_inst *inst, enum msm_vidc_buffer_type type);
  25. };
  26. struct msm_vidc_allocations_info {
  27. struct msm_vidc_allocations bin;
  28. struct msm_vidc_allocations arp;
  29. struct msm_vidc_allocations comv;
  30. struct msm_vidc_allocations non_comv;
  31. struct msm_vidc_allocations line;
  32. struct msm_vidc_allocations dpb;
  33. struct msm_vidc_allocations persist;
  34. struct msm_vidc_allocations vpss;
  35. struct msm_vidc_allocations partial_data;
  36. };
  37. struct msm_vidc_mappings_info {
  38. struct msm_vidc_mappings bin;
  39. struct msm_vidc_mappings arp;
  40. struct msm_vidc_mappings comv;
  41. struct msm_vidc_mappings non_comv;
  42. struct msm_vidc_mappings line;
  43. struct msm_vidc_mappings dpb;
  44. struct msm_vidc_mappings persist;
  45. struct msm_vidc_mappings vpss;
  46. struct msm_vidc_mappings partial_data;
  47. };
  48. struct msm_vidc_buffers_info {
  49. struct msm_vidc_buffers input;
  50. struct msm_vidc_buffers output;
  51. struct msm_vidc_buffers read_only;
  52. struct msm_vidc_buffers input_meta;
  53. struct msm_vidc_buffers output_meta;
  54. struct msm_vidc_buffers bin;
  55. struct msm_vidc_buffers arp;
  56. struct msm_vidc_buffers comv;
  57. struct msm_vidc_buffers non_comv;
  58. struct msm_vidc_buffers line;
  59. struct msm_vidc_buffers dpb;
  60. struct msm_vidc_buffers persist;
  61. struct msm_vidc_buffers vpss;
  62. struct msm_vidc_buffers partial_data;
  63. };
  64. enum msm_vidc_state {
  65. MSM_VIDC_OPEN = 1,
  66. MSM_VIDC_INPUT_STREAMING = 2,
  67. MSM_VIDC_OUTPUT_STREAMING = 3,
  68. MSM_VIDC_STREAMING = 4,
  69. MSM_VIDC_CLOSE = 5,
  70. MSM_VIDC_ERROR = 6,
  71. };
  72. #define MSM_VIDC_SUB_STATE_NONE 0
  73. #define MSM_VIDC_MAX_SUB_STATES 6
  74. /*
  75. * max value of inst->sub_state if all
  76. * the 6 valid bits are set i.e 111111==>63
  77. */
  78. #define MSM_VIDC_MAX_SUB_STATE_VALUE ((1 << MSM_VIDC_MAX_SUB_STATES) - 1)
  79. enum msm_vidc_sub_state {
  80. MSM_VIDC_DRAIN = BIT(0),
  81. MSM_VIDC_DRC = BIT(1),
  82. MSM_VIDC_DRAIN_LAST_BUFFER = BIT(2),
  83. MSM_VIDC_DRC_LAST_BUFFER = BIT(3),
  84. MSM_VIDC_INPUT_PAUSE = BIT(4),
  85. MSM_VIDC_OUTPUT_PAUSE = BIT(5),
  86. };
  87. struct buf_queue {
  88. struct vb2_queue *vb2q;
  89. };
  90. struct msm_vidc_inst {
  91. struct list_head list;
  92. struct mutex lock;
  93. struct mutex request_lock;
  94. struct mutex client_lock;
  95. enum msm_vidc_state state;
  96. enum msm_vidc_sub_state sub_state;
  97. char sub_state_name[MAX_NAME_LENGTH];
  98. enum msm_vidc_domain_type domain;
  99. enum msm_vidc_codec_type codec;
  100. void *core;
  101. struct kref kref;
  102. u32 session_id;
  103. u8 debug_str[24];
  104. void *packet;
  105. u32 packet_size;
  106. struct v4l2_format fmts[MAX_PORT];
  107. struct v4l2_ctrl_handler ctrl_handler;
  108. struct v4l2_fh event_handler;
  109. struct v4l2_m2m_dev *m2m_dev;
  110. struct v4l2_m2m_ctx *m2m_ctx;
  111. struct v4l2_ctrl **ctrls;
  112. u32 num_ctrls;
  113. enum hfi_rate_control hfi_rc_type;
  114. enum hfi_layer_encoding_type hfi_layer_type;
  115. bool request;
  116. struct buf_queue bufq[MAX_PORT];
  117. struct msm_vidc_rectangle crop;
  118. struct msm_vidc_rectangle compose;
  119. struct msm_vidc_power power;
  120. struct vidc_bus_vote_data bus_data;
  121. struct msm_memory_pool pool[MSM_MEM_POOL_MAX];
  122. struct msm_vidc_buffers_info buffers;
  123. struct msm_vidc_mappings_info mappings;
  124. struct msm_vidc_allocations_info allocations;
  125. struct msm_vidc_timestamps timestamps;
  126. struct msm_vidc_timestamps ts_reorder; /* list of struct msm_vidc_timestamp */
  127. bool subscribed_input_psc;
  128. bool subscribed_output_psc;
  129. bool subscribed_input_prop;
  130. bool subscribed_output_prop;
  131. struct msm_vidc_subscription_params subcr_params[MAX_PORT];
  132. struct msm_vidc_hfi_frame_info hfi_frame_info;
  133. struct msm_vidc_decode_batch decode_batch;
  134. struct msm_vidc_decode_vpp_delay decode_vpp_delay;
  135. struct msm_vidc_session_idle session_idle;
  136. struct delayed_work stats_work;
  137. struct work_struct stability_work;
  138. struct msm_vidc_stability stability;
  139. struct workqueue_struct *workq;
  140. struct list_head enc_input_crs;
  141. struct list_head dmabuf_tracker; /* list of struct msm_memory_dmabuf */
  142. struct list_head input_timer_list; /* list of struct msm_vidc_input_timer */
  143. struct list_head caps_list;
  144. struct list_head children_list; /* struct msm_vidc_inst_cap_entry */
  145. struct list_head firmware_list; /* struct msm_vidc_inst_cap_entry */
  146. struct list_head pending_pkts; /* list of struct hfi_pending_packet */
  147. struct list_head fence_list; /* list of struct msm_vidc_fence */
  148. struct list_head buffer_stats_list; /* struct msm_vidc_buffer_stats */
  149. bool once_per_session_set;
  150. bool ipsc_properties_set;
  151. bool opsc_properties_set;
  152. struct dentry *debugfs_root;
  153. struct msm_vidc_debug debug;
  154. struct debug_buf_count debug_count;
  155. struct msm_vidc_statistics stats;
  156. struct msm_vidc_inst_capability *capabilities;
  157. struct completion completions[MAX_SIGNAL];
  158. struct msm_vidc_fence_context fence_context;
  159. bool active;
  160. u64 last_qbuf_time_ns;
  161. u64 initial_time_us;
  162. bool vb2q_init;
  163. u32 max_input_data_size;
  164. u32 dpb_list_payload[MAX_DPB_LIST_ARRAY_SIZE];
  165. u32 max_map_output_count;
  166. u32 auto_framerate;
  167. u32 max_rate;
  168. bool has_bframe;
  169. bool ir_enabled;
  170. u32 adjust_priority;
  171. };
  172. #endif // _MSM_VIDC_INST_H_