aboutsummaryrefslogtreecommitdiffstats
path: root/common/recipes-kernel/linux/files/0683-drm-amd-dal-Define-interface-for-External-VBIOS-part.patch
blob: 85c17bf2892272318ebaee0517bda464ebf83344 (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
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
From 028d2eb5ef5519c27bdbf497651faf9273559c0f Mon Sep 17 00:00:00 2001
From: David Rokhvarg <David.Rokhvarg@amd.com>
Date: Fri, 8 Jan 2016 15:40:44 -0500
Subject: [PATCH 0683/1110] drm/amd/dal: Define interface for External VBIOS -
 part 1.

Current use is to allow Diagnositcs/Validation of DCE on FPGA.

Signed-off-by: David Rokhvarg <David.Rokhvarg@amd.com>
Acked-by: Jordan Lazare <Jordan.Lazare@amd.com>
---
 .../gpu/drm/amd/dal/dc/adapter/adapter_service.c   | 36 ++++++++++++++-----
 .../gpu/drm/amd/dal/dc/adapter/adapter_service.h   |  3 +-
 drivers/gpu/drm/amd/dal/dc/bios/bios_parser.c      | 14 +++++++-
 drivers/gpu/drm/amd/dal/dc/bios/bios_parser.h      |  6 ++++
 drivers/gpu/drm/amd/dal/dc/core/dc.c               |  9 +++--
 drivers/gpu/drm/amd/dal/dc/dc_bios_types.h         | 40 ++++++++++++++++++++++
 .../amd/dal/include/adapter_service_interface.h    |  1 +
 .../drm/amd/dal/include/bios_parser_interface.h    |  7 ++--
 drivers/gpu/drm/amd/dal/include/dal_types.h        |  4 +++
 9 files changed, 104 insertions(+), 16 deletions(-)
 create mode 100644 drivers/gpu/drm/amd/dal/dc/dc_bios_types.h

diff --git a/drivers/gpu/drm/amd/dal/dc/adapter/adapter_service.c b/drivers/gpu/drm/amd/dal/dc/adapter/adapter_service.c
index 4f9a637..6084466 100644
--- a/drivers/gpu/drm/amd/dal/dc/adapter/adapter_service.c
+++ b/drivers/gpu/drm/amd/dal/dc/adapter/adapter_service.c
@@ -34,6 +34,7 @@
 #include "include/asic_capability_interface.h"
 #include "include/logger_interface.h"
 
+#include "dc_bios_types.h"
 #include "adapter_service.h"
 #include "hw_ctx_adapter_service.h"
 #include "wireless_data_source.h"
@@ -735,10 +736,16 @@ static bool adapter_service_construct(
 		goto failed_to_generate_features;
 	}
 
-	/* Create BIOS parser */
-	init_data->bp_init_data.ctx = init_data->ctx;
-	as->bios_parser =
-		dal_bios_parser_create(&init_data->bp_init_data, as);
+	if (init_data->vbios_override) {
+		/* TODO: remove the typecast */
+		as->bios_parser = (struct bios_parser *)init_data->vbios_override;
+	} else {
+		/* Create BIOS parser */
+		init_data->bp_init_data.ctx = init_data->ctx;
+
+		as->bios_parser =
+			dal_bios_parser_create(&init_data->bp_init_data, as);
+	}
 
 	if (!as->bios_parser) {
 		ASSERT_CRITICAL(false);
@@ -905,7 +912,6 @@ uint8_t dal_adapter_service_get_controllers_num(
 	return result;
 }
 
-
 /** Get total number of connectors.
  *
  * \param as	Adapter Service
@@ -918,9 +924,13 @@ uint8_t dal_adapter_service_get_connectors_num(
 {
 	uint8_t vbios_connectors_num = 0;
 	uint8_t wireless_connectors_num = 0;
+	struct dc_bios *dcb;
+
+	/* TODO: remove type cast */
+	dcb = (struct dc_bios*)dal_adapter_service_get_bios_parser(as);
+
+	vbios_connectors_num = dcb->funcs->get_connectors_number(dcb);
 
-	vbios_connectors_num = dal_bios_parser_get_connectors_number(
-			as->bios_parser);
 	wireless_connectors_num = wireless_get_connectors_num(as);
 
 	return vbios_connectors_num + wireless_connectors_num;
@@ -1004,8 +1014,13 @@ struct graphics_object_id dal_adapter_service_get_connector_obj_id(
 		struct adapter_service *as,
 		uint8_t connector_index)
 {
-	uint8_t bios_connectors_num =
-		dal_bios_parser_get_connectors_number(as->bios_parser);
+	struct dc_bios *dcb;
+	uint8_t bios_connectors_num;
+
+	/* TODO: remove type cast */
+	dcb = (struct dc_bios*)dal_adapter_service_get_bios_parser(as);
+
+	bios_connectors_num = dcb->funcs->get_connectors_number(dcb);
 
 	if (connector_index >= bios_connectors_num)
 		return wireless_get_connector_id(
@@ -1651,9 +1666,12 @@ uint32_t dal_adapter_service_get_memory_type_multiplier(
  *
  * Get BIOS parser handler
  */
+/* TODO: change return type to 'dc_bios'. */
 struct bios_parser *dal_adapter_service_get_bios_parser(
 	struct adapter_service *as)
 {
+	/* TODO: conditionally return 'override' or 'real'.
+	 * Works for now because 'base' is first member of 'bios parser' */
 	return as->bios_parser;
 }
 
diff --git a/drivers/gpu/drm/amd/dal/dc/adapter/adapter_service.h b/drivers/gpu/drm/amd/dal/dc/adapter/adapter_service.h
index 25ac648..dd5bb00 100644
--- a/drivers/gpu/drm/amd/dal/dc/adapter/adapter_service.h
+++ b/drivers/gpu/drm/amd/dal/dc/adapter/adapter_service.h
@@ -35,12 +35,13 @@
  */
 struct gpio_service;
 struct asic_cap;
+struct dc_bios;
 
 /* Adapter service */
 struct adapter_service {
 	struct dc_context *ctx;
 	struct asic_capability *asic_cap;
-	struct bios_parser *bios_parser;
+	struct bios_parser *bios_parser;/* TODO: remove it. replace by struct dc_bios *dcb; */
 	struct gpio_service *gpio_service;
 	struct i2caux *i2caux;
 	struct wireless_data wireless_data;
diff --git a/drivers/gpu/drm/amd/dal/dc/bios/bios_parser.c b/drivers/gpu/drm/amd/dal/dc/bios/bios_parser.c
index 1d02be9..3329322 100644
--- a/drivers/gpu/drm/amd/dal/dc/bios/bios_parser.c
+++ b/drivers/gpu/drm/amd/dal/dc/bios/bios_parser.c
@@ -27,6 +27,7 @@
 
 #include "atom.h"
 
+#include "dc_bios_types.h"
 #include "include/adapter_service_interface.h"
 #include "include/grph_object_ctrl_defs.h"
 #include "include/bios_parser_interface.h"
@@ -98,6 +99,13 @@ static void process_ext_display_connection_info(struct bios_parser *bp);
 #define BIOS_IMAGE_SIZE_OFFSET 2
 #define BIOS_IMAGE_SIZE_UNIT 512
 
+/*****************************************************************************/
+static uint8_t bios_parser_get_connectors_number(struct dc_bios *dcb);
+
+const struct dc_vbios_funcs vbios_funcs = {
+	.get_connectors_number = bios_parser_get_connectors_number
+};
+
 static bool bios_parser_construct(
 	struct bios_parser *bp,
 	struct bp_init_data *init,
@@ -117,6 +125,8 @@ static bool bios_parser_construct(
 	if (!init->bios)
 		return false;
 
+	bp->base.funcs = &vbios_funcs;
+
 	dce_version = dal_adapter_service_get_dce_version(as);
 	bp->ctx = init->ctx;
 	bp->as = as;
@@ -255,8 +265,10 @@ uint8_t dal_bios_parser_get_encoders_number(struct bios_parser *bp)
 		le16_to_cpu(bp->object_info_tbl.v1_1->usEncoderObjectTableOffset));
 }
 
-uint8_t dal_bios_parser_get_connectors_number(struct bios_parser *bp)
+static uint8_t bios_parser_get_connectors_number(struct dc_bios *dcb)
 {
+	struct bios_parser *bp = BP_FROM_DCB(dcb);
+
 	return get_number_of_objects(bp,
 		le16_to_cpu(bp->object_info_tbl.v1_1->usConnectorObjectTableOffset));
 }
diff --git a/drivers/gpu/drm/amd/dal/dc/bios/bios_parser.h b/drivers/gpu/drm/amd/dal/dc/bios/bios_parser.h
index db169f1..f8fa108 100644
--- a/drivers/gpu/drm/amd/dal/dc/bios/bios_parser.h
+++ b/drivers/gpu/drm/amd/dal/dc/bios/bios_parser.h
@@ -26,6 +26,7 @@
 #ifndef __DAL_BIOS_PARSER_H__
 #define __DAL_BIOS_PARSER_H__
 
+#include "dc_bios_types.h"
 #include "bios_parser_helper.h"
 
 struct atom_data_revision {
@@ -50,6 +51,7 @@ enum spread_spectrum_id {
 };
 
 struct bios_parser {
+	struct dc_bios base;
 	struct dc_context *ctx;
 	struct adapter_service *as;
 
@@ -75,4 +77,8 @@ struct bios_parser {
 	bool headless_no_opm;
 };
 
+/* Bios Parser from DC Bios */
+#define BP_FROM_DCB(dc_bios) \
+	container_of(dc_bios, struct bios_parser, base)
+
 #endif
diff --git a/drivers/gpu/drm/amd/dal/dc/core/dc.c b/drivers/gpu/drm/amd/dal/dc/core/dc.c
index e003f78..00a2453 100644
--- a/drivers/gpu/drm/amd/dal/dc/core/dc.c
+++ b/drivers/gpu/drm/amd/dal/dc/core/dc.c
@@ -34,6 +34,7 @@
 
 #include "adapter_service_interface.h"
 #include "clock_source_interface.h"
+#include "dc_bios_types.h"
 
 #include "include/irq_service_interface.h"
 #include "bandwidth_calcs.h"
@@ -77,12 +78,13 @@ static bool create_links(struct dc *dc, const struct dc_init_data *init_params)
 {
 	int i;
 	int connectors_num;
+	struct dc_bios *dcb;
 
 	dc->link_count = 0;
 
-	connectors_num = dal_bios_parser_get_connectors_number(
-			dal_adapter_service_get_bios_parser(
-					init_params->adapter_srv));
+	dcb = (struct dc_bios*)dal_adapter_service_get_bios_parser(init_params->adapter_srv);
+
+	connectors_num = dcb->funcs->get_connectors_number(dcb);
 
 	if (0 == connectors_num || connectors_num > ENUM_ID_COUNT) {
 		dal_error("DC: Invalid number of connectors!\n");
@@ -224,6 +226,7 @@ static struct adapter_service *create_as(
 	init_data.bdf_info = init->bdf_info;
 
 	init_data.display_param = &init->display_param;
+	init_data.vbios_override = init->vbios_override;
 
 	as = dal_adapter_service_create(&init_data);
 
diff --git a/drivers/gpu/drm/amd/dal/dc/dc_bios_types.h b/drivers/gpu/drm/amd/dal/dc/dc_bios_types.h
new file mode 100644
index 0000000..a82cbee
--- /dev/null
+++ b/drivers/gpu/drm/amd/dal/dc/dc_bios_types.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2016 Advanced Micro Devices, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Authors: AMD
+ *
+ */
+
+#ifndef DC_BIOS_TYPES_H
+#define DC_BIOS_TYPES_H
+
+struct dc_vbios_funcs;
+
+struct dc_bios {
+	const struct dc_vbios_funcs *funcs;
+};
+
+struct dc_vbios_funcs {
+	uint8_t (*get_connectors_number)(struct dc_bios *bios);
+};
+
+
+#endif /* DC_BIOS_TYPES_H */
diff --git a/drivers/gpu/drm/amd/dal/include/adapter_service_interface.h b/drivers/gpu/drm/amd/dal/include/adapter_service_interface.h
index aa503a8..e449db6 100644
--- a/drivers/gpu/drm/amd/dal/include/adapter_service_interface.h
+++ b/drivers/gpu/drm/amd/dal/include/adapter_service_interface.h
@@ -322,6 +322,7 @@ struct as_init_data {
 	struct dc_context *ctx;
 	struct bdf_info bdf_info;
 	const struct dal_override_parameters *display_param;
+	struct dc_bios *vbios_override;
 };
 
 /* Create adapter service */
diff --git a/drivers/gpu/drm/amd/dal/include/bios_parser_interface.h b/drivers/gpu/drm/amd/dal/include/bios_parser_interface.h
index 13fa8ab..77999fc 100644
--- a/drivers/gpu/drm/amd/dal/include/bios_parser_interface.h
+++ b/drivers/gpu/drm/amd/dal/include/bios_parser_interface.h
@@ -57,6 +57,8 @@ struct bios_parser *dal_bios_parser_create(
 	struct adapter_service *as);
 void dal_bios_parser_destroy(
 	struct bios_parser **bp);
+
+
 void dal_bios_parser_power_down(
 	struct bios_parser *bp);
 void dal_bios_parser_power_up(
@@ -64,8 +66,6 @@ void dal_bios_parser_power_up(
 
 uint8_t dal_bios_parser_get_encoders_number(
 	struct bios_parser *bp);
-uint8_t dal_bios_parser_get_connectors_number(
-	struct bios_parser *bp);
 uint32_t dal_bios_parser_get_oem_ddc_lines_number(
 	struct bios_parser *bp);
 struct graphics_object_id dal_bios_parser_get_encoder_id(
@@ -294,4 +294,7 @@ struct integrated_info *dal_bios_parser_create_integrated_info(
 
 /* Destroy provided integrated info */
 void dal_bios_parser_destroy_integrated_info(struct dc_context *ctx, struct integrated_info **info);
+
+
+
 #endif
diff --git a/drivers/gpu/drm/amd/dal/include/dal_types.h b/drivers/gpu/drm/amd/dal/include/dal_types.h
index 5ec4784..caaacf6 100644
--- a/drivers/gpu/drm/amd/dal/include/dal_types.h
+++ b/drivers/gpu/drm/amd/dal/include/dal_types.h
@@ -30,6 +30,7 @@
 #include "dc_types.h"
 
 struct dal_logger;
+struct dc_bios;
 
 enum dce_version {
 	DCE_VERSION_UNKNOWN = (-1),
@@ -137,6 +138,9 @@ struct dal_init_data {
 	void *driver; /* ctx */
 	void *cgs_device;
 	uint8_t num_virtual_links;
+	/* If 'vbios_override' not NULL, it will be called instead
+	 * of the real VBIOS. Intended use is Diagnostics on FPGA. */
+	struct dc_bios *vbios_override;
 };
 
 struct dal_dc_init_data {
-- 
2.7.4