aboutsummaryrefslogtreecommitdiffstats
path: root/sound/drivers/aloop.c
diff options
context:
space:
mode:
authorJaroslav Kysela <perex@perex.cz>2010-10-18 03:43:10 -0400
committerJaroslav Kysela <perex@perex.cz>2010-10-18 05:08:21 -0400
commite74670b6fdc37b15ebee11825849d8983e52a74a (patch)
tree33574e595b7e2dd8eba0e71b65dbce2b38e1ae33 /sound/drivers/aloop.c
parent0db710230589b5571c23f59250eabc9504b17c98 (diff)
ALSA: snd-aloop: add cable#0 and cable#1 files to proc card tree
Show some useful runtime information using procfs. Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Diffstat (limited to 'sound/drivers/aloop.c')
-rw-r--r--sound/drivers/aloop.c84
1 files changed, 84 insertions, 0 deletions
diff --git a/sound/drivers/aloop.c b/sound/drivers/aloop.c
index 838ad86311b8..66786ea6f480 100644
--- a/sound/drivers/aloop.c
+++ b/sound/drivers/aloop.c
@@ -39,6 +39,7 @@
39#include <sound/core.h> 39#include <sound/core.h>
40#include <sound/control.h> 40#include <sound/control.h>
41#include <sound/pcm.h> 41#include <sound/pcm.h>
42#include <sound/info.h>
42#include <sound/initval.h> 43#include <sound/initval.h>
43 44
44MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>"); 45MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>");
@@ -184,6 +185,7 @@ static void loopback_timer_start(struct loopback_pcm *dpcm)
184static inline void loopback_timer_stop(struct loopback_pcm *dpcm) 185static inline void loopback_timer_stop(struct loopback_pcm *dpcm)
185{ 186{
186 del_timer(&dpcm->timer); 187 del_timer(&dpcm->timer);
188 dpcm->timer.expires = 0;
187} 189}
188 190
189#define CABLE_VALID_PLAYBACK (1 << SNDRV_PCM_STREAM_PLAYBACK) 191#define CABLE_VALID_PLAYBACK (1 << SNDRV_PCM_STREAM_PLAYBACK)
@@ -1011,6 +1013,86 @@ static int __devinit loopback_mixer_new(struct loopback *loopback, int notify)
1011 return 0; 1013 return 0;
1012} 1014}
1013 1015
1016#ifdef CONFIG_PROC_FS
1017
1018static void print_dpcm_info(struct snd_info_buffer *buffer,
1019 struct loopback_pcm *dpcm,
1020 const char *id)
1021{
1022 snd_iprintf(buffer, " %s\n", id);
1023 if (dpcm == NULL) {
1024 snd_iprintf(buffer, " inactive\n");
1025 return;
1026 }
1027 snd_iprintf(buffer, " buffer_size:\t%u\n", dpcm->pcm_buffer_size);
1028 snd_iprintf(buffer, " buffer_pos:\t\t%u\n", dpcm->buf_pos);
1029 snd_iprintf(buffer, " silent_size:\t%u\n", dpcm->silent_size);
1030 snd_iprintf(buffer, " period_size:\t%u\n", dpcm->pcm_period_size);
1031 snd_iprintf(buffer, " bytes_per_sec:\t%u\n", dpcm->pcm_bps);
1032 snd_iprintf(buffer, " sample_align:\t%u\n", dpcm->pcm_salign);
1033 snd_iprintf(buffer, " rate_shift:\t\t%u\n", dpcm->pcm_rate_shift);
1034 snd_iprintf(buffer, " update_pending:\t%u\n",
1035 dpcm->period_update_pending);
1036 snd_iprintf(buffer, " irq_pos:\t\t%u\n", dpcm->irq_pos);
1037 snd_iprintf(buffer, " period_frac:\t%u\n", dpcm->period_size_frac);
1038 snd_iprintf(buffer, " last_jiffies:\t%lu (%lu)\n",
1039 dpcm->last_jiffies, jiffies);
1040 snd_iprintf(buffer, " timer_expires:\t%lu\n", dpcm->timer.expires);
1041}
1042
1043static void print_substream_info(struct snd_info_buffer *buffer,
1044 struct loopback *loopback,
1045 int sub,
1046 int num)
1047{
1048 struct loopback_cable *cable = loopback->cables[sub][num];
1049
1050 snd_iprintf(buffer, "Cable %i substream %i:\n", num, sub);
1051 if (cable == NULL) {
1052 snd_iprintf(buffer, " inactive\n");
1053 return;
1054 }
1055 snd_iprintf(buffer, " valid: %u\n", cable->valid);
1056 snd_iprintf(buffer, " running: %u\n", cable->running);
1057 print_dpcm_info(buffer, cable->streams[0], "Playback");
1058 print_dpcm_info(buffer, cable->streams[1], "Capture");
1059}
1060
1061static void print_cable_info(struct snd_info_entry *entry,
1062 struct snd_info_buffer *buffer)
1063{
1064 struct loopback *loopback = entry->private_data;
1065 int sub, num;
1066
1067 mutex_lock(&loopback->cable_lock);
1068 num = entry->name[strlen(entry->name)-1];
1069 num = num == '0' ? 0 : 1;
1070 for (sub = 0; sub < MAX_PCM_SUBSTREAMS; sub++)
1071 print_substream_info(buffer, loopback, sub, num);
1072 mutex_unlock(&loopback->cable_lock);
1073}
1074
1075static int __devinit loopback_proc_new(struct loopback *loopback, int cidx)
1076{
1077 char name[32];
1078 struct snd_info_entry *entry;
1079 int err;
1080
1081 snprintf(name, sizeof(name), "cable#%d", cidx);
1082 err = snd_card_proc_new(loopback->card, name, &entry);
1083 if (err < 0)
1084 return err;
1085
1086 snd_info_set_text_ops(entry, loopback, print_cable_info);
1087 return 0;
1088}
1089
1090#else /* !CONFIG_PROC_FS */
1091
1092#define loopback_proc_new(loopback, cidx) do { } while (0)
1093
1094#endif
1095
1014static int __devinit loopback_probe(struct platform_device *devptr) 1096static int __devinit loopback_probe(struct platform_device *devptr)
1015{ 1097{
1016 struct snd_card *card; 1098 struct snd_card *card;
@@ -1041,6 +1123,8 @@ static int __devinit loopback_probe(struct platform_device *devptr)
1041 err = loopback_mixer_new(loopback, pcm_notify[dev] ? 1 : 0); 1123 err = loopback_mixer_new(loopback, pcm_notify[dev] ? 1 : 0);
1042 if (err < 0) 1124 if (err < 0)
1043 goto __nodev; 1125 goto __nodev;
1126 loopback_proc_new(loopback, 0);
1127 loopback_proc_new(loopback, 1);
1044 strcpy(card->driver, "Loopback"); 1128 strcpy(card->driver, "Loopback");
1045 strcpy(card->shortname, "Loopback"); 1129 strcpy(card->shortname, "Loopback");
1046 sprintf(card->longname, "Loopback %i", dev + 1); 1130 sprintf(card->longname, "Loopback %i", dev + 1);