evergreen_hdmi.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489
  1. /*
  2. * Copyright 2008 Advanced Micro Devices, Inc.
  3. * Copyright 2008 Red Hat Inc.
  4. * Copyright 2009 Christian König.
  5. *
  6. * Permission is hereby granted, free of charge, to any person obtaining a
  7. * copy of this software and associated documentation files (the "Software"),
  8. * to deal in the Software without restriction, including without limitation
  9. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  10. * and/or sell copies of the Software, and to permit persons to whom the
  11. * Software is furnished to do so, subject to the following conditions:
  12. *
  13. * The above copyright notice and this permission notice shall be included in
  14. * all copies or substantial portions of the Software.
  15. *
  16. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  19. * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
  20. * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  21. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  22. * OTHER DEALINGS IN THE SOFTWARE.
  23. *
  24. * Authors: Christian König
  25. * Rafał Miłecki
  26. */
  27. #include <linux/hdmi.h>
  28. #include <drm/drmP.h>
  29. #include <drm/radeon_drm.h>
  30. #include "radeon.h"
  31. #include "radeon_asic.h"
  32. #include "radeon_audio.h"
  33. #include "evergreend.h"
  34. #include "atom.h"
  35. /* enable the audio stream */
  36. void dce4_audio_enable(struct radeon_device *rdev,
  37. struct r600_audio_pin *pin,
  38. u8 enable_mask)
  39. {
  40. u32 tmp = RREG32(AZ_HOT_PLUG_CONTROL);
  41. if (!pin)
  42. return;
  43. if (enable_mask) {
  44. tmp |= AUDIO_ENABLED;
  45. if (enable_mask & 1)
  46. tmp |= PIN0_AUDIO_ENABLED;
  47. if (enable_mask & 2)
  48. tmp |= PIN1_AUDIO_ENABLED;
  49. if (enable_mask & 4)
  50. tmp |= PIN2_AUDIO_ENABLED;
  51. if (enable_mask & 8)
  52. tmp |= PIN3_AUDIO_ENABLED;
  53. } else {
  54. tmp &= ~(AUDIO_ENABLED |
  55. PIN0_AUDIO_ENABLED |
  56. PIN1_AUDIO_ENABLED |
  57. PIN2_AUDIO_ENABLED |
  58. PIN3_AUDIO_ENABLED);
  59. }
  60. WREG32(AZ_HOT_PLUG_CONTROL, tmp);
  61. }
  62. void evergreen_hdmi_update_acr(struct drm_encoder *encoder, long offset,
  63. const struct radeon_hdmi_acr *acr)
  64. {
  65. struct drm_device *dev = encoder->dev;
  66. struct radeon_device *rdev = dev->dev_private;
  67. int bpc = 8;
  68. if (encoder->crtc) {
  69. struct radeon_crtc *radeon_crtc = to_radeon_crtc(encoder->crtc);
  70. bpc = radeon_crtc->bpc;
  71. }
  72. if (bpc > 8)
  73. WREG32(HDMI_ACR_PACKET_CONTROL + offset,
  74. HDMI_ACR_AUTO_SEND); /* allow hw to sent ACR packets when required */
  75. else
  76. WREG32(HDMI_ACR_PACKET_CONTROL + offset,
  77. HDMI_ACR_SOURCE | /* select SW CTS value */
  78. HDMI_ACR_AUTO_SEND); /* allow hw to sent ACR packets when required */
  79. WREG32(HDMI_ACR_32_0 + offset, HDMI_ACR_CTS_32(acr->cts_32khz));
  80. WREG32(HDMI_ACR_32_1 + offset, acr->n_32khz);
  81. WREG32(HDMI_ACR_44_0 + offset, HDMI_ACR_CTS_44(acr->cts_44_1khz));
  82. WREG32(HDMI_ACR_44_1 + offset, acr->n_44_1khz);
  83. WREG32(HDMI_ACR_48_0 + offset, HDMI_ACR_CTS_48(acr->cts_48khz));
  84. WREG32(HDMI_ACR_48_1 + offset, acr->n_48khz);
  85. }
  86. void dce4_afmt_write_latency_fields(struct drm_encoder *encoder,
  87. struct drm_connector *connector, struct drm_display_mode *mode)
  88. {
  89. struct radeon_device *rdev = encoder->dev->dev_private;
  90. u32 tmp = 0;
  91. if (mode->flags & DRM_MODE_FLAG_INTERLACE) {
  92. if (connector->latency_present[1])
  93. tmp = VIDEO_LIPSYNC(connector->video_latency[1]) |
  94. AUDIO_LIPSYNC(connector->audio_latency[1]);
  95. else
  96. tmp = VIDEO_LIPSYNC(255) | AUDIO_LIPSYNC(255);
  97. } else {
  98. if (connector->latency_present[0])
  99. tmp = VIDEO_LIPSYNC(connector->video_latency[0]) |
  100. AUDIO_LIPSYNC(connector->audio_latency[0]);
  101. else
  102. tmp = VIDEO_LIPSYNC(255) | AUDIO_LIPSYNC(255);
  103. }
  104. WREG32_ENDPOINT(0, AZ_F0_CODEC_PIN0_CONTROL_RESPONSE_LIPSYNC, tmp);
  105. }
  106. void dce4_afmt_hdmi_write_speaker_allocation(struct drm_encoder *encoder,
  107. u8 *sadb, int sad_count)
  108. {
  109. struct radeon_device *rdev = encoder->dev->dev_private;
  110. u32 tmp;
  111. /* program the speaker allocation */
  112. tmp = RREG32_ENDPOINT(0, AZ_F0_CODEC_PIN0_CONTROL_CHANNEL_SPEAKER);
  113. tmp &= ~(DP_CONNECTION | SPEAKER_ALLOCATION_MASK);
  114. /* set HDMI mode */
  115. tmp |= HDMI_CONNECTION;
  116. if (sad_count)
  117. tmp |= SPEAKER_ALLOCATION(sadb[0]);
  118. else
  119. tmp |= SPEAKER_ALLOCATION(5); /* stereo */
  120. WREG32_ENDPOINT(0, AZ_F0_CODEC_PIN0_CONTROL_CHANNEL_SPEAKER, tmp);
  121. }
  122. void dce4_afmt_dp_write_speaker_allocation(struct drm_encoder *encoder,
  123. u8 *sadb, int sad_count)
  124. {
  125. struct radeon_device *rdev = encoder->dev->dev_private;
  126. u32 tmp;
  127. /* program the speaker allocation */
  128. tmp = RREG32_ENDPOINT(0, AZ_F0_CODEC_PIN0_CONTROL_CHANNEL_SPEAKER);
  129. tmp &= ~(HDMI_CONNECTION | SPEAKER_ALLOCATION_MASK);
  130. /* set DP mode */
  131. tmp |= DP_CONNECTION;
  132. if (sad_count)
  133. tmp |= SPEAKER_ALLOCATION(sadb[0]);
  134. else
  135. tmp |= SPEAKER_ALLOCATION(5); /* stereo */
  136. WREG32_ENDPOINT(0, AZ_F0_CODEC_PIN0_CONTROL_CHANNEL_SPEAKER, tmp);
  137. }
  138. void evergreen_hdmi_write_sad_regs(struct drm_encoder *encoder,
  139. struct cea_sad *sads, int sad_count)
  140. {
  141. int i;
  142. struct radeon_device *rdev = encoder->dev->dev_private;
  143. static const u16 eld_reg_to_type[][2] = {
  144. { AZ_F0_CODEC_PIN0_CONTROL_AUDIO_DESCRIPTOR0, HDMI_AUDIO_CODING_TYPE_PCM },
  145. { AZ_F0_CODEC_PIN0_CONTROL_AUDIO_DESCRIPTOR1, HDMI_AUDIO_CODING_TYPE_AC3 },
  146. { AZ_F0_CODEC_PIN0_CONTROL_AUDIO_DESCRIPTOR2, HDMI_AUDIO_CODING_TYPE_MPEG1 },
  147. { AZ_F0_CODEC_PIN0_CONTROL_AUDIO_DESCRIPTOR3, HDMI_AUDIO_CODING_TYPE_MP3 },
  148. { AZ_F0_CODEC_PIN0_CONTROL_AUDIO_DESCRIPTOR4, HDMI_AUDIO_CODING_TYPE_MPEG2 },
  149. { AZ_F0_CODEC_PIN0_CONTROL_AUDIO_DESCRIPTOR5, HDMI_AUDIO_CODING_TYPE_AAC_LC },
  150. { AZ_F0_CODEC_PIN0_CONTROL_AUDIO_DESCRIPTOR6, HDMI_AUDIO_CODING_TYPE_DTS },
  151. { AZ_F0_CODEC_PIN0_CONTROL_AUDIO_DESCRIPTOR7, HDMI_AUDIO_CODING_TYPE_ATRAC },
  152. { AZ_F0_CODEC_PIN0_CONTROL_AUDIO_DESCRIPTOR9, HDMI_AUDIO_CODING_TYPE_EAC3 },
  153. { AZ_F0_CODEC_PIN0_CONTROL_AUDIO_DESCRIPTOR10, HDMI_AUDIO_CODING_TYPE_DTS_HD },
  154. { AZ_F0_CODEC_PIN0_CONTROL_AUDIO_DESCRIPTOR11, HDMI_AUDIO_CODING_TYPE_MLP },
  155. { AZ_F0_CODEC_PIN0_CONTROL_AUDIO_DESCRIPTOR13, HDMI_AUDIO_CODING_TYPE_WMA_PRO },
  156. };
  157. for (i = 0; i < ARRAY_SIZE(eld_reg_to_type); i++) {
  158. u32 value = 0;
  159. u8 stereo_freqs = 0;
  160. int max_channels = -1;
  161. int j;
  162. for (j = 0; j < sad_count; j++) {
  163. struct cea_sad *sad = &sads[j];
  164. if (sad->format == eld_reg_to_type[i][1]) {
  165. if (sad->channels > max_channels) {
  166. value = MAX_CHANNELS(sad->channels) |
  167. DESCRIPTOR_BYTE_2(sad->byte2) |
  168. SUPPORTED_FREQUENCIES(sad->freq);
  169. max_channels = sad->channels;
  170. }
  171. if (sad->format == HDMI_AUDIO_CODING_TYPE_PCM)
  172. stereo_freqs |= sad->freq;
  173. else
  174. break;
  175. }
  176. }
  177. value |= SUPPORTED_FREQUENCIES_STEREO(stereo_freqs);
  178. WREG32_ENDPOINT(0, eld_reg_to_type[i][0], value);
  179. }
  180. }
  181. /*
  182. * build a AVI Info Frame
  183. */
  184. void evergreen_set_avi_packet(struct radeon_device *rdev, u32 offset,
  185. unsigned char *buffer, size_t size)
  186. {
  187. uint8_t *frame = buffer + 3;
  188. WREG32(AFMT_AVI_INFO0 + offset,
  189. frame[0x0] | (frame[0x1] << 8) | (frame[0x2] << 16) | (frame[0x3] << 24));
  190. WREG32(AFMT_AVI_INFO1 + offset,
  191. frame[0x4] | (frame[0x5] << 8) | (frame[0x6] << 16) | (frame[0x7] << 24));
  192. WREG32(AFMT_AVI_INFO2 + offset,
  193. frame[0x8] | (frame[0x9] << 8) | (frame[0xA] << 16) | (frame[0xB] << 24));
  194. WREG32(AFMT_AVI_INFO3 + offset,
  195. frame[0xC] | (frame[0xD] << 8) | (buffer[1] << 24));
  196. WREG32_P(HDMI_INFOFRAME_CONTROL1 + offset,
  197. HDMI_AVI_INFO_LINE(2), /* anything other than 0 */
  198. ~HDMI_AVI_INFO_LINE_MASK);
  199. }
  200. void dce4_hdmi_audio_set_dto(struct radeon_device *rdev,
  201. struct radeon_crtc *crtc, unsigned int clock)
  202. {
  203. unsigned int max_ratio = clock / 24000;
  204. u32 dto_phase;
  205. u32 wallclock_ratio;
  206. u32 value;
  207. if (max_ratio >= 8) {
  208. dto_phase = 192 * 1000;
  209. wallclock_ratio = 3;
  210. } else if (max_ratio >= 4) {
  211. dto_phase = 96 * 1000;
  212. wallclock_ratio = 2;
  213. } else if (max_ratio >= 2) {
  214. dto_phase = 48 * 1000;
  215. wallclock_ratio = 1;
  216. } else {
  217. dto_phase = 24 * 1000;
  218. wallclock_ratio = 0;
  219. }
  220. value = RREG32(DCCG_AUDIO_DTO0_CNTL) & ~DCCG_AUDIO_DTO_WALLCLOCK_RATIO_MASK;
  221. value |= DCCG_AUDIO_DTO_WALLCLOCK_RATIO(wallclock_ratio);
  222. value &= ~DCCG_AUDIO_DTO1_USE_512FBR_DTO;
  223. WREG32(DCCG_AUDIO_DTO0_CNTL, value);
  224. /* Two dtos; generally use dto0 for HDMI */
  225. value = 0;
  226. if (crtc)
  227. value |= DCCG_AUDIO_DTO0_SOURCE_SEL(crtc->crtc_id);
  228. WREG32(DCCG_AUDIO_DTO_SOURCE, value);
  229. /* Express [24MHz / target pixel clock] as an exact rational
  230. * number (coefficient of two integer numbers. DCCG_AUDIO_DTOx_PHASE
  231. * is the numerator, DCCG_AUDIO_DTOx_MODULE is the denominator
  232. */
  233. WREG32(DCCG_AUDIO_DTO0_PHASE, dto_phase);
  234. WREG32(DCCG_AUDIO_DTO0_MODULE, clock);
  235. }
  236. void dce4_dp_audio_set_dto(struct radeon_device *rdev,
  237. struct radeon_crtc *crtc, unsigned int clock)
  238. {
  239. u32 value;
  240. value = RREG32(DCCG_AUDIO_DTO1_CNTL) & ~DCCG_AUDIO_DTO_WALLCLOCK_RATIO_MASK;
  241. value |= DCCG_AUDIO_DTO1_USE_512FBR_DTO;
  242. WREG32(DCCG_AUDIO_DTO1_CNTL, value);
  243. /* Two dtos; generally use dto1 for DP */
  244. value = 0;
  245. value |= DCCG_AUDIO_DTO_SEL;
  246. if (crtc)
  247. value |= DCCG_AUDIO_DTO0_SOURCE_SEL(crtc->crtc_id);
  248. WREG32(DCCG_AUDIO_DTO_SOURCE, value);
  249. /* Express [24MHz / target pixel clock] as an exact rational
  250. * number (coefficient of two integer numbers. DCCG_AUDIO_DTOx_PHASE
  251. * is the numerator, DCCG_AUDIO_DTOx_MODULE is the denominator
  252. */
  253. if (ASIC_IS_DCE41(rdev)) {
  254. unsigned int div = (RREG32(DCE41_DENTIST_DISPCLK_CNTL) &
  255. DENTIST_DPREFCLK_WDIVIDER_MASK) >>
  256. DENTIST_DPREFCLK_WDIVIDER_SHIFT;
  257. div = radeon_audio_decode_dfs_div(div);
  258. if (div)
  259. clock = 100 * clock / div;
  260. }
  261. WREG32(DCCG_AUDIO_DTO1_PHASE, 24000);
  262. WREG32(DCCG_AUDIO_DTO1_MODULE, clock);
  263. }
  264. void dce4_set_vbi_packet(struct drm_encoder *encoder, u32 offset)
  265. {
  266. struct drm_device *dev = encoder->dev;
  267. struct radeon_device *rdev = dev->dev_private;
  268. WREG32(HDMI_VBI_PACKET_CONTROL + offset,
  269. HDMI_NULL_SEND | /* send null packets when required */
  270. HDMI_GC_SEND | /* send general control packets */
  271. HDMI_GC_CONT); /* send general control packets every frame */
  272. }
  273. void dce4_hdmi_set_color_depth(struct drm_encoder *encoder, u32 offset, int bpc)
  274. {
  275. struct drm_device *dev = encoder->dev;
  276. struct radeon_device *rdev = dev->dev_private;
  277. struct drm_connector *connector = radeon_get_connector_for_encoder(encoder);
  278. uint32_t val;
  279. val = RREG32(HDMI_CONTROL + offset);
  280. val &= ~HDMI_DEEP_COLOR_ENABLE;
  281. val &= ~HDMI_DEEP_COLOR_DEPTH_MASK;
  282. switch (bpc) {
  283. case 0:
  284. case 6:
  285. case 8:
  286. case 16:
  287. default:
  288. DRM_DEBUG("%s: Disabling hdmi deep color for %d bpc.\n",
  289. connector->name, bpc);
  290. break;
  291. case 10:
  292. val |= HDMI_DEEP_COLOR_ENABLE;
  293. val |= HDMI_DEEP_COLOR_DEPTH(HDMI_30BIT_DEEP_COLOR);
  294. DRM_DEBUG("%s: Enabling hdmi deep color 30 for 10 bpc.\n",
  295. connector->name);
  296. break;
  297. case 12:
  298. val |= HDMI_DEEP_COLOR_ENABLE;
  299. val |= HDMI_DEEP_COLOR_DEPTH(HDMI_36BIT_DEEP_COLOR);
  300. DRM_DEBUG("%s: Enabling hdmi deep color 36 for 12 bpc.\n",
  301. connector->name);
  302. break;
  303. }
  304. WREG32(HDMI_CONTROL + offset, val);
  305. }
  306. void dce4_set_audio_packet(struct drm_encoder *encoder, u32 offset)
  307. {
  308. struct drm_device *dev = encoder->dev;
  309. struct radeon_device *rdev = dev->dev_private;
  310. WREG32(AFMT_INFOFRAME_CONTROL0 + offset,
  311. AFMT_AUDIO_INFO_UPDATE); /* required for audio info values to be updated */
  312. WREG32(AFMT_60958_0 + offset,
  313. AFMT_60958_CS_CHANNEL_NUMBER_L(1));
  314. WREG32(AFMT_60958_1 + offset,
  315. AFMT_60958_CS_CHANNEL_NUMBER_R(2));
  316. WREG32(AFMT_60958_2 + offset,
  317. AFMT_60958_CS_CHANNEL_NUMBER_2(3) |
  318. AFMT_60958_CS_CHANNEL_NUMBER_3(4) |
  319. AFMT_60958_CS_CHANNEL_NUMBER_4(5) |
  320. AFMT_60958_CS_CHANNEL_NUMBER_5(6) |
  321. AFMT_60958_CS_CHANNEL_NUMBER_6(7) |
  322. AFMT_60958_CS_CHANNEL_NUMBER_7(8));
  323. WREG32(AFMT_AUDIO_PACKET_CONTROL2 + offset,
  324. AFMT_AUDIO_CHANNEL_ENABLE(0xff));
  325. WREG32(HDMI_AUDIO_PACKET_CONTROL + offset,
  326. HDMI_AUDIO_DELAY_EN(1) | /* set the default audio delay */
  327. HDMI_AUDIO_PACKETS_PER_LINE(3)); /* should be suffient for all audio modes and small enough for all hblanks */
  328. /* allow 60958 channel status and send audio packets fields to be updated */
  329. WREG32_OR(AFMT_AUDIO_PACKET_CONTROL + offset,
  330. AFMT_RESET_FIFO_WHEN_AUDIO_DIS | AFMT_60958_CS_UPDATE);
  331. }
  332. void dce4_set_mute(struct drm_encoder *encoder, u32 offset, bool mute)
  333. {
  334. struct drm_device *dev = encoder->dev;
  335. struct radeon_device *rdev = dev->dev_private;
  336. if (mute)
  337. WREG32_OR(HDMI_GC + offset, HDMI_GC_AVMUTE);
  338. else
  339. WREG32_AND(HDMI_GC + offset, ~HDMI_GC_AVMUTE);
  340. }
  341. void evergreen_hdmi_enable(struct drm_encoder *encoder, bool enable)
  342. {
  343. struct drm_device *dev = encoder->dev;
  344. struct radeon_device *rdev = dev->dev_private;
  345. struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
  346. struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv;
  347. if (!dig || !dig->afmt)
  348. return;
  349. if (enable) {
  350. struct drm_connector *connector = radeon_get_connector_for_encoder(encoder);
  351. if (connector && drm_detect_monitor_audio(radeon_connector_edid(connector))) {
  352. WREG32(HDMI_INFOFRAME_CONTROL0 + dig->afmt->offset,
  353. HDMI_AVI_INFO_SEND | /* enable AVI info frames */
  354. HDMI_AVI_INFO_CONT | /* required for audio info values to be updated */
  355. HDMI_AUDIO_INFO_SEND | /* enable audio info frames (frames won't be set until audio is enabled) */
  356. HDMI_AUDIO_INFO_CONT); /* required for audio info values to be updated */
  357. WREG32_OR(AFMT_AUDIO_PACKET_CONTROL + dig->afmt->offset,
  358. AFMT_AUDIO_SAMPLE_SEND);
  359. } else {
  360. WREG32(HDMI_INFOFRAME_CONTROL0 + dig->afmt->offset,
  361. HDMI_AVI_INFO_SEND | /* enable AVI info frames */
  362. HDMI_AVI_INFO_CONT); /* required for audio info values to be updated */
  363. WREG32_AND(AFMT_AUDIO_PACKET_CONTROL + dig->afmt->offset,
  364. ~AFMT_AUDIO_SAMPLE_SEND);
  365. }
  366. } else {
  367. WREG32_AND(AFMT_AUDIO_PACKET_CONTROL + dig->afmt->offset,
  368. ~AFMT_AUDIO_SAMPLE_SEND);
  369. WREG32(HDMI_INFOFRAME_CONTROL0 + dig->afmt->offset, 0);
  370. }
  371. dig->afmt->enabled = enable;
  372. DRM_DEBUG("%sabling HDMI interface @ 0x%04X for encoder 0x%x\n",
  373. enable ? "En" : "Dis", dig->afmt->offset, radeon_encoder->encoder_id);
  374. }
  375. void evergreen_dp_enable(struct drm_encoder *encoder, bool enable)
  376. {
  377. struct drm_device *dev = encoder->dev;
  378. struct radeon_device *rdev = dev->dev_private;
  379. struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
  380. struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv;
  381. struct drm_connector *connector = radeon_get_connector_for_encoder(encoder);
  382. if (!dig || !dig->afmt)
  383. return;
  384. if (enable && connector &&
  385. drm_detect_monitor_audio(radeon_connector_edid(connector))) {
  386. struct drm_connector *connector = radeon_get_connector_for_encoder(encoder);
  387. struct radeon_connector *radeon_connector = to_radeon_connector(connector);
  388. struct radeon_connector_atom_dig *dig_connector;
  389. uint32_t val;
  390. WREG32_OR(AFMT_AUDIO_PACKET_CONTROL + dig->afmt->offset,
  391. AFMT_AUDIO_SAMPLE_SEND);
  392. WREG32(EVERGREEN_DP_SEC_TIMESTAMP + dig->afmt->offset,
  393. EVERGREEN_DP_SEC_TIMESTAMP_MODE(1));
  394. if (!ASIC_IS_DCE6(rdev) && radeon_connector->con_priv) {
  395. dig_connector = radeon_connector->con_priv;
  396. val = RREG32(EVERGREEN_DP_SEC_AUD_N + dig->afmt->offset);
  397. val &= ~EVERGREEN_DP_SEC_N_BASE_MULTIPLE(0xf);
  398. if (dig_connector->dp_clock == 162000)
  399. val |= EVERGREEN_DP_SEC_N_BASE_MULTIPLE(3);
  400. else
  401. val |= EVERGREEN_DP_SEC_N_BASE_MULTIPLE(5);
  402. WREG32(EVERGREEN_DP_SEC_AUD_N + dig->afmt->offset, val);
  403. }
  404. WREG32(EVERGREEN_DP_SEC_CNTL + dig->afmt->offset,
  405. EVERGREEN_DP_SEC_ASP_ENABLE | /* Audio packet transmission */
  406. EVERGREEN_DP_SEC_ATP_ENABLE | /* Audio timestamp packet transmission */
  407. EVERGREEN_DP_SEC_AIP_ENABLE | /* Audio infoframe packet transmission */
  408. EVERGREEN_DP_SEC_STREAM_ENABLE); /* Master enable for secondary stream engine */
  409. } else {
  410. WREG32(EVERGREEN_DP_SEC_CNTL + dig->afmt->offset, 0);
  411. WREG32_AND(AFMT_AUDIO_PACKET_CONTROL + dig->afmt->offset,
  412. ~AFMT_AUDIO_SAMPLE_SEND);
  413. }
  414. dig->afmt->enabled = enable;
  415. }