r600_hdmi.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586
  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. */
  26. #include "drmP.h"
  27. #include "radeon_drm.h"
  28. #include "radeon.h"
  29. #include "radeon_asic.h"
  30. #include "atom.h"
  31. /*
  32. * HDMI color format
  33. */
  34. enum r600_hdmi_color_format {
  35. RGB = 0,
  36. YCC_422 = 1,
  37. YCC_444 = 2
  38. };
  39. /*
  40. * IEC60958 status bits
  41. */
  42. enum r600_hdmi_iec_status_bits {
  43. AUDIO_STATUS_DIG_ENABLE = 0x01,
  44. AUDIO_STATUS_V = 0x02,
  45. AUDIO_STATUS_VCFG = 0x04,
  46. AUDIO_STATUS_EMPHASIS = 0x08,
  47. AUDIO_STATUS_COPYRIGHT = 0x10,
  48. AUDIO_STATUS_NONAUDIO = 0x20,
  49. AUDIO_STATUS_PROFESSIONAL = 0x40,
  50. AUDIO_STATUS_LEVEL = 0x80
  51. };
  52. struct {
  53. uint32_t Clock;
  54. int N_32kHz;
  55. int CTS_32kHz;
  56. int N_44_1kHz;
  57. int CTS_44_1kHz;
  58. int N_48kHz;
  59. int CTS_48kHz;
  60. } r600_hdmi_ACR[] = {
  61. /* 32kHz 44.1kHz 48kHz */
  62. /* Clock N CTS N CTS N CTS */
  63. { 25174, 4576, 28125, 7007, 31250, 6864, 28125 }, /* 25,20/1.001 MHz */
  64. { 25200, 4096, 25200, 6272, 28000, 6144, 25200 }, /* 25.20 MHz */
  65. { 27000, 4096, 27000, 6272, 30000, 6144, 27000 }, /* 27.00 MHz */
  66. { 27027, 4096, 27027, 6272, 30030, 6144, 27027 }, /* 27.00*1.001 MHz */
  67. { 54000, 4096, 54000, 6272, 60000, 6144, 54000 }, /* 54.00 MHz */
  68. { 54054, 4096, 54054, 6272, 60060, 6144, 54054 }, /* 54.00*1.001 MHz */
  69. { 74175, 11648, 210937, 17836, 234375, 11648, 140625 }, /* 74.25/1.001 MHz */
  70. { 74250, 4096, 74250, 6272, 82500, 6144, 74250 }, /* 74.25 MHz */
  71. { 148351, 11648, 421875, 8918, 234375, 5824, 140625 }, /* 148.50/1.001 MHz */
  72. { 148500, 4096, 148500, 6272, 165000, 6144, 148500 }, /* 148.50 MHz */
  73. { 0, 4096, 0, 6272, 0, 6144, 0 } /* Other */
  74. };
  75. /*
  76. * calculate CTS value if it's not found in the table
  77. */
  78. static void r600_hdmi_calc_CTS(uint32_t clock, int *CTS, int N, int freq)
  79. {
  80. if (*CTS == 0)
  81. *CTS = clock * N / (128 * freq) * 1000;
  82. DRM_DEBUG("Using ACR timing N=%d CTS=%d for frequency %d\n",
  83. N, *CTS, freq);
  84. }
  85. /*
  86. * update the N and CTS parameters for a given pixel clock rate
  87. */
  88. static void r600_hdmi_update_ACR(struct drm_encoder *encoder, uint32_t clock)
  89. {
  90. struct drm_device *dev = encoder->dev;
  91. struct radeon_device *rdev = dev->dev_private;
  92. uint32_t offset = to_radeon_encoder(encoder)->hdmi_offset;
  93. int CTS;
  94. int N;
  95. int i;
  96. for (i = 0; r600_hdmi_ACR[i].Clock != clock && r600_hdmi_ACR[i].Clock != 0; i++);
  97. CTS = r600_hdmi_ACR[i].CTS_32kHz;
  98. N = r600_hdmi_ACR[i].N_32kHz;
  99. r600_hdmi_calc_CTS(clock, &CTS, N, 32000);
  100. WREG32(offset+R600_HDMI_32kHz_CTS, CTS << 12);
  101. WREG32(offset+R600_HDMI_32kHz_N, N);
  102. CTS = r600_hdmi_ACR[i].CTS_44_1kHz;
  103. N = r600_hdmi_ACR[i].N_44_1kHz;
  104. r600_hdmi_calc_CTS(clock, &CTS, N, 44100);
  105. WREG32(offset+R600_HDMI_44_1kHz_CTS, CTS << 12);
  106. WREG32(offset+R600_HDMI_44_1kHz_N, N);
  107. CTS = r600_hdmi_ACR[i].CTS_48kHz;
  108. N = r600_hdmi_ACR[i].N_48kHz;
  109. r600_hdmi_calc_CTS(clock, &CTS, N, 48000);
  110. WREG32(offset+R600_HDMI_48kHz_CTS, CTS << 12);
  111. WREG32(offset+R600_HDMI_48kHz_N, N);
  112. }
  113. /*
  114. * calculate the crc for a given info frame
  115. */
  116. static void r600_hdmi_infoframe_checksum(uint8_t packetType,
  117. uint8_t versionNumber,
  118. uint8_t length,
  119. uint8_t *frame)
  120. {
  121. int i;
  122. frame[0] = packetType + versionNumber + length;
  123. for (i = 1; i <= length; i++)
  124. frame[0] += frame[i];
  125. frame[0] = 0x100 - frame[0];
  126. }
  127. /*
  128. * build a HDMI Video Info Frame
  129. */
  130. static void r600_hdmi_videoinfoframe(
  131. struct drm_encoder *encoder,
  132. enum r600_hdmi_color_format color_format,
  133. int active_information_present,
  134. uint8_t active_format_aspect_ratio,
  135. uint8_t scan_information,
  136. uint8_t colorimetry,
  137. uint8_t ex_colorimetry,
  138. uint8_t quantization,
  139. int ITC,
  140. uint8_t picture_aspect_ratio,
  141. uint8_t video_format_identification,
  142. uint8_t pixel_repetition,
  143. uint8_t non_uniform_picture_scaling,
  144. uint8_t bar_info_data_valid,
  145. uint16_t top_bar,
  146. uint16_t bottom_bar,
  147. uint16_t left_bar,
  148. uint16_t right_bar
  149. )
  150. {
  151. struct drm_device *dev = encoder->dev;
  152. struct radeon_device *rdev = dev->dev_private;
  153. uint32_t offset = to_radeon_encoder(encoder)->hdmi_offset;
  154. uint8_t frame[14];
  155. frame[0x0] = 0;
  156. frame[0x1] =
  157. (scan_information & 0x3) |
  158. ((bar_info_data_valid & 0x3) << 2) |
  159. ((active_information_present & 0x1) << 4) |
  160. ((color_format & 0x3) << 5);
  161. frame[0x2] =
  162. (active_format_aspect_ratio & 0xF) |
  163. ((picture_aspect_ratio & 0x3) << 4) |
  164. ((colorimetry & 0x3) << 6);
  165. frame[0x3] =
  166. (non_uniform_picture_scaling & 0x3) |
  167. ((quantization & 0x3) << 2) |
  168. ((ex_colorimetry & 0x7) << 4) |
  169. ((ITC & 0x1) << 7);
  170. frame[0x4] = (video_format_identification & 0x7F);
  171. frame[0x5] = (pixel_repetition & 0xF);
  172. frame[0x6] = (top_bar & 0xFF);
  173. frame[0x7] = (top_bar >> 8);
  174. frame[0x8] = (bottom_bar & 0xFF);
  175. frame[0x9] = (bottom_bar >> 8);
  176. frame[0xA] = (left_bar & 0xFF);
  177. frame[0xB] = (left_bar >> 8);
  178. frame[0xC] = (right_bar & 0xFF);
  179. frame[0xD] = (right_bar >> 8);
  180. r600_hdmi_infoframe_checksum(0x82, 0x02, 0x0D, frame);
  181. WREG32(offset+R600_HDMI_VIDEOINFOFRAME_0,
  182. frame[0x0] | (frame[0x1] << 8) | (frame[0x2] << 16) | (frame[0x3] << 24));
  183. WREG32(offset+R600_HDMI_VIDEOINFOFRAME_1,
  184. frame[0x4] | (frame[0x5] << 8) | (frame[0x6] << 16) | (frame[0x7] << 24));
  185. WREG32(offset+R600_HDMI_VIDEOINFOFRAME_2,
  186. frame[0x8] | (frame[0x9] << 8) | (frame[0xA] << 16) | (frame[0xB] << 24));
  187. WREG32(offset+R600_HDMI_VIDEOINFOFRAME_3,
  188. frame[0xC] | (frame[0xD] << 8));
  189. }
  190. /*
  191. * build a Audio Info Frame
  192. */
  193. static void r600_hdmi_audioinfoframe(
  194. struct drm_encoder *encoder,
  195. uint8_t channel_count,
  196. uint8_t coding_type,
  197. uint8_t sample_size,
  198. uint8_t sample_frequency,
  199. uint8_t format,
  200. uint8_t channel_allocation,
  201. uint8_t level_shift,
  202. int downmix_inhibit
  203. )
  204. {
  205. struct drm_device *dev = encoder->dev;
  206. struct radeon_device *rdev = dev->dev_private;
  207. uint32_t offset = to_radeon_encoder(encoder)->hdmi_offset;
  208. uint8_t frame[11];
  209. frame[0x0] = 0;
  210. frame[0x1] = (channel_count & 0x7) | ((coding_type & 0xF) << 4);
  211. frame[0x2] = (sample_size & 0x3) | ((sample_frequency & 0x7) << 2);
  212. frame[0x3] = format;
  213. frame[0x4] = channel_allocation;
  214. frame[0x5] = ((level_shift & 0xF) << 3) | ((downmix_inhibit & 0x1) << 7);
  215. frame[0x6] = 0;
  216. frame[0x7] = 0;
  217. frame[0x8] = 0;
  218. frame[0x9] = 0;
  219. frame[0xA] = 0;
  220. r600_hdmi_infoframe_checksum(0x84, 0x01, 0x0A, frame);
  221. WREG32(offset+R600_HDMI_AUDIOINFOFRAME_0,
  222. frame[0x0] | (frame[0x1] << 8) | (frame[0x2] << 16) | (frame[0x3] << 24));
  223. WREG32(offset+R600_HDMI_AUDIOINFOFRAME_1,
  224. frame[0x4] | (frame[0x5] << 8) | (frame[0x6] << 16) | (frame[0x8] << 24));
  225. }
  226. /*
  227. * test if audio buffer is filled enough to start playing
  228. */
  229. static int r600_hdmi_is_audio_buffer_filled(struct drm_encoder *encoder)
  230. {
  231. struct drm_device *dev = encoder->dev;
  232. struct radeon_device *rdev = dev->dev_private;
  233. uint32_t offset = to_radeon_encoder(encoder)->hdmi_offset;
  234. return (RREG32(offset+R600_HDMI_STATUS) & 0x10) != 0;
  235. }
  236. /*
  237. * have buffer status changed since last call?
  238. */
  239. int r600_hdmi_buffer_status_changed(struct drm_encoder *encoder)
  240. {
  241. struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
  242. int status, result;
  243. if (!radeon_encoder->hdmi_offset)
  244. return 0;
  245. status = r600_hdmi_is_audio_buffer_filled(encoder);
  246. result = radeon_encoder->hdmi_buffer_status != status;
  247. radeon_encoder->hdmi_buffer_status = status;
  248. return result;
  249. }
  250. /*
  251. * write the audio workaround status to the hardware
  252. */
  253. void r600_hdmi_audio_workaround(struct drm_encoder *encoder)
  254. {
  255. struct drm_device *dev = encoder->dev;
  256. struct radeon_device *rdev = dev->dev_private;
  257. struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
  258. uint32_t offset = radeon_encoder->hdmi_offset;
  259. if (!offset)
  260. return;
  261. if (!radeon_encoder->hdmi_audio_workaround ||
  262. r600_hdmi_is_audio_buffer_filled(encoder)) {
  263. /* disable audio workaround */
  264. WREG32_P(offset+R600_HDMI_CNTL, 0x00000001, ~0x00001001);
  265. } else {
  266. /* enable audio workaround */
  267. WREG32_P(offset+R600_HDMI_CNTL, 0x00001001, ~0x00001001);
  268. }
  269. }
  270. /*
  271. * update the info frames with the data from the current display mode
  272. */
  273. void r600_hdmi_setmode(struct drm_encoder *encoder, struct drm_display_mode *mode)
  274. {
  275. struct drm_device *dev = encoder->dev;
  276. struct radeon_device *rdev = dev->dev_private;
  277. uint32_t offset = to_radeon_encoder(encoder)->hdmi_offset;
  278. if (ASIC_IS_DCE4(rdev))
  279. return;
  280. if (!offset)
  281. return;
  282. r600_audio_set_clock(encoder, mode->clock);
  283. WREG32(offset+R600_HDMI_UNKNOWN_0, 0x1000);
  284. WREG32(offset+R600_HDMI_UNKNOWN_1, 0x0);
  285. WREG32(offset+R600_HDMI_UNKNOWN_2, 0x1000);
  286. r600_hdmi_update_ACR(encoder, mode->clock);
  287. WREG32(offset+R600_HDMI_VIDEOCNTL, 0x13);
  288. WREG32(offset+R600_HDMI_VERSION, 0x202);
  289. r600_hdmi_videoinfoframe(encoder, RGB, 0, 0, 0, 0,
  290. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
  291. /* it's unknown what these bits do excatly, but it's indeed quite useful for debugging */
  292. WREG32(offset+R600_HDMI_AUDIO_DEBUG_0, 0x00FFFFFF);
  293. WREG32(offset+R600_HDMI_AUDIO_DEBUG_1, 0x007FFFFF);
  294. WREG32(offset+R600_HDMI_AUDIO_DEBUG_2, 0x00000001);
  295. WREG32(offset+R600_HDMI_AUDIO_DEBUG_3, 0x00000001);
  296. r600_hdmi_audio_workaround(encoder);
  297. /* audio packets per line, does anyone know how to calc this ? */
  298. WREG32_P(offset+R600_HDMI_CNTL, 0x00040000, ~0x001F0000);
  299. }
  300. /*
  301. * update settings with current parameters from audio engine
  302. */
  303. void r600_hdmi_update_audio_settings(struct drm_encoder *encoder)
  304. {
  305. struct drm_device *dev = encoder->dev;
  306. struct radeon_device *rdev = dev->dev_private;
  307. uint32_t offset = to_radeon_encoder(encoder)->hdmi_offset;
  308. int channels = r600_audio_channels(rdev);
  309. int rate = r600_audio_rate(rdev);
  310. int bps = r600_audio_bits_per_sample(rdev);
  311. uint8_t status_bits = r600_audio_status_bits(rdev);
  312. uint8_t category_code = r600_audio_category_code(rdev);
  313. uint32_t iec;
  314. if (!offset)
  315. return;
  316. DRM_DEBUG("%s with %d channels, %d Hz sampling rate, %d bits per sample,\n",
  317. r600_hdmi_is_audio_buffer_filled(encoder) ? "playing" : "stopped",
  318. channels, rate, bps);
  319. DRM_DEBUG("0x%02X IEC60958 status bits and 0x%02X category code\n",
  320. (int)status_bits, (int)category_code);
  321. iec = 0;
  322. if (status_bits & AUDIO_STATUS_PROFESSIONAL)
  323. iec |= 1 << 0;
  324. if (status_bits & AUDIO_STATUS_NONAUDIO)
  325. iec |= 1 << 1;
  326. if (status_bits & AUDIO_STATUS_COPYRIGHT)
  327. iec |= 1 << 2;
  328. if (status_bits & AUDIO_STATUS_EMPHASIS)
  329. iec |= 1 << 3;
  330. iec |= category_code << 8;
  331. switch (rate) {
  332. case 32000: iec |= 0x3 << 24; break;
  333. case 44100: iec |= 0x0 << 24; break;
  334. case 88200: iec |= 0x8 << 24; break;
  335. case 176400: iec |= 0xc << 24; break;
  336. case 48000: iec |= 0x2 << 24; break;
  337. case 96000: iec |= 0xa << 24; break;
  338. case 192000: iec |= 0xe << 24; break;
  339. }
  340. WREG32(offset+R600_HDMI_IEC60958_1, iec);
  341. iec = 0;
  342. switch (bps) {
  343. case 16: iec |= 0x2; break;
  344. case 20: iec |= 0x3; break;
  345. case 24: iec |= 0xb; break;
  346. }
  347. if (status_bits & AUDIO_STATUS_V)
  348. iec |= 0x5 << 16;
  349. WREG32_P(offset+R600_HDMI_IEC60958_2, iec, ~0x5000f);
  350. /* 0x021 or 0x031 sets the audio frame length */
  351. WREG32(offset+R600_HDMI_AUDIOCNTL, 0x31);
  352. r600_hdmi_audioinfoframe(encoder, channels-1, 0, 0, 0, 0, 0, 0, 0);
  353. r600_hdmi_audio_workaround(encoder);
  354. }
  355. static int r600_hdmi_find_free_block(struct drm_device *dev)
  356. {
  357. struct radeon_device *rdev = dev->dev_private;
  358. struct drm_encoder *encoder;
  359. struct radeon_encoder *radeon_encoder;
  360. bool free_blocks[3] = { true, true, true };
  361. list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) {
  362. radeon_encoder = to_radeon_encoder(encoder);
  363. switch (radeon_encoder->hdmi_offset) {
  364. case R600_HDMI_BLOCK1:
  365. free_blocks[0] = false;
  366. break;
  367. case R600_HDMI_BLOCK2:
  368. free_blocks[1] = false;
  369. break;
  370. case R600_HDMI_BLOCK3:
  371. free_blocks[2] = false;
  372. break;
  373. }
  374. }
  375. if (rdev->family == CHIP_RS600 || rdev->family == CHIP_RS690 ||
  376. rdev->family == CHIP_RS740) {
  377. return free_blocks[0] ? R600_HDMI_BLOCK1 : 0;
  378. } else if (rdev->family >= CHIP_R600) {
  379. if (free_blocks[0])
  380. return R600_HDMI_BLOCK1;
  381. else if (free_blocks[1])
  382. return R600_HDMI_BLOCK2;
  383. }
  384. return 0;
  385. }
  386. static void r600_hdmi_assign_block(struct drm_encoder *encoder)
  387. {
  388. struct drm_device *dev = encoder->dev;
  389. struct radeon_device *rdev = dev->dev_private;
  390. struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
  391. struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv;
  392. if (!dig) {
  393. dev_err(rdev->dev, "Enabling HDMI on non-dig encoder\n");
  394. return;
  395. }
  396. if (ASIC_IS_DCE4(rdev)) {
  397. /* TODO */
  398. } else if (ASIC_IS_DCE3(rdev)) {
  399. radeon_encoder->hdmi_offset = dig->dig_encoder ?
  400. R600_HDMI_BLOCK3 : R600_HDMI_BLOCK1;
  401. if (ASIC_IS_DCE32(rdev))
  402. radeon_encoder->hdmi_config_offset = dig->dig_encoder ?
  403. R600_HDMI_CONFIG2 : R600_HDMI_CONFIG1;
  404. } else if (rdev->family >= CHIP_R600 || rdev->family == CHIP_RS600 ||
  405. rdev->family == CHIP_RS690 || rdev->family == CHIP_RS740) {
  406. radeon_encoder->hdmi_offset = r600_hdmi_find_free_block(dev);
  407. }
  408. }
  409. /*
  410. * enable the HDMI engine
  411. */
  412. void r600_hdmi_enable(struct drm_encoder *encoder)
  413. {
  414. struct drm_device *dev = encoder->dev;
  415. struct radeon_device *rdev = dev->dev_private;
  416. struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
  417. uint32_t offset;
  418. if (ASIC_IS_DCE4(rdev))
  419. return;
  420. if (!radeon_encoder->hdmi_offset) {
  421. r600_hdmi_assign_block(encoder);
  422. if (!radeon_encoder->hdmi_offset) {
  423. dev_warn(rdev->dev, "Could not find HDMI block for "
  424. "0x%x encoder\n", radeon_encoder->encoder_id);
  425. return;
  426. }
  427. }
  428. offset = radeon_encoder->hdmi_offset;
  429. if (ASIC_IS_DCE32(rdev) && !ASIC_IS_DCE4(rdev)) {
  430. WREG32_P(radeon_encoder->hdmi_config_offset + 0x4, 0x1, ~0x1);
  431. } else if (rdev->family >= CHIP_R600 && !ASIC_IS_DCE3(rdev)) {
  432. switch (radeon_encoder->encoder_id) {
  433. case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_TMDS1:
  434. WREG32_P(AVIVO_TMDSA_CNTL, 0x4, ~0x4);
  435. WREG32(offset + R600_HDMI_ENABLE, 0x101);
  436. break;
  437. case ENCODER_OBJECT_ID_INTERNAL_LVTM1:
  438. WREG32_P(AVIVO_LVTMA_CNTL, 0x4, ~0x4);
  439. WREG32(offset + R600_HDMI_ENABLE, 0x105);
  440. break;
  441. default:
  442. dev_err(rdev->dev, "Unknown HDMI output type\n");
  443. break;
  444. }
  445. }
  446. if (rdev->irq.installed
  447. && rdev->family != CHIP_RS600
  448. && rdev->family != CHIP_RS690
  449. && rdev->family != CHIP_RS740) {
  450. /* if irq is available use it */
  451. rdev->irq.hdmi[offset == R600_HDMI_BLOCK1 ? 0 : 1] = true;
  452. radeon_irq_set(rdev);
  453. r600_audio_disable_polling(encoder);
  454. } else {
  455. /* if not fallback to polling */
  456. r600_audio_enable_polling(encoder);
  457. }
  458. DRM_DEBUG("Enabling HDMI interface @ 0x%04X for encoder 0x%x\n",
  459. radeon_encoder->hdmi_offset, radeon_encoder->encoder_id);
  460. }
  461. /*
  462. * disable the HDMI engine
  463. */
  464. void r600_hdmi_disable(struct drm_encoder *encoder)
  465. {
  466. struct drm_device *dev = encoder->dev;
  467. struct radeon_device *rdev = dev->dev_private;
  468. struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
  469. uint32_t offset;
  470. if (ASIC_IS_DCE4(rdev))
  471. return;
  472. offset = radeon_encoder->hdmi_offset;
  473. if (!offset) {
  474. dev_err(rdev->dev, "Disabling not enabled HDMI\n");
  475. return;
  476. }
  477. DRM_DEBUG("Disabling HDMI interface @ 0x%04X for encoder 0x%x\n",
  478. offset, radeon_encoder->encoder_id);
  479. /* disable irq */
  480. rdev->irq.hdmi[offset == R600_HDMI_BLOCK1 ? 0 : 1] = false;
  481. radeon_irq_set(rdev);
  482. /* disable polling */
  483. r600_audio_disable_polling(encoder);
  484. if (ASIC_IS_DCE32(rdev) && !ASIC_IS_DCE4(rdev)) {
  485. WREG32_P(radeon_encoder->hdmi_config_offset + 0x4, 0, ~0x1);
  486. } else if (rdev->family >= CHIP_R600 && !ASIC_IS_DCE3(rdev)) {
  487. switch (radeon_encoder->encoder_id) {
  488. case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_TMDS1:
  489. WREG32_P(AVIVO_TMDSA_CNTL, 0, ~0x4);
  490. WREG32(offset + R600_HDMI_ENABLE, 0);
  491. break;
  492. case ENCODER_OBJECT_ID_INTERNAL_LVTM1:
  493. WREG32_P(AVIVO_LVTMA_CNTL, 0, ~0x4);
  494. WREG32(offset + R600_HDMI_ENABLE, 0);
  495. break;
  496. default:
  497. dev_err(rdev->dev, "Unknown HDMI output type\n");
  498. break;
  499. }
  500. }
  501. radeon_encoder->hdmi_offset = 0;
  502. radeon_encoder->hdmi_config_offset = 0;
  503. }