msm_vidc_inst.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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_allocations_info {
  25. struct msm_vidc_allocations bin;
  26. struct msm_vidc_allocations arp;
  27. struct msm_vidc_allocations comv;
  28. struct msm_vidc_allocations non_comv;
  29. struct msm_vidc_allocations line;
  30. struct msm_vidc_allocations dpb;
  31. struct msm_vidc_allocations persist;
  32. struct msm_vidc_allocations vpss;
  33. };
  34. struct msm_vidc_mappings_info {
  35. struct msm_vidc_mappings input;
  36. struct msm_vidc_mappings output;
  37. struct msm_vidc_mappings input_meta;
  38. struct msm_vidc_mappings output_meta;
  39. struct msm_vidc_mappings bin;
  40. struct msm_vidc_mappings arp;
  41. struct msm_vidc_mappings comv;
  42. struct msm_vidc_mappings non_comv;
  43. struct msm_vidc_mappings line;
  44. struct msm_vidc_mappings dpb;
  45. struct msm_vidc_mappings persist;
  46. struct msm_vidc_mappings vpss;
  47. };
  48. struct msm_vidc_buffers_info {
  49. struct msm_vidc_buffers input;
  50. struct msm_vidc_buffers output;
  51. struct msm_vidc_buffers input_meta;
  52. struct msm_vidc_buffers output_meta;
  53. struct msm_vidc_buffers bin;
  54. struct msm_vidc_buffers arp;
  55. struct msm_vidc_buffers comv;
  56. struct msm_vidc_buffers non_comv;
  57. struct msm_vidc_buffers line;
  58. struct msm_vidc_buffers dpb;
  59. struct msm_vidc_buffers persist;
  60. struct msm_vidc_buffers vpss;
  61. };
  62. enum msm_vidc_inst_state {
  63. MSM_VIDC_OPEN = 1,
  64. MSM_VIDC_START_INPUT = 2,
  65. MSM_VIDC_START_OUTPUT = 3,
  66. MSM_VIDC_START = 4,
  67. MSM_VIDC_DRC = 5,
  68. MSM_VIDC_DRC_LAST_FLAG = 6,
  69. MSM_VIDC_DRAIN = 7,
  70. MSM_VIDC_DRAIN_LAST_FLAG = 8,
  71. MSM_VIDC_DRC_DRAIN = 9,
  72. MSM_VIDC_DRC_DRAIN_LAST_FLAG = 10,
  73. MSM_VIDC_DRAIN_START_INPUT = 11,
  74. MSM_VIDC_ERROR = 12,
  75. };
  76. struct msm_vidc_inst {
  77. struct list_head list;
  78. struct mutex lock;
  79. enum msm_vidc_inst_state state;
  80. enum msm_vidc_domain_type domain;
  81. enum msm_vidc_codec_type codec;
  82. void *core;
  83. struct kref kref;
  84. u32 session_id;
  85. u8 debug_str[24];
  86. void *packet;
  87. u32 packet_size;
  88. struct v4l2_format fmts[MAX_PORT];
  89. struct v4l2_ctrl_handler ctrl_handler;
  90. struct v4l2_fh event_handler;
  91. struct v4l2_ctrl **ctrls;
  92. u32 num_ctrls;
  93. struct msm_vidc_inst_cap_entry children;
  94. struct msm_vidc_inst_cap_entry firmware;
  95. enum hfi_rate_control hfi_rc_type;
  96. bool request;
  97. struct vb2_queue vb2q[MAX_PORT];
  98. struct msm_vidc_rectangle crop;
  99. struct msm_vidc_rectangle compose;
  100. struct msm_vidc_power power;
  101. enum msm_vidc_modes flags;
  102. struct vidc_bus_vote_data bus_data;
  103. struct msm_vidc_buffers_info buffers;
  104. struct msm_vidc_mappings_info mappings;
  105. struct msm_vidc_allocations_info allocations;
  106. bool subscribed_input_psc;
  107. bool subscribed_output_psc;
  108. bool subscribed_input_prop;
  109. bool subscribed_output_prop;
  110. struct msm_vidc_subscription_params subcr_params[MAX_PORT];
  111. struct msm_vidc_hfi_frame_info hfi_frame_info;
  112. struct msm_vidc_decode_batch decode_batch;
  113. struct msm_vidc_decode_vpp_delay decode_vpp_delay;
  114. struct msm_vidc_session_idle session_idle;
  115. struct delayed_work response_work;
  116. struct workqueue_struct *response_workq;
  117. struct list_head response_works; /* list of struct response_work */
  118. struct list_head input_ts;
  119. struct list_head enc_input_crs;
  120. struct list_head decode_bitrate_data;
  121. bool once_per_session_set;
  122. bool ipsc_properties_set;
  123. bool opsc_properties_set;
  124. struct dentry *debugfs_root;
  125. struct msm_vidc_debug debug;
  126. struct debug_buf_count debug_count;
  127. struct msm_vidc_inst_capability *capabilities;
  128. struct completion completions[MAX_SIGNAL];
  129. bool active;
  130. u64 last_qbuf_time_ns;
  131. bool vb2q_init;
  132. };
  133. #endif // _MSM_VIDC_INST_H_