# intel-hda sometimes fails to load (Workaround included)

## hede

Sometimes alsa didn't recognize my soundcard. it's an intel hda codec, realtek ALC880.

But if I compile intel-hda as a module, I can unload and reload it and mostly the second time it gets recognized.

So I've written a patch for /etc/init.d/alsasound which does this unloading and reloading automatically if it fails.

It is especial for my sound card and needs customisation for every other one.

In my case it recognizes the string "line_outs=4" in dmesg, which is only there if the card is successfully detected.

Other cards may have other strings to detect this.

This is just a proof of concept and some kind of a "hint" for those who are having the same problem

```
--- alsasound-ori   2007-05-23 14:32:24.000000000 +0200

+++ alsasound   2007-05-23 14:30:09.000000000 +0200

@@ -13,6 +13,39 @@

    after bootmisc modules isapnp coldplug hotplug

 }

 

+modprobe_module() {

+  #echo Start: >> /var/log/alsaworkaround

+  echo -n `date`: >> /var/log/alsaworkaround

+  #date >> /var/log/alsaworkaround

+  test -z $1 && { 

+    echo " Error in modprobe_module" >> /var/log/alsaworkaround 

+    ebegin "   Error in modprobe_module" 

+    return 1

+  }

+  for ((i=1;i<=5;i++))

+  do

+    #MODOUT="$(modprobe $1)"

+    ebegin "   Modprobe $1 try $i"

+    modprobe $1

+    #unfortunately there is no error if it fails :-(

+    #so we have to parse dmesg, insert your "successful message"

+    #dmesg | grep speaker_outs > /dev/null

+    dmesg | grep "line_outs=4" > /dev/null

+    test $? -eq 0 && {

+      echo " Try $i successful"  >> /var/log/alsaworkaround

+      ebegin "   Try $i successful"

+      return

+    }

+    if [ $i -lt 5 ]

+    then

+      #/sbin/rmmod $1

+      /sbin/rmmod $(cat /etc/modules.conf | grep "^alias $1" | awk '{ print $3 }') 

+    fi

+  done

+  echo " Not successful after 5 trys" >> /var/log/alsaworkaround

+  ebegin "   Not successful after 5 trys"

+}

+

 load_modules() {

    # List of drivers for each card.

    local DRIVERS="$(modprobe -c | sed -n -e 's/^alias \(snd-card-[[:digit:]]\+\) .*/\1/p')"

@@ -45,7 +78,8 @@

       DMOD="$(echo "${DRIVER}" | sed -e 's/-/_/g')"

       if ! grep -q "^${DMOD} " /proc/modules ; then

          ebegin "Loading: ${DRIVER}"

-         modprobe ${DRIVER}

+         #modprobe ${DRIVER}

+                        modprobe_module ${DRIVER}

          eend $?

       fi

    done
```

----------

## jsfan

I reckon this is something that has very much to do with your hardware.

I'm also using the hda-intel driver but on genuine Intel hardware (82801G)

and have never had this problem.

Any other chipsets that have the problem described above?

----------

## hede

Before I've written this workaround I've googled for a solution and found many peaple describing this error (also some errors in dmesg were the same).

So I think it's a common problem. I'm using this workaround for some months now and it works like a charm.

I did not have any erroneous dmesg-output for now, but I will post it next time my soundcard needs more than one try to get detected (if I remember) for all of those googling for a solution...

btw: I'm also using genuine Intel hardware (82801FB/FBM/FR/FW/FRW (ICH6 Family) High Definition Audio Controller). Try getting your real codec with e.g. "cat /proc/asound/pcm"

----------

## jsfan

Sorry about the "genuine Intel" confusion. I'm not big in sound cards.

cat /proc/asound/pcm gives me

```
00-06: Si3054 Modem : Si3054 Modem : playback 1 : capture 1

00-00: AD198x Analog : AD198x Analog : playback 1 : capture 1

```

As I mentioned before. I don't have the problems you described. It

therefore seems to be related to certain chipsets.

However, I'm not sure if I can meanwhile play audio CDs. For long time that

did not work for me. But I haven't tried in a few months...

----------

## hede

 *jsfan wrote:*   

> As I mentioned before. I don't have the problems you described. It
> 
> therefore seems to be related to certain chipsets.

 

Oh, maybe that was my fault. I'm sure it's related to some special board layout. Did I forgot to mention that?  :Rolling Eyes: 

----------

