struct snd_minor {
struct list_head list; /* list of all minors per card */
int number; /* minor number */
+ int type; /* SNDRV_DEVICE_TYPE_XXX */
int device; /* device number */
- const char *comment; /* for /proc/asound/devices */
struct file_operations *f_ops; /* file operations */
char name[0]; /* device name (keep at the end of
structure) */
void snd_request_card(int card);
-int snd_register_device(int type, struct snd_card *card, int dev, struct snd_minor *reg, const char *name);
+int snd_register_device(int type, struct snd_card *card, int dev,
+ struct file_operations *f_ops, const char *name);
int snd_unregister_device(int type, struct snd_card *card, int dev);
#ifdef CONFIG_SND_OSSEMUL
-int snd_register_oss_device(int type, struct snd_card *card, int dev, struct snd_minor *reg, const char *name);
+int snd_register_oss_device(int type, struct snd_card *card, int dev,
+ struct file_operations *f_ops, const char *name);
int snd_unregister_oss_device(int type, struct snd_card *card, int dev);
#endif
struct snd_pcm_oss_stream oss;
#endif
struct snd_pcm_file *files;
- struct snd_minor *reg;
struct snd_info_entry *proc_root;
struct snd_info_entry *proc_info_entry;
#ifdef CONFIG_SND_DEBUG
*/
extern struct snd_pcm *snd_pcm_devices[];
-extern struct snd_minor snd_pcm_reg[2];
+extern struct file_operations snd_pcm_f_ops[2];
int snd_pcm_new(struct snd_card *card, char *id, int device,
int playback_count, int capture_count,
.fasync = snd_ctl_fasync,
};
-static struct snd_minor snd_ctl_reg =
-{
- .comment = "ctl",
- .f_ops = &snd_ctl_f_ops,
-};
-
/*
* registration of the control device
*/
snd_assert(cardnum >= 0 && cardnum < SNDRV_CARDS, return -ENXIO);
sprintf(name, "controlC%i", cardnum);
if ((err = snd_register_device(SNDRV_DEVICE_TYPE_CONTROL,
- card, 0, &snd_ctl_reg, name)) < 0)
+ card, -1, &snd_ctl_f_ops, name)) < 0)
return err;
return 0;
}
snd_assert(card != NULL, return -ENXIO);
cardnum = card->number;
snd_assert(cardnum >= 0 && cardnum < SNDRV_CARDS, return -ENXIO);
- if ((err = snd_unregister_device(SNDRV_DEVICE_TYPE_CONTROL, card, 0)) < 0)
+ if ((err = snd_unregister_device(SNDRV_DEVICE_TYPE_CONTROL,
+ card, -1)) < 0)
return err;
return snd_ctl_dev_free(device);
}
.mmap = snd_hwdep_mmap,
};
-static struct snd_minor snd_hwdep_reg =
-{
- .comment = "hardware dependent",
- .f_ops = &snd_hwdep_f_ops,
-};
-
/**
* snd_hwdep_new - create a new hwdep instance
* @card: the card instance
sprintf(name, "hwC%iD%i", hwdep->card->number, hwdep->device);
if ((err = snd_register_device(SNDRV_DEVICE_TYPE_HWDEP,
hwdep->card, hwdep->device,
- &snd_hwdep_reg, name)) < 0) {
+ &snd_hwdep_f_ops, name)) < 0) {
snd_printk(KERN_ERR "unable to register hardware dependent device %i:%i\n",
hwdep->card->number, hwdep->device);
snd_hwdep_devices[idx] = NULL;
} else {
if (snd_register_oss_device(hwdep->oss_type,
hwdep->card, hwdep->device,
- &snd_hwdep_reg, hwdep->oss_dev) < 0) {
+ &snd_hwdep_f_ops,
+ hwdep->oss_dev) < 0) {
snd_printk(KERN_ERR "unable to register OSS compatibility device %i:%i\n",
hwdep->card->number, hwdep->device);
} else
.compat_ioctl = snd_mixer_oss_ioctl_compat,
};
-static struct snd_minor snd_mixer_oss_reg =
-{
- .comment = "mixer",
- .f_ops = &snd_mixer_oss_f_ops,
-};
-
/*
* utilities
*/
sprintf(name, "mixer%i%i", card->number, 0);
if ((err = snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_MIXER,
card, 0,
- &snd_mixer_oss_reg,
+ &snd_mixer_oss_f_ops,
name)) < 0) {
snd_printk(KERN_ERR "unable to register OSS mixer device %i:%i\n",
card->number, 0);
.mmap = snd_pcm_oss_mmap,
};
-static struct snd_minor snd_pcm_oss_reg =
-{
- .comment = "digital audio",
- .f_ops = &snd_pcm_oss_f_reg,
-};
-
static void register_oss_dsp(struct snd_pcm *pcm, int index)
{
char name[128];
sprintf(name, "dsp%i%i", pcm->card->number, pcm->device);
if (snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_PCM,
- pcm->card, index, &snd_pcm_oss_reg,
+ pcm->card, index, &snd_pcm_oss_f_reg,
name) < 0) {
snd_printk(KERN_ERR "unable to register OSS PCM device %i:%i\n",
pcm->card->number, pcm->device);
pstr->stream = stream;
pstr->pcm = pcm;
pstr->substream_count = substream_count;
- pstr->reg = &snd_pcm_reg[stream];
if (substream_count > 0) {
err = snd_pcm_stream_proc_init(pstr);
if (err < 0) {
devtype = SNDRV_DEVICE_TYPE_PCM_CAPTURE;
break;
}
- if ((err = snd_register_device(devtype, pcm->card, pcm->device, pcm->streams[cidx].reg, str)) < 0) {
+ if ((err = snd_register_device(devtype, pcm->card,
+ pcm->device,
+ &snd_pcm_f_ops[cidx], str)) < 0)
+ {
snd_pcm_devices[idx] = NULL;
up(®ister_mutex);
return err;
* Register section
*/
-static struct file_operations snd_pcm_f_ops_playback = {
- .owner = THIS_MODULE,
- .write = snd_pcm_write,
- .writev = snd_pcm_writev,
- .open = snd_pcm_open,
- .release = snd_pcm_release,
- .poll = snd_pcm_playback_poll,
- .unlocked_ioctl = snd_pcm_playback_ioctl,
- .compat_ioctl = snd_pcm_ioctl_compat,
- .mmap = snd_pcm_mmap,
- .fasync = snd_pcm_fasync,
-};
-
-static struct file_operations snd_pcm_f_ops_capture = {
- .owner = THIS_MODULE,
- .read = snd_pcm_read,
- .readv = snd_pcm_readv,
- .open = snd_pcm_open,
- .release = snd_pcm_release,
- .poll = snd_pcm_capture_poll,
- .unlocked_ioctl = snd_pcm_capture_ioctl,
- .compat_ioctl = snd_pcm_ioctl_compat,
- .mmap = snd_pcm_mmap,
- .fasync = snd_pcm_fasync,
-};
-
-struct snd_minor snd_pcm_reg[2] =
-{
+struct file_operations snd_pcm_f_ops[2] = {
{
- .comment = "digital audio playback",
- .f_ops = &snd_pcm_f_ops_playback,
+ .owner = THIS_MODULE,
+ .write = snd_pcm_write,
+ .writev = snd_pcm_writev,
+ .open = snd_pcm_open,
+ .release = snd_pcm_release,
+ .poll = snd_pcm_playback_poll,
+ .unlocked_ioctl = snd_pcm_playback_ioctl,
+ .compat_ioctl = snd_pcm_ioctl_compat,
+ .mmap = snd_pcm_mmap,
+ .fasync = snd_pcm_fasync,
},
{
- .comment = "digital audio capture",
- .f_ops = &snd_pcm_f_ops_capture,
+ .owner = THIS_MODULE,
+ .read = snd_pcm_read,
+ .readv = snd_pcm_readv,
+ .open = snd_pcm_open,
+ .release = snd_pcm_release,
+ .poll = snd_pcm_capture_poll,
+ .unlocked_ioctl = snd_pcm_capture_ioctl,
+ .compat_ioctl = snd_pcm_ioctl_compat,
+ .mmap = snd_pcm_mmap,
+ .fasync = snd_pcm_fasync,
}
};
.compat_ioctl = snd_rawmidi_ioctl_compat,
};
-static struct snd_minor snd_rawmidi_reg =
-{
- .comment = "raw midi",
- .f_ops = &snd_rawmidi_f_ops,
-};
-
static int snd_rawmidi_alloc_substreams(struct snd_rawmidi *rmidi,
struct snd_rawmidi_str *stream,
int direction,
sprintf(name, "midiC%iD%i", rmidi->card->number, rmidi->device);
if ((err = snd_register_device(SNDRV_DEVICE_TYPE_RAWMIDI,
rmidi->card, rmidi->device,
- &snd_rawmidi_reg, name)) < 0) {
+ &snd_rawmidi_f_ops, name)) < 0) {
snd_printk(KERN_ERR "unable to register rawmidi device %i:%i\n", rmidi->card->number, rmidi->device);
snd_rawmidi_devices[idx] = NULL;
up(®ister_mutex);
rmidi->ossreg = 0;
if ((int)rmidi->device == midi_map[rmidi->card->number]) {
if (snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_MIDI,
- rmidi->card, 0, &snd_rawmidi_reg, name) < 0) {
+ rmidi->card, 0,
+ &snd_rawmidi_f_ops, name) < 0) {
snd_printk(KERN_ERR "unable to register OSS rawmidi device %i:%i\n", rmidi->card->number, 0);
} else {
rmidi->ossreg++;
}
if ((int)rmidi->device == amidi_map[rmidi->card->number]) {
if (snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_MIDI,
- rmidi->card, 1, &snd_rawmidi_reg, name) < 0) {
+ rmidi->card, 1,
+ &snd_rawmidi_f_ops, name) < 0) {
snd_printk(KERN_ERR "unable to register OSS rawmidi device %i:%i\n", rmidi->card->number, 1);
} else {
rmidi->ossreg++;
.compat_ioctl = odev_ioctl_compat,
};
-static struct snd_minor seq_oss_reg = {
- .comment = "sequencer",
- .f_ops = &seq_oss_f_ops,
-};
-
static int __init
register_device(void)
{
down(®ister_mutex);
if ((rc = snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_SEQUENCER,
NULL, 0,
- &seq_oss_reg,
+ &seq_oss_f_ops,
SNDRV_SEQ_OSS_DEVNAME)) < 0) {
snd_printk(KERN_ERR "can't register device seq\n");
up(®ister_mutex);
}
if ((rc = snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_MUSIC,
NULL, 0,
- &seq_oss_reg,
+ &seq_oss_f_ops,
SNDRV_SEQ_OSS_DEVNAME)) < 0) {
snd_printk(KERN_ERR "can't register device music\n");
snd_unregister_oss_device(SNDRV_OSS_DEVICE_TYPE_SEQUENCER, NULL, 0);
.compat_ioctl = snd_seq_ioctl_compat,
};
-static struct snd_minor snd_seq_reg =
-{
- .comment = "sequencer",
- .f_ops = &snd_seq_f_ops,
-};
-
-
/*
* register sequencer device
*/
if (down_interruptible(®ister_mutex))
return -ERESTARTSYS;
- if ((err = snd_register_device(SNDRV_DEVICE_TYPE_SEQUENCER, NULL, 0, &snd_seq_reg, "seq")) < 0) {
+ if ((err = snd_register_device(SNDRV_DEVICE_TYPE_SEQUENCER, NULL, 0,
+ &snd_seq_f_ops, "seq")) < 0) {
up(®ister_mutex);
return err;
}
* @type: the device type, SNDRV_DEVICE_TYPE_XXX
* @card: the card instance
* @dev: the device index
- * @reg: the struct snd_minor record
+ * @f_ops: the file operations
* @name: the device file name
*
* Registers an ALSA device file for the given card.
*
* Retrurns zero if successful, or a negative error code on failure.
*/
-int snd_register_device(int type, struct snd_card *card, int dev, struct snd_minor * reg, const char *name)
+int snd_register_device(int type, struct snd_card *card, int dev,
+ struct file_operations *f_ops, const char *name)
{
int minor = snd_kernel_minor(type, card, dev);
struct snd_minor *preg;
if (minor < 0)
return minor;
snd_assert(name, return -EINVAL);
- preg = kmalloc(sizeof(struct snd_minor) + strlen(name) + 1, GFP_KERNEL);
+ preg = kzalloc(sizeof(struct snd_minor) + strlen(name) + 1, GFP_KERNEL);
if (preg == NULL)
return -ENOMEM;
- *preg = *reg;
preg->number = minor;
+ preg->type = type;
preg->device = dev;
+ preg->f_ops = f_ops;
strcpy(preg->name, name);
down(&sound_mutex);
if (snd_minor_search(minor)) {
static struct snd_info_entry *snd_minor_info_entry = NULL;
+static const char *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";
+ default:
+ return "?";
+ }
+}
+
static void snd_minor_info_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer)
{
int card, device;
mptr = list_entry(list, struct snd_minor, list);
if (SNDRV_MINOR_DEVICE(mptr->number) != SNDRV_MINOR_GLOBAL) {
if ((device = mptr->device) >= 0)
- snd_iprintf(buffer, "%3i: [%i-%2i]: %s\n", mptr->number, card, device, mptr->comment);
+ snd_iprintf(buffer, "%3i: [%i-%2i]: %s\n", mptr->number, card, device, snd_device_type_name(mptr->type));
else
- snd_iprintf(buffer, "%3i: [%i] : %s\n", mptr->number, card, mptr->comment);
+ snd_iprintf(buffer, "%3i: [%i] : %s\n", mptr->number, card, snd_device_type_name(mptr->type));
} else {
- snd_iprintf(buffer, "%3i: : %s\n", mptr->number, mptr->comment);
+ snd_iprintf(buffer, "%3i: : %s\n", mptr->number, snd_device_type_name(mptr->type));
}
}
}
}
int snd_register_oss_device(int type, struct snd_card *card, int dev,
- struct snd_minor * reg, const char *name)
+ struct file_operations *f_ops, const char *name)
{
int minor = snd_oss_kernel_minor(type, card, dev);
int minor_unit;
if (minor < 0)
return minor;
- preg = (struct snd_minor *)kmalloc(sizeof(struct snd_minor), GFP_KERNEL);
+ preg = kzalloc(sizeof(struct snd_minor), GFP_KERNEL);
if (preg == NULL)
return -ENOMEM;
- *preg = *reg;
preg->number = minor;
+ preg->type = type;
preg->device = dev;
+ preg->f_ops = f_ops;
down(&sound_oss_mutex);
list_add_tail(&preg->list, &snd_oss_minors_hash[cidx]);
minor_unit = SNDRV_MINOR_OSS_DEVICE(minor);
}
if (card)
carddev = card->dev;
- register1 = register_sound_special_device(reg->f_ops, minor, carddev);
+ register1 = register_sound_special_device(f_ops, minor, carddev);
if (register1 != minor)
goto __end;
if (track2 >= 0) {
- register2 = register_sound_special_device(reg->f_ops, track2, carddev);
+ register2 = register_sound_special_device(f_ops, track2,
+ carddev);
if (register2 != track2)
goto __end;
}
static struct snd_info_entry *snd_minor_info_oss_entry = NULL;
+static const char *snd_oss_device_type_name(int type)
+{
+ switch (type) {
+ case SNDRV_OSS_DEVICE_TYPE_MIXER:
+ return "mixer";
+ case SNDRV_OSS_DEVICE_TYPE_SEQUENCER:
+ case SNDRV_OSS_DEVICE_TYPE_MUSIC:
+ return "sequencer";
+ case SNDRV_OSS_DEVICE_TYPE_PCM:
+ return "digital audio";
+ case SNDRV_OSS_DEVICE_TYPE_MIDI:
+ return "raw midi";
+ case SNDRV_OSS_DEVICE_TYPE_DMFM:
+ return "hardware dependent";
+ default:
+ return "?";
+ }
+}
+
static void snd_minor_info_oss_read(struct snd_info_entry *entry,
struct snd_info_buffer *buffer)
{
if (dev != SNDRV_MINOR_OSS_SNDSTAT &&
dev != SNDRV_MINOR_OSS_SEQUENCER &&
dev != SNDRV_MINOR_OSS_MUSIC)
- snd_iprintf(buffer, "%3i: [%i-%2i]: %s\n", mptr->number, card, dev, mptr->comment);
+ snd_iprintf(buffer, "%3i: [%i-%2i]: %s\n", mptr->number, card, dev, snd_oss_device_type_name(mptr->type));
else
- snd_iprintf(buffer, "%3i: : %s\n", mptr->number, mptr->comment);
+ snd_iprintf(buffer, "%3i: : %s\n", mptr->number, snd_oss_device_type_name(mptr->type));
}
}
up(&sound_oss_mutex);
.fasync = snd_timer_user_fasync,
};
-static struct snd_minor snd_timer_reg =
-{
- .comment = "timer",
- .f_ops = &snd_timer_f_ops,
-};
-
/*
* ENTRY functions
*/
snd_printk(KERN_ERR "unable to register system timer (%i)\n",
err);
if ((err = snd_register_device(SNDRV_DEVICE_TYPE_TIMER,
- NULL, 0, &snd_timer_reg, "timer"))<0)
+ NULL, 0, &snd_timer_f_ops, "timer")) < 0)
snd_printk(KERN_ERR "unable to register timer device (%i)\n",
err);
return 0;