1*b843c749SSergey Zigachev /*
2*b843c749SSergey Zigachev * Copyright 2012-15 Advanced Micro Devices, Inc.
3*b843c749SSergey Zigachev *
4*b843c749SSergey Zigachev * Permission is hereby granted, free of charge, to any person obtaining a
5*b843c749SSergey Zigachev * copy of this software and associated documentation files (the "Software"),
6*b843c749SSergey Zigachev * to deal in the Software without restriction, including without limitation
7*b843c749SSergey Zigachev * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8*b843c749SSergey Zigachev * and/or sell copies of the Software, and to permit persons to whom the
9*b843c749SSergey Zigachev * Software is furnished to do so, subject to the following conditions:
10*b843c749SSergey Zigachev *
11*b843c749SSergey Zigachev * The above copyright notice and this permission notice shall be included in
12*b843c749SSergey Zigachev * all copies or substantial portions of the Software.
13*b843c749SSergey Zigachev *
14*b843c749SSergey Zigachev * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15*b843c749SSergey Zigachev * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16*b843c749SSergey Zigachev * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17*b843c749SSergey Zigachev * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18*b843c749SSergey Zigachev * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19*b843c749SSergey Zigachev * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20*b843c749SSergey Zigachev * OTHER DEALINGS IN THE SOFTWARE.
21*b843c749SSergey Zigachev *
22*b843c749SSergey Zigachev * Authors: AMD
23*b843c749SSergey Zigachev *
24*b843c749SSergey Zigachev */
25*b843c749SSergey Zigachev
26*b843c749SSergey Zigachev #include "bios_parser_common.h"
27*b843c749SSergey Zigachev #include "include/grph_object_ctrl_defs.h"
28*b843c749SSergey Zigachev
object_type_from_bios_object_id(uint32_t bios_object_id)29*b843c749SSergey Zigachev static enum object_type object_type_from_bios_object_id(uint32_t bios_object_id)
30*b843c749SSergey Zigachev {
31*b843c749SSergey Zigachev uint32_t bios_object_type = (bios_object_id & OBJECT_TYPE_MASK)
32*b843c749SSergey Zigachev >> OBJECT_TYPE_SHIFT;
33*b843c749SSergey Zigachev enum object_type object_type;
34*b843c749SSergey Zigachev
35*b843c749SSergey Zigachev switch (bios_object_type) {
36*b843c749SSergey Zigachev case GRAPH_OBJECT_TYPE_GPU:
37*b843c749SSergey Zigachev object_type = OBJECT_TYPE_GPU;
38*b843c749SSergey Zigachev break;
39*b843c749SSergey Zigachev case GRAPH_OBJECT_TYPE_ENCODER:
40*b843c749SSergey Zigachev object_type = OBJECT_TYPE_ENCODER;
41*b843c749SSergey Zigachev break;
42*b843c749SSergey Zigachev case GRAPH_OBJECT_TYPE_CONNECTOR:
43*b843c749SSergey Zigachev object_type = OBJECT_TYPE_CONNECTOR;
44*b843c749SSergey Zigachev break;
45*b843c749SSergey Zigachev case GRAPH_OBJECT_TYPE_ROUTER:
46*b843c749SSergey Zigachev object_type = OBJECT_TYPE_ROUTER;
47*b843c749SSergey Zigachev break;
48*b843c749SSergey Zigachev case GRAPH_OBJECT_TYPE_GENERIC:
49*b843c749SSergey Zigachev object_type = OBJECT_TYPE_GENERIC;
50*b843c749SSergey Zigachev break;
51*b843c749SSergey Zigachev default:
52*b843c749SSergey Zigachev object_type = OBJECT_TYPE_UNKNOWN;
53*b843c749SSergey Zigachev break;
54*b843c749SSergey Zigachev }
55*b843c749SSergey Zigachev
56*b843c749SSergey Zigachev return object_type;
57*b843c749SSergey Zigachev }
58*b843c749SSergey Zigachev
enum_id_from_bios_object_id(uint32_t bios_object_id)59*b843c749SSergey Zigachev static enum object_enum_id enum_id_from_bios_object_id(uint32_t bios_object_id)
60*b843c749SSergey Zigachev {
61*b843c749SSergey Zigachev uint32_t bios_enum_id =
62*b843c749SSergey Zigachev (bios_object_id & ENUM_ID_MASK) >> ENUM_ID_SHIFT;
63*b843c749SSergey Zigachev enum object_enum_id id;
64*b843c749SSergey Zigachev
65*b843c749SSergey Zigachev switch (bios_enum_id) {
66*b843c749SSergey Zigachev case GRAPH_OBJECT_ENUM_ID1:
67*b843c749SSergey Zigachev id = ENUM_ID_1;
68*b843c749SSergey Zigachev break;
69*b843c749SSergey Zigachev case GRAPH_OBJECT_ENUM_ID2:
70*b843c749SSergey Zigachev id = ENUM_ID_2;
71*b843c749SSergey Zigachev break;
72*b843c749SSergey Zigachev case GRAPH_OBJECT_ENUM_ID3:
73*b843c749SSergey Zigachev id = ENUM_ID_3;
74*b843c749SSergey Zigachev break;
75*b843c749SSergey Zigachev case GRAPH_OBJECT_ENUM_ID4:
76*b843c749SSergey Zigachev id = ENUM_ID_4;
77*b843c749SSergey Zigachev break;
78*b843c749SSergey Zigachev case GRAPH_OBJECT_ENUM_ID5:
79*b843c749SSergey Zigachev id = ENUM_ID_5;
80*b843c749SSergey Zigachev break;
81*b843c749SSergey Zigachev case GRAPH_OBJECT_ENUM_ID6:
82*b843c749SSergey Zigachev id = ENUM_ID_6;
83*b843c749SSergey Zigachev break;
84*b843c749SSergey Zigachev case GRAPH_OBJECT_ENUM_ID7:
85*b843c749SSergey Zigachev id = ENUM_ID_7;
86*b843c749SSergey Zigachev break;
87*b843c749SSergey Zigachev default:
88*b843c749SSergey Zigachev id = ENUM_ID_UNKNOWN;
89*b843c749SSergey Zigachev break;
90*b843c749SSergey Zigachev }
91*b843c749SSergey Zigachev
92*b843c749SSergey Zigachev return id;
93*b843c749SSergey Zigachev }
94*b843c749SSergey Zigachev
gpu_id_from_bios_object_id(uint32_t bios_object_id)95*b843c749SSergey Zigachev static uint32_t gpu_id_from_bios_object_id(uint32_t bios_object_id)
96*b843c749SSergey Zigachev {
97*b843c749SSergey Zigachev return (bios_object_id & OBJECT_ID_MASK) >> OBJECT_ID_SHIFT;
98*b843c749SSergey Zigachev }
99*b843c749SSergey Zigachev
encoder_id_from_bios_object_id(uint32_t bios_object_id)100*b843c749SSergey Zigachev static enum encoder_id encoder_id_from_bios_object_id(uint32_t bios_object_id)
101*b843c749SSergey Zigachev {
102*b843c749SSergey Zigachev uint32_t bios_encoder_id = gpu_id_from_bios_object_id(bios_object_id);
103*b843c749SSergey Zigachev enum encoder_id id;
104*b843c749SSergey Zigachev
105*b843c749SSergey Zigachev switch (bios_encoder_id) {
106*b843c749SSergey Zigachev case ENCODER_OBJECT_ID_INTERNAL_LVDS:
107*b843c749SSergey Zigachev id = ENCODER_ID_INTERNAL_LVDS;
108*b843c749SSergey Zigachev break;
109*b843c749SSergey Zigachev case ENCODER_OBJECT_ID_INTERNAL_TMDS1:
110*b843c749SSergey Zigachev id = ENCODER_ID_INTERNAL_TMDS1;
111*b843c749SSergey Zigachev break;
112*b843c749SSergey Zigachev case ENCODER_OBJECT_ID_INTERNAL_TMDS2:
113*b843c749SSergey Zigachev id = ENCODER_ID_INTERNAL_TMDS2;
114*b843c749SSergey Zigachev break;
115*b843c749SSergey Zigachev case ENCODER_OBJECT_ID_INTERNAL_DAC1:
116*b843c749SSergey Zigachev id = ENCODER_ID_INTERNAL_DAC1;
117*b843c749SSergey Zigachev break;
118*b843c749SSergey Zigachev case ENCODER_OBJECT_ID_INTERNAL_DAC2:
119*b843c749SSergey Zigachev id = ENCODER_ID_INTERNAL_DAC2;
120*b843c749SSergey Zigachev break;
121*b843c749SSergey Zigachev case ENCODER_OBJECT_ID_INTERNAL_LVTM1:
122*b843c749SSergey Zigachev id = ENCODER_ID_INTERNAL_LVTM1;
123*b843c749SSergey Zigachev break;
124*b843c749SSergey Zigachev case ENCODER_OBJECT_ID_HDMI_INTERNAL:
125*b843c749SSergey Zigachev id = ENCODER_ID_INTERNAL_HDMI;
126*b843c749SSergey Zigachev break;
127*b843c749SSergey Zigachev case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_TMDS1:
128*b843c749SSergey Zigachev id = ENCODER_ID_INTERNAL_KLDSCP_TMDS1;
129*b843c749SSergey Zigachev break;
130*b843c749SSergey Zigachev case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DAC1:
131*b843c749SSergey Zigachev id = ENCODER_ID_INTERNAL_KLDSCP_DAC1;
132*b843c749SSergey Zigachev break;
133*b843c749SSergey Zigachev case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DAC2:
134*b843c749SSergey Zigachev id = ENCODER_ID_INTERNAL_KLDSCP_DAC2;
135*b843c749SSergey Zigachev break;
136*b843c749SSergey Zigachev case ENCODER_OBJECT_ID_MVPU_FPGA:
137*b843c749SSergey Zigachev id = ENCODER_ID_EXTERNAL_MVPU_FPGA;
138*b843c749SSergey Zigachev break;
139*b843c749SSergey Zigachev case ENCODER_OBJECT_ID_INTERNAL_DDI:
140*b843c749SSergey Zigachev id = ENCODER_ID_INTERNAL_DDI;
141*b843c749SSergey Zigachev break;
142*b843c749SSergey Zigachev case ENCODER_OBJECT_ID_INTERNAL_UNIPHY:
143*b843c749SSergey Zigachev id = ENCODER_ID_INTERNAL_UNIPHY;
144*b843c749SSergey Zigachev break;
145*b843c749SSergey Zigachev case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_LVTMA:
146*b843c749SSergey Zigachev id = ENCODER_ID_INTERNAL_KLDSCP_LVTMA;
147*b843c749SSergey Zigachev break;
148*b843c749SSergey Zigachev case ENCODER_OBJECT_ID_INTERNAL_UNIPHY1:
149*b843c749SSergey Zigachev id = ENCODER_ID_INTERNAL_UNIPHY1;
150*b843c749SSergey Zigachev break;
151*b843c749SSergey Zigachev case ENCODER_OBJECT_ID_INTERNAL_UNIPHY2:
152*b843c749SSergey Zigachev id = ENCODER_ID_INTERNAL_UNIPHY2;
153*b843c749SSergey Zigachev break;
154*b843c749SSergey Zigachev case ENCODER_OBJECT_ID_ALMOND: /* ENCODER_OBJECT_ID_NUTMEG */
155*b843c749SSergey Zigachev id = ENCODER_ID_EXTERNAL_NUTMEG;
156*b843c749SSergey Zigachev break;
157*b843c749SSergey Zigachev case ENCODER_OBJECT_ID_TRAVIS:
158*b843c749SSergey Zigachev id = ENCODER_ID_EXTERNAL_TRAVIS;
159*b843c749SSergey Zigachev break;
160*b843c749SSergey Zigachev case ENCODER_OBJECT_ID_INTERNAL_UNIPHY3:
161*b843c749SSergey Zigachev id = ENCODER_ID_INTERNAL_UNIPHY3;
162*b843c749SSergey Zigachev break;
163*b843c749SSergey Zigachev default:
164*b843c749SSergey Zigachev id = ENCODER_ID_UNKNOWN;
165*b843c749SSergey Zigachev ASSERT(0);
166*b843c749SSergey Zigachev break;
167*b843c749SSergey Zigachev }
168*b843c749SSergey Zigachev
169*b843c749SSergey Zigachev return id;
170*b843c749SSergey Zigachev }
171*b843c749SSergey Zigachev
connector_id_from_bios_object_id(uint32_t bios_object_id)172*b843c749SSergey Zigachev static enum connector_id connector_id_from_bios_object_id(
173*b843c749SSergey Zigachev uint32_t bios_object_id)
174*b843c749SSergey Zigachev {
175*b843c749SSergey Zigachev uint32_t bios_connector_id = gpu_id_from_bios_object_id(bios_object_id);
176*b843c749SSergey Zigachev
177*b843c749SSergey Zigachev enum connector_id id;
178*b843c749SSergey Zigachev
179*b843c749SSergey Zigachev switch (bios_connector_id) {
180*b843c749SSergey Zigachev case CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I:
181*b843c749SSergey Zigachev id = CONNECTOR_ID_SINGLE_LINK_DVII;
182*b843c749SSergey Zigachev break;
183*b843c749SSergey Zigachev case CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I:
184*b843c749SSergey Zigachev id = CONNECTOR_ID_DUAL_LINK_DVII;
185*b843c749SSergey Zigachev break;
186*b843c749SSergey Zigachev case CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D:
187*b843c749SSergey Zigachev id = CONNECTOR_ID_SINGLE_LINK_DVID;
188*b843c749SSergey Zigachev break;
189*b843c749SSergey Zigachev case CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_D:
190*b843c749SSergey Zigachev id = CONNECTOR_ID_DUAL_LINK_DVID;
191*b843c749SSergey Zigachev break;
192*b843c749SSergey Zigachev case CONNECTOR_OBJECT_ID_VGA:
193*b843c749SSergey Zigachev id = CONNECTOR_ID_VGA;
194*b843c749SSergey Zigachev break;
195*b843c749SSergey Zigachev case CONNECTOR_OBJECT_ID_HDMI_TYPE_A:
196*b843c749SSergey Zigachev id = CONNECTOR_ID_HDMI_TYPE_A;
197*b843c749SSergey Zigachev break;
198*b843c749SSergey Zigachev case CONNECTOR_OBJECT_ID_LVDS:
199*b843c749SSergey Zigachev id = CONNECTOR_ID_LVDS;
200*b843c749SSergey Zigachev break;
201*b843c749SSergey Zigachev case CONNECTOR_OBJECT_ID_PCIE_CONNECTOR:
202*b843c749SSergey Zigachev id = CONNECTOR_ID_PCIE;
203*b843c749SSergey Zigachev break;
204*b843c749SSergey Zigachev case CONNECTOR_OBJECT_ID_HARDCODE_DVI:
205*b843c749SSergey Zigachev id = CONNECTOR_ID_HARDCODE_DVI;
206*b843c749SSergey Zigachev break;
207*b843c749SSergey Zigachev case CONNECTOR_OBJECT_ID_DISPLAYPORT:
208*b843c749SSergey Zigachev id = CONNECTOR_ID_DISPLAY_PORT;
209*b843c749SSergey Zigachev break;
210*b843c749SSergey Zigachev case CONNECTOR_OBJECT_ID_eDP:
211*b843c749SSergey Zigachev id = CONNECTOR_ID_EDP;
212*b843c749SSergey Zigachev break;
213*b843c749SSergey Zigachev case CONNECTOR_OBJECT_ID_MXM:
214*b843c749SSergey Zigachev id = CONNECTOR_ID_MXM;
215*b843c749SSergey Zigachev break;
216*b843c749SSergey Zigachev default:
217*b843c749SSergey Zigachev id = CONNECTOR_ID_UNKNOWN;
218*b843c749SSergey Zigachev break;
219*b843c749SSergey Zigachev }
220*b843c749SSergey Zigachev
221*b843c749SSergey Zigachev return id;
222*b843c749SSergey Zigachev }
223*b843c749SSergey Zigachev
generic_id_from_bios_object_id(uint32_t bios_object_id)224*b843c749SSergey Zigachev static enum generic_id generic_id_from_bios_object_id(uint32_t bios_object_id)
225*b843c749SSergey Zigachev {
226*b843c749SSergey Zigachev uint32_t bios_generic_id = gpu_id_from_bios_object_id(bios_object_id);
227*b843c749SSergey Zigachev
228*b843c749SSergey Zigachev enum generic_id id;
229*b843c749SSergey Zigachev
230*b843c749SSergey Zigachev switch (bios_generic_id) {
231*b843c749SSergey Zigachev case GENERIC_OBJECT_ID_MXM_OPM:
232*b843c749SSergey Zigachev id = GENERIC_ID_MXM_OPM;
233*b843c749SSergey Zigachev break;
234*b843c749SSergey Zigachev case GENERIC_OBJECT_ID_GLSYNC:
235*b843c749SSergey Zigachev id = GENERIC_ID_GLSYNC;
236*b843c749SSergey Zigachev break;
237*b843c749SSergey Zigachev case GENERIC_OBJECT_ID_STEREO_PIN:
238*b843c749SSergey Zigachev id = GENERIC_ID_STEREO;
239*b843c749SSergey Zigachev break;
240*b843c749SSergey Zigachev default:
241*b843c749SSergey Zigachev id = GENERIC_ID_UNKNOWN;
242*b843c749SSergey Zigachev break;
243*b843c749SSergey Zigachev }
244*b843c749SSergey Zigachev
245*b843c749SSergey Zigachev return id;
246*b843c749SSergey Zigachev }
247*b843c749SSergey Zigachev
id_from_bios_object_id(enum object_type type,uint32_t bios_object_id)248*b843c749SSergey Zigachev static uint32_t id_from_bios_object_id(enum object_type type,
249*b843c749SSergey Zigachev uint32_t bios_object_id)
250*b843c749SSergey Zigachev {
251*b843c749SSergey Zigachev switch (type) {
252*b843c749SSergey Zigachev case OBJECT_TYPE_GPU:
253*b843c749SSergey Zigachev return gpu_id_from_bios_object_id(bios_object_id);
254*b843c749SSergey Zigachev case OBJECT_TYPE_ENCODER:
255*b843c749SSergey Zigachev return (uint32_t)encoder_id_from_bios_object_id(bios_object_id);
256*b843c749SSergey Zigachev case OBJECT_TYPE_CONNECTOR:
257*b843c749SSergey Zigachev return (uint32_t)connector_id_from_bios_object_id(
258*b843c749SSergey Zigachev bios_object_id);
259*b843c749SSergey Zigachev case OBJECT_TYPE_GENERIC:
260*b843c749SSergey Zigachev return generic_id_from_bios_object_id(bios_object_id);
261*b843c749SSergey Zigachev default:
262*b843c749SSergey Zigachev return 0;
263*b843c749SSergey Zigachev }
264*b843c749SSergey Zigachev }
265*b843c749SSergey Zigachev
object_id_from_bios_object_id(uint32_t bios_object_id)266*b843c749SSergey Zigachev struct graphics_object_id object_id_from_bios_object_id(uint32_t bios_object_id)
267*b843c749SSergey Zigachev {
268*b843c749SSergey Zigachev enum object_type type;
269*b843c749SSergey Zigachev enum object_enum_id enum_id;
270*b843c749SSergey Zigachev struct graphics_object_id go_id = { 0 };
271*b843c749SSergey Zigachev
272*b843c749SSergey Zigachev type = object_type_from_bios_object_id(bios_object_id);
273*b843c749SSergey Zigachev
274*b843c749SSergey Zigachev if (OBJECT_TYPE_UNKNOWN == type)
275*b843c749SSergey Zigachev return go_id;
276*b843c749SSergey Zigachev
277*b843c749SSergey Zigachev enum_id = enum_id_from_bios_object_id(bios_object_id);
278*b843c749SSergey Zigachev
279*b843c749SSergey Zigachev if (ENUM_ID_UNKNOWN == enum_id)
280*b843c749SSergey Zigachev return go_id;
281*b843c749SSergey Zigachev
282*b843c749SSergey Zigachev go_id = dal_graphics_object_id_init(
283*b843c749SSergey Zigachev id_from_bios_object_id(type, bios_object_id), enum_id, type);
284*b843c749SSergey Zigachev
285*b843c749SSergey Zigachev return go_id;
286*b843c749SSergey Zigachev }
287*b843c749SSergey Zigachev
288*b843c749SSergey Zigachev
289