dm_helpers.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. /*
  2. * Copyright 2012-15 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. */
  25. /**
  26. * This file defines helper functions provided by the Display Manager to
  27. * Display Core.
  28. */
  29. #ifndef __DM_HELPERS__
  30. #define __DM_HELPERS__
  31. #include "dc_types.h"
  32. #include "dc.h"
  33. struct dc_dp_mst_stream_allocation_table;
  34. struct aux_payload;
  35. enum aux_return_code_type;
  36. enum set_config_status;
  37. /*
  38. * Allocate memory accessible by the GPU
  39. *
  40. * frame buffer allocations must be aligned to a 4096-byte boundary
  41. *
  42. * Returns virtual address, sets addr to physical address
  43. */
  44. void *dm_helpers_allocate_gpu_mem(
  45. struct dc_context *ctx,
  46. enum dc_gpu_mem_alloc_type type,
  47. size_t size,
  48. long long *addr);
  49. /*
  50. * Free the GPU-accessible memory at the virtual address pvMem
  51. */
  52. void dm_helpers_free_gpu_mem(
  53. struct dc_context *ctx,
  54. enum dc_gpu_mem_alloc_type type,
  55. void *pvMem);
  56. enum dc_edid_status dm_helpers_parse_edid_caps(
  57. struct dc_link *link,
  58. const struct dc_edid *edid,
  59. struct dc_edid_caps *edid_caps);
  60. /*
  61. * Update DP branch info
  62. */
  63. void dm_helpers_dp_update_branch_info(
  64. struct dc_context *ctx,
  65. const struct dc_link *link);
  66. /*
  67. * Writes payload allocation table in immediate downstream device.
  68. */
  69. bool dm_helpers_dp_mst_write_payload_allocation_table(
  70. struct dc_context *ctx,
  71. const struct dc_stream_state *stream,
  72. struct dc_dp_mst_stream_allocation_table *proposed_table,
  73. bool enable);
  74. /*
  75. * poll pending down reply
  76. */
  77. void dm_helpers_dp_mst_poll_pending_down_reply(
  78. struct dc_context *ctx,
  79. const struct dc_link *link);
  80. /*
  81. * Clear payload allocation table before enable MST DP link.
  82. */
  83. void dm_helpers_dp_mst_clear_payload_allocation_table(
  84. struct dc_context *ctx,
  85. const struct dc_link *link);
  86. /*
  87. * Polls for ACT (allocation change trigger) handled and
  88. */
  89. enum act_return_status dm_helpers_dp_mst_poll_for_allocation_change_trigger(
  90. struct dc_context *ctx,
  91. const struct dc_stream_state *stream);
  92. /*
  93. * Sends ALLOCATE_PAYLOAD message.
  94. */
  95. void dm_helpers_dp_mst_send_payload_allocation(
  96. struct dc_context *ctx,
  97. const struct dc_stream_state *stream);
  98. /*
  99. * Update mst manager relevant variables
  100. */
  101. void dm_helpers_dp_mst_update_mst_mgr_for_deallocation(
  102. struct dc_context *ctx,
  103. const struct dc_stream_state *stream);
  104. bool dm_helpers_dp_mst_start_top_mgr(
  105. struct dc_context *ctx,
  106. const struct dc_link *link,
  107. bool boot);
  108. bool dm_helpers_dp_mst_stop_top_mgr(
  109. struct dc_context *ctx,
  110. struct dc_link *link);
  111. void dm_helpers_dp_mst_update_branch_bandwidth(
  112. struct dc_context *ctx,
  113. struct dc_link *link);
  114. /**
  115. * OS specific aux read callback.
  116. */
  117. bool dm_helpers_dp_read_dpcd(
  118. struct dc_context *ctx,
  119. const struct dc_link *link,
  120. uint32_t address,
  121. uint8_t *data,
  122. uint32_t size);
  123. /**
  124. * OS specific aux write callback.
  125. */
  126. bool dm_helpers_dp_write_dpcd(
  127. struct dc_context *ctx,
  128. const struct dc_link *link,
  129. uint32_t address,
  130. const uint8_t *data,
  131. uint32_t size);
  132. bool dm_helpers_submit_i2c(
  133. struct dc_context *ctx,
  134. const struct dc_link *link,
  135. struct i2c_command *cmd);
  136. bool dm_helpers_dp_write_dsc_enable(
  137. struct dc_context *ctx,
  138. const struct dc_stream_state *stream,
  139. bool enable
  140. );
  141. bool dm_helpers_is_dp_sink_present(
  142. struct dc_link *link);
  143. void dm_helpers_mst_enable_stream_features(const struct dc_stream_state *stream);
  144. enum dc_edid_status dm_helpers_read_local_edid(
  145. struct dc_context *ctx,
  146. struct dc_link *link,
  147. struct dc_sink *sink);
  148. bool dm_helpers_dp_handle_test_pattern_request(
  149. struct dc_context *ctx,
  150. const struct dc_link *link,
  151. union link_test_pattern dpcd_test_pattern,
  152. union test_misc dpcd_test_params);
  153. void dm_set_dcn_clocks(
  154. struct dc_context *ctx,
  155. struct dc_clocks *clks);
  156. void dm_helpers_enable_periodic_detection(struct dc_context *ctx, bool enable);
  157. void dm_set_phyd32clk(struct dc_context *ctx, int freq_khz);
  158. bool dm_helpers_dmub_outbox_interrupt_control(struct dc_context *ctx, bool enable);
  159. void dm_helpers_smu_timeout(struct dc_context *ctx, unsigned int msg_id, unsigned int param, unsigned int timeout_us);
  160. // 0x1 = Result_OK, 0xFE = Result_UnkmownCmd, 0x0 = Status_Busy
  161. #define IS_SMU_TIMEOUT(result) \
  162. (result == 0x0)
  163. void dm_helpers_init_panel_settings(
  164. struct dc_context *ctx,
  165. struct dc_panel_config *config,
  166. struct dc_sink *sink);
  167. void dm_helpers_override_panel_settings(
  168. struct dc_context *ctx,
  169. struct dc_panel_config *config);
  170. int dm_helper_dmub_aux_transfer_sync(
  171. struct dc_context *ctx,
  172. const struct dc_link *link,
  173. struct aux_payload *payload,
  174. enum aux_return_code_type *operation_result);
  175. int dm_helpers_dmub_set_config_sync(struct dc_context *ctx,
  176. const struct dc_link *link,
  177. struct set_config_cmd_payload *payload,
  178. enum set_config_status *operation_result);
  179. enum adaptive_sync_type dm_get_adaptive_sync_support_type(struct dc_link *link);
  180. enum dc_edid_status dm_helpers_get_sbios_edid(struct dc_link *link, struct dc_edid *edid);
  181. bool dm_helpers_is_fullscreen(struct dc_context *ctx, struct dc_stream_state *stream);
  182. bool dm_helpers_is_hdr_on(struct dc_context *ctx, struct dc_stream_state *stream);
  183. #endif /* __DM_HELPERS__ */