aboutsummaryrefslogtreecommitdiffstats
path: root/meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.14.71/0130-drm-amd-display-fix-cursor-disappearing-after-resume.patch
blob: ffbd5f17ee2a0521187657b5eb4818f162841977 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
From 4ec02986640094ec1646eacabe22dad99394c112 Mon Sep 17 00:00:00 2001
From: Arindam Nath <arindam.nath@amd.com>
Date: Mon, 9 Jan 2017 11:50:27 +0530
Subject: [PATCH 0130/4131] drm/amd/display: fix cursor disappearing after
 resume

Since during suspend, the cursor registers are cleared,
once the system resumes back, the cursor remains disabled.
cursor_set_attributes() only sets the cursor attributes
along with cursor size and surface address, but does not
enable the cursor back on.

We need to save the current cursor location so that
we can resume back to the same location. This is done
in dm_crtc_cursor_move(), where we save the current
cursor location into cursor_x and cursor_y. Later during
resume we use these same values to set the cursor
position along with cursor attributes.

Signed-off-by: Arindam Nath <arindam.nath@amd.com>
Reviewed-by: Harry Wentland <harry.wentland@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
 .../drm/amd/display/amdgpu_dm/amdgpu_dm_types.c    | 38 ++++++++++++++++++++++
 1 file changed, 38 insertions(+)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_types.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_types.c
index fc5b0f0..27783cf 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_types.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_types.c
@@ -79,6 +79,11 @@ static void dm_set_cursor(
 	uint32_t height)
 {
 	struct dc_cursor_attributes attributes;
+	struct dc_cursor_position position;
+	struct drm_crtc *crtc = &amdgpu_crtc->base;
+	int x, y;
+	int xorigin = 0, yorigin = 0;
+
 	amdgpu_crtc->cursor_width = width;
 	amdgpu_crtc->cursor_height = height;
 
@@ -92,11 +97,41 @@ static void dm_set_cursor(
 	attributes.rotation_angle    = 0;
 	attributes.attribute_flags.value = 0;
 
+	x = amdgpu_crtc->cursor_x;
+	y = amdgpu_crtc->cursor_y;
+
+	/* avivo cursor are offset into the total surface */
+	x += crtc->primary->state->src_x >> 16;
+	y += crtc->primary->state->src_y >> 16;
+
+	if (x < 0) {
+		xorigin = min(-x, amdgpu_crtc->max_cursor_width - 1);
+		x = 0;
+	}
+	if (y < 0) {
+		yorigin = min(-y, amdgpu_crtc->max_cursor_height - 1);
+		y = 0;
+	}
+
+	position.enable = true;
+	position.x = x;
+	position.y = y;
+
+	position.hot_spot_enable = true;
+	position.x_hotspot = xorigin;
+	position.y_hotspot = yorigin;
+
 	if (!dc_target_set_cursor_attributes(
 				amdgpu_crtc->target,
 				&attributes)) {
 		DRM_ERROR("DC failed to set cursor attributes\n");
 	}
+
+	if (!dc_target_set_cursor_position(
+				amdgpu_crtc->target,
+				&position)) {
+		DRM_ERROR("DC failed to set cursor position\n");
+	}
 }
 
 static int dm_crtc_unpin_cursor_bo_old(
@@ -275,6 +310,9 @@ static int dm_crtc_cursor_move(struct drm_crtc *crtc,
 	int xorigin = 0, yorigin = 0;
 	struct dc_cursor_position position;
 
+	amdgpu_crtc->cursor_x = x;
+	amdgpu_crtc->cursor_y = y;
+
 	/* avivo cursor are offset into the total surface */
 	x += crtc->primary->state->src_x >> 16;
 	y += crtc->primary->state->src_y >> 16;
-- 
2.7.4