@@ -826,12 +826,8 @@ static int dpu_plane_atomic_check_nosspp(struct drm_plane *plane,
826826 struct dpu_plane_state * pstate = to_dpu_plane_state (new_plane_state );
827827 struct dpu_sw_pipe_cfg * pipe_cfg ;
828828 struct dpu_sw_pipe_cfg * r_pipe_cfg ;
829- struct dpu_sw_pipe_cfg init_pipe_cfg ;
830829 struct drm_rect fb_rect = { 0 };
831- const struct drm_display_mode * mode = & crtc_state -> adjusted_mode ;
832830 uint32_t max_linewidth ;
833- u32 num_lm ;
834- int stage_id , num_stages ;
835831
836832 min_scale = FRAC_16_16 (1 , MAX_UPSCALE_RATIO );
837833 max_scale = MAX_DOWNSCALE_RATIO << 16 ;
@@ -854,10 +850,13 @@ static int dpu_plane_atomic_check_nosspp(struct drm_plane *plane,
854850 return - EINVAL ;
855851 }
856852
857- num_lm = dpu_crtc_get_num_lm (crtc_state );
858-
853+ /* move the assignment here, to ease handling to another pairs later */
854+ pipe_cfg = & pstate -> pipe_cfg [0 ];
855+ r_pipe_cfg = & pstate -> pipe_cfg [1 ];
859856 /* state->src is 16.16, src_rect is not */
860- drm_rect_fp_to_int (& init_pipe_cfg .src_rect , & new_plane_state -> src );
857+ drm_rect_fp_to_int (& pipe_cfg -> src_rect , & new_plane_state -> src );
858+
859+ pipe_cfg -> dst_rect = new_plane_state -> dst ;
861860
862861 fb_rect .x2 = new_plane_state -> fb -> width ;
863862 fb_rect .y2 = new_plane_state -> fb -> height ;
@@ -882,94 +881,35 @@ static int dpu_plane_atomic_check_nosspp(struct drm_plane *plane,
882881
883882 max_linewidth = pdpu -> catalog -> caps -> max_linewidth ;
884883
885- drm_rect_rotate (& init_pipe_cfg . src_rect ,
884+ drm_rect_rotate (& pipe_cfg -> src_rect ,
886885 new_plane_state -> fb -> width , new_plane_state -> fb -> height ,
887886 new_plane_state -> rotation );
888887
889- /*
890- * We have 1 mixer pair cfg for 1:1:1 and 2:2:1 topology, 2 mixer pair
891- * configs for left and right half screen in case of 4:4:2 topology.
892- * But we may have 2 rect to split wide plane that exceeds limit with 1
893- * config for 2:2:1. So need to handle both wide plane splitting, and
894- * two halves of screen splitting for quad-pipe case. Check dest
895- * rectangle left/right clipping first, then check wide rectangle
896- * splitting in every half next.
897- */
898- num_stages = (num_lm + 1 ) / 2 ;
899- /* iterate mixer configs for this plane, to separate left/right with the id */
900- for (stage_id = 0 ; stage_id < num_stages ; stage_id ++ ) {
901- struct drm_rect mixer_rect = {
902- .x1 = stage_id * mode -> hdisplay / num_stages ,
903- .y1 = 0 ,
904- .x2 = (stage_id + 1 ) * mode -> hdisplay / num_stages ,
905- .y2 = mode -> vdisplay
906- };
907- int cfg_idx = stage_id * PIPES_PER_STAGE ;
908-
909- pipe_cfg = & pstate -> pipe_cfg [cfg_idx ];
910- r_pipe_cfg = & pstate -> pipe_cfg [cfg_idx + 1 ];
911-
912- drm_rect_fp_to_int (& pipe_cfg -> src_rect , & new_plane_state -> src );
913- pipe_cfg -> dst_rect = new_plane_state -> dst ;
914-
915- DPU_DEBUG_PLANE (pdpu , "checking src " DRM_RECT_FMT
916- " vs clip window " DRM_RECT_FMT "\n" ,
917- DRM_RECT_ARG (& pipe_cfg -> src_rect ),
918- DRM_RECT_ARG (& mixer_rect ));
919-
920- /*
921- * If this plane does not fall into mixer rect, check next
922- * mixer rect.
923- */
924- if (!drm_rect_clip_scaled (& pipe_cfg -> src_rect ,
925- & pipe_cfg -> dst_rect ,
926- & mixer_rect )) {
927- memset (pipe_cfg , 0 , 2 * sizeof (struct dpu_sw_pipe_cfg ));
928-
929- continue ;
888+ if ((drm_rect_width (& pipe_cfg -> src_rect ) > max_linewidth ) ||
889+ _dpu_plane_calc_clk (& crtc_state -> adjusted_mode , pipe_cfg ) > max_mdp_clk_rate ) {
890+ if (drm_rect_width (& pipe_cfg -> src_rect ) > 2 * max_linewidth ) {
891+ DPU_DEBUG_PLANE (pdpu , "invalid src " DRM_RECT_FMT " line:%u\n" ,
892+ DRM_RECT_ARG (& pipe_cfg -> src_rect ), max_linewidth );
893+ return - E2BIG ;
930894 }
931895
932- pipe_cfg -> dst_rect .x1 -= mixer_rect .x1 ;
933- pipe_cfg -> dst_rect .x2 -= mixer_rect .x1 ;
934-
935- DPU_DEBUG_PLANE (pdpu , "Got clip src:" DRM_RECT_FMT " dst: " DRM_RECT_FMT "\n" ,
936- DRM_RECT_ARG (& pipe_cfg -> src_rect ), DRM_RECT_ARG (& pipe_cfg -> dst_rect ));
937-
938- /* Split wide rect into 2 rect */
939- if ((drm_rect_width (& pipe_cfg -> src_rect ) > max_linewidth ) ||
940- _dpu_plane_calc_clk (mode , pipe_cfg ) > max_mdp_clk_rate ) {
941-
942- if (drm_rect_width (& pipe_cfg -> src_rect ) > 2 * max_linewidth ) {
943- DPU_DEBUG_PLANE (pdpu , "invalid src " DRM_RECT_FMT " line:%u\n" ,
944- DRM_RECT_ARG (& pipe_cfg -> src_rect ), max_linewidth );
945- return - E2BIG ;
946- }
947-
948- memcpy (r_pipe_cfg , pipe_cfg , sizeof (struct dpu_sw_pipe_cfg ));
949- pipe_cfg -> src_rect .x2 = (pipe_cfg -> src_rect .x1 + pipe_cfg -> src_rect .x2 ) >> 1 ;
950- pipe_cfg -> dst_rect .x2 = (pipe_cfg -> dst_rect .x1 + pipe_cfg -> dst_rect .x2 ) >> 1 ;
951- r_pipe_cfg -> src_rect .x1 = pipe_cfg -> src_rect .x2 ;
952- r_pipe_cfg -> dst_rect .x1 = pipe_cfg -> dst_rect .x2 ;
953- DPU_DEBUG_PLANE (pdpu , "Split wide plane into:"
954- DRM_RECT_FMT " and " DRM_RECT_FMT "\n" ,
955- DRM_RECT_ARG (& pipe_cfg -> src_rect ),
956- DRM_RECT_ARG (& r_pipe_cfg -> src_rect ));
957- } else {
958- memset (r_pipe_cfg , 0 , sizeof (struct dpu_sw_pipe_cfg ));
959- }
896+ * r_pipe_cfg = * pipe_cfg ;
897+ pipe_cfg -> src_rect .x2 = (pipe_cfg -> src_rect .x1 + pipe_cfg -> src_rect .x2 ) >> 1 ;
898+ pipe_cfg -> dst_rect .x2 = (pipe_cfg -> dst_rect .x1 + pipe_cfg -> dst_rect .x2 ) >> 1 ;
899+ r_pipe_cfg -> src_rect .x1 = pipe_cfg -> src_rect .x2 ;
900+ r_pipe_cfg -> dst_rect .x1 = pipe_cfg -> dst_rect .x2 ;
901+ } else {
902+ memset (r_pipe_cfg , 0 , sizeof (* r_pipe_cfg ));
903+ }
960904
961- drm_rect_rotate_inv (& pipe_cfg -> src_rect ,
962- new_plane_state -> fb -> width ,
963- new_plane_state -> fb -> height ,
905+ drm_rect_rotate_inv (& pipe_cfg -> src_rect ,
906+ new_plane_state -> fb -> width , new_plane_state -> fb -> height ,
907+ new_plane_state -> rotation );
908+ if (drm_rect_width (& r_pipe_cfg -> src_rect ) != 0 )
909+ drm_rect_rotate_inv (& r_pipe_cfg -> src_rect ,
910+ new_plane_state -> fb -> width , new_plane_state -> fb -> height ,
964911 new_plane_state -> rotation );
965912
966- if (drm_rect_width (& r_pipe_cfg -> src_rect ) != 0 )
967- drm_rect_rotate_inv (& r_pipe_cfg -> src_rect ,
968- new_plane_state -> fb -> width ,
969- new_plane_state -> fb -> height ,
970- new_plane_state -> rotation );
971- }
972-
973913 pstate -> needs_qos_remap = drm_atomic_crtc_needs_modeset (crtc_state );
974914
975915 return 0 ;
@@ -1045,17 +985,20 @@ static int dpu_plane_atomic_check_sspp(struct drm_plane *plane,
1045985 drm_atomic_get_new_plane_state (state , plane );
1046986 struct dpu_plane * pdpu = to_dpu_plane (plane );
1047987 struct dpu_plane_state * pstate = to_dpu_plane_state (new_plane_state );
1048- struct dpu_sw_pipe * pipe ;
1049- struct dpu_sw_pipe_cfg * pipe_cfg ;
1050- int ret = 0 , i ;
988+ struct dpu_sw_pipe * pipe = & pstate -> pipe [0 ];
989+ struct dpu_sw_pipe * r_pipe = & pstate -> pipe [1 ];
990+ struct dpu_sw_pipe_cfg * pipe_cfg = & pstate -> pipe_cfg [0 ];
991+ struct dpu_sw_pipe_cfg * r_pipe_cfg = & pstate -> pipe_cfg [1 ];
992+ int ret = 0 ;
1051993
1052- for (i = 0 ; i < PIPES_PER_PLANE ; i ++ ) {
1053- pipe = & pstate -> pipe [i ];
1054- pipe_cfg = & pstate -> pipe_cfg [i ];
1055- if (!drm_rect_width (& pipe_cfg -> src_rect ))
1056- continue ;
1057- DPU_DEBUG_PLANE (pdpu , "pipe %d is in use, validate it\n" , i );
1058- ret = dpu_plane_atomic_check_pipe (pdpu , pipe , pipe_cfg ,
994+ ret = dpu_plane_atomic_check_pipe (pdpu , pipe , pipe_cfg ,
995+ & crtc_state -> adjusted_mode ,
996+ new_plane_state );
997+ if (ret )
998+ return ret ;
999+
1000+ if (drm_rect_width (& r_pipe_cfg -> src_rect ) != 0 ) {
1001+ ret = dpu_plane_atomic_check_pipe (pdpu , r_pipe , r_pipe_cfg ,
10591002 & crtc_state -> adjusted_mode ,
10601003 new_plane_state );
10611004 if (ret )
0 commit comments