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 "dm_services.h"
30 #include "include/bios_parser_types.h"
32 #include "../command_table_helper2.h"
34 static uint8_t phy_id_to_atom(enum transmitter t)
39 case TRANSMITTER_UNIPHY_A:
40 atom_phy_id = ATOM_PHY_ID_UNIPHYA;
42 case TRANSMITTER_UNIPHY_B:
43 atom_phy_id = ATOM_PHY_ID_UNIPHYB;
45 case TRANSMITTER_UNIPHY_C:
46 atom_phy_id = ATOM_PHY_ID_UNIPHYC;
48 case TRANSMITTER_UNIPHY_D:
49 atom_phy_id = ATOM_PHY_ID_UNIPHYD;
51 case TRANSMITTER_UNIPHY_E:
52 atom_phy_id = ATOM_PHY_ID_UNIPHYE;
54 case TRANSMITTER_UNIPHY_F:
55 atom_phy_id = ATOM_PHY_ID_UNIPHYF;
57 case TRANSMITTER_UNIPHY_G:
58 atom_phy_id = ATOM_PHY_ID_UNIPHYG;
61 atom_phy_id = ATOM_PHY_ID_UNIPHYA;
67 static uint8_t signal_type_to_atom_dig_mode(enum signal_type s)
69 uint8_t atom_dig_mode = ATOM_TRANSMITTER_DIGMODE_V6_DP;
72 case SIGNAL_TYPE_DISPLAY_PORT:
74 atom_dig_mode = ATOM_TRANSMITTER_DIGMODE_V6_DP;
76 case SIGNAL_TYPE_DVI_SINGLE_LINK:
77 case SIGNAL_TYPE_DVI_DUAL_LINK:
78 atom_dig_mode = ATOM_TRANSMITTER_DIGMODE_V6_DVI;
80 case SIGNAL_TYPE_HDMI_TYPE_A:
81 atom_dig_mode = ATOM_TRANSMITTER_DIGMODE_V6_HDMI;
83 case SIGNAL_TYPE_DISPLAY_PORT_MST:
84 atom_dig_mode = ATOM_TRANSMITTER_DIGMODE_V6_DP_MST;
87 atom_dig_mode = ATOM_TRANSMITTER_DIGMODE_V6_DVI;
94 static uint8_t clock_source_id_to_atom_phy_clk_src_id(
95 enum clock_source_id id)
97 uint8_t atom_phy_clk_src_id = 0;
100 case CLOCK_SOURCE_ID_PLL0:
101 atom_phy_clk_src_id = ATOM_TRANSMITTER_CONFIG_V5_P0PLL;
103 case CLOCK_SOURCE_ID_PLL1:
104 atom_phy_clk_src_id = ATOM_TRANSMITTER_CONFIG_V5_P1PLL;
106 case CLOCK_SOURCE_ID_PLL2:
107 atom_phy_clk_src_id = ATOM_TRANSMITTER_CONFIG_V5_P2PLL;
109 case CLOCK_SOURCE_ID_EXTERNAL:
110 atom_phy_clk_src_id = ATOM_TRANSMITTER_CONFIG_V5_REFCLK_SRC_EXT;
113 atom_phy_clk_src_id = ATOM_TRANSMITTER_CONFIG_V5_P1PLL;
117 return atom_phy_clk_src_id >> 2;
120 static uint8_t hpd_sel_to_atom(enum hpd_source_id id)
122 uint8_t atom_hpd_sel = 0;
126 atom_hpd_sel = ATOM_TRANSMITTER_V6_HPD1_SEL;
129 atom_hpd_sel = ATOM_TRANSMITTER_V6_HPD2_SEL;
132 atom_hpd_sel = ATOM_TRANSMITTER_V6_HPD3_SEL;
135 atom_hpd_sel = ATOM_TRANSMITTER_V6_HPD4_SEL;
138 atom_hpd_sel = ATOM_TRANSMITTER_V6_HPD5_SEL;
141 atom_hpd_sel = ATOM_TRANSMITTER_V6_HPD6_SEL;
143 case HPD_SOURCEID_UNKNOWN:
151 static uint8_t dig_encoder_sel_to_atom(enum engine_id id)
153 uint8_t atom_dig_encoder_sel = 0;
157 atom_dig_encoder_sel = ATOM_TRANMSITTER_V6__DIGA_SEL;
160 atom_dig_encoder_sel = ATOM_TRANMSITTER_V6__DIGB_SEL;
163 atom_dig_encoder_sel = ATOM_TRANMSITTER_V6__DIGC_SEL;
166 atom_dig_encoder_sel = ATOM_TRANMSITTER_V6__DIGD_SEL;
169 atom_dig_encoder_sel = ATOM_TRANMSITTER_V6__DIGE_SEL;
172 atom_dig_encoder_sel = ATOM_TRANMSITTER_V6__DIGF_SEL;
175 atom_dig_encoder_sel = ATOM_TRANMSITTER_V6__DIGG_SEL;
177 case ENGINE_ID_UNKNOWN:
178 /* No DIG_FRONT is associated to DIG_BACKEND */
179 atom_dig_encoder_sel = 0;
182 atom_dig_encoder_sel = ATOM_TRANMSITTER_V6__DIGA_SEL;
189 static bool clock_source_id_to_atom(
190 enum clock_source_id id,
191 uint32_t *atom_pll_id)
195 if (atom_pll_id != NULL)
197 case CLOCK_SOURCE_COMBO_PHY_PLL0:
198 *atom_pll_id = ATOM_COMBOPHY_PLL0;
200 case CLOCK_SOURCE_COMBO_PHY_PLL1:
201 *atom_pll_id = ATOM_COMBOPHY_PLL1;
203 case CLOCK_SOURCE_COMBO_PHY_PLL2:
204 *atom_pll_id = ATOM_COMBOPHY_PLL2;
206 case CLOCK_SOURCE_COMBO_PHY_PLL3:
207 *atom_pll_id = ATOM_COMBOPHY_PLL3;
209 case CLOCK_SOURCE_COMBO_PHY_PLL4:
210 *atom_pll_id = ATOM_COMBOPHY_PLL4;
212 case CLOCK_SOURCE_COMBO_PHY_PLL5:
213 *atom_pll_id = ATOM_COMBOPHY_PLL5;
215 case CLOCK_SOURCE_COMBO_DISPLAY_PLL0:
216 *atom_pll_id = ATOM_PPLL0;
218 case CLOCK_SOURCE_ID_DFS:
219 *atom_pll_id = ATOM_GCK_DFS;
221 case CLOCK_SOURCE_ID_VCE:
222 *atom_pll_id = ATOM_DP_DTO;
224 case CLOCK_SOURCE_ID_DP_DTO:
225 *atom_pll_id = ATOM_DP_DTO;
227 case CLOCK_SOURCE_ID_UNDEFINED:
228 /* Should not happen */
229 *atom_pll_id = ATOM_PPLL_INVALID;
240 static bool engine_bp_to_atom(enum engine_id id, uint32_t *atom_engine_id)
244 if (atom_engine_id != NULL)
247 *atom_engine_id = ASIC_INT_DIG1_ENCODER_ID;
251 *atom_engine_id = ASIC_INT_DIG2_ENCODER_ID;
255 *atom_engine_id = ASIC_INT_DIG3_ENCODER_ID;
259 *atom_engine_id = ASIC_INT_DIG4_ENCODER_ID;
263 *atom_engine_id = ASIC_INT_DIG5_ENCODER_ID;
267 *atom_engine_id = ASIC_INT_DIG6_ENCODER_ID;
271 *atom_engine_id = ASIC_INT_DIG7_ENCODER_ID;
275 *atom_engine_id = ASIC_INT_DAC1_ENCODER_ID;
285 static uint8_t encoder_action_to_atom(enum bp_encoder_control_action action)
287 uint8_t atom_action = 0;
290 case ENCODER_CONTROL_ENABLE:
291 atom_action = ATOM_ENABLE;
293 case ENCODER_CONTROL_DISABLE:
294 atom_action = ATOM_DISABLE;
296 case ENCODER_CONTROL_SETUP:
297 atom_action = ATOM_ENCODER_CMD_STREAM_SETUP;
299 case ENCODER_CONTROL_INIT:
300 atom_action = ATOM_ENCODER_INIT;
303 BREAK_TO_DEBUGGER(); /* Unhandle action in driver.!! */
310 static uint8_t disp_power_gating_action_to_atom(
311 enum bp_pipe_control_action action)
313 uint8_t atom_pipe_action = 0;
316 case ASIC_PIPE_DISABLE:
317 atom_pipe_action = ATOM_DISABLE;
319 case ASIC_PIPE_ENABLE:
320 atom_pipe_action = ATOM_ENABLE;
323 atom_pipe_action = ATOM_INIT;
326 ASSERT_CRITICAL(false); /* Unhandle action in driver! */
330 return atom_pipe_action;
333 static bool dc_clock_type_to_atom(
334 enum bp_dce_clock_type id,
335 uint32_t *atom_clock_type)
339 if (atom_clock_type != NULL) {
341 case DCECLOCK_TYPE_DISPLAY_CLOCK:
342 *atom_clock_type = DCE_CLOCK_TYPE_DISPCLK;
345 case DCECLOCK_TYPE_DPREFCLK:
346 *atom_clock_type = DCE_CLOCK_TYPE_DPREFCLK;
350 ASSERT_CRITICAL(false); /* Unhandle action in driver! */
358 static uint8_t transmitter_color_depth_to_atom(enum transmitter_color_depth id)
360 uint8_t atomColorDepth = 0;
363 case TRANSMITTER_COLOR_DEPTH_24:
364 atomColorDepth = PIXEL_CLOCK_V7_DEEPCOLOR_RATIO_DIS;
366 case TRANSMITTER_COLOR_DEPTH_30:
367 atomColorDepth = PIXEL_CLOCK_V7_DEEPCOLOR_RATIO_5_4;
369 case TRANSMITTER_COLOR_DEPTH_36:
370 atomColorDepth = PIXEL_CLOCK_V7_DEEPCOLOR_RATIO_3_2;
372 case TRANSMITTER_COLOR_DEPTH_48:
373 atomColorDepth = PIXEL_CLOCK_V7_DEEPCOLOR_RATIO_2_1;
376 ASSERT_CRITICAL(false); /* Unhandle action in driver! */
380 return atomColorDepth;
384 static const struct command_table_helper command_table_helper_funcs = {
385 .controller_id_to_atom = dal_cmd_table_helper_controller_id_to_atom2,
386 .encoder_action_to_atom = encoder_action_to_atom,
387 .engine_bp_to_atom = engine_bp_to_atom,
388 .clock_source_id_to_atom = clock_source_id_to_atom,
389 .clock_source_id_to_atom_phy_clk_src_id =
390 clock_source_id_to_atom_phy_clk_src_id,
391 .signal_type_to_atom_dig_mode = signal_type_to_atom_dig_mode,
392 .hpd_sel_to_atom = hpd_sel_to_atom,
393 .dig_encoder_sel_to_atom = dig_encoder_sel_to_atom,
394 .phy_id_to_atom = phy_id_to_atom,
395 .disp_power_gating_action_to_atom = disp_power_gating_action_to_atom,
396 .clock_source_id_to_ref_clk_src = NULL,
397 .transmitter_bp_to_atom = NULL,
398 .encoder_id_to_atom = dal_cmd_table_helper_encoder_id_to_atom2,
399 .encoder_mode_bp_to_atom =
400 dal_cmd_table_helper_encoder_mode_bp_to_atom2,
401 .dc_clock_type_to_atom = dc_clock_type_to_atom,
402 .transmitter_color_depth_to_atom = transmitter_color_depth_to_atom,
406 * dal_cmd_tbl_helper_dce110_get_table
409 * Initialize command table helper functions
412 * const struct command_table_helper **h - [out] struct of functions
415 const struct command_table_helper *dal_cmd_tbl_helper_dce112_get_table2(void)
417 return &command_table_helper_funcs;