All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: max SNDRV_CARDS bug ? questions ....
  2003-12-03 19:00 max SNDRV_CARDS bug ? questions Benno Senoner
@ 2003-12-03 13:05 ` Takashi Iwai
  2003-12-03 22:25   ` Max # of cards, pcm devices, midi devices Was: " Benno Senoner
  0 siblings, 1 reply; 3+ messages in thread
From: Takashi Iwai @ 2003-12-03 13:05 UTC (permalink / raw)
  To: Benno Senoner; +Cc: alsa-devel

At Wed, 03 Dec 2003 20:00:05 +0100,
Benno Senoner wrote:
> 
> Hi,
> (I'm using alsa-driver-1.0.0rc1)
> 
> I have a question about the SNDRV_CARDS.
> normally it is defined as 8
> ./alsa-kernel/core/memalloc.c: #define SNDRV_CARDS     8
> 
> Does that mean we can have a maximum of 8 soundcards
> in the PC or is this simply how many instances a certain module supports ?
> (eg I could have 8 emu10k instances, 8 sb16 instances etc ?).

no, totally 8 instances.  not the number of modules.

> Plus I noticed something in
> 
> ./alsa-kernel/core/memalloc.c: static int enable[8] = {[0 ... 
> (SNDRV_CARDS-1)] = 1};
> 
> shouldn't that be:
> static int enable[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)] = 1};     ?

yes, but not a bug as long as SNDRV_CARDS = 8 :)

> is this a bug ? what happens if we set SNDRV_CARDS to a value > 8 ?

more than 8 cards are not supported in the current assignment of
devices.  the minor devices will be out of range.


Takashi


-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
Does SourceForge.net help you be more productive?  Does it
help you create better code?  SHARE THE LOVE, and help us help
YOU!  Click Here: http://sourceforge.net/donate/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* max SNDRV_CARDS bug ? questions ....
@ 2003-12-03 19:00 Benno Senoner
  2003-12-03 13:05 ` Takashi Iwai
  0 siblings, 1 reply; 3+ messages in thread
From: Benno Senoner @ 2003-12-03 19:00 UTC (permalink / raw)
  To: alsa-devel

Hi,
(I'm using alsa-driver-1.0.0rc1)

I have a question about the SNDRV_CARDS.
normally it is defined as 8
./alsa-kernel/core/memalloc.c: #define SNDRV_CARDS     8

Does that mean we can have a maximum of 8 soundcards
in the PC or is this simply how many instances a certain module supports ?
(eg I could have 8 emu10k instances, 8 sb16 instances etc ?).

Plus I noticed something in

./alsa-kernel/core/memalloc.c: static int enable[8] = {[0 ... 
(SNDRV_CARDS-1)] = 1};

shouldn't that be:
static int enable[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)] = 1};     ?

is this a bug ? what happens if we set SNDRV_CARDS to a value > 8 ?
Does this generate memory corruption problems ?
(keep in mind I'm not familiar with the alsa-driver sourcebase so I 
could say nonsense)

I grepped the entire source for 'enable[' and the only place where I 
found enable[8] was
in the ./alsa-kernel/core/memalloc.c file.

Basically the reason why I wrote this mail is to ask if I can use more than
8 snd-serialmidi devices.
Takashi gave me the module parameter options to make it work.
(BTWthanks Takashi ! :-) )

options snd-serialmidi enable=1,1,1,1 
sdev=/dev/ttyS2,/dev/ttyS3,/dev/ttyS4,/dev/ttyS5

but if you look at the drivers/serialmidi.c source
....
static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE;static char 
*sdev[SNDRV_CARDS] = {"/dev/ttyS0", [1 ... (SNDRV_CARDS - 1)] = ""};
....

all arrays are of size SNDRV_CARDS this means that I can have max 8 
serial devices.
So what do you suggest to allow for example 12 serial midi devices ? 
(via multi port serial card).
just set SNDRV_CARDS to 12 and fix the enable[8] statement in memalloc.c ?

Or should I simply use a local SNDRV_CARDS in serialmidi.c ? (eg #define 
SERIAL_SNDRV_CARDS 12) ?
(the latter is a hack so I guess it's more convenient to change the 
global SNDRV_CARDS define  right ?).

I posted this mail just to be sure that alsa does not becomes unstable 
or something breaks because of the
define change.

Let me know please.

thanks,
Benno
http://www.linuxsampler.org






-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
Does SourceForge.net help you be more productive?  Does it
help you create better code?  SHARE THE LOVE, and help us help
YOU!  Click Here: http://sourceforge.net/donate/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Max # of cards, pcm devices, midi devices Was: max SNDRV_CARDS bug ? questions ....
  2003-12-03 13:05 ` Takashi Iwai
