aboutsummaryrefslogtreecommitdiffstats
path: root/meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.14.71/0590-drm-amd-display-Refactor-dc_commit_streams.patch
blob: 056b3f2c47039f639f0cdf03f942362a041f1f56 (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
From ec182f37688c93f633ede0059d431e8d31bd2c66 Mon Sep 17 00:00:00 2001
From: Andrey Grodzovsky <Andrey.Grodzovsky@amd.com>
Date: Thu, 6 Jul 2017 13:53:15 -0400
Subject: [PATCH 0590/4131] drm/amd/display: Refactor dc_commit_streams

Change it to sue dc_commit_context. dc_commit_context
is used directly from Linux DM.

Signed-off-by: Andrey Grodzovsky <Andrey.Grodzovsky@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.c | 99 +++++++++++++-------------------
 1 file changed, 41 insertions(+), 58 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/core/dc.c b/drivers/gpu/drm/amd/display/dc/core/dc.c
index 2f93f0e..52077d39 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc.c
@@ -913,33 +913,22 @@ bool dc_enable_stereo(
 	return ret;
 }
 
-/* TODO operate on validation set (or something like it) */
-bool dc_commit_context(struct dc *dc, struct validate_context *context)
+
+/*
+ * Applies given context to HW and copy it into current context.
+ * It's up to the user to release the src context afterwards.
+ */
+static bool dc_commit_context_no_check(struct dc *dc, struct validate_context *context)
 {
 	struct core_dc *core_dc = DC_TO_CORE(dc);
 	struct dc_bios *dcb = core_dc->ctx->dc_bios;
 	enum dc_status result = DC_ERROR_UNEXPECTED;
 	struct pipe_ctx *pipe;
 	int i, j, k, l;
+	const struct dc_stream *dc_streams[MAX_STREAMS] = {0};
 
-	if (!context)
-		dm_logger_write(core_dc->ctx->logger, LOG_ERROR,
-				"%s: dc_commit_context with no context!\n",
-				__func__);
-
-	if (false == context_changed(core_dc, context))
-		return DC_OK;
-
-	dm_logger_write(core_dc->ctx->logger, LOG_DC, "%s: %d streams\n",
-				__func__, context->stream_count);
-
-	for (i = 0; i < context->stream_count; i++) {
-		const struct dc_stream *stream = &context->streams[i]->public;
-
-		dc_stream_log(stream,
-				core_dc->ctx->logger,
-				LOG_DC);
-	}
+	for (i = 0; i < context->stream_count; i++)
+		dc_streams[i] =  &context->streams[i]->public;
 
 	if (!dcb->funcs->is_accelerated_mode(dcb))
 		core_dc->hwss.enable_accelerated_mode(core_dc);
@@ -981,22 +970,49 @@ bool dc_commit_context(struct dc *dc, struct validate_context *context)
 				context->streams[i]->public.timing.pix_clk_khz);
 	}
 
+	dc_enable_stereo(dc, context, dc_streams, context->stream_count);
+
 	dc_resource_validate_ctx_copy_construct(context, core_dc->current_context);
 
 	return (result == DC_OK);
 }
 
+bool dc_commit_context(struct dc *dc, struct validate_context *context)
+{
+	enum dc_status result = DC_ERROR_UNEXPECTED;
+	struct core_dc *core_dc = DC_TO_CORE(dc);
+	int i;
+
+	if (false == context_changed(core_dc, context))
+		return DC_OK;
+
+	dm_logger_write(core_dc->ctx->logger, LOG_DC, "%s: %d streams\n",
+				__func__, context->stream_count);
+
+	for (i = 0; i < context->stream_count; i++) {
+		const struct dc_stream *stream = &context->streams[i]->public;
+
+		dc_stream_log(stream,
+				core_dc->ctx->logger,
+				LOG_DC);
+	}
+
+	result = dc_commit_context_no_check(dc, context);
+
+	return (result == DC_OK);
+}
+
+
 bool dc_commit_streams(
 	struct dc *dc,
 	const struct dc_stream *streams[],
 	uint8_t stream_count)
 {
 	struct core_dc *core_dc = DC_TO_CORE(dc);
-	struct dc_bios *dcb = core_dc->ctx->dc_bios;
 	enum dc_status result = DC_ERROR_UNEXPECTED;
 	struct validate_context *context;
 	struct dc_validation_set set[MAX_STREAMS] = { {0, {0} } };
-	int i, j;
+	int i;
 
 	if (false == streams_changed(core_dc, streams, stream_count))
 		return DC_OK;
@@ -1039,43 +1055,10 @@ bool dc_commit_streams(
 		goto fail;
 	}
 
-	if (!dcb->funcs->is_accelerated_mode(dcb)) {
-		core_dc->hwss.enable_accelerated_mode(core_dc);
-	}
-
-	if (result == DC_OK) {
-		result = core_dc->hwss.apply_ctx_to_hw(core_dc, context);
-	}
-
-	program_timing_sync(core_dc, context);
-
-	for (i = 0; i < context->stream_count; i++) {
-		const struct core_sink *sink = context->streams[i]->sink;
-
-		for (j = 0; j < context->stream_status[i].surface_count; j++) {
-			struct core_surface *surface =
-					DC_SURFACE_TO_CORE(context->stream_status[i].surfaces[j]);
-
-			core_dc->hwss.apply_ctx_for_surface(core_dc, surface, context);
-		}
+	result = dc_commit_context_no_check(dc, context);
 
-		CONN_MSG_MODE(sink->link, "{%ux%u, %ux%u@%u, %ux%u@%uKhz}",
-				context->streams[i]->public.src.width,
-				context->streams[i]->public.src.height,
-				context->streams[i]->public.timing.h_addressable,
-				context->streams[i]->public.timing.v_addressable,
-				context->streams[i]->public.timing.pix_clk_khz * 1000 /
-					context->streams[i]->public.timing.h_total /
-					context->streams[i]->public.timing.v_total, // Refresh rate
-				context->streams[i]->public.timing.h_total,
-				context->streams[i]->public.timing.v_total,
-				context->streams[i]->public.timing.pix_clk_khz);
-	}
-	dc_enable_stereo(dc, context, streams, stream_count);
-	dc_resource_validate_ctx_destruct(core_dc->current_context);
-	dm_free(core_dc->current_context);
-
-	core_dc->current_context = context;
+	dc_resource_validate_ctx_destruct(context);
+	dm_free(context);
 
 	return (result == DC_OK);
 
-- 
2.7.4