Merge branch 'for-2.6.27' of git://git.infradead.org/users/dwmw2/firmware-2.6
[sfrench/cifs-2.6.git] / sound / core / pcm_memory.c
index be030cb4d373207751fa516ea1b13534b8d143c4..ff07b4a9992e80e4ad65bb3c1dac6a353020ad68 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 <asm/io.h>
 #include <linux/time.h>
 #include <linux/init.h>
@@ -101,6 +100,8 @@ int snd_pcm_lib_preallocate_free(struct snd_pcm_substream *substream)
 {
        snd_pcm_lib_preallocate_dma_free(substream);
 #ifdef CONFIG_SND_VERBOSE_PROCFS
+       snd_info_free_entry(substream->proc_prealloc_max_entry);
+       substream->proc_prealloc_max_entry = NULL;
        snd_info_free_entry(substream->proc_prealloc_entry);
        substream->proc_prealloc_entry = NULL;
 #endif
@@ -141,6 +142,18 @@ static void snd_pcm_lib_preallocate_proc_read(struct snd_info_entry *entry,
        snd_iprintf(buffer, "%lu\n", (unsigned long) substream->dma_buffer.bytes / 1024);
 }
 
+/*
+ * read callback for prealloc_max proc file
+ *
+ * prints the maximum allowed size in kB.
+ */
+static void snd_pcm_lib_preallocate_max_proc_read(struct snd_info_entry *entry,
+                                                 struct snd_info_buffer *buffer)
+{
+       struct snd_pcm_substream *substream = entry->private_data;
+       snd_iprintf(buffer, "%lu\n", (unsigned long) substream->dma_max / 1024);
+}
+
 /*
  * write callback for prealloc proc file
  *
@@ -203,6 +216,15 @@ static inline void preallocate_info_init(struct snd_pcm_substream *substream)
                }
        }
        substream->proc_prealloc_entry = entry;
+       if ((entry = snd_info_create_card_entry(substream->pcm->card, "prealloc_max", substream->proc_root)) != NULL) {
+               entry->c.text.read = snd_pcm_lib_preallocate_max_proc_read;
+               entry->private_data = substream;
+               if (snd_info_register(entry) < 0) {
+                       snd_info_free_entry(entry);
+                       entry = NULL;
+               }
+       }
+       substream->proc_prealloc_max_entry = entry;
 }
 
 #else /* !CONFIG_SND_VERBOSE_PROCFS */