dp_link.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2012-2019, The Linux Foundation. All rights reserved.
  4. */
  5. #ifndef _DP_LINK_H_
  6. #define _DP_LINK_H_
  7. #include "dp_aux.h"
  8. #define DS_PORT_STATUS_CHANGED 0x200
  9. #define DP_TEST_BIT_DEPTH_UNKNOWN 0xFFFFFFFF
  10. #define DP_LINK_ENUM_STR(x) #x
  11. enum dp_link_voltage_level {
  12. DP_LINK_VOLTAGE_LEVEL_0,
  13. DP_LINK_VOLTAGE_LEVEL_1,
  14. DP_LINK_VOLTAGE_LEVEL_2,
  15. DP_LINK_VOLTAGE_MAX = DP_LINK_VOLTAGE_LEVEL_2,
  16. };
  17. enum dp_link_preemaphasis_level {
  18. DP_LINK_PRE_EMPHASIS_LEVEL_0,
  19. DP_LINK_PRE_EMPHASIS_LEVEL_1,
  20. DP_LINK_PRE_EMPHASIS_LEVEL_2,
  21. DP_LINK_PRE_EMPHASIS_LEVEL_3,
  22. DP_LINK_PRE_EMPHASIS_MAX = DP_LINK_PRE_EMPHASIS_LEVEL_3,
  23. };
  24. struct dp_link_sink_count {
  25. u32 count;
  26. bool cp_ready;
  27. };
  28. struct dp_link_test_video {
  29. u32 test_video_pattern;
  30. u32 test_bit_depth;
  31. u32 test_dyn_range;
  32. u32 test_h_total;
  33. u32 test_v_total;
  34. u32 test_h_start;
  35. u32 test_v_start;
  36. u32 test_hsync_pol;
  37. u32 test_hsync_width;
  38. u32 test_vsync_pol;
  39. u32 test_vsync_width;
  40. u32 test_h_width;
  41. u32 test_v_height;
  42. u32 test_rr_d;
  43. u32 test_rr_n;
  44. };
  45. struct dp_link_test_audio {
  46. u32 test_audio_sampling_rate;
  47. u32 test_audio_channel_count;
  48. u32 test_audio_pattern_type;
  49. u32 test_audio_period_ch_1;
  50. u32 test_audio_period_ch_2;
  51. u32 test_audio_period_ch_3;
  52. u32 test_audio_period_ch_4;
  53. u32 test_audio_period_ch_5;
  54. u32 test_audio_period_ch_6;
  55. u32 test_audio_period_ch_7;
  56. u32 test_audio_period_ch_8;
  57. };
  58. struct dp_link_hdcp_status {
  59. int hdcp_state;
  60. int hdcp_version;
  61. };
  62. struct dp_link_phy_params {
  63. u32 phy_test_pattern_sel;
  64. u8 v_level;
  65. u8 p_level;
  66. };
  67. struct dp_link_params {
  68. u32 lane_count;
  69. u32 bw_code;
  70. };
  71. static inline char *dp_link_get_test_name(u32 test_requested)
  72. {
  73. switch (test_requested) {
  74. case DP_TEST_LINK_TRAINING:
  75. return DP_LINK_ENUM_STR(DP_TEST_LINK_TRAINING);
  76. case DP_TEST_LINK_VIDEO_PATTERN:
  77. return DP_LINK_ENUM_STR(DP_TEST_LINK_VIDEO_PATTERN);
  78. case DP_TEST_LINK_EDID_READ:
  79. return DP_LINK_ENUM_STR(DP_TEST_LINK_EDID_READ);
  80. case DP_TEST_LINK_PHY_TEST_PATTERN:
  81. return DP_LINK_ENUM_STR(DP_TEST_LINK_PHY_TEST_PATTERN);
  82. case DP_TEST_LINK_AUDIO_PATTERN:
  83. return DP_LINK_ENUM_STR(DP_TEST_LINK_AUDIO_PATTERN);
  84. case DS_PORT_STATUS_CHANGED:
  85. return DP_LINK_ENUM_STR(DS_PORT_STATUS_CHANGED);
  86. case DP_LINK_STATUS_UPDATED:
  87. return DP_LINK_ENUM_STR(DP_LINK_STATUS_UPDATED);
  88. default:
  89. return "unknown";
  90. }
  91. }
  92. struct dp_link {
  93. u32 sink_request;
  94. u32 test_response;
  95. struct dp_link_sink_count sink_count;
  96. struct dp_link_test_video test_video;
  97. struct dp_link_test_audio test_audio;
  98. struct dp_link_phy_params phy_params;
  99. struct dp_link_params link_params;
  100. struct dp_link_hdcp_status hdcp_status;
  101. u32 (*get_test_bits_depth)(struct dp_link *dp_link, u32 bpp);
  102. int (*process_request)(struct dp_link *dp_link);
  103. int (*get_colorimetry_config)(struct dp_link *dp_link);
  104. int (*adjust_levels)(struct dp_link *dp_link, u8 *link_status);
  105. int (*send_psm_request)(struct dp_link *dp_link, bool req);
  106. void (*send_test_response)(struct dp_link *dp_link);
  107. int (*psm_config)(struct dp_link *dp_link,
  108. struct drm_dp_link *link_info, bool enable);
  109. void (*send_edid_checksum)(struct dp_link *dp_link, u8 checksum);
  110. };
  111. static inline char *dp_link_get_phy_test_pattern(u32 phy_test_pattern_sel)
  112. {
  113. switch (phy_test_pattern_sel) {
  114. case DP_TEST_PHY_PATTERN_NONE:
  115. return DP_LINK_ENUM_STR(DP_TEST_PHY_PATTERN_NONE);
  116. case DP_TEST_PHY_PATTERN_D10_2_NO_SCRAMBLING:
  117. return DP_LINK_ENUM_STR(
  118. DP_TEST_PHY_PATTERN_D10_2_NO_SCRAMBLING);
  119. case DP_TEST_PHY_PATTERN_SYMBOL_ERR_MEASUREMENT_CNT:
  120. return DP_LINK_ENUM_STR(
  121. DP_TEST_PHY_PATTERN_SYMBOL_ERR_MEASUREMENT_CNT);
  122. case DP_TEST_PHY_PATTERN_PRBS7:
  123. return DP_LINK_ENUM_STR(DP_TEST_PHY_PATTERN_PRBS7);
  124. case DP_TEST_PHY_PATTERN_80_BIT_CUSTOM_PATTERN:
  125. return DP_LINK_ENUM_STR(
  126. DP_TEST_PHY_PATTERN_80_BIT_CUSTOM_PATTERN);
  127. case DP_TEST_PHY_PATTERN_CP2520_PATTERN_1:
  128. return DP_LINK_ENUM_STR(DP_TEST_PHY_PATTERN_CP2520_PATTERN_1);
  129. case DP_TEST_PHY_PATTERN_CP2520_PATTERN_2:
  130. return DP_LINK_ENUM_STR(DP_TEST_PHY_PATTERN_CP2520_PATTERN_2);
  131. case DP_TEST_PHY_PATTERN_CP2520_PATTERN_3:
  132. return DP_LINK_ENUM_STR(DP_TEST_PHY_PATTERN_CP2520_PATTERN_3);
  133. default:
  134. return "unknown";
  135. }
  136. }
  137. /**
  138. * mdss_dp_test_bit_depth_to_bpp() - convert test bit depth to bpp
  139. * @tbd: test bit depth
  140. *
  141. * Returns the bits per pixel (bpp) to be used corresponding to the
  142. * git bit depth value. This function assumes that bit depth has
  143. * already been validated.
  144. */
  145. static inline u32 dp_link_bit_depth_to_bpp(u32 tbd)
  146. {
  147. u32 bpp;
  148. /*
  149. * Few simplistic rules and assumptions made here:
  150. * 1. Bit depth is per color component
  151. * 2. If bit depth is unknown return 0
  152. * 3. Assume 3 color components
  153. */
  154. switch (tbd) {
  155. case DP_TEST_BIT_DEPTH_6:
  156. bpp = 18;
  157. break;
  158. case DP_TEST_BIT_DEPTH_8:
  159. bpp = 24;
  160. break;
  161. case DP_TEST_BIT_DEPTH_10:
  162. bpp = 30;
  163. break;
  164. case DP_TEST_BIT_DEPTH_UNKNOWN:
  165. default:
  166. bpp = 0;
  167. }
  168. return bpp;
  169. }
  170. /**
  171. * dp_link_get() - get the functionalities of dp test module
  172. *
  173. *
  174. * return: a pointer to dp_link struct
  175. */
  176. struct dp_link *dp_link_get(struct device *dev, struct dp_aux *aux);
  177. /**
  178. * dp_link_put() - releases the dp test module's resources
  179. *
  180. * @dp_link: an instance of dp_link module
  181. *
  182. */
  183. void dp_link_put(struct dp_link *dp_link);
  184. #endif /* _DP_LINK_H_ */