aboutsummaryrefslogtreecommitdiffstats
path: root/common/recipes-kernel/linux/files/0991-drm-amd-dal-Fix-underscan-when-enabling-before-setti.patch
blob: 8dfc7ea82217995edb44975d64c8617a6835d1ab (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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
From 0d1247fd5e2d37e0db495608cf0d4fd1b51e27fe Mon Sep 17 00:00:00 2001
From: Jordan Lazare <Jordan.Lazare@amd.com>
Date: Wed, 30 Mar 2016 18:35:32 -0400
Subject: [PATCH 0991/1110] drm/amd/dal: Fix underscan when enabling before
 setting

In order for plane properties to be updated (including underscan),
it is necessary to trigger an atomic_update by calling
drm_atomic_get_plane_state, which will also create or duplicate
a new state if one currently does not exist.

Signed-off-by: Jordan Lazare <Jordan.Lazare@amd.com>
Acked-by: Harry Wentland <harry.wentland@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
 .../gpu/drm/amd/dal/amdgpu_dm/amdgpu_dm_types.c    | 94 +++++++---------------
 1 file changed, 31 insertions(+), 63 deletions(-)

diff --git a/drivers/gpu/drm/amd/dal/amdgpu_dm/amdgpu_dm_types.c b/drivers/gpu/drm/amd/dal/amdgpu_dm/amdgpu_dm_types.c
index f79cbee..010705d 100644
--- a/drivers/gpu/drm/amd/dal/amdgpu_dm/amdgpu_dm_types.c
+++ b/drivers/gpu/drm/amd/dal/amdgpu_dm/amdgpu_dm_types.c
@@ -1019,10 +1019,12 @@ int amdgpu_dm_connector_atomic_set_property(
 	struct dm_connector_state *dm_new_state =
 		to_dm_connector_state(connector_state);
 
+	struct drm_crtc_state *new_crtc_state;
+	struct drm_crtc *crtc;
+	int i;
+	int ret = -EINVAL;
+
 	if (property == dev->mode_config.scaling_mode_property) {
-		struct drm_crtc_state *new_crtc_state;
-		struct drm_crtc *crtc;
-		int i;
 		enum amdgpu_rmx_type rmx_type;
 
 		switch (val) {
@@ -1045,79 +1047,45 @@ int amdgpu_dm_connector_atomic_set_property(
 			return 0;
 
 		dm_new_state->scaling = rmx_type;
-
-		for_each_crtc_in_state(
-			connector_state->state,
-			crtc,
-			new_crtc_state,
-			i) {
-
-			if (crtc == connector_state->crtc) {
-				struct drm_plane_state *plane_state;
-
-				new_crtc_state->mode_changed = true;
-
-				/*
-				 * Bit of magic done here. We need to ensure
-				 * that planes get update after mode is set.
-				 * So, we need to add primary plane to state,
-				 * and this way atomic_update would be called
-				 * for it
-				 */
-				plane_state =
-					drm_atomic_get_plane_state(
-						connector_state->state,
-						crtc->primary);
-
-				if (!plane_state)
-					return -EINVAL;
-			}
-		}
-
-		return 0;
+		ret = 0;
 	} else if (property == adev->mode_info.underscan_hborder_property) {
 		dm_new_state->underscan_hborder = val;
-		return 0;
+		ret = 0;
 	} else if (property == adev->mode_info.underscan_vborder_property) {
 		dm_new_state->underscan_vborder = val;
-		return 0;
+		ret = 0;
 	} else if (property == adev->mode_info.underscan_property) {
-		struct drm_crtc_state *new_crtc_state;
-		struct drm_crtc *crtc;
-		int i;
-
 		dm_new_state->underscan_enable = val;
+		ret = 0;
+	}
 
-		for_each_crtc_in_state(
-			connector_state->state,
-			crtc,
-			new_crtc_state,
-			i) {
+	for_each_crtc_in_state(
+		connector_state->state,
+		crtc,
+		new_crtc_state,
+		i) {
 
-			if (crtc == connector_state->crtc) {
-				struct drm_plane_state *plane_state;
+		if (crtc == connector_state->crtc) {
+			struct drm_plane_state *plane_state;
 
-				/*
-				 * Bit of magic done here. We need to ensure
-				 * that planes get update after mode is set.
-				 * So, we need to add primary plane to state,
-				 * and this way atomic_update would be called
-				 * for it
-				 */
-				plane_state =
-					drm_atomic_get_plane_state(
-						connector_state->state,
-						crtc->primary);
+			/*
+			 * Bit of magic done here. We need to ensure
+			 * that planes get update after mode is set.
+			 * So, we need to add primary plane to state,
+			 * and this way atomic_update would be called
+			 * for it
+			 */
+			plane_state =
+				drm_atomic_get_plane_state(
+					connector_state->state,
+					crtc->primary);
 
-				if (!plane_state)
-					return -EINVAL;
-			}
+			if (!plane_state)
+				return -EINVAL;
 		}
-
-		return 0;
 	}
 
-	return -EINVAL;
+	return ret;
 }
 
 void amdgpu_dm_connector_destroy(struct drm_connector *connector)
-- 
2.7.4