dc_link.h 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. /*
  2. * Copyright 2012-14 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. #ifndef DC_LINK_H_
  26. #define DC_LINK_H_
  27. #include "dc_types.h"
  28. #include "grph_object_defs.h"
  29. struct dc_link_status {
  30. struct dpcd_caps *dpcd_caps;
  31. };
  32. /* DP MST stream allocation (payload bandwidth number) */
  33. struct link_mst_stream_allocation {
  34. /* DIG front */
  35. const struct stream_encoder *stream_enc;
  36. /* associate DRM payload table with DC stream encoder */
  37. uint8_t vcp_id;
  38. /* number of slots required for the DP stream in transport packet */
  39. uint8_t slot_count;
  40. };
  41. /* DP MST stream allocation table */
  42. struct link_mst_stream_allocation_table {
  43. /* number of DP video streams */
  44. int stream_count;
  45. /* array of stream allocations */
  46. struct link_mst_stream_allocation stream_allocations[MAX_CONTROLLER_NUM];
  47. };
  48. struct time_stamp {
  49. uint64_t edp_poweroff;
  50. uint64_t edp_poweron;
  51. };
  52. struct link_trace {
  53. struct time_stamp time_stamp;
  54. };
  55. /*
  56. * A link contains one or more sinks and their connected status.
  57. * The currently active signal type (HDMI, DP-SST, DP-MST) is also reported.
  58. */
  59. struct dc_link {
  60. struct dc_sink *remote_sinks[MAX_SINKS_PER_LINK];
  61. unsigned int sink_count;
  62. struct dc_sink *local_sink;
  63. unsigned int link_index;
  64. enum dc_connection_type type;
  65. enum signal_type connector_signal;
  66. enum dc_irq_source irq_source_hpd;
  67. enum dc_irq_source irq_source_hpd_rx;/* aka DP Short Pulse */
  68. bool is_hpd_filter_disabled;
  69. bool dp_ss_off;
  70. /* caps is the same as reported_link_cap. link_traing use
  71. * reported_link_cap. Will clean up. TODO
  72. */
  73. struct dc_link_settings reported_link_cap;
  74. struct dc_link_settings verified_link_cap;
  75. struct dc_link_settings cur_link_settings;
  76. struct dc_lane_settings cur_lane_setting;
  77. struct dc_link_settings preferred_link_setting;
  78. uint8_t ddc_hw_inst;
  79. uint8_t hpd_src;
  80. uint8_t link_enc_hw_inst;
  81. bool test_pattern_enabled;
  82. union compliance_test_state compliance_test_state;
  83. void *priv;
  84. struct ddc_service *ddc;
  85. bool aux_mode;
  86. /* Private to DC core */
  87. const struct dc *dc;
  88. struct dc_context *ctx;
  89. struct link_encoder *link_enc;
  90. struct graphics_object_id link_id;
  91. union ddi_channel_mapping ddi_channel_mapping;
  92. struct connector_device_tag_info device_tag;
  93. struct dpcd_caps dpcd_caps;
  94. unsigned short chip_caps;
  95. unsigned int dpcd_sink_count;
  96. enum edp_revision edp_revision;
  97. bool psr_enabled;
  98. /* MST record stream using this link */
  99. struct link_flags {
  100. bool dp_keep_receiver_powered;
  101. } wa_flags;
  102. struct link_mst_stream_allocation_table mst_stream_alloc_table;
  103. struct dc_link_status link_status;
  104. struct link_trace link_trace;
  105. };
  106. const struct dc_link_status *dc_link_get_status(const struct dc_link *dc_link);
  107. /*
  108. * Return an enumerated dc_link. dc_link order is constant and determined at
  109. * boot time. They cannot be created or destroyed.
  110. * Use dc_get_caps() to get number of links.
  111. */
  112. static inline struct dc_link *dc_get_link_at_index(struct dc *dc, uint32_t link_index)
  113. {
  114. return dc->links[link_index];
  115. }
  116. /* Set backlight level of an embedded panel (eDP, LVDS). */
  117. bool dc_link_set_backlight_level(const struct dc_link *dc_link, uint32_t level,
  118. uint32_t frame_ramp, const struct dc_stream_state *stream);
  119. int dc_link_get_backlight_level(const struct dc_link *dc_link);
  120. bool dc_link_set_abm_disable(const struct dc_link *dc_link);
  121. bool dc_link_set_psr_enable(const struct dc_link *dc_link, bool enable, bool wait);
  122. bool dc_link_get_psr_state(const struct dc_link *dc_link, uint32_t *psr_state);
  123. bool dc_link_setup_psr(struct dc_link *dc_link,
  124. const struct dc_stream_state *stream, struct psr_config *psr_config,
  125. struct psr_context *psr_context);
  126. /* Request DC to detect if there is a Panel connected.
  127. * boot - If this call is during initial boot.
  128. * Return false for any type of detection failure or MST detection
  129. * true otherwise. True meaning further action is required (status update
  130. * and OS notification).
  131. */
  132. enum dc_detect_reason {
  133. DETECT_REASON_BOOT,
  134. DETECT_REASON_HPD,
  135. DETECT_REASON_HPDRX,
  136. };
  137. bool dc_link_detect(struct dc_link *dc_link, enum dc_detect_reason reason);
  138. bool dc_link_get_hpd_state(struct dc_link *dc_link);
  139. /* Notify DC about DP RX Interrupt (aka Short Pulse Interrupt).
  140. * Return:
  141. * true - Downstream port status changed. DM should call DC to do the
  142. * detection.
  143. * false - no change in Downstream port status. No further action required
  144. * from DM. */
  145. bool dc_link_handle_hpd_rx_irq(struct dc_link *dc_link,
  146. union hpd_irq_data *hpd_irq_dpcd_data, bool *out_link_loss);
  147. struct dc_sink_init_data;
  148. struct dc_sink *dc_link_add_remote_sink(
  149. struct dc_link *dc_link,
  150. const uint8_t *edid,
  151. int len,
  152. struct dc_sink_init_data *init_data);
  153. void dc_link_remove_remote_sink(
  154. struct dc_link *link,
  155. struct dc_sink *sink);
  156. /* Used by diagnostics for virtual link at the moment */
  157. void dc_link_dp_set_drive_settings(
  158. struct dc_link *link,
  159. struct link_training_settings *lt_settings);
  160. enum link_training_result dc_link_dp_perform_link_training(
  161. struct dc_link *link,
  162. const struct dc_link_settings *link_setting,
  163. bool skip_video_pattern);
  164. void dc_link_dp_enable_hpd(const struct dc_link *link);
  165. void dc_link_dp_disable_hpd(const struct dc_link *link);
  166. bool dc_link_dp_set_test_pattern(
  167. struct dc_link *link,
  168. enum dp_test_pattern test_pattern,
  169. const struct link_training_settings *p_link_settings,
  170. const unsigned char *p_custom_pattern,
  171. unsigned int cust_pattern_size);
  172. void dc_link_enable_hpd_filter(struct dc_link *link, bool enable);
  173. bool dc_link_is_dp_sink_present(struct dc_link *link);
  174. bool dc_link_detect_sink(struct dc_link *link, enum dc_connection_type *type);
  175. /*
  176. * DPCD access interfaces
  177. */
  178. void dc_link_set_drive_settings(struct dc *dc,
  179. struct link_training_settings *lt_settings,
  180. const struct dc_link *link);
  181. void dc_link_perform_link_training(struct dc *dc,
  182. struct dc_link_settings *link_setting,
  183. bool skip_video_pattern);
  184. void dc_link_set_preferred_link_settings(struct dc *dc,
  185. struct dc_link_settings *link_setting,
  186. struct dc_link *link);
  187. void dc_link_enable_hpd(const struct dc_link *link);
  188. void dc_link_disable_hpd(const struct dc_link *link);
  189. void dc_link_set_test_pattern(struct dc_link *link,
  190. enum dp_test_pattern test_pattern,
  191. const struct link_training_settings *p_link_settings,
  192. const unsigned char *p_custom_pattern,
  193. unsigned int cust_pattern_size);
  194. bool dc_submit_i2c(
  195. struct dc *dc,
  196. uint32_t link_index,
  197. struct i2c_command *cmd);
  198. #endif /* DC_LINK_H_ */