r600_hdmi.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535
  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 <linux/hdmi.h>
  27. #include <linux/gcd.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 "r600d.h"
  34. #include "atom.h"
  35. /*
  36. * HDMI color format
  37. */
  38. enum r600_hdmi_color_format {
  39. RGB = 0,
  40. YCC_422 = 1,
  41. YCC_444 = 2
  42. };
  43. /*
  44. * IEC60958 status bits
  45. */
  46. enum r600_hdmi_iec_status_bits {
  47. AUDIO_STATUS_DIG_ENABLE = 0x01,
  48. AUDIO_STATUS_V = 0x02,
  49. AUDIO_STATUS_VCFG = 0x04,
  50. AUDIO_STATUS_EMPHASIS = 0x08,
  51. AUDIO_STATUS_COPYRIGHT = 0x10,
  52. AUDIO_STATUS_NONAUDIO = 0x20,
  53. AUDIO_STATUS_PROFESSIONAL = 0x40,
  54. AUDIO_STATUS_LEVEL = 0x80
  55. };
  56. static struct r600_audio_pin r600_audio_status(struct radeon_device *rdev)
  57. {
  58. struct r600_audio_pin status;
  59. uint32_t value;
  60. value = RREG32(R600_AUDIO_RATE_BPS_CHANNEL);
  61. /* number of channels */
  62. status.channels = (value & 0x7) + 1;
  63. /* bits per sample */
  64. switch ((value & 0xF0) >> 4) {
  65. case 0x0:
  66. status.bits_per_sample = 8;
  67. break;
  68. case 0x1:
  69. status.bits_per_sample = 16;
  70. break;
  71. case 0x2:
  72. status.bits_per_sample = 20;
  73. break;
  74. case 0x3:
  75. status.bits_per_sample = 24;
  76. break;
  77. case 0x4:
  78. status.bits_per_sample = 32;
  79. break;
  80. default:
  81. dev_err(rdev->dev, "Unknown bits per sample 0x%x, using 16\n",
  82. (int)value);
  83. status.bits_per_sample = 16;
  84. }
  85. /* current sampling rate in HZ */
  86. if (value & 0x4000)
  87. status.rate = 44100;
  88. else
  89. status.rate = 48000;
  90. status.rate *= ((value >> 11) & 0x7) + 1;
  91. status.rate /= ((value >> 8) & 0x7) + 1;
  92. value = RREG32(R600_AUDIO_STATUS_BITS);
  93. /* iec 60958 status bits */
  94. status.status_bits = value & 0xff;
  95. /* iec 60958 category code */
  96. status.category_code = (value >> 8) & 0xff;
  97. return status;
  98. }
  99. /*
  100. * update all hdmi interfaces with current audio parameters
  101. */
  102. void r600_audio_update_hdmi(struct work_struct *work)
  103. {
  104. struct radeon_device *rdev = container_of(work, struct radeon_device,
  105. audio_work);
  106. struct drm_device *dev = rdev->ddev;
  107. struct r600_audio_pin audio_status = r600_audio_status(rdev);
  108. struct drm_encoder *encoder;
  109. bool changed = false;
  110. if (rdev->audio.pin[0].channels != audio_status.channels ||
  111. rdev->audio.pin[0].rate != audio_status.rate ||
  112. rdev->audio.pin[0].bits_per_sample != audio_status.bits_per_sample ||
  113. rdev->audio.pin[0].status_bits != audio_status.status_bits ||
  114. rdev->audio.pin[0].category_code != audio_status.category_code) {
  115. rdev->audio.pin[0] = audio_status;
  116. changed = true;
  117. }
  118. list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) {
  119. if (!radeon_encoder_is_digital(encoder))
  120. continue;
  121. if (changed || r600_hdmi_buffer_status_changed(encoder))
  122. r600_hdmi_update_audio_settings(encoder);
  123. }
  124. }
  125. /* enable the audio stream */
  126. void r600_audio_enable(struct radeon_device *rdev,
  127. struct r600_audio_pin *pin,
  128. u8 enable_mask)
  129. {
  130. u32 tmp = RREG32(AZ_HOT_PLUG_CONTROL);
  131. if (!pin)
  132. return;
  133. if (enable_mask) {
  134. tmp |= AUDIO_ENABLED;
  135. if (enable_mask & 1)
  136. tmp |= PIN0_AUDIO_ENABLED;
  137. if (enable_mask & 2)
  138. tmp |= PIN1_AUDIO_ENABLED;
  139. if (enable_mask & 4)
  140. tmp |= PIN2_AUDIO_ENABLED;
  141. if (enable_mask & 8)
  142. tmp |= PIN3_AUDIO_ENABLED;
  143. } else {
  144. tmp &= ~(AUDIO_ENABLED |
  145. PIN0_AUDIO_ENABLED |
  146. PIN1_AUDIO_ENABLED |
  147. PIN2_AUDIO_ENABLED |
  148. PIN3_AUDIO_ENABLED);
  149. }
  150. WREG32(AZ_HOT_PLUG_CONTROL, tmp);
  151. }
  152. struct r600_audio_pin *r600_audio_get_pin(struct radeon_device *rdev)
  153. {
  154. /* only one pin on 6xx-NI */
  155. return &rdev->audio.pin[0];
  156. }
  157. void r600_hdmi_update_acr(struct drm_encoder *encoder, long offset,
  158. const struct radeon_hdmi_acr *acr)
  159. {
  160. struct drm_device *dev = encoder->dev;
  161. struct radeon_device *rdev = dev->dev_private;
  162. /* DCE 3.0 uses register that's normally for CRC_CONTROL */
  163. uint32_t acr_ctl = ASIC_IS_DCE3(rdev) ? DCE3_HDMI0_ACR_PACKET_CONTROL :
  164. HDMI0_ACR_PACKET_CONTROL;
  165. WREG32_P(acr_ctl + offset,
  166. HDMI0_ACR_SOURCE | /* select SW CTS value */
  167. HDMI0_ACR_AUTO_SEND, /* allow hw to sent ACR packets when required */
  168. ~(HDMI0_ACR_SOURCE |
  169. HDMI0_ACR_AUTO_SEND));
  170. WREG32_P(HDMI0_ACR_32_0 + offset,
  171. HDMI0_ACR_CTS_32(acr->cts_32khz),
  172. ~HDMI0_ACR_CTS_32_MASK);
  173. WREG32_P(HDMI0_ACR_32_1 + offset,
  174. HDMI0_ACR_N_32(acr->n_32khz),
  175. ~HDMI0_ACR_N_32_MASK);
  176. WREG32_P(HDMI0_ACR_44_0 + offset,
  177. HDMI0_ACR_CTS_44(acr->cts_44_1khz),
  178. ~HDMI0_ACR_CTS_44_MASK);
  179. WREG32_P(HDMI0_ACR_44_1 + offset,
  180. HDMI0_ACR_N_44(acr->n_44_1khz),
  181. ~HDMI0_ACR_N_44_MASK);
  182. WREG32_P(HDMI0_ACR_48_0 + offset,
  183. HDMI0_ACR_CTS_48(acr->cts_48khz),
  184. ~HDMI0_ACR_CTS_48_MASK);
  185. WREG32_P(HDMI0_ACR_48_1 + offset,
  186. HDMI0_ACR_N_48(acr->n_48khz),
  187. ~HDMI0_ACR_N_48_MASK);
  188. }
  189. /*
  190. * build a HDMI Video Info Frame
  191. */
  192. void r600_set_avi_packet(struct radeon_device *rdev, u32 offset,
  193. unsigned char *buffer, size_t size)
  194. {
  195. uint8_t *frame = buffer + 3;
  196. WREG32(HDMI0_AVI_INFO0 + offset,
  197. frame[0x0] | (frame[0x1] << 8) | (frame[0x2] << 16) | (frame[0x3] << 24));
  198. WREG32(HDMI0_AVI_INFO1 + offset,
  199. frame[0x4] | (frame[0x5] << 8) | (frame[0x6] << 16) | (frame[0x7] << 24));
  200. WREG32(HDMI0_AVI_INFO2 + offset,
  201. frame[0x8] | (frame[0x9] << 8) | (frame[0xA] << 16) | (frame[0xB] << 24));
  202. WREG32(HDMI0_AVI_INFO3 + offset,
  203. frame[0xC] | (frame[0xD] << 8) | (buffer[1] << 24));
  204. WREG32_OR(HDMI0_INFOFRAME_CONTROL1 + offset,
  205. HDMI0_AVI_INFO_LINE(2)); /* anything other than 0 */
  206. WREG32_OR(HDMI0_INFOFRAME_CONTROL0 + offset,
  207. HDMI0_AVI_INFO_SEND | /* enable AVI info frames */
  208. HDMI0_AVI_INFO_CONT); /* send AVI info frames every frame/field */
  209. }
  210. /*
  211. * build a Audio Info Frame
  212. */
  213. static void r600_hdmi_update_audio_infoframe(struct drm_encoder *encoder,
  214. const void *buffer, size_t size)
  215. {
  216. struct drm_device *dev = encoder->dev;
  217. struct radeon_device *rdev = dev->dev_private;
  218. struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
  219. struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv;
  220. uint32_t offset = dig->afmt->offset;
  221. const u8 *frame = buffer + 3;
  222. WREG32(HDMI0_AUDIO_INFO0 + offset,
  223. frame[0x0] | (frame[0x1] << 8) | (frame[0x2] << 16) | (frame[0x3] << 24));
  224. WREG32(HDMI0_AUDIO_INFO1 + offset,
  225. frame[0x4] | (frame[0x5] << 8) | (frame[0x6] << 16) | (frame[0x8] << 24));
  226. }
  227. /*
  228. * test if audio buffer is filled enough to start playing
  229. */
  230. static bool r600_hdmi_is_audio_buffer_filled(struct drm_encoder *encoder)
  231. {
  232. struct drm_device *dev = encoder->dev;
  233. struct radeon_device *rdev = dev->dev_private;
  234. struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
  235. struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv;
  236. uint32_t offset = dig->afmt->offset;
  237. return (RREG32(HDMI0_STATUS + offset) & 0x10) != 0;
  238. }
  239. /*
  240. * have buffer status changed since last call?
  241. */
  242. int r600_hdmi_buffer_status_changed(struct drm_encoder *encoder)
  243. {
  244. struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
  245. struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv;
  246. int status, result;
  247. if (!dig->afmt || !dig->afmt->enabled)
  248. return 0;
  249. status = r600_hdmi_is_audio_buffer_filled(encoder);
  250. result = dig->afmt->last_buffer_filled_status != status;
  251. dig->afmt->last_buffer_filled_status = status;
  252. return result;
  253. }
  254. /*
  255. * write the audio workaround status to the hardware
  256. */
  257. void r600_hdmi_audio_workaround(struct drm_encoder *encoder)
  258. {
  259. struct drm_device *dev = encoder->dev;
  260. struct radeon_device *rdev = dev->dev_private;
  261. struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
  262. struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv;
  263. uint32_t offset = dig->afmt->offset;
  264. bool hdmi_audio_workaround = false; /* FIXME */
  265. u32 value;
  266. if (!hdmi_audio_workaround ||
  267. r600_hdmi_is_audio_buffer_filled(encoder))
  268. value = 0; /* disable workaround */
  269. else
  270. value = HDMI0_AUDIO_TEST_EN; /* enable workaround */
  271. WREG32_P(HDMI0_AUDIO_PACKET_CONTROL + offset,
  272. value, ~HDMI0_AUDIO_TEST_EN);
  273. }
  274. void r600_hdmi_audio_set_dto(struct radeon_device *rdev,
  275. struct radeon_crtc *crtc, unsigned int clock)
  276. {
  277. struct radeon_encoder *radeon_encoder;
  278. struct radeon_encoder_atom_dig *dig;
  279. if (!crtc)
  280. return;
  281. radeon_encoder = to_radeon_encoder(crtc->encoder);
  282. dig = radeon_encoder->enc_priv;
  283. if (!dig)
  284. return;
  285. if (dig->dig_encoder == 0) {
  286. WREG32(DCCG_AUDIO_DTO0_PHASE, 24000 * 100);
  287. WREG32(DCCG_AUDIO_DTO0_MODULE, clock * 100);
  288. WREG32(DCCG_AUDIO_DTO_SELECT, 0); /* select DTO0 */
  289. } else {
  290. WREG32(DCCG_AUDIO_DTO1_PHASE, 24000 * 100);
  291. WREG32(DCCG_AUDIO_DTO1_MODULE, clock * 100);
  292. WREG32(DCCG_AUDIO_DTO_SELECT, 1); /* select DTO1 */
  293. }
  294. }
  295. void r600_set_vbi_packet(struct drm_encoder *encoder, u32 offset)
  296. {
  297. struct drm_device *dev = encoder->dev;
  298. struct radeon_device *rdev = dev->dev_private;
  299. WREG32_OR(HDMI0_VBI_PACKET_CONTROL + offset,
  300. HDMI0_NULL_SEND | /* send null packets when required */
  301. HDMI0_GC_SEND | /* send general control packets */
  302. HDMI0_GC_CONT); /* send general control packets every frame */
  303. }
  304. void r600_set_audio_packet(struct drm_encoder *encoder, u32 offset)
  305. {
  306. struct drm_device *dev = encoder->dev;
  307. struct radeon_device *rdev = dev->dev_private;
  308. WREG32_P(HDMI0_AUDIO_PACKET_CONTROL + offset,
  309. HDMI0_AUDIO_SAMPLE_SEND | /* send audio packets */
  310. HDMI0_AUDIO_DELAY_EN(1) | /* default audio delay */
  311. HDMI0_AUDIO_PACKETS_PER_LINE(3) | /* should be suffient for all audio modes and small enough for all hblanks */
  312. HDMI0_60958_CS_UPDATE, /* allow 60958 channel status fields to be updated */
  313. ~(HDMI0_AUDIO_SAMPLE_SEND |
  314. HDMI0_AUDIO_DELAY_EN_MASK |
  315. HDMI0_AUDIO_PACKETS_PER_LINE_MASK |
  316. HDMI0_60958_CS_UPDATE));
  317. WREG32_OR(HDMI0_INFOFRAME_CONTROL0 + offset,
  318. HDMI0_AUDIO_INFO_SEND | /* enable audio info frames (frames won't be set until audio is enabled) */
  319. HDMI0_AUDIO_INFO_UPDATE); /* required for audio info values to be updated */
  320. WREG32_P(HDMI0_INFOFRAME_CONTROL1 + offset,
  321. HDMI0_AUDIO_INFO_LINE(2), /* anything other than 0 */
  322. ~HDMI0_AUDIO_INFO_LINE_MASK);
  323. WREG32_AND(HDMI0_GENERIC_PACKET_CONTROL + offset,
  324. ~(HDMI0_GENERIC0_SEND |
  325. HDMI0_GENERIC0_CONT |
  326. HDMI0_GENERIC0_UPDATE |
  327. HDMI0_GENERIC1_SEND |
  328. HDMI0_GENERIC1_CONT |
  329. HDMI0_GENERIC0_LINE_MASK |
  330. HDMI0_GENERIC1_LINE_MASK));
  331. WREG32_P(HDMI0_60958_0 + offset,
  332. HDMI0_60958_CS_CHANNEL_NUMBER_L(1),
  333. ~(HDMI0_60958_CS_CHANNEL_NUMBER_L_MASK |
  334. HDMI0_60958_CS_CLOCK_ACCURACY_MASK));
  335. WREG32_P(HDMI0_60958_1 + offset,
  336. HDMI0_60958_CS_CHANNEL_NUMBER_R(2),
  337. ~HDMI0_60958_CS_CHANNEL_NUMBER_R_MASK);
  338. }
  339. void r600_set_mute(struct drm_encoder *encoder, u32 offset, bool mute)
  340. {
  341. struct drm_device *dev = encoder->dev;
  342. struct radeon_device *rdev = dev->dev_private;
  343. if (mute)
  344. WREG32_OR(HDMI0_GC + offset, HDMI0_GC_AVMUTE);
  345. else
  346. WREG32_AND(HDMI0_GC + offset, ~HDMI0_GC_AVMUTE);
  347. }
  348. /**
  349. * r600_hdmi_update_audio_settings - Update audio infoframe
  350. *
  351. * @encoder: drm encoder
  352. *
  353. * Gets info about current audio stream and updates audio infoframe.
  354. */
  355. void r600_hdmi_update_audio_settings(struct drm_encoder *encoder)
  356. {
  357. struct drm_device *dev = encoder->dev;
  358. struct radeon_device *rdev = dev->dev_private;
  359. struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
  360. struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv;
  361. struct r600_audio_pin audio = r600_audio_status(rdev);
  362. uint8_t buffer[HDMI_INFOFRAME_HEADER_SIZE + HDMI_AUDIO_INFOFRAME_SIZE];
  363. struct hdmi_audio_infoframe frame;
  364. uint32_t offset;
  365. uint32_t value;
  366. ssize_t err;
  367. if (!dig->afmt || !dig->afmt->enabled)
  368. return;
  369. offset = dig->afmt->offset;
  370. DRM_DEBUG("%s with %d channels, %d Hz sampling rate, %d bits per sample,\n",
  371. r600_hdmi_is_audio_buffer_filled(encoder) ? "playing" : "stopped",
  372. audio.channels, audio.rate, audio.bits_per_sample);
  373. DRM_DEBUG("0x%02X IEC60958 status bits and 0x%02X category code\n",
  374. (int)audio.status_bits, (int)audio.category_code);
  375. err = hdmi_audio_infoframe_init(&frame);
  376. if (err < 0) {
  377. DRM_ERROR("failed to setup audio infoframe\n");
  378. return;
  379. }
  380. frame.channels = audio.channels;
  381. err = hdmi_audio_infoframe_pack(&frame, buffer, sizeof(buffer));
  382. if (err < 0) {
  383. DRM_ERROR("failed to pack audio infoframe\n");
  384. return;
  385. }
  386. value = RREG32(HDMI0_AUDIO_PACKET_CONTROL + offset);
  387. if (value & HDMI0_AUDIO_TEST_EN)
  388. WREG32(HDMI0_AUDIO_PACKET_CONTROL + offset,
  389. value & ~HDMI0_AUDIO_TEST_EN);
  390. WREG32_OR(HDMI0_CONTROL + offset,
  391. HDMI0_ERROR_ACK);
  392. WREG32_AND(HDMI0_INFOFRAME_CONTROL0 + offset,
  393. ~HDMI0_AUDIO_INFO_SOURCE);
  394. r600_hdmi_update_audio_infoframe(encoder, buffer, sizeof(buffer));
  395. WREG32_OR(HDMI0_INFOFRAME_CONTROL0 + offset,
  396. HDMI0_AUDIO_INFO_CONT |
  397. HDMI0_AUDIO_INFO_UPDATE);
  398. }
  399. /*
  400. * enable the HDMI engine
  401. */
  402. void r600_hdmi_enable(struct drm_encoder *encoder, bool enable)
  403. {
  404. struct drm_device *dev = encoder->dev;
  405. struct radeon_device *rdev = dev->dev_private;
  406. struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
  407. struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv;
  408. u32 hdmi = HDMI0_ERROR_ACK;
  409. if (!dig || !dig->afmt)
  410. return;
  411. /* Older chipsets require setting HDMI and routing manually */
  412. if (!ASIC_IS_DCE3(rdev)) {
  413. if (enable)
  414. hdmi |= HDMI0_ENABLE;
  415. switch (radeon_encoder->encoder_id) {
  416. case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_TMDS1:
  417. if (enable) {
  418. WREG32_OR(AVIVO_TMDSA_CNTL, AVIVO_TMDSA_CNTL_HDMI_EN);
  419. hdmi |= HDMI0_STREAM(HDMI0_STREAM_TMDSA);
  420. } else {
  421. WREG32_AND(AVIVO_TMDSA_CNTL, ~AVIVO_TMDSA_CNTL_HDMI_EN);
  422. }
  423. break;
  424. case ENCODER_OBJECT_ID_INTERNAL_LVTM1:
  425. if (enable) {
  426. WREG32_OR(AVIVO_LVTMA_CNTL, AVIVO_LVTMA_CNTL_HDMI_EN);
  427. hdmi |= HDMI0_STREAM(HDMI0_STREAM_LVTMA);
  428. } else {
  429. WREG32_AND(AVIVO_LVTMA_CNTL, ~AVIVO_LVTMA_CNTL_HDMI_EN);
  430. }
  431. break;
  432. case ENCODER_OBJECT_ID_INTERNAL_DDI:
  433. if (enable) {
  434. WREG32_OR(DDIA_CNTL, DDIA_HDMI_EN);
  435. hdmi |= HDMI0_STREAM(HDMI0_STREAM_DDIA);
  436. } else {
  437. WREG32_AND(DDIA_CNTL, ~DDIA_HDMI_EN);
  438. }
  439. break;
  440. case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_DVO1:
  441. if (enable)
  442. hdmi |= HDMI0_STREAM(HDMI0_STREAM_DVOA);
  443. break;
  444. default:
  445. dev_err(rdev->dev, "Invalid encoder for HDMI: 0x%X\n",
  446. radeon_encoder->encoder_id);
  447. break;
  448. }
  449. WREG32(HDMI0_CONTROL + dig->afmt->offset, hdmi);
  450. }
  451. if (rdev->irq.installed) {
  452. /* if irq is available use it */
  453. /* XXX: shouldn't need this on any asics. Double check DCE2/3 */
  454. if (enable)
  455. radeon_irq_kms_enable_afmt(rdev, dig->afmt->id);
  456. else
  457. radeon_irq_kms_disable_afmt(rdev, dig->afmt->id);
  458. }
  459. dig->afmt->enabled = enable;
  460. DRM_DEBUG("%sabling HDMI interface @ 0x%04X for encoder 0x%x\n",
  461. enable ? "En" : "Dis", dig->afmt->offset, radeon_encoder->encoder_id);
  462. }