Bug 101900

Summary: No HDMI HBR audio on Polaris (no TrueHD, no Atmos, no Neo:X, no HD Master audio) and static noise in sound when LPCM on amdgpu Xorg driver
Product: DRI Reporter: Direx <direx>
Component: DRM/AMDgpuAssignee: Default DRI bug account <dri-devel>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: medium CC: alexander, direx, frederik.vogelsang, harry.wentland, kohlhz, lethalwp, sandro.wellner
Version: unspecified   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:
Attachments:
Description Flags
dmesg
none
Alsa codec info for HDMI device
none
recording of audio LPCM output from RX550 card
none
[PATCH] Add one to EDID's audio channel count when passing to DC none

Description Direx 2017-07-24 15:38:01 UTC
Created attachment 132868 [details]
dmesg

I am using the current amd-staging-4.11 tree with DC/DAL and HDMI audio is still not working on my RX480. I have already experimented with the amdgpu.audio parameter, but it does not change anything.

alsamixer shows 6 different SPDIF devices for "HDA ATI HDMI" and they are all unmuted. Still HDMI audio is not working at all.

The dmesg actually looks promising, as dc_link_detect detects my AVR and quite a few sound modes with different channel numbers.
Comment 1 Direx 2017-07-24 15:39:01 UTC
Created attachment 132869 [details]
Alsa codec info for HDMI device
Comment 2 Harry Wentland 2017-07-25 13:13:03 UTC
Does this patch fix your issue?

https://patchwork.freedesktop.org/patch/168445/
Comment 3 Direx 2017-07-25 18:56:26 UTC
OK, it seems I tested with the wrong file. PCM is working fine, the issue is just related to HBR audio.

This is my observation:

- Stereo and 5.1 PCM are working
- Dolby Digial and DTS are working

- Dolby TrueHD is not working
- DTS HD Master Audio is not working
- Dolby Atmos is not working
- DTS:X is not working

I have updated the title of the bug to make clear that this is about high bitrate audio. I have also tested the suggested patch, but it does not change anything (neither positive nor negative).

I also turned on my PC speakers which are connected to my internal Intel HDA device and made a funny observation: when I am playing HBR audio there is some bad noise coming from them, although the passthrough device is set to HDMI1.

My audio player is Kodi (ALSA backend) on Arch Linux.
Comment 4 Direx 2017-08-09 19:16:56 UTC
Is there any information missing from my side? Do I need to provide any logs or something like that? I just checked the very latest amd-staging-drm-next and the issue is still present there.

I don't know if this is an ALSA bug, but since other graphics cards are working fine with HBR audio I'd assume it is not. Please point me to the right direction if I am wrong.
Comment 5 Harry Wentland 2017-08-09 19:21:51 UTC
I think the info on this ticket is pretty good. We just haven't had a chance to look at this yet.
Comment 6 Alex Deucher 2017-08-09 19:29:14 UTC
Here's the relevant ALSA code:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/sound/pci/hda/hda_eld.c
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/sound/pci/hda/patch_hdmi.c
The display driver parses the audio capabilities of the monitor and then passes that information to the audio driver via a shared structure called the ELD.  AMD hardware doeswn't use an ELD directly since display audio support on AMD hardware pre-dated ELD.  Instead, the display driver writes fills in the audio descriptors from the monitor into registers that are shared between the audio hardware and the display hardware.  The audio driver then parses these registers and generated and ELD which is used by the audio driver to determine what audio modes are supported by the display.  See snd_hdmi_get_eld_ati().  See patch_atihdmi() for how the streams are set up on the audio side.
Comment 7 Direx 2017-08-10 17:38:07 UTC
Thank you for the feedback. From Alex's comment I take that it actually should be an ALSA issue (correct me if I am wrong). I also opened an ALSA bug, let's see what the ALSA developers think about this:

https://bugzilla.kernel.org/show_bug.cgi?id=196637
Comment 8 Alex Deucher 2017-08-10 18:04:49 UTC
Not sure if it's an Alsa issue or not.  Just pointing out the relevant code to aid in debugging.
Comment 9 Frederik 2017-09-17 16:33:29 UTC
I have the same issue on my Sapphire RX470. I am on the "amd-staging-drm-next" tree and HD audio does not work at all. When playing back a Dolby TrueHD or DTS-HD Master audio file I have also noise coming from my internal speakers instead of the passthrough device.

After the noise comes up, HDMI audio dies completely on me. This means that HDMI audio only works until a HD audio file is being sent to the passthrough device.

I would like to help getting this fixed, as this is a blocker for Kodi users. What logs are needed to get to the root of this issue? From Takashi Iwai's comment on the Alsa bug it looks like this is not an Alsa issue.
Comment 10 Timofonic 2017-10-12 21:49:03 UTC
Any news? This would make AMD hardware more interesting to be used on my future workstation + HTPC setup.
Comment 11 Harry Wentland 2017-10-13 20:06:37 UTC
So, unbeknowst to me, we never supported HBR audio (i.e. TrueHD, etc.) with DC. We would like to enable it but it's not top priority right now.
Comment 12 lethalwp 2017-12-05 09:52:58 UTC
- bumping this thread.
kernel 4.15-rc2 with dc activated for polaris

Still no HBR amdgpu's.

Tried with RX480 & RX550

But i have some worse experience than Direx:
 - Stereo works fine
 - dolby ac3 works fine
 - dts works fine

What doesn't work for me:
 - video+LPCM 5.1 48Khz doesn't work fine (static noise added to the sound, like the bandwith is limited or not optimal scheduling or something?)

 - Dolby Plus also has problems & stutters

 - No Dts-hd, no Dolby TrueHD as previously said.
Comment 13 lethalwp 2017-12-05 14:31:51 UTC
This is an example running mpv & decoding the stereo pcm_s16le 2ch 48000Hz to 6 channels 48Khz.

This generates the audio + noise ( small wav recording attached to this case)


mpv command & verbose:
~# DISPLAY=:0.0 mpv --audio-device='alsa/hdmi:CARD=HDMI,DEV=3' /Fr* -vo vdpau --audio-channels=8 -vo gpu -v
[cplayer] Command line options: '--audio-device=alsa/hdmi:CARD=HDMI,DEV=3' '/Francis.mkv' '-vo' 'vdpau' '--audio-channels=8' '-vo' 'gpu' '-v'
[cplayer] mpv git-2017-10-14-b299a3f (C) 2000-2017 mpv/MPlayer/mplayer2 projects
[cplayer]  built on Tue Oct 17 01:30:07 UTC 2017
[cplayer] ffmpeg library versions:
[cplayer]    libavutil       55.79.100
[cplayer]    libavcodec      57.108.100
[cplayer]    libavformat     57.84.100
[cplayer]    libswscale      4.9.100
[cplayer]    libavfilter     6.108.100
[cplayer]    libswresample   2.10.100
[cplayer] ffmpeg version: git-2017-10-14-0655810
[cplayer]
[cplayer] Configuration: ./waf configure CC=clang-4.0 --enable-pdf-build --enable-dvbin --enable-dvdread --enable-dvdnav --enable-html-build --prefix=/usr --confdir=/etc/mpv
[cplayer] List of enabled features: 52arch alsa asm atomics avutil-content-light-level avutil-icc-profile avutil-spherical build-date cplayer cplugins cuda-hwaccel debug-build drm dvbin dvdnav dvdread dvdread-common egl-drm egl-helpers egl-x11 encoding fchmod gbm gbm.h gl gl-wayland gl-x11 glibc-thread-name glob glob-posix gnuc gpl iconv is_ffmpeg jack jpeg lcms2 libaf libass libass-osd libav libavcodec libavdevice libbluray libdl libm librt linux-fstatfs lua nanosleep optimize oss-audio posix posix-or-mingw posix-spawn posix-spawn-native pthreads pulse rubberband shm stdatomic termios uchardet vaapi vaapi-drm vaapi-egl vaapi-glx vaapi-hwaccel vaapi-wayland vaapi-x-egl vaapi-x11 vdpau vdpau-gl-x11 vdpau-hwaccel vt.h wayland wayland-protocols x11 xv zlib


[bdmv/bluray] Opening /Francis.mkv
[file] Opening /Francis.mkv
[file] Stream opened successfully.
[demux] Trying demuxers for level=normal.
[mkv] Found the head...
[mkv] + a segment...
[mkv] Parsing seek head...
[mkv] |+ segment information...
[mkv] | + muxing app: libebml v1.3.5 + libmatroska v1.4.5
[mkv] | + writing app: mkvmerge v15.0.0 ('Duel with the Devil') 64-bit
[mkv] | + timecode scale: 1000000
[mkv] | + duration: 10595.641s
[mkv] | + segment uid 9f 5f 3d 2a 9c 0f 87 99 b4 ab 82 7c e8 54 b3 21
[mkv] |+ segment tracks...
[mkv] | + a track...
[mkv] |  + Track number: 1
[mkv] |  + Track type: Video
[mkv] |  + Video track
[mkv] |   + Display width: 1920
[mkv] |   + Display height: 1080
[mkv] |   + Pixel width: 1920
[mkv] |   + Pixel height: 1080
[mkv] |  + Codec ID: V_MPEG4/ISO/AVC
[mkv] |  + CodecPrivate, length 58
[mkv] |  + Language: und
[mkv] |  + Default duration: 40.000ms ( = 25.000 fps)
[mkv] | + a track...
[mkv] |  + Track number: 2
[mkv] |  + Track type: Audio
[mkv] |  + Audio track
[mkv] |   + Sampling frequency: 48000.000000
[mkv] |   + Bit depth: 16
[mkv] |   + Channels: 2
[mkv] |  + Codec ID: A_PCM/INT/LIT
[mkv] |  + Language: und
[mkv] |  + Default duration: 31.250ms ( = 32.000 fps)
[mkv] | + a track...
[mkv] |  + Track number: 3
[mkv] |  + Track type: Audio
[mkv] |  + Audio track
[mkv] |   + Sampling frequency: 48000.000000
[mkv] |   + Bit depth: 24
[mkv] |   + Channels: 6
[mkv] |  + Codec ID: A_DTS
[mkv] |  + Language: und
[mkv] |  + Default flag: 0
[mkv] |  + Default duration: 10.667ms ( = 93.750 fps)
[mkv] Parsing chapters...
[mkv] New edition 0
[mkv] Default edition flag: 0
[mkv] |+ found cluster
[mkv] SeekHead position beyond end of file - incomplete file?
[mkv] All headers are parsed!
[demux] Detected file format: Matroska
[cplayer] Opening done: /Francis.mkv
[find_files] Loading external files in /

[cplayer] Running hook: ytdl_hook/on_preloaded
[cplayer] Run command: hook-ack, flags=0, args=[on_preloaded]
[cplayer]  (+) Video --vid=1 (*) (h264 1920x1080 25.000fps)
[cplayer]  (+) Audio --aid=1 (*) (pcm_s16le 2ch 48000Hz)
[cplayer]      Audio --aid=2 (dts 6ch 48000Hz)
[vo/gpu] Probing for best GPU context.
[vo/gpu/opengl] Initializing GPU context 'x11probe'
[vo/gpu/x11] X11 opening display: :0.0
[vo/gpu/x11] X11 running at 1920x1080 (":0.0" => local display)
[vo/gpu/x11] Unknown wm type...
[vo/gpu/x11] Display 0 (HDMI-A-0): [0, 0, 1920, 1080] @ 60.000000 FPS
[vo/gpu/x11] Current display FPS: 60.000000
[vo/gpu/opengl] GLX chose FB config with ID 0xad
[vo/gpu/opengl] GLX chose visual with ID 0x303
[vo/gpu/opengl] Creating OpenGL 4.4 context...
[vo/gpu] GL_VERSION='4.5 (Core Profile) Mesa 17.4.0-devel - padoka PPA'
[vo/gpu] Detected desktop OpenGL 4.5.
[vo/gpu] GL_VENDOR='X.Org'
[vo/gpu] GL_RENDERER='Radeon RX 550 Series (POLARIS12 / DRM 3.23.0 / 4.15.0-041500rc2-lowlatency, LLVM 6.0.0)'
[vo/gpu] GL_SHADING_LANGUAGE_VERSION='4.50'
[vo/gpu] Loaded extension GLX_SGI_swap_control.
[vo/gpu] Loaded extension GLX_MESA_swap_control.
[vo/gpu] Loaded extension GLX_SGI_video_sync.
[vo/gpu] Loaded extension GL_NV_vdpau_interop.
[vo/gpu] Testing FBO format rgba16
[vo/gpu] Resizing texture: 16x16
[vo/gpu] Using FBO format rgba16.
[vo/gpu] No advanced processing required. Enabling dumb mode.
[vo/gpu] Loading hwdec driver 'vaapi-glx'
[vo/gpu/vaapi-glx/vaapi] libva: VA-API version 0.40.0
[vo/gpu/vaapi-glx/vaapi] libva: va_getDriverName() returns 0
[vo/gpu/vaapi-glx/vaapi] libva: Trying to open /usr/lib/x86_64-linux-gnu/dri/radeonsi_drv_video.so
[vo/gpu/vaapi-glx/vaapi] libva: Found init function __vaDriverInit_0_40
mesa: for the -simplifycfg-sink-common option: may only occur zero or one times!
[vo/gpu/vaapi-glx/vaapi] libva: va_openDriver() returns 0
[vo/gpu/vaapi-glx/vaapi] Initialized VAAPI: version 0.40
[ffmpeg] AVHWDeviceContext: Unknown driver "mesa gallium vaapi", assuming standard behaviour.
[vo/gpu] Assuming 60.000000 FPS for display sync.
[vd] Container reported FPS: 25.000000
[vd] Codec list:
[vd]     h264 - H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10
[vd]     h264_v4l2m2m (h264) - V4L2 mem2mem H.264 decoder wrapper
[vd]     h264_cuvid (h264) - Nvidia CUVID H264 decoder
[vd] Opening video decoder h264
[vd] Probing 'vaapi'...
[vd] Trying hardware decoding.
[vd] Selected video codec: h264 (H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10)
[ad] Codec list:
[ad]     pcm_s16le - PCM signed 16-bit little-endian
[ad] Opening audio decoder pcm_s16le
[ad] Requesting 1 threads for decoding.
[ad] Selected audio codec: pcm_s16le (PCM signed 16-bit little-endian)
[cplayer] Starting playback...
[af] Adding filter scaletempo
[af] Adding filter lavcac3enc
[af] Setting option 'tospdif' = 'yes' (flags = 0)
[af] Setting option 'bitrate' = '640' (flags = 0)
[af] Setting option 'minch' = '3' (flags = 0)
[af] Removing filter lavcac3enc
[af] Adding filter lavrresample
[lavrresample] Remix: stereo -> 7.1
[af] Audio filter chain:
[af]   [in] 48000Hz stereo 2ch s16
[af]   [scaletempo] 48000Hz stereo 2ch s16
[af]   [lavrresample] 48000Hz 7.1 8ch s16 [a]
[af]   [out] 48000Hz 7.1 8ch s16
[af]   [ao] 48000Hz 7.1 8ch s16
[af] Removing filter lavrresample
[af] Adding filter lavrresample
[lavrresample] Remix: stereo -> 7.1
[af] Moving up output conversion.
[lavrresample] Remix: stereo -> 7.1
[af] Audio filter chain:
[af]   [in] 48000Hz stereo 2ch s16
[af]   [lavrresample] 48000Hz 7.1 8ch s16 [a]
[af]   [scaletempo] 48000Hz 7.1 8ch s16
[af]   [out] 48000Hz 7.1 8ch s16
[af]   [ao] 48000Hz 7.1 8ch s16
[ao] Trying audio driver 'alsa'
[ao] Using preferred device 'hdmi:CARD=HDMI,DEV=3'
[ao/alsa] requested format: 48000 Hz, 7.1 channels, s16
[ao/alsa] using ALSA version: 1.1.3
[ao/alsa] opening device 'hdmi:CARD=HDMI,DEV=3'
[ao/alsa] trying format s16/2
[ao/alsa] Channel layouts:
[ao/alsa]  - stereo
[ao/alsa]  - 2.1
[ao/alsa]  - 3.0
[ao/alsa]  - 3.0(back)
[ao/alsa]  - quad
[ao/alsa]  - 3.1
[ao/alsa]  - 3.1(back)
[ao/alsa]  - 4.0
[ao/alsa]  - fl-fr-lfe-bl-br
[ao/alsa]  - 5.0
[ao/alsa]  - 4.1
[ao/alsa]  - fl-fr-bl-br-bc
[ao/alsa]  - 5.1
[ao/alsa]  - fl-fr-lfe-bl-br-bc
[ao/alsa]  - hexagonal
[ao/alsa]  - fl-fr-bl-br-sl-sr
[ao/alsa]  - 6.1(back)
[ao/alsa]  - fl-fr-lfe-bl-br-sl-sr
[ao/alsa]  - 7.0
[ao/alsa]  - 7.1
[ao/alsa] result: 7.1
[ao/alsa] Going to set final HW params:
[ao/alsa] ---
[ao/alsa] ACCESS:  RW_INTERLEAVED
[ao/alsa] FORMAT:  S16_LE
[ao/alsa] SUBFORMAT:  STD
[ao/alsa] SAMPLE_BITS: 16
[ao/alsa] FRAME_BITS: 96
[ao/alsa] CHANNELS: 6
[ao/alsa] RATE: 48000
[ao/alsa] PERIOD_TIME: (6666 6667)
[ao/alsa] PERIOD_SIZE: 320
[ao/alsa] PERIOD_BYTES: 3840
[ao/alsa] PERIODS: 17
[ao/alsa] BUFFER_TIME: (113333 113334)
[ao/alsa] BUFFER_SIZE: 5440
[ao/alsa] BUFFER_BYTES: 65280
[ao/alsa] TICK_TIME: ALL
[ao/alsa] ---
[ao/alsa] trying to set ALSA channel map: FL FR FC LFE RLC RRC RL RR
[ao/alsa] channel map reported by ALSA: FL FR FC LFE RLC RRC
[ao/alsa] which we understand as: fl-fr-fc-lfe-sdl-sdr
[ao/alsa] using the ALSA channel map.
[ao/alsa] hw pausing supported: yes
[ao/alsa] buffersize: 5440 samples
[ao/alsa] period size: 320 samples
[ao/alsa] device buffer: 5440 samples.
[ao/alsa] using soft-buffer of 9600 samples.
[cplayer] AO: [alsa] 48000Hz fl-fr-fc-lfe-sdl-sdr 6ch s16
[cplayer] AO: Description: ALSA audio output
[af] Removing filter lavrresample
[af] Adding filter lavrresample
[lavrresample] Remix: stereo -> fl-fr-fc-lfe-sdl-sdr
[af] Audio filter chain:
[af]   [in] 48000Hz stereo 2ch s16
[af]   [scaletempo] 48000Hz stereo 2ch s16
[af]   [lavrresample] 48000Hz fl-fr-fc-lfe-sdl-sdr 6ch s16 [a]
[af]   [out] 48000Hz fl-fr-fc-lfe-sdl-sdr 6ch s16
[af]   [ao] 48000Hz fl-fr-fc-lfe-sdl-sdr 6ch s16
[af] Removing filter lavrresample
[af] Adding filter lavrresample
[lavrresample] Remix: stereo -> fl-fr-fc-lfe-sdl-sdr
[af] Moving up output conversion.
[lavrresample] Remix: stereo -> fl-fr-fc-lfe-sdl-sdr
[af] Audio filter chain:
[af]   [in] 48000Hz stereo 2ch s16
[af]   [lavrresample] 48000Hz fl-fr-fc-lfe-sdl-sdr 6ch s16 [a]
[af]   [scaletempo] 48000Hz fl-fr-fc-lfe-sdl-sdr 6ch s16
[af]   [out] 48000Hz fl-fr-fc-lfe-sdl-sdr 6ch s16
[af]   [ao] 48000Hz fl-fr-fc-lfe-sdl-sdr 6ch s16
[vd] Pixel formats supported by decoder: vdpau vaapi_vld yuv420p
[vd] Codec profile: Main (0x4d)
[vd] Requesting pixfmt 'vaapi_vld' from decoder.
[ffmpeg/video] h264: Reinit context to 1920x1088, pix_fmt: vaapi_vld
[vd] Using hardware decoding (vaapi).
[vd] Decoder format: 1920x1080 vaapi[nv12] auto/auto/auto/limited CL=mpeg2/4/h264 (auto 0.000000/0.000000/0.000000)
[vd] Using container aspect ratio.
[vf] Video filter chain:
[vf]   [in] 1920x1080 vaapi[nv12] bt.709/bt.709/bt.1886/limited SP=1.000000 CL=mpeg2/4/h264
[vf]   [out] 1920x1080 vaapi[nv12] bt.709/bt.709/bt.1886/limited SP=1.000000 CL=mpeg2/4/h264
[cplayer] VO: [gpu] 1920x1080 vaapi[nv12]
[cplayer] VO: Description: Shader-based GPU Renderer
[vo/gpu] Resize: 1920x1080
[vo/gpu] Window size: 1920x1080
[vo/gpu] Video source: 1920x1080 (1:1)
[vo/gpu] Video display: (0, 0) 1920x1080 -> (0, 0) 1920x1080
[vo/gpu] Video scale: 1.000000/1.000000
[vo/gpu] OSD borders: l=0 t=0 r=0 b=0
[vo/gpu] Video borders: l=0 t=0 r=0 b=0
[vo/gpu] Reported display depth: 8
[vo/gpu] Testing FBO format rgba16
[vo/gpu] Resizing texture: 16x16
[vo/gpu] Using FBO format rgba16.
[vo/gpu] No advanced processing required. Enabling dumb mode.
[vo/gpu] new shader program:
[vo/gpu] [  1] color.rgb = 1.000000 * vec4(texture(texture0, texcoord0)).rgb;
[vo/gpu] [  2] color = color.rgbr;
[vo/gpu] [  3] color.rgb = mat3(colormatrix) * color.rgb + colormatrix_c;
[vo/gpu] [  4] color.a = 1.0;
[vo/gpu] [  5] // color mapping
[osd/libass] fontselect: (sans-serif, 400, 0) -> /usr/share/fonts/truetype/dejavu/DejaVuSans.ttf, 0, DejaVuSans
[cplayer] first video frame after restart shown
[cplayer] starting audio playback
[cplayer] playback restart complete
[statusline] AV: 00:00:00 / 02:56:35 (0%) A-V:  0.000
[vo/gpu/x11] Disabling screensaver.
[statusline] AV: 00:00:01 / 02:56:35 (0%) A-V:  0.000
...
Comment 14 lethalwp 2017-12-05 14:33:28 UTC
Created attachment 135979 [details]
recording of audio LPCM output from RX550 card
Comment 15 lethalwp 2017-12-05 14:41:22 UTC
dc_log enabled:

