staticint major = CONFIG_SND_MAJOR; int snd_major;
EXPORT_SYMBOL(snd_major);
staticint cards_limit = 1;
MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>");
MODULE_DESCRIPTION("Advanced Linux Sound Architecture driver for soundcards.");
MODULE_LICENSE("GPL");
module_param(major, int, 0444);
MODULE_PARM_DESC(major, "Major # for sound driver.");
module_param(cards_limit, int, 0444);
MODULE_PARM_DESC(cards_limit, "Count of auto-loadable soundcards.");
MODULE_ALIAS_CHARDEV_MAJOR(CONFIG_SND_MAJOR);
/* this one holds the actual max. card number currently available. * as default, it's identical with cards_limit option. when more * modules are loaded manually, this limit number increases, too.
*/ int snd_ecards_limit;
EXPORT_SYMBOL(snd_ecards_limit);
/** * snd_request_card - try to load the card module * @card: the card number * * Tries to load the module "snd-card-X" for the given card number * via request_module. Returns immediately if already loaded.
*/ void snd_request_card(int card)
{ if (snd_card_locked(card)) return; if (card < 0 || card >= cards_limit) return;
request_module("snd-card-%i", card);
}
EXPORT_SYMBOL(snd_request_card);
switch (minor) { case SNDRV_MINOR_SEQUENCER: str = "snd-seq"; break; case SNDRV_MINOR_TIMER: str = "snd-timer"; break; default: return;
}
request_module(str);
}
#endif/* modular kernel */
/** * snd_lookup_minor_data - get user data of a registered device * @minor: the minor number * @type: device type (SNDRV_DEVICE_TYPE_XXX) * * Checks that a minor device with the specified type is registered, and returns * its user data pointer. * * This function increments the reference counter of the card instance * if an associated instance with the given minor number and type is found. * The caller must call snd_card_unref() appropriately later. * * Return: The user data pointer if the specified device is found. %NULL * otherwise.
*/ void *snd_lookup_minor_data(unsignedint minor, int type)
{ struct snd_minor *mreg; void *private_data;
#ifdef CONFIG_SND_DYNAMIC_MINORS staticint snd_find_free_minor(int type, struct snd_card *card, int dev)
{ int minor;
/* static minors for module auto loading */ if (type == SNDRV_DEVICE_TYPE_SEQUENCER) return SNDRV_MINOR_SEQUENCER; if (type == SNDRV_DEVICE_TYPE_TIMER) return SNDRV_MINOR_TIMER;
for (minor = 0; minor < ARRAY_SIZE(snd_minors); ++minor) { /* skip static minors still used for module auto loading */ if (SNDRV_MINOR_DEVICE(minor) == SNDRV_MINOR_CONTROL) continue; if (minor == SNDRV_MINOR_SEQUENCER ||
minor == SNDRV_MINOR_TIMER) continue; if (!snd_minors[minor]) return minor;
} return -EBUSY;
} #else staticint snd_find_free_minor(int type, struct snd_card *card, int dev)
{ int minor;
switch (type) { case SNDRV_DEVICE_TYPE_SEQUENCER: case SNDRV_DEVICE_TYPE_TIMER:
minor = type; break; case SNDRV_DEVICE_TYPE_CONTROL: if (snd_BUG_ON(!card)) return -EINVAL;
minor = SNDRV_MINOR(card->number, type); break; case SNDRV_DEVICE_TYPE_HWDEP: case SNDRV_DEVICE_TYPE_RAWMIDI: case SNDRV_DEVICE_TYPE_PCM_PLAYBACK: case SNDRV_DEVICE_TYPE_PCM_CAPTURE: case SNDRV_DEVICE_TYPE_COMPRESS: if (snd_BUG_ON(!card)) return -EINVAL;
minor = SNDRV_MINOR(card->number, type + dev); break; default: return -EINVAL;
} if (snd_BUG_ON(minor < 0 || minor >= SNDRV_OS_MINORS)) return -EINVAL; if (snd_minors[minor]) return -EBUSY; return minor;
} #endif
/** * snd_register_device - Register the ALSA device file for the card * @type: the device type, SNDRV_DEVICE_TYPE_XXX * @card: the card instance * @dev: the device index * @f_ops: the file operations * @private_data: user pointer for f_ops->open() * @device: the device to register * * Registers an ALSA device file for the given card. * The operators have to be set in reg parameter. * * Return: Zero if successful, or a negative error code on failure.
*/ int snd_register_device(int type, struct snd_card *card, int dev, conststruct file_operations *f_ops, void *private_data, struct device *device)
{ int minor; int err = 0; struct snd_minor *preg;
/** * snd_unregister_device - unregister the device on the given card * @dev: the device instance * * Unregisters the device file already registered via * snd_register_device(). * * Return: Zero if successful, or a negative error code on failure.
*/ int snd_unregister_device(struct device *dev)
{ int minor; struct snd_minor *preg;
guard(mutex)(&sound_mutex); for (minor = 0; minor < ARRAY_SIZE(snd_minors); ++minor) {
preg = snd_minors[minor]; if (preg && preg->dev == dev) {
snd_minors[minor] = NULL;
device_del(dev);
kfree(preg); break;
}
} if (minor >= ARRAY_SIZE(snd_minors)) return -ENOENT; return 0;
}
EXPORT_SYMBOL(snd_unregister_device);
#ifdef CONFIG_SND_PROC_FS /* * INFO PART
*/ staticconstchar *snd_device_type_name(int type)
{ switch (type) { case SNDRV_DEVICE_TYPE_CONTROL: return"control"; case SNDRV_DEVICE_TYPE_HWDEP: return"hardware dependent"; case SNDRV_DEVICE_TYPE_RAWMIDI: return"raw midi"; case SNDRV_DEVICE_TYPE_PCM_PLAYBACK: return"digital audio playback"; case SNDRV_DEVICE_TYPE_PCM_CAPTURE: return"digital audio capture"; case SNDRV_DEVICE_TYPE_SEQUENCER: return"sequencer"; case SNDRV_DEVICE_TYPE_TIMER: return"timer"; case SNDRV_DEVICE_TYPE_COMPRESS: return"compress"; default: return"?";
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.