Commit 287b1242 authored by Jaroslav Kysela's avatar Jaroslav Kysela

[ALSA] Interpret negative index as bitmask of permissible indexes

Documentation,ALSA Core
Currently arguments of the 'index' option from 0 through SNDRV_CARDS-1
force a module to take the specified index. Index -1 makes the module
take the first available index. This patch extends this convention so
that a negative index value is interpreted as a bitmask of the
permitted indexes. Special cases:

    -1 0xffffffff 0 and up
    -2 0xfffffffe 1 and up
    -4 0xfffffffc 2 and up
    ...

The patch includes also corrections of ALSA-Configuration.txt document.
Signed-off-by: default avatarThomas Hood <jdthood@yahoo.co.uk>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 7d426895
...@@ -84,16 +84,13 @@ snd_card_t *snd_card_new(int idx, const char *xid, ...@@ -84,16 +84,13 @@ snd_card_t *snd_card_new(int idx, const char *xid,
write_lock(&snd_card_rwlock); write_lock(&snd_card_rwlock);
if (idx < 0) { if (idx < 0) {
int idx2; int idx2;
for (idx2 = 0; idx2 < snd_ecards_limit; idx2++) for (idx2 = 0; idx2 < SNDRV_CARDS; idx2++)
if (!(snd_cards_lock & (1 << idx2))) { if (~snd_cards_lock & idx & 1<<idx2) {
idx = idx2; idx = idx2;
if (idx >= snd_ecards_limit)
snd_ecards_limit = idx + 1;
break; break;
} }
if (idx < 0 && snd_ecards_limit < SNDRV_CARDS)
/* for dynamically additional devices like hotplug:
* increment the limit if still free slot exists.
*/
idx = snd_ecards_limit++;
} else if (idx < snd_ecards_limit) { } else if (idx < snd_ecards_limit) {
if (snd_cards_lock & (1 << idx)) if (snd_cards_lock & (1 << idx))
err = -ENODEV; /* invalid */ err = -ENODEV; /* invalid */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment