Submit #3026

Patch to enable HDMI audio for Gigabyte Radeon R7 240

Added by davshao over 3 years ago. Updated over 3 years ago.

Target version:
Start date:
Due date:
% Done:


Estimated time:


In a years old thread

amd64 panic snd_hda - hdac_get_capabilities: Invalid corb size (0)

Andriy Gapon suggested the following patches to enable HDMI audio for
an ATI/AMD video card. But at that time the original poster was not
able to actually get the sound device to properly attach.

Well these patches DO work for DragonFly, at least using a custom kernel
starting from master sometime in the last couple of weeks with
radeon audio patches from Linux 4.7.10 (adding radeon_audio.c and radeon_audio.h
and updating everything related).

I startx using xfce4 and a custom version of pkgsrc with mesa 17, xorg server 19.3

# kldload snd_hda

Read the end of dmesg:

[drm] Initialized radeon 2.40.0 20080528
hdac0: <Intel Panther Point HDA Controller> mem 0xf7f10000-0xf7f13fff irq 22 at device 27.0 on pci0
hdac0: link ctrl 0x800
hdac0: disable nosnoop
hdac1: <ATI (0xaab0) HDA Controller> mem 0xf7e60000-0xf7e63fff irq 17 at device 0.1 on pci2
hdac1: link ctrl 0x2800
hdac1: disable nosnoop
hdacc0: <VIA VT1708S_0 HDA CODEC> at cad 0 on hdac0
hdaa0: <VIA VT1708S_0 Audio Function Group> at nid 1 on hdacc0
hdacc1: <ATI R6xx HDA CODEC> at cad 0 on hdac1
hdaa1: <ATI R6xx Audio Function Group> at nid 1 on hdacc1
pcm0: <VIA VT1708S_0 (Analog 7.1+HP/2.0)> at nid 28,34,25,35,29 and 26,30,27 on hdaa0
pcm1: <VIA VT1708S_0 (Digital)> at nid 32 on hdaa0
pcm2: <VIA VT1708S_0 (Rear-panel Digital)> at nid 33 on hdaa0
pcm3: <ATI R6xx (HDMI)> at nid 3 on hdaa1

# sysctl hw.snd.default_unit=3
hw.snd.default_unit: 0 -> 3

fire up firefox, go to youtube and listen to whatever.

The following patches are safer for DragonFly because by default
no sound drivers are loaded. Original poster actually had
kernel crashes because on his version of FreeBSD sound drivers
were automatically loaded. Also there was a claim at the time,
least if the initial value of corb_size was 0, that Linux actually does
do some default assumption of 256.

diff --git a/sys/dev/sound/pci/hda/hdac.c b/sys/dev/sound/pci/hda/hdac.c
index d63843a10f..2178243f88 100644
--- a/sys/dev/sound/pci/hda/hdac.c
+++ b/sys/dev/sound/pci/hda/hdac.c
@@ -488,7 +488,15 @@ hdac_get_capabilities(struct hdac_softc *sc)
else {
device_printf(sc->dev, "%s: Invalid corb size (%x)\n",
__func__, corbsize);
- return (ENXIO);
+ if (1) {
+ device_printf(sc->dev, "Resetting corb size to 256\n");
+ sc->corb_size = 256;
+ corbsize =
+ HDAC_WRITE_1(&sc->mem, HDAC_CORBSIZE, corbsize);
+ }
+ else
+ return (ENXIO);

rirbsize = HDAC_READ_1(&sc->mem, HDAC_RIRBSIZE);
@@ -504,7 +512,15 @@ hdac_get_capabilities(struct hdac_softc *sc)
else {
device_printf(sc->dev, "%s: Invalid rirb size (%x)\n",
__func__, rirbsize);
- return (ENXIO);
+ if (1) {
+ device_printf(sc->dev, "Resetting rirb size to 256\n");
+ sc->rirb_size = 256;
+ rirbsize =
+ HDAC_WRITE_1(&sc->mem, HDAC_RIRBSIZE, rirbsize);
+ }
+ else
+ return (ENXIO);

@@ -1211,6 +1227,8 @@ hdac_attach(device_t dev)
if (result != 0)
goto hdac_attach_fail;

+ hdac_reset(sc, 1);
/* Get Capabilities */
result = hdac_get_capabilities(sc);
if (result != 0)


corbsize.diff (1.31 KB) corbsize.diff davshao, 04/12/2017 06:27 PM



Updated by ftigeot over 3 years ago

  • Status changed from New to Resolved
  • % Done changed from 0 to 100

Pushed today, thanks!

Also available in: Atom PDF