Skip to content

Commit dbbf57d

Browse files
committed
drm/msm/dpu: split dpu_plane_atomic_check()
Split dpu_plane_atomic_check() function into two pieces: dpu_plane_atomic_check_nosspp() performing generic checks on the pstate, without touching the associated SSPP blocks, and dpu_plane_atomic_check_sspp(), which takes into account used SSPPs. Signed-off-by: Dmitry Baryshkov <[email protected]> Reviewed-by: Abhinav Kumar <[email protected]> Patchwork: https://patchwork.freedesktop.org/patch/621484/ Link: https://lore.kernel.org/r/[email protected]
1 parent 8f15005 commit dbbf57d

File tree

1 file changed

+112
-66
lines changed

1 file changed

+112
-66
lines changed

drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c

Lines changed: 112 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -780,49 +780,22 @@ static int dpu_plane_atomic_check_pipe(struct dpu_plane *pdpu,
780780
#define MAX_UPSCALE_RATIO 20
781781
#define MAX_DOWNSCALE_RATIO 4
782782

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)
785786
{
786-
struct drm_plane_state *new_plane_state = drm_atomic_get_new_plane_state(state,
787-
plane);
788787
int i, ret = 0, min_scale, max_scale;
789788
struct dpu_plane *pdpu = to_dpu_plane(plane);
790789
struct dpu_kms *kms = _dpu_plane_get_kms(&pdpu->base);
791790
u64 max_mdp_clk_rate = kms->perf.max_core_clk_rate;
792791
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;
797792
struct dpu_sw_pipe_cfg *pipe_cfg = &pstate->pipe_cfg;
798793
struct dpu_sw_pipe_cfg *r_pipe_cfg = &pstate->r_pipe_cfg;
799794
struct drm_rect fb_rect = { 0 };
800795
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;
812796

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;
826799

827800
ret = drm_atomic_helper_check_plane_state(new_plane_state, crtc_state,
828801
min_scale,
@@ -835,11 +808,6 @@ static int dpu_plane_atomic_check(struct drm_plane *plane,
835808
if (!new_plane_state->visible)
836809
return 0;
837810

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-
843811
pstate->stage = DPU_STAGE_0 + pstate->base.normalized_zpos;
844812
if (pstate->stage >= pdpu->catalog->caps->max_mixer_blendstages) {
845813
DPU_ERROR("> %d plane stages assigned\n",
@@ -873,8 +841,6 @@ static int dpu_plane_atomic_check(struct drm_plane *plane,
873841
if (pstate->layout.plane_pitch[i] > DPU_SSPP_MAX_PITCH_SIZE)
874842
return -E2BIG;
875843

876-
fmt = msm_framebuffer_format(new_plane_state->fb);
877-
878844
max_linewidth = pdpu->catalog->caps->max_linewidth;
879845

880846
drm_rect_rotate(&pipe_cfg->src_rect,
@@ -883,6 +849,78 @@ static int dpu_plane_atomic_check(struct drm_plane *plane,
883849

884850
if ((drm_rect_width(&pipe_cfg->src_rect) > max_linewidth) ||
885851
_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) {
886924
/*
887925
* In parallel multirect case only the half of the usual width
888926
* 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,
896934
return -E2BIG;
897935
}
898936

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-
905937
if (drm_rect_width(&pipe_cfg->src_rect) != drm_rect_width(&pipe_cfg->dst_rect) ||
906938
drm_rect_height(&pipe_cfg->src_rect) != drm_rect_height(&pipe_cfg->dst_rect) ||
907939
(!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,
923955
r_pipe->multirect_index = DPU_SSPP_RECT_1;
924956
r_pipe->multirect_mode = DPU_SSPP_MULTIRECT_PARALLEL;
925957

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) {
946958
ret = dpu_plane_atomic_check_pipe(pdpu, r_pipe, r_pipe_cfg, fmt,
947959
&crtc_state->adjusted_mode);
948960
if (ret)
@@ -965,11 +977,45 @@ static int dpu_plane_atomic_check(struct drm_plane *plane,
965977
}
966978

967979
pstate->rotation = rotation;
968-
pstate->needs_qos_remap = drm_atomic_crtc_needs_modeset(crtc_state);
969980

970981
return 0;
971982
}
972983

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+
9731019
static void dpu_plane_flush_csc(struct dpu_plane *pdpu, struct dpu_sw_pipe *pipe)
9741020
{
9751021
const struct msm_format *format =

0 commit comments

Comments
 (0)