mod_freesync.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. /*
  2. * Copyright 2016 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. * Copyright 2016 Advanced Micro Devices, Inc.
  27. *
  28. * Permission is hereby granted, free of charge, to any person obtaining a
  29. * copy of this software and associated documentation files (the "Software"),
  30. * to deal in the Software without restriction, including without limitation
  31. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  32. * and/or sell copies of the Software, and to permit persons to whom the
  33. * Software is furnished to do so, subject to the following conditions:
  34. *
  35. * The above copyright notice and this permission notice shall be included in
  36. * all copies or substantial portions of the Software.
  37. *
  38. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  39. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  40. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  41. * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
  42. * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  43. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  44. * OTHER DEALINGS IN THE SOFTWARE.
  45. *
  46. * Authors: AMD
  47. *
  48. */
  49. #ifndef MOD_FREESYNC_H_
  50. #define MOD_FREESYNC_H_
  51. #include "mod_shared.h"
  52. // Access structures
  53. struct mod_freesync {
  54. int dummy;
  55. };
  56. // TODO: References to this should be removed
  57. struct mod_freesync_caps {
  58. bool supported;
  59. unsigned int min_refresh_in_micro_hz;
  60. unsigned int max_refresh_in_micro_hz;
  61. };
  62. enum mod_vrr_state {
  63. VRR_STATE_UNSUPPORTED = 0,
  64. VRR_STATE_DISABLED,
  65. VRR_STATE_INACTIVE,
  66. VRR_STATE_ACTIVE_VARIABLE,
  67. VRR_STATE_ACTIVE_FIXED
  68. };
  69. struct mod_freesync_config {
  70. enum mod_vrr_state state;
  71. bool vsif_supported;
  72. bool ramping;
  73. bool btr;
  74. unsigned int min_refresh_in_uhz;
  75. unsigned int max_refresh_in_uhz;
  76. };
  77. struct mod_vrr_params_btr {
  78. bool btr_enabled;
  79. bool btr_active;
  80. uint32_t mid_point_in_us;
  81. uint32_t inserted_duration_in_us;
  82. uint32_t frames_to_insert;
  83. uint32_t frame_counter;
  84. };
  85. struct mod_vrr_params_fixed_refresh {
  86. bool fixed_active;
  87. bool ramping_active;
  88. bool ramping_done;
  89. uint32_t target_refresh_in_uhz;
  90. uint32_t frame_counter;
  91. };
  92. struct mod_vrr_params {
  93. bool supported;
  94. bool send_vsif;
  95. enum mod_vrr_state state;
  96. uint32_t min_refresh_in_uhz;
  97. uint32_t max_duration_in_us;
  98. uint32_t max_refresh_in_uhz;
  99. uint32_t min_duration_in_us;
  100. struct dc_crtc_timing_adjust adjust;
  101. struct mod_vrr_params_fixed_refresh fixed;
  102. struct mod_vrr_params_btr btr;
  103. };
  104. struct mod_freesync *mod_freesync_create(struct dc *dc);
  105. void mod_freesync_destroy(struct mod_freesync *mod_freesync);
  106. bool mod_freesync_get_vmin_vmax(struct mod_freesync *mod_freesync,
  107. const struct dc_stream_state *stream,
  108. unsigned int *vmin,
  109. unsigned int *vmax);
  110. bool mod_freesync_get_v_position(struct mod_freesync *mod_freesync,
  111. struct dc_stream_state *stream,
  112. unsigned int *nom_v_pos,
  113. unsigned int *v_pos);
  114. void mod_freesync_get_settings(struct mod_freesync *mod_freesync,
  115. const struct mod_vrr_params *vrr,
  116. unsigned int *v_total_min, unsigned int *v_total_max,
  117. unsigned int *event_triggers,
  118. unsigned int *window_min, unsigned int *window_max,
  119. unsigned int *lfc_mid_point_in_us,
  120. unsigned int *inserted_frames,
  121. unsigned int *inserted_duration_in_us);
  122. void mod_freesync_build_vrr_infopacket(struct mod_freesync *mod_freesync,
  123. const struct dc_stream_state *stream,
  124. const struct mod_vrr_params *vrr,
  125. enum vrr_packet_type packet_type,
  126. const enum color_transfer_func *app_tf,
  127. struct dc_info_packet *infopacket);
  128. void mod_freesync_build_vrr_params(struct mod_freesync *mod_freesync,
  129. const struct dc_stream_state *stream,
  130. struct mod_freesync_config *in_config,
  131. struct mod_vrr_params *in_out_vrr);
  132. void mod_freesync_handle_preflip(struct mod_freesync *mod_freesync,
  133. const struct dc_plane_state *plane,
  134. const struct dc_stream_state *stream,
  135. unsigned int curr_time_stamp_in_us,
  136. struct mod_vrr_params *in_out_vrr);
  137. void mod_freesync_handle_v_update(struct mod_freesync *mod_freesync,
  138. const struct dc_stream_state *stream,
  139. struct mod_vrr_params *in_out_vrr);
  140. unsigned long long mod_freesync_calc_nominal_field_rate(
  141. const struct dc_stream_state *stream);
  142. bool mod_freesync_is_valid_range(struct mod_freesync *mod_freesync,
  143. const struct dc_stream_state *stream,
  144. uint32_t min_refresh_cap_in_uhz,
  145. uint32_t max_refresh_cap_in_uhz,
  146. uint32_t min_refresh_request_in_uhz,
  147. uint32_t max_refresh_request_in_uhz);
  148. #endif