Commit c7132aeb authored by Jaroslav Kysela's avatar Jaroslav Kysela

[ALSA] pcm core: add prealloc_max file to substream directory to show maximum DMA size

Users ask us many times about the maximum DMA size for PCM devices. This
file gives them a hint in KB.
Signed-off-by: default avatarJaroslav Kysela <perex@suse.cz>
parent b66b3cfe
...@@ -384,6 +384,7 @@ struct snd_pcm_substream { ...@@ -384,6 +384,7 @@ struct snd_pcm_substream {
struct snd_info_entry *proc_sw_params_entry; struct snd_info_entry *proc_sw_params_entry;
struct snd_info_entry *proc_status_entry; struct snd_info_entry *proc_status_entry;
struct snd_info_entry *proc_prealloc_entry; struct snd_info_entry *proc_prealloc_entry;
struct snd_info_entry *proc_prealloc_max_entry;
#endif #endif
/* misc flags */ /* misc flags */
unsigned int hw_opened: 1; unsigned int hw_opened: 1;
......
...@@ -101,6 +101,8 @@ int snd_pcm_lib_preallocate_free(struct snd_pcm_substream *substream) ...@@ -101,6 +101,8 @@ int snd_pcm_lib_preallocate_free(struct snd_pcm_substream *substream)
{ {
snd_pcm_lib_preallocate_dma_free(substream); snd_pcm_lib_preallocate_dma_free(substream);
#ifdef CONFIG_SND_VERBOSE_PROCFS #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); snd_info_free_entry(substream->proc_prealloc_entry);
substream->proc_prealloc_entry = NULL; substream->proc_prealloc_entry = NULL;
#endif #endif
...@@ -141,6 +143,18 @@ static void snd_pcm_lib_preallocate_proc_read(struct snd_info_entry *entry, ...@@ -141,6 +143,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); 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 * write callback for prealloc proc file
* *
...@@ -203,6 +217,15 @@ static inline void preallocate_info_init(struct snd_pcm_substream *substream) ...@@ -203,6 +217,15 @@ static inline void preallocate_info_init(struct snd_pcm_substream *substream)
} }
} }
substream->proc_prealloc_entry = entry; 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 */ #else /* !CONFIG_SND_VERBOSE_PROCFS */
......
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