aboutsummaryrefslogtreecommitdiffstats
path: root/meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.14.71/0423-drm-amd-display-fix-scaling-calculation-for-proper-s.patch
blob: 426f73b8832080a0bafd9ae1c8abc1151333f45c (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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
From bd025418437344338ac79ef90af461a068cc8163 Mon Sep 17 00:00:00 2001
From: Dmytro Laktyushkin <Dmytro.Laktyushkin@amd.com>
Date: Tue, 9 May 2017 16:39:26 -0400
Subject: [PATCH 0423/4131] drm/amd/display: fix scaling calculation for proper
 surface input format

Signed-off-by: Dmytro Laktyushkin <Dmytro.Laktyushkin@amd.com>
Reviewed-by: Tony Cheng <Tony.Cheng@amd.com>
Acked-by: Harry Wentland <Harry.Wentland@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/amd/display/dc/core/dc_resource.c | 60 +++++++++++++++--------
 drivers/gpu/drm/amd/display/dc/dc_hw_types.h      | 20 ++++----
 2 files changed, 49 insertions(+), 31 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_resource.c b/drivers/gpu/drm/amd/display/dc/core/dc_resource.c
index 9588217..7ca03d1 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_resource.c
@@ -431,6 +431,7 @@ static void calculate_viewport(struct pipe_ctx *pipe_ctx)
 	const struct dc_surface *surface = &pipe_ctx->surface->public;
 	const struct dc_stream *stream = &pipe_ctx->stream->public;
 	struct scaler_data *data = &pipe_ctx->scl_data;
+	struct rect surf_src = surface->src_rect;
 	struct rect clip = { 0 };
 	int vpc_div = (data->format == PIXEL_FORMAT_420BPP12
 			|| data->format == PIXEL_FORMAT_420BPP15) ? 2 : 1;
@@ -444,6 +445,11 @@ static void calculate_viewport(struct pipe_ctx *pipe_ctx)
 		pri_split = false;
 		sec_split = false;
 	}
+
+	if (pipe_ctx->surface->public.rotation == ROTATION_ANGLE_90 ||
+			pipe_ctx->surface->public.rotation == ROTATION_ANGLE_270)
+		rect_swap_helper(&surf_src);
+
 	/* The actual clip is an intersection between stream
 	 * source and surface clip
 	 */
@@ -463,18 +469,18 @@ static void calculate_viewport(struct pipe_ctx *pipe_ctx)
 			stream->src.y + stream->src.height - clip.y :
 			surface->clip_rect.y + surface->clip_rect.height - clip.y ;
 
-	/* offset = src.ofs + (clip.ofs - surface->dst_rect.ofs) * scl_ratio
+	/* offset = surf_src.ofs + (clip.ofs - surface->dst_rect.ofs) * scl_ratio
 	 * num_pixels = clip.num_pix * scl_ratio
 	 */
-	data->viewport.x = surface->src_rect.x + (clip.x - surface->dst_rect.x) *
-			surface->src_rect.width / surface->dst_rect.width;
+	data->viewport.x = surf_src.x + (clip.x - surface->dst_rect.x) *
+			surf_src.width / surface->dst_rect.width;
 	data->viewport.width = clip.width *
-			surface->src_rect.width / surface->dst_rect.width;
+			surf_src.width / surface->dst_rect.width;
 
-	data->viewport.y = surface->src_rect.y + (clip.y - surface->dst_rect.y) *
-			surface->src_rect.height / surface->dst_rect.height;
+	data->viewport.y = surf_src.y + (clip.y - surface->dst_rect.y) *
+			surf_src.height / surface->dst_rect.height;
 	data->viewport.height = clip.height *
-			surface->src_rect.height / surface->dst_rect.height;
+			surf_src.height / surface->dst_rect.height;
 
 	/* Round down, compensate in init */
 	data->viewport_c.x = data->viewport.x / vpc_div;
