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
,
39 #if defined(CONFIG_DRM_AMD_DC_SI)
43 *h
= dal_cmd_tbl_helper_dce60_get_table();
50 *h
= dal_cmd_tbl_helper_dce80_get_table();
53 case DCE_VERSION_10_0
:
54 *h
= dal_cmd_tbl_helper_dce110_get_table();
57 case DCE_VERSION_11_0
:
58 *h
= dal_cmd_tbl_helper_dce110_get_table();
61 case DCE_VERSION_11_2
:
62 case DCE_VERSION_11_22
:
63 *h
= dal_cmd_tbl_helper_dce112_get_table();
73 /* real implementations */
75 bool dal_cmd_table_helper_controller_id_to_atom(
76 enum controller_id id
,
79 if (atom_id
== NULL
) {
85 case CONTROLLER_ID_D0
:
86 *atom_id
= ATOM_CRTC1
;
88 case CONTROLLER_ID_D1
:
89 *atom_id
= ATOM_CRTC2
;
91 case CONTROLLER_ID_D2
:
92 *atom_id
= ATOM_CRTC3
;
94 case CONTROLLER_ID_D3
:
95 *atom_id
= ATOM_CRTC4
;
97 case CONTROLLER_ID_D4
:
98 *atom_id
= ATOM_CRTC5
;
100 case CONTROLLER_ID_D5
:
101 *atom_id
= ATOM_CRTC6
;
103 case CONTROLLER_ID_UNDERLAY0
:
104 *atom_id
= ATOM_UNDERLAY_PIPE0
;
106 case CONTROLLER_ID_UNDEFINED
:
107 *atom_id
= ATOM_CRTC_INVALID
;
110 /* Wrong controller id */
117 * translate_transmitter_bp_to_atom
120 * Translate the Transmitter to the corresponding ATOM BIOS value
124 * output digitalTransmitter
125 * // =00: Digital Transmitter1 ( UNIPHY linkAB )
126 * // =01: Digital Transmitter2 ( UNIPHY linkCD )
127 * // =02: Digital Transmitter3 ( UNIPHY linkEF )
129 uint8_t dal_cmd_table_helper_transmitter_bp_to_atom(
133 case TRANSMITTER_UNIPHY_A
:
134 case TRANSMITTER_UNIPHY_B
:
135 case TRANSMITTER_TRAVIS_LCD
:
137 case TRANSMITTER_UNIPHY_C
:
138 case TRANSMITTER_UNIPHY_D
:
140 case TRANSMITTER_UNIPHY_E
:
141 case TRANSMITTER_UNIPHY_F
:
144 /* Invalid Transmitter Type! */
150 uint32_t dal_cmd_table_helper_encoder_mode_bp_to_atom(
152 bool enable_dp_audio
)
155 case SIGNAL_TYPE_DVI_SINGLE_LINK
:
156 case SIGNAL_TYPE_DVI_DUAL_LINK
:
157 return ATOM_ENCODER_MODE_DVI
;
158 case SIGNAL_TYPE_HDMI_TYPE_A
:
159 return ATOM_ENCODER_MODE_HDMI
;
160 case SIGNAL_TYPE_LVDS
:
161 return ATOM_ENCODER_MODE_LVDS
;
162 case SIGNAL_TYPE_EDP
:
163 case SIGNAL_TYPE_DISPLAY_PORT_MST
:
164 case SIGNAL_TYPE_DISPLAY_PORT
:
165 case SIGNAL_TYPE_VIRTUAL
:
167 return ATOM_ENCODER_MODE_DP_AUDIO
;
169 return ATOM_ENCODER_MODE_DP
;
170 case SIGNAL_TYPE_RGB
:
171 return ATOM_ENCODER_MODE_CRT
;
173 return ATOM_ENCODER_MODE_CRT
;
177 void dal_cmd_table_helper_assign_control_parameter(
178 const struct command_table_helper
*h
,
179 struct bp_encoder_control
*control
,
180 DIG_ENCODER_CONTROL_PARAMETERS_V2
*ctrl_param
)
182 /* there are three transmitter blocks, each one has two links 4-lanes
183 * each, A+B, C+D, E+F, Uniphy A, C and E are enumerated as link 0 in
184 * each transmitter block B, D and F as link 1, third transmitter block
185 * has non splitable links (UniphyE and UniphyF can not be configured
186 * separately to drive two different streams)
188 if ((control
->transmitter
== TRANSMITTER_UNIPHY_B
) ||
189 (control
->transmitter
== TRANSMITTER_UNIPHY_D
) ||
190 (control
->transmitter
== TRANSMITTER_UNIPHY_F
)) {
195 ctrl_param
->acConfig
.ucLinkSel
= 1;
198 /* Bit[4:3]: Transmitter Selection
199 * =00: Digital Transmitter1 ( UNIPHY linkAB )
200 * =01: Digital Transmitter2 ( UNIPHY linkCD )
201 * =02: Digital Transmitter3 ( UNIPHY linkEF )
204 ctrl_param
->acConfig
.ucTransmitterSel
=
205 (uint8_t)(h
->transmitter_bp_to_atom(control
->transmitter
));
207 /* We need to convert from KHz units into 10KHz units */
208 ctrl_param
->ucAction
= h
->encoder_action_to_atom(control
->action
);
209 ctrl_param
->usPixelClock
= cpu_to_le16((uint16_t)(control
->pixel_clock
/ 10));
210 ctrl_param
->ucEncoderMode
=
211 (uint8_t)(h
->encoder_mode_bp_to_atom(
212 control
->signal
, control
->enable_dp_audio
));
213 ctrl_param
->ucLaneNum
= (uint8_t)(control
->lanes_number
);
216 bool dal_cmd_table_helper_clock_source_id_to_ref_clk_src(
217 enum clock_source_id id
,
218 uint32_t *ref_clk_src_id
)
220 if (ref_clk_src_id
== NULL
) {
226 case CLOCK_SOURCE_ID_PLL1
:
227 *ref_clk_src_id
= ENCODER_REFCLK_SRC_P1PLL
;
229 case CLOCK_SOURCE_ID_PLL2
:
230 *ref_clk_src_id
= ENCODER_REFCLK_SRC_P2PLL
;
232 case CLOCK_SOURCE_ID_DCPLL
:
233 *ref_clk_src_id
= ENCODER_REFCLK_SRC_DCPLL
;
235 case CLOCK_SOURCE_ID_EXTERNAL
:
236 *ref_clk_src_id
= ENCODER_REFCLK_SRC_EXTCLK
;
238 case CLOCK_SOURCE_ID_UNDEFINED
:
239 *ref_clk_src_id
= ENCODER_REFCLK_SRC_INVALID
;
242 /* Unsupported clock source id */
248 uint8_t dal_cmd_table_helper_encoder_id_to_atom(
252 case ENCODER_ID_INTERNAL_LVDS
:
253 return ENCODER_OBJECT_ID_INTERNAL_LVDS
;
254 case ENCODER_ID_INTERNAL_TMDS1
:
255 return ENCODER_OBJECT_ID_INTERNAL_TMDS1
;
256 case ENCODER_ID_INTERNAL_TMDS2
:
257 return ENCODER_OBJECT_ID_INTERNAL_TMDS2
;
258 case ENCODER_ID_INTERNAL_DAC1
:
259 return ENCODER_OBJECT_ID_INTERNAL_DAC1
;
260 case ENCODER_ID_INTERNAL_DAC2
:
261 return ENCODER_OBJECT_ID_INTERNAL_DAC2
;
262 case ENCODER_ID_INTERNAL_LVTM1
:
263 return ENCODER_OBJECT_ID_INTERNAL_LVTM1
;
264 case ENCODER_ID_INTERNAL_HDMI
:
265 return ENCODER_OBJECT_ID_HDMI_INTERNAL
;
266 case ENCODER_ID_EXTERNAL_TRAVIS
:
267 return ENCODER_OBJECT_ID_TRAVIS
;
268 case ENCODER_ID_EXTERNAL_NUTMEG
:
269 return ENCODER_OBJECT_ID_NUTMEG
;
270 case ENCODER_ID_INTERNAL_KLDSCP_TMDS1
:
271 return ENCODER_OBJECT_ID_INTERNAL_KLDSCP_TMDS1
;
272 case ENCODER_ID_INTERNAL_KLDSCP_DAC1
:
273 return ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DAC1
;
274 case ENCODER_ID_INTERNAL_KLDSCP_DAC2
:
275 return ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DAC2
;
276 case ENCODER_ID_EXTERNAL_MVPU_FPGA
:
277 return ENCODER_OBJECT_ID_MVPU_FPGA
;
278 case ENCODER_ID_INTERNAL_DDI
:
279 return ENCODER_OBJECT_ID_INTERNAL_DDI
;
280 case ENCODER_ID_INTERNAL_UNIPHY
:
281 return ENCODER_OBJECT_ID_INTERNAL_UNIPHY
;
282 case ENCODER_ID_INTERNAL_KLDSCP_LVTMA
:
283 return ENCODER_OBJECT_ID_INTERNAL_KLDSCP_LVTMA
;
284 case ENCODER_ID_INTERNAL_UNIPHY1
:
285 return ENCODER_OBJECT_ID_INTERNAL_UNIPHY1
;
286 case ENCODER_ID_INTERNAL_UNIPHY2
:
287 return ENCODER_OBJECT_ID_INTERNAL_UNIPHY2
;
288 case ENCODER_ID_INTERNAL_UNIPHY3
:
289 return ENCODER_OBJECT_ID_INTERNAL_UNIPHY3
;
290 case ENCODER_ID_INTERNAL_WIRELESS
:
291 return ENCODER_OBJECT_ID_INTERNAL_VCE
;
292 case ENCODER_ID_UNKNOWN
:
293 return ENCODER_OBJECT_ID_NONE
;
295 /* Invalid encoder id */
297 return ENCODER_OBJECT_ID_NONE
;