@@ -55,18 +55,20 @@ struct dc_pipe_mapping_scratch {
5555 struct dc_plane_pipe_pool pipe_pool ;
5656};
5757
58- static bool get_plane_id (const struct dc_state * state , const struct dc_plane_state * plane ,
59- unsigned int stream_id , unsigned int * plane_id )
58+ static bool get_plane_id (struct dml2_context * dml2 , const struct dc_state * state , const struct dc_plane_state * plane ,
59+ unsigned int stream_id , unsigned int plane_index , unsigned int * plane_id )
6060{
6161 int i , j ;
62+ bool is_plane_duplicate = dml2 -> v20 .scratch .plane_duplicate_exists ;
6263
6364 if (!plane_id )
6465 return false;
6566
6667 for (i = 0 ; i < state -> stream_count ; i ++ ) {
6768 if (state -> streams [i ]-> stream_id == stream_id ) {
6869 for (j = 0 ; j < state -> stream_status [i ].plane_count ; j ++ ) {
69- if (state -> stream_status [i ].plane_states [j ] == plane ) {
70+ if (state -> stream_status [i ].plane_states [j ] == plane &&
71+ (!is_plane_duplicate || (is_plane_duplicate && (j == plane_index )))) {
7072 * plane_id = (i << 16 ) | j ;
7173 return true;
7274 }
@@ -123,8 +125,9 @@ static struct pipe_ctx *find_master_pipe_of_plane(struct dml2_context *ctx,
123125 unsigned int plane_id_assigned_to_pipe ;
124126
125127 for (i = 0 ; i < ctx -> config .dcn_pipe_count ; i ++ ) {
126- if (state -> res_ctx .pipe_ctx [i ].plane_state && get_plane_id (state , state -> res_ctx .pipe_ctx [i ].plane_state ,
127- state -> res_ctx .pipe_ctx [i ].stream -> stream_id , & plane_id_assigned_to_pipe )) {
128+ if (state -> res_ctx .pipe_ctx [i ].plane_state && get_plane_id (ctx , state , state -> res_ctx .pipe_ctx [i ].plane_state ,
129+ state -> res_ctx .pipe_ctx [i ].stream -> stream_id ,
130+ ctx -> v20 .scratch .dml_to_dc_pipe_mapping .dml_pipe_idx_to_plane_index [state -> res_ctx .pipe_ctx [i ].pipe_idx ], & plane_id_assigned_to_pipe )) {
128131 if (plane_id_assigned_to_pipe == plane_id )
129132 return & state -> res_ctx .pipe_ctx [i ];
130133 }
@@ -141,8 +144,9 @@ static unsigned int find_pipes_assigned_to_plane(struct dml2_context *ctx,
141144 unsigned int plane_id_assigned_to_pipe ;
142145
143146 for (i = 0 ; i < ctx -> config .dcn_pipe_count ; i ++ ) {
144- if (state -> res_ctx .pipe_ctx [i ].plane_state && get_plane_id (state , state -> res_ctx .pipe_ctx [i ].plane_state ,
145- state -> res_ctx .pipe_ctx [i ].stream -> stream_id , & plane_id_assigned_to_pipe )) {
147+ if (state -> res_ctx .pipe_ctx [i ].plane_state && get_plane_id (ctx , state , state -> res_ctx .pipe_ctx [i ].plane_state ,
148+ state -> res_ctx .pipe_ctx [i ].stream -> stream_id ,
149+ ctx -> v20 .scratch .dml_to_dc_pipe_mapping .dml_pipe_idx_to_plane_index [state -> res_ctx .pipe_ctx [i ].pipe_idx ], & plane_id_assigned_to_pipe )) {
146150 if (plane_id_assigned_to_pipe == plane_id )
147151 pipes [num_found ++ ] = i ;
148152 }
@@ -609,6 +613,7 @@ static struct pipe_ctx *assign_pipes_to_plane(struct dml2_context *ctx, struct d
609613 const struct dc_plane_state * plane ,
610614 int odm_factor ,
611615 int mpc_factor ,
616+ int plane_index ,
612617 struct dc_plane_pipe_pool * pipe_pool ,
613618 const struct dc_state * existing_state )
614619{
@@ -620,7 +625,7 @@ static struct pipe_ctx *assign_pipes_to_plane(struct dml2_context *ctx, struct d
620625 unsigned int next_pipe_to_assign ;
621626 int odm_slice , mpc_slice ;
622627
623- if (!get_plane_id (state , plane , stream -> stream_id , & plane_id )) {
628+ if (!get_plane_id (ctx , state , plane , stream -> stream_id , plane_index , & plane_id )) {
624629 ASSERT (false);
625630 return master_pipe ;
626631 }
@@ -667,12 +672,16 @@ static void free_pipe(struct pipe_ctx *pipe)
667672}
668673
669674static void free_unused_pipes_for_plane (struct dml2_context * ctx , struct dc_state * state ,
670- const struct dc_plane_state * plane , const struct dc_plane_pipe_pool * pool , unsigned int stream_id )
675+ const struct dc_plane_state * plane , const struct dc_plane_pipe_pool * pool , unsigned int stream_id , int plane_index )
671676{
672677 int i ;
678+ bool is_plane_duplicate = ctx -> v20 .scratch .plane_duplicate_exists ;
679+
673680 for (i = 0 ; i < ctx -> config .dcn_pipe_count ; i ++ ) {
674681 if (state -> res_ctx .pipe_ctx [i ].plane_state == plane &&
675682 state -> res_ctx .pipe_ctx [i ].stream -> stream_id == stream_id &&
683+ (!is_plane_duplicate || (is_plane_duplicate &&
684+ ctx -> v20 .scratch .dml_to_dc_pipe_mapping .dml_pipe_idx_to_plane_index [state -> res_ctx .pipe_ctx [i ].pipe_idx ] == plane_index )) &&
676685 !is_pipe_used (pool , state -> res_ctx .pipe_ctx [i ].pipe_idx )) {
677686 free_pipe (& state -> res_ctx .pipe_ctx [i ]);
678687 }
@@ -717,19 +726,20 @@ static void map_pipes_for_stream(struct dml2_context *ctx, struct dc_state *stat
717726}
718727
719728static void map_pipes_for_plane (struct dml2_context * ctx , struct dc_state * state , const struct dc_stream_state * stream , const struct dc_plane_state * plane ,
720- struct dc_pipe_mapping_scratch * scratch , const struct dc_state * existing_state )
729+ int plane_index , struct dc_pipe_mapping_scratch * scratch , const struct dc_state * existing_state )
721730{
722731 int odm_slice_index ;
723732 unsigned int plane_id ;
724733 struct pipe_ctx * master_pipe = NULL ;
725734 int i ;
726735
727- if (!get_plane_id (state , plane , stream -> stream_id , & plane_id )) {
736+ if (!get_plane_id (ctx , state , plane , stream -> stream_id , plane_index , & plane_id )) {
728737 ASSERT (false);
729738 return ;
730739 }
731740
732- master_pipe = assign_pipes_to_plane (ctx , state , stream , plane , scratch -> odm_info .odm_factor , scratch -> mpc_info .mpc_factor , & scratch -> pipe_pool , existing_state );
741+ master_pipe = assign_pipes_to_plane (ctx , state , stream , plane , scratch -> odm_info .odm_factor ,
742+ scratch -> mpc_info .mpc_factor , plane_index , & scratch -> pipe_pool , existing_state );
733743 sort_pipes_for_splitting (& scratch -> pipe_pool );
734744
735745 for (odm_slice_index = 0 ; odm_slice_index < scratch -> odm_info .odm_factor ; odm_slice_index ++ ) {
@@ -755,7 +765,7 @@ static void map_pipes_for_plane(struct dml2_context *ctx, struct dc_state *state
755765 }
756766 }
757767
758- free_unused_pipes_for_plane (ctx , state , plane , & scratch -> pipe_pool , stream -> stream_id );
768+ free_unused_pipes_for_plane (ctx , state , plane , & scratch -> pipe_pool , stream -> stream_id , plane_index );
759769}
760770
761771static unsigned int get_mpc_factor (struct dml2_context * ctx ,
@@ -768,7 +778,7 @@ static unsigned int get_mpc_factor(struct dml2_context *ctx,
768778 unsigned int plane_id ;
769779 unsigned int cfg_idx ;
770780
771- get_plane_id (state , status -> plane_states [plane_idx ], stream_id , & plane_id );
781+ get_plane_id (ctx , state , status -> plane_states [plane_idx ], stream_id , plane_idx , & plane_id );
772782 cfg_idx = find_disp_cfg_idx_by_plane_id (mapping , plane_id );
773783 if (ctx -> architecture == dml2_architecture_20 )
774784 return (unsigned int )disp_cfg -> hw .DPPPerSurface [cfg_idx ];
@@ -946,8 +956,8 @@ bool dml2_map_dc_pipes(struct dml2_context *ctx, struct dc_state *state, const s
946956
947957 for (plane_index = 0 ; plane_index < state -> stream_status [stream_index ].plane_count ; plane_index ++ ) {
948958 // Planes are ordered top to bottom.
949- if (get_plane_id (state , state -> stream_status [stream_index ].plane_states [plane_index ],
950- stream_id , & plane_id )) {
959+ if (get_plane_id (ctx , state , state -> stream_status [stream_index ].plane_states [plane_index ],
960+ stream_id , plane_index , & plane_id )) {
951961 plane_disp_cfg_index = find_disp_cfg_idx_by_plane_id (mapping , plane_id );
952962
953963 // Setup mpc_info for this plane
@@ -971,7 +981,8 @@ bool dml2_map_dc_pipes(struct dml2_context *ctx, struct dc_state *state, const s
971981 // Clear the pool assignment scratch (which is per plane)
972982 memset (& scratch .pipe_pool , 0 , sizeof (struct dc_plane_pipe_pool ));
973983
974- map_pipes_for_plane (ctx , state , state -> streams [stream_index ], state -> stream_status [stream_index ].plane_states [plane_index ], & scratch , existing_state );
984+ map_pipes_for_plane (ctx , state , state -> streams [stream_index ],
985+ state -> stream_status [stream_index ].plane_states [plane_index ], plane_index , & scratch , existing_state );
975986 } else {
976987 // Plane ID cannot be generated, therefore no DML mapping can be performed.
977988 ASSERT (false);
0 commit comments