resource.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. /*
  2. * Copyright 2015 Advanced Micro Devices, Inc.
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  17. * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
  18. * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  19. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  20. * OTHER DEALINGS IN THE SOFTWARE.
  21. *
  22. * Authors: AMD
  23. */
  24. #ifndef DRIVERS_GPU_DRM_AMD_DC_DEV_DC_INC_RESOURCE_H_
  25. #define DRIVERS_GPU_DRM_AMD_DC_DEV_DC_INC_RESOURCE_H_
  26. #include "core_types.h"
  27. #include "core_status.h"
  28. #include "dal_asic_id.h"
  29. #include "dm_pp_smu.h"
  30. /* TODO unhardcode, 4 for CZ*/
  31. #define MEMORY_TYPE_MULTIPLIER 4
  32. enum dce_version resource_parse_asic_id(
  33. struct hw_asic_id asic_id);
  34. struct resource_caps {
  35. int num_timing_generator;
  36. int num_opp;
  37. int num_video_plane;
  38. int num_audio;
  39. int num_stream_encoder;
  40. int num_pll;
  41. int num_dwb;
  42. };
  43. struct resource_straps {
  44. uint32_t hdmi_disable;
  45. uint32_t dc_pinstraps_audio;
  46. uint32_t audio_stream_number;
  47. };
  48. struct resource_create_funcs {
  49. void (*read_dce_straps)(
  50. struct dc_context *ctx, struct resource_straps *straps);
  51. struct audio *(*create_audio)(
  52. struct dc_context *ctx, unsigned int inst);
  53. struct stream_encoder *(*create_stream_encoder)(
  54. enum engine_id eng_id, struct dc_context *ctx);
  55. struct dce_hwseq *(*create_hwseq)(
  56. struct dc_context *ctx);
  57. };
  58. bool resource_construct(
  59. unsigned int num_virtual_links,
  60. struct dc *dc,
  61. struct resource_pool *pool,
  62. const struct resource_create_funcs *create_funcs);
  63. struct resource_pool *dc_create_resource_pool(
  64. struct dc *dc,
  65. int num_virtual_links,
  66. enum dce_version dc_version,
  67. struct hw_asic_id asic_id);
  68. void dc_destroy_resource_pool(struct dc *dc);
  69. enum dc_status resource_map_pool_resources(
  70. const struct dc *dc,
  71. struct dc_state *context,
  72. struct dc_stream_state *stream);
  73. bool resource_build_scaling_params(struct pipe_ctx *pipe_ctx);
  74. enum dc_status resource_build_scaling_params_for_context(
  75. const struct dc *dc,
  76. struct dc_state *context);
  77. void resource_build_info_frame(struct pipe_ctx *pipe_ctx);
  78. void resource_unreference_clock_source(
  79. struct resource_context *res_ctx,
  80. const struct resource_pool *pool,
  81. struct clock_source *clock_source);
  82. void resource_reference_clock_source(
  83. struct resource_context *res_ctx,
  84. const struct resource_pool *pool,
  85. struct clock_source *clock_source);
  86. int resource_get_clock_source_reference(
  87. struct resource_context *res_ctx,
  88. const struct resource_pool *pool,
  89. struct clock_source *clock_source);
  90. bool resource_are_streams_timing_synchronizable(
  91. struct dc_stream_state *stream1,
  92. struct dc_stream_state *stream2);
  93. struct clock_source *resource_find_used_clk_src_for_sharing(
  94. struct resource_context *res_ctx,
  95. struct pipe_ctx *pipe_ctx);
  96. struct clock_source *dc_resource_find_first_free_pll(
  97. struct resource_context *res_ctx,
  98. const struct resource_pool *pool);
  99. struct pipe_ctx *resource_get_head_pipe_for_stream(
  100. struct resource_context *res_ctx,
  101. struct dc_stream_state *stream);
  102. bool resource_attach_surfaces_to_context(
  103. struct dc_plane_state *const *plane_state,
  104. int surface_count,
  105. struct dc_stream_state *dc_stream,
  106. struct dc_state *context,
  107. const struct resource_pool *pool);
  108. struct pipe_ctx *find_idle_secondary_pipe(
  109. struct resource_context *res_ctx,
  110. const struct resource_pool *pool);
  111. bool resource_is_stream_unchanged(
  112. struct dc_state *old_context, struct dc_stream_state *stream);
  113. bool resource_validate_attach_surfaces(
  114. const struct dc_validation_set set[],
  115. int set_count,
  116. const struct dc_state *old_context,
  117. struct dc_state *context,
  118. const struct resource_pool *pool);
  119. void resource_validate_ctx_update_pointer_after_copy(
  120. const struct dc_state *src_ctx,
  121. struct dc_state *dst_ctx);
  122. enum dc_status resource_map_clock_resources(
  123. const struct dc *dc,
  124. struct dc_state *context,
  125. struct dc_stream_state *stream);
  126. enum dc_status resource_map_phy_clock_resources(
  127. const struct dc *dc,
  128. struct dc_state *context,
  129. struct dc_stream_state *stream);
  130. bool pipe_need_reprogram(
  131. struct pipe_ctx *pipe_ctx_old,
  132. struct pipe_ctx *pipe_ctx);
  133. void resource_build_bit_depth_reduction_params(struct dc_stream_state *stream,
  134. struct bit_depth_reduction_params *fmt_bit_depth);
  135. void update_audio_usage(
  136. struct resource_context *res_ctx,
  137. const struct resource_pool *pool,
  138. struct audio *audio,
  139. bool acquired);
  140. #endif /* DRIVERS_GPU_DRM_AMD_DC_DEV_DC_INC_RESOURCE_H_ */