@@ -177,6 +177,40 @@ void dm_helpers_dp_update_branch_info(
177177 const struct dc_link * link )
178178{}
179179
180+ static void dm_helpers_construct_old_payload (
181+ struct dc_link * link ,
182+ int pbn_per_slot ,
183+ struct drm_dp_mst_atomic_payload * new_payload ,
184+ struct drm_dp_mst_atomic_payload * old_payload )
185+ {
186+ struct link_mst_stream_allocation_table current_link_table =
187+ link -> mst_stream_alloc_table ;
188+ struct link_mst_stream_allocation * dc_alloc ;
189+ int i ;
190+
191+ * old_payload = * new_payload ;
192+
193+ /* Set correct time_slots/PBN of old payload.
194+ * other fields (delete & dsc_enabled) in
195+ * struct drm_dp_mst_atomic_payload are don't care fields
196+ * while calling drm_dp_remove_payload()
197+ */
198+ for (i = 0 ; i < current_link_table .stream_count ; i ++ ) {
199+ dc_alloc =
200+ & current_link_table .stream_allocations [i ];
201+
202+ if (dc_alloc -> vcp_id == new_payload -> vcpi ) {
203+ old_payload -> time_slots = dc_alloc -> slot_count ;
204+ old_payload -> pbn = dc_alloc -> slot_count * pbn_per_slot ;
205+ break ;
206+ }
207+ }
208+
209+ /* make sure there is an old payload*/
210+ ASSERT (i != current_link_table .stream_count );
211+
212+ }
213+
180214/*
181215 * Writes payload allocation table in immediate downstream device.
182216 */
@@ -188,7 +222,7 @@ bool dm_helpers_dp_mst_write_payload_allocation_table(
188222{
189223 struct amdgpu_dm_connector * aconnector ;
190224 struct drm_dp_mst_topology_state * mst_state ;
191- struct drm_dp_mst_atomic_payload * payload ;
225+ struct drm_dp_mst_atomic_payload * target_payload , * new_payload , old_payload ;
192226 struct drm_dp_mst_topology_mgr * mst_mgr ;
193227
194228 aconnector = (struct amdgpu_dm_connector * )stream -> dm_stream_context ;
@@ -204,17 +238,26 @@ bool dm_helpers_dp_mst_write_payload_allocation_table(
204238 mst_state = to_drm_dp_mst_topology_state (mst_mgr -> base .state );
205239
206240 /* It's OK for this to fail */
207- payload = drm_atomic_get_mst_payload_state (mst_state , aconnector -> mst_output_port );
208- if (enable )
209- drm_dp_add_payload_part1 (mst_mgr , mst_state , payload );
210- else
211- drm_dp_remove_payload (mst_mgr , mst_state , payload , payload );
241+ new_payload = drm_atomic_get_mst_payload_state (mst_state , aconnector -> mst_output_port );
242+
243+ if (enable ) {
244+ target_payload = new_payload ;
245+
246+ drm_dp_add_payload_part1 (mst_mgr , mst_state , new_payload );
247+ } else {
248+ /* construct old payload by VCPI*/
249+ dm_helpers_construct_old_payload (stream -> link , mst_state -> pbn_div ,
250+ new_payload , & old_payload );
251+ target_payload = & old_payload ;
252+
253+ drm_dp_remove_payload (mst_mgr , mst_state , & old_payload , new_payload );
254+ }
212255
213256 /* mst_mgr->->payloads are VC payload notify MST branch using DPCD or
214257 * AUX message. The sequence is slot 1-63 allocated sequence for each
215258 * stream. AMD ASIC stream slot allocation should follow the same
216259 * sequence. copy DRM MST allocation to dc */
217- fill_dc_mst_payload_table_from_drm (stream -> link , enable , payload , proposed_table );
260+ fill_dc_mst_payload_table_from_drm (stream -> link , enable , target_payload , proposed_table );
218261
219262 return true;
220263}
0 commit comments