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_helper.h"
34 bool dal_bios_parser_init_cmd_tbl_helper(
35 const struct command_table_helper
**h
,
42 *h
= dal_cmd_tbl_helper_dce80_get_table();
45 case DCE_VERSION_10_0
:
46 *h
= dal_cmd_tbl_helper_dce110_get_table();
49 case DCE_VERSION_11_0
:
50 *h
= dal_cmd_tbl_helper_dce110_get_table();
53 case DCE_VERSION_11_2
:
54 case DCE_VERSION_11_22
:
55 *h
= dal_cmd_tbl_helper_dce112_get_table();
65 /* real implementations */
67 bool dal_cmd_table_helper_controller_id_to_atom(
68 enum controller_id id
,
71 if (atom_id
== NULL
) {
77 case CONTROLLER_ID_D0
:
78 *atom_id
= ATOM_CRTC1
;
80 case CONTROLLER_ID_D1
:
81 *atom_id
= ATOM_CRTC2
;
83 case CONTROLLER_ID_D2
:
84 *atom_id
= ATOM_CRTC3
;
86 case CONTROLLER_ID_D3
:
87 *atom_id
= ATOM_CRTC4
;
89 case CONTROLLER_ID_D4
:
90 *atom_id
= ATOM_CRTC5
;
92 case CONTROLLER_ID_D5
:
93 *atom_id
= ATOM_CRTC6
;
95 case CONTROLLER_ID_UNDERLAY0
:
96 *atom_id
= ATOM_UNDERLAY_PIPE0
;
98 case CONTROLLER_ID_UNDEFINED
:
99 *atom_id
= ATOM_CRTC_INVALID
;
102 /* Wrong controller id */
109 * translate_transmitter_bp_to_atom
112 * Translate the Transmitter to the corresponding ATOM BIOS value
116 * output digitalTransmitter
117 * // =00: Digital Transmitter1 ( UNIPHY linkAB )
118 * // =01: Digital Transmitter2 ( UNIPHY linkCD )
119 * // =02: Digital Transmitter3 ( UNIPHY linkEF )
121 uint8_t dal_cmd_table_helper_transmitter_bp_to_atom(
125 case TRANSMITTER_UNIPHY_A
:
126 case TRANSMITTER_UNIPHY_B
:
127 case TRANSMITTER_TRAVIS_LCD
:
129 case TRANSMITTER_UNIPHY_C
:
130 case TRANSMITTER_UNIPHY_D
:
132 case TRANSMITTER_UNIPHY_E
:
133 case TRANSMITTER_UNIPHY_F
:
136 /* Invalid Transmitter Type! */
142 uint32_t dal_cmd_table_helper_encoder_mode_bp_to_atom(
144 bool enable_dp_audio
)
147 case SIGNAL_TYPE_DVI_SINGLE_LINK
:
148 case SIGNAL_TYPE_DVI_DUAL_LINK
:
149 return ATOM_ENCODER_MODE_DVI
;
150 case SIGNAL_TYPE_HDMI_TYPE_A
:
151 return ATOM_ENCODER_MODE_HDMI
;
152 case SIGNAL_TYPE_LVDS
:
153 return ATOM_ENCODER_MODE_LVDS
;
154 case SIGNAL_TYPE_EDP
:
155 case SIGNAL_TYPE_DISPLAY_PORT_MST
:
156 case SIGNAL_TYPE_DISPLAY_PORT
:
157 case SIGNAL_TYPE_VIRTUAL
:
159 return ATOM_ENCODER_MODE_DP_AUDIO
;
161 return ATOM_ENCODER_MODE_DP
;
162 case SIGNAL_TYPE_RGB
:
163 return ATOM_ENCODER_MODE_CRT
;
165 return ATOM_ENCODER_MODE_CRT
;
169 void dal_cmd_table_helper_assign_control_parameter(
170 const struct command_table_helper
*h
,
171 struct bp_encoder_control
*control
,
172 DIG_ENCODER_CONTROL_PARAMETERS_V2
*ctrl_param
)
174 /* there are three transmitter blocks, each one has two links 4-lanes
175 * each, A+B, C+D, E+F, Uniphy A, C and E are enumerated as link 0 in
176 * each transmitter block B, D and F as link 1, third transmitter block
177 * has non splitable links (UniphyE and UniphyF can not be configured
178 * separately to drive two different streams)
180 if ((control
->transmitter
== TRANSMITTER_UNIPHY_B
) ||
181 (control
->transmitter
== TRANSMITTER_UNIPHY_D
) ||
182 (control
->transmitter
== TRANSMITTER_UNIPHY_F
)) {
187 ctrl_param
->acConfig
.ucLinkSel
= 1;
190 /* Bit[4:3]: Transmitter Selection
191 * =00: Digital Transmitter1 ( UNIPHY linkAB )
192 * =01: Digital Transmitter2 ( UNIPHY linkCD )
193 * =02: Digital Transmitter3 ( UNIPHY linkEF )
196 ctrl_param
->acConfig
.ucTransmitterSel
=
197 (uint8_t)(h
->transmitter_bp_to_atom(control
->transmitter
));
199 /* We need to convert from KHz units into 10KHz units */
200 ctrl_param
->ucAction
= h
->encoder_action_to_atom(control
->action
);
201 ctrl_param
->usPixelClock
= cpu_to_le16((uint16_t)(control
->pixel_clock
/ 10));
202 ctrl_param
->ucEncoderMode
=
203 (uint8_t)(h
->encoder_mode_bp_to_atom(
204 control
->signal
, control
->enable_dp_audio
));
205 ctrl_param
->ucLaneNum
= (uint8_t)(control
->lanes_number
);
208 bool dal_cmd_table_helper_clock_source_id_to_ref_clk_src(
209 enum clock_source_id id
,
210 uint32_t *ref_clk_src_id
)
212 if (ref_clk_src_id
== NULL
) {
218 case CLOCK_SOURCE_ID_PLL1
:
219 *ref_clk_src_id
= ENCODER_REFCLK_SRC_P1PLL
;
221 case CLOCK_SOURCE_ID_PLL2
:
222 *ref_clk_src_id
= ENCODER_REFCLK_SRC_P2PLL
;
224 case CLOCK_SOURCE_ID_DCPLL
:
225 *ref_clk_src_id
= ENCODER_REFCLK_SRC_DCPLL
;
227 case CLOCK_SOURCE_ID_EXTERNAL
:
228 *ref_clk_src_id
= ENCODER_REFCLK_SRC_EXTCLK
;
230 case CLOCK_SOURCE_ID_UNDEFINED
:
231 *ref_clk_src_id
= ENCODER_REFCLK_SRC_INVALID
;
234 /* Unsupported clock source id */
240 uint8_t dal_cmd_table_helper_encoder_id_to_atom(
244 case ENCODER_ID_INTERNAL_LVDS
:
245 return ENCODER_OBJECT_ID_INTERNAL_LVDS
;
246 case ENCODER_ID_INTERNAL_TMDS1
:
247 return ENCODER_OBJECT_ID_INTERNAL_TMDS1
;
248 case ENCODER_ID_INTERNAL_TMDS2
:
249 return ENCODER_OBJECT_ID_INTERNAL_TMDS2
;
250 case ENCODER_ID_INTERNAL_DAC1
:
251 return ENCODER_OBJECT_ID_INTERNAL_DAC1
;
252 case ENCODER_ID_INTERNAL_DAC2
:
253 return ENCODER_OBJECT_ID_INTERNAL_DAC2
;
254 case ENCODER_ID_INTERNAL_LVTM1
:
255 return ENCODER_OBJECT_ID_INTERNAL_LVTM1
;
256 case ENCODER_ID_INTERNAL_HDMI
:
257 return ENCODER_OBJECT_ID_HDMI_INTERNAL
;
258 case ENCODER_ID_EXTERNAL_TRAVIS
:
259 return ENCODER_OBJECT_ID_TRAVIS
;
260 case ENCODER_ID_EXTERNAL_NUTMEG
:
261 return ENCODER_OBJECT_ID_NUTMEG
;
262 case ENCODER_ID_INTERNAL_KLDSCP_TMDS1
:
263 return ENCODER_OBJECT_ID_INTERNAL_KLDSCP_TMDS1
;
264 case ENCODER_ID_INTERNAL_KLDSCP_DAC1
:
265 return ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DAC1
;
266 case ENCODER_ID_INTERNAL_KLDSCP_DAC2
:
267 return ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DAC2
;
268 case ENCODER_ID_EXTERNAL_MVPU_FPGA
:
269 return ENCODER_OBJECT_ID_MVPU_FPGA
;
270 case ENCODER_ID_INTERNAL_DDI
:
271 return ENCODER_OBJECT_ID_INTERNAL_DDI
;
272 case ENCODER_ID_INTERNAL_UNIPHY
:
273 return ENCODER_OBJECT_ID_INTERNAL_UNIPHY
;
274 case ENCODER_ID_INTERNAL_KLDSCP_LVTMA
:
275 return ENCODER_OBJECT_ID_INTERNAL_KLDSCP_LVTMA
;
276 case ENCODER_ID_INTERNAL_UNIPHY1
:
277 return ENCODER_OBJECT_ID_INTERNAL_UNIPHY1
;
278 case ENCODER_ID_INTERNAL_UNIPHY2
:
279 return ENCODER_OBJECT_ID_INTERNAL_UNIPHY2
;
280 case ENCODER_ID_INTERNAL_UNIPHY3
:
281 return ENCODER_OBJECT_ID_INTERNAL_UNIPHY3
;
282 case ENCODER_ID_INTERNAL_WIRELESS
:
283 return ENCODER_OBJECT_ID_INTERNAL_VCE
;
284 case ENCODER_ID_UNKNOWN
:
285 return ENCODER_OBJECT_ID_NONE
;
287 /* Invalid encoder id */
289 return ENCODER_OBJECT_ID_NONE
;