0001
0002
0003
0004
0005
0006
0007 #include <linux/slab.h>
0008 #include <linux/time.h>
0009 #include <linux/string.h>
0010 #include <linux/export.h>
0011 #include <sound/core.h>
0012 #include <sound/minors.h>
0013 #include <sound/info.h>
0014 #include <linux/utsname.h>
0015 #include <linux/mutex.h>
0016
0017
0018
0019
0020
0021 static DEFINE_MUTEX(strings);
0022 static char *snd_sndstat_strings[SNDRV_CARDS][SNDRV_OSS_INFO_DEV_COUNT];
0023
0024 int snd_oss_info_register(int dev, int num, char *string)
0025 {
0026 char *x;
0027
0028 if (snd_BUG_ON(dev < 0 || dev >= SNDRV_OSS_INFO_DEV_COUNT))
0029 return -ENXIO;
0030 if (snd_BUG_ON(num < 0 || num >= SNDRV_CARDS))
0031 return -ENXIO;
0032 mutex_lock(&strings);
0033 if (string == NULL) {
0034 x = snd_sndstat_strings[num][dev];
0035 kfree(x);
0036 x = NULL;
0037 } else {
0038 x = kstrdup(string, GFP_KERNEL);
0039 if (x == NULL) {
0040 mutex_unlock(&strings);
0041 return -ENOMEM;
0042 }
0043 }
0044 snd_sndstat_strings[num][dev] = x;
0045 mutex_unlock(&strings);
0046 return 0;
0047 }
0048 EXPORT_SYMBOL(snd_oss_info_register);
0049
0050 static int snd_sndstat_show_strings(struct snd_info_buffer *buf, char *id, int dev)
0051 {
0052 int idx, ok = -1;
0053 char *str;
0054
0055 snd_iprintf(buf, "\n%s:", id);
0056 mutex_lock(&strings);
0057 for (idx = 0; idx < SNDRV_CARDS; idx++) {
0058 str = snd_sndstat_strings[idx][dev];
0059 if (str) {
0060 if (ok < 0) {
0061 snd_iprintf(buf, "\n");
0062 ok++;
0063 }
0064 snd_iprintf(buf, "%i: %s\n", idx, str);
0065 }
0066 }
0067 mutex_unlock(&strings);
0068 if (ok < 0)
0069 snd_iprintf(buf, " NOT ENABLED IN CONFIG\n");
0070 return ok;
0071 }
0072
0073 static void snd_sndstat_proc_read(struct snd_info_entry *entry,
0074 struct snd_info_buffer *buffer)
0075 {
0076 snd_iprintf(buffer, "Sound Driver:3.8.1a-980706 (ALSA emulation code)\n");
0077 snd_iprintf(buffer, "Kernel: %s %s %s %s %s\n",
0078 init_utsname()->sysname,
0079 init_utsname()->nodename,
0080 init_utsname()->release,
0081 init_utsname()->version,
0082 init_utsname()->machine);
0083 snd_iprintf(buffer, "Config options: 0\n");
0084 snd_iprintf(buffer, "\nInstalled drivers: \n");
0085 snd_iprintf(buffer, "Type 10: ALSA emulation\n");
0086 snd_iprintf(buffer, "\nCard config: \n");
0087 snd_card_info_read_oss(buffer);
0088 snd_sndstat_show_strings(buffer, "Audio devices", SNDRV_OSS_INFO_DEV_AUDIO);
0089 snd_sndstat_show_strings(buffer, "Synth devices", SNDRV_OSS_INFO_DEV_SYNTH);
0090 snd_sndstat_show_strings(buffer, "Midi devices", SNDRV_OSS_INFO_DEV_MIDI);
0091 snd_sndstat_show_strings(buffer, "Timers", SNDRV_OSS_INFO_DEV_TIMERS);
0092 snd_sndstat_show_strings(buffer, "Mixers", SNDRV_OSS_INFO_DEV_MIXERS);
0093 }
0094
0095 int __init snd_info_minor_register(void)
0096 {
0097 struct snd_info_entry *entry;
0098
0099 memset(snd_sndstat_strings, 0, sizeof(snd_sndstat_strings));
0100 entry = snd_info_create_module_entry(THIS_MODULE, "sndstat",
0101 snd_oss_root);
0102 if (!entry)
0103 return -ENOMEM;
0104 entry->c.text.read = snd_sndstat_proc_read;
0105 return snd_info_register(entry);
0106 }