Too many sounds cards

Following the re-alignment of the computers in the hydrus network, I figured I would transfer myself to the fastest machine, tugg, which has an AMD 2GHz, 2 core processor and 500GB of disk. Given that the Windows 7 RC2 candidate had been released, it seemed a good time to check the latest version of Windows out on the only box that would support it properly. However, I had to verify that both it, and Debian Lenny, would work on the tugg hardware.

While Debian worked well, graphically and sound-wise, the Windows 7 system had one significant problem. When logging out, or when the screensaver was initiated, or indeed any graphics change, the video display would go crazy. It was possible to regain a good display by swapping the monitor cable between the two ports on the card (a Nvidia 7900GT 256MB), but something was obviously awry. The problem did not manifest itself on Windows XP, so I figured that something in the Windows 7 Nvidia driver was provoking an error on the graphics card. The card had previously (under XP) shown itself to be a little strange as at one time, it had refused to show any graphics at all, until swapped to an alternative slot in the PC. Time for a new card, preferably ATI, so if it were some Nvidia problem I would not encounter it again.

I bought an ATI Radeon 4670HD, since this was also supported on Debian, albeit with a proprietary ATI Xorg driver. It worked perfectly under Windows 7, as it also did under Windows XP and Debian Lenny. However, I found that the sound on Debian no longer worked. The sound before had been provided by an AC'97 capability on the MSI K8N motherboard.

I first noticed that sound was broken when my /etc/rc.local script, which ensures that the mixer sound levels are raised, failed. On investigation, the output of aplay -L was:

  default:CARD=HDMI
    HDA ATI HDMI
    Default Audio Device
  front:CARD=HDMI
    HDA ATI HDMI
    Front speakers
  surround40:CARD=HDMI
    HDA ATI HDMI
    4.0 Surround output to Front and Rear speakers
  surround41:CARD=HDMI
    HDA ATI HDMI
    4.1 Surround output to Front, Rear and Subwoofer speakers
  surround50:CARD=HDMI
    HDA ATI HDMI
    5.0 Surround output to Front, Center and Rear speakers
  surround51:CARD=HDMI
    HDA ATI HDMI
    5.1 Surround output to Front, Center, Rear and Subwoofer speakers
  surround71:CARD=HDMI
    HDA ATI HDMI
    7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
  iec958:CARD=HDMI
    HDA ATI HDMI
    IEC958 (S/PDIF) Digital Audio Output
  null
    Discard all samples (playback) or generate zero samples (capture)

Hmm, where did the AC'97 sound card go? I noticed in dmesg the following:

  cannot find the slot for index 0 (range 0-0), error: -16
  Intel ICH: probe of 0000:00:04.0 failed with error -12

Googling for this error returned (and/or led to) the following pages:

redhat alsa FAQ alsa FAQ this

Digesting these lead me to believe that I had a race on the motherboard, which caused alsa to recognise the HDMI capability in the new ATI card before the AC'97 card (aka CK804). If I ran alsaconf following the boot, I could have the AC'97 facility recognised and I had sound. However, the next time I booted, I lost sound again. Not wishing to run alsaconf after every boot, I thought some more.

The links above seemed to indicate that an index was set incorrectly by alsaconf. Indeed, the /etc/modprobe.d/sound file contained the following:

  alias snd-card-0 snd-intel8x0
  options snd-intel8x0 index 0

So, first I removed the options snd-intel8x0 index 0 line and rebooted. Things looked better (no Intel ICh probe errors), but still no sound. aplay -L returned:

  default:CARD=HDMI
    HDA ATI HDMI
    Default Audio Device
  front:CARD=HDMI
    HDA ATI HDMI
    Front speakers
  surround40:CARD=HDMI
    HDA ATI HDMI
    4.0 Surround output to Front and Rear speakers
  surround41:CARD=HDMI
    HDA ATI HDMI
    4.1 Surround output to Front, Rear and Subwoofer speakers
  surround50:CARD=HDMI
    HDA ATI HDMI
    5.0 Surround output to Front, Center and Rear speakers
  surround51:CARD=HDMI
    HDA ATI HDMI
    5.1 Surround output to Front, Center, Rear and Subwoofer speakers
  surround71:CARD=HDMI
    HDA ATI HDMI
    7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
  iec958:CARD=HDMI
    HDA ATI HDMI
    IEC958 (S/PDIF) Digital Audio Output
  null
    Discard all samples (playback) or generate zero samples (capture)
  default:CARD=CK804
    NVidia CK804, NVidia CK804
    Default Audio Device
  front:CARD=CK804,DEV=0
    NVidia CK804, NVidia CK804
    Front speakers
  surround40:CARD=CK804,DEV=0
    NVidia CK804, NVidia CK804
    4.0 Surround output to Front and Rear speakers
  surround41:CARD=CK804,DEV=0
    NVidia CK804, NVidia CK804
    4.1 Surround output to Front, Rear and Subwoofer speakers
  surround50:CARD=CK804,DEV=0
    NVidia CK804, NVidia CK804
    5.0 Surround output to Front, Center and Rear speakers
  surround51:CARD=CK804,DEV=0
    NVidia CK804, NVidia CK804
    5.1 Surround output to Front, Center, Rear and Subwoofer speakers

The HDMI card was being detected first. OK, the next step was to get alsa to ignore the HDMI card. I added the following line to /etc/modprobe.d/alsa-base-blacklist:

  blacklist snd-hda-intel

snd-hda-intel is the driver invoked for the ATI card sound capability.

At last, sound returned.