aboutsummaryrefslogtreecommitdiffstats
path: root/sound/core/pcm.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/core/pcm.c')
-rw-r--r--sound/core/pcm.c104
1 files changed, 62 insertions, 42 deletions
diff --git a/sound/core/pcm.c b/sound/core/pcm.c
index 95036c83de43..28ca61eb0b0d 100644
--- a/sound/core/pcm.c
+++ b/sound/core/pcm.c
@@ -151,30 +151,6 @@ static int snd_pcm_control_ioctl(struct snd_card *card,
151#define FORMAT(v) [SNDRV_PCM_FORMAT_##v] = #v 151#define FORMAT(v) [SNDRV_PCM_FORMAT_##v] = #v
152#define SUBFORMAT(v) [SNDRV_PCM_SUBFORMAT_##v] = #v 152#define SUBFORMAT(v) [SNDRV_PCM_SUBFORMAT_##v] = #v
153 153
154static char *snd_pcm_stream_names[] = {
155 STREAM(PLAYBACK),
156 STREAM(CAPTURE),
157};
158
159static char *snd_pcm_state_names[] = {
160 STATE(OPEN),
161 STATE(SETUP),
162 STATE(PREPARED),
163 STATE(RUNNING),
164 STATE(XRUN),
165 STATE(DRAINING),
166 STATE(PAUSED),
167 STATE(SUSPENDED),
168};
169
170static char *snd_pcm_access_names[] = {
171 ACCESS(MMAP_INTERLEAVED),
172 ACCESS(MMAP_NONINTERLEAVED),
173 ACCESS(MMAP_COMPLEX),
174 ACCESS(RW_INTERLEAVED),
175 ACCESS(RW_NONINTERLEAVED),
176};
177
178static char *snd_pcm_format_names[] = { 154static char *snd_pcm_format_names[] = {
179 FORMAT(S8), 155 FORMAT(S8),
180 FORMAT(U8), 156 FORMAT(U8),
@@ -216,6 +192,36 @@ static char *snd_pcm_format_names[] = {
216 FORMAT(U18_3BE), 192 FORMAT(U18_3BE),
217}; 193};
218 194
195const char *snd_pcm_format_name(snd_pcm_format_t format)
196{
197 return snd_pcm_format_names[format];
198}
199
200#ifdef CONFIG_PROC_FS
201static char *snd_pcm_stream_names[] = {
202 STREAM(PLAYBACK),
203 STREAM(CAPTURE),
204};
205
206static char *snd_pcm_state_names[] = {
207 STATE(OPEN),
208 STATE(SETUP),
209 STATE(PREPARED),
210 STATE(RUNNING),
211 STATE(XRUN),
212 STATE(DRAINING),
213 STATE(PAUSED),
214 STATE(SUSPENDED),
215};
216
217static char *snd_pcm_access_names[] = {
218 ACCESS(MMAP_INTERLEAVED),
219 ACCESS(MMAP_NONINTERLEAVED),
220 ACCESS(MMAP_COMPLEX),
221 ACCESS(RW_INTERLEAVED),
222 ACCESS(RW_NONINTERLEAVED),
223};
224
219static char *snd_pcm_subformat_names[] = { 225static char *snd_pcm_subformat_names[] = {
220 SUBFORMAT(STD), 226 SUBFORMAT(STD),
221}; 227};
@@ -236,11 +242,6 @@ static const char *snd_pcm_access_name(snd_pcm_access_t access)
236 return snd_pcm_access_names[access]; 242 return snd_pcm_access_names[access];
237} 243}
238 244
239const char *snd_pcm_format_name(snd_pcm_format_t format)
240{
241 return snd_pcm_format_names[format];
242}
243
244static const char *snd_pcm_subformat_name(snd_pcm_subformat_t subformat) 245static const char *snd_pcm_subformat_name(snd_pcm_subformat_t subformat)
245{ 246{
246 return snd_pcm_subformat_names[subformat]; 247 return snd_pcm_subformat_names[subformat];
@@ -288,7 +289,6 @@ static const char *snd_pcm_oss_format_name(int format)
288} 289}
289#endif 290#endif
290 291
291#ifdef CONFIG_PROC_FS
292static void snd_pcm_proc_info_read(struct snd_pcm_substream *substream, 292static void snd_pcm_proc_info_read(struct snd_pcm_substream *substream,
293 struct snd_info_buffer *buffer) 293 struct snd_info_buffer *buffer)
294{ 294{
@@ -431,7 +431,6 @@ static void snd_pcm_substream_proc_status_read(struct snd_info_entry *entry,
431 snd_iprintf(buffer, "hw_ptr : %ld\n", runtime->status->hw_ptr); 431 snd_iprintf(buffer, "hw_ptr : %ld\n", runtime->status->hw_ptr);
432 snd_iprintf(buffer, "appl_ptr : %ld\n", runtime->control->appl_ptr); 432 snd_iprintf(buffer, "appl_ptr : %ld\n", runtime->control->appl_ptr);
433} 433}
434#endif
435 434
436#ifdef CONFIG_SND_DEBUG 435#ifdef CONFIG_SND_DEBUG
437static void snd_pcm_xrun_debug_read(struct snd_info_entry *entry, 436static void snd_pcm_xrun_debug_read(struct snd_info_entry *entry,
@@ -596,6 +595,12 @@ static int snd_pcm_substream_proc_done(struct snd_pcm_substream *substream)
596 } 595 }
597 return 0; 596 return 0;
598} 597}
598#else /* !CONFIG_PROC_FS */
599static inline int snd_pcm_stream_proc_init(struct snd_pcm_str *pstr) { return 0; }
600static inline int snd_pcm_stream_proc_done(struct snd_pcm_str *pstr) { return 0; }
601static inline int snd_pcm_substream_proc_init(struct snd_pcm_substream *substream) { return 0; }
602static inline int snd_pcm_substream_proc_done(struct snd_pcm_substream *substream) { return 0; }
603#endif /* CONFIG_PROC_FS */
599 604
600/** 605/**
601 * snd_pcm_new_stream - create a new PCM stream 606 * snd_pcm_new_stream - create a new PCM stream
@@ -1013,6 +1018,7 @@ int snd_pcm_notify(struct snd_pcm_notify *notify, int nfree)
1013 return 0; 1018 return 0;
1014} 1019}
1015 1020
1021#ifdef CONFIG_PROC_FS
1016/* 1022/*
1017 * Info interface 1023 * Info interface
1018 */ 1024 */
@@ -1039,18 +1045,12 @@ static void snd_pcm_proc_read(struct snd_info_entry *entry,
1039 up(&register_mutex); 1045 up(&register_mutex);
1040} 1046}
1041 1047
1042/*
1043 * ENTRY functions
1044 */
1045
1046static struct snd_info_entry *snd_pcm_proc_entry = NULL; 1048static struct snd_info_entry *snd_pcm_proc_entry = NULL;
1047 1049
1048static int __init alsa_pcm_init(void) 1050static void snd_pcm_proc_init(void)
1049{ 1051{
1050 struct snd_info_entry *entry; 1052 struct snd_info_entry *entry;
1051 1053
1052 snd_ctl_register_ioctl(snd_pcm_control_ioctl);
1053 snd_ctl_register_ioctl_compat(snd_pcm_control_ioctl);
1054 if ((entry = snd_info_create_module_entry(THIS_MODULE, "pcm", NULL)) != NULL) { 1054 if ((entry = snd_info_create_module_entry(THIS_MODULE, "pcm", NULL)) != NULL) {
1055 snd_info_set_text_ops(entry, NULL, SNDRV_CARDS * SNDRV_PCM_DEVICES * 128, 1055 snd_info_set_text_ops(entry, NULL, SNDRV_CARDS * SNDRV_PCM_DEVICES * 128,
1056 snd_pcm_proc_read); 1056 snd_pcm_proc_read);
@@ -1060,6 +1060,29 @@ static int __init alsa_pcm_init(void)
1060 } 1060 }
1061 } 1061 }
1062 snd_pcm_proc_entry = entry; 1062 snd_pcm_proc_entry = entry;
1063}
1064
1065static void snd_pcm_proc_done(void)
1066{
1067 if (snd_pcm_proc_entry)
1068 snd_info_unregister(snd_pcm_proc_entry);
1069}
1070
1071#else /* !CONFIG_PROC_FS */
1072#define snd_pcm_proc_init()
1073#define snd_pcm_proc_done()
1074#endif /* CONFIG_PROC_FS */
1075
1076
1077/*
1078 * ENTRY functions
1079 */
1080
1081static int __init alsa_pcm_init(void)
1082{
1083 snd_ctl_register_ioctl(snd_pcm_control_ioctl);
1084 snd_ctl_register_ioctl_compat(snd_pcm_control_ioctl);
1085 snd_pcm_proc_init();
1063 return 0; 1086 return 0;
1064} 1087}
1065 1088
@@ -1067,10 +1090,7 @@ static void __exit alsa_pcm_exit(void)
1067{ 1090{
1068 snd_ctl_unregister_ioctl(snd_pcm_control_ioctl); 1091 snd_ctl_unregister_ioctl(snd_pcm_control_ioctl);
1069 snd_ctl_unregister_ioctl_compat(snd_pcm_control_ioctl); 1092 snd_ctl_unregister_ioctl_compat(snd_pcm_control_ioctl);
1070 if (snd_pcm_proc_entry) { 1093 snd_pcm_proc_done();
1071 snd_info_unregister(snd_pcm_proc_entry);
1072 snd_pcm_proc_entry = NULL;
1073 }
1074} 1094}
1075 1095
1076module_init(alsa_pcm_init) 1096module_init(alsa_pcm_init)