Skip to content

Commit aa649e8

Browse files
boddobrobclark
authored andcommitted
drm/msm/mdp5: mdp5_crtc: Restore cursor state only if LM cursors are enabled
MDP5 on newer SoCs support cursor planes (i.e, cursor SSPPs). They are a separate entity unlike the cursors within LM. Do not try to restore the MDP5 LM cursor registers, or the corresponding CTL bits if we are not using LM cursors. Also, since we've introduced a new variable 'lm_cursor_enabled', we can now use it to avoid creating a different sets of crtc_funcs for CRTCs with LM cursors and CRTCs with cursor planes. Fixes: "drm/msm/mdp5: restore cursor state when enabling crtc" Signed-off-by: Archit Taneja <[email protected]> Signed-off-by: Rob Clark <[email protected]>
1 parent b148928 commit aa649e8

File tree

1 file changed

+37
-29
lines changed

1 file changed

+37
-29
lines changed

drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c

+37-29
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ struct mdp5_crtc {
5555

5656
struct completion pp_completion;
5757

58+
bool lm_cursor_enabled;
59+
5860
struct {
5961
/* protect REG_MDP5_LM_CURSOR* registers and cursor scanout_bo*/
6062
spinlock_t lock;
@@ -457,19 +459,24 @@ static void mdp5_crtc_atomic_enable(struct drm_crtc *crtc,
457459

458460
pm_runtime_get_sync(dev);
459461

460-
/* Restore cursor state, as it might have been lost with suspend: */
461-
if (mdp5_crtc->cursor.iova) {
462-
unsigned long flags;
463-
464-
spin_lock_irqsave(&mdp5_crtc->cursor.lock, flags);
465-
mdp5_crtc_restore_cursor(crtc);
466-
spin_unlock_irqrestore(&mdp5_crtc->cursor.lock, flags);
467-
468-
mdp5_ctl_set_cursor(mdp5_cstate->ctl,
469-
&mdp5_cstate->pipeline, 0, true);
470-
} else {
471-
mdp5_ctl_set_cursor(mdp5_cstate->ctl,
472-
&mdp5_cstate->pipeline, 0, false);
462+
if (mdp5_crtc->lm_cursor_enabled) {
463+
/*
464+
* Restore LM cursor state, as it might have been lost
465+
* with suspend:
466+
*/
467+
if (mdp5_crtc->cursor.iova) {
468+
unsigned long flags;
469+
470+
spin_lock_irqsave(&mdp5_crtc->cursor.lock, flags);
471+
mdp5_crtc_restore_cursor(crtc);
472+
spin_unlock_irqrestore(&mdp5_crtc->cursor.lock, flags);
473+
474+
mdp5_ctl_set_cursor(mdp5_cstate->ctl,
475+
&mdp5_cstate->pipeline, 0, true);
476+
} else {
477+
mdp5_ctl_set_cursor(mdp5_cstate->ctl,
478+
&mdp5_cstate->pipeline, 0, false);
479+
}
473480
}
474481

475482
/* Restore vblank irq handling after power is enabled */
@@ -817,6 +824,12 @@ static int mdp5_crtc_cursor_set(struct drm_crtc *crtc,
817824
bool cursor_enable = true;
818825
unsigned long flags;
819826

827+
if (!mdp5_crtc->lm_cursor_enabled) {
828+
dev_warn(dev->dev,
829+
"cursor_set is deprecated with cursor planes\n");
830+
return -EINVAL;
831+
}
832+
820833
if ((width > CURSOR_WIDTH) || (height > CURSOR_HEIGHT)) {
821834
dev_err(dev->dev, "bad cursor size: %dx%d\n", width, height);
822835
return -EINVAL;
@@ -888,10 +901,17 @@ static int mdp5_crtc_cursor_move(struct drm_crtc *crtc, int x, int y)
888901
struct mdp5_crtc *mdp5_crtc = to_mdp5_crtc(crtc);
889902
struct mdp5_crtc_state *mdp5_cstate = to_mdp5_crtc_state(crtc->state);
890903
uint32_t flush_mask = mdp_ctl_flush_mask_cursor(0);
904+
struct drm_device *dev = crtc->dev;
891905
uint32_t roi_w;
892906
uint32_t roi_h;
893907
unsigned long flags;
894908

909+
if (!mdp5_crtc->lm_cursor_enabled) {
910+
dev_warn(dev->dev,
911+
"cursor_move is deprecated with cursor planes\n");
912+
return -EINVAL;
913+
}
914+
895915
/* don't support LM cursors when we we have source split enabled */
896916
if (mdp5_cstate->pipeline.r_mixer)
897917
return -EINVAL;
@@ -993,16 +1013,6 @@ static const struct drm_crtc_funcs mdp5_crtc_funcs = {
9931013
.atomic_print_state = mdp5_crtc_atomic_print_state,
9941014
};
9951015

996-
static const struct drm_crtc_funcs mdp5_crtc_no_lm_cursor_funcs = {
997-
.set_config = drm_atomic_helper_set_config,
998-
.destroy = mdp5_crtc_destroy,
999-
.page_flip = drm_atomic_helper_page_flip,
1000-
.reset = mdp5_crtc_reset,
1001-
.atomic_duplicate_state = mdp5_crtc_duplicate_state,
1002-
.atomic_destroy_state = mdp5_crtc_destroy_state,
1003-
.atomic_print_state = mdp5_crtc_atomic_print_state,
1004-
};
1005-
10061016
static const struct drm_crtc_helper_funcs mdp5_crtc_helper_funcs = {
10071017
.mode_set_nofb = mdp5_crtc_mode_set_nofb,
10081018
.atomic_check = mdp5_crtc_atomic_check,
@@ -1171,12 +1181,10 @@ struct drm_crtc *mdp5_crtc_init(struct drm_device *dev,
11711181
mdp5_crtc->err.irq = mdp5_crtc_err_irq;
11721182
mdp5_crtc->pp_done.irq = mdp5_crtc_pp_done_irq;
11731183

1174-
if (cursor_plane)
1175-
drm_crtc_init_with_planes(dev, crtc, plane, cursor_plane,
1176-
&mdp5_crtc_no_lm_cursor_funcs, NULL);
1177-
else
1178-
drm_crtc_init_with_planes(dev, crtc, plane, NULL,
1179-
&mdp5_crtc_funcs, NULL);
1184+
mdp5_crtc->lm_cursor_enabled = cursor_plane ? false : true;
1185+
1186+
drm_crtc_init_with_planes(dev, crtc, plane, cursor_plane,
1187+
&mdp5_crtc_funcs, NULL);
11801188

11811189
drm_flip_work_init(&mdp5_crtc->unref_cursor_work,
11821190
"unref cursor", unref_cursor_worker);

0 commit comments

Comments
 (0)