msm_vidc_inst.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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. int (*calc_freq)(struct msm_vidc_inst *inst, struct msm_vidc_buffer *mbuf);
  14. int (*calc_bw)(struct msm_vidc_inst *inst, struct msm_vidc_buffer *mbuf);
  15. int (*decide_work_route)(struct msm_vidc_inst *inst);
  16. int (*decide_work_mode)(struct msm_vidc_inst *inst);
  17. int (*decide_core_and_power_mode)(struct msm_vidc_inst *inst);
  18. int (*buffer_size)(struct msm_vidc_inst *inst, enum msm_vidc_buffer_type type);
  19. int (*min_count)(struct msm_vidc_inst *inst, enum msm_vidc_buffer_type type);
  20. int (*extra_count)(struct msm_vidc_inst *inst, enum msm_vidc_buffer_type type);
  21. };
  22. struct msm_vidc_allocations {
  23. struct msm_vidc_alloc_info scratch;
  24. struct msm_vidc_alloc_info scratch_1;
  25. struct msm_vidc_alloc_info scratch_2;
  26. struct msm_vidc_alloc_info persist;
  27. struct msm_vidc_alloc_info persist_1;
  28. };
  29. struct msm_vidc_maps {
  30. struct msm_vidc_map_info input;
  31. struct msm_vidc_map_info output;
  32. struct msm_vidc_map_info input_meta;
  33. struct msm_vidc_map_info output_meta;
  34. struct msm_vidc_map_info scratch;
  35. struct msm_vidc_map_info scratch_1;
  36. struct msm_vidc_map_info scratch_2;
  37. struct msm_vidc_map_info persist;
  38. struct msm_vidc_map_info persist_1;
  39. };
  40. struct msm_vidc_buffers {
  41. struct msm_vidc_buffer_info input;
  42. struct msm_vidc_buffer_info output;
  43. struct msm_vidc_buffer_info input_meta;
  44. struct msm_vidc_buffer_info output_meta;
  45. struct msm_vidc_buffer_info scratch;
  46. struct msm_vidc_buffer_info scratch_1;
  47. struct msm_vidc_buffer_info scratch_2;
  48. struct msm_vidc_buffer_info persist;
  49. struct msm_vidc_buffer_info persist_1;
  50. };
  51. enum msm_vidc_inst_state {
  52. MSM_VIDC_OPEN = 1,
  53. MSM_VIDC_START_INPUT = 2,
  54. MSM_VIDC_START_OUTPUT = 3,
  55. MSM_VIDC_START = 4,
  56. MSM_VIDC_DRC = 5,
  57. MSM_VIDC_DRC_LAST_FLAG = 6,
  58. MSM_VIDC_DRAIN = 7,
  59. MSM_VIDC_DRAIN_LAST_FLAG = 8,
  60. MSM_VIDC_DRC_DRAIN = 9,
  61. MSM_VIDC_DRC_DRAIN_LAST_FLAG = 10,
  62. MSM_VIDC_DRAIN_START_INPUT = 11,
  63. MSM_VIDC_ERROR = 12,
  64. };
  65. struct msm_vidc_inst {
  66. struct list_head list;
  67. struct mutex lock;
  68. enum msm_vidc_inst_state state;
  69. enum msm_vidc_domain_type domain;
  70. enum msm_vidc_codec_type codec;
  71. void *core;
  72. struct kref kref;
  73. u32 session_id;
  74. u32 sid;
  75. void *packet;
  76. u32 packet_size;
  77. struct v4l2_format fmts[MAX_PORT];
  78. struct v4l2_ctrl_handler ctrl_handler;
  79. struct v4l2_fh event_handler;
  80. struct v4l2_ctrl **ctrls;
  81. u32 num_ctrls;
  82. struct msm_vidc_inst_cap_entry children;
  83. struct msm_vidc_inst_cap_entry firmware;
  84. bool request;
  85. struct vb2_queue vb2q[MAX_PORT];
  86. struct msm_vidc_crop crop;
  87. struct msm_vidc_properties prop;
  88. struct msm_vidc_power power;
  89. struct msm_vidc_buffers buffers;
  90. struct msm_vidc_maps maps;
  91. struct msm_vidc_allocations allocations;
  92. bool subscribed_input_psc;
  93. bool subscribed_output_psc;
  94. bool subscribed_input_prop;
  95. bool subscribed_output_prop;
  96. struct msm_vidc_subscription_params vidc_subcr[MAX_PORT];
  97. struct msm_vidc_subscription_params hfi_subcr[MAX_PORT];
  98. struct msm_vidc_decode_batch decode_batch;
  99. struct msm_vidc_decode_vpp_delay decode_vpp_delay;
  100. struct msm_vidc_session_idle session_idle;
  101. struct list_head input_ts;
  102. struct list_head enc_input_crs;
  103. struct list_head decode_bitrate_data;
  104. bool session_created;
  105. struct dentry *debugfs_root;
  106. struct msm_vidc_debug debug;
  107. struct msm_vidc_inst_capability *capabilities;
  108. struct completion completions[MAX_SIGNAL];
  109. };
  110. #endif // _MSM_VIDC_INST_H_