msm_vidc_inst.h 6.7 KB

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