1 /* SPDX-License-Identifier: GPL-2.0-only */ 2 /* 3 * Copyright (c) 2012-2020, The Linux Foundation. All rights reserved. 4 */ 5 6 #ifndef _DP_LINK_H_ 7 #define _DP_LINK_H_ 8 9 #include "dp_aux.h" 10 11 #define DS_PORT_STATUS_CHANGED 0x200 12 #define DP_TEST_BIT_DEPTH_UNKNOWN 0xFFFFFFFF 13 #define DP_LINK_CAP_ENHANCED_FRAMING (1 << 0) 14 15 struct dp_link_info { 16 unsigned char revision; 17 unsigned int rate; 18 unsigned int num_lanes; 19 unsigned long capabilities; 20 }; 21 22 #define DP_TRAIN_LEVEL_MAX 3 23 24 struct dp_link_test_video { 25 u32 test_video_pattern; 26 u32 test_bit_depth; 27 u32 test_dyn_range; 28 u32 test_h_total; 29 u32 test_v_total; 30 u32 test_h_start; 31 u32 test_v_start; 32 u32 test_hsync_pol; 33 u32 test_hsync_width; 34 u32 test_vsync_pol; 35 u32 test_vsync_width; 36 u32 test_h_width; 37 u32 test_v_height; 38 u32 test_rr_d; 39 u32 test_rr_n; 40 }; 41 42 struct dp_link_test_audio { 43 u32 test_audio_sampling_rate; 44 u32 test_audio_channel_count; 45 u32 test_audio_pattern_type; 46 u32 test_audio_period_ch_1; 47 u32 test_audio_period_ch_2; 48 u32 test_audio_period_ch_3; 49 u32 test_audio_period_ch_4; 50 u32 test_audio_period_ch_5; 51 u32 test_audio_period_ch_6; 52 u32 test_audio_period_ch_7; 53 u32 test_audio_period_ch_8; 54 }; 55 56 struct dp_link_phy_params { 57 u32 phy_test_pattern_sel; 58 u8 v_level; 59 u8 p_level; 60 }; 61 62 struct dp_link { 63 u32 sink_request; 64 u32 test_response; 65 bool psm_enabled; 66 67 u8 sink_count; 68 struct dp_link_test_video test_video; 69 struct dp_link_test_audio test_audio; 70 struct dp_link_phy_params phy_params; 71 struct dp_link_info link_params; 72 }; 73 74 /** 75 * mdss_dp_test_bit_depth_to_bpp() - convert test bit depth to bpp 76 * @tbd: test bit depth 77 * 78 * Returns the bits per pixel (bpp) to be used corresponding to the 79 * git bit depth value. This function assumes that bit depth has 80 * already been validated. 81 */ 82 static inline u32 dp_link_bit_depth_to_bpp(u32 tbd) 83 { 84 /* 85 * Few simplistic rules and assumptions made here: 86 * 1. Bit depth is per color component 87 * 2. If bit depth is unknown return 0 88 * 3. Assume 3 color components 89 */ 90 switch (tbd) { 91 case DP_TEST_BIT_DEPTH_6: 92 return 18; 93 case DP_TEST_BIT_DEPTH_8: 94 return 24; 95 case DP_TEST_BIT_DEPTH_10: 96 return 30; 97 case DP_TEST_BIT_DEPTH_UNKNOWN: 98 default: 99 return 0; 100 } 101 } 102 103 /** 104 * dp_test_bit_depth_to_bpc() - convert test bit depth to bpc 105 * @tbd: test bit depth 106 * 107 * Returns the bits per comp (bpc) to be used corresponding to the 108 * bit depth value. This function assumes that bit depth has 109 * already been validated. 110 */ 111 static inline u32 dp_link_bit_depth_to_bpc(u32 tbd) 112 { 113 switch (tbd) { 114 case DP_TEST_BIT_DEPTH_6: 115 return 6; 116 case DP_TEST_BIT_DEPTH_8: 117 return 8; 118 case DP_TEST_BIT_DEPTH_10: 119 return 10; 120 case DP_TEST_BIT_DEPTH_UNKNOWN: 121 default: 122 return 0; 123 } 124 } 125 126 void dp_link_reset_phy_params_vx_px(struct dp_link *dp_link); 127 u32 dp_link_get_test_bits_depth(struct dp_link *dp_link, u32 bpp); 128 int dp_link_process_request(struct dp_link *dp_link); 129 int dp_link_get_colorimetry_config(struct dp_link *dp_link); 130 int dp_link_adjust_levels(struct dp_link *dp_link, u8 *link_status); 131 bool dp_link_send_test_response(struct dp_link *dp_link); 132 int dp_link_psm_config(struct dp_link *dp_link, 133 struct dp_link_info *link_info, bool enable); 134 bool dp_link_send_edid_checksum(struct dp_link *dp_link, u8 checksum); 135 136 /** 137 * dp_link_get() - get the functionalities of dp test module 138 * 139 * 140 * return: a pointer to dp_link struct 141 */ 142 struct dp_link *dp_link_get(struct device *dev, struct drm_dp_aux *aux); 143 144 #endif /* _DP_LINK_H_ */ 145