23 #include <linux/slab.h>
24 #include <linux/time.h>
25 #include <linux/device.h>
26 #include <linux/module.h>
39 static int cards_limit = 1;
73 if (card < 0 || card >= cards_limit)
75 request_module(
"snd-card-%i", card);
80 static void snd_request_other(
int minor)
114 mreg = snd_minors[minor];
115 if (mreg && mreg->
type == type) {
127 #ifdef CONFIG_MODULES
140 snd_request_other(minor);
143 return snd_minors[minor];
146 #define autoload_device(minor) NULL
151 unsigned int minor = iminor(inode);
159 mptr = snd_minors[minor];
167 old_fops = file->
f_op;
170 file->
f_op = old_fops;
177 if (file->
f_op->open) {
178 err = file->
f_op->open(inode, file);
195 #ifdef CONFIG_SND_DYNAMIC_MINORS
196 static int snd_find_free_minor(
int type)
206 for (minor = 0; minor <
ARRAY_SIZE(snd_minors); ++minor) {
213 if (!snd_minors[minor])
219 static int snd_kernel_minor(
int type,
struct snd_card *card,
int dev)
286 #ifdef CONFIG_SND_DYNAMIC_MINORS
287 minor = snd_find_free_minor(type);
289 minor = snd_kernel_minor(type, card, dev);
290 if (minor >= 0 && snd_minors[minor])
298 snd_minors[minor] = preg;
300 private_data,
"%s", name);
301 if (IS_ERR(preg->
dev)) {
302 snd_minors[minor] =
NULL;
304 minor = PTR_ERR(preg->
dev);
318 static int find_snd_minor(
int type,
struct snd_card *card,
int dev)
323 cardnum = card ? card->
number : -1;
324 for (minor = 0; minor <
ARRAY_SIZE(snd_minors); ++minor)
325 if ((mptr = snd_minors[minor]) !=
NULL &&
326 mptr->
type == type &&
327 mptr->
card == cardnum &&
349 minor = find_snd_minor(type, card, dev);
357 kfree(snd_minors[minor]);
358 snd_minors[minor] =
NULL;
372 minor = find_snd_minor(type, card, dev);
373 if (minor >= 0 && (d = snd_minors[minor]->dev) !=
NULL)
382 #ifdef CONFIG_PROC_FS
389 static const char *snd_device_type_name(
int type)
395 return "hardware dependent";
399 return "digital audio playback";
401 return "digital audio capture";
418 if (!(mptr = snd_minors[minor]))
420 if (mptr->
card >= 0) {
422 snd_iprintf(buffer,
"%3i: [%2i-%2i]: %s\n",
424 snd_device_type_name(mptr->
type));
426 snd_iprintf(buffer,
"%3i: [%2i] : %s\n",
428 snd_device_type_name(mptr->
type));
430 snd_iprintf(buffer,
"%3i: : %s\n", minor,
431 snd_device_type_name(mptr->
type));
442 entry->
c.
text.read = snd_minor_info_read;
443 if (snd_info_register(entry) < 0) {
444 snd_info_free_entry(entry);
448 snd_minor_info_entry =
entry;
454 snd_info_free_entry(snd_minor_info_entry);
463 static int __init alsa_sound_init(
void)
467 if (register_chrdev(major,
"alsa", &snd_fops)) {
471 if (snd_info_init() < 0) {
472 unregister_chrdev(major,
"alsa");
477 printk(
KERN_INFO "Advanced Linux Sound Architecture Driver Initialized.\n");
482 static void __exit alsa_sound_exit(
void)
486 unregister_chrdev(major,
"alsa");