@@ -780,49 +780,22 @@ static int dpu_plane_atomic_check_pipe(struct dpu_plane *pdpu,
780
780
#define MAX_UPSCALE_RATIO 20
781
781
#define MAX_DOWNSCALE_RATIO 4
782
782
783
- static int dpu_plane_atomic_check (struct drm_plane * plane ,
784
- struct drm_atomic_state * state )
783
+ static int dpu_plane_atomic_check_nosspp (struct drm_plane * plane ,
784
+ struct drm_plane_state * new_plane_state ,
785
+ const struct drm_crtc_state * crtc_state )
785
786
{
786
- struct drm_plane_state * new_plane_state = drm_atomic_get_new_plane_state (state ,
787
- plane );
788
787
int i , ret = 0 , min_scale , max_scale ;
789
788
struct dpu_plane * pdpu = to_dpu_plane (plane );
790
789
struct dpu_kms * kms = _dpu_plane_get_kms (& pdpu -> base );
791
790
u64 max_mdp_clk_rate = kms -> perf .max_core_clk_rate ;
792
791
struct dpu_plane_state * pstate = to_dpu_plane_state (new_plane_state );
793
- struct dpu_sw_pipe * pipe = & pstate -> pipe ;
794
- struct dpu_sw_pipe * r_pipe = & pstate -> r_pipe ;
795
- const struct drm_crtc_state * crtc_state = NULL ;
796
- const struct msm_format * fmt ;
797
792
struct dpu_sw_pipe_cfg * pipe_cfg = & pstate -> pipe_cfg ;
798
793
struct dpu_sw_pipe_cfg * r_pipe_cfg = & pstate -> r_pipe_cfg ;
799
794
struct drm_rect fb_rect = { 0 };
800
795
uint32_t max_linewidth ;
801
- unsigned int rotation ;
802
- uint32_t supported_rotations ;
803
- const struct dpu_sspp_cfg * pipe_hw_caps ;
804
- const struct dpu_sspp_sub_blks * sblk ;
805
-
806
- if (new_plane_state -> crtc )
807
- crtc_state = drm_atomic_get_new_crtc_state (state ,
808
- new_plane_state -> crtc );
809
-
810
- pipe -> sspp = dpu_rm_get_sspp (& kms -> rm , pdpu -> pipe );
811
- r_pipe -> sspp = NULL ;
812
796
813
- if (!pipe -> sspp )
814
- return - EINVAL ;
815
-
816
- pipe_hw_caps = pipe -> sspp -> cap ;
817
- sblk = pipe -> sspp -> cap -> sblk ;
818
-
819
- if (sblk -> scaler_blk .len ) {
820
- min_scale = FRAC_16_16 (1 , MAX_UPSCALE_RATIO );
821
- max_scale = MAX_DOWNSCALE_RATIO << 16 ;
822
- } else {
823
- min_scale = DRM_PLANE_NO_SCALING ;
824
- max_scale = DRM_PLANE_NO_SCALING ;
825
- }
797
+ min_scale = FRAC_16_16 (1 , MAX_UPSCALE_RATIO );
798
+ max_scale = MAX_DOWNSCALE_RATIO << 16 ;
826
799
827
800
ret = drm_atomic_helper_check_plane_state (new_plane_state , crtc_state ,
828
801
min_scale ,
@@ -835,11 +808,6 @@ static int dpu_plane_atomic_check(struct drm_plane *plane,
835
808
if (!new_plane_state -> visible )
836
809
return 0 ;
837
810
838
- pipe -> multirect_index = DPU_SSPP_RECT_SOLO ;
839
- pipe -> multirect_mode = DPU_SSPP_MULTIRECT_NONE ;
840
- r_pipe -> multirect_index = DPU_SSPP_RECT_SOLO ;
841
- r_pipe -> multirect_mode = DPU_SSPP_MULTIRECT_NONE ;
842
-
843
811
pstate -> stage = DPU_STAGE_0 + pstate -> base .normalized_zpos ;
844
812
if (pstate -> stage >= pdpu -> catalog -> caps -> max_mixer_blendstages ) {
845
813
DPU_ERROR ("> %d plane stages assigned\n" ,
@@ -873,8 +841,6 @@ static int dpu_plane_atomic_check(struct drm_plane *plane,
873
841
if (pstate -> layout .plane_pitch [i ] > DPU_SSPP_MAX_PITCH_SIZE )
874
842
return - E2BIG ;
875
843
876
- fmt = msm_framebuffer_format (new_plane_state -> fb );
877
-
878
844
max_linewidth = pdpu -> catalog -> caps -> max_linewidth ;
879
845
880
846
drm_rect_rotate (& pipe_cfg -> src_rect ,
@@ -883,6 +849,78 @@ static int dpu_plane_atomic_check(struct drm_plane *plane,
883
849
884
850
if ((drm_rect_width (& pipe_cfg -> src_rect ) > max_linewidth ) ||
885
851
_dpu_plane_calc_clk (& crtc_state -> adjusted_mode , pipe_cfg ) > max_mdp_clk_rate ) {
852
+ if (drm_rect_width (& pipe_cfg -> src_rect ) > 2 * max_linewidth ) {
853
+ DPU_DEBUG_PLANE (pdpu , "invalid src " DRM_RECT_FMT " line:%u\n" ,
854
+ DRM_RECT_ARG (& pipe_cfg -> src_rect ), max_linewidth );
855
+ return - E2BIG ;
856
+ }
857
+
858
+ * r_pipe_cfg = * pipe_cfg ;
859
+ pipe_cfg -> src_rect .x2 = (pipe_cfg -> src_rect .x1 + pipe_cfg -> src_rect .x2 ) >> 1 ;
860
+ pipe_cfg -> dst_rect .x2 = (pipe_cfg -> dst_rect .x1 + pipe_cfg -> dst_rect .x2 ) >> 1 ;
861
+ r_pipe_cfg -> src_rect .x1 = pipe_cfg -> src_rect .x2 ;
862
+ r_pipe_cfg -> dst_rect .x1 = pipe_cfg -> dst_rect .x2 ;
863
+ } else {
864
+ memset (r_pipe_cfg , 0 , sizeof (* r_pipe_cfg ));
865
+ }
866
+
867
+ drm_rect_rotate_inv (& pipe_cfg -> src_rect ,
868
+ new_plane_state -> fb -> width , new_plane_state -> fb -> height ,
869
+ new_plane_state -> rotation );
870
+ if (r_pipe_cfg -> src_rect .x1 != 0 )
871
+ drm_rect_rotate_inv (& r_pipe_cfg -> src_rect ,
872
+ new_plane_state -> fb -> width , new_plane_state -> fb -> height ,
873
+ new_plane_state -> rotation );
874
+
875
+ pstate -> needs_qos_remap = drm_atomic_crtc_needs_modeset (crtc_state );
876
+
877
+ return 0 ;
878
+ }
879
+
880
+ static int dpu_plane_atomic_check_sspp (struct drm_plane * plane ,
881
+ struct drm_atomic_state * state ,
882
+ const struct drm_crtc_state * crtc_state )
883
+ {
884
+ struct drm_plane_state * new_plane_state =
885
+ drm_atomic_get_new_plane_state (state , plane );
886
+ struct dpu_plane * pdpu = to_dpu_plane (plane );
887
+ struct dpu_plane_state * pstate = to_dpu_plane_state (new_plane_state );
888
+ struct dpu_sw_pipe * pipe = & pstate -> pipe ;
889
+ struct dpu_sw_pipe * r_pipe = & pstate -> r_pipe ;
890
+ const struct msm_format * fmt ;
891
+ struct dpu_sw_pipe_cfg * pipe_cfg = & pstate -> pipe_cfg ;
892
+ struct dpu_sw_pipe_cfg * r_pipe_cfg = & pstate -> r_pipe_cfg ;
893
+ uint32_t max_linewidth ;
894
+ unsigned int rotation ;
895
+ uint32_t supported_rotations ;
896
+ const struct dpu_sspp_cfg * pipe_hw_caps ;
897
+ const struct dpu_sspp_sub_blks * sblk ;
898
+ int ret = 0 ;
899
+
900
+ pipe_hw_caps = pipe -> sspp -> cap ;
901
+ sblk = pipe -> sspp -> cap -> sblk ;
902
+
903
+ /*
904
+ * We already have verified scaling against platform limitations.
905
+ * Now check if the SSPP supports scaling at all.
906
+ */
907
+ if (!sblk -> scaler_blk .len &&
908
+ ((drm_rect_width (& new_plane_state -> src ) >> 16 !=
909
+ drm_rect_width (& new_plane_state -> dst )) ||
910
+ (drm_rect_height (& new_plane_state -> src ) >> 16 !=
911
+ drm_rect_height (& new_plane_state -> dst ))))
912
+ return - ERANGE ;
913
+
914
+ fmt = msm_framebuffer_format (new_plane_state -> fb );
915
+
916
+ max_linewidth = pdpu -> catalog -> caps -> max_linewidth ;
917
+
918
+ ret = dpu_plane_atomic_check_pipe (pdpu , pipe , pipe_cfg , fmt ,
919
+ & crtc_state -> adjusted_mode );
920
+ if (ret )
921
+ return ret ;
922
+
923
+ if (drm_rect_width (& r_pipe_cfg -> src_rect ) != 0 ) {
886
924
/*
887
925
* In parallel multirect case only the half of the usual width
888
926
* is supported for tiled formats. If we are here, we know that
@@ -896,12 +934,6 @@ static int dpu_plane_atomic_check(struct drm_plane *plane,
896
934
return - E2BIG ;
897
935
}
898
936
899
- if (drm_rect_width (& pipe_cfg -> src_rect ) > 2 * max_linewidth ) {
900
- DPU_DEBUG_PLANE (pdpu , "invalid src " DRM_RECT_FMT " line:%u\n" ,
901
- DRM_RECT_ARG (& pipe_cfg -> src_rect ), max_linewidth );
902
- return - E2BIG ;
903
- }
904
-
905
937
if (drm_rect_width (& pipe_cfg -> src_rect ) != drm_rect_width (& pipe_cfg -> dst_rect ) ||
906
938
drm_rect_height (& pipe_cfg -> src_rect ) != drm_rect_height (& pipe_cfg -> dst_rect ) ||
907
939
(!test_bit (DPU_SSPP_SMART_DMA_V1 , & pipe -> sspp -> cap -> features ) &&
@@ -923,26 +955,6 @@ static int dpu_plane_atomic_check(struct drm_plane *plane,
923
955
r_pipe -> multirect_index = DPU_SSPP_RECT_1 ;
924
956
r_pipe -> multirect_mode = DPU_SSPP_MULTIRECT_PARALLEL ;
925
957
926
- * r_pipe_cfg = * pipe_cfg ;
927
- pipe_cfg -> src_rect .x2 = (pipe_cfg -> src_rect .x1 + pipe_cfg -> src_rect .x2 ) >> 1 ;
928
- pipe_cfg -> dst_rect .x2 = (pipe_cfg -> dst_rect .x1 + pipe_cfg -> dst_rect .x2 ) >> 1 ;
929
- r_pipe_cfg -> src_rect .x1 = pipe_cfg -> src_rect .x2 ;
930
- r_pipe_cfg -> dst_rect .x1 = pipe_cfg -> dst_rect .x2 ;
931
- }
932
-
933
- drm_rect_rotate_inv (& pipe_cfg -> src_rect ,
934
- new_plane_state -> fb -> width , new_plane_state -> fb -> height ,
935
- new_plane_state -> rotation );
936
- if (r_pipe -> sspp )
937
- drm_rect_rotate_inv (& r_pipe_cfg -> src_rect ,
938
- new_plane_state -> fb -> width , new_plane_state -> fb -> height ,
939
- new_plane_state -> rotation );
940
-
941
- ret = dpu_plane_atomic_check_pipe (pdpu , pipe , pipe_cfg , fmt , & crtc_state -> adjusted_mode );
942
- if (ret )
943
- return ret ;
944
-
945
- if (r_pipe -> sspp ) {
946
958
ret = dpu_plane_atomic_check_pipe (pdpu , r_pipe , r_pipe_cfg , fmt ,
947
959
& crtc_state -> adjusted_mode );
948
960
if (ret )
@@ -965,11 +977,45 @@ static int dpu_plane_atomic_check(struct drm_plane *plane,
965
977
}
966
978
967
979
pstate -> rotation = rotation ;
968
- pstate -> needs_qos_remap = drm_atomic_crtc_needs_modeset (crtc_state );
969
980
970
981
return 0 ;
971
982
}
972
983
984
+ static int dpu_plane_atomic_check (struct drm_plane * plane ,
985
+ struct drm_atomic_state * state )
986
+ {
987
+ struct drm_plane_state * new_plane_state = drm_atomic_get_new_plane_state (state ,
988
+ plane );
989
+ int ret = 0 ;
990
+ struct dpu_plane * pdpu = to_dpu_plane (plane );
991
+ struct dpu_plane_state * pstate = to_dpu_plane_state (new_plane_state );
992
+ struct dpu_kms * dpu_kms = _dpu_plane_get_kms (plane );
993
+ struct dpu_sw_pipe * pipe = & pstate -> pipe ;
994
+ struct dpu_sw_pipe * r_pipe = & pstate -> r_pipe ;
995
+ const struct drm_crtc_state * crtc_state = NULL ;
996
+
997
+ if (new_plane_state -> crtc )
998
+ crtc_state = drm_atomic_get_new_crtc_state (state ,
999
+ new_plane_state -> crtc );
1000
+
1001
+ pipe -> sspp = dpu_rm_get_sspp (& dpu_kms -> rm , pdpu -> pipe );
1002
+ r_pipe -> sspp = NULL ;
1003
+
1004
+ ret = dpu_plane_atomic_check_nosspp (plane , new_plane_state , crtc_state );
1005
+ if (ret )
1006
+ return ret ;
1007
+
1008
+ if (!new_plane_state -> visible )
1009
+ return 0 ;
1010
+
1011
+ pipe -> multirect_index = DPU_SSPP_RECT_SOLO ;
1012
+ pipe -> multirect_mode = DPU_SSPP_MULTIRECT_NONE ;
1013
+ r_pipe -> multirect_index = DPU_SSPP_RECT_SOLO ;
1014
+ r_pipe -> multirect_mode = DPU_SSPP_MULTIRECT_NONE ;
1015
+
1016
+ return dpu_plane_atomic_check_sspp (plane , state , crtc_state );
1017
+ }
1018
+
973
1019
static void dpu_plane_flush_csc (struct dpu_plane * pdpu , struct dpu_sw_pipe * pipe )
974
1020
{
975
1021
const struct msm_format * format =
0 commit comments