msm_vidc_inst.h 5.9 KB

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