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