# Multiple soundcards with alsa

## JefP@@

Hey

Got a question about using multiple sound cards with alsa & devfs. I have the 2 modules compiled, changed the /etc/modules.d/alsa config file, to set up for 2 audio cards. But that's not quite doing it  :Sad:   When I try to load the second module, it says there's no device for it ... This is probably related to modules.devfs config, maybe even devfsd.conf ? 

Anyone any ideas on how I should get this working ?

Thx, 

Grtz

----------

## knala

Jeff, I am running Via on-board sound and an AWE32 both through alsa. 

I went through the headaches some time ago, so I am digging into distant memory. 

Are you certain you are not loading any kernel built-in drivers?

I am at work at the moment, I will dig into my configuration files this evening and see if anything there stimulates my memory.

knala

----------

## JefP@@

thx knala

and no, I'm not using builtin kernel drivers. I just put on sound support ...

btw: on my old slackware box, I had 2 soundcards running, with the old alsa drivers, but ofcourse, not with devfs ...

Maybe I should try my second soundcard first, it's an onboard soundcard (should be via686a thing). So gonna try it first ... it would explain a lot if it doesn't work :p

Grtz

----------

## knala

I have the via686 as the first card and the awe as the second.

I have not had any trouble with the via driver, most of my pain has been with the AWE (an old ISA card).

I have just this weekend upgraded from alsa 5.... to alsa 9...

Not completely smoothly, the alsa dirvers are working o.k., but I am having difficulty with oss emulation on the second card. So my offer of help may have been a bit premature 

You say you are getting an error when you try to load the 2nd module?

This is snd-via686? What is the other driver?

----------

## JefP@@

k, I tested both soundcards. They're working now under alsa (the second one via686, wouldn't load, because I forgot to turn on a jumper switch on the mobo ... Should have checked dmesg earlier, I guess, it stated : device not found or in use ... then I suddenly remembered there was a jumper switch on the mainboard  :Razz: )

