Blame view

sound/core/info_oss.c 3.53 KB
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1
2
  /*
   *  Information interface for ALSA driver
c1017a4cd   Jaroslav Kysela   [ALSA] Changed Ja...
3
   *  Copyright (c) by Jaroslav Kysela <perex@perex.cz>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
   *
   *
   *   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
   *
   */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
21
22
  #include <linux/slab.h>
  #include <linux/time.h>
543537bd9   Paulo Marques   [PATCH] create a ...
23
  #include <linux/string.h>
d81a6d717   Paul Gortmaker   sound: Add export...
24
  #include <linux/export.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
25
26
27
  #include <sound/core.h>
  #include <sound/minors.h>
  #include <sound/info.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
28
  #include <linux/utsname.h>
1a60d4c5a   Ingo Molnar   [ALSA] semaphore ...
29
  #include <linux/mutex.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
30

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
31
32
33
  /*
   *  OSS compatible part
   */
1a60d4c5a   Ingo Molnar   [ALSA] semaphore ...
34
  static DEFINE_MUTEX(strings);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
35
  static char *snd_sndstat_strings[SNDRV_CARDS][SNDRV_OSS_INFO_DEV_COUNT];
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
36
37
38
39
  
  int snd_oss_info_register(int dev, int num, char *string)
  {
  	char *x;
7eaa943c8   Takashi Iwai   ALSA: Kill snd_as...
40
41
42
43
  	if (snd_BUG_ON(dev < 0 || dev >= SNDRV_OSS_INFO_DEV_COUNT))
  		return -ENXIO;
  	if (snd_BUG_ON(num < 0 || num >= SNDRV_CARDS))
  		return -ENXIO;
1a60d4c5a   Ingo Molnar   [ALSA] semaphore ...
44
  	mutex_lock(&strings);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
45
46
47
48
49
50
  	if (string == NULL) {
  		if ((x = snd_sndstat_strings[num][dev]) != NULL) {
  			kfree(x);
  			x = NULL;
  		}
  	} else {
543537bd9   Paulo Marques   [PATCH] create a ...
51
  		x = kstrdup(string, GFP_KERNEL);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
52
  		if (x == NULL) {
1a60d4c5a   Ingo Molnar   [ALSA] semaphore ...
53
  			mutex_unlock(&strings);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
54
55
56
57
  			return -ENOMEM;
  		}
  	}
  	snd_sndstat_strings[num][dev] = x;
1a60d4c5a   Ingo Molnar   [ALSA] semaphore ...
58
  	mutex_unlock(&strings);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
59
60
  	return 0;
  }
c0d3fb39e   Takashi Iwai   [ALSA] Clean up E...
61
  EXPORT_SYMBOL(snd_oss_info_register);
174c1f65e   Takashi Iwai   [ALSA] Remove xxx...
62
  static int snd_sndstat_show_strings(struct snd_info_buffer *buf, char *id, int dev)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
63
64
65
66
67
68
  {
  	int idx, ok = -1;
  	char *str;
  
  	snd_iprintf(buf, "
  %s:", id);
1a60d4c5a   Ingo Molnar   [ALSA] semaphore ...
69
  	mutex_lock(&strings);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
70
71
72
73
74
75
76
77
78
79
80
81
  	for (idx = 0; idx < SNDRV_CARDS; idx++) {
  		str = snd_sndstat_strings[idx][dev];
  		if (str) {
  			if (ok < 0) {
  				snd_iprintf(buf, "
  ");
  				ok++;
  			}
  			snd_iprintf(buf, "%i: %s
  ", idx, str);
  		}
  	}
1a60d4c5a   Ingo Molnar   [ALSA] semaphore ...
82
  	mutex_unlock(&strings);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
83
84
85
86
87
  	if (ok < 0)
  		snd_iprintf(buf, " NOT ENABLED IN CONFIG
  ");
  	return ok;
  }
174c1f65e   Takashi Iwai   [ALSA] Remove xxx...
88
89
  static void snd_sndstat_proc_read(struct snd_info_entry *entry,
  				  struct snd_info_buffer *buffer)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
90
  {
426627483   Jaroslav Kysela   ALSA: remove the ...
91
92
  	snd_iprintf(buffer, "Sound Driver:3.8.1a-980706 (ALSA emulation code)
  ");
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
93
94
  	snd_iprintf(buffer, "Kernel: %s %s %s %s %s
  ",
96b644bde   Serge E. Hallyn   [PATCH] namespace...
95
96
97
98
99
  		    init_utsname()->sysname,
  		    init_utsname()->nodename,
  		    init_utsname()->release,
  		    init_utsname()->version,
  		    init_utsname()->machine);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
  	snd_iprintf(buffer, "Config options: 0
  ");
  	snd_iprintf(buffer, "
  Installed drivers: 
  ");
  	snd_iprintf(buffer, "Type 10: ALSA emulation
  ");
  	snd_iprintf(buffer, "
  Card config: 
  ");
  	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);
  }
a0dca822e   Takashi Iwai   ALSA: core: Clean...
117
  int __init snd_info_minor_register(void)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
118
  {
174c1f65e   Takashi Iwai   [ALSA] Remove xxx...
119
  	struct snd_info_entry *entry;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
120
121
  
  	memset(snd_sndstat_strings, 0, sizeof(snd_sndstat_strings));
a0dca822e   Takashi Iwai   ALSA: core: Clean...
122
123
124
125
126
127
  	entry = snd_info_create_module_entry(THIS_MODULE, "sndstat",
  					     snd_oss_root);
  	if (!entry)
  		return -ENOMEM;
  	entry->c.text.read = snd_sndstat_proc_read;
  	return snd_info_register(entry); /* freed in error path */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
128
  }