aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm
diff options
context:
space:
mode:
authorAlex Deucher <alexander.deucher@amd.com>2013-08-29 10:51:04 -0400
committerAlex Deucher <alexander.deucher@amd.com>2013-08-30 16:31:11 -0400
commitc1cbee0ec0697c531778fbaf34aa358c0f5ef00e (patch)
tree803bb01757e17fe3600ceb77c53d3a69925a9a62 /drivers/gpu/drm
parentfb93df1c2d8b3b1fb16d6ee9e32554e0c038815d (diff)
drm/radeon/audio: set up the sads on DCE3.2 asics
This sets up the short audio descriptors properly on DCE3.2 asics for hdmi audio. Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm')
-rw-r--r--drivers/gpu/drm/radeon/r600_hdmi.c66
-rw-r--r--drivers/gpu/drm/radeon/r600d.h29
2 files changed, 94 insertions, 1 deletions
diff --git a/drivers/gpu/drm/radeon/r600_hdmi.c b/drivers/gpu/drm/radeon/r600_hdmi.c
index 6d7128d02493..f443010ce90b 100644
--- a/drivers/gpu/drm/radeon/r600_hdmi.c
+++ b/drivers/gpu/drm/radeon/r600_hdmi.c
@@ -322,6 +322,68 @@ static void dce3_2_afmt_write_speaker_allocation(struct drm_encoder *encoder)
322 kfree(sadb); 322 kfree(sadb);
323} 323}
324 324
325static void dce3_2_afmt_write_sad_regs(struct drm_encoder *encoder)
326{
327 struct radeon_device *rdev = encoder->dev->dev_private;
328 struct drm_connector *connector;
329 struct radeon_connector *radeon_connector = NULL;
330 struct cea_sad *sads;
331 int i, sad_count;
332
333 static const u16 eld_reg_to_type[][2] = {
334 { AZ_F0_CODEC_PIN0_CONTROL_AUDIO_DESCRIPTOR0, HDMI_AUDIO_CODING_TYPE_PCM },
335 { AZ_F0_CODEC_PIN0_CONTROL_AUDIO_DESCRIPTOR1, HDMI_AUDIO_CODING_TYPE_AC3 },
336 { AZ_F0_CODEC_PIN0_CONTROL_AUDIO_DESCRIPTOR2, HDMI_AUDIO_CODING_TYPE_MPEG1 },
337 { AZ_F0_CODEC_PIN0_CONTROL_AUDIO_DESCRIPTOR3, HDMI_AUDIO_CODING_TYPE_MP3 },
338 { AZ_F0_CODEC_PIN0_CONTROL_AUDIO_DESCRIPTOR4, HDMI_AUDIO_CODING_TYPE_MPEG2 },
339 { AZ_F0_CODEC_PIN0_CONTROL_AUDIO_DESCRIPTOR5, HDMI_AUDIO_CODING_TYPE_AAC_LC },
340 { AZ_F0_CODEC_PIN0_CONTROL_AUDIO_DESCRIPTOR6, HDMI_AUDIO_CODING_TYPE_DTS },
341 { AZ_F0_CODEC_PIN0_CONTROL_AUDIO_DESCRIPTOR7, HDMI_AUDIO_CODING_TYPE_ATRAC },
342 { AZ_F0_CODEC_PIN0_CONTROL_AUDIO_DESCRIPTOR9, HDMI_AUDIO_CODING_TYPE_EAC3 },
343 { AZ_F0_CODEC_PIN0_CONTROL_AUDIO_DESCRIPTOR10, HDMI_AUDIO_CODING_TYPE_DTS_HD },
344 { AZ_F0_CODEC_PIN0_CONTROL_AUDIO_DESCRIPTOR11, HDMI_AUDIO_CODING_TYPE_MLP },
345 { AZ_F0_CODEC_PIN0_CONTROL_AUDIO_DESCRIPTOR13, HDMI_AUDIO_CODING_TYPE_WMA_PRO },
346 };
347
348 list_for_each_entry(connector, &encoder->dev->mode_config.connector_list, head) {
349 if (connector->encoder == encoder)
350 radeon_connector = to_radeon_connector(connector);
351 }
352
353 if (!radeon_connector) {
354 DRM_ERROR("Couldn't find encoder's connector\n");
355 return;
356 }
357
358 sad_count = drm_edid_to_sad(radeon_connector->edid, &sads);
359 if (sad_count < 0) {
360 DRM_ERROR("Couldn't read SADs: %d\n", sad_count);
361 return;
362 }
363 BUG_ON(!sads);
364
365 for (i = 0; i < ARRAY_SIZE(eld_reg_to_type); i++) {
366 u32 value = 0;
367 int j;
368
369 for (j = 0; j < sad_count; j++) {
370 struct cea_sad *sad = &sads[j];
371
372 if (sad->format == eld_reg_to_type[i][1]) {
373 value = MAX_CHANNELS(sad->channels) |
374 DESCRIPTOR_BYTE_2(sad->byte2) |
375 SUPPORTED_FREQUENCIES(sad->freq);
376 if (sad->format == HDMI_AUDIO_CODING_TYPE_PCM)
377 value |= SUPPORTED_FREQUENCIES_STEREO(sad->freq);
378 break;
379 }
380 }
381 WREG32(eld_reg_to_type[i][0], value);
382 }
383
384 kfree(sads);
385}
386
325/* 387/*
326 * update the info frames with the data from the current display mode 388 * update the info frames with the data from the current display mode
327 */ 389 */
@@ -366,8 +428,10 @@ void r600_hdmi_setmode(struct drm_encoder *encoder, struct drm_display_mode *mod
366 HDMI0_60958_CS_UPDATE); /* allow 60958 channel status fields to be updated */ 428 HDMI0_60958_CS_UPDATE); /* allow 60958 channel status fields to be updated */
367 } 429 }
368 430
369 if (ASIC_IS_DCE32(rdev)) 431 if (ASIC_IS_DCE32(rdev)) {
370 dce3_2_afmt_write_speaker_allocation(encoder); 432 dce3_2_afmt_write_speaker_allocation(encoder);
433 dce3_2_afmt_write_sad_regs(encoder);
434 }
371 435
372 WREG32(HDMI0_ACR_PACKET_CONTROL + offset, 436 WREG32(HDMI0_ACR_PACKET_CONTROL + offset,
373 HDMI0_ACR_AUTO_SEND | /* allow hw to sent ACR packets when required */ 437 HDMI0_ACR_AUTO_SEND | /* allow hw to sent ACR packets when required */
diff --git a/drivers/gpu/drm/radeon/r600d.h b/drivers/gpu/drm/radeon/r600d.h
index 44ec7a148c3d..454f90a849e4 100644
--- a/drivers/gpu/drm/radeon/r600d.h
+++ b/drivers/gpu/drm/radeon/r600d.h
@@ -967,6 +967,35 @@
967#define HDMI_CONNECTION (1 << 16) 967#define HDMI_CONNECTION (1 << 16)
968#define DP_CONNECTION (1 << 17) 968#define DP_CONNECTION (1 << 17)
969 969
970#define AZ_F0_CODEC_PIN0_CONTROL_AUDIO_DESCRIPTOR0 0x71c8 /* LPCM */
971#define AZ_F0_CODEC_PIN0_CONTROL_AUDIO_DESCRIPTOR1 0x71cc /* AC3 */
972#define AZ_F0_CODEC_PIN0_CONTROL_AUDIO_DESCRIPTOR2 0x71d0 /* MPEG1 */
973#define AZ_F0_CODEC_PIN0_CONTROL_AUDIO_DESCRIPTOR3 0x71d4 /* MP3 */
974#define AZ_F0_CODEC_PIN0_CONTROL_AUDIO_DESCRIPTOR4 0x71d8 /* MPEG2 */
975#define AZ_F0_CODEC_PIN0_CONTROL_AUDIO_DESCRIPTOR5 0x71dc /* AAC */
976#define AZ_F0_CODEC_PIN0_CONTROL_AUDIO_DESCRIPTOR6 0x71e0 /* DTS */
977#define AZ_F0_CODEC_PIN0_CONTROL_AUDIO_DESCRIPTOR7 0x71e4 /* ATRAC */
978#define AZ_F0_CODEC_PIN0_CONTROL_AUDIO_DESCRIPTOR8 0x71e8 /* one bit audio - leave at 0 (default) */
979#define AZ_F0_CODEC_PIN0_CONTROL_AUDIO_DESCRIPTOR9 0x71ec /* Dolby Digital */
980#define AZ_F0_CODEC_PIN0_CONTROL_AUDIO_DESCRIPTOR10 0x71f0 /* DTS-HD */
981#define AZ_F0_CODEC_PIN0_CONTROL_AUDIO_DESCRIPTOR11 0x71f4 /* MAT-MLP */
982#define AZ_F0_CODEC_PIN0_CONTROL_AUDIO_DESCRIPTOR12 0x71f8 /* DTS */
983#define AZ_F0_CODEC_PIN0_CONTROL_AUDIO_DESCRIPTOR13 0x71fc /* WMA Pro */
984# define MAX_CHANNELS(x) (((x) & 0x7) << 0)
985/* max channels minus one. 7 = 8 channels */
986# define SUPPORTED_FREQUENCIES(x) (((x) & 0xff) << 8)
987# define DESCRIPTOR_BYTE_2(x) (((x) & 0xff) << 16)
988# define SUPPORTED_FREQUENCIES_STEREO(x) (((x) & 0xff) << 24) /* LPCM only */
989/* SUPPORTED_FREQUENCIES, SUPPORTED_FREQUENCIES_STEREO
990 * bit0 = 32 kHz
991 * bit1 = 44.1 kHz
992 * bit2 = 48 kHz
993 * bit3 = 88.2 kHz
994 * bit4 = 96 kHz
995 * bit5 = 176.4 kHz
996 * bit6 = 192 kHz
997 */
998
970/* rs6xx/rs740 and r6xx share the same HDMI blocks, however, rs6xx has only one 999/* rs6xx/rs740 and r6xx share the same HDMI blocks, however, rs6xx has only one
971 * instance of the blocks while r6xx has 2. DCE 3.0 cards are slightly 1000 * instance of the blocks while r6xx has 2. DCE 3.0 cards are slightly
972 * different due to the new DIG blocks, but also have 2 instances. 1001 * different due to the new DIG blocks, but also have 2 instances.