1 From 23eb470a4e4f6b377b623f7449a2cbfbd18e08ab Mon Sep 17 00:00:00 2001
2 From: Eric Anholt <eric@anholt.net>
3 Date: Thu, 6 Jul 2017 11:45:48 -0700
4 Subject: [PATCH 115/773] drm/vc4: Add support for setting DPMS in firmwarekms.
6 This ensures that the screen goes blank during DPMS (screensaver),
7 including the cursor. Planes don't necessarily get disabled during
8 CRTC disable, so we need to be careful to not leave them on or turn
11 Signed-off-by: Eric Anholt <eric@anholt.net>
13 drivers/gpu/drm/vc4/vc4_firmware_kms.c | 40 ++++++++++++++++++++++++--
14 1 file changed, 37 insertions(+), 3 deletions(-)
16 --- a/drivers/gpu/drm/vc4/vc4_firmware_kms.c
17 +++ b/drivers/gpu/drm/vc4/vc4_firmware_kms.c
18 @@ -36,6 +36,8 @@ struct vc4_crtc {
20 struct drm_encoder *encoder;
21 struct drm_connector *connector;
22 + struct drm_plane *primary;
23 + struct drm_plane *cursor;
26 struct drm_pending_vblank_event *event;
27 @@ -123,8 +125,6 @@ static void vc4_primary_plane_atomic_upd
31 - vc4_plane_set_primary_blank(plane, false);
33 fbinfo->xres = state->crtc_w;
34 fbinfo->yres = state->crtc_h;
35 fbinfo->xres_virtual = state->crtc_w;
36 @@ -168,6 +168,12 @@ static void vc4_primary_plane_atomic_upd
37 vc4_plane->fbinfo_bus_addr);
38 WARN_ON_ONCE(fbinfo->pitch != fb->pitches[0]);
39 WARN_ON_ONCE(fbinfo->base != bo->paddr + fb->offsets[0]);
41 + /* If the CRTC is on (or going to be on) and we're enabled,
42 + * then unblank. Otherwise, stay blank until CRTC enable.
44 + if (state->crtc->state->active)
45 + vc4_plane_set_primary_blank(plane, false);
48 static void vc4_primary_plane_atomic_disable(struct drm_plane *plane,
49 @@ -184,7 +190,12 @@ static void vc4_cursor_plane_atomic_upda
50 struct drm_framebuffer *fb = state->fb;
51 struct drm_gem_cma_object *bo = drm_fb_cma_get_gem_obj(fb, 0);
53 - u32 packet_state[] = { true, state->crtc_x, state->crtc_y, 0 };
54 + u32 packet_state[] = {
55 + state->crtc->state->active,
60 u32 packet_info[] = { state->crtc_w, state->crtc_h,
62 bo->paddr + fb->offsets[0],
63 @@ -321,10 +332,30 @@ static void vc4_crtc_mode_set_nofb(struc
65 static void vc4_crtc_disable(struct drm_crtc *crtc, struct drm_crtc_state *old_state)
67 + struct vc4_crtc *vc4_crtc = to_vc4_crtc(crtc);
69 + /* Always turn the planes off on CRTC disable. In DRM, planes
70 + * are enabled/disabled through the update/disable hooks
71 + * above, and the CRTC enable/disable independently controls
72 + * whether anything scans out at all, but the firmware doesn't
73 + * give us a CRTC-level control for that.
75 + vc4_cursor_plane_atomic_disable(vc4_crtc->cursor,
76 + vc4_crtc->cursor->state);
77 + vc4_plane_set_primary_blank(vc4_crtc->primary, true);
80 static void vc4_crtc_enable(struct drm_crtc *crtc, struct drm_crtc_state *old_state)
82 + struct vc4_crtc *vc4_crtc = to_vc4_crtc(crtc);
84 + /* Unblank the planes (if they're supposed to be displayed). */
85 + if (vc4_crtc->primary->state->fb)
86 + vc4_plane_set_primary_blank(vc4_crtc->primary, false);
87 + if (vc4_crtc->cursor->state->fb) {
88 + vc4_cursor_plane_atomic_update(vc4_crtc->cursor,
89 + vc4_crtc->cursor->state);
93 static int vc4_crtc_atomic_check(struct drm_crtc *crtc,
94 @@ -618,6 +649,9 @@ static int vc4_fkms_bind(struct device *
95 primary_plane->crtc = crtc;
96 cursor_plane->crtc = crtc;
98 + vc4_crtc->primary = primary_plane;
99 + vc4_crtc->cursor = cursor_plane;
101 vc4_encoder = devm_kzalloc(dev, sizeof(*vc4_encoder), GFP_KERNEL);