@@ -169,11 +169,23 @@ static void add_link_enc_assignment(
169169/* Return first available DIG link encoder. */
170170static enum engine_id find_first_avail_link_enc (
171171 const struct dc_context * ctx ,
172- const struct dc_state * state )
172+ const struct dc_state * state ,
173+ enum engine_id eng_id_requested )
173174{
174175 enum engine_id eng_id = ENGINE_ID_UNKNOWN ;
175176 int i ;
176177
178+ if (eng_id_requested != ENGINE_ID_UNKNOWN ) {
179+
180+ for (i = 0 ; i < ctx -> dc -> res_pool -> res_cap -> num_dig_link_enc ; i ++ ) {
181+ eng_id = state -> res_ctx .link_enc_cfg_ctx .link_enc_avail [i ];
182+ if (eng_id == eng_id_requested )
183+ return eng_id ;
184+ }
185+ }
186+
187+ eng_id = ENGINE_ID_UNKNOWN ;
188+
177189 for (i = 0 ; i < ctx -> dc -> res_pool -> res_cap -> num_dig_link_enc ; i ++ ) {
178190 eng_id = state -> res_ctx .link_enc_cfg_ctx .link_enc_avail [i ];
179191 if (eng_id != ENGINE_ID_UNKNOWN )
@@ -287,7 +299,7 @@ void link_enc_cfg_link_encs_assign(
287299 struct dc_stream_state * streams [],
288300 uint8_t stream_count )
289301{
290- enum engine_id eng_id = ENGINE_ID_UNKNOWN ;
302+ enum engine_id eng_id = ENGINE_ID_UNKNOWN , eng_id_req = ENGINE_ID_UNKNOWN ;
291303 int i ;
292304 int j ;
293305
@@ -377,8 +389,15 @@ void link_enc_cfg_link_encs_assign(
377389 * assigned to that endpoint.
378390 */
379391 link_enc = get_link_enc_used_by_link (state , stream -> link );
380- if (link_enc == NULL )
381- eng_id = find_first_avail_link_enc (stream -> ctx , state );
392+ if (link_enc == NULL ) {
393+
394+ if (stream -> link -> ep_type == DISPLAY_ENDPOINT_USB4_DPIA &&
395+ stream -> link -> dpia_preferred_eng_id != ENGINE_ID_UNKNOWN )
396+ eng_id_req = stream -> link -> dpia_preferred_eng_id ;
397+
398+ if (eng_id == ENGINE_ID_UNKNOWN )
399+ eng_id = find_first_avail_link_enc (stream -> ctx , state , eng_id_req );
400+ }
382401 else
383402 eng_id = link_enc -> preferred_engine ;
384403
@@ -402,7 +421,9 @@ void link_enc_cfg_link_encs_assign(
402421 DC_LOG_DEBUG ("%s: CUR %s(%d) - enc_id(%d)\n" ,
403422 __func__ ,
404423 assignment .ep_id .ep_type == DISPLAY_ENDPOINT_PHY ? "PHY" : "DPIA" ,
405- assignment .ep_id .link_id .enum_id - 1 ,
424+ assignment .ep_id .ep_type == DISPLAY_ENDPOINT_PHY ?
425+ assignment .ep_id .link_id .enum_id :
426+ assignment .ep_id .link_id .enum_id - 1 ,
406427 assignment .eng_id );
407428 }
408429 for (i = 0 ; i < MAX_PIPES ; i ++ ) {
@@ -413,7 +434,9 @@ void link_enc_cfg_link_encs_assign(
413434 DC_LOG_DEBUG ("%s: NEW %s(%d) - enc_id(%d)\n" ,
414435 __func__ ,
415436 assignment .ep_id .ep_type == DISPLAY_ENDPOINT_PHY ? "PHY" : "DPIA" ,
416- assignment .ep_id .link_id .enum_id - 1 ,
437+ assignment .ep_id .ep_type == DISPLAY_ENDPOINT_PHY ?
438+ assignment .ep_id .link_id .enum_id :
439+ assignment .ep_id .link_id .enum_id - 1 ,
417440 assignment .eng_id );
418441 }
419442
0 commit comments