aboutsummaryrefslogtreecommitdiffstats
path: root/sound/core/sound.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/core/sound.c')
-rw-r--r--sound/core/sound.c38
1 files changed, 31 insertions, 7 deletions
diff --git a/sound/core/sound.c b/sound/core/sound.c
index fb236a6b9c34..798c24c2de20 100644
--- a/sound/core/sound.c
+++ b/sound/core/sound.c
@@ -195,7 +195,7 @@ static int snd_kernel_minor(int type, struct snd_card *card, int dev)
195 * @type: the device type, SNDRV_DEVICE_TYPE_XXX 195 * @type: the device type, SNDRV_DEVICE_TYPE_XXX
196 * @card: the card instance 196 * @card: the card instance
197 * @dev: the device index 197 * @dev: the device index
198 * @reg: the struct snd_minor record 198 * @f_ops: the file operations
199 * @name: the device file name 199 * @name: the device file name
200 * 200 *
201 * Registers an ALSA device file for the given card. 201 * 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 * 203 *
204 * Retrurns zero if successful, or a negative error code on failure. 204 * Retrurns zero if successful, or a negative error code on failure.
205 */ 205 */
206int snd_register_device(int type, struct snd_card *card, int dev, struct snd_minor * reg, const char *name) 206int snd_register_device(int type, struct snd_card *card, int dev,
207 struct file_operations *f_ops, const char *name)
207{ 208{
208 int minor = snd_kernel_minor(type, card, dev); 209 int minor = snd_kernel_minor(type, card, dev);
209 struct snd_minor *preg; 210 struct snd_minor *preg;
@@ -212,12 +213,13 @@ int snd_register_device(int type, struct snd_card *card, int dev, struct snd_min
212 if (minor < 0) 213 if (minor < 0)
213 return minor; 214 return minor;
214 snd_assert(name, return -EINVAL); 215 snd_assert(name, return -EINVAL);
215 preg = kmalloc(sizeof(struct snd_minor) + strlen(name) + 1, GFP_KERNEL); 216 preg = kzalloc(sizeof(struct snd_minor) + strlen(name) + 1, GFP_KERNEL);
216 if (preg == NULL) 217 if (preg == NULL)
217 return -ENOMEM; 218 return -ENOMEM;
218 *preg = *reg;
219 preg->number = minor; 219 preg->number = minor;
220 preg->type = type;
220 preg->device = dev; 221 preg->device = dev;
222 preg->f_ops = f_ops;
221 strcpy(preg->name, name); 223 strcpy(preg->name, name);
222 down(&sound_mutex); 224 down(&sound_mutex);
223 if (snd_minor_search(minor)) { 225 if (snd_minor_search(minor)) {
@@ -276,6 +278,28 @@ int snd_unregister_device(int type, struct snd_card *card, int dev)
276 278
277static struct snd_info_entry *snd_minor_info_entry = NULL; 279static struct snd_info_entry *snd_minor_info_entry = NULL;
278 280
281static const char *snd_device_type_name(int type)
282{
283 switch (type) {
284 case SNDRV_DEVICE_TYPE_CONTROL:
285 return "control";
286 case SNDRV_DEVICE_TYPE_HWDEP:
287 return "hardware dependent";
288 case SNDRV_DEVICE_TYPE_RAWMIDI:
289 return "raw midi";
290 case SNDRV_DEVICE_TYPE_PCM_PLAYBACK:
291 return "digital audio playback";
292 case SNDRV_DEVICE_TYPE_PCM_CAPTURE:
293 return "digital audio capture";
294 case SNDRV_DEVICE_TYPE_SEQUENCER:
295 return "sequencer";
296 case SNDRV_DEVICE_TYPE_TIMER:
297 return "timer";
298 default:
299 return "?";
300 }
301}
302
279static void snd_minor_info_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer) 303static void snd_minor_info_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer)
280{ 304{
281 int card, device; 305 int card, device;
@@ -288,11 +312,11 @@ static void snd_minor_info_read(struct snd_info_entry *entry, struct snd_info_bu
288 mptr = list_entry(list, struct snd_minor, list); 312 mptr = list_entry(list, struct snd_minor, list);
289 if (SNDRV_MINOR_DEVICE(mptr->number) != SNDRV_MINOR_GLOBAL) { 313 if (SNDRV_MINOR_DEVICE(mptr->number) != SNDRV_MINOR_GLOBAL) {
290 if ((device = mptr->device) >= 0) 314 if ((device = mptr->device) >= 0)
291 snd_iprintf(buffer, "%3i: [%i-%2i]: %s\n", mptr->number, card, device, mptr->comment); 315 snd_iprintf(buffer, "%3i: [%i-%2i]: %s\n", mptr->number, card, device, snd_device_type_name(mptr->type));
292 else 316 else
293 snd_iprintf(buffer, "%3i: [%i] : %s\n", mptr->number, card, mptr->comment); 317 snd_iprintf(buffer, "%3i: [%i] : %s\n", mptr->number, card, snd_device_type_name(mptr->type));
294 } else { 318 } else {
295 snd_iprintf(buffer, "%3i: : %s\n", mptr->number, mptr->comment); 319 snd_iprintf(buffer, "%3i: : %s\n", mptr->number, snd_device_type_name(mptr->type));
296 } 320 }
297 } 321 }
298 } 322 }