]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - sound/core/pcm.c
[ARM] 4861/1: AT91: Update maintainer email address (again)
[linux-2.6-omap-h63xx.git] / sound / core / pcm.c
index 8e018988551610574daece3988e78d53d1ca9c5d..9dd9bc73fe1d6ab8b568fa1ce865650f52bae72f 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Digital Audio (PCM) abstract layer
- *  Copyright (c) by Jaroslav Kysela <perex@suse.cz>
+ *  Copyright (c) by Jaroslav Kysela <perex@perex.cz>
  *
  *
  *   This program is free software; you can redistribute it and/or modify
@@ -19,7 +19,6 @@
  *
  */
 
-#include <sound/driver.h>
 #include <linux/init.h>
 #include <linux/slab.h>
 #include <linux/time.h>
@@ -30,7 +29,7 @@
 #include <sound/control.h>
 #include <sound/info.h>
 
-MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>, Abramo Bagnara <abramo@alsa-project.org>");
+MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>, Abramo Bagnara <abramo@alsa-project.org>");
 MODULE_DESCRIPTION("Midlevel PCM code for ALSA.");
 MODULE_LICENSE("GPL");
 
@@ -45,11 +44,9 @@ static int snd_pcm_dev_disconnect(struct snd_device *device);
 
 static struct snd_pcm *snd_pcm_search(struct snd_card *card, int device)
 {
-       struct list_head *p;
        struct snd_pcm *pcm;
 
-       list_for_each(p, &snd_pcm_devices) {
-               pcm = list_entry(p, struct snd_pcm, list);
+       list_for_each_entry(pcm, &snd_pcm_devices, list) {
                if (pcm->card == card && pcm->device == device)
                        return pcm;
        }
@@ -230,7 +227,7 @@ static char *snd_pcm_subformat_names[] = {
 
 static char *snd_pcm_tstamp_mode_names[] = {
        TSTAMP(NONE),
-       TSTAMP(MMAP),
+       TSTAMP(ENABLE),
 };
 
 static const char *snd_pcm_stream_name(int stream)
@@ -361,7 +358,6 @@ static void snd_pcm_substream_proc_hw_params_read(struct snd_info_entry *entry,
        snd_iprintf(buffer, "rate: %u (%u/%u)\n", runtime->rate, runtime->rate_num, runtime->rate_den); 
        snd_iprintf(buffer, "period_size: %lu\n", runtime->period_size);        
        snd_iprintf(buffer, "buffer_size: %lu\n", runtime->buffer_size);        
-       snd_iprintf(buffer, "tick_time: %u\n", runtime->tick_time);
 #if defined(CONFIG_SND_PCM_OSS) || defined(CONFIG_SND_PCM_OSS_MODULE)
        if (substream->oss.oss) {
                snd_iprintf(buffer, "OSS format: %s\n", snd_pcm_oss_format_name(runtime->oss.format));
@@ -389,9 +385,7 @@ static void snd_pcm_substream_proc_sw_params_read(struct snd_info_entry *entry,
        }
        snd_iprintf(buffer, "tstamp_mode: %s\n", snd_pcm_tstamp_mode_name(runtime->tstamp_mode));
        snd_iprintf(buffer, "period_step: %u\n", runtime->period_step);
-       snd_iprintf(buffer, "sleep_min: %u\n", runtime->sleep_min);
        snd_iprintf(buffer, "avail_min: %lu\n", runtime->control->avail_min);
-       snd_iprintf(buffer, "xfer_align: %lu\n", runtime->xfer_align);
        snd_iprintf(buffer, "start_threshold: %lu\n", runtime->start_threshold);
        snd_iprintf(buffer, "stop_threshold: %lu\n", runtime->stop_threshold);
        snd_iprintf(buffer, "silence_threshold: %lu\n", runtime->silence_threshold);
@@ -767,12 +761,6 @@ static int snd_pcm_dev_free(struct snd_device *device)
        return snd_pcm_free(pcm);
 }
 
-static void snd_pcm_tick_timer_func(unsigned long data)
-{
-       struct snd_pcm_substream *substream = (struct snd_pcm_substream *) data;
-       snd_pcm_tick_elapsed(substream);
-}
-
 int snd_pcm_attach_substream(struct snd_pcm *pcm, int stream,
                             struct file *file,
                             struct snd_pcm_substream **rsubstream)
@@ -782,7 +770,6 @@ int snd_pcm_attach_substream(struct snd_pcm *pcm, int stream,
        struct snd_pcm_runtime *runtime;
        struct snd_ctl_file *kctl;
        struct snd_card *card;
-       struct list_head *list;
        int prefer_subdevice = -1;
        size_t size;
 
@@ -795,8 +782,7 @@ int snd_pcm_attach_substream(struct snd_pcm *pcm, int stream,
 
        card = pcm->card;
        down_read(&card->controls_rwsem);
-       list_for_each(list, &card->ctl_files) {
-               kctl = snd_ctl_file(list);
+       list_for_each_entry(kctl, &card->ctl_files, list) {
                if (kctl->pid == current->pid) {
                        prefer_subdevice = kctl->prefer_pcm_subdevice;
                        if (prefer_subdevice != -1)
@@ -881,9 +867,6 @@ int snd_pcm_attach_substream(struct snd_pcm *pcm, int stream,
        memset((void*)runtime->control, 0, size);
 
        init_waitqueue_head(&runtime->sleep);
-       init_timer(&runtime->tick_timer);
-       runtime->tick_timer.function = snd_pcm_tick_timer_func;
-       runtime->tick_timer.data = (unsigned long) substream;
 
        runtime->status->state = SNDRV_PCM_STATE_OPEN;
 
@@ -941,9 +924,10 @@ static int snd_pcm_dev_register(struct snd_device *device)
 {
        int cidx, err;
        struct snd_pcm_substream *substream;
-       struct list_head *list;
+       struct snd_pcm_notify *notify;
        char str[16];
        struct snd_pcm *pcm = device->device_data;
+       struct device *dev;
 
        snd_assert(pcm != NULL && device != NULL, return -ENXIO);
        mutex_lock(&register_mutex);
@@ -966,11 +950,18 @@ static int snd_pcm_dev_register(struct snd_device *device)
                        devtype = SNDRV_DEVICE_TYPE_PCM_CAPTURE;
                        break;
                }
-               if ((err = snd_register_device(devtype, pcm->card,
-                                              pcm->device,
-                                              &snd_pcm_f_ops[cidx],
-                                              pcm, str)) < 0)
-               {
+               /* device pointer to use, pcm->dev takes precedence if
+                * it is assigned, otherwise fall back to card's device
+                * if possible */
+               dev = pcm->dev;
+               if (!dev)
+                       dev = snd_card_get_device_link(pcm->card);
+               /* register pcm */
+               err = snd_register_device_for_dev(devtype, pcm->card,
+                                                 pcm->device,
+                                                 &snd_pcm_f_ops[cidx],
+                                                 pcm, str, dev);
+               if (err < 0) {
                        list_del(&pcm->list);
                        mutex_unlock(&register_mutex);
                        return err;
@@ -980,11 +971,10 @@ static int snd_pcm_dev_register(struct snd_device *device)
                for (substream = pcm->streams[cidx].substream; substream; substream = substream->next)
                        snd_pcm_timer_init(substream);
        }
-       list_for_each(list, &snd_pcm_notify_list) {
-               struct snd_pcm_notify *notify;
-               notify = list_entry(list, struct snd_pcm_notify, list);
+
+       list_for_each_entry(notify, &snd_pcm_notify_list, list)
                notify->n_register(pcm);
-       }
+
        mutex_unlock(&register_mutex);
        return 0;
 }
@@ -1027,7 +1017,7 @@ static int snd_pcm_dev_disconnect(struct snd_device *device)
 
 int snd_pcm_notify(struct snd_pcm_notify *notify, int nfree)
 {
-       struct list_head *p;
+       struct snd_pcm *pcm;
 
        snd_assert(notify != NULL &&
                   notify->n_register != NULL &&
@@ -1036,13 +1026,12 @@ int snd_pcm_notify(struct snd_pcm_notify *notify, int nfree)
        mutex_lock(&register_mutex);
        if (nfree) {
                list_del(&notify->list);
-               list_for_each(p, &snd_pcm_devices)
-                       notify->n_unregister(list_entry(p,
-                                                       struct snd_pcm, list));
+               list_for_each_entry(pcm, &snd_pcm_devices, list)
+                       notify->n_unregister(pcm);
        } else {
                list_add_tail(&notify->list, &snd_pcm_notify_list);
-               list_for_each(p, &snd_pcm_devices)
-                       notify->n_register(list_entry(p, struct snd_pcm, list));
+               list_for_each_entry(pcm, &snd_pcm_devices, list)
+                       notify->n_register(pcm);
        }
        mutex_unlock(&register_mutex);
        return 0;
@@ -1058,12 +1047,10 @@ EXPORT_SYMBOL(snd_pcm_notify);
 static void snd_pcm_proc_read(struct snd_info_entry *entry,
                              struct snd_info_buffer *buffer)
 {
-       struct list_head *p;
        struct snd_pcm *pcm;
 
        mutex_lock(&register_mutex);
-       list_for_each(p, &snd_pcm_devices) {
-               pcm = list_entry(p, struct snd_pcm, list);
+       list_for_each_entry(pcm, &snd_pcm_devices, list) {
                snd_iprintf(buffer, "%02i-%02i: %s : %s",
                            pcm->card->number, pcm->device, pcm->id, pcm->name);
                if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream)