Commit 2af677fc authored by Clemens Ladisch's avatar Clemens Ladisch Committed by Jaroslav Kysela

[ALSA] dynamic minors (1/6): store device type in struct snd_minor

Instead of a comment string, store the device type in the snd_minor
structure.  This makes snd_minor more flexible, and has the nice side
effect that we don't need anymore to create a separate snd_minor
template for registering a device but can pass the file_operations
directly to snd_register_device().
Signed-off-by: default avatarClemens Ladisch <clemens@ladisch.de>
parent a106cd3d
...@@ -185,8 +185,8 @@ static inline int snd_power_wait(struct snd_card *card, unsigned int state, stru ...@@ -185,8 +185,8 @@ static inline int snd_power_wait(struct snd_card *card, unsigned int state, stru
struct snd_minor { struct snd_minor {
struct list_head list; /* list of all minors per card */ struct list_head list; /* list of all minors per card */
int number; /* minor number */ int number; /* minor number */
int type; /* SNDRV_DEVICE_TYPE_XXX */
int device; /* device number */ int device; /* device number */
const char *comment; /* for /proc/asound/devices */
struct file_operations *f_ops; /* file operations */ struct file_operations *f_ops; /* file operations */
char name[0]; /* device name (keep at the end of char name[0]; /* device name (keep at the end of
structure) */ structure) */
...@@ -199,11 +199,13 @@ extern int snd_ecards_limit; ...@@ -199,11 +199,13 @@ extern int snd_ecards_limit;
void snd_request_card(int card); 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); int snd_unregister_device(int type, struct snd_card *card, int dev);
#ifdef CONFIG_SND_OSSEMUL #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); int snd_unregister_oss_device(int type, struct snd_card *card, int dev);
#endif #endif
......
...@@ -402,7 +402,6 @@ struct snd_pcm_str { ...@@ -402,7 +402,6 @@ struct snd_pcm_str {
struct snd_pcm_oss_stream oss; struct snd_pcm_oss_stream oss;
#endif #endif
struct snd_pcm_file *files; struct snd_pcm_file *files;
struct snd_minor *reg;
struct snd_info_entry *proc_root; struct snd_info_entry *proc_root;
struct snd_info_entry *proc_info_entry; struct snd_info_entry *proc_info_entry;
#ifdef CONFIG_SND_DEBUG #ifdef CONFIG_SND_DEBUG
...@@ -441,7 +440,7 @@ struct snd_pcm_notify { ...@@ -441,7 +440,7 @@ struct snd_pcm_notify {
*/ */
extern struct snd_pcm *snd_pcm_devices[]; 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 snd_pcm_new(struct snd_card *card, char *id, int device,
int playback_count, int capture_count, int playback_count, int capture_count,
......
...@@ -1264,12 +1264,6 @@ static struct file_operations snd_ctl_f_ops = ...@@ -1264,12 +1264,6 @@ static struct file_operations snd_ctl_f_ops =
.fasync = snd_ctl_fasync, .fasync = snd_ctl_fasync,
}; };
static struct snd_minor snd_ctl_reg =
{
.comment = "ctl",
.f_ops = &snd_ctl_f_ops,
};
/* /*
* registration of the control device * registration of the control device
*/ */
...@@ -1284,7 +1278,7 @@ static int snd_ctl_dev_register(struct snd_device *device) ...@@ -1284,7 +1278,7 @@ static int snd_ctl_dev_register(struct snd_device *device)
snd_assert(cardnum >= 0 && cardnum < SNDRV_CARDS, return -ENXIO); snd_assert(cardnum >= 0 && cardnum < SNDRV_CARDS, return -ENXIO);
sprintf(name, "controlC%i", cardnum); sprintf(name, "controlC%i", cardnum);
if ((err = snd_register_device(SNDRV_DEVICE_TYPE_CONTROL, 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 err;
return 0; return 0;
} }
...@@ -1336,7 +1330,8 @@ static int snd_ctl_dev_unregister(struct snd_device *device) ...@@ -1336,7 +1330,8 @@ static int snd_ctl_dev_unregister(struct snd_device *device)
snd_assert(card != NULL, return -ENXIO); snd_assert(card != NULL, return -ENXIO);
cardnum = card->number; cardnum = card->number;
snd_assert(cardnum >= 0 && cardnum < SNDRV_CARDS, return -ENXIO); 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 err;
return snd_ctl_dev_free(device); return snd_ctl_dev_free(device);
} }
......
...@@ -330,12 +330,6 @@ static struct file_operations snd_hwdep_f_ops = ...@@ -330,12 +330,6 @@ static struct file_operations snd_hwdep_f_ops =
.mmap = snd_hwdep_mmap, .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 * snd_hwdep_new - create a new hwdep instance
* @card: the card instance * @card: the card instance
...@@ -416,7 +410,7 @@ static int snd_hwdep_dev_register(struct snd_device *device) ...@@ -416,7 +410,7 @@ static int snd_hwdep_dev_register(struct snd_device *device)
sprintf(name, "hwC%iD%i", hwdep->card->number, hwdep->device); sprintf(name, "hwC%iD%i", hwdep->card->number, hwdep->device);
if ((err = snd_register_device(SNDRV_DEVICE_TYPE_HWDEP, if ((err = snd_register_device(SNDRV_DEVICE_TYPE_HWDEP,
hwdep->card, hwdep->device, 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", snd_printk(KERN_ERR "unable to register hardware dependent device %i:%i\n",
hwdep->card->number, hwdep->device); hwdep->card->number, hwdep->device);
snd_hwdep_devices[idx] = NULL; snd_hwdep_devices[idx] = NULL;
...@@ -431,7 +425,8 @@ static int snd_hwdep_dev_register(struct snd_device *device) ...@@ -431,7 +425,8 @@ static int snd_hwdep_dev_register(struct snd_device *device)
} else { } else {
if (snd_register_oss_device(hwdep->oss_type, if (snd_register_oss_device(hwdep->oss_type,
hwdep->card, hwdep->device, 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", snd_printk(KERN_ERR "unable to register OSS compatibility device %i:%i\n",
hwdep->card->number, hwdep->device); hwdep->card->number, hwdep->device);
} else } else
......
...@@ -398,12 +398,6 @@ static struct file_operations snd_mixer_oss_f_ops = ...@@ -398,12 +398,6 @@ static struct file_operations snd_mixer_oss_f_ops =
.compat_ioctl = snd_mixer_oss_ioctl_compat, .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 * utilities
*/ */
...@@ -1292,7 +1286,7 @@ static int snd_mixer_oss_notify_handler(struct snd_card *card, int cmd) ...@@ -1292,7 +1286,7 @@ static int snd_mixer_oss_notify_handler(struct snd_card *card, int cmd)
sprintf(name, "mixer%i%i", card->number, 0); sprintf(name, "mixer%i%i", card->number, 0);
if ((err = snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_MIXER, if ((err = snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_MIXER,
card, 0, card, 0,
&snd_mixer_oss_reg, &snd_mixer_oss_f_ops,
name)) < 0) { name)) < 0) {
snd_printk(KERN_ERR "unable to register OSS mixer device %i:%i\n", snd_printk(KERN_ERR "unable to register OSS mixer device %i:%i\n",
card->number, 0); card->number, 0);
......
...@@ -2444,18 +2444,12 @@ static struct file_operations snd_pcm_oss_f_reg = ...@@ -2444,18 +2444,12 @@ static struct file_operations snd_pcm_oss_f_reg =
.mmap = snd_pcm_oss_mmap, .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) static void register_oss_dsp(struct snd_pcm *pcm, int index)
{ {
char name[128]; char name[128];
sprintf(name, "dsp%i%i", pcm->card->number, pcm->device); sprintf(name, "dsp%i%i", pcm->card->number, pcm->device);
if (snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_PCM, 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) { name) < 0) {
snd_printk(KERN_ERR "unable to register OSS PCM device %i:%i\n", snd_printk(KERN_ERR "unable to register OSS PCM device %i:%i\n",
pcm->card->number, pcm->device); pcm->card->number, pcm->device);
......
...@@ -597,7 +597,6 @@ int snd_pcm_new_stream(struct snd_pcm *pcm, int stream, int substream_count) ...@@ -597,7 +597,6 @@ int snd_pcm_new_stream(struct snd_pcm *pcm, int stream, int substream_count)
pstr->stream = stream; pstr->stream = stream;
pstr->pcm = pcm; pstr->pcm = pcm;
pstr->substream_count = substream_count; pstr->substream_count = substream_count;
pstr->reg = &snd_pcm_reg[stream];
if (substream_count > 0) { if (substream_count > 0) {
err = snd_pcm_stream_proc_init(pstr); err = snd_pcm_stream_proc_init(pstr);
if (err < 0) { if (err < 0) {
...@@ -897,7 +896,10 @@ static int snd_pcm_dev_register(struct snd_device *device) ...@@ -897,7 +896,10 @@ static int snd_pcm_dev_register(struct snd_device *device)
devtype = SNDRV_DEVICE_TYPE_PCM_CAPTURE; devtype = SNDRV_DEVICE_TYPE_PCM_CAPTURE;
break; 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; snd_pcm_devices[idx] = NULL;
up(&register_mutex); up(&register_mutex);
return err; return err;
......
...@@ -3370,40 +3370,29 @@ static int snd_pcm_hw_params_old_user(struct snd_pcm_substream *substream, ...@@ -3370,40 +3370,29 @@ static int snd_pcm_hw_params_old_user(struct snd_pcm_substream *substream,
* Register section * Register section
*/ */
static struct file_operations snd_pcm_f_ops_playback = { struct file_operations snd_pcm_f_ops[2] = {
.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] =
{
{ {
.comment = "digital audio playback", .owner = THIS_MODULE,
.f_ops = &snd_pcm_f_ops_playback, .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", .owner = THIS_MODULE,
.f_ops = &snd_pcm_f_ops_capture, .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,
} }
}; };
...@@ -1367,12 +1367,6 @@ static struct file_operations snd_rawmidi_f_ops = ...@@ -1367,12 +1367,6 @@ static struct file_operations snd_rawmidi_f_ops =
.compat_ioctl = snd_rawmidi_ioctl_compat, .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, static int snd_rawmidi_alloc_substreams(struct snd_rawmidi *rmidi,
struct snd_rawmidi_str *stream, struct snd_rawmidi_str *stream,
int direction, int direction,
...@@ -1516,7 +1510,7 @@ static int snd_rawmidi_dev_register(struct snd_device *device) ...@@ -1516,7 +1510,7 @@ static int snd_rawmidi_dev_register(struct snd_device *device)
sprintf(name, "midiC%iD%i", rmidi->card->number, rmidi->device); sprintf(name, "midiC%iD%i", rmidi->card->number, rmidi->device);
if ((err = snd_register_device(SNDRV_DEVICE_TYPE_RAWMIDI, if ((err = snd_register_device(SNDRV_DEVICE_TYPE_RAWMIDI,
rmidi->card, rmidi->device, 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_printk(KERN_ERR "unable to register rawmidi device %i:%i\n", rmidi->card->number, rmidi->device);
snd_rawmidi_devices[idx] = NULL; snd_rawmidi_devices[idx] = NULL;
up(&register_mutex); up(&register_mutex);
...@@ -1533,7 +1527,8 @@ static int snd_rawmidi_dev_register(struct snd_device *device) ...@@ -1533,7 +1527,8 @@ static int snd_rawmidi_dev_register(struct snd_device *device)
rmidi->ossreg = 0; rmidi->ossreg = 0;
if ((int)rmidi->device == midi_map[rmidi->card->number]) { if ((int)rmidi->device == midi_map[rmidi->card->number]) {
if (snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_MIDI, 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); snd_printk(KERN_ERR "unable to register OSS rawmidi device %i:%i\n", rmidi->card->number, 0);
} else { } else {
rmidi->ossreg++; rmidi->ossreg++;
...@@ -1544,7 +1539,8 @@ static int snd_rawmidi_dev_register(struct snd_device *device) ...@@ -1544,7 +1539,8 @@ static int snd_rawmidi_dev_register(struct snd_device *device)
} }
if ((int)rmidi->device == amidi_map[rmidi->card->number]) { if ((int)rmidi->device == amidi_map[rmidi->card->number]) {
if (snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_MIDI, 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); snd_printk(KERN_ERR "unable to register OSS rawmidi device %i:%i\n", rmidi->card->number, 1);
} else { } else {
rmidi->ossreg++; rmidi->ossreg++;
......
...@@ -217,11 +217,6 @@ static struct file_operations seq_oss_f_ops = ...@@ -217,11 +217,6 @@ static struct file_operations seq_oss_f_ops =
.compat_ioctl = odev_ioctl_compat, .compat_ioctl = odev_ioctl_compat,
}; };
static struct snd_minor seq_oss_reg = {
.comment = "sequencer",
.f_ops = &seq_oss_f_ops,
};
static int __init static int __init
register_device(void) register_device(void)
{ {
...@@ -230,7 +225,7 @@ register_device(void) ...@@ -230,7 +225,7 @@ register_device(void)
down(&register_mutex); down(&register_mutex);
if ((rc = snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_SEQUENCER, if ((rc = snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_SEQUENCER,
NULL, 0, NULL, 0,
&seq_oss_reg, &seq_oss_f_ops,
SNDRV_SEQ_OSS_DEVNAME)) < 0) { SNDRV_SEQ_OSS_DEVNAME)) < 0) {
snd_printk(KERN_ERR "can't register device seq\n"); snd_printk(KERN_ERR "can't register device seq\n");
up(&register_mutex); up(&register_mutex);
...@@ -238,7 +233,7 @@ register_device(void) ...@@ -238,7 +233,7 @@ register_device(void)
} }
if ((rc = snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_MUSIC, if ((rc = snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_MUSIC,
NULL, 0, NULL, 0,
&seq_oss_reg, &seq_oss_f_ops,
SNDRV_SEQ_OSS_DEVNAME)) < 0) { SNDRV_SEQ_OSS_DEVNAME)) < 0) {
snd_printk(KERN_ERR "can't register device music\n"); snd_printk(KERN_ERR "can't register device music\n");
snd_unregister_oss_device(SNDRV_OSS_DEVICE_TYPE_SEQUENCER, NULL, 0); snd_unregister_oss_device(SNDRV_OSS_DEVICE_TYPE_SEQUENCER, NULL, 0);
......
...@@ -2520,13 +2520,6 @@ static struct file_operations snd_seq_f_ops = ...@@ -2520,13 +2520,6 @@ static struct file_operations snd_seq_f_ops =
.compat_ioctl = snd_seq_ioctl_compat, .compat_ioctl = snd_seq_ioctl_compat,
}; };
static struct snd_minor snd_seq_reg =
{
.comment = "sequencer",
.f_ops = &snd_seq_f_ops,
};
/* /*
* register sequencer device * register sequencer device
*/ */
...@@ -2537,7 +2530,8 @@ int __init snd_sequencer_device_init(void) ...@@ -2537,7 +2530,8 @@ int __init snd_sequencer_device_init(void)
if (down_interruptible(&register_mutex)) if (down_interruptible(&register_mutex))
return -ERESTARTSYS; 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(&register_mutex); up(&register_mutex);
return err; return err;
} }
......
...@@ -195,7 +195,7 @@ static int snd_kernel_minor(int type, struct snd_card *card, int dev) ...@@ -195,7 +195,7 @@ static int snd_kernel_minor(int type, struct snd_card *card, int dev)
* @type: the device type, SNDRV_DEVICE_TYPE_XXX * @type: the device type, SNDRV_DEVICE_TYPE_XXX
* @card: the card instance * @card: the card instance
* @dev: the device index * @dev: the device index
* @reg: the struct snd_minor record * @f_ops: the file operations
* @name: the device file name * @name: the device file name
* *
* Registers an ALSA device file for the given card. * Registers an ALSA device file for the given card.
...@@ -203,7 +203,8 @@ static int snd_kernel_minor(int type, struct snd_card *card, int dev) ...@@ -203,7 +203,8 @@ static int snd_kernel_minor(int type, struct snd_card *card, int dev)
* *
* Retrurns zero if successful, or a negative error code on failure. * 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); int minor = snd_kernel_minor(type, card, dev);
struct snd_minor *preg; struct snd_minor *preg;
...@@ -212,12 +213,13 @@ int snd_register_device(int type, struct snd_card *card, int dev, struct snd_min ...@@ -212,12 +213,13 @@ int snd_register_device(int type, struct snd_card *card, int dev, struct snd_min
if (minor < 0) if (minor < 0)
return minor; return minor;
snd_assert(name, return -EINVAL); 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) if (preg == NULL)
return -ENOMEM; return -ENOMEM;
*preg = *reg;
preg->number = minor; preg->number = minor;
preg->type = type;
preg->device = dev; preg->device = dev;
preg->f_ops = f_ops;
strcpy(preg->name, name); strcpy(preg->name, name);
down(&sound_mutex); down(&sound_mutex);
if (snd_minor_search(minor)) { if (snd_minor_search(minor)) {
...@@ -276,6 +278,28 @@ int snd_unregister_device(int type, struct snd_card *card, int dev) ...@@ -276,6 +278,28 @@ int snd_unregister_device(int type, struct snd_card *card, int dev)
static struct snd_info_entry *snd_minor_info_entry = NULL; 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) static void snd_minor_info_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer)
{ {
int card, device; int card, device;
...@@ -288,11 +312,11 @@ static void snd_minor_info_read(struct snd_info_entry *entry, struct snd_info_bu ...@@ -288,11 +312,11 @@ static void snd_minor_info_read(struct snd_info_entry *entry, struct snd_info_bu
mptr = list_entry(list, struct snd_minor, list); mptr = list_entry(list, struct snd_minor, list);
if (SNDRV_MINOR_DEVICE(mptr->number) != SNDRV_MINOR_GLOBAL) { if (SNDRV_MINOR_DEVICE(mptr->number) != SNDRV_MINOR_GLOBAL) {
if ((device = mptr->device) >= 0) 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 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 { } 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));
} }
} }
} }
......
...@@ -91,7 +91,7 @@ static int snd_oss_kernel_minor(int type, struct snd_card *card, int dev) ...@@ -91,7 +91,7 @@ static int snd_oss_kernel_minor(int type, struct snd_card *card, int dev)
} }
int snd_register_oss_device(int type, struct snd_card *card, int dev, 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 = snd_oss_kernel_minor(type, card, dev);
int minor_unit; int minor_unit;
...@@ -103,12 +103,13 @@ int snd_register_oss_device(int type, struct snd_card *card, int dev, ...@@ -103,12 +103,13 @@ int snd_register_oss_device(int type, struct snd_card *card, int dev,
if (minor < 0) if (minor < 0)
return minor; return minor;
preg = (struct snd_minor *)kmalloc(sizeof(struct snd_minor), GFP_KERNEL); preg = kzalloc(sizeof(struct snd_minor), GFP_KERNEL);
if (preg == NULL) if (preg == NULL)
return -ENOMEM; return -ENOMEM;
*preg = *reg;
preg->number = minor; preg->number = minor;
preg->type = type;
preg->device = dev; preg->device = dev;
preg->f_ops = f_ops;
down(&sound_oss_mutex); down(&sound_oss_mutex);
list_add_tail(&preg->list, &snd_oss_minors_hash[cidx]); list_add_tail(&preg->list, &snd_oss_minors_hash[cidx]);
minor_unit = SNDRV_MINOR_OSS_DEVICE(minor); minor_unit = SNDRV_MINOR_OSS_DEVICE(minor);
...@@ -125,11 +126,12 @@ int snd_register_oss_device(int type, struct snd_card *card, int dev, ...@@ -125,11 +126,12 @@ int snd_register_oss_device(int type, struct snd_card *card, int dev,
} }
if (card) if (card)
carddev = card->dev; 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) if (register1 != minor)
goto __end; goto __end;
if (track2 >= 0) { 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) if (register2 != track2)
goto __end; goto __end;
} }
...@@ -190,6 +192,25 @@ int snd_unregister_oss_device(int type, struct snd_card *card, int dev) ...@@ -190,6 +192,25 @@ int snd_unregister_oss_device(int type, struct snd_card *card, int dev)
static struct snd_info_entry *snd_minor_info_oss_entry = NULL; 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, static void snd_minor_info_oss_read(struct snd_info_entry *entry,
struct snd_info_buffer *buffer) struct snd_info_buffer *buffer)
{ {
...@@ -205,9 +226,9 @@ static void snd_minor_info_oss_read(struct snd_info_entry *entry, ...@@ -205,9 +226,9 @@ static void snd_minor_info_oss_read(struct snd_info_entry *entry,
if (dev != SNDRV_MINOR_OSS_SNDSTAT && if (dev != SNDRV_MINOR_OSS_SNDSTAT &&
dev != SNDRV_MINOR_OSS_SEQUENCER && dev != SNDRV_MINOR_OSS_SEQUENCER &&
dev != SNDRV_MINOR_OSS_MUSIC) 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 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); up(&sound_oss_mutex);
......
...@@ -1924,12 +1924,6 @@ static struct file_operations snd_timer_f_ops = ...@@ -1924,12 +1924,6 @@ static struct file_operations snd_timer_f_ops =
.fasync = snd_timer_user_fasync, .fasync = snd_timer_user_fasync,
}; };
static struct snd_minor snd_timer_reg =
{
.comment = "timer",
.f_ops = &snd_timer_f_ops,
};
/* /*
* ENTRY functions * ENTRY functions
*/ */
...@@ -1959,7 +1953,7 @@ static int __init alsa_timer_init(void) ...@@ -1959,7 +1953,7 @@ static int __init alsa_timer_init(void)
snd_printk(KERN_ERR "unable to register system timer (%i)\n", snd_printk(KERN_ERR "unable to register system timer (%i)\n",
err); err);
if ((err = snd_register_device(SNDRV_DEVICE_TYPE_TIMER, 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", snd_printk(KERN_ERR "unable to register timer device (%i)\n",
err); err);
return 0; return 0;
......
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