resource.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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_video_plane;
  37. int num_audio;
  38. int num_stream_encoder;
  39. int num_pll;
  40. int num_dwb;
  41. };
  42. struct resource_straps {
  43. uint32_t hdmi_disable;
  44. uint32_t dc_pinstraps_audio;
  45. uint32_t audio_stream_number;
  46. };
  47. struct resource_create_funcs {
  48. void (*read_dce_straps)(
  49. struct dc_context *ctx, struct resource_straps *straps);
  50. struct audio *(*create_audio)(
  51. struct dc_context *ctx, unsigned int inst);
  52. struct stream_encoder *(*create_stream_encoder)(
  53. enum engine_id eng_id, struct dc_context *ctx);
  54. struct dce_hwseq *(*create_hwseq)(
  55. struct dc_context *ctx);
  56. };
  57. bool resource_construct(
  58. unsigned int num_virtual_links,
  59. struct dc *dc,
  60. struct resource_pool *pool,
  61. const struct resource_create_funcs *create_funcs);
  62. struct resource_pool *dc_create_resource_pool(
  63. struct dc *dc,
  64. int num_virtual_links,
  65. enum dce_version dc_version,
  66. struct hw_asic_id asic_id);
  67. void dc_destroy_resource_pool(struct dc *dc);
  68. enum dc_status resource_map_pool_resources(
  69. const struct dc *dc,
  70. struct dc_state *context,
  71. struct dc_stream_state *stream);
  72. bool resource_build_scaling_params(struct pipe_ctx *pipe_ctx);
  73. enum dc_status resource_build_scaling_params_for_context(
  74. const struct dc *dc,
  75. struct dc_state *context);
  76. void resource_build_info_frame(struct pipe_ctx *pipe_ctx);
  77. void resource_unreference_clock_source(
  78. struct resource_context *res_ctx,
  79. const struct resource_pool *pool,
  80. struct clock_source *clock_source);
  81. void resource_reference_clock_source(
  82. struct resource_context *res_ctx,
  83. const struct resource_pool *pool,
  84. struct clock_source *clock_source);
  85. bool resource_are_streams_timing_synchronizable(
  86. struct dc_stream_state *stream1,
  87. struct dc_stream_state *stream2);
  88. struct clock_source *resource_find_used_clk_src_for_sharing(
  89. struct resource_context *res_ctx,
  90. struct pipe_ctx *pipe_ctx);
  91. struct clock_source *dc_resource_find_first_free_pll(
  92. struct resource_context *res_ctx,
  93. const struct resource_pool *pool);
  94. struct pipe_ctx *resource_get_head_pipe_for_stream(
  95. struct resource_context *res_ctx,
  96. struct dc_stream_state *stream);
  97. bool resource_attach_surfaces_to_context(
  98. struct dc_plane_state *const *plane_state,
  99. int surface_count,
  100. struct dc_stream_state *dc_stream,
  101. struct dc_state *context,
  102. const struct resource_pool *pool);
  103. struct pipe_ctx *find_idle_secondary_pipe(
  104. struct resource_context *res_ctx,
  105. const struct resource_pool *pool);
  106. bool resource_is_stream_unchanged(
  107. struct dc_state *old_context, struct dc_stream_state *stream);
  108. bool resource_validate_attach_surfaces(
  109. const struct dc_validation_set set[],
  110. int set_count,
  111. const struct dc_state *old_context,
  112. struct dc_state *context,
  113. const struct resource_pool *pool);
  114. void validate_guaranteed_copy_streams(
  115. struct dc_state *context,
  116. int max_streams);
  117. void resource_validate_ctx_update_pointer_after_copy(
  118. const struct dc_state *src_ctx,
  119. struct dc_state *dst_ctx);
  120. enum dc_status resource_map_clock_resources(
  121. const struct dc *dc,
  122. struct dc_state *context,
  123. struct dc_stream_state *stream);
  124. enum dc_status resource_map_phy_clock_resources(
  125. const struct dc *dc,
  126. struct dc_state *context,
  127. struct dc_stream_state *stream);
  128. bool pipe_need_reprogram(
  129. struct pipe_ctx *pipe_ctx_old,
  130. struct pipe_ctx *pipe_ctx);
  131. void resource_build_bit_depth_reduction_params(struct dc_stream_state *stream,
  132. struct bit_depth_reduction_params *fmt_bit_depth);
  133. void update_audio_usage(
  134. struct resource_context *res_ctx,
  135. const struct resource_pool *pool,
  136. struct audio *audio,
  137. bool acquired);
  138. #endif /* DRIVERS_GPU_DRM_AMD_DC_DEV_DC_INC_RESOURCE_H_ */