dp_link.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2012-2020, The Linux Foundation. All rights reserved.
  4. */
  5. #ifndef _DP_LINK_H_
  6. #define _DP_LINK_H_
  7. #include "dp_aux.h"
  8. #include <drm/display/drm_dp_helper.h>
  9. #define DS_PORT_STATUS_CHANGED 0x200
  10. #define DP_TEST_BIT_DEPTH_UNKNOWN 0xFFFFFFFF
  11. #define DP_LINK_CAP_ENHANCED_FRAMING (1 << 0)
  12. #define DP_MAX_NUM_DP_LANES 4
  13. struct msm_dp_link_info {
  14. unsigned char revision;
  15. unsigned int rate;
  16. unsigned int supported_rates[DP_MAX_SUPPORTED_RATES];
  17. unsigned int rate_set;
  18. bool use_rate_set;
  19. unsigned int num_lanes;
  20. unsigned long capabilities;
  21. };
  22. #define DP_TRAIN_LEVEL_MAX 3
  23. struct msm_dp_link_test_video {
  24. u32 test_video_pattern;
  25. u32 test_bit_depth;
  26. u32 test_dyn_range;
  27. u32 test_h_total;
  28. u32 test_v_total;
  29. u32 test_h_start;
  30. u32 test_v_start;
  31. u32 test_hsync_pol;
  32. u32 test_hsync_width;
  33. u32 test_vsync_pol;
  34. u32 test_vsync_width;
  35. u32 test_h_width;
  36. u32 test_v_height;
  37. u32 test_rr_d;
  38. u32 test_rr_n;
  39. };
  40. struct msm_dp_link_test_audio {
  41. u32 test_audio_sampling_rate;
  42. u32 test_audio_channel_count;
  43. u32 test_audio_pattern_type;
  44. u32 test_audio_period_ch_1;
  45. u32 test_audio_period_ch_2;
  46. u32 test_audio_period_ch_3;
  47. u32 test_audio_period_ch_4;
  48. u32 test_audio_period_ch_5;
  49. u32 test_audio_period_ch_6;
  50. u32 test_audio_period_ch_7;
  51. u32 test_audio_period_ch_8;
  52. };
  53. struct msm_dp_link_phy_params {
  54. u32 phy_test_pattern_sel;
  55. u8 v_level;
  56. u8 p_level;
  57. };
  58. struct msm_dp_link {
  59. u8 lttpr_common_caps[DP_LTTPR_COMMON_CAP_SIZE];
  60. int lttpr_count;
  61. u32 sink_request;
  62. u32 test_response;
  63. u8 sink_count;
  64. struct msm_dp_link_test_video test_video;
  65. struct msm_dp_link_test_audio test_audio;
  66. struct msm_dp_link_phy_params phy_params;
  67. struct msm_dp_link_info link_params;
  68. u32 lane_map[DP_MAX_NUM_DP_LANES];
  69. u32 max_dp_lanes;
  70. u32 max_dp_link_rate;
  71. };
  72. /**
  73. * msm_dp_link_bit_depth_to_bpp() - convert test bit depth to bpp
  74. * @tbd: test bit depth
  75. *
  76. * Returns: the bits per pixel (bpp) to be used corresponding to the
  77. * bit depth value. This function assumes that bit depth has
  78. * already been validated.
  79. */
  80. static inline u32 msm_dp_link_bit_depth_to_bpp(u32 tbd)
  81. {
  82. /*
  83. * Few simplistic rules and assumptions made here:
  84. * 1. Bit depth is per color component
  85. * 2. If bit depth is unknown return 0
  86. * 3. Assume 3 color components
  87. */
  88. switch (tbd) {
  89. case DP_TEST_BIT_DEPTH_6:
  90. return 18;
  91. case DP_TEST_BIT_DEPTH_8:
  92. return 24;
  93. case DP_TEST_BIT_DEPTH_10:
  94. return 30;
  95. case DP_TEST_BIT_DEPTH_UNKNOWN:
  96. default:
  97. return 0;
  98. }
  99. }
  100. void msm_dp_link_reset_phy_params_vx_px(struct msm_dp_link *msm_dp_link);
  101. u32 msm_dp_link_get_test_bits_depth(struct msm_dp_link *msm_dp_link, u32 bpp);
  102. int msm_dp_link_process_request(struct msm_dp_link *msm_dp_link);
  103. int msm_dp_link_get_colorimetry_config(struct msm_dp_link *msm_dp_link);
  104. int msm_dp_link_adjust_levels(struct msm_dp_link *msm_dp_link, u8 *link_status);
  105. bool msm_dp_link_send_test_response(struct msm_dp_link *msm_dp_link);
  106. int msm_dp_link_psm_config(struct msm_dp_link *msm_dp_link,
  107. struct msm_dp_link_info *link_info, bool enable);
  108. bool msm_dp_link_send_edid_checksum(struct msm_dp_link *msm_dp_link, u8 checksum);
  109. /**
  110. * msm_dp_link_get() - get the functionalities of dp test module
  111. * @dev: kernel device structure
  112. * @aux: DisplayPort AUX channel
  113. *
  114. * return: a pointer to msm_dp_link struct
  115. */
  116. struct msm_dp_link *msm_dp_link_get(struct device *dev, struct drm_dp_aux *aux);
  117. #endif /* _DP_LINK_H_ */