2929#include <drm/drm_edid.h>
3030#include <drm/drm_probe_helper.h>
3131
32+ static int intel_dp_mst_compute_link_config (struct intel_encoder * encoder ,
33+ struct intel_crtc_state * crtc_state ,
34+ struct drm_connector_state * conn_state ,
35+ struct link_config_limits * limits )
36+ {
37+ struct drm_atomic_state * state = crtc_state -> base .state ;
38+ struct intel_dp_mst_encoder * intel_mst = enc_to_mst (& encoder -> base );
39+ struct intel_dp * intel_dp = & intel_mst -> primary -> dp ;
40+ struct intel_connector * connector =
41+ to_intel_connector (conn_state -> connector );
42+ const struct drm_display_mode * adjusted_mode =
43+ & crtc_state -> base .adjusted_mode ;
44+ void * port = connector -> port ;
45+ bool constant_n = drm_dp_has_quirk (& intel_dp -> desc ,
46+ DP_DPCD_QUIRK_CONSTANT_N );
47+ int bpp , slots = - EINVAL ;
48+
49+ crtc_state -> lane_count = limits -> max_lane_count ;
50+ crtc_state -> port_clock = limits -> max_clock ;
51+
52+ for (bpp = limits -> max_bpp ; bpp >= limits -> min_bpp ; bpp -= 2 * 3 ) {
53+ crtc_state -> pipe_bpp = bpp ;
54+
55+ crtc_state -> pbn = drm_dp_calc_pbn_mode (adjusted_mode -> crtc_clock ,
56+ crtc_state -> pipe_bpp );
57+
58+ slots = drm_dp_atomic_find_vcpi_slots (state , & intel_dp -> mst_mgr ,
59+ port , crtc_state -> pbn );
60+ if (slots == - EDEADLK )
61+ return slots ;
62+ if (slots >= 0 )
63+ break ;
64+ }
65+
66+ if (slots < 0 ) {
67+ DRM_DEBUG_KMS ("failed finding vcpi slots:%d\n" , slots );
68+ return slots ;
69+ }
70+
71+ intel_link_compute_m_n (crtc_state -> pipe_bpp ,
72+ crtc_state -> lane_count ,
73+ adjusted_mode -> crtc_clock ,
74+ crtc_state -> port_clock ,
75+ & crtc_state -> dp_m_n ,
76+ constant_n );
77+ crtc_state -> dp_m_n .tu = slots ;
78+
79+ return 0 ;
80+ }
81+
3282static int intel_dp_mst_compute_config (struct intel_encoder * encoder ,
3383 struct intel_crtc_state * pipe_config ,
3484 struct drm_connector_state * conn_state )
3585{
3686 struct drm_i915_private * dev_priv = to_i915 (encoder -> base .dev );
3787 struct intel_dp_mst_encoder * intel_mst = enc_to_mst (& encoder -> base );
38- struct intel_digital_port * intel_dig_port = intel_mst -> primary ;
39- struct intel_dp * intel_dp = & intel_dig_port -> dp ;
40- struct drm_connector * connector = conn_state -> connector ;
88+ struct intel_dp * intel_dp = & intel_mst -> primary -> dp ;
89+ struct intel_connector * connector =
90+ to_intel_connector ( conn_state -> connector ) ;
4191 struct intel_digital_connector_state * intel_conn_state =
4292 to_intel_digital_connector_state (conn_state );
43- void * port = to_intel_connector (connector )-> port ;
44- struct drm_atomic_state * state = pipe_config -> base .state ;
45- struct drm_crtc * crtc = pipe_config -> base .crtc ;
46- struct drm_crtc_state * old_crtc_state =
47- drm_atomic_get_old_crtc_state (state , crtc );
48- int bpp ;
49- int lane_count , slots =
50- to_intel_crtc_state (old_crtc_state )-> dp_m_n .tu ;
51- const struct drm_display_mode * adjusted_mode = & pipe_config -> base .adjusted_mode ;
52- int mst_pbn ;
53- bool constant_n = drm_dp_has_quirk (& intel_dp -> desc ,
54- DP_DPCD_QUIRK_CONSTANT_N );
93+ const struct drm_display_mode * adjusted_mode =
94+ & pipe_config -> base .adjusted_mode ;
95+ void * port = connector -> port ;
96+ struct link_config_limits limits ;
97+ int ret ;
5598
5699 if (adjusted_mode -> flags & DRM_MODE_FLAG_DBLSCAN )
57100 return - EINVAL ;
58101
59102 pipe_config -> output_format = INTEL_OUTPUT_FORMAT_RGB ;
60103 pipe_config -> has_pch_encoder = false;
61- bpp = 24 ;
62- if (intel_dp -> compliance .test_data .bpc ) {
63- bpp = intel_dp -> compliance .test_data .bpc * 3 ;
64- DRM_DEBUG_KMS ("Setting pipe bpp to %d\n" ,
65- bpp );
66- }
67104
68105 if (intel_conn_state -> force_audio == HDMI_AUDIO_AUTO )
69106 pipe_config -> has_audio =
@@ -76,36 +113,25 @@ static int intel_dp_mst_compute_config(struct intel_encoder *encoder,
76113 * for MST we always configure max link bw - the spec doesn't
77114 * seem to suggest we should do otherwise.
78115 */
79- lane_count = intel_dp_max_lane_count (intel_dp );
116+ limits .min_clock =
117+ limits .max_clock = intel_dp_max_link_rate (intel_dp );
80118
81- pipe_config -> lane_count = lane_count ;
119+ limits .min_lane_count =
120+ limits .max_lane_count = intel_dp_max_lane_count (intel_dp );
82121
83- pipe_config -> pipe_bpp = bpp ;
122+ limits .min_bpp = 6 * 3 ;
123+ limits .max_bpp = pipe_config -> pipe_bpp ;
84124
85- pipe_config -> port_clock = intel_dp_max_link_rate (intel_dp );
125+ intel_dp_adjust_compliance_config (intel_dp , pipe_config , & limits );
126+
127+ ret = intel_dp_mst_compute_link_config (encoder , pipe_config ,
128+ conn_state , & limits );
129+ if (ret )
130+ return ret ;
86131
87132 pipe_config -> limited_color_range =
88133 intel_dp_limited_color_range (pipe_config , conn_state );
89134
90- mst_pbn = drm_dp_calc_pbn_mode (adjusted_mode -> crtc_clock , bpp );
91- pipe_config -> pbn = mst_pbn ;
92-
93- slots = drm_dp_atomic_find_vcpi_slots (state , & intel_dp -> mst_mgr , port ,
94- mst_pbn );
95- if (slots < 0 ) {
96- DRM_DEBUG_KMS ("failed finding vcpi slots:%d\n" ,
97- slots );
98- return slots ;
99- }
100-
101- intel_link_compute_m_n (bpp , lane_count ,
102- adjusted_mode -> crtc_clock ,
103- pipe_config -> port_clock ,
104- & pipe_config -> dp_m_n ,
105- constant_n );
106-
107- pipe_config -> dp_m_n .tu = slots ;
108-
109135 if (IS_GEN9_LP (dev_priv ))
110136 pipe_config -> lane_lat_optim_mask =
111137 bxt_ddi_phy_calc_lane_lat_optim_mask (pipe_config -> lane_count );
@@ -389,7 +415,6 @@ intel_dp_mst_mode_valid(struct drm_connector *connector,
389415 struct intel_connector * intel_connector = to_intel_connector (connector );
390416 struct intel_dp * intel_dp = intel_connector -> mst_port ;
391417 int max_dotclk = to_i915 (connector -> dev )-> max_dotclk_freq ;
392- int bpp = 24 ; /* MST uses fixed bpp */
393418 int max_rate , mode_rate , max_lanes , max_link_clock ;
394419
395420 if (drm_connector_is_unregistered (connector ))
@@ -402,7 +427,7 @@ intel_dp_mst_mode_valid(struct drm_connector *connector,
402427 max_lanes = intel_dp_max_lane_count (intel_dp );
403428
404429 max_rate = intel_dp_max_data_rate (max_link_clock , max_lanes );
405- mode_rate = intel_dp_link_required (mode -> clock , bpp );
430+ mode_rate = intel_dp_link_required (mode -> clock , 18 );
406431
407432 /* TODO - validate mode against available PBN for link */
408433 if (mode -> clock < 10000 )
0 commit comments