Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1/*
2 * Copyright 2012-15 Advanced Micro Devices, Inc.
3 *
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:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
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.
21 *
22 * Authors: AMD
23 *
24 */
25
26#include "dc_bios_types.h"
27#include "dce_stream_encoder.h"
28#include "reg_helper.h"
29#include "hw_shared.h"
30
31#define DC_LOGGER \
32 enc110->base.ctx->logger
33
34
35#define REG(reg)\
36 (enc110->regs->reg)
37
38#undef FN
39#define FN(reg_name, field_name) \
40 enc110->se_shift->field_name, enc110->se_mask->field_name
41
42#define VBI_LINE_0 0
43#define DP_BLANK_MAX_RETRY 20
44#define HDMI_CLOCK_CHANNEL_RATE_MORE_340M 340000
45
46#ifndef TMDS_CNTL__TMDS_PIXEL_ENCODING_MASK
47 #define TMDS_CNTL__TMDS_PIXEL_ENCODING_MASK 0x00000010L
48 #define TMDS_CNTL__TMDS_COLOR_FORMAT_MASK 0x00000300L
49 #define TMDS_CNTL__TMDS_PIXEL_ENCODING__SHIFT 0x00000004
50 #define TMDS_CNTL__TMDS_COLOR_FORMAT__SHIFT 0x00000008
51#endif
52
53enum {
54 DP_MST_UPDATE_MAX_RETRY = 50
55};
56
57#define DCE110_SE(audio)\
58 container_of(audio, struct dce110_stream_encoder, base)
59
60#define CTX \
61 enc110->base.ctx
62
63static void dce110_update_generic_info_packet(
64 struct dce110_stream_encoder *enc110,
65 uint32_t packet_index,
66 const struct dc_info_packet *info_packet)
67{
68 uint32_t regval;
69 /* TODOFPGA Figure out a proper number for max_retries polling for lock
70 * use 50 for now.
71 */
72 uint32_t max_retries = 50;
73
74 /*we need turn on clock before programming AFMT block*/
75 if (REG(AFMT_CNTL))
76 REG_UPDATE(AFMT_CNTL, AFMT_AUDIO_CLOCK_EN, 1);
77
78 if (REG(AFMT_VBI_PACKET_CONTROL1)) {
79 if (packet_index >= 8)
80 ASSERT(0);
81
82 /* poll dig_update_lock is not locked -> asic internal signal
83 * assume otg master lock will unlock it
84 */
85/* REG_WAIT(AFMT_VBI_PACKET_CONTROL, AFMT_GENERIC_LOCK_STATUS,
86 0, 10, max_retries);*/
87
88 /* check if HW reading GSP memory */
89 REG_WAIT(AFMT_VBI_PACKET_CONTROL, AFMT_GENERIC_CONFLICT,
90 0, 10, max_retries);
91
92 /* HW does is not reading GSP memory not reading too long ->
93 * something wrong. clear GPS memory access and notify?
94 * hw SW is writing to GSP memory
95 */
96 REG_UPDATE(AFMT_VBI_PACKET_CONTROL, AFMT_GENERIC_CONFLICT_CLR, 1);
97 }
98 /* choose which generic packet to use */
99 {
100 regval = REG_READ(AFMT_VBI_PACKET_CONTROL);
101 REG_UPDATE(AFMT_VBI_PACKET_CONTROL,
102 AFMT_GENERIC_INDEX, packet_index);
103 }
104
105 /* write generic packet header
106 * (4th byte is for GENERIC0 only) */
107 {
108 REG_SET_4(AFMT_GENERIC_HDR, 0,
109 AFMT_GENERIC_HB0, info_packet->hb0,
110 AFMT_GENERIC_HB1, info_packet->hb1,
111 AFMT_GENERIC_HB2, info_packet->hb2,
112 AFMT_GENERIC_HB3, info_packet->hb3);
113 }
114
115 /* write generic packet contents
116 * (we never use last 4 bytes)
117 * there are 8 (0-7) mmDIG0_AFMT_GENERIC0_x registers */
118 {
119 const uint32_t *content =
120 (const uint32_t *) &info_packet->sb[0];
121
122 REG_WRITE(AFMT_GENERIC_0, *content++);
123 REG_WRITE(AFMT_GENERIC_1, *content++);
124 REG_WRITE(AFMT_GENERIC_2, *content++);
125 REG_WRITE(AFMT_GENERIC_3, *content++);
126 REG_WRITE(AFMT_GENERIC_4, *content++);
127 REG_WRITE(AFMT_GENERIC_5, *content++);
128 REG_WRITE(AFMT_GENERIC_6, *content++);
129 REG_WRITE(AFMT_GENERIC_7, *content);
130 }
131
132 if (!REG(AFMT_VBI_PACKET_CONTROL1)) {
133 /* force double-buffered packet update */
134 REG_UPDATE_2(AFMT_VBI_PACKET_CONTROL,
135 AFMT_GENERIC0_UPDATE, (packet_index == 0),
136 AFMT_GENERIC2_UPDATE, (packet_index == 2));
137 }
138#if defined(CONFIG_DRM_AMD_DC_DCN1_0)
139 if (REG(AFMT_VBI_PACKET_CONTROL1)) {
140 switch (packet_index) {
141 case 0:
142 REG_UPDATE(AFMT_VBI_PACKET_CONTROL1,
143 AFMT_GENERIC0_FRAME_UPDATE, 1);
144 break;
145 case 1:
146 REG_UPDATE(AFMT_VBI_PACKET_CONTROL1,
147 AFMT_GENERIC1_FRAME_UPDATE, 1);
148 break;
149 case 2:
150 REG_UPDATE(AFMT_VBI_PACKET_CONTROL1,
151 AFMT_GENERIC2_FRAME_UPDATE, 1);
152 break;
153 case 3:
154 REG_UPDATE(AFMT_VBI_PACKET_CONTROL1,
155 AFMT_GENERIC3_FRAME_UPDATE, 1);
156 break;
157 case 4:
158 REG_UPDATE(AFMT_VBI_PACKET_CONTROL1,
159 AFMT_GENERIC4_FRAME_UPDATE, 1);
160 break;
161 case 5:
162 REG_UPDATE(AFMT_VBI_PACKET_CONTROL1,
163 AFMT_GENERIC5_FRAME_UPDATE, 1);
164 break;
165 case 6:
166 REG_UPDATE(AFMT_VBI_PACKET_CONTROL1,
167 AFMT_GENERIC6_FRAME_UPDATE, 1);
168 break;
169 case 7:
170 REG_UPDATE(AFMT_VBI_PACKET_CONTROL1,
171 AFMT_GENERIC7_FRAME_UPDATE, 1);
172 break;
173 default:
174 break;
175 }
176 }
177#endif
178}
179
180static void dce110_update_hdmi_info_packet(
181 struct dce110_stream_encoder *enc110,
182 uint32_t packet_index,
183 const struct dc_info_packet *info_packet)
184{
185 uint32_t cont, send, line;
186
187 if (info_packet->valid) {
188 dce110_update_generic_info_packet(
189 enc110,
190 packet_index,
191 info_packet);
192
193 /* enable transmission of packet(s) -
194 * packet transmission begins on the next frame */
195 cont = 1;
196 /* send packet(s) every frame */
197 send = 1;
198 /* select line number to send packets on */
199 line = 2;
200 } else {
201 cont = 0;
202 send = 0;
203 line = 0;
204 }
205
206 /* choose which generic packet control to use */
207 switch (packet_index) {
208 case 0:
209 REG_UPDATE_3(HDMI_GENERIC_PACKET_CONTROL0,
210 HDMI_GENERIC0_CONT, cont,
211 HDMI_GENERIC0_SEND, send,
212 HDMI_GENERIC0_LINE, line);
213 break;
214 case 1:
215 REG_UPDATE_3(HDMI_GENERIC_PACKET_CONTROL0,
216 HDMI_GENERIC1_CONT, cont,
217 HDMI_GENERIC1_SEND, send,
218 HDMI_GENERIC1_LINE, line);
219 break;
220 case 2:
221 REG_UPDATE_3(HDMI_GENERIC_PACKET_CONTROL1,
222 HDMI_GENERIC0_CONT, cont,
223 HDMI_GENERIC0_SEND, send,
224 HDMI_GENERIC0_LINE, line);
225 break;
226 case 3:
227 REG_UPDATE_3(HDMI_GENERIC_PACKET_CONTROL1,
228 HDMI_GENERIC1_CONT, cont,
229 HDMI_GENERIC1_SEND, send,
230 HDMI_GENERIC1_LINE, line);
231 break;
232#if defined(CONFIG_DRM_AMD_DC_DCN1_0)
233 case 4:
234 if (REG(HDMI_GENERIC_PACKET_CONTROL2))
235 REG_UPDATE_3(HDMI_GENERIC_PACKET_CONTROL2,
236 HDMI_GENERIC0_CONT, cont,
237 HDMI_GENERIC0_SEND, send,
238 HDMI_GENERIC0_LINE, line);
239 break;
240 case 5:
241 if (REG(HDMI_GENERIC_PACKET_CONTROL2))
242 REG_UPDATE_3(HDMI_GENERIC_PACKET_CONTROL2,
243 HDMI_GENERIC1_CONT, cont,
244 HDMI_GENERIC1_SEND, send,
245 HDMI_GENERIC1_LINE, line);
246 break;
247 case 6:
248 if (REG(HDMI_GENERIC_PACKET_CONTROL3))
249 REG_UPDATE_3(HDMI_GENERIC_PACKET_CONTROL3,
250 HDMI_GENERIC0_CONT, cont,
251 HDMI_GENERIC0_SEND, send,
252 HDMI_GENERIC0_LINE, line);
253 break;
254 case 7:
255 if (REG(HDMI_GENERIC_PACKET_CONTROL3))
256 REG_UPDATE_3(HDMI_GENERIC_PACKET_CONTROL3,
257 HDMI_GENERIC1_CONT, cont,
258 HDMI_GENERIC1_SEND, send,
259 HDMI_GENERIC1_LINE, line);
260 break;
261#endif
262 default:
263 /* invalid HW packet index */
264 DC_LOG_WARNING(
265 "Invalid HW packet index: %s()\n",
266 __func__);
267 return;
268 }
269}
270
271/* setup stream encoder in dp mode */
272static void dce110_stream_encoder_dp_set_stream_attribute(
273 struct stream_encoder *enc,
274 struct dc_crtc_timing *crtc_timing,
275 enum dc_color_space output_color_space,
276 uint32_t enable_sdp_splitting)
277{
278#if defined(CONFIG_DRM_AMD_DC_DCN1_0)
279 uint32_t h_active_start;
280 uint32_t v_active_start;
281 uint32_t misc0 = 0;
282 uint32_t misc1 = 0;
283 uint32_t h_blank;
284 uint32_t h_back_porch;
285 uint8_t synchronous_clock = 0; /* asynchronous mode */
286 uint8_t colorimetry_bpc;
287 uint8_t dynamic_range_rgb = 0; /*full range*/
288 uint8_t dynamic_range_ycbcr = 1; /*bt709*/
289#endif
290
291 struct dce110_stream_encoder *enc110 = DCE110STRENC_FROM_STRENC(enc);
292 struct dc_crtc_timing hw_crtc_timing = *crtc_timing;
293 if (hw_crtc_timing.flags.INTERLACE) {
294 /*the input timing is in VESA spec format with Interlace flag =1*/
295 hw_crtc_timing.v_total /= 2;
296 hw_crtc_timing.v_border_top /= 2;
297 hw_crtc_timing.v_addressable /= 2;
298 hw_crtc_timing.v_border_bottom /= 2;
299 hw_crtc_timing.v_front_porch /= 2;
300 hw_crtc_timing.v_sync_width /= 2;
301 }
302 /* set pixel encoding */
303 switch (hw_crtc_timing.pixel_encoding) {
304 case PIXEL_ENCODING_YCBCR422:
305 REG_UPDATE(DP_PIXEL_FORMAT, DP_PIXEL_ENCODING,
306 DP_PIXEL_ENCODING_TYPE_YCBCR422);
307 break;
308 case PIXEL_ENCODING_YCBCR444:
309 REG_UPDATE(DP_PIXEL_FORMAT, DP_PIXEL_ENCODING,
310 DP_PIXEL_ENCODING_TYPE_YCBCR444);
311
312 if (hw_crtc_timing.flags.Y_ONLY)
313 if (hw_crtc_timing.display_color_depth != COLOR_DEPTH_666)
314 /* HW testing only, no use case yet.
315 * Color depth of Y-only could be
316 * 8, 10, 12, 16 bits */
317 REG_UPDATE(DP_PIXEL_FORMAT, DP_PIXEL_ENCODING,
318 DP_PIXEL_ENCODING_TYPE_Y_ONLY);
319 /* Note: DP_MSA_MISC1 bit 7 is the indicator
320 * of Y-only mode.
321 * This bit is set in HW if register
322 * DP_PIXEL_ENCODING is programmed to 0x4 */
323 break;
324 case PIXEL_ENCODING_YCBCR420:
325 REG_UPDATE(DP_PIXEL_FORMAT, DP_PIXEL_ENCODING,
326 DP_PIXEL_ENCODING_TYPE_YCBCR420);
327 if (enc110->se_mask->DP_VID_M_DOUBLE_VALUE_EN)
328 REG_UPDATE(DP_VID_TIMING, DP_VID_M_DOUBLE_VALUE_EN, 1);
329
330#if defined(CONFIG_DRM_AMD_DC_DCN1_0)
331 if (enc110->se_mask->DP_VID_N_MUL)
332 REG_UPDATE(DP_VID_TIMING, DP_VID_N_MUL, 1);
333#endif
334 break;
335 default:
336 REG_UPDATE(DP_PIXEL_FORMAT, DP_PIXEL_ENCODING,
337 DP_PIXEL_ENCODING_TYPE_RGB444);
338 break;
339 }
340
341#if defined(CONFIG_DRM_AMD_DC_DCN1_0)
342 if (REG(DP_MSA_MISC))
343 misc1 = REG_READ(DP_MSA_MISC);
344#endif
345
346 /* set color depth */
347
348 switch (hw_crtc_timing.display_color_depth) {
349 case COLOR_DEPTH_666:
350 REG_UPDATE(DP_PIXEL_FORMAT, DP_COMPONENT_DEPTH,
351 0);
352 break;
353 case COLOR_DEPTH_888:
354 REG_UPDATE(DP_PIXEL_FORMAT, DP_COMPONENT_DEPTH,
355 DP_COMPONENT_PIXEL_DEPTH_8BPC);
356 break;
357 case COLOR_DEPTH_101010:
358 REG_UPDATE(DP_PIXEL_FORMAT, DP_COMPONENT_DEPTH,
359 DP_COMPONENT_PIXEL_DEPTH_10BPC);
360
361 break;
362 case COLOR_DEPTH_121212:
363 REG_UPDATE(DP_PIXEL_FORMAT, DP_COMPONENT_DEPTH,
364 DP_COMPONENT_PIXEL_DEPTH_12BPC);
365 break;
366 default:
367 REG_UPDATE(DP_PIXEL_FORMAT, DP_COMPONENT_DEPTH,
368 DP_COMPONENT_PIXEL_DEPTH_6BPC);
369 break;
370 }
371
372 /* set dynamic range and YCbCr range */
373
374
375#if defined(CONFIG_DRM_AMD_DC_DCN1_0)
376 switch (hw_crtc_timing.display_color_depth) {
377 case COLOR_DEPTH_666:
378 colorimetry_bpc = 0;
379 break;
380 case COLOR_DEPTH_888:
381 colorimetry_bpc = 1;
382 break;
383 case COLOR_DEPTH_101010:
384 colorimetry_bpc = 2;
385 break;
386 case COLOR_DEPTH_121212:
387 colorimetry_bpc = 3;
388 break;
389 default:
390 colorimetry_bpc = 0;
391 break;
392 }
393
394 misc0 = misc0 | synchronous_clock;
395 misc0 = colorimetry_bpc << 5;
396
397 if (REG(DP_MSA_TIMING_PARAM1)) {
398 switch (output_color_space) {
399 case COLOR_SPACE_SRGB:
400 misc0 = misc0 | 0x0;
401 misc1 = misc1 & ~0x80; /* bit7 = 0*/
402 dynamic_range_rgb = 0; /*full range*/
403 break;
404 case COLOR_SPACE_SRGB_LIMITED:
405 misc0 = misc0 | 0x8; /* bit3=1 */
406 misc1 = misc1 & ~0x80; /* bit7 = 0*/
407 dynamic_range_rgb = 1; /*limited range*/
408 break;
409 case COLOR_SPACE_YCBCR601:
410 case COLOR_SPACE_YCBCR601_LIMITED:
411 misc0 = misc0 | 0x8; /* bit3=1, bit4=0 */
412 misc1 = misc1 & ~0x80; /* bit7 = 0*/
413 dynamic_range_ycbcr = 0; /*bt601*/
414 if (hw_crtc_timing.pixel_encoding == PIXEL_ENCODING_YCBCR422)
415 misc0 = misc0 | 0x2; /* bit2=0, bit1=1 */
416 else if (hw_crtc_timing.pixel_encoding == PIXEL_ENCODING_YCBCR444)
417 misc0 = misc0 | 0x4; /* bit2=1, bit1=0 */
418 break;
419 case COLOR_SPACE_YCBCR709:
420 case COLOR_SPACE_YCBCR709_LIMITED:
421 misc0 = misc0 | 0x18; /* bit3=1, bit4=1 */
422 misc1 = misc1 & ~0x80; /* bit7 = 0*/
423 dynamic_range_ycbcr = 1; /*bt709*/
424 if (hw_crtc_timing.pixel_encoding == PIXEL_ENCODING_YCBCR422)
425 misc0 = misc0 | 0x2; /* bit2=0, bit1=1 */
426 else if (hw_crtc_timing.pixel_encoding == PIXEL_ENCODING_YCBCR444)
427 misc0 = misc0 | 0x4; /* bit2=1, bit1=0 */
428 break;
429 case COLOR_SPACE_2020_RGB_LIMITEDRANGE:
430 dynamic_range_rgb = 1; /*limited range*/
431 break;
432 case COLOR_SPACE_2020_RGB_FULLRANGE:
433 case COLOR_SPACE_2020_YCBCR:
434 case COLOR_SPACE_XR_RGB:
435 case COLOR_SPACE_MSREF_SCRGB:
436 case COLOR_SPACE_ADOBERGB:
437 case COLOR_SPACE_DCIP3:
438 case COLOR_SPACE_XV_YCC_709:
439 case COLOR_SPACE_XV_YCC_601:
440 case COLOR_SPACE_DISPLAYNATIVE:
441 case COLOR_SPACE_DOLBYVISION:
442 case COLOR_SPACE_APPCTRL:
443 case COLOR_SPACE_CUSTOMPOINTS:
444 case COLOR_SPACE_UNKNOWN:
445 /* do nothing */
446 break;
447 }
448 if (enc110->se_mask->DP_DYN_RANGE && enc110->se_mask->DP_YCBCR_RANGE)
449 REG_UPDATE_2(
450 DP_PIXEL_FORMAT,
451 DP_DYN_RANGE, dynamic_range_rgb,
452 DP_YCBCR_RANGE, dynamic_range_ycbcr);
453
454#if defined(CONFIG_DRM_AMD_DC_DCN1_0)
455 if (REG(DP_MSA_COLORIMETRY))
456 REG_SET(DP_MSA_COLORIMETRY, 0, DP_MSA_MISC0, misc0);
457
458 if (REG(DP_MSA_MISC))
459 REG_WRITE(DP_MSA_MISC, misc1); /* MSA_MISC1 */
460
461 /* dcn new register
462 * dc_crtc_timing is vesa dmt struct. data from edid
463 */
464 if (REG(DP_MSA_TIMING_PARAM1))
465 REG_SET_2(DP_MSA_TIMING_PARAM1, 0,
466 DP_MSA_HTOTAL, hw_crtc_timing.h_total,
467 DP_MSA_VTOTAL, hw_crtc_timing.v_total);
468#endif
469
470 /* calcuate from vesa timing parameters
471 * h_active_start related to leading edge of sync
472 */
473
474 h_blank = hw_crtc_timing.h_total - hw_crtc_timing.h_border_left -
475 hw_crtc_timing.h_addressable - hw_crtc_timing.h_border_right;
476
477 h_back_porch = h_blank - hw_crtc_timing.h_front_porch -
478 hw_crtc_timing.h_sync_width;
479
480 /* start at begining of left border */
481 h_active_start = hw_crtc_timing.h_sync_width + h_back_porch;
482
483
484 v_active_start = hw_crtc_timing.v_total - hw_crtc_timing.v_border_top -
485 hw_crtc_timing.v_addressable - hw_crtc_timing.v_border_bottom -
486 hw_crtc_timing.v_front_porch;
487
488
489#if defined(CONFIG_DRM_AMD_DC_DCN1_0)
490 /* start at begining of left border */
491 if (REG(DP_MSA_TIMING_PARAM2))
492 REG_SET_2(DP_MSA_TIMING_PARAM2, 0,
493 DP_MSA_HSTART, h_active_start,
494 DP_MSA_VSTART, v_active_start);
495
496 if (REG(DP_MSA_TIMING_PARAM3))
497 REG_SET_4(DP_MSA_TIMING_PARAM3, 0,
498 DP_MSA_HSYNCWIDTH,
499 hw_crtc_timing.h_sync_width,
500 DP_MSA_HSYNCPOLARITY,
501 !hw_crtc_timing.flags.HSYNC_POSITIVE_POLARITY,
502 DP_MSA_VSYNCWIDTH,
503 hw_crtc_timing.v_sync_width,
504 DP_MSA_VSYNCPOLARITY,
505 !hw_crtc_timing.flags.VSYNC_POSITIVE_POLARITY);
506
507 /* HWDITH include border or overscan */
508 if (REG(DP_MSA_TIMING_PARAM4))
509 REG_SET_2(DP_MSA_TIMING_PARAM4, 0,
510 DP_MSA_HWIDTH, hw_crtc_timing.h_border_left +
511 hw_crtc_timing.h_addressable + hw_crtc_timing.h_border_right,
512 DP_MSA_VHEIGHT, hw_crtc_timing.v_border_top +
513 hw_crtc_timing.v_addressable + hw_crtc_timing.v_border_bottom);
514#endif
515 }
516#endif
517}
518
519static void dce110_stream_encoder_set_stream_attribute_helper(
520 struct dce110_stream_encoder *enc110,
521 struct dc_crtc_timing *crtc_timing)
522{
523 if (enc110->regs->TMDS_CNTL) {
524 switch (crtc_timing->pixel_encoding) {
525 case PIXEL_ENCODING_YCBCR422:
526 REG_UPDATE(TMDS_CNTL, TMDS_PIXEL_ENCODING, 1);
527 break;
528 default:
529 REG_UPDATE(TMDS_CNTL, TMDS_PIXEL_ENCODING, 0);
530 break;
531 }
532 REG_UPDATE(TMDS_CNTL, TMDS_COLOR_FORMAT, 0);
533 } else if (enc110->regs->DIG_FE_CNTL) {
534 switch (crtc_timing->pixel_encoding) {
535 case PIXEL_ENCODING_YCBCR422:
536 REG_UPDATE(DIG_FE_CNTL, TMDS_PIXEL_ENCODING, 1);
537 break;
538 default:
539 REG_UPDATE(DIG_FE_CNTL, TMDS_PIXEL_ENCODING, 0);
540 break;
541 }
542 REG_UPDATE(DIG_FE_CNTL, TMDS_COLOR_FORMAT, 0);
543 }
544
545}
546
547/* setup stream encoder in hdmi mode */
548static void dce110_stream_encoder_hdmi_set_stream_attribute(
549 struct stream_encoder *enc,
550 struct dc_crtc_timing *crtc_timing,
551 int actual_pix_clk_khz,
552 bool enable_audio)
553{
554 struct dce110_stream_encoder *enc110 = DCE110STRENC_FROM_STRENC(enc);
555 struct bp_encoder_control cntl = {0};
556
557 cntl.action = ENCODER_CONTROL_SETUP;
558 cntl.engine_id = enc110->base.id;
559 cntl.signal = SIGNAL_TYPE_HDMI_TYPE_A;
560 cntl.enable_dp_audio = enable_audio;
561 cntl.pixel_clock = actual_pix_clk_khz;
562 cntl.lanes_number = LANE_COUNT_FOUR;
563
564 if (enc110->base.bp->funcs->encoder_control(
565 enc110->base.bp, &cntl) != BP_RESULT_OK)
566 return;
567
568 dce110_stream_encoder_set_stream_attribute_helper(enc110, crtc_timing);
569
570 /* setup HDMI engine */
571 if (!enc110->se_mask->HDMI_DATA_SCRAMBLE_EN) {
572 REG_UPDATE_3(HDMI_CONTROL,
573 HDMI_PACKET_GEN_VERSION, 1,
574 HDMI_KEEPOUT_MODE, 1,
575 HDMI_DEEP_COLOR_ENABLE, 0);
576 } else if (enc110->regs->DIG_FE_CNTL) {
577 REG_UPDATE_5(HDMI_CONTROL,
578 HDMI_PACKET_GEN_VERSION, 1,
579 HDMI_KEEPOUT_MODE, 1,
580 HDMI_DEEP_COLOR_ENABLE, 0,
581 HDMI_DATA_SCRAMBLE_EN, 0,
582 HDMI_CLOCK_CHANNEL_RATE, 0);
583 }
584
585 switch (crtc_timing->display_color_depth) {
586 case COLOR_DEPTH_888:
587 REG_UPDATE(HDMI_CONTROL, HDMI_DEEP_COLOR_DEPTH, 0);
588 break;
589 case COLOR_DEPTH_101010:
590 if (crtc_timing->pixel_encoding == PIXEL_ENCODING_YCBCR422) {
591 REG_UPDATE_2(HDMI_CONTROL,
592 HDMI_DEEP_COLOR_DEPTH, 1,
593 HDMI_DEEP_COLOR_ENABLE, 0);
594 } else {
595 REG_UPDATE_2(HDMI_CONTROL,
596 HDMI_DEEP_COLOR_DEPTH, 1,
597 HDMI_DEEP_COLOR_ENABLE, 1);
598 }
599 break;
600 case COLOR_DEPTH_121212:
601 if (crtc_timing->pixel_encoding == PIXEL_ENCODING_YCBCR422) {
602 REG_UPDATE_2(HDMI_CONTROL,
603 HDMI_DEEP_COLOR_DEPTH, 2,
604 HDMI_DEEP_COLOR_ENABLE, 0);
605 } else {
606 REG_UPDATE_2(HDMI_CONTROL,
607 HDMI_DEEP_COLOR_DEPTH, 2,
608 HDMI_DEEP_COLOR_ENABLE, 1);
609 }
610 break;
611 case COLOR_DEPTH_161616:
612 REG_UPDATE_2(HDMI_CONTROL,
613 HDMI_DEEP_COLOR_DEPTH, 3,
614 HDMI_DEEP_COLOR_ENABLE, 1);
615 break;
616 default:
617 break;
618 }
619
620 if (enc110->se_mask->HDMI_DATA_SCRAMBLE_EN) {
621 if (actual_pix_clk_khz >= HDMI_CLOCK_CHANNEL_RATE_MORE_340M) {
622 /* enable HDMI data scrambler
623 * HDMI_CLOCK_CHANNEL_RATE_MORE_340M
624 * Clock channel frequency is 1/4 of character rate.
625 */
626 REG_UPDATE_2(HDMI_CONTROL,
627 HDMI_DATA_SCRAMBLE_EN, 1,
628 HDMI_CLOCK_CHANNEL_RATE, 1);
629 } else if (crtc_timing->flags.LTE_340MCSC_SCRAMBLE) {
630
631 /* TODO: New feature for DCE11, still need to implement */
632
633 /* enable HDMI data scrambler
634 * HDMI_CLOCK_CHANNEL_FREQ_EQUAL_TO_CHAR_RATE
635 * Clock channel frequency is the same
636 * as character rate
637 */
638 REG_UPDATE_2(HDMI_CONTROL,
639 HDMI_DATA_SCRAMBLE_EN, 1,
640 HDMI_CLOCK_CHANNEL_RATE, 0);
641 }
642 }
643
644 REG_UPDATE_3(HDMI_VBI_PACKET_CONTROL,
645 HDMI_GC_CONT, 1,
646 HDMI_GC_SEND, 1,
647 HDMI_NULL_SEND, 1);
648
649 /* following belongs to audio */
650 REG_UPDATE(HDMI_INFOFRAME_CONTROL0, HDMI_AUDIO_INFO_SEND, 1);
651
652 REG_UPDATE(AFMT_INFOFRAME_CONTROL0, AFMT_AUDIO_INFO_UPDATE, 1);
653
654 REG_UPDATE(HDMI_INFOFRAME_CONTROL1, HDMI_AUDIO_INFO_LINE,
655 VBI_LINE_0 + 2);
656
657 REG_UPDATE(HDMI_GC, HDMI_GC_AVMUTE, 0);
658
659}
660
661/* setup stream encoder in dvi mode */
662static void dce110_stream_encoder_dvi_set_stream_attribute(
663 struct stream_encoder *enc,
664 struct dc_crtc_timing *crtc_timing,
665 bool is_dual_link)
666{
667 struct dce110_stream_encoder *enc110 = DCE110STRENC_FROM_STRENC(enc);
668 struct bp_encoder_control cntl = {0};
669
670 cntl.action = ENCODER_CONTROL_SETUP;
671 cntl.engine_id = enc110->base.id;
672 cntl.signal = is_dual_link ?
673 SIGNAL_TYPE_DVI_DUAL_LINK : SIGNAL_TYPE_DVI_SINGLE_LINK;
674 cntl.enable_dp_audio = false;
675 cntl.pixel_clock = crtc_timing->pix_clk_100hz / 10;
676 cntl.lanes_number = (is_dual_link) ? LANE_COUNT_EIGHT : LANE_COUNT_FOUR;
677
678 if (enc110->base.bp->funcs->encoder_control(
679 enc110->base.bp, &cntl) != BP_RESULT_OK)
680 return;
681
682 ASSERT(crtc_timing->pixel_encoding == PIXEL_ENCODING_RGB);
683 ASSERT(crtc_timing->display_color_depth == COLOR_DEPTH_888);
684 dce110_stream_encoder_set_stream_attribute_helper(enc110, crtc_timing);
685}
686
687/* setup stream encoder in LVDS mode */
688static void dce110_stream_encoder_lvds_set_stream_attribute(
689 struct stream_encoder *enc,
690 struct dc_crtc_timing *crtc_timing)
691{
692 struct dce110_stream_encoder *enc110 = DCE110STRENC_FROM_STRENC(enc);
693 struct bp_encoder_control cntl = {0};
694
695 cntl.action = ENCODER_CONTROL_SETUP;
696 cntl.engine_id = enc110->base.id;
697 cntl.signal = SIGNAL_TYPE_LVDS;
698 cntl.enable_dp_audio = false;
699 cntl.pixel_clock = crtc_timing->pix_clk_100hz / 10;
700 cntl.lanes_number = LANE_COUNT_FOUR;
701
702 if (enc110->base.bp->funcs->encoder_control(
703 enc110->base.bp, &cntl) != BP_RESULT_OK)
704 return;
705
706 ASSERT(crtc_timing->pixel_encoding == PIXEL_ENCODING_RGB);
707}
708
709static void dce110_stream_encoder_set_mst_bandwidth(
710 struct stream_encoder *enc,
711 struct fixed31_32 avg_time_slots_per_mtp)
712{
713 struct dce110_stream_encoder *enc110 = DCE110STRENC_FROM_STRENC(enc);
714 uint32_t x = dc_fixpt_floor(
715 avg_time_slots_per_mtp);
716 uint32_t y = dc_fixpt_ceil(
717 dc_fixpt_shl(
718 dc_fixpt_sub_int(
719 avg_time_slots_per_mtp,
720 x),
721 26));
722
723 {
724 REG_SET_2(DP_MSE_RATE_CNTL, 0,
725 DP_MSE_RATE_X, x,
726 DP_MSE_RATE_Y, y);
727 }
728
729 /* wait for update to be completed on the link */
730 /* i.e. DP_MSE_RATE_UPDATE_PENDING field (read only) */
731 /* is reset to 0 (not pending) */
732 REG_WAIT(DP_MSE_RATE_UPDATE, DP_MSE_RATE_UPDATE_PENDING,
733 0,
734 10, DP_MST_UPDATE_MAX_RETRY);
735}
736
737static void dce110_stream_encoder_update_hdmi_info_packets(
738 struct stream_encoder *enc,
739 const struct encoder_info_frame *info_frame)
740{
741 struct dce110_stream_encoder *enc110 = DCE110STRENC_FROM_STRENC(enc);
742
743 if (enc110->se_mask->HDMI_AVI_INFO_CONT &&
744 enc110->se_mask->HDMI_AVI_INFO_SEND) {
745
746 if (info_frame->avi.valid) {
747 const uint32_t *content =
748 (const uint32_t *) &info_frame->avi.sb[0];
749 /*we need turn on clock before programming AFMT block*/
750 if (REG(AFMT_CNTL))
751 REG_UPDATE(AFMT_CNTL, AFMT_AUDIO_CLOCK_EN, 1);
752
753 REG_WRITE(AFMT_AVI_INFO0, content[0]);
754
755 REG_WRITE(AFMT_AVI_INFO1, content[1]);
756
757 REG_WRITE(AFMT_AVI_INFO2, content[2]);
758
759 REG_WRITE(AFMT_AVI_INFO3, content[3]);
760
761 REG_UPDATE(AFMT_AVI_INFO3, AFMT_AVI_INFO_VERSION,
762 info_frame->avi.hb1);
763
764 REG_UPDATE_2(HDMI_INFOFRAME_CONTROL0,
765 HDMI_AVI_INFO_SEND, 1,
766 HDMI_AVI_INFO_CONT, 1);
767
768 REG_UPDATE(HDMI_INFOFRAME_CONTROL1, HDMI_AVI_INFO_LINE,
769 VBI_LINE_0 + 2);
770
771 } else {
772 REG_UPDATE_2(HDMI_INFOFRAME_CONTROL0,
773 HDMI_AVI_INFO_SEND, 0,
774 HDMI_AVI_INFO_CONT, 0);
775 }
776 }
777
778 if (enc110->se_mask->HDMI_AVI_INFO_CONT &&
779 enc110->se_mask->HDMI_AVI_INFO_SEND) {
780 dce110_update_hdmi_info_packet(enc110, 0, &info_frame->vendor);
781 dce110_update_hdmi_info_packet(enc110, 1, &info_frame->gamut);
782 dce110_update_hdmi_info_packet(enc110, 2, &info_frame->spd);
783 dce110_update_hdmi_info_packet(enc110, 3, &info_frame->hdrsmd);
784 }
785
786#if defined(CONFIG_DRM_AMD_DC_DCN1_0)
787 if (enc110->se_mask->HDMI_DB_DISABLE) {
788 /* for bring up, disable dp double TODO */
789 if (REG(HDMI_DB_CONTROL))
790 REG_UPDATE(HDMI_DB_CONTROL, HDMI_DB_DISABLE, 1);
791
792 dce110_update_hdmi_info_packet(enc110, 0, &info_frame->avi);
793 dce110_update_hdmi_info_packet(enc110, 1, &info_frame->vendor);
794 dce110_update_hdmi_info_packet(enc110, 2, &info_frame->gamut);
795 dce110_update_hdmi_info_packet(enc110, 3, &info_frame->spd);
796 dce110_update_hdmi_info_packet(enc110, 4, &info_frame->hdrsmd);
797 }
798#endif
799}
800
801static void dce110_stream_encoder_stop_hdmi_info_packets(
802 struct stream_encoder *enc)
803{
804 struct dce110_stream_encoder *enc110 = DCE110STRENC_FROM_STRENC(enc);
805
806 /* stop generic packets 0 & 1 on HDMI */
807 REG_SET_6(HDMI_GENERIC_PACKET_CONTROL0, 0,
808 HDMI_GENERIC1_CONT, 0,
809 HDMI_GENERIC1_LINE, 0,
810 HDMI_GENERIC1_SEND, 0,
811 HDMI_GENERIC0_CONT, 0,
812 HDMI_GENERIC0_LINE, 0,
813 HDMI_GENERIC0_SEND, 0);
814
815 /* stop generic packets 2 & 3 on HDMI */
816 REG_SET_6(HDMI_GENERIC_PACKET_CONTROL1, 0,
817 HDMI_GENERIC0_CONT, 0,
818 HDMI_GENERIC0_LINE, 0,
819 HDMI_GENERIC0_SEND, 0,
820 HDMI_GENERIC1_CONT, 0,
821 HDMI_GENERIC1_LINE, 0,
822 HDMI_GENERIC1_SEND, 0);
823
824#if defined(CONFIG_DRM_AMD_DC_DCN1_0)
825 /* stop generic packets 2 & 3 on HDMI */
826 if (REG(HDMI_GENERIC_PACKET_CONTROL2))
827 REG_SET_6(HDMI_GENERIC_PACKET_CONTROL2, 0,
828 HDMI_GENERIC0_CONT, 0,
829 HDMI_GENERIC0_LINE, 0,
830 HDMI_GENERIC0_SEND, 0,
831 HDMI_GENERIC1_CONT, 0,
832 HDMI_GENERIC1_LINE, 0,
833 HDMI_GENERIC1_SEND, 0);
834
835 if (REG(HDMI_GENERIC_PACKET_CONTROL3))
836 REG_SET_6(HDMI_GENERIC_PACKET_CONTROL3, 0,
837 HDMI_GENERIC0_CONT, 0,
838 HDMI_GENERIC0_LINE, 0,
839 HDMI_GENERIC0_SEND, 0,
840 HDMI_GENERIC1_CONT, 0,
841 HDMI_GENERIC1_LINE, 0,
842 HDMI_GENERIC1_SEND, 0);
843#endif
844}
845
846static void dce110_stream_encoder_update_dp_info_packets(
847 struct stream_encoder *enc,
848 const struct encoder_info_frame *info_frame)
849{
850 struct dce110_stream_encoder *enc110 = DCE110STRENC_FROM_STRENC(enc);
851 uint32_t value = 0;
852
853 if (info_frame->vsc.valid)
854 dce110_update_generic_info_packet(
855 enc110,
856 0, /* packetIndex */
857 &info_frame->vsc);
858
859 if (info_frame->spd.valid)
860 dce110_update_generic_info_packet(
861 enc110,
862 2, /* packetIndex */
863 &info_frame->spd);
864
865 if (info_frame->hdrsmd.valid)
866 dce110_update_generic_info_packet(
867 enc110,
868 3, /* packetIndex */
869 &info_frame->hdrsmd);
870
871 /* enable/disable transmission of packet(s).
872 * If enabled, packet transmission begins on the next frame
873 */
874 REG_UPDATE(DP_SEC_CNTL, DP_SEC_GSP0_ENABLE, info_frame->vsc.valid);
875 REG_UPDATE(DP_SEC_CNTL, DP_SEC_GSP2_ENABLE, info_frame->spd.valid);
876 REG_UPDATE(DP_SEC_CNTL, DP_SEC_GSP3_ENABLE, info_frame->hdrsmd.valid);
877
878 /* This bit is the master enable bit.
879 * When enabling secondary stream engine,
880 * this master bit must also be set.
881 * This register shared with audio info frame.
882 * Therefore we need to enable master bit
883 * if at least on of the fields is not 0
884 */
885 value = REG_READ(DP_SEC_CNTL);
886 if (value)
887 REG_UPDATE(DP_SEC_CNTL, DP_SEC_STREAM_ENABLE, 1);
888}
889
890static void dce110_stream_encoder_stop_dp_info_packets(
891 struct stream_encoder *enc)
892{
893 /* stop generic packets on DP */
894 struct dce110_stream_encoder *enc110 = DCE110STRENC_FROM_STRENC(enc);
895 uint32_t value = 0;
896
897 if (enc110->se_mask->DP_SEC_AVI_ENABLE) {
898 REG_SET_7(DP_SEC_CNTL, 0,
899 DP_SEC_GSP0_ENABLE, 0,
900 DP_SEC_GSP1_ENABLE, 0,
901 DP_SEC_GSP2_ENABLE, 0,
902 DP_SEC_GSP3_ENABLE, 0,
903 DP_SEC_AVI_ENABLE, 0,
904 DP_SEC_MPG_ENABLE, 0,
905 DP_SEC_STREAM_ENABLE, 0);
906 }
907
908 /* this register shared with audio info frame.
909 * therefore we need to keep master enabled
910 * if at least one of the fields is not 0 */
911 value = REG_READ(DP_SEC_CNTL);
912 if (value)
913 REG_UPDATE(DP_SEC_CNTL, DP_SEC_STREAM_ENABLE, 1);
914
915}
916
917static void dce110_stream_encoder_dp_blank(
918 struct stream_encoder *enc)
919{
920 struct dce110_stream_encoder *enc110 = DCE110STRENC_FROM_STRENC(enc);
921 uint32_t reg1 = 0;
922 uint32_t max_retries = DP_BLANK_MAX_RETRY * 10;
923
924 /* Note: For CZ, we are changing driver default to disable
925 * stream deferred to next VBLANK. If results are positive, we
926 * will make the same change to all DCE versions. There are a
927 * handful of panels that cannot handle disable stream at
928 * HBLANK and will result in a white line flash across the
929 * screen on stream disable. */
930 REG_GET(DP_VID_STREAM_CNTL, DP_VID_STREAM_ENABLE, ®1);
931 if ((reg1 & 0x1) == 0)
932 /*stream not enabled*/
933 return;
934 /* Specify the video stream disable point
935 * (2 = start of the next vertical blank) */
936 REG_UPDATE(DP_VID_STREAM_CNTL, DP_VID_STREAM_DIS_DEFER, 2);
937 /* Larger delay to wait until VBLANK - use max retry of
938 * 10us*3000=30ms. This covers 16.6ms of typical 60 Hz mode +
939 * a little more because we may not trust delay accuracy.
940 */
941 max_retries = DP_BLANK_MAX_RETRY * 150;
942
943 /* disable DP stream */
944 REG_UPDATE(DP_VID_STREAM_CNTL, DP_VID_STREAM_ENABLE, 0);
945
946 /* the encoder stops sending the video stream
947 * at the start of the vertical blanking.
948 * Poll for DP_VID_STREAM_STATUS == 0
949 */
950
951 REG_WAIT(DP_VID_STREAM_CNTL, DP_VID_STREAM_STATUS,
952 0,
953 10, max_retries);
954
955 /* Tell the DP encoder to ignore timing from CRTC, must be done after
956 * the polling. If we set DP_STEER_FIFO_RESET before DP stream blank is
957 * complete, stream status will be stuck in video stream enabled state,
958 * i.e. DP_VID_STREAM_STATUS stuck at 1.
959 */
960
961 REG_UPDATE(DP_STEER_FIFO, DP_STEER_FIFO_RESET, true);
962}
963
964/* output video stream to link encoder */
965static void dce110_stream_encoder_dp_unblank(
966 struct stream_encoder *enc,
967 const struct encoder_unblank_param *param)
968{
969 struct dce110_stream_encoder *enc110 = DCE110STRENC_FROM_STRENC(enc);
970
971 if (param->link_settings.link_rate != LINK_RATE_UNKNOWN) {
972 uint32_t n_vid = 0x8000;
973 uint32_t m_vid;
974
975 /* M / N = Fstream / Flink
976 * m_vid / n_vid = pixel rate / link rate
977 */
978
979 uint64_t m_vid_l = n_vid;
980
981 m_vid_l *= param->timing.pix_clk_100hz / 10;
982 m_vid_l = div_u64(m_vid_l,
983 param->link_settings.link_rate
984 * LINK_RATE_REF_FREQ_IN_KHZ);
985
986 m_vid = (uint32_t) m_vid_l;
987
988 /* enable auto measurement */
989
990 REG_UPDATE(DP_VID_TIMING, DP_VID_M_N_GEN_EN, 0);
991
992 /* auto measurement need 1 full 0x8000 symbol cycle to kick in,
993 * therefore program initial value for Mvid and Nvid
994 */
995
996 REG_UPDATE(DP_VID_N, DP_VID_N, n_vid);
997
998 REG_UPDATE(DP_VID_M, DP_VID_M, m_vid);
999
1000 REG_UPDATE(DP_VID_TIMING, DP_VID_M_N_GEN_EN, 1);
1001 }
1002
1003 /* set DIG_START to 0x1 to resync FIFO */
1004
1005 REG_UPDATE(DIG_FE_CNTL, DIG_START, 1);
1006
1007 /* switch DP encoder to CRTC data */
1008
1009 REG_UPDATE(DP_STEER_FIFO, DP_STEER_FIFO_RESET, 0);
1010
1011 /* wait 100us for DIG/DP logic to prime
1012 * (i.e. a few video lines)
1013 */
1014 udelay(100);
1015
1016 /* the hardware would start sending video at the start of the next DP
1017 * frame (i.e. rising edge of the vblank).
1018 * NOTE: We used to program DP_VID_STREAM_DIS_DEFER = 2 here, but this
1019 * register has no effect on enable transition! HW always guarantees
1020 * VID_STREAM enable at start of next frame, and this is not
1021 * programmable
1022 */
1023
1024 REG_UPDATE(DP_VID_STREAM_CNTL, DP_VID_STREAM_ENABLE, true);
1025}
1026
1027static void dce110_stream_encoder_set_avmute(
1028 struct stream_encoder *enc,
1029 bool enable)
1030{
1031 struct dce110_stream_encoder *enc110 = DCE110STRENC_FROM_STRENC(enc);
1032 unsigned int value = enable ? 1 : 0;
1033
1034 REG_UPDATE(HDMI_GC, HDMI_GC_AVMUTE, value);
1035}
1036
1037
1038#define DP_SEC_AUD_N__DP_SEC_AUD_N__DEFAULT 0x8000
1039#define DP_SEC_TIMESTAMP__DP_SEC_TIMESTAMP_MODE__AUTO_CALC 1
1040
1041#include "include/audio_types.h"
1042
1043/**
1044* speakersToChannels
1045*
1046* @brief
1047* translate speakers to channels
1048*
1049* FL - Front Left
1050* FR - Front Right
1051* RL - Rear Left
1052* RR - Rear Right
1053* RC - Rear Center
1054* FC - Front Center
1055* FLC - Front Left Center
1056* FRC - Front Right Center
1057* RLC - Rear Left Center
1058* RRC - Rear Right Center
1059* LFE - Low Freq Effect
1060*
1061* FC
1062* FLC FRC
1063* FL FR
1064*
1065* LFE
1066* ()
1067*
1068*
1069* RL RR
1070* RLC RRC
1071* RC
1072*
1073* ch 8 7 6 5 4 3 2 1
1074* 0b00000011 - - - - - - FR FL
1075* 0b00000111 - - - - - LFE FR FL
1076* 0b00001011 - - - - FC - FR FL
1077* 0b00001111 - - - - FC LFE FR FL
1078* 0b00010011 - - - RC - - FR FL
1079* 0b00010111 - - - RC - LFE FR FL
1080* 0b00011011 - - - RC FC - FR FL
1081* 0b00011111 - - - RC FC LFE FR FL
1082* 0b00110011 - - RR RL - - FR FL
1083* 0b00110111 - - RR RL - LFE FR FL
1084* 0b00111011 - - RR RL FC - FR FL
1085* 0b00111111 - - RR RL FC LFE FR FL
1086* 0b01110011 - RC RR RL - - FR FL
1087* 0b01110111 - RC RR RL - LFE FR FL
1088* 0b01111011 - RC RR RL FC - FR FL
1089* 0b01111111 - RC RR RL FC LFE FR FL
1090* 0b11110011 RRC RLC RR RL - - FR FL
1091* 0b11110111 RRC RLC RR RL - LFE FR FL
1092* 0b11111011 RRC RLC RR RL FC - FR FL
1093* 0b11111111 RRC RLC RR RL FC LFE FR FL
1094* 0b11000011 FRC FLC - - - - FR FL
1095* 0b11000111 FRC FLC - - - LFE FR FL
1096* 0b11001011 FRC FLC - - FC - FR FL
1097* 0b11001111 FRC FLC - - FC LFE FR FL
1098* 0b11010011 FRC FLC - RC - - FR FL
1099* 0b11010111 FRC FLC - RC - LFE FR FL
1100* 0b11011011 FRC FLC - RC FC - FR FL
1101* 0b11011111 FRC FLC - RC FC LFE FR FL
1102* 0b11110011 FRC FLC RR RL - - FR FL
1103* 0b11110111 FRC FLC RR RL - LFE FR FL
1104* 0b11111011 FRC FLC RR RL FC - FR FL
1105* 0b11111111 FRC FLC RR RL FC LFE FR FL
1106*
1107* @param
1108* speakers - speaker information as it comes from CEA audio block
1109*/
1110/* translate speakers to channels */
1111
1112union audio_cea_channels {
1113 uint8_t all;
1114 struct audio_cea_channels_bits {
1115 uint32_t FL:1;
1116 uint32_t FR:1;
1117 uint32_t LFE:1;
1118 uint32_t FC:1;
1119 uint32_t RL_RC:1;
1120 uint32_t RR:1;
1121 uint32_t RC_RLC_FLC:1;
1122 uint32_t RRC_FRC:1;
1123 } channels;
1124};
1125
1126struct audio_clock_info {
1127 /* pixel clock frequency*/
1128 uint32_t pixel_clock_in_10khz;
1129 /* N - 32KHz audio */
1130 uint32_t n_32khz;
1131 /* CTS - 32KHz audio*/
1132 uint32_t cts_32khz;
1133 uint32_t n_44khz;
1134 uint32_t cts_44khz;
1135 uint32_t n_48khz;
1136 uint32_t cts_48khz;
1137};
1138
1139/* 25.2MHz/1.001*/
1140/* 25.2MHz/1.001*/
1141/* 25.2MHz*/
1142/* 27MHz */
1143/* 27MHz*1.001*/
1144/* 27MHz*1.001*/
1145/* 54MHz*/
1146/* 54MHz*1.001*/
1147/* 74.25MHz/1.001*/
1148/* 74.25MHz*/
1149/* 148.5MHz/1.001*/
1150/* 148.5MHz*/
1151
1152static const struct audio_clock_info audio_clock_info_table[16] = {
1153 {2517, 4576, 28125, 7007, 31250, 6864, 28125},
1154 {2518, 4576, 28125, 7007, 31250, 6864, 28125},
1155 {2520, 4096, 25200, 6272, 28000, 6144, 25200},
1156 {2700, 4096, 27000, 6272, 30000, 6144, 27000},
1157 {2702, 4096, 27027, 6272, 30030, 6144, 27027},
1158 {2703, 4096, 27027, 6272, 30030, 6144, 27027},
1159 {5400, 4096, 54000, 6272, 60000, 6144, 54000},
1160 {5405, 4096, 54054, 6272, 60060, 6144, 54054},
1161 {7417, 11648, 210937, 17836, 234375, 11648, 140625},
1162 {7425, 4096, 74250, 6272, 82500, 6144, 74250},
1163 {14835, 11648, 421875, 8918, 234375, 5824, 140625},
1164 {14850, 4096, 148500, 6272, 165000, 6144, 148500},
1165 {29670, 5824, 421875, 4459, 234375, 5824, 281250},
1166 {29700, 3072, 222750, 4704, 247500, 5120, 247500},
1167 {59340, 5824, 843750, 8918, 937500, 5824, 562500},
1168 {59400, 3072, 445500, 9408, 990000, 6144, 594000}
1169};
1170
1171static const struct audio_clock_info audio_clock_info_table_36bpc[14] = {
1172 {2517, 9152, 84375, 7007, 48875, 9152, 56250},
1173 {2518, 9152, 84375, 7007, 48875, 9152, 56250},
1174 {2520, 4096, 37800, 6272, 42000, 6144, 37800},
1175 {2700, 4096, 40500, 6272, 45000, 6144, 40500},
1176 {2702, 8192, 81081, 6272, 45045, 8192, 54054},
1177 {2703, 8192, 81081, 6272, 45045, 8192, 54054},
1178 {5400, 4096, 81000, 6272, 90000, 6144, 81000},
1179 {5405, 4096, 81081, 6272, 90090, 6144, 81081},
1180 {7417, 11648, 316406, 17836, 351562, 11648, 210937},
1181 {7425, 4096, 111375, 6272, 123750, 6144, 111375},
1182 {14835, 11648, 632812, 17836, 703125, 11648, 421875},
1183 {14850, 4096, 222750, 6272, 247500, 6144, 222750},
1184 {29670, 5824, 632812, 8918, 703125, 5824, 421875},
1185 {29700, 4096, 445500, 4704, 371250, 5120, 371250}
1186};
1187
1188static const struct audio_clock_info audio_clock_info_table_48bpc[14] = {
1189 {2517, 4576, 56250, 7007, 62500, 6864, 56250},
1190 {2518, 4576, 56250, 7007, 62500, 6864, 56250},
1191 {2520, 4096, 50400, 6272, 56000, 6144, 50400},
1192 {2700, 4096, 54000, 6272, 60000, 6144, 54000},
1193 {2702, 4096, 54054, 6267, 60060, 8192, 54054},
1194 {2703, 4096, 54054, 6272, 60060, 8192, 54054},
1195 {5400, 4096, 108000, 6272, 120000, 6144, 108000},
1196 {5405, 4096, 108108, 6272, 120120, 6144, 108108},
1197 {7417, 11648, 421875, 17836, 468750, 11648, 281250},
1198 {7425, 4096, 148500, 6272, 165000, 6144, 148500},
1199 {14835, 11648, 843750, 8918, 468750, 11648, 281250},
1200 {14850, 4096, 297000, 6272, 330000, 6144, 297000},
1201 {29670, 5824, 843750, 4459, 468750, 5824, 562500},
1202 {29700, 3072, 445500, 4704, 495000, 5120, 495000}
1203
1204
1205};
1206
1207static union audio_cea_channels speakers_to_channels(
1208 struct audio_speaker_flags speaker_flags)
1209{
1210 union audio_cea_channels cea_channels = {0};
1211
1212 /* these are one to one */
1213 cea_channels.channels.FL = speaker_flags.FL_FR;
1214 cea_channels.channels.FR = speaker_flags.FL_FR;
1215 cea_channels.channels.LFE = speaker_flags.LFE;
1216 cea_channels.channels.FC = speaker_flags.FC;
1217
1218 /* if Rear Left and Right exist move RC speaker to channel 7
1219 * otherwise to channel 5
1220 */
1221 if (speaker_flags.RL_RR) {
1222 cea_channels.channels.RL_RC = speaker_flags.RL_RR;
1223 cea_channels.channels.RR = speaker_flags.RL_RR;
1224 cea_channels.channels.RC_RLC_FLC = speaker_flags.RC;
1225 } else {
1226 cea_channels.channels.RL_RC = speaker_flags.RC;
1227 }
1228
1229 /* FRONT Left Right Center and REAR Left Right Center are exclusive */
1230 if (speaker_flags.FLC_FRC) {
1231 cea_channels.channels.RC_RLC_FLC = speaker_flags.FLC_FRC;
1232 cea_channels.channels.RRC_FRC = speaker_flags.FLC_FRC;
1233 } else {
1234 cea_channels.channels.RC_RLC_FLC = speaker_flags.RLC_RRC;
1235 cea_channels.channels.RRC_FRC = speaker_flags.RLC_RRC;
1236 }
1237
1238 return cea_channels;
1239}
1240
1241static uint32_t calc_max_audio_packets_per_line(
1242 const struct audio_crtc_info *crtc_info)
1243{
1244 uint32_t max_packets_per_line;
1245
1246 max_packets_per_line =
1247 crtc_info->h_total - crtc_info->h_active;
1248
1249 if (crtc_info->pixel_repetition)
1250 max_packets_per_line *= crtc_info->pixel_repetition;
1251
1252 /* for other hdmi features */
1253 max_packets_per_line -= 58;
1254 /* for Control Period */
1255 max_packets_per_line -= 16;
1256 /* Number of Audio Packets per Line */
1257 max_packets_per_line /= 32;
1258
1259 return max_packets_per_line;
1260}
1261
1262static void get_audio_clock_info(
1263 enum dc_color_depth color_depth,
1264 uint32_t crtc_pixel_clock_in_khz,
1265 uint32_t actual_pixel_clock_in_khz,
1266 struct audio_clock_info *audio_clock_info)
1267{
1268 const struct audio_clock_info *clock_info;
1269 uint32_t index;
1270 uint32_t crtc_pixel_clock_in_10khz = crtc_pixel_clock_in_khz / 10;
1271 uint32_t audio_array_size;
1272
1273 switch (color_depth) {
1274 case COLOR_DEPTH_161616:
1275 clock_info = audio_clock_info_table_48bpc;
1276 audio_array_size = ARRAY_SIZE(
1277 audio_clock_info_table_48bpc);
1278 break;
1279 case COLOR_DEPTH_121212:
1280 clock_info = audio_clock_info_table_36bpc;
1281 audio_array_size = ARRAY_SIZE(
1282 audio_clock_info_table_36bpc);
1283 break;
1284 default:
1285 clock_info = audio_clock_info_table;
1286 audio_array_size = ARRAY_SIZE(
1287 audio_clock_info_table);
1288 break;
1289 }
1290
1291 if (clock_info != NULL) {
1292 /* search for exact pixel clock in table */
1293 for (index = 0; index < audio_array_size; index++) {
1294 if (clock_info[index].pixel_clock_in_10khz >
1295 crtc_pixel_clock_in_10khz)
1296 break; /* not match */
1297 else if (clock_info[index].pixel_clock_in_10khz ==
1298 crtc_pixel_clock_in_10khz) {
1299 /* match found */
1300 *audio_clock_info = clock_info[index];
1301 return;
1302 }
1303 }
1304 }
1305
1306 /* not found */
1307 if (actual_pixel_clock_in_khz == 0)
1308 actual_pixel_clock_in_khz = crtc_pixel_clock_in_khz;
1309
1310 /* See HDMI spec the table entry under
1311 * pixel clock of "Other". */
1312 audio_clock_info->pixel_clock_in_10khz =
1313 actual_pixel_clock_in_khz / 10;
1314 audio_clock_info->cts_32khz = actual_pixel_clock_in_khz;
1315 audio_clock_info->cts_44khz = actual_pixel_clock_in_khz;
1316 audio_clock_info->cts_48khz = actual_pixel_clock_in_khz;
1317
1318 audio_clock_info->n_32khz = 4096;
1319 audio_clock_info->n_44khz = 6272;
1320 audio_clock_info->n_48khz = 6144;
1321}
1322
1323static void dce110_se_audio_setup(
1324 struct stream_encoder *enc,
1325 unsigned int az_inst,
1326 struct audio_info *audio_info)
1327{
1328 struct dce110_stream_encoder *enc110 = DCE110STRENC_FROM_STRENC(enc);
1329
1330 uint32_t speakers = 0;
1331 uint32_t channels = 0;
1332
1333 ASSERT(audio_info);
1334 if (audio_info == NULL)
1335 /* This should not happen.it does so we don't get BSOD*/
1336 return;
1337
1338 speakers = audio_info->flags.info.ALLSPEAKERS;
1339 channels = speakers_to_channels(audio_info->flags.speaker_flags).all;
1340
1341 /* setup the audio stream source select (audio -> dig mapping) */
1342 REG_SET(AFMT_AUDIO_SRC_CONTROL, 0, AFMT_AUDIO_SRC_SELECT, az_inst);
1343
1344 /* Channel allocation */
1345 REG_UPDATE(AFMT_AUDIO_PACKET_CONTROL2, AFMT_AUDIO_CHANNEL_ENABLE, channels);
1346}
1347
1348static void dce110_se_setup_hdmi_audio(
1349 struct stream_encoder *enc,
1350 const struct audio_crtc_info *crtc_info)
1351{
1352 struct dce110_stream_encoder *enc110 = DCE110STRENC_FROM_STRENC(enc);
1353
1354 struct audio_clock_info audio_clock_info = {0};
1355 uint32_t max_packets_per_line;
1356
1357 /* For now still do calculation, although this field is ignored when
1358 above HDMI_PACKET_GEN_VERSION set to 1 */
1359 max_packets_per_line = calc_max_audio_packets_per_line(crtc_info);
1360
1361 /* HDMI_AUDIO_PACKET_CONTROL */
1362 REG_UPDATE_2(HDMI_AUDIO_PACKET_CONTROL,
1363 HDMI_AUDIO_PACKETS_PER_LINE, max_packets_per_line,
1364 HDMI_AUDIO_DELAY_EN, 1);
1365
1366 /* AFMT_AUDIO_PACKET_CONTROL */
1367 REG_UPDATE(AFMT_AUDIO_PACKET_CONTROL, AFMT_60958_CS_UPDATE, 1);
1368
1369 /* AFMT_AUDIO_PACKET_CONTROL2 */
1370 REG_UPDATE_2(AFMT_AUDIO_PACKET_CONTROL2,
1371 AFMT_AUDIO_LAYOUT_OVRD, 0,
1372 AFMT_60958_OSF_OVRD, 0);
1373
1374 /* HDMI_ACR_PACKET_CONTROL */
1375 REG_UPDATE_3(HDMI_ACR_PACKET_CONTROL,
1376 HDMI_ACR_AUTO_SEND, 1,
1377 HDMI_ACR_SOURCE, 0,
1378 HDMI_ACR_AUDIO_PRIORITY, 0);
1379
1380 /* Program audio clock sample/regeneration parameters */
1381 get_audio_clock_info(crtc_info->color_depth,
1382 crtc_info->requested_pixel_clock,
1383 crtc_info->calculated_pixel_clock,
1384 &audio_clock_info);
1385 DC_LOG_HW_AUDIO(
1386 "\n%s:Input::requested_pixel_clock = %d" \
1387 "calculated_pixel_clock = %d \n", __func__, \
1388 crtc_info->requested_pixel_clock, \
1389 crtc_info->calculated_pixel_clock);
1390
1391 /* HDMI_ACR_32_0__HDMI_ACR_CTS_32_MASK */
1392 REG_UPDATE(HDMI_ACR_32_0, HDMI_ACR_CTS_32, audio_clock_info.cts_32khz);
1393
1394 /* HDMI_ACR_32_1__HDMI_ACR_N_32_MASK */
1395 REG_UPDATE(HDMI_ACR_32_1, HDMI_ACR_N_32, audio_clock_info.n_32khz);
1396
1397 /* HDMI_ACR_44_0__HDMI_ACR_CTS_44_MASK */
1398 REG_UPDATE(HDMI_ACR_44_0, HDMI_ACR_CTS_44, audio_clock_info.cts_44khz);
1399
1400 /* HDMI_ACR_44_1__HDMI_ACR_N_44_MASK */
1401 REG_UPDATE(HDMI_ACR_44_1, HDMI_ACR_N_44, audio_clock_info.n_44khz);
1402
1403 /* HDMI_ACR_48_0__HDMI_ACR_CTS_48_MASK */
1404 REG_UPDATE(HDMI_ACR_48_0, HDMI_ACR_CTS_48, audio_clock_info.cts_48khz);
1405
1406 /* HDMI_ACR_48_1__HDMI_ACR_N_48_MASK */
1407 REG_UPDATE(HDMI_ACR_48_1, HDMI_ACR_N_48, audio_clock_info.n_48khz);
1408
1409 /* Video driver cannot know in advance which sample rate will
1410 be used by HD Audio driver
1411 HDMI_ACR_PACKET_CONTROL__HDMI_ACR_N_MULTIPLE field is
1412 programmed below in interruppt callback */
1413
1414 /* AFMT_60958_0__AFMT_60958_CS_CHANNEL_NUMBER_L_MASK &
1415 AFMT_60958_0__AFMT_60958_CS_CLOCK_ACCURACY_MASK */
1416 REG_UPDATE_2(AFMT_60958_0,
1417 AFMT_60958_CS_CHANNEL_NUMBER_L, 1,
1418 AFMT_60958_CS_CLOCK_ACCURACY, 0);
1419
1420 /* AFMT_60958_1 AFMT_60958_CS_CHALNNEL_NUMBER_R */
1421 REG_UPDATE(AFMT_60958_1, AFMT_60958_CS_CHANNEL_NUMBER_R, 2);
1422
1423 /*AFMT_60958_2 now keep this settings until
1424 * Programming guide comes out*/
1425 REG_UPDATE_6(AFMT_60958_2,
1426 AFMT_60958_CS_CHANNEL_NUMBER_2, 3,
1427 AFMT_60958_CS_CHANNEL_NUMBER_3, 4,
1428 AFMT_60958_CS_CHANNEL_NUMBER_4, 5,
1429 AFMT_60958_CS_CHANNEL_NUMBER_5, 6,
1430 AFMT_60958_CS_CHANNEL_NUMBER_6, 7,
1431 AFMT_60958_CS_CHANNEL_NUMBER_7, 8);
1432}
1433
1434static void dce110_se_setup_dp_audio(
1435 struct stream_encoder *enc)
1436{
1437 struct dce110_stream_encoder *enc110 = DCE110STRENC_FROM_STRENC(enc);
1438
1439 /* --- DP Audio packet configurations --- */
1440
1441 /* ATP Configuration */
1442 REG_SET(DP_SEC_AUD_N, 0,
1443 DP_SEC_AUD_N, DP_SEC_AUD_N__DP_SEC_AUD_N__DEFAULT);
1444
1445 /* Async/auto-calc timestamp mode */
1446 REG_SET(DP_SEC_TIMESTAMP, 0, DP_SEC_TIMESTAMP_MODE,
1447 DP_SEC_TIMESTAMP__DP_SEC_TIMESTAMP_MODE__AUTO_CALC);
1448
1449 /* --- The following are the registers
1450 * copied from the SetupHDMI --- */
1451
1452 /* AFMT_AUDIO_PACKET_CONTROL */
1453 REG_UPDATE(AFMT_AUDIO_PACKET_CONTROL, AFMT_60958_CS_UPDATE, 1);
1454
1455 /* AFMT_AUDIO_PACKET_CONTROL2 */
1456 /* Program the ATP and AIP next */
1457 REG_UPDATE_2(AFMT_AUDIO_PACKET_CONTROL2,
1458 AFMT_AUDIO_LAYOUT_OVRD, 0,
1459 AFMT_60958_OSF_OVRD, 0);
1460
1461 /* AFMT_INFOFRAME_CONTROL0 */
1462 REG_UPDATE(AFMT_INFOFRAME_CONTROL0, AFMT_AUDIO_INFO_UPDATE, 1);
1463
1464 /* AFMT_60958_0__AFMT_60958_CS_CLOCK_ACCURACY_MASK */
1465 REG_UPDATE(AFMT_60958_0, AFMT_60958_CS_CLOCK_ACCURACY, 0);
1466}
1467
1468static void dce110_se_enable_audio_clock(
1469 struct stream_encoder *enc,
1470 bool enable)
1471{
1472 struct dce110_stream_encoder *enc110 = DCE110STRENC_FROM_STRENC(enc);
1473
1474 if (REG(AFMT_CNTL) == 0)
1475 return; /* DCE8/10 does not have this register */
1476
1477 REG_UPDATE(AFMT_CNTL, AFMT_AUDIO_CLOCK_EN, !!enable);
1478
1479 /* wait for AFMT clock to turn on,
1480 * expectation: this should complete in 1-2 reads
1481 *
1482 * REG_WAIT(AFMT_CNTL, AFMT_AUDIO_CLOCK_ON, !!enable, 1, 10);
1483 *
1484 * TODO: wait for clock_on does not work well. May need HW
1485 * program sequence. But audio seems work normally even without wait
1486 * for clock_on status change
1487 */
1488}
1489
1490static void dce110_se_enable_dp_audio(
1491 struct stream_encoder *enc)
1492{
1493 struct dce110_stream_encoder *enc110 = DCE110STRENC_FROM_STRENC(enc);
1494
1495 /* Enable Audio packets */
1496 REG_UPDATE(DP_SEC_CNTL, DP_SEC_ASP_ENABLE, 1);
1497
1498 /* Program the ATP and AIP next */
1499 REG_UPDATE_2(DP_SEC_CNTL,
1500 DP_SEC_ATP_ENABLE, 1,
1501 DP_SEC_AIP_ENABLE, 1);
1502
1503 /* Program STREAM_ENABLE after all the other enables. */
1504 REG_UPDATE(DP_SEC_CNTL, DP_SEC_STREAM_ENABLE, 1);
1505}
1506
1507static void dce110_se_disable_dp_audio(
1508 struct stream_encoder *enc)
1509{
1510 struct dce110_stream_encoder *enc110 = DCE110STRENC_FROM_STRENC(enc);
1511 uint32_t value = 0;
1512
1513 /* Disable Audio packets */
1514 REG_UPDATE_5(DP_SEC_CNTL,
1515 DP_SEC_ASP_ENABLE, 0,
1516 DP_SEC_ATP_ENABLE, 0,
1517 DP_SEC_AIP_ENABLE, 0,
1518 DP_SEC_ACM_ENABLE, 0,
1519 DP_SEC_STREAM_ENABLE, 0);
1520
1521 /* This register shared with encoder info frame. Therefore we need to
1522 keep master enabled if at least on of the fields is not 0 */
1523 value = REG_READ(DP_SEC_CNTL);
1524 if (value != 0)
1525 REG_UPDATE(DP_SEC_CNTL, DP_SEC_STREAM_ENABLE, 1);
1526
1527}
1528
1529void dce110_se_audio_mute_control(
1530 struct stream_encoder *enc,
1531 bool mute)
1532{
1533 struct dce110_stream_encoder *enc110 = DCE110STRENC_FROM_STRENC(enc);
1534
1535 REG_UPDATE(AFMT_AUDIO_PACKET_CONTROL, AFMT_AUDIO_SAMPLE_SEND, !mute);
1536}
1537
1538void dce110_se_dp_audio_setup(
1539 struct stream_encoder *enc,
1540 unsigned int az_inst,
1541 struct audio_info *info)
1542{
1543 dce110_se_audio_setup(enc, az_inst, info);
1544}
1545
1546void dce110_se_dp_audio_enable(
1547 struct stream_encoder *enc)
1548{
1549 dce110_se_enable_audio_clock(enc, true);
1550 dce110_se_setup_dp_audio(enc);
1551 dce110_se_enable_dp_audio(enc);
1552}
1553
1554void dce110_se_dp_audio_disable(
1555 struct stream_encoder *enc)
1556{
1557 dce110_se_disable_dp_audio(enc);
1558 dce110_se_enable_audio_clock(enc, false);
1559}
1560
1561void dce110_se_hdmi_audio_setup(
1562 struct stream_encoder *enc,
1563 unsigned int az_inst,
1564 struct audio_info *info,
1565 struct audio_crtc_info *audio_crtc_info)
1566{
1567 dce110_se_enable_audio_clock(enc, true);
1568 dce110_se_setup_hdmi_audio(enc, audio_crtc_info);
1569 dce110_se_audio_setup(enc, az_inst, info);
1570}
1571
1572void dce110_se_hdmi_audio_disable(
1573 struct stream_encoder *enc)
1574{
1575 dce110_se_enable_audio_clock(enc, false);
1576}
1577
1578
1579static void setup_stereo_sync(
1580 struct stream_encoder *enc,
1581 int tg_inst, bool enable)
1582{
1583 struct dce110_stream_encoder *enc110 = DCE110STRENC_FROM_STRENC(enc);
1584 REG_UPDATE(DIG_FE_CNTL, DIG_STEREOSYNC_SELECT, tg_inst);
1585 REG_UPDATE(DIG_FE_CNTL, DIG_STEREOSYNC_GATE_EN, !enable);
1586}
1587
1588static void dig_connect_to_otg(
1589 struct stream_encoder *enc,
1590 int tg_inst)
1591{
1592 struct dce110_stream_encoder *enc110 = DCE110STRENC_FROM_STRENC(enc);
1593
1594 REG_UPDATE(DIG_FE_CNTL, DIG_SOURCE_SELECT, tg_inst);
1595}
1596
1597static const struct stream_encoder_funcs dce110_str_enc_funcs = {
1598 .dp_set_stream_attribute =
1599 dce110_stream_encoder_dp_set_stream_attribute,
1600 .hdmi_set_stream_attribute =
1601 dce110_stream_encoder_hdmi_set_stream_attribute,
1602 .dvi_set_stream_attribute =
1603 dce110_stream_encoder_dvi_set_stream_attribute,
1604 .lvds_set_stream_attribute =
1605 dce110_stream_encoder_lvds_set_stream_attribute,
1606 .set_mst_bandwidth =
1607 dce110_stream_encoder_set_mst_bandwidth,
1608 .update_hdmi_info_packets =
1609 dce110_stream_encoder_update_hdmi_info_packets,
1610 .stop_hdmi_info_packets =
1611 dce110_stream_encoder_stop_hdmi_info_packets,
1612 .update_dp_info_packets =
1613 dce110_stream_encoder_update_dp_info_packets,
1614 .stop_dp_info_packets =
1615 dce110_stream_encoder_stop_dp_info_packets,
1616 .dp_blank =
1617 dce110_stream_encoder_dp_blank,
1618 .dp_unblank =
1619 dce110_stream_encoder_dp_unblank,
1620 .audio_mute_control = dce110_se_audio_mute_control,
1621
1622 .dp_audio_setup = dce110_se_dp_audio_setup,
1623 .dp_audio_enable = dce110_se_dp_audio_enable,
1624 .dp_audio_disable = dce110_se_dp_audio_disable,
1625
1626 .hdmi_audio_setup = dce110_se_hdmi_audio_setup,
1627 .hdmi_audio_disable = dce110_se_hdmi_audio_disable,
1628 .setup_stereo_sync = setup_stereo_sync,
1629 .set_avmute = dce110_stream_encoder_set_avmute,
1630 .dig_connect_to_otg = dig_connect_to_otg,
1631};
1632
1633void dce110_stream_encoder_construct(
1634 struct dce110_stream_encoder *enc110,
1635 struct dc_context *ctx,
1636 struct dc_bios *bp,
1637 enum engine_id eng_id,
1638 const struct dce110_stream_enc_registers *regs,
1639 const struct dce_stream_encoder_shift *se_shift,
1640 const struct dce_stream_encoder_mask *se_mask)
1641{
1642 enc110->base.funcs = &dce110_str_enc_funcs;
1643 enc110->base.ctx = ctx;
1644 enc110->base.id = eng_id;
1645 enc110->base.bp = bp;
1646 enc110->regs = regs;
1647 enc110->se_shift = se_shift;
1648 enc110->se_mask = se_mask;
1649}