msm_vidc_inst.h 5.3 KB

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