So now, I have both drivers loaded and appearantly working ok (I set the mixer settings & stored them to /etc/asound.state

my trouble now is, I only have 1 dsp device in /dev and dmesg gives me an error:

devfs_register(unknown): could not append to parent, err: -17

so I guess, I still have to edit some files : devfsd.conf or modules.devfs. I figure only sound-slot-0 is defined in modules.devfs, so maybe I have to add an entry for snd-slot-1 .. and it appears only 1 dsp device can exist ..  so I'll have to change that 2. 

But how  :Wink: 

btw: my first sound card is a Guillemot maxi sound Fortissimo, it uses the snd-ymfpci driver.

Grtz

----------

## knala

Glad to hear you got it going. Now we are both at the same point. Everything was working for me in 0.5xx, but now I only get 1 OSS compatible /dev/dsp.

I am not sure that the "could not append to parent" message is related, I have seen that reported elsewhere (it seems related to "manual" entries in the /dev directory conflicting with devfs and seems generally harmless).

I got it both before and after changing alsa versions.

I guess we will see who gets there first   :Smile: 

knala

----------

## JefP@@

Ok, Knala, I got it working !!!

Here's what my /dev/sound looks like :

```
crw-rw----    1 root     audio     14,  12 Jan  1  1970 adsp

crw-rw----    1 root     audio     14,   4 Jan  1  1970 audio

crw-rw----    1 root     audio     14,  20 Jan  1  1970 audio1

crw-rw----    1 root     audio     14,  10 Jan  1  1970 dmfm

crw-rw----    1 root     audio     14,   9 Jan  1  1970 dmmidi

crw-rw----    1 root     audio     14,  25 Jan  1  1970 dmmidi1

crw-rw----    1 root     audio     14,   3 Jan  1  1970 dsp

crw-rw----    1 root     audio     14,  19 Jan  1  1970 dsp1

crw-rw----    1 root     audio     14,   2 Jan  1  1970 midi

crw-rw----    1 root     audio     14,  18 Jan  1  1970 midi1

crw-rw----    1 root     audio     14,   0 Jan  1  1970 mixer

crw-rw----    1 root     audio     14,  16 Jan  1  1970 mixer1

crw-rw----    1 root     audio     14,   1 Jan  1  1970 sequencer

crw-rw----    1 root     audio     14,   8 Jan  1  1970 sequencer2
```

How I did this, that's a bit tricky. While searching on google, I found an interesting post on the kernel mailing lists. It stated the same problem we had here (also with devfs) and moreover, it contained a patch (for kernel v. 2.4.17). I cp & pasted the patch in a file and tried it on backup copy of my 2.4.18-xfs ... which ofcourse didn't work. So I had to apply the patch by hand. Which I did, and quite succesfully  :Wink: , so it seems. I have 2 devices now (dsp & dsp1) and both soundcards are working. The patch itself only changed a few things in the sound_core.c file. You can download the file  here. I'm using the vanilla kernel v. 2.4.18 patched for xfs support, so that's the version of the sound_core.c file ... It could be, the patch isn't needed anymore in the 2.5.x series, but I duno & I don't intend to use it, because it's a development series.

Here's the original patch I found in the mailing lists :

```
--- linux-2.4.17/drivers/sound/sound_core.c.orig Sun Jan 6 17:31:30 2002

+++ linux-2.4.17/drivers/sound/sound_core.c Sun Jan 6 17:39:43 2002

@@ -17,7 +17,7 @@

* plug into this. The fact they dont all go via OSS doesn't mean

* they don't have to implement the OSS API. There is a lot of logic

* to keeping much of the OSS weight out of the code in a compatibility

- * module, but its up to the driver to rember to load it...

+ * module, but it's up to the driver to remember to load it...

*

* The code provides a set of functions for registration of devices

* by type. This is done rather than providing a single call so that

@@ -173,10 +173,10 @@

return r;

}

- if (r == low)

+ if ( r < SOUND_STEP )

sprintf (name_buf, "%s", name);

else

- sprintf (name_buf, "%s%d", name, (r - low) / SOUND_STEP);

+ sprintf (name_buf, "%s%d", name, (r / SOUND_STEP));

s->de = devfs_register (devfs_handle, name_buf,

DEVFS_FL_NONE, SOUND_MAJOR, s->unit_minor,

S_IFCHR | mode, fops, NULL);

@@ -231,17 +231,20 @@

int register_sound_special(struct file_operations *fops, int unit)

{

- char *name;

+ const int chain = (unit & 0x0F);

+ int max_unit = chain + 128;

+ const char *name;

- switch (unit) {

+ switch (chain) {

case 0:

name = "mixer";

break;

case 1:

name = "sequencer";

+ max_unit = unit + 1;

break;

case 2:

- name = "midi00";

+ name = "midi";

break;

case 3:

name = "dsp";

@@ -260,6 +263,7 @@

break;

case 8:

name = "sequencer2";

+ max_unit = unit + 1;

break;

case 9:

name = "dmmidi";

@@ -280,10 +284,10 @@

name = "admmidi";

break;

default:

- name = "unknown";

+ name = "unknownX";

break;

}

- return sound_insert_unit(&chains[unit&15], fops, -1, unit, unit+1,

+ return sound_insert_unit(&chains[chain], fops, -1, unit, max_unit,

name, S_IRUSR | S_IWUSR);

}
```

k, hope that does it for you Knala, it did for me, so I wouldn't see why not ...

Grtz (this has been quite an enlightening discussion, thx for the help  :Wink:  )

----------

## knala

Thanks for the great info, I will look into that this evening. 

I  eventually have managed to get my /dev/dsp1 working by creating it manually. Not an elegant solution and not getting to the core problem, like yours, but it works for what I want.

knala

----------

## JefP@@

hehe, lol

it's a different approach, but I'm sure it works too.

Not realy good if you want to keep everything nice & clean  :Razz: 

Grtz

btw: would it be possible to fake 4 speaker support using 2 soundblasters ? To let the audio, destined for the front speakers go through 1 card, and the other stream through the other... lol would be nice   :Twisted Evil:  (emulate dolby surround with 2 soundcards)

----------

## knala

Hmm.. I have been running the gentoo patched kernel (2.4.19-gentoo-r5). The diff between that sound_core.c and the one you posted (for 2.4.18?) is fairly small. 

I won't get time to check it out till next weekend though. 

A brief look through the diff doesn't reveal anything that looks likely to break just using that file with the remainder of the gentoo kernel.. though I am not a kernel expert! (IANAKE?)

As for 4 speaker surround... seems do-able. A GPL Dolby decoder could be problematic though  :Sad: 

Thanks again for your good info.

knala

----------

## knala

OK, checked it out. It works for me too. Have you submitted this as a patch to gentoo? Or perhaps an entry in the "Tips & Tricks" forum. 

If there is effort required I am happy to assist, although my main available time is limited to the weekends.

knala

----------

## JefP@@

No I haven't ...

You said there was a sound patch applied to the 2.4.19-gentoo-r5 sources, similar to mine ... did that do the trick, or did you use my patch ?

anyways, duno anything about diffs etc. Maybe my brother does  :Razz: , he has a lot more experience in these matters  :Wink:  And unfortunately my time is limited too... those damned exams ... Another 3 weeks left *sigh* 

Grtz

----------

## knala

No, I ran a diff between your posted file and the sound_core.c source in the 2.4.19-gentoo-r5 tree. The difference showed that I could just use your posted file as is, since the only differences were in the enumeration.

Good luck with the exams. Are you taking or marking?

knala

----------

## idave

Good news: https://bugs.gentoo.org/show_bug.cgi?id=30837

----------

## knala

 :Embarassed:   I forgot to submit this as a bug. I only noticed this weekend when it bit me again.

knala

----------

