resource.h 5.2 KB

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