2005-04-16 16:20:36 -06:00
|
|
|
/*
|
|
|
|
* Information interface for ALSA driver
|
2007-10-15 01:50:19 -06:00
|
|
|
* Copyright (c) by Jaroslav Kysela <perex@perex.cz>
|
2005-04-16 16:20:36 -06:00
|
|
|
*
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/slab.h>
|
|
|
|
#include <linux/time.h>
|
2005-06-23 01:09:02 -06:00
|
|
|
#include <linux/string.h>
|
2005-04-16 16:20:36 -06:00
|
|
|
#include <sound/core.h>
|
|
|
|
#include <sound/minors.h>
|
|
|
|
#include <sound/info.h>
|
|
|
|
#include <sound/version.h>
|
|
|
|
#include <linux/utsname.h>
|
2006-01-16 08:29:08 -07:00
|
|
|
#include <linux/mutex.h>
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
#if defined(CONFIG_SND_OSSEMUL) && defined(CONFIG_PROC_FS)
|
|
|
|
|
|
|
|
/*
|
|
|
|
* OSS compatible part
|
|
|
|
*/
|
|
|
|
|
2006-01-16 08:29:08 -07:00
|
|
|
static DEFINE_MUTEX(strings);
|
2005-04-16 16:20:36 -06:00
|
|
|
static char *snd_sndstat_strings[SNDRV_CARDS][SNDRV_OSS_INFO_DEV_COUNT];
|
2005-11-17 06:00:19 -07:00
|
|
|
static struct snd_info_entry *snd_sndstat_proc_entry;
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
int snd_oss_info_register(int dev, int num, char *string)
|
|
|
|
{
|
|
|
|
char *x;
|
|
|
|
|
|
|
|
snd_assert(dev >= 0 && dev < SNDRV_OSS_INFO_DEV_COUNT, return -ENXIO);
|
|
|
|
snd_assert(num >= 0 && num < SNDRV_CARDS, return -ENXIO);
|
2006-01-16 08:29:08 -07:00
|
|
|
mutex_lock(&strings);
|
2005-04-16 16:20:36 -06:00
|
|
|
if (string == NULL) {
|
|
|
|
if ((x = snd_sndstat_strings[num][dev]) != NULL) {
|
|
|
|
kfree(x);
|
|
|
|
x = NULL;
|
|
|
|
}
|
|
|
|
} else {
|
2005-06-23 01:09:02 -06:00
|
|
|
x = kstrdup(string, GFP_KERNEL);
|
2005-04-16 16:20:36 -06:00
|
|
|
if (x == NULL) {
|
2006-01-16 08:29:08 -07:00
|
|
|
mutex_unlock(&strings);
|
2005-04-16 16:20:36 -06:00
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
snd_sndstat_strings[num][dev] = x;
|
2006-01-16 08:29:08 -07:00
|
|
|
mutex_unlock(&strings);
|
2005-04-16 16:20:36 -06:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-04-28 07:13:39 -06:00
|
|
|
EXPORT_SYMBOL(snd_oss_info_register);
|
|
|
|
|
2005-11-17 06:00:19 -07:00
|
|
|
static int snd_sndstat_show_strings(struct snd_info_buffer *buf, char *id, int dev)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
|
|
|
int idx, ok = -1;
|
|
|
|
char *str;
|
|
|
|
|
|
|
|
snd_iprintf(buf, "\n%s:", id);
|
2006-01-16 08:29:08 -07:00
|
|
|
mutex_lock(&strings);
|
2005-04-16 16:20:36 -06:00
|
|
|
for (idx = 0; idx < SNDRV_CARDS; idx++) {
|
|
|
|
str = snd_sndstat_strings[idx][dev];
|
|
|
|
if (str) {
|
|
|
|
if (ok < 0) {
|
|
|
|
snd_iprintf(buf, "\n");
|
|
|
|
ok++;
|
|
|
|
}
|
|
|
|
snd_iprintf(buf, "%i: %s\n", idx, str);
|
|
|
|
}
|
|
|
|
}
|
2006-01-16 08:29:08 -07:00
|
|
|
mutex_unlock(&strings);
|
2005-04-16 16:20:36 -06:00
|
|
|
if (ok < 0)
|
|
|
|
snd_iprintf(buf, " NOT ENABLED IN CONFIG\n");
|
|
|
|
return ok;
|
|
|
|
}
|
|
|
|
|
2005-11-17 06:00:19 -07:00
|
|
|
static void snd_sndstat_proc_read(struct snd_info_entry *entry,
|
|
|
|
struct snd_info_buffer *buffer)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
|
|
|
snd_iprintf(buffer, "Sound Driver:3.8.1a-980706 (ALSA v" CONFIG_SND_VERSION " emulation code)\n");
|
|
|
|
snd_iprintf(buffer, "Kernel: %s %s %s %s %s\n",
|
2006-10-02 03:18:13 -06:00
|
|
|
init_utsname()->sysname,
|
|
|
|
init_utsname()->nodename,
|
|
|
|
init_utsname()->release,
|
|
|
|
init_utsname()->version,
|
|
|
|
init_utsname()->machine);
|
2005-04-16 16:20:36 -06:00
|
|
|
snd_iprintf(buffer, "Config options: 0\n");
|
|
|
|
snd_iprintf(buffer, "\nInstalled drivers: \n");
|
|
|
|
snd_iprintf(buffer, "Type 10: ALSA emulation\n");
|
|
|
|
snd_iprintf(buffer, "\nCard config: \n");
|
|
|
|
snd_card_info_read_oss(buffer);
|
|
|
|
snd_sndstat_show_strings(buffer, "Audio devices", SNDRV_OSS_INFO_DEV_AUDIO);
|
|
|
|
snd_sndstat_show_strings(buffer, "Synth devices", SNDRV_OSS_INFO_DEV_SYNTH);
|
|
|
|
snd_sndstat_show_strings(buffer, "Midi devices", SNDRV_OSS_INFO_DEV_MIDI);
|
|
|
|
snd_sndstat_show_strings(buffer, "Timers", SNDRV_OSS_INFO_DEV_TIMERS);
|
|
|
|
snd_sndstat_show_strings(buffer, "Mixers", SNDRV_OSS_INFO_DEV_MIXERS);
|
|
|
|
}
|
|
|
|
|
|
|
|
int snd_info_minor_register(void)
|
|
|
|
{
|
2005-11-17 06:00:19 -07:00
|
|
|
struct snd_info_entry *entry;
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
memset(snd_sndstat_strings, 0, sizeof(snd_sndstat_strings));
|
|
|
|
if ((entry = snd_info_create_module_entry(THIS_MODULE, "sndstat", snd_oss_root)) != NULL) {
|
|
|
|
entry->c.text.read = snd_sndstat_proc_read;
|
|
|
|
if (snd_info_register(entry) < 0) {
|
|
|
|
snd_info_free_entry(entry);
|
|
|
|
entry = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
snd_sndstat_proc_entry = entry;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int snd_info_minor_unregister(void)
|
|
|
|
{
|
2006-06-23 06:37:59 -06:00
|
|
|
snd_info_free_entry(snd_sndstat_proc_entry);
|
|
|
|
snd_sndstat_proc_entry = NULL;
|
2005-04-16 16:20:36 -06:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* CONFIG_SND_OSSEMUL */
|