2 * Copyright 2012-15 Advanced Micro Devices, Inc.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
26 #include "bios_parser_common.h"
27 #include "include/grph_object_ctrl_defs.h"
29 static enum object_type
object_type_from_bios_object_id(uint32_t bios_object_id
)
31 uint32_t bios_object_type
= (bios_object_id
& OBJECT_TYPE_MASK
)
33 enum object_type object_type
;
35 switch (bios_object_type
) {
36 case GRAPH_OBJECT_TYPE_GPU
:
37 object_type
= OBJECT_TYPE_GPU
;
39 case GRAPH_OBJECT_TYPE_ENCODER
:
40 object_type
= OBJECT_TYPE_ENCODER
;
42 case GRAPH_OBJECT_TYPE_CONNECTOR
:
43 object_type
= OBJECT_TYPE_CONNECTOR
;
45 case GRAPH_OBJECT_TYPE_ROUTER
:
46 object_type
= OBJECT_TYPE_ROUTER
;
48 case GRAPH_OBJECT_TYPE_GENERIC
:
49 object_type
= OBJECT_TYPE_GENERIC
;
52 object_type
= OBJECT_TYPE_UNKNOWN
;
59 static enum object_enum_id
enum_id_from_bios_object_id(uint32_t bios_object_id
)
61 uint32_t bios_enum_id
=
62 (bios_object_id
& ENUM_ID_MASK
) >> ENUM_ID_SHIFT
;
63 enum object_enum_id id
;
65 switch (bios_enum_id
) {
66 case GRAPH_OBJECT_ENUM_ID1
:
69 case GRAPH_OBJECT_ENUM_ID2
:
72 case GRAPH_OBJECT_ENUM_ID3
:
75 case GRAPH_OBJECT_ENUM_ID4
:
78 case GRAPH_OBJECT_ENUM_ID5
:
81 case GRAPH_OBJECT_ENUM_ID6
:
84 case GRAPH_OBJECT_ENUM_ID7
:
95 static uint32_t gpu_id_from_bios_object_id(uint32_t bios_object_id
)
97 return (bios_object_id
& OBJECT_ID_MASK
) >> OBJECT_ID_SHIFT
;
100 static enum encoder_id
encoder_id_from_bios_object_id(uint32_t bios_object_id
)
102 uint32_t bios_encoder_id
= gpu_id_from_bios_object_id(bios_object_id
);
105 switch (bios_encoder_id
) {
106 case ENCODER_OBJECT_ID_INTERNAL_LVDS
:
107 id
= ENCODER_ID_INTERNAL_LVDS
;
109 case ENCODER_OBJECT_ID_INTERNAL_TMDS1
:
110 id
= ENCODER_ID_INTERNAL_TMDS1
;
112 case ENCODER_OBJECT_ID_INTERNAL_TMDS2
:
113 id
= ENCODER_ID_INTERNAL_TMDS2
;
115 case ENCODER_OBJECT_ID_INTERNAL_DAC1
:
116 id
= ENCODER_ID_INTERNAL_DAC1
;
118 case ENCODER_OBJECT_ID_INTERNAL_DAC2
:
119 id
= ENCODER_ID_INTERNAL_DAC2
;
121 case ENCODER_OBJECT_ID_INTERNAL_LVTM1
:
122 id
= ENCODER_ID_INTERNAL_LVTM1
;
124 case ENCODER_OBJECT_ID_HDMI_INTERNAL
:
125 id
= ENCODER_ID_INTERNAL_HDMI
;
127 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_TMDS1
:
128 id
= ENCODER_ID_INTERNAL_KLDSCP_TMDS1
;
130 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DAC1
:
131 id
= ENCODER_ID_INTERNAL_KLDSCP_DAC1
;
133 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DAC2
:
134 id
= ENCODER_ID_INTERNAL_KLDSCP_DAC2
;
136 case ENCODER_OBJECT_ID_MVPU_FPGA
:
137 id
= ENCODER_ID_EXTERNAL_MVPU_FPGA
;
139 case ENCODER_OBJECT_ID_INTERNAL_DDI
:
140 id
= ENCODER_ID_INTERNAL_DDI
;
142 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY
:
143 id
= ENCODER_ID_INTERNAL_UNIPHY
;
145 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_LVTMA
:
146 id
= ENCODER_ID_INTERNAL_KLDSCP_LVTMA
;
148 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY1
:
149 id
= ENCODER_ID_INTERNAL_UNIPHY1
;
151 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY2
:
152 id
= ENCODER_ID_INTERNAL_UNIPHY2
;
154 case ENCODER_OBJECT_ID_ALMOND
: /* ENCODER_OBJECT_ID_NUTMEG */
155 id
= ENCODER_ID_EXTERNAL_NUTMEG
;
157 case ENCODER_OBJECT_ID_TRAVIS
:
158 id
= ENCODER_ID_EXTERNAL_TRAVIS
;
160 case ENCODER_OBJECT_ID_INTERNAL_UNIPHY3
:
161 id
= ENCODER_ID_INTERNAL_UNIPHY3
;
164 id
= ENCODER_ID_UNKNOWN
;
172 static enum connector_id
connector_id_from_bios_object_id(
173 uint32_t bios_object_id
)
175 uint32_t bios_connector_id
= gpu_id_from_bios_object_id(bios_object_id
);
177 enum connector_id id
;
179 switch (bios_connector_id
) {
180 case CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_I
:
181 id
= CONNECTOR_ID_SINGLE_LINK_DVII
;
183 case CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_I
:
184 id
= CONNECTOR_ID_DUAL_LINK_DVII
;
186 case CONNECTOR_OBJECT_ID_SINGLE_LINK_DVI_D
:
187 id
= CONNECTOR_ID_SINGLE_LINK_DVID
;
189 case CONNECTOR_OBJECT_ID_DUAL_LINK_DVI_D
:
190 id
= CONNECTOR_ID_DUAL_LINK_DVID
;
192 case CONNECTOR_OBJECT_ID_VGA
:
193 id
= CONNECTOR_ID_VGA
;
195 case CONNECTOR_OBJECT_ID_HDMI_TYPE_A
:
196 id
= CONNECTOR_ID_HDMI_TYPE_A
;
198 case CONNECTOR_OBJECT_ID_LVDS
:
199 id
= CONNECTOR_ID_LVDS
;
201 case CONNECTOR_OBJECT_ID_PCIE_CONNECTOR
:
202 id
= CONNECTOR_ID_PCIE
;
204 case CONNECTOR_OBJECT_ID_HARDCODE_DVI
:
205 id
= CONNECTOR_ID_HARDCODE_DVI
;
207 case CONNECTOR_OBJECT_ID_DISPLAYPORT
:
208 id
= CONNECTOR_ID_DISPLAY_PORT
;
210 case CONNECTOR_OBJECT_ID_eDP
:
211 id
= CONNECTOR_ID_EDP
;
213 case CONNECTOR_OBJECT_ID_MXM
:
214 id
= CONNECTOR_ID_MXM
;
217 id
= CONNECTOR_ID_UNKNOWN
;
224 static enum generic_id
generic_id_from_bios_object_id(uint32_t bios_object_id
)
226 uint32_t bios_generic_id
= gpu_id_from_bios_object_id(bios_object_id
);
230 switch (bios_generic_id
) {
231 case GENERIC_OBJECT_ID_MXM_OPM
:
232 id
= GENERIC_ID_MXM_OPM
;
234 case GENERIC_OBJECT_ID_GLSYNC
:
235 id
= GENERIC_ID_GLSYNC
;
237 case GENERIC_OBJECT_ID_STEREO_PIN
:
238 id
= GENERIC_ID_STEREO
;
241 id
= GENERIC_ID_UNKNOWN
;
248 static uint32_t id_from_bios_object_id(enum object_type type
,
249 uint32_t bios_object_id
)
252 case OBJECT_TYPE_GPU
:
253 return gpu_id_from_bios_object_id(bios_object_id
);
254 case OBJECT_TYPE_ENCODER
:
255 return (uint32_t)encoder_id_from_bios_object_id(bios_object_id
);
256 case OBJECT_TYPE_CONNECTOR
:
257 return (uint32_t)connector_id_from_bios_object_id(
259 case OBJECT_TYPE_GENERIC
:
260 return generic_id_from_bios_object_id(bios_object_id
);
266 struct graphics_object_id
object_id_from_bios_object_id(uint32_t bios_object_id
)
268 enum object_type type
;
269 enum object_enum_id enum_id
;
270 struct graphics_object_id go_id
= { 0 };
272 type
= object_type_from_bios_object_id(bios_object_id
);
274 if (OBJECT_TYPE_UNKNOWN
== type
)
277 enum_id
= enum_id_from_bios_object_id(bios_object_id
);
279 if (ENUM_ID_UNKNOWN
== enum_id
)
282 go_id
= dal_graphics_object_id_init(
283 id_from_bios_object_id(type
, bios_object_id
), enum_id
, type
);