@@ -523,16 +529,21 @@ static void calculate_recout(struct pipe_ctx *pipe_ctx, struct view *recout_skip
 {
 	const struct dc_surface *surface = &pipe_ctx->surface->public;
 	struct core_stream *stream = pipe_ctx->stream;
-	struct rect clip = surface->clip_rect;
+	struct rect surf_src = surface->src_rect;
+	struct rect surf_clip = surface->clip_rect;
 	int recout_full_x, recout_full_y;
 
+	if (pipe_ctx->surface->public.rotation == ROTATION_ANGLE_90 ||
+			pipe_ctx->surface->public.rotation == ROTATION_ANGLE_270)
+		rect_swap_helper(&surf_src);
+
 	pipe_ctx->scl_data.recout.x = stream->public.dst.x;
-	if (stream->public.src.x < clip.x)
-		pipe_ctx->scl_data.recout.x += (clip.x
+	if (stream->public.src.x < surf_clip.x)
+		pipe_ctx->scl_data.recout.x += (surf_clip.x
 			- stream->public.src.x) * stream->public.dst.width
 						/ stream->public.src.width;
 
-	pipe_ctx->scl_data.recout.width = clip.width *
+	pipe_ctx->scl_data.recout.width = surf_clip.width *
 			stream->public.dst.width / stream->public.src.width;
 	if (pipe_ctx->scl_data.recout.width + pipe_ctx->scl_data.recout.x >
 			stream->public.dst.x + stream->public.dst.width)
@@ -541,12 +552,12 @@ static void calculate_recout(struct pipe_ctx *pipe_ctx, struct view *recout_skip
 						- pipe_ctx->scl_data.recout.x;
 
 	pipe_ctx->scl_data.recout.y = stream->public.dst.y;
-	if (stream->public.src.y < clip.y)
-		pipe_ctx->scl_data.recout.y += (clip.y
+	if (stream->public.src.y < surf_clip.y)
+		pipe_ctx->scl_data.recout.y += (surf_clip.y
 			- stream->public.src.y) * stream->public.dst.height
 						/ stream->public.src.height;
 
-	pipe_ctx->scl_data.recout.height = clip.height *
+	pipe_ctx->scl_data.recout.height = surf_clip.height *
 			stream->public.dst.height / stream->public.src.height;
 	if (pipe_ctx->scl_data.recout.height + pipe_ctx->scl_data.recout.y >
 			stream->public.dst.y + stream->public.dst.height)
@@ -569,7 +580,7 @@ static void calculate_recout(struct pipe_ctx *pipe_ctx, struct view *recout_skip
 			pipe_ctx->scl_data.recout.width += pipe_ctx->scl_data.recout.width % 2;
 		}
 	} else if (pipe_ctx->bottom_pipe &&
-			   pipe_ctx->bottom_pipe->surface == pipe_ctx->surface) {
+			pipe_ctx->bottom_pipe->surface == pipe_ctx->surface) {
 		if (stream->public.timing.timing_3d_format ==
 			TIMING_3D_FORMAT_TOP_AND_BOTTOM)
 			pipe_ctx->scl_data.recout.height /= 2;
@@ -577,17 +588,17 @@ static void calculate_recout(struct pipe_ctx *pipe_ctx, struct view *recout_skip
 			pipe_ctx->scl_data.recout.width /= 2;
 	}
 
-	/* Unclipped recout offset = stream dst offset + ((surf dst offset - stream src offset)
-	 * 				* 1/ stream scaling ratio) - (surf src offset * 1/ full scl
+	/* Unclipped recout offset = stream dst offset + ((surf dst offset - stream surf_src offset)
+	 * 				* 1/ stream scaling ratio) - (surf surf_src offset * 1/ full scl
 	 * 				ratio)
 	 */
 	recout_full_x = stream->public.dst.x + (surface->dst_rect.x -  stream->public.src.x)
 					* stream->public.dst.width / stream->public.src.width -
-			surface->src_rect.x * surface->dst_rect.width / surface->src_rect.width
+			surf_src.x * surface->dst_rect.width / surf_src.width
 					* stream->public.dst.width / stream->public.src.width;
 	recout_full_y = stream->public.dst.y + (surface->dst_rect.y -  stream->public.src.y)
 					* stream->public.dst.height / stream->public.src.height -
-			surface->src_rect.y * surface->dst_rect.height / surface->src_rect.height
+			surf_src.y * surface->dst_rect.height / surf_src.height
 					* stream->public.dst.height / stream->public.src.height;
 
 	recout_skip->width = pipe_ctx->scl_data.recout.x - recout_full_x;
@@ -598,16 +609,21 @@ static void calculate_scaling_ratios(struct pipe_ctx *pipe_ctx)
 {
 	const struct dc_surface *surface = &pipe_ctx->surface->public;
 	struct core_stream *stream = pipe_ctx->stream;
+	struct rect surf_src = surface->src_rect;
 	const int in_w = stream->public.src.width;
 	const int in_h = stream->public.src.height;
 	const int out_w = stream->public.dst.width;
 	const int out_h = stream->public.dst.height;
 
+	if (pipe_ctx->surface->public.rotation == ROTATION_ANGLE_90 ||
+			pipe_ctx->surface->public.rotation == ROTATION_ANGLE_270)
+		rect_swap_helper(&surf_src);
+
 	pipe_ctx->scl_data.ratios.horz = dal_fixed31_32_from_fraction(
-					surface->src_rect.width,
+					surf_src.width,
 					surface->dst_rect.width);
 	pipe_ctx->scl_data.ratios.vert = dal_fixed31_32_from_fraction(
-					surface->src_rect.height,
+					surf_src.height,
 					surface->dst_rect.height);
 
 	if (surface->stereo_format == PLANE_STEREO_FORMAT_SIDE_BY_SIDE)
@@ -637,8 +653,10 @@ static void calculate_inits_and_adj_vp(struct pipe_ctx *pipe_ctx, struct view *r
 	int vpc_div = (data->format == PIXEL_FORMAT_420BPP12
 			|| data->format == PIXEL_FORMAT_420BPP15) ? 2 : 1;
 
+
 	if (pipe_ctx->surface->public.rotation == ROTATION_ANGLE_90 ||
 			pipe_ctx->surface->public.rotation == ROTATION_ANGLE_270) {
+		rect_swap_helper(&src);
 		rect_swap_helper(&data->viewport_c);
 		rect_swap_helper(&data->viewport);
 	}
diff --git a/drivers/gpu/drm/amd/display/dc/dc_hw_types.h b/drivers/gpu/drm/amd/display/dc/dc_hw_types.h
index 1a7ce06..58a3bcd 100644
--- a/drivers/gpu/drm/amd/display/dc/dc_hw_types.h
+++ b/drivers/gpu/drm/amd/display/dc/dc_hw_types.h
@@ -99,15 +99,15 @@ struct dc_plane_address {
 };
 
 struct dc_size {
-	uint32_t width;
-	uint32_t height;
+	int width;
+	int height;
 };
 
 struct rect {
 	int x;
 	int y;
-	uint32_t width;
-	uint32_t height;
+	int width;
+	int height;
 };
 
 union plane_size {
@@ -123,7 +123,7 @@ union plane_size {
 		 * In LINEAR_GENERAL mode, pitch
 		 * is 32 pixel aligned.
 		 */
-		uint32_t surface_pitch;
+		int surface_pitch;
 	} grph;
 
 	struct {
@@ -132,14 +132,14 @@ union plane_size {
 		 * In LINEAR_GENERAL mode, pitch is
 		 * 32 pixel aligned.
 		 */
-		uint32_t luma_pitch;
+		int luma_pitch;
 
 		struct rect chroma_size;
 		/* Graphic surface pitch in pixels.
 		 * In LINEAR_GENERAL mode, pitch is
 		 * 32 pixel aligned.
 		 */
-		uint32_t chroma_pitch;
+		int chroma_pitch;
 	} video;
 };
 
@@ -148,15 +148,15 @@ struct dc_plane_dcc_param {
 
 	union {
 		struct {
-			uint32_t meta_pitch;
+			int meta_pitch;
 			bool independent_64b_blks;
 		} grph;
 
 		struct {
-			uint32_t meta_pitch_l;
+			int meta_pitch_l;
 			bool independent_64b_blks_l;
 
-			uint32_t meta_pitch_c;
+			int meta_pitch_c;
 			bool independent_64b_blks_c;
 		} video;
 	};
-- 
2.7.4