msm_vidc_inst.h 7.3 KB

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