14562236bSHarry Wentland /*
24562236bSHarry Wentland * Copyright 2012-15 Advanced Micro Devices, Inc.
34562236bSHarry Wentland *
44562236bSHarry Wentland * Permission is hereby granted, free of charge, to any person obtaining a
54562236bSHarry Wentland * copy of this software and associated documentation files (the "Software"),
64562236bSHarry Wentland * to deal in the Software without restriction, including without limitation
74562236bSHarry Wentland * the rights to use, copy, modify, merge, publish, distribute, sublicense,
84562236bSHarry Wentland * and/or sell copies of the Software, and to permit persons to whom the
94562236bSHarry Wentland * Software is furnished to do so, subject to the following conditions:
104562236bSHarry Wentland *
114562236bSHarry Wentland * The above copyright notice and this permission notice shall be included in
124562236bSHarry Wentland * all copies or substantial portions of the Software.
134562236bSHarry Wentland *
144562236bSHarry Wentland * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
154562236bSHarry Wentland * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
164562236bSHarry Wentland * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
174562236bSHarry Wentland * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
184562236bSHarry Wentland * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
194562236bSHarry Wentland * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
204562236bSHarry Wentland * OTHER DEALINGS IN THE SOFTWARE.
214562236bSHarry Wentland *
224562236bSHarry Wentland * Authors: AMD
234562236bSHarry Wentland *
244562236bSHarry Wentland */
254562236bSHarry Wentland
264562236bSHarry Wentland #ifndef __DAL_GRPH_OBJECT_ID_H__
274562236bSHarry Wentland #define __DAL_GRPH_OBJECT_ID_H__
284562236bSHarry Wentland
294562236bSHarry Wentland /* Types of graphics objects */
304562236bSHarry Wentland enum object_type {
314562236bSHarry Wentland OBJECT_TYPE_UNKNOWN = 0,
324562236bSHarry Wentland
334562236bSHarry Wentland /* Direct ATOM BIOS translation */
344562236bSHarry Wentland OBJECT_TYPE_GPU,
354562236bSHarry Wentland OBJECT_TYPE_ENCODER,
364562236bSHarry Wentland OBJECT_TYPE_CONNECTOR,
374562236bSHarry Wentland OBJECT_TYPE_ROUTER,
384562236bSHarry Wentland OBJECT_TYPE_GENERIC,
394562236bSHarry Wentland
404562236bSHarry Wentland /* Driver specific */
414562236bSHarry Wentland OBJECT_TYPE_AUDIO,
424562236bSHarry Wentland OBJECT_TYPE_CONTROLLER,
434562236bSHarry Wentland OBJECT_TYPE_CLOCK_SOURCE,
444562236bSHarry Wentland OBJECT_TYPE_ENGINE,
454562236bSHarry Wentland
464562236bSHarry Wentland OBJECT_TYPE_COUNT
474562236bSHarry Wentland };
484562236bSHarry Wentland
494562236bSHarry Wentland /* Enumeration inside one type of graphics objects */
504562236bSHarry Wentland enum object_enum_id {
514562236bSHarry Wentland ENUM_ID_UNKNOWN = 0,
524562236bSHarry Wentland ENUM_ID_1,
534562236bSHarry Wentland ENUM_ID_2,
544562236bSHarry Wentland ENUM_ID_3,
554562236bSHarry Wentland ENUM_ID_4,
564562236bSHarry Wentland ENUM_ID_5,
574562236bSHarry Wentland ENUM_ID_6,
584562236bSHarry Wentland ENUM_ID_7,
594562236bSHarry Wentland
604562236bSHarry Wentland ENUM_ID_COUNT
614562236bSHarry Wentland };
624562236bSHarry Wentland
634562236bSHarry Wentland /* Generic object ids */
644562236bSHarry Wentland enum generic_id {
654562236bSHarry Wentland GENERIC_ID_UNKNOWN = 0,
664562236bSHarry Wentland GENERIC_ID_MXM_OPM,
674562236bSHarry Wentland GENERIC_ID_GLSYNC,
684562236bSHarry Wentland GENERIC_ID_STEREO,
694562236bSHarry Wentland
704562236bSHarry Wentland GENERIC_ID_COUNT
714562236bSHarry Wentland };
724562236bSHarry Wentland
734562236bSHarry Wentland /* Controller object ids */
744562236bSHarry Wentland enum controller_id {
754562236bSHarry Wentland CONTROLLER_ID_UNDEFINED = 0,
764562236bSHarry Wentland CONTROLLER_ID_D0,
774562236bSHarry Wentland CONTROLLER_ID_D1,
784562236bSHarry Wentland CONTROLLER_ID_D2,
794562236bSHarry Wentland CONTROLLER_ID_D3,
804562236bSHarry Wentland CONTROLLER_ID_D4,
814562236bSHarry Wentland CONTROLLER_ID_D5,
824562236bSHarry Wentland CONTROLLER_ID_UNDERLAY0,
834562236bSHarry Wentland CONTROLLER_ID_MAX = CONTROLLER_ID_UNDERLAY0
844562236bSHarry Wentland };
854562236bSHarry Wentland
864562236bSHarry Wentland #define IS_UNDERLAY_CONTROLLER(ctrlr_id) (ctrlr_id >= CONTROLLER_ID_UNDERLAY0)
874562236bSHarry Wentland
884562236bSHarry Wentland /*
894562236bSHarry Wentland * ClockSource object ids.
904562236bSHarry Wentland * We maintain the order matching (more or less) ATOM BIOS
914562236bSHarry Wentland * to improve optimized acquire
924562236bSHarry Wentland */
934562236bSHarry Wentland enum clock_source_id {
944562236bSHarry Wentland CLOCK_SOURCE_ID_UNDEFINED = 0,
954562236bSHarry Wentland CLOCK_SOURCE_ID_PLL0,
964562236bSHarry Wentland CLOCK_SOURCE_ID_PLL1,
974562236bSHarry Wentland CLOCK_SOURCE_ID_PLL2,
984562236bSHarry Wentland CLOCK_SOURCE_ID_EXTERNAL, /* ID (Phy) ref. clk. for DP */
994562236bSHarry Wentland CLOCK_SOURCE_ID_DCPLL,
1004562236bSHarry Wentland CLOCK_SOURCE_ID_DFS, /* DENTIST */
1014562236bSHarry Wentland CLOCK_SOURCE_ID_VCE, /* VCE does not need a real PLL */
1024562236bSHarry Wentland /* Used to distinguish between programming pixel clock and ID (Phy) clock */
1034562236bSHarry Wentland CLOCK_SOURCE_ID_DP_DTO,
1044562236bSHarry Wentland
1054562236bSHarry Wentland CLOCK_SOURCE_COMBO_PHY_PLL0, /*combo PHY PLL defines (DC 11.2 and up)*/
1064562236bSHarry Wentland CLOCK_SOURCE_COMBO_PHY_PLL1,
1074562236bSHarry Wentland CLOCK_SOURCE_COMBO_PHY_PLL2,
1084562236bSHarry Wentland CLOCK_SOURCE_COMBO_PHY_PLL3,
1094562236bSHarry Wentland CLOCK_SOURCE_COMBO_PHY_PLL4,
1104562236bSHarry Wentland CLOCK_SOURCE_COMBO_PHY_PLL5,
1114562236bSHarry Wentland CLOCK_SOURCE_COMBO_DISPLAY_PLL0
1124562236bSHarry Wentland };
1134562236bSHarry Wentland
1144562236bSHarry Wentland /* Encoder object ids */
1154562236bSHarry Wentland enum encoder_id {
1164562236bSHarry Wentland ENCODER_ID_UNKNOWN = 0,
1174562236bSHarry Wentland
1184562236bSHarry Wentland /* Radeon Class Display Hardware */
1194562236bSHarry Wentland ENCODER_ID_INTERNAL_LVDS,
1204562236bSHarry Wentland ENCODER_ID_INTERNAL_TMDS1,
1214562236bSHarry Wentland ENCODER_ID_INTERNAL_TMDS2,
1224562236bSHarry Wentland ENCODER_ID_INTERNAL_DAC1,
1234562236bSHarry Wentland ENCODER_ID_INTERNAL_DAC2, /* TV/CV DAC */
1244562236bSHarry Wentland
1254562236bSHarry Wentland /* External Third Party Encoders */
1264562236bSHarry Wentland ENCODER_ID_INTERNAL_LVTM1, /* not used for Radeon */
1274562236bSHarry Wentland ENCODER_ID_INTERNAL_HDMI,
1284562236bSHarry Wentland
1294562236bSHarry Wentland /* Kaledisope (KLDSCP) Class Display Hardware */
1304562236bSHarry Wentland ENCODER_ID_INTERNAL_KLDSCP_TMDS1,
1314562236bSHarry Wentland ENCODER_ID_INTERNAL_KLDSCP_DAC1,
1324562236bSHarry Wentland ENCODER_ID_INTERNAL_KLDSCP_DAC2, /* Shared with CV/TV and CRT */
1334562236bSHarry Wentland /* External TMDS (dual link) */
1344562236bSHarry Wentland ENCODER_ID_EXTERNAL_MVPU_FPGA, /* MVPU FPGA chip */
1354562236bSHarry Wentland ENCODER_ID_INTERNAL_DDI,
1364562236bSHarry Wentland ENCODER_ID_INTERNAL_UNIPHY,
1374562236bSHarry Wentland ENCODER_ID_INTERNAL_KLDSCP_LVTMA,
1384562236bSHarry Wentland ENCODER_ID_INTERNAL_UNIPHY1,
1394562236bSHarry Wentland ENCODER_ID_INTERNAL_UNIPHY2,
1404562236bSHarry Wentland ENCODER_ID_EXTERNAL_NUTMEG,
1414562236bSHarry Wentland ENCODER_ID_EXTERNAL_TRAVIS,
1424562236bSHarry Wentland
1434562236bSHarry Wentland ENCODER_ID_INTERNAL_WIRELESS, /* Internal wireless display encoder */
1444562236bSHarry Wentland ENCODER_ID_INTERNAL_UNIPHY3,
1454562236bSHarry Wentland ENCODER_ID_INTERNAL_VIRTUAL,
1464562236bSHarry Wentland };
1474562236bSHarry Wentland
1484562236bSHarry Wentland /* Connector object ids */
1494562236bSHarry Wentland enum connector_id {
1504562236bSHarry Wentland CONNECTOR_ID_UNKNOWN = 0,
1514562236bSHarry Wentland CONNECTOR_ID_SINGLE_LINK_DVII = 1,
1524562236bSHarry Wentland CONNECTOR_ID_DUAL_LINK_DVII = 2,
1534562236bSHarry Wentland CONNECTOR_ID_SINGLE_LINK_DVID = 3,
1544562236bSHarry Wentland CONNECTOR_ID_DUAL_LINK_DVID = 4,
1554562236bSHarry Wentland CONNECTOR_ID_VGA = 5,
1564562236bSHarry Wentland CONNECTOR_ID_HDMI_TYPE_A = 12,
1574562236bSHarry Wentland CONNECTOR_ID_LVDS = 14,
1584562236bSHarry Wentland CONNECTOR_ID_PCIE = 16,
1594562236bSHarry Wentland CONNECTOR_ID_HARDCODE_DVI = 18,
1604562236bSHarry Wentland CONNECTOR_ID_DISPLAY_PORT = 19,
1614562236bSHarry Wentland CONNECTOR_ID_EDP = 20,
1624562236bSHarry Wentland CONNECTOR_ID_MXM = 21,
1634562236bSHarry Wentland CONNECTOR_ID_WIRELESS = 22,
1644562236bSHarry Wentland CONNECTOR_ID_MIRACAST = 23,
1658cb3c169SSamson Tam CONNECTOR_ID_USBC = 24,
1664562236bSHarry Wentland
1674562236bSHarry Wentland CONNECTOR_ID_VIRTUAL = 100
1684562236bSHarry Wentland };
1694562236bSHarry Wentland
1704562236bSHarry Wentland /* Audio object ids */
1714562236bSHarry Wentland enum audio_id {
1724562236bSHarry Wentland AUDIO_ID_UNKNOWN = 0,
1734562236bSHarry Wentland AUDIO_ID_INTERNAL_AZALIA
1744562236bSHarry Wentland };
1754562236bSHarry Wentland
1764562236bSHarry Wentland /* Engine object ids */
1774562236bSHarry Wentland enum engine_id {
1784562236bSHarry Wentland ENGINE_ID_DIGA,
1794562236bSHarry Wentland ENGINE_ID_DIGB,
1804562236bSHarry Wentland ENGINE_ID_DIGC,
1814562236bSHarry Wentland ENGINE_ID_DIGD,
1824562236bSHarry Wentland ENGINE_ID_DIGE,
1834562236bSHarry Wentland ENGINE_ID_DIGF,
1844562236bSHarry Wentland ENGINE_ID_DIGG,
1854562236bSHarry Wentland ENGINE_ID_DACA,
1864562236bSHarry Wentland ENGINE_ID_DACB,
1874562236bSHarry Wentland ENGINE_ID_VCE, /* wireless display pseudo-encoder */
18883228ebbSFangzhi Zuo ENGINE_ID_HPO_0,
18983228ebbSFangzhi Zuo ENGINE_ID_HPO_1,
19083228ebbSFangzhi Zuo ENGINE_ID_HPO_DP_0,
19183228ebbSFangzhi Zuo ENGINE_ID_HPO_DP_1,
19283228ebbSFangzhi Zuo ENGINE_ID_HPO_DP_2,
19383228ebbSFangzhi Zuo ENGINE_ID_HPO_DP_3,
1944562236bSHarry Wentland ENGINE_ID_VIRTUAL,
1954562236bSHarry Wentland
1964562236bSHarry Wentland ENGINE_ID_COUNT,
1974562236bSHarry Wentland ENGINE_ID_UNKNOWN = (-1L)
1984562236bSHarry Wentland };
1994562236bSHarry Wentland
2004562236bSHarry Wentland enum transmitter_color_depth {
2014562236bSHarry Wentland TRANSMITTER_COLOR_DEPTH_24 = 0, /* 8 bits */
2024562236bSHarry Wentland TRANSMITTER_COLOR_DEPTH_30, /* 10 bits */
2034562236bSHarry Wentland TRANSMITTER_COLOR_DEPTH_36, /* 12 bits */
2044562236bSHarry Wentland TRANSMITTER_COLOR_DEPTH_48 /* 16 bits */
2054562236bSHarry Wentland };
2064562236bSHarry Wentland
2077e17cb4bSCharlene Liu enum dp_alt_mode {
2087e17cb4bSCharlene Liu DP_Alt_mode__Unknown = 0,
2097e17cb4bSCharlene Liu DP_Alt_mode__Connect,
2107e17cb4bSCharlene Liu DP_Alt_mode__NoConnect,
2117e17cb4bSCharlene Liu };
2124562236bSHarry Wentland /*
2134562236bSHarry Wentland *****************************************************************************
2144562236bSHarry Wentland * graphics_object_id struct
2154562236bSHarry Wentland *
2164562236bSHarry Wentland * graphics_object_id is a very simple struct wrapping 32bit Graphics
2174562236bSHarry Wentland * Object identication
2184562236bSHarry Wentland *
2194562236bSHarry Wentland * This struct should stay very simple
2204562236bSHarry Wentland * No dependencies at all (no includes)
2214562236bSHarry Wentland * No debug messages or asserts
2224562236bSHarry Wentland * No #ifndef and preprocessor directives
2234562236bSHarry Wentland * No grow in space (no more data member)
2244562236bSHarry Wentland *****************************************************************************
2254562236bSHarry Wentland */
2264562236bSHarry Wentland
2274562236bSHarry Wentland struct graphics_object_id {
2284562236bSHarry Wentland uint32_t id:8;
229*6d438caaSArnd Bergmann enum object_enum_id enum_id :4;
230*6d438caaSArnd Bergmann enum object_type type :4;
2314562236bSHarry Wentland uint32_t reserved:16; /* for padding. total size should be u32 */
2324562236bSHarry Wentland };
2334562236bSHarry Wentland
2344562236bSHarry Wentland /* some simple functions for convenient graphics_object_id handle */
2354562236bSHarry Wentland
dal_graphics_object_id_init(uint32_t id,enum object_enum_id enum_id,enum object_type type)2364562236bSHarry Wentland static inline struct graphics_object_id dal_graphics_object_id_init(
2374562236bSHarry Wentland uint32_t id,
2384562236bSHarry Wentland enum object_enum_id enum_id,
2394562236bSHarry Wentland enum object_type type)
2404562236bSHarry Wentland {
2414562236bSHarry Wentland struct graphics_object_id result = {
2424562236bSHarry Wentland id, enum_id, type, 0
2434562236bSHarry Wentland };
2444562236bSHarry Wentland
2454562236bSHarry Wentland return result;
2464562236bSHarry Wentland }
2474562236bSHarry Wentland
24848aa3ddfSDave Airlie /* Based on internal data members memory layout */
dal_graphics_object_id_to_uint(struct graphics_object_id id)24948aa3ddfSDave Airlie static inline uint32_t dal_graphics_object_id_to_uint(
25048aa3ddfSDave Airlie struct graphics_object_id id)
25148aa3ddfSDave Airlie {
25248aa3ddfSDave Airlie return id.id + (id.enum_id << 0x8) + (id.type << 0xc);
25348aa3ddfSDave Airlie }
25448aa3ddfSDave Airlie
dal_graphics_object_id_get_controller_id(struct graphics_object_id id)25548aa3ddfSDave Airlie static inline enum controller_id dal_graphics_object_id_get_controller_id(
25648aa3ddfSDave Airlie struct graphics_object_id id)
25748aa3ddfSDave Airlie {
25848aa3ddfSDave Airlie if (id.type == OBJECT_TYPE_CONTROLLER)
25959c185acSHarry Wentland return (enum controller_id) id.id;
26048aa3ddfSDave Airlie return CONTROLLER_ID_UNDEFINED;
26148aa3ddfSDave Airlie }
26248aa3ddfSDave Airlie
dal_graphics_object_id_get_clock_source_id(struct graphics_object_id id)26348aa3ddfSDave Airlie static inline enum clock_source_id dal_graphics_object_id_get_clock_source_id(
26448aa3ddfSDave Airlie struct graphics_object_id id)
26548aa3ddfSDave Airlie {
26648aa3ddfSDave Airlie if (id.type == OBJECT_TYPE_CLOCK_SOURCE)
26759c185acSHarry Wentland return (enum clock_source_id) id.id;
26848aa3ddfSDave Airlie return CLOCK_SOURCE_ID_UNDEFINED;
26948aa3ddfSDave Airlie }
27048aa3ddfSDave Airlie
dal_graphics_object_id_get_encoder_id(struct graphics_object_id id)27148aa3ddfSDave Airlie static inline enum encoder_id dal_graphics_object_id_get_encoder_id(
27248aa3ddfSDave Airlie struct graphics_object_id id)
27348aa3ddfSDave Airlie {
27448aa3ddfSDave Airlie if (id.type == OBJECT_TYPE_ENCODER)
27559c185acSHarry Wentland return (enum encoder_id) id.id;
27648aa3ddfSDave Airlie return ENCODER_ID_UNKNOWN;
27748aa3ddfSDave Airlie }
27848aa3ddfSDave Airlie
dal_graphics_object_id_get_connector_id(struct graphics_object_id id)27948aa3ddfSDave Airlie static inline enum connector_id dal_graphics_object_id_get_connector_id(
28048aa3ddfSDave Airlie struct graphics_object_id id)
28148aa3ddfSDave Airlie {
28248aa3ddfSDave Airlie if (id.type == OBJECT_TYPE_CONNECTOR)
28359c185acSHarry Wentland return (enum connector_id) id.id;
28448aa3ddfSDave Airlie return CONNECTOR_ID_UNKNOWN;
28548aa3ddfSDave Airlie }
28648aa3ddfSDave Airlie
dal_graphics_object_id_get_audio_id(struct graphics_object_id id)28748aa3ddfSDave Airlie static inline enum audio_id dal_graphics_object_id_get_audio_id(
28848aa3ddfSDave Airlie struct graphics_object_id id)
28948aa3ddfSDave Airlie {
29048aa3ddfSDave Airlie if (id.type == OBJECT_TYPE_AUDIO)
29159c185acSHarry Wentland return (enum audio_id) id.id;
29248aa3ddfSDave Airlie return AUDIO_ID_UNKNOWN;
29348aa3ddfSDave Airlie }
29448aa3ddfSDave Airlie
dal_graphics_object_id_get_engine_id(struct graphics_object_id id)29548aa3ddfSDave Airlie static inline enum engine_id dal_graphics_object_id_get_engine_id(
29648aa3ddfSDave Airlie struct graphics_object_id id)
29748aa3ddfSDave Airlie {
29848aa3ddfSDave Airlie if (id.type == OBJECT_TYPE_ENGINE)
29959c185acSHarry Wentland return (enum engine_id) id.id;
30048aa3ddfSDave Airlie return ENGINE_ID_UNKNOWN;
30148aa3ddfSDave Airlie }
3021eeedbccSSamson Tam
dal_graphics_object_id_equal(struct graphics_object_id id_1,struct graphics_object_id id_2)3031eeedbccSSamson Tam static inline bool dal_graphics_object_id_equal(
3041eeedbccSSamson Tam struct graphics_object_id id_1,
3051eeedbccSSamson Tam struct graphics_object_id id_2)
3061eeedbccSSamson Tam {
3071eeedbccSSamson Tam if ((id_1.id == id_2.id) && (id_1.enum_id == id_2.enum_id) &&
3081eeedbccSSamson Tam (id_1.type == id_2.type)) {
3091eeedbccSSamson Tam return true;
3101eeedbccSSamson Tam }
3111eeedbccSSamson Tam return false;
3121eeedbccSSamson Tam }
3134562236bSHarry Wentland #endif
314