@ 2003-12-03 22:25   ` Benno Senoner
  0 siblings, 0 replies; 3+ messages in thread
From: Benno Senoner @ 2003-12-03 22:25 UTC (permalink / raw)
  To: alsa-devel

Takashi Iwai wrote:

>At Wed, 03 Dec 2003 20:00:05 +0100,
>Benno Senoner wrote:
>  
>
>>Hi,
>>(I'm using alsa-driver-1.0.0rc1)
>>
>>I have a question about the SNDRV_CARDS.
>>normally it is defined as 8
>>./alsa-kernel/core/memalloc.c: #define SNDRV_CARDS     8
>>
>>Does that mean we can have a maximum of 8 soundcards
>>in the PC or is this simply how many instances a certain module supports ?
>>(eg I could have 8 emu10k instances, 8 sb16 instances etc ?).
>>    
>>
>
>no, totally 8 instances.  not the number of modules.
>
Please elaborate here:  
does that mean that if I have 3 soundcards (eg. 3 emu10k1 cards) and 6 
snd-serialmidi devices
( = total of 9 "cards"), that this configuration does not work ?


>>Plus I noticed something in
>>
>>./alsa-kernel/core/memalloc.c: static int enable[8] = {[0 ... 
>>(SNDRV_CARDS-1)] = 1};
>>
>>shouldn't that be:
>>static int enable[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)] = 1};     ?
>>    
>>
>
>yes, but not a bug as long as SNDRV_CARDS = 8 :)
>
Then I see no reason not to fix it, or at least place a big FIXME in the 
sources near the
SNDDRV_CARDS definition.
Otherwise when these SNDRV_CARDS limits will be lifted someday developes
will need to fix these nasty fixed array size assumption.

>
>  
>
>>is this a bug ? what happens if we set SNDRV_CARDS to a value > 8 ?
>>    
>>
>
>more than 8 cards are not supported in the current assignment of
>devices.  the minor devices will be out of range.
>
I did look at /dev/snd:

devicename, maj, min

/dev/snd/midiC0D0  116, 8  
/dev/snd/midiC0D1  116, 9
....
/dev/snd/midiC0D7  116,15

/dev/snd/pcmC0D0p 116, 16
/dev/snd/pcmC0D1c  116,25
/dev/snd/pcmC0D1p  116,17
/dev/snd/pcmC0D2c  116,26
...

Is that the minor devices conflict you are refering to ?
I assume the midi serial devices allocate a /dev/snd/midiC0Dx device 
thus only 8 midi ports
per card are allowed.
After midiC0D7 (116,15) comes  pcmC0D0p (116, 16) so there would be no 
room for
midiC0D8, right ?

The question is now: is it possible to change the device major,minor 
number layout to allow
for more /dev/snd/midiCxDy devices (and simultaneously increasing 
SNDRV_CARDS) ?

Is it simply a matter of changing the snddevices script or does 
alsa-driver/alsa-lib make assumptions
about the devicenode numbers thus rendering such modifications useless ?

About the minor number:
I understand it is limited to 1 byte thus has a 0-255 range.
I did look at the snddevices script and it seems that every card uses 32 
minor numbers thus
32 * 8 cards = 256 = full range used.
Even if the script only creates the device nodes for the first 4 cards 
(thus minor numbers 0-127) I assume
you can redefine MAX_CARDS in the script and create the device nodes for 
all 8 cards.

in
./alsa-kernel/include/minors.h  I see:

#define SNDRV_MINOR_DEVICES             32
#define SNDRV_MINOR_CARD(minor)         ((minor) >> 5)
#define SNDRV_MINOR_RAWMIDI             8       /* 8 - 15 */
#define SNDRV_MINOR_RAWMIDIS            8
#define SNDRV_MINOR_PCM_PLAYBACK        16      /* 16 - 23 */
#define SNDRV_MINOR_PCM_CAPTURE         24      /* 24 - 31 */
#define SNDRV_MINOR_PCMS                8


So basically as far as I understand those macros would need to to be 
changed too.
I see PCM_PLAYBACK and PCM_CAPTURE each taking up 8 device nodes each.
Perhaps I could reduce that to 4 thus making room for 2*4=8 more RAWMIDI 
devices ?
(but these are per card so I guess that is the wrong way to go, read below)

The question how many multiple PCM_PLAYBACK devices are usually needed ?
Of course this depends from the card. For example for my CMI8738MC6 card
in /proc/asound I see:  pcm0c, pcm0p, pcm1p, pcm2c, pcm2p
thus 3 devices each for playback and capture.
What happens in the case of the hammerfall where you can have up to 24 
playback channels ?
Is that seen as a single capture/playback device  ? Or cards like the 
delta 1010 ?
Ok the good old Steve Harris just did a cat /proc/asound/ on his 
Hammerfall box for me:
 id, oss_mixer, pcm0c, pcm0p, rme9652
So it means it uses only one pcm device.

But the big doubt is: since Takashi said each snd_serialmidi device 
allocates one of the available
SNDRV_CARDS slots it basically means that we use only one midiCxDy per card.
If I use the module options line Takashi gave me

options snd-serialmidi enable=1,1,1,1 
sdev=/dev/ttyS2,/dev/ttyS3,/dev/ttyS4,/dev/ttyS5

and I do aconnect I get something like
72:0  Serial Midi Device 1  (or was the name Raw Midi ? does not matter 
for explanation purposes).
80:0  Serial Midi Device 2
88:0  ....

So I assume of each "card" only /dev/snd/midiCxD0 is used.
Correct me if I'm wrong.
To make it short, do you think I have a chance to succeed increase 
SNDRV_CARDS to 12-16
(and change the snddevices script and the SNDRV_ macros) ?
Must each card use a power of two (currently 32) of minor device nodes ?
If that is true then the only alternative would be SNDRV_CARDS = 16 but 
that would leave only
16 minor numbers for card which is too little to make fit a few pcm 
devices, rawmidi and the other stuff neded.
Perhaps the ideal tradeoff would be SNDRV_CARDS=12 but that would 
require a per card
minor device number that is not a  power of two.
Ok some macros would become a bit slower eg (assuming 20 minor ids per card)

#define SNDRV_MINOR_CARD(minor)         ((minor)  / 20)

But this is not the end of the world.

Let me know please. I'll share my experiences (problems, failures, 
success etc) here on the mailing list.

thanks,
Benno
http://www.linuxsampler.org




-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
Does SourceForge.net help you be more productive?  Does it
help you create better code?  SHARE THE LOVE, and help us help
YOU!  Click Here: http://sourceforge.net/donate/

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2003-12-03 22:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-12-03 19:00 max SNDRV_CARDS bug ? questions Benno Senoner
2003-12-03 13:05 ` Takashi Iwai
2003-12-03 22:25   ` Max # of cards, pcm devices, midi devices Was: " Benno Senoner

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.