:~# dmesg | grep drm
[    1.413712] [drm] amdgpu kernel modesetting enabled.
[    1.420821] fb: switching to amdgpudrmfb from VESA VGA
[    1.421365] [drm] initializing kernel modesetting (POLARIS12 0x1002:0x699F 0x1DA2:0xE367 0xC7).
[    1.421375] [drm] register mmio base: 0xFF9C0000
[    1.421376] [drm] register mmio size: 262144
[    1.421386] [drm] probing gen 2 caps for device 8086:277d = 2012501/0
[    1.421387] [drm] probing mlw for device 8086:277d = 2012501
[    1.421395] [drm] UVD is enabled in VM mode
[    1.421396] [drm] UVD ENC is enabled in VM mode
[    1.421398] [drm] VCE enabled in VM mode
[    1.422382] [drm] GPU post is not needed
[    1.422402] [drm] vm size is 64 GB, block size is 13-bit, fragment size is 9-bit
[    1.422452] [drm] Detected VRAM RAM=2048M, BAR=256M
[    1.422453] [drm] RAM width 128bits GDDR5
[    1.422538] [drm] amdgpu: 2048M of VRAM memory ready
[    1.422539] [drm] amdgpu: 3072M of GTT memory ready.
[    1.422547] [drm] GART: num cpu pages 65536, num gpu pages 65536
[    1.422597] [drm] PCIE GART of 256M enabled (table at 0x000000F400040000).
[    1.422690] [drm] amdgpu: irq initialized.
[    1.422768] [drm] Chained IB support enabled!
[    1.424499] [drm] Found UVD firmware Version: 1.79 Family ID: 16
[    1.425670] [drm] Found VCE firmware Version: 52.4 Binary ID: 3
[    1.505597] [drm] DM_PPLIB: values for Engine clock
[    1.505599] [drm] DM_PPLIB:   21400
[    1.505600] [drm] DM_PPLIB:   55100
[    1.505600] [drm] DM_PPLIB:   73400
[    1.505601] [drm] DM_PPLIB:   98000
[    1.505601] [drm] DM_PPLIB:   104600
[    1.505602] [drm] DM_PPLIB:   109800
[    1.505602] [drm] DM_PPLIB:   112400
[    1.505603] [drm] DM_PPLIB:   120600
[    1.505603] [drm] DM_PPLIB: Warning: using default validation clocks!
[    1.505604] [drm] DM_PPLIB: Validation clocks:
[    1.505605] [drm] DM_PPLIB:    engine_max_clock: 72000
[    1.505605] [drm] DM_PPLIB:    memory_max_clock: 80000
[    1.505606] [drm] DM_PPLIB:    level           : 0
[    1.505606] [drm] DM_PPLIB: reducing engine clock level from 8 to 2
[    1.505608] [drm] DM_PPLIB: values for Memory clock
[    1.505608] [drm] DM_PPLIB:   30000
[    1.505609] [drm] DM_PPLIB:   62500
[    1.505609] [drm] DM_PPLIB:   175000
[    1.505610] [drm] DM_PPLIB: Warning: using default validation clocks!
[    1.505611] [drm] DM_PPLIB: Validation clocks:
[    1.505611] [drm] DM_PPLIB:    engine_max_clock: 72000
[    1.505612] [drm] DM_PPLIB:    memory_max_clock: 80000
[    1.505612] [drm] DM_PPLIB:    level           : 0
[    1.505613] [drm] DM_PPLIB: reducing memory clock level from 3 to 2
[    1.505615] [drm] DC: create_links: connectors_num: physical:3, virtual:0
[    1.505620] [drm] Connector[0] description:signal 32
[    1.505637] [drm] Connector[1] description:signal 4
[    1.505650] [drm] Connector[2] description:signal 2
[    1.515049] [drm] Display Core initialized
[    1.515051] [drm] Display Core initialized!
[    1.515588] [drm] link=0, dc_sink_in=          (null) is now Disconnected
[    1.540524] [drm] [Detect]   [HDMIA][ConnIdx:1] DENON-AVAMP: [Block 0] 00 FF FF FF FF FF FF 00 11 EE 29 00 01 01 01 01 00 15 01 03 80 00 00 78 0A DA FF A3 58 4A A2 29 17 49 4B 00 00 00 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 1D 80 D0 72 1C 16 20 10 2C 25 80 9A 26 53 00 00 9E 01 1D 80 18 71 1C 16 20 58 2C 25 00 9A 26 53 00 00 9E 00 00 00 FC 00 44 45 4E 4F 4E 2D 41 56 41 4D 50 0A 20 00 00 00 FD 00 17 3D 0F 44 0F 00 0A 20 20 20 20 20 20 01 CA ^
[    1.540538] [drm] [Detect]   [HDMIA][ConnIdx:1] DENON-AVAMP: [Block 1] 02 03 3B 72 58 13 04 94 85 1F 10 20 12 03 11 02 16 07 15 06 01 0E 23 0F 24 1D 25 1E 26 32 0F 7F 07 3D 1E C0 15 07 50 5F 7E 01 57 06 00 67 7E 00 83 5F 00 00 66 03 0C 00 12 00 80 01 1D 80 D0 72 1C 16 20 10 2C 25 80 9A 26 53 00 00 9E 8C 0A D0 90 20 40 31 20 0C 40 55 00 9A 26 53 00 00 18 01 1D 80 18 71 1C 16 20 58 2C 25 00 9A 26 53 00 00 9E 00 00 00 00 00 00 00 00 00 00 00 00 00 00 CB ^
[    1.540541] [drm] dc_link_detect: manufacturer_id = EE11, product_id = 29, serial_number = 1010101, manufacture_week = 0, manufacture_year = 21, display_name = DENON-AVAMP, speaker_flag = 95, audio_mode_count = 6
[    1.540542] [drm] dc_link_detect: mode number = 0, format_code = 1, channel_count = 7, sample_rate = 127, sample_size = 7
[    1.540543] [drm] dc_link_detect: mode number = 1, format_code = 7, channel_count = 5, sample_rate = 30, sample_size = 192
[    1.540545] [drm] dc_link_detect: mode number = 2, format_code = 2, channel_count = 5, sample_rate = 7, sample_size = 80
[    1.540546] [drm] dc_link_detect: mode number = 3, format_code = 11, channel_count = 7, sample_rate = 126, sample_size = 1
[    1.540547] [drm] dc_link_detect: mode number = 4, format_code = 10, channel_count = 7, sample_rate = 6, sample_size = 0
[    1.540549] [drm] dc_link_detect: mode number = 5, format_code = 12, channel_count = 7, sample_rate = 126, sample_size = 0
[    1.540550] [drm] link=1, dc_sink_in=00000000cf1ce385 is now Connected
[    1.540658] [drm] link=2, dc_sink_in=          (null) is now Disconnected
[    1.540663] [drm] Supports vblank timestamp caching Rev 2 (21.10.2013).
[    1.540664] [drm] Driver supports precise vblank timestamp query.
[    1.541992] [drm] ring test on 0 succeeded in 14 usecs
[    1.542810] [drm] ring test on 9 succeeded in 12 usecs
[    1.542833] [drm] ring test on 1 succeeded in 10 usecs
[    1.542842] [drm] ring test on 2 succeeded in 3 usecs
[    1.542851] [drm] ring test on 3 succeeded in 3 usecs
[    1.542860] [drm] ring test on 4 succeeded in 3 usecs
[    1.542886] [drm] ring test on 5 succeeded in 12 usecs
[    1.542895] [drm] ring test on 6 succeeded in 3 usecs
[    1.542905] [drm] ring test on 7 succeeded in 3 usecs
[    1.542914] [drm] ring test on 8 succeeded in 3 usecs
[    1.542971] [drm] ring test on 10 succeeded in 6 usecs
[    1.542982] [drm] ring test on 11 succeeded in 6 usecs
[    1.589877] [drm] ring test on 12 succeeded in 1 usecs
[    1.589925] [drm] ring test on 13 succeeded in 19 usecs
[    1.589935] [drm] ring test on 14 succeeded in 3 usecs
[    1.589936] [drm] UVD and UVD ENC initialized successfully.
[    1.700851] [drm] ring test on 15 succeeded in 6 usecs
[    1.700862] [drm] ring test on 16 succeeded in 3 usecs
[    1.700862] [drm] VCE initialized successfully.
[    1.701192] [drm] ib test on ring 0 succeeded
[    1.701356] [drm] ib test on ring 1 succeeded
[    1.701404] [drm] ib test on ring 2 succeeded
[    1.701452] [drm] ib test on ring 3 succeeded
[    1.701500] [drm] ib test on ring 4 succeeded
[    1.701548] [drm] ib test on ring 5 succeeded
[    1.701596] [drm] ib test on ring 6 succeeded
[    1.701644] [drm] ib test on ring 7 succeeded
[    1.701700] [drm] ib test on ring 8 succeeded
[    2.208003] [drm] ib test on ring 9 succeeded
[    2.208045] [drm] ib test on ring 10 succeeded
[    2.208075] [drm] ib test on ring 11 succeeded
[    2.209590] [drm] ib test on ring 12 succeeded
[    2.209923] [drm] ib test on ring 13 succeeded
[    2.210201] [drm] ib test on ring 14 succeeded
[    2.210446] [drm] ib test on ring 15 succeeded
[    2.212094] [drm] fb mappable at 0xD03F2000
[    2.212095] [drm] vram apper at 0xD0000000
[    2.212096] [drm] size 8294400
[    2.212097] [drm] fb depth is 24
[    2.212098] [drm]    pitch is 7680
[    2.212174] fbcon: amdgpudrmfb (fb0) is primary device
[    2.212733] [drm] dc_commit_state: 1 streams
[    2.212736] [drm] core_stream 0x7369a800: src: 0, 0, 1920, 1080; dst: 0, 0, 1920, 1080, colorSpace:4
[    2.212737] [drm]    pix_clk_khz: 148500, h_total: 2200, v_total: 1125, pixelencoder:3, displaycolorDepth:2
[    2.212738] [drm]    sink name: DENON-AVAMP, serial: 16843009
[    2.212739] [drm]    link: 1
[    2.231575] [drm] [Mode]     [HDMIA][ConnIdx:1] {1920x1080, 2200x1125@148500Khz}^
[    2.271162] amdgpu 0000:05:00.0: fb0: amdgpudrmfb frame buffer device
[    2.277167] [drm] Initialized amdgpu 3.23.0 20150101 for 0000:05:00.0 on minor 0
Comment 16 Sandro 2017-12-19 16:10:09 UTC
Does this have any priority at all? This is essential for HTPC users out there so it would be good to know if somebody is working on this or if there is any information missing here.
Comment 17 Michel Dänzer 2017-12-22 09:42:41 UTC
FWIW, according to comments on https://lwn.net/Articles/740916/:

* HDMI sinks complying with the relevant specs only accept Dolby TrueHD with HDCP enabled.
* There are buggy HDMI sinks which only play some other "high quality" bit streams with HDCP enabled.
Comment 18 Direx 2017-12-22 13:31:46 UTC
(In reply to Michel Dänzer from comment #17)
> FWIW, according to comments on https://lwn.net/Articles/740916/:
> 
> * HDMI sinks complying with the relevant specs only accept Dolby TrueHD with
> HDCP enabled.
> * There are buggy HDMI sinks which only play some other "high quality" bit
> streams with HDCP enabled.

The article does not say anything at all about HBR audio. Just one comment and I also doubt that this is true. Where is that spec? I have tested quite a few GPUs (Intel with i915, Nvidia, r600) and all of them had proper HDMI audio/HBR support, which was completely unrelated to HDCP.

Even on Windows HBR audio does not have anything to do with HDCP. I am not using HDCP there either and my RX480 properly passes all audio formats to my AVR on Windows.

From this bug report it looks like AMD has completely given up on HTPC people and leaves this area entirely to Intel.
Comment 19 Andy Furniss 2017-12-29 00:06:56 UTC
(In reply to lethalwp from comment #14)
> Created attachment 135979 [details]
> recording of audio LPCM output from RX550 card

FWIW, for years "direct" alsa + hdmi on recent cards has had issues.

It can work if there is enough cpu i/o load. Not quite enough load can sound like that, no where near enough load can sound like it's stuck.

Pulse or jack don't have the issue as they do things differently.

See -

https://bugzilla.kernel.org/show_bug.cgi?id=86351
Comment 20 Alex Deucher 2018-01-11 21:09:42 UTC
Everything looks like it's implemented properly in the code to enable HBR audio.  Take a look at:
drivers/gpu/drm/amd/display/dc/dce/dce_audio.c for audio configuration
drivers/gpu/drm/amd/display/dc/dce/dce_stream_encoder.c for display stream infoframes

Can you add some debugging output to dce_aud_az_configure() to see why it may not be getting enabled in your case?  Specifically see if is_audio_format_supported() is failing for HBR formats and why and see if set_high_bit_rate_capable() is getting enabled.
Comment 21 Direx 2018-01-12 11:48:02 UTC
Alex, thanks a lot for taking a look at this. I also think that everything is already in place and just a tiny piece is missing or going wrong (with a big impact though). I'd like to help you sort that out.

(In reply to Alex Deucher from comment #20)
> Can you add some debugging output to dce_aud_az_configure() to see why it
> may not be getting enabled in your case?  Specifically see if
> is_audio_format_supported() is failing for HBR formats and why and see if
> set_high_bit_rate_capable() is getting enabled.

OK, I've hacked my kernel (4.15-rc7) like this (sorry for the noobish print debugging):

diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_audio.c b/drivers/gpu/drm/amd/display/dc/dce/dce_audio.c
index 0df9ecb2710c..1c9e5b0a3f39 100644
--- a/drivers/gpu/drm/amd/display/dc/dce/dce_audio.c
+++ b/drivers/gpu/drm/amd/display/dc/dce/dce_audio.c
@@ -291,7 +291,12 @@ static void set_high_bit_rate_capable(
        struct audio *audio,
        bool capable)
 {
-       uint32_t value = 0;
+    if (capable)
+        printk(KERN_WARNING "hbrlog: HBR capable is enabled");
+    else
+        printk(KERN_WARNING "hbrlog: HBR cabable is disabled");
+
+    uint32_t value = 0;
 
        /* set high bit rate audio capable*/
        value = AZ_REG_READ(AZALIA_F0_CODEC_PIN_CONTROL_RESPONSE_HBR);
@@ -499,6 +504,9 @@ void dce_aud_az_configure(
                /* check if supported */
                if (is_audio_format_supported(
                                audio_info, audio_format_code, &index)) {
+
+            printk(KERN_WARNING "hbrlog: audio codec is supported");
+
                        const struct audio_mode *audio_mode =
                                        &audio_info->modes[index];
                        union audio_sample_rates sample_rates =
@@ -527,9 +535,13 @@ void dce_aud_az_configure(
                                break;
                        case AUDIO_FORMAT_CODE_DOLBYDIGITALPLUS:
                        case AUDIO_FORMAT_CODE_DTS_HD:
+                printk(KERN_WARNING "hbrlog: DTS-HD detected");
                        case AUDIO_FORMAT_CODE_MAT_MLP:
-                       case AUDIO_FORMAT_CODE_DST:
+                printk(KERN_WARNING "hbrlog: TrueHD/MLP detected");
+            case AUDIO_FORMAT_CODE_DST:
+                printk(KERN_WARNING "hbrlog: DST detected");
                        case AUDIO_FORMAT_CODE_WMAPRO:
+                printk(KERN_WARNING "hbrlog: vendor_specific");
                                byte2 = audio_mode->vendor_specific;
                                break;
                        default:
@@ -551,7 +563,35 @@ void dce_aud_az_configure(
                                        byte2,
                                        AZALIA_F0_CODEC_PIN_CONTROL_AUDIO_DESCRIPTOR0,
                                        DESCRIPTOR_BYTE_2);
-               } /* if */
+               } else {
+            /* unsupported audio codec */
+                       switch (audio_format_code) {
+                       case AUDIO_FORMAT_CODE_LINEARPCM:
+                printk(KERN_WARNING "hbrlog: PCM unsupported");
+                               break;
+                       case AUDIO_FORMAT_CODE_AC3:
+                printk(KERN_WARNING "hbrlog: AC3 unsupported");
+                               break;
+                       case AUDIO_FORMAT_CODE_DOLBYDIGITALPLUS:
+                printk(KERN_WARNING "hbrlog: DD+ unsupported");
+                break;
+            case AUDIO_FORMAT_CODE_DTS_HD:
+                printk(KERN_WARNING "hbrlog: DTS-HD unsupported");
+                break;
+                       case AUDIO_FORMAT_CODE_MAT_MLP:
+                printk(KERN_WARNING "hbrlog: TrueHD/MLP unsupported");
+                break;
+            case AUDIO_FORMAT_CODE_DST:
+                printk(KERN_WARNING "hbrlog: DST unsupported");
+                break;
+                       case AUDIO_FORMAT_CODE_WMAPRO:
+                printk(KERN_WARNING "hbrlog: WMAPRO unsupported");
+                               break;
+                       default:
+                printk(KERN_WARNING "hbrlog: audio codec unsupported");
+                               break;
+                       }
+        }
 
                AZ_REG_WRITE(
                                AZALIA_F0_CODEC_PIN_CONTROL_AUDIO_DESCRIPTOR0 + format_index,

But as far as I understand this code is only run once when initializing the GPU, not when playing back audio. Below is my dmesg output, please let me know if this is useful or if you need additional information. I had only attached one dislplay for this capture (my AVR). It looks like TrueHD and DTS-HD are properly marked as "supported".


[   17.027288] fbcon: amdgpudrmfb (fb0) is primary device
[   17.050864] [drm] {3840x2160, 4400x2250@594000Khz}
[   17.050976] hbrlog: audio codec is supported
[   17.050977] hbrlog: audio codec is supported
[   17.050977] hbrlog: audio codec unsupported
[   17.050977] hbrlog: audio codec unsupported
[   17.050978] hbrlog: audio codec unsupported
[   17.050978] hbrlog: audio codec unsupported
[   17.050978] hbrlog: audio codec is supported
[   17.050978] hbrlog: audio codec unsupported
[   17.050979] hbrlog: audio codec is supported
[   17.050979] hbrlog: DTS-HD detected
[   17.050979] hbrlog: TrueHD/MLP detected
[   17.050979] hbrlog: DST detected
[   17.050979] hbrlog: vendor_specific
[   17.050980] hbrlog: audio codec is supported
[   17.050980] hbrlog: DTS-HD detected
[   17.050980] hbrlog: TrueHD/MLP detected
[   17.050980] hbrlog: DST detected
[   17.050980] hbrlog: vendor_specific
[   17.050980] hbrlog: audio codec is supported
[   17.050980] hbrlog: TrueHD/MLP detected
[   17.050981] hbrlog: DST detected
[   17.050981] hbrlog: vendor_specific
[   17.050981] hbrlog: WMAPRO unsupported
[   17.050981] hbrlog: HBR capable is enabled
[   17.067921] Console: switching to colour frame buffer device 480x135
[   17.078529] amdgpu 0000:01:00.0: fb0: amdgpudrmfb frame buffer device
[   17.104099] amdgpu 0000:01:00.0: kfd not supported on this ASIC
[   17.104114] [drm] Initialized amdgpu 3.23.0 20150101 for 0000:01:00.0 on minor 0
[   17.194239] IPv6: ADDRCONF(NETDEV_UP): enp3s0: link is not ready
[   17.302047] r8169 0000:03:00.0 enp3s0: link down
[   17.302049] r8169 0000:03:00.0 enp3s0: link down
[   17.302087] IPv6: ADDRCONF(NETDEV_UP): enp3s0: link is not ready
[   17.968392] [drm] {1920x1080, 2200x1125@148500Khz}
[   18.001320] hbrlog: audio codec is supported
[   18.001320] hbrlog: audio codec is supported
[   18.001321] hbrlog: audio codec unsupported
[   18.001321] hbrlog: audio codec unsupported
[   18.001322] hbrlog: audio codec unsupported
[   18.001322] hbrlog: audio codec unsupported
[   18.001322] hbrlog: audio codec is supported
[   18.001323] hbrlog: audio codec unsupported
[   18.001323] hbrlog: audio codec is supported
[   18.001323] hbrlog: DTS-HD detected
[   18.001324] hbrlog: TrueHD/MLP detected
[   18.001324] hbrlog: DST detected
[   18.001324] hbrlog: vendor_specific
[   18.001325] hbrlog: audio codec is supported
[   18.001325] hbrlog: DTS-HD detected
[   18.001325] hbrlog: TrueHD/MLP detected
[   18.001325] hbrlog: DST detected
[   18.001325] hbrlog: vendor_specific
[   18.001326] hbrlog: audio codec is supported
[   18.001326] hbrlog: TrueHD/MLP detected
[   18.001326] hbrlog: DST detected
[   18.001326] hbrlog: vendor_specific
[   18.001327] hbrlog: WMAPRO unsupported
[   18.001327] hbrlog: HBR capable is enabled
[   19.580261] r8169 0000:03:00.0 enp3s0: link up
[   19.580266] IPv6: ADDRCONF(NETDEV_CHANGE): enp3s0: link becomes ready
Comment 22 lethalwp 2018-01-12 14:04:27 UTC
Thank you for the printks.

If the code is only ran at initialization of gpu:

could this explain the lpcm noise issue?: The reserved bandwidth at gpu init isn't enough anymore when video+more audio comes through?
Comment 23 Alex Deucher 2018-01-12 17:53:28 UTC
(In reply to lethalwp from comment #22)
> Thank you for the printks.
> 
> If the code is only ran at initialization of gpu:
> 
> could this explain the lpcm noise issue?: The reserved bandwidth at gpu init
> isn't enough anymore when video+more audio comes through?

The audio configuration only needs to run once per modeset.  It basically just  forwards the display info to the audio device and tells the audio device what it can support given the current display mode and enables the audio stream within the display stream.  At that point, the display device is just a conduit for the audio device.
Comment 24 Alex Deucher 2018-01-12 17:55:36 UTC
Can you see what channels is set to in dce110_se_audio_setup() in dce_stream_encoder.c?  Does forcing it to 0xff help?
Comment 25 Direx 2018-01-12 18:50:26 UTC
The printks indeed only show up when the computer boots or when the display comes back from DPMS. I don't get any printks when playing audio streams.

(In reply to Alex Deucher from comment #24)
> Can you see what channels is set to in dce110_se_audio_setup() in
> dce_stream_encoder.c?  Does forcing it to 0xff help?

Ok, here's my change:

diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_stream_encoder.c b/drivers/gpu/drm/amd/display/dc/dce/dce_stream_encoder.c
index e42b6eb1c1f0..19befbf594c2 100644
--- a/drivers/gpu/drm/amd/display/dc/dce/dce_stream_encoder.c
+++ b/drivers/gpu/drm/amd/display/dc/dce/dce_stream_encoder.c
@@ -1320,6 +1320,9 @@ static void dce110_se_audio_setup(
        speakers = audio_info->flags.info.ALLSPEAKERS;
        channels = speakers_to_channels(audio_info->flags.speaker_flags).all;
 
+    printk(KERN_WARNING "hbrlog: channels set to %d, forcing 0xff", channels);
+    channels = 0xff;
+
        /* setup the audio stream source select (audio -> dig mapping) */
        REG_SET(AFMT_AUDIO_SRC_CONTROL, 0, AFMT_AUDIO_SRC_SELECT, az_inst);


And that's what I get in dmesg:

[   10.920144] hbrlog: channels set to 255, forcing 0xff

-> So unfortunately no change here.

//BTW: my DP monitor is reporting 3 channels, which also sounds good to me
Comment 26 lethalwp 2018-01-21 19:43:34 UTC
The UVD polaris firmware update from 18 of january 2018 solves my problem:
the LPCM & DTS sound is normal now.

Still missing are high bitrate codecs (dts-hd etc).

The RX cards can finally serve as HTPC cards!
Comment 27 lethalwp 2018-01-22 09:14:51 UTC
After more tests, i have a small race condition on my systemctl setup which causes X to be unable to load the "amdgpu" driver and fallbacks on "modesetting" instead.

In this case, the videocard can't use vdpau anymore, so it's fully software decoding. Then the sound is playing perfectly.

When X is loading the amdgpu driver, the sound problems are still present. The video must eat the sound bandwidth or something (?)

Actually on "4.15.0-999-generic #201801102100"
Comment 28 Andy Furniss 2018-01-22 09:55:46 UTC
(In reply to lethalwp from comment #27)
> After more tests, i have a small race condition on my systemctl setup which
> causes X to be unable to load the "amdgpu" driver and fallbacks on
> "modesetting" instead.
> 
> In this case, the videocard can't use vdpau anymore, so it's fully software
> decoding. Then the sound is playing perfectly.
> 
> When X is loading the amdgpu driver, the sound problems are still present.
> The video must eat the sound bandwidth or something (?)

Software decode/display may load CPUs enough to hide the alsa bug I mentioned earlier.

Try testing with an audio only file (be sure the player for this test is using alsa not pulse).
Comment 29 lethalwp 2018-01-23 17:29:55 UTC
Thank you Andy, i will look into your previous comments and make some tests, hope i will be able to confirm somehow.

I suppose these are all ati/radeon audio+cpu related?

Because i'ved used hdmi-audio on nvidia for years without problems, so it's not "general" as in every hdmi-audio driver.

From what i've seen in the code, amdgpu reuse the same audio code than previous radeon cards. This could explain that the problem is still present, even years laters (?)
Comment 30 lethalwp 2018-01-23 17:33:26 UTC
@andy:
Indeed, when i make -j3 on the kernel, the sound gets right.
When i kill the make,  the audio gets glitchy !
Comment 31 Andrew Nelson 2018-03-04 21:48:07 UTC
I have been running into the same issue. The problem seems to be that AMDGPU is reporting that it supports 7 speakers instead of 8 in the EID. HBR formats work with 5.1 encoded audio, but not 7.1. For some reason, the driver is configured to subtract 1 from the channel count before passing it into the EID. I have removed this and confirmed that 7.1 HBR audio works. Patch below:

diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_audio.c b/drivers/gpu/drm/amd/display/dc/dce/dce_audio.c
index 8bfb4577b4d5..5dcc685a1379 100644
--- a/drivers/gpu/drm/amd/display/dc/dce/dce_audio.c
+++ b/drivers/gpu/drm/amd/display/dc/dce/dce_audio.c
@@ -557,7 +557,7 @@ void dce_aud_az_configure(

                        /* fill audio format data */
                        set_reg_field_value(value,
-                                       audio_mode->channel_count - 1,
+                                       audio_mode->channel_count,
                                        AZALIA_F0_CODEC_PIN_CONTROL_AUDIO_DESCRIPTOR0,
                                        MAX_CHANNELS);
Comment 32 Direx 2018-03-05 18:45:26 UTC
(In reply to Andrew Nelson from comment #31)
> I have been running into the same issue. The problem seems to be that AMDGPU
> is reporting that it supports 7 speakers instead of 8 in the EID. HBR
> formats work with 5.1 encoded audio, but not 7.1. For some reason, the
> driver is configured to subtract 1 from the channel count before passing it
> into the EID. I have removed this and confirmed that 7.1 HBR audio works.

Jackpot, this is it. Just tried your patch and now all audio formats are working. I can confirm that the following formats can now be played back correctly on my RX480:

- PCM 2.0
- PCM 5.1
- PCM 7.1
- Dolby Digital@5.1
- DTS@5.1
- Dolby TrueHD@7.1
- DTS HD-MA@7.1
- Dolby Atmos

Excellent job. Can we please get this patch into drm-fixes, as it is cleary a bug fix and not a new feature.
Comment 33 lethalwp 2018-03-07 10:44:46 UTC
After trying the channel-count patch.

The different formats tested advertise correctly to my receiver
(tried dts-hdma and dolby trued hd).


But the sound is even more "garbled" in those format than previous ones.
Where a "stress -m2" was enough high cpu load to get a good sound, it now improves the garbling, but not enough anymore.


So It is better, HBR formats are now passing by, yeay! :)


But bug https://bugzilla.kernel.org/show_bug.cgi?id=86351 is still killing my sound.
Comment 34 Harry Wentland 2018-03-07 18:53:34 UTC
Created attachment 137870 [details] [review]
[PATCH] Add one to EDID's audio channel count when passing to DC

Thanks everyone for the debug on this one and especially Andrew for the patch.

DC seems to take channel_count/audio_count to refer to the actual number of channels whereas the CEA EDID extension and our HW represent it as the number of channels-1. So as not to break other uses of this count (such as check_audio_bandwidth_hdmi()) this patch adds 1 when we get the count from the EDID.

Can someone give it a spin? It's based on the latest amd-staging-drm-next branch but should apply on other branches as well.
Comment 35 Direx 2018-03-07 19:23:57 UTC
(In reply to Harry Wentland from comment #34)
> DC seems to take channel_count/audio_count to refer to the actual number of
> channels whereas the CEA EDID extension and our HW represent it as the
> number of channels-1. So as not to break other uses of this count (such as
> check_audio_bandwidth_hdmi()) this patch adds 1 when we get the count from
> the EDID.
> 
> Can someone give it a spin? It's based on the latest amd-staging-drm-next
> branch but should apply on other branches as well.

Just tested it on a fresh amd-staging-drm-next and it is also working. All audio formats are working correctly. *thumbs up*

Could this be backported to 4.15 / 4.16 as it actually is a simple bug fix?


@lethalwp:

I think your issue is unrelated to this one. I get that too occasionally, but it has nothing to do with the wrong channel count in this bug.
Comment 36 Harry Wentland 2018-03-07 19:40:08 UTC
Thanks, Direx. I'll get it reviewed and intend to get it into 4.16 as well. Will send it to the stable tree as well, where GregKH can pick it up.
Comment 37 Harry Wentland 2018-03-07 19:40:23 UTC
... pick it up for 4.15 is what I meant to say.
Comment 38 Direx 2018-03-07 20:39:42 UTC
Just for the record (it might not surprise you): The patch also works on 4.15, just tested it on the "old" kernel.
Comment 39 Harry Wentland 2018-04-24 19:05:29 UTC
Marking resolved as fix has been in mainline for a while now. If this is still an issue feel free to reopen.
Comment 40 Christophe Viallon 2018-06-26 09:27:44 UTC
Does this patch corrects HBR audio over HDMI for Kavery APU family too ?
Comment 41 Alex Deucher 2018-06-26 14:39:11 UTC
(In reply to Christophe Viallon from comment #40)
> Does this patch corrects HBR audio over HDMI for Kavery APU family too ?

Covers all asics supported by DC.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.