aboutsummaryrefslogtreecommitdiffstats
path: root/meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.14.71/0267-drm-amd-display-fix-hsplit-viewport-calculation-for-.patch
blob: 37bf51ef0349a1df61323c28bc7ec23e411e8c2a (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
From c21d85cb9f4b2aed6bd791c44b5c277edaac0e63 Mon Sep 17 00:00:00 2001
From: Dmytro Laktyushkin <Dmytro.Laktyushkin@amd.com>
Date: Mon, 6 Mar 2017 14:57:28 -0500
Subject: [PATCH 0267/4131] drm/amd/display: fix hsplit viewport calculation
 for rotated/mirrored usecases

Signed-off-by: Dmytro Laktyushkin <Dmytro.Laktyushkin@amd.com>
Acked-by: Harry Wentland <Harry.Wentland@amd.com>
Reviewed-by: Tony Cheng <Tony.Cheng@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/amd/display/dc/core/dc_resource.c | 47 +++++++++++++++++------
 1 file changed, 36 insertions(+), 11 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 d4b338f..e34b52e 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_resource.c
@@ -412,6 +412,8 @@ static void calculate_viewport(struct pipe_ctx *pipe_ctx)
 	struct rect clip = {0};
 	int vpc_div = (data->format == PIXEL_FORMAT_420BPP12
 			|| data->format == PIXEL_FORMAT_420BPP15) ? 2 : 1;
+	bool need_split = (pipe_ctx->top_pipe && pipe_ctx->top_pipe->surface == pipe_ctx->surface)
+		|| (pipe_ctx->bottom_pipe && pipe_ctx->bottom_pipe->surface == pipe_ctx->surface);
 
 
 	if (surface->rotation == ROTATION_ANGLE_90 ||
@@ -466,17 +468,40 @@ static void calculate_viewport(struct pipe_ctx *pipe_ctx)
 	data->viewport_c.height = (data->viewport.height + vpc_div - 1) / vpc_div;
 
 	/* Handle hsplit */
-	if (pipe_ctx->top_pipe && pipe_ctx->top_pipe->surface == pipe_ctx->surface) {
-		data->viewport.width /= 2;
-		data->viewport_c.width /= 2;
-		data->viewport.x +=  data->viewport.width;
-		data->viewport_c.x +=  data->viewport_c.width;
-		/* Floor primary pipe, ceil 2ndary pipe */
-		data->viewport.width += data->viewport.width % 2;
-		data->viewport_c.width += data->viewport_c.width % 2;
-	} else if (pipe_ctx->bottom_pipe && pipe_ctx->bottom_pipe->surface == pipe_ctx->surface) {
-		data->viewport.width /= 2;
-		data->viewport_c.width /= 2;
+	if (need_split && (surface->rotation == ROTATION_ANGLE_90 ||
+				surface->rotation == ROTATION_ANGLE_270)) {
+		bool lower_view = (surface->rotation == ROTATION_ANGLE_270) ^
+			(pipe_ctx->top_pipe && pipe_ctx->top_pipe->surface == pipe_ctx->surface);
+
+		if (lower_view) {
+			data->viewport.height /= 2;
+			data->viewport_c.height /= 2;
+			data->viewport.y +=  data->viewport.height;
+			data->viewport_c.y +=  data->viewport_c.height;
+			/* Ceil offset pipe */
+			data->viewport.height += data->viewport.height % 2;
+			data->viewport_c.height += data->viewport_c.height % 2;
+		} else {
+			data->viewport.height /= 2;
+			data->viewport_c.height /= 2;
+		}
+	} else if (need_split) {
+		bool right_view = (surface->rotation == ROTATION_ANGLE_180) ^
+			(pipe_ctx->top_pipe && pipe_ctx->top_pipe->surface == pipe_ctx->surface) ^
+			surface->horizontal_mirror;
+
+		if (right_view) {
+			data->viewport.width /= 2;
+			data->viewport_c.width /= 2;
+			data->viewport.x +=  data->viewport.width;
+			data->viewport_c.x +=  data->viewport_c.width;
+			/* Ceil offset pipe */
+			data->viewport.width += data->viewport.width % 2;
+			data->viewport_c.width += data->viewport_c.width % 2;
+		} else {
+			data->viewport.width /= 2;
+			data->viewport_c.width /= 2;
+		}
 	}
 }
 
-- 
2.7.4