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 #ifndef __DAL_GRPH_OBJECT_ID_H__
27*b843c749SSergey Zigachev #define __DAL_GRPH_OBJECT_ID_H__
28*b843c749SSergey Zigachev
29*b843c749SSergey Zigachev /* Types of graphics objects */
30*b843c749SSergey Zigachev enum object_type {
31*b843c749SSergey Zigachev OBJECT_TYPE_UNKNOWN = 0,
32*b843c749SSergey Zigachev
33*b843c749SSergey Zigachev /* Direct ATOM BIOS translation */
34*b843c749SSergey Zigachev OBJECT_TYPE_GPU,
35*b843c749SSergey Zigachev OBJECT_TYPE_ENCODER,
36*b843c749SSergey Zigachev OBJECT_TYPE_CONNECTOR,
37*b843c749SSergey Zigachev OBJECT_TYPE_ROUTER,
38*b843c749SSergey Zigachev OBJECT_TYPE_GENERIC,
39*b843c749SSergey Zigachev
40*b843c749SSergey Zigachev /* Driver specific */
41*b843c749SSergey Zigachev OBJECT_TYPE_AUDIO,
42*b843c749SSergey Zigachev OBJECT_TYPE_CONTROLLER,
43*b843c749SSergey Zigachev OBJECT_TYPE_CLOCK_SOURCE,
44*b843c749SSergey Zigachev OBJECT_TYPE_ENGINE,
45*b843c749SSergey Zigachev
46*b843c749SSergey Zigachev OBJECT_TYPE_COUNT
47*b843c749SSergey Zigachev };
48*b843c749SSergey Zigachev
49*b843c749SSergey Zigachev /* Enumeration inside one type of graphics objects */
50*b843c749SSergey Zigachev enum object_enum_id {
51*b843c749SSergey Zigachev ENUM_ID_UNKNOWN = 0,
52*b843c749SSergey Zigachev ENUM_ID_1,
53*b843c749SSergey Zigachev ENUM_ID_2,
54*b843c749SSergey Zigachev ENUM_ID_3,
55*b843c749SSergey Zigachev ENUM_ID_4,
56*b843c749SSergey Zigachev ENUM_ID_5,
57*b843c749SSergey Zigachev ENUM_ID_6,
58*b843c749SSergey Zigachev ENUM_ID_7,
59*b843c749SSergey Zigachev
60*b843c749SSergey Zigachev ENUM_ID_COUNT
61*b843c749SSergey Zigachev };
62*b843c749SSergey Zigachev
63*b843c749SSergey Zigachev /* Generic object ids */
64*b843c749SSergey Zigachev enum generic_id {
65*b843c749SSergey Zigachev GENERIC_ID_UNKNOWN = 0,
66*b843c749SSergey Zigachev GENERIC_ID_MXM_OPM,
67*b843c749SSergey Zigachev GENERIC_ID_GLSYNC,
68*b843c749SSergey Zigachev GENERIC_ID_STEREO,
69*b843c749SSergey Zigachev
70*b843c749SSergey Zigachev GENERIC_ID_COUNT
71*b843c749SSergey Zigachev };
72*b843c749SSergey Zigachev
73*b843c749SSergey Zigachev /* Controller object ids */
74*b843c749SSergey Zigachev enum controller_id {
75*b843c749SSergey Zigachev CONTROLLER_ID_UNDEFINED = 0,
76*b843c749SSergey Zigachev CONTROLLER_ID_D0,
77*b843c749SSergey Zigachev CONTROLLER_ID_D1,
78*b843c749SSergey Zigachev CONTROLLER_ID_D2,
79*b843c749SSergey Zigachev CONTROLLER_ID_D3,
80*b843c749SSergey Zigachev CONTROLLER_ID_D4,
81*b843c749SSergey Zigachev CONTROLLER_ID_D5,
82*b843c749SSergey Zigachev CONTROLLER_ID_UNDERLAY0,
83*b843c749SSergey Zigachev CONTROLLER_ID_MAX = CONTROLLER_ID_UNDERLAY0
84*b843c749SSergey Zigachev };
85*b843c749SSergey Zigachev
86*b843c749SSergey Zigachev #define IS_UNDERLAY_CONTROLLER(ctrlr_id) (ctrlr_id >= CONTROLLER_ID_UNDERLAY0)
87*b843c749SSergey Zigachev
88*b843c749SSergey Zigachev /*
89*b843c749SSergey Zigachev * ClockSource object ids.
90*b843c749SSergey Zigachev * We maintain the order matching (more or less) ATOM BIOS
91*b843c749SSergey Zigachev * to improve optimized acquire
92*b843c749SSergey Zigachev */
93*b843c749SSergey Zigachev enum clock_source_id {
94*b843c749SSergey Zigachev CLOCK_SOURCE_ID_UNDEFINED = 0,
95*b843c749SSergey Zigachev CLOCK_SOURCE_ID_PLL0,
96*b843c749SSergey Zigachev CLOCK_SOURCE_ID_PLL1,
97*b843c749SSergey Zigachev CLOCK_SOURCE_ID_PLL2,
98*b843c749SSergey Zigachev CLOCK_SOURCE_ID_EXTERNAL, /* ID (Phy) ref. clk. for DP */
99*b843c749SSergey Zigachev CLOCK_SOURCE_ID_DCPLL,
100*b843c749SSergey Zigachev CLOCK_SOURCE_ID_DFS, /* DENTIST */
101*b843c749SSergey Zigachev CLOCK_SOURCE_ID_VCE, /* VCE does not need a real PLL */
102*b843c749SSergey Zigachev /* Used to distinguish between programming pixel clock and ID (Phy) clock */
103*b843c749SSergey Zigachev CLOCK_SOURCE_ID_DP_DTO,
104*b843c749SSergey Zigachev
105*b843c749SSergey Zigachev CLOCK_SOURCE_COMBO_PHY_PLL0, /*combo PHY PLL defines (DC 11.2 and up)*/
106*b843c749SSergey Zigachev CLOCK_SOURCE_COMBO_PHY_PLL1,
107*b843c749SSergey Zigachev CLOCK_SOURCE_COMBO_PHY_PLL2,
108*b843c749SSergey Zigachev CLOCK_SOURCE_COMBO_PHY_PLL3,
109*b843c749SSergey Zigachev CLOCK_SOURCE_COMBO_PHY_PLL4,
110*b843c749SSergey Zigachev CLOCK_SOURCE_COMBO_PHY_PLL5,
111*b843c749SSergey Zigachev CLOCK_SOURCE_COMBO_DISPLAY_PLL0
112*b843c749SSergey Zigachev };
113*b843c749SSergey Zigachev
114*b843c749SSergey Zigachev /* Encoder object ids */
115*b843c749SSergey Zigachev enum encoder_id {
116*b843c749SSergey Zigachev ENCODER_ID_UNKNOWN = 0,
117*b843c749SSergey Zigachev
118*b843c749SSergey Zigachev /* Radeon Class Display Hardware */
119*b843c749SSergey Zigachev ENCODER_ID_INTERNAL_LVDS,
120*b843c749SSergey Zigachev ENCODER_ID_INTERNAL_TMDS1,
121*b843c749SSergey Zigachev ENCODER_ID_INTERNAL_TMDS2,
122*b843c749SSergey Zigachev ENCODER_ID_INTERNAL_DAC1,
123*b843c749SSergey Zigachev ENCODER_ID_INTERNAL_DAC2, /* TV/CV DAC */
124*b843c749SSergey Zigachev
125*b843c749SSergey Zigachev /* External Third Party Encoders */
126*b843c749SSergey Zigachev ENCODER_ID_INTERNAL_LVTM1, /* not used for Radeon */
127*b843c749SSergey Zigachev ENCODER_ID_INTERNAL_HDMI,
128*b843c749SSergey Zigachev
129*b843c749SSergey Zigachev /* Kaledisope (KLDSCP) Class Display Hardware */
130*b843c749SSergey Zigachev ENCODER_ID_INTERNAL_KLDSCP_TMDS1,
131*b843c749SSergey Zigachev ENCODER_ID_INTERNAL_KLDSCP_DAC1,
132*b843c749SSergey Zigachev ENCODER_ID_INTERNAL_KLDSCP_DAC2, /* Shared with CV/TV and CRT */
133*b843c749SSergey Zigachev /* External TMDS (dual link) */
134*b843c749SSergey Zigachev ENCODER_ID_EXTERNAL_MVPU_FPGA, /* MVPU FPGA chip */
135*b843c749SSergey Zigachev ENCODER_ID_INTERNAL_DDI,
136*b843c749SSergey Zigachev ENCODER_ID_INTERNAL_UNIPHY,
137*b843c749SSergey Zigachev ENCODER_ID_INTERNAL_KLDSCP_LVTMA,
138*b843c749SSergey Zigachev ENCODER_ID_INTERNAL_UNIPHY1,
139*b843c749SSergey Zigachev ENCODER_ID_INTERNAL_UNIPHY2,
140*b843c749SSergey Zigachev ENCODER_ID_EXTERNAL_NUTMEG,
141*b843c749SSergey Zigachev ENCODER_ID_EXTERNAL_TRAVIS,
142*b843c749SSergey Zigachev
143*b843c749SSergey Zigachev ENCODER_ID_INTERNAL_WIRELESS, /* Internal wireless display encoder */
144*b843c749SSergey Zigachev ENCODER_ID_INTERNAL_UNIPHY3,
145*b843c749SSergey Zigachev ENCODER_ID_INTERNAL_VIRTUAL,
146*b843c749SSergey Zigachev };
147*b843c749SSergey Zigachev
148*b843c749SSergey Zigachev /* Connector object ids */
149*b843c749SSergey Zigachev enum connector_id {
150*b843c749SSergey Zigachev CONNECTOR_ID_UNKNOWN = 0,
151*b843c749SSergey Zigachev CONNECTOR_ID_SINGLE_LINK_DVII = 1,
152*b843c749SSergey Zigachev CONNECTOR_ID_DUAL_LINK_DVII = 2,
153*b843c749SSergey Zigachev CONNECTOR_ID_SINGLE_LINK_DVID = 3,
154*b843c749SSergey Zigachev CONNECTOR_ID_DUAL_LINK_DVID = 4,
155*b843c749SSergey Zigachev CONNECTOR_ID_VGA = 5,
156*b843c749SSergey Zigachev CONNECTOR_ID_HDMI_TYPE_A = 12,
157*b843c749SSergey Zigachev CONNECTOR_ID_LVDS = 14,
158*b843c749SSergey Zigachev CONNECTOR_ID_PCIE = 16,
159*b843c749SSergey Zigachev CONNECTOR_ID_HARDCODE_DVI = 18,
160*b843c749SSergey Zigachev CONNECTOR_ID_DISPLAY_PORT = 19,
161*b843c749SSergey Zigachev CONNECTOR_ID_EDP = 20,
162*b843c749SSergey Zigachev CONNECTOR_ID_MXM = 21,
163*b843c749SSergey Zigachev CONNECTOR_ID_WIRELESS = 22,
164*b843c749SSergey Zigachev CONNECTOR_ID_MIRACAST = 23,
165*b843c749SSergey Zigachev
166*b843c749SSergey Zigachev CONNECTOR_ID_VIRTUAL = 100
167*b843c749SSergey Zigachev };
168*b843c749SSergey Zigachev
169*b843c749SSergey Zigachev /* Audio object ids */
170*b843c749SSergey Zigachev enum audio_id {
171*b843c749SSergey Zigachev AUDIO_ID_UNKNOWN = 0,
172*b843c749SSergey Zigachev AUDIO_ID_INTERNAL_AZALIA
173*b843c749SSergey Zigachev };
174*b843c749SSergey Zigachev
175*b843c749SSergey Zigachev /* Engine object ids */
176*b843c749SSergey Zigachev enum engine_id {
177*b843c749SSergey Zigachev ENGINE_ID_DIGA,
178*b843c749SSergey Zigachev ENGINE_ID_DIGB,
179*b843c749SSergey Zigachev ENGINE_ID_DIGC,
180*b843c749SSergey Zigachev ENGINE_ID_DIGD,
181*b843c749SSergey Zigachev ENGINE_ID_DIGE,
182*b843c749SSergey Zigachev ENGINE_ID_DIGF,
183*b843c749SSergey Zigachev ENGINE_ID_DIGG,
184*b843c749SSergey Zigachev ENGINE_ID_DACA,
185*b843c749SSergey Zigachev ENGINE_ID_DACB,
186*b843c749SSergey Zigachev ENGINE_ID_VCE, /* wireless display pseudo-encoder */
187*b843c749SSergey Zigachev ENGINE_ID_VIRTUAL,
188*b843c749SSergey Zigachev
189*b843c749SSergey Zigachev ENGINE_ID_COUNT,
190*b843c749SSergey Zigachev ENGINE_ID_UNKNOWN = (-1L)
191*b843c749SSergey Zigachev };
192*b843c749SSergey Zigachev
193*b843c749SSergey Zigachev enum transmitter_color_depth {
194*b843c749SSergey Zigachev TRANSMITTER_COLOR_DEPTH_24 = 0, /* 8 bits */
195*b843c749SSergey Zigachev TRANSMITTER_COLOR_DEPTH_30, /* 10 bits */
196*b843c749SSergey Zigachev TRANSMITTER_COLOR_DEPTH_36, /* 12 bits */
197*b843c749SSergey Zigachev TRANSMITTER_COLOR_DEPTH_48 /* 16 bits */
198*b843c749SSergey Zigachev };
199*b843c749SSergey Zigachev
200*b843c749SSergey Zigachev enum dp_alt_mode {
201*b843c749SSergey Zigachev DP_Alt_mode__Unknown = 0,
202*b843c749SSergey Zigachev DP_Alt_mode__Connect,
203*b843c749SSergey Zigachev DP_Alt_mode__NoConnect,
204*b843c749SSergey Zigachev };
205*b843c749SSergey Zigachev /*
206*b843c749SSergey Zigachev *****************************************************************************
207*b843c749SSergey Zigachev * graphics_object_id struct
208*b843c749SSergey Zigachev *
209*b843c749SSergey Zigachev * graphics_object_id is a very simple struct wrapping 32bit Graphics
210*b843c749SSergey Zigachev * Object identication
211*b843c749SSergey Zigachev *
212*b843c749SSergey Zigachev * This struct should stay very simple
213*b843c749SSergey Zigachev * No dependencies at all (no includes)
214*b843c749SSergey Zigachev * No debug messages or asserts
215*b843c749SSergey Zigachev * No #ifndef and preprocessor directives
216*b843c749SSergey Zigachev * No grow in space (no more data member)
217*b843c749SSergey Zigachev *****************************************************************************
218*b843c749SSergey Zigachev */
219*b843c749SSergey Zigachev
220*b843c749SSergey Zigachev struct graphics_object_id {
221*b843c749SSergey Zigachev uint32_t id:8;
222*b843c749SSergey Zigachev uint32_t enum_id:4;
223*b843c749SSergey Zigachev uint32_t type:4;
224*b843c749SSergey Zigachev uint32_t reserved:16; /* for padding. total size should be u32 */
225*b843c749SSergey Zigachev };
226*b843c749SSergey Zigachev
227*b843c749SSergey Zigachev /* some simple functions for convenient graphics_object_id handle */
228*b843c749SSergey Zigachev
dal_graphics_object_id_init(uint32_t id,enum object_enum_id enum_id,enum object_type type)229*b843c749SSergey Zigachev static inline struct graphics_object_id dal_graphics_object_id_init(
230*b843c749SSergey Zigachev uint32_t id,
231*b843c749SSergey Zigachev enum object_enum_id enum_id,
232*b843c749SSergey Zigachev enum object_type type)
233*b843c749SSergey Zigachev {
234*b843c749SSergey Zigachev struct graphics_object_id result = {
235*b843c749SSergey Zigachev id, enum_id, type, 0
236*b843c749SSergey Zigachev };
237*b843c749SSergey Zigachev
238*b843c749SSergey Zigachev return result;
239*b843c749SSergey Zigachev }
240*b843c749SSergey Zigachev
241*b843c749SSergey Zigachev /* Based on internal data members memory layout */
dal_graphics_object_id_to_uint(struct graphics_object_id id)242*b843c749SSergey Zigachev static inline uint32_t dal_graphics_object_id_to_uint(
243*b843c749SSergey Zigachev struct graphics_object_id id)
244*b843c749SSergey Zigachev {
245*b843c749SSergey Zigachev return id.id + (id.enum_id << 0x8) + (id.type << 0xc);
246*b843c749SSergey Zigachev }
247*b843c749SSergey Zigachev
dal_graphics_object_id_get_controller_id(struct graphics_object_id id)248*b843c749SSergey Zigachev static inline enum controller_id dal_graphics_object_id_get_controller_id(
249*b843c749SSergey Zigachev struct graphics_object_id id)
250*b843c749SSergey Zigachev {
251*b843c749SSergey Zigachev if (id.type == OBJECT_TYPE_CONTROLLER)
252*b843c749SSergey Zigachev return (enum controller_id) id.id;
253*b843c749SSergey Zigachev return CONTROLLER_ID_UNDEFINED;
254*b843c749SSergey Zigachev }
255*b843c749SSergey Zigachev
dal_graphics_object_id_get_clock_source_id(struct graphics_object_id id)256*b843c749SSergey Zigachev static inline enum clock_source_id dal_graphics_object_id_get_clock_source_id(
257*b843c749SSergey Zigachev struct graphics_object_id id)
258*b843c749SSergey Zigachev {
259*b843c749SSergey Zigachev if (id.type == OBJECT_TYPE_CLOCK_SOURCE)
260*b843c749SSergey Zigachev return (enum clock_source_id) id.id;
261*b843c749SSergey Zigachev return CLOCK_SOURCE_ID_UNDEFINED;
262*b843c749SSergey Zigachev }
263*b843c749SSergey Zigachev
dal_graphics_object_id_get_encoder_id(struct graphics_object_id id)264*b843c749SSergey Zigachev static inline enum encoder_id dal_graphics_object_id_get_encoder_id(
265*b843c749SSergey Zigachev struct graphics_object_id id)
266*b843c749SSergey Zigachev {
267*b843c749SSergey Zigachev if (id.type == OBJECT_TYPE_ENCODER)
268*b843c749SSergey Zigachev return (enum encoder_id) id.id;
269*b843c749SSergey Zigachev return ENCODER_ID_UNKNOWN;
270*b843c749SSergey Zigachev }
271*b843c749SSergey Zigachev
dal_graphics_object_id_get_connector_id(struct graphics_object_id id)272*b843c749SSergey Zigachev static inline enum connector_id dal_graphics_object_id_get_connector_id(
273*b843c749SSergey Zigachev struct graphics_object_id id)
274*b843c749SSergey Zigachev {
275*b843c749SSergey Zigachev if (id.type == OBJECT_TYPE_CONNECTOR)
276*b843c749SSergey Zigachev return (enum connector_id) id.id;
277*b843c749SSergey Zigachev return CONNECTOR_ID_UNKNOWN;
278*b843c749SSergey Zigachev }
279*b843c749SSergey Zigachev
dal_graphics_object_id_get_audio_id(struct graphics_object_id id)280*b843c749SSergey Zigachev static inline enum audio_id dal_graphics_object_id_get_audio_id(
281*b843c749SSergey Zigachev struct graphics_object_id id)
282*b843c749SSergey Zigachev {
283*b843c749SSergey Zigachev if (id.type == OBJECT_TYPE_AUDIO)
284*b843c749SSergey Zigachev return (enum audio_id) id.id;
285*b843c749SSergey Zigachev return AUDIO_ID_UNKNOWN;
286*b843c749SSergey Zigachev }
287*b843c749SSergey Zigachev
dal_graphics_object_id_get_engine_id(struct graphics_object_id id)288*b843c749SSergey Zigachev static inline enum engine_id dal_graphics_object_id_get_engine_id(
289*b843c749SSergey Zigachev struct graphics_object_id id)
290*b843c749SSergey Zigachev {
291*b843c749SSergey Zigachev if (id.type == OBJECT_TYPE_ENGINE)
292*b843c749SSergey Zigachev return (enum engine_id) id.id;
293*b843c749SSergey Zigachev return ENGINE_ID_UNKNOWN;
294*b843c749SSergey Zigachev }
295*b843c749SSergey Zigachev
dal_graphics_object_id_equal(struct graphics_object_id id_1,struct graphics_object_id id_2)296*b843c749SSergey Zigachev static inline bool dal_graphics_object_id_equal(
297*b843c749SSergey Zigachev struct graphics_object_id id_1,
298*b843c749SSergey Zigachev struct graphics_object_id id_2)
299*b843c749SSergey Zigachev {
300*b843c749SSergey Zigachev if ((id_1.id == id_2.id) && (id_1.enum_id == id_2.enum_id) &&
301*b843c749SSergey Zigachev (id_1.type == id_2.type)) {
302*b843c749SSergey Zigachev return true;
303*b843c749SSergey Zigachev }
304*b843c749SSergey Zigachev return false;
305*b843c749SSergey Zigachev }
306*b843c749SSergey Zigachev #endif
307