aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArchit Taneja <architt@codeaurora.org>2017-10-27 06:57:31 -0400
committerRob Clark <robdclark@gmail.com>2017-10-28 14:02:58 -0400
commitaa649e875daf6919bae8d406f115d38a6f39e59c (patch)
treeae4006677d8b1d78b9c99c08e24602c659cd7937
parentb14892801078085cb54dcbe3389057e12c1746a2 (diff)
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 <architt@codeaurora.org> Signed-off-by: Rob Clark <robdclark@gmail.com>
-rw-r--r--drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c66
1 files changed, 37 insertions, 29 deletions
diff --git a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c
index 95ba9edebf04..6f84796c5abc 100644
--- a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c
+++ b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c
@@ -55,6 +55,8 @@ struct mdp5_crtc {
55 55
56 struct completion pp_completion; 56 struct completion pp_completion;
57 57
58 bool lm_cursor_enabled;
59
58 struct { 60 struct {
59 /* protect REG_MDP5_LM_CURSOR* registers and cursor scanout_bo*/ 61 /* protect REG_MDP5_LM_CURSOR* registers and cursor scanout_bo*/
60 spinlock_t lock; 62 spinlock_t lock;
@@ -457,19 +459,24 @@ static void mdp5_crtc_atomic_enable(struct drm_crtc *crtc,
457 459
458 pm_runtime_get_sync(dev); 460 pm_runtime_get_sync(dev);
459 461
460 /* Restore cursor state, as it might have been lost with suspend: */ 462 if (mdp5_crtc->lm_cursor_enabled) {
461 if (mdp5_crtc->cursor.iova) { 463 /*
462 unsigned long flags; 464 * Restore LM cursor state, as it might have been lost
463 465 * with suspend:
464 spin_lock_irqsave(&mdp5_crtc->cursor.lock, flags); 466 */
465 mdp5_crtc_restore_cursor(crtc); 467 if (mdp5_crtc->cursor.iova) {
466 spin_unlock_irqrestore(&mdp5_crtc->cursor.lock, flags); 468 unsigned long flags;
467 469
468 mdp5_ctl_set_cursor(mdp5_cstate->ctl, 470 spin_lock_irqsave(&mdp5_crtc->cursor.lock, flags);
469 &mdp5_cstate->pipeline, 0, true); 471 mdp5_crtc_restore_cursor(crtc);
470 } else { 472 spin_unlock_irqrestore(&mdp5_crtc->cursor.lock, flags);
471 mdp5_ctl_set_cursor(mdp5_cstate->ctl, 473
472 &mdp5_cstate->pipeline, 0, false); 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 }
473 } 480 }
474 481
475 /* Restore vblank irq handling after power is enabled */ 482 /* Restore vblank irq handling after power is enabled */
@@ -817,6 +824,12 @@ static int mdp5_crtc_cursor_set(struct drm_crtc *crtc,
817 bool cursor_enable = true; 824 bool cursor_enable = true;
818 unsigned long flags; 825 unsigned long flags;
819 826
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
820 if ((width > CURSOR_WIDTH) || (height > CURSOR_HEIGHT)) { 833 if ((width > CURSOR_WIDTH) || (height > CURSOR_HEIGHT)) {
821 dev_err(dev->dev, "bad cursor size: %dx%d\n", width, height); 834 dev_err(dev->dev, "bad cursor size: %dx%d\n", width, height);
822 return -EINVAL; 835 return -EINVAL;
@@ -888,10 +901,17 @@ static int mdp5_crtc_cursor_move(struct drm_crtc *crtc, int x, int y)
888 struct mdp5_crtc *mdp5_crtc = to_mdp5_crtc(crtc); 901 struct mdp5_crtc *mdp5_crtc = to_mdp5_crtc(crtc);
889 struct mdp5_crtc_state *mdp5_cstate = to_mdp5_crtc_state(crtc->state); 902 struct mdp5_crtc_state *mdp5_cstate = to_mdp5_crtc_state(crtc->state);
890 uint32_t flush_mask = mdp_ctl_flush_mask_cursor(0); 903 uint32_t flush_mask = mdp_ctl_flush_mask_cursor(0);
904 struct drm_device *dev = crtc->dev;
891 uint32_t roi_w; 905 uint32_t roi_w;
892 uint32_t roi_h; 906 uint32_t roi_h;
893 unsigned long flags; 907 unsigned long flags;
894 908
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
895 /* don't support LM cursors when we we have source split enabled */ 915 /* don't support LM cursors when we we have source split enabled */
896 if (mdp5_cstate->pipeline.r_mixer) 916 if (mdp5_cstate->pipeline.r_mixer)
897 return -EINVAL; 917 return -EINVAL;
@@ -993,16 +1013,6 @@ static const struct drm_crtc_funcs mdp5_crtc_funcs = {
993 .atomic_print_state = mdp5_crtc_atomic_print_state, 1013 .atomic_print_state = mdp5_crtc_atomic_print_state,
994}; 1014};
995 1015
996static 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
1006static const struct drm_crtc_helper_funcs mdp5_crtc_helper_funcs = { 1016static const struct drm_crtc_helper_funcs mdp5_crtc_helper_funcs = {
1007 .mode_set_nofb = mdp5_crtc_mode_set_nofb, 1017 .mode_set_nofb = mdp5_crtc_mode_set_nofb,
1008 .atomic_check = mdp5_crtc_atomic_check, 1018 .atomic_check = mdp5_crtc_atomic_check,
@@ -1171,12 +1181,10 @@ struct drm_crtc *mdp5_crtc_init(struct drm_device *dev,
1171 mdp5_crtc->err.irq = mdp5_crtc_err_irq; 1181 mdp5_crtc->err.irq = mdp5_crtc_err_irq;
1172 mdp5_crtc->pp_done.irq = mdp5_crtc_pp_done_irq; 1182 mdp5_crtc->pp_done.irq = mdp5_crtc_pp_done_irq;
1173 1183
1174 if (cursor_plane) 1184 mdp5_crtc->lm_cursor_enabled = cursor_plane ? false : true;
1175 drm_crtc_init_with_planes(dev, crtc, plane, cursor_plane, 1185
1176 &mdp5_crtc_no_lm_cursor_funcs, NULL); 1186 drm_crtc_init_with_planes(dev, crtc, plane, cursor_plane,
1177 else 1187 &mdp5_crtc_funcs, NULL);
1178 drm_crtc_init_with_planes(dev, crtc, plane, NULL,
1179 &mdp5_crtc_funcs, NULL);
1180 1188
1181 drm_flip_work_init(&mdp5_crtc->unref_cursor_work, 1189 drm_flip_work_init(&mdp5_crtc->unref_cursor_work,
1182 "unref cursor", unref_cursor_worker); 1190 "unref cursor", unref_cursor_worker);