Blame view

include/sound/info.h 7.41 KB
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1
2
3
4
5
  #ifndef __SOUND_INFO_H
  #define __SOUND_INFO_H
  
  /*
   *  Header file for info interface
c1017a4cd   Jaroslav Kysela   [ALSA] Changed Ja...
6
   *  Copyright (c) by Jaroslav Kysela <perex@perex.cz>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
   *
   *
   *   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/poll.h>
4adb7bcbc   Takashi Iwai   ALSA: core: Use s...
26
  #include <linux/seq_file.h>
c560a6797   Takashi Iwai   ALSA: core: Remov...
27
  #include <sound/core.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
28
29
30
31
  
  /* buffer for information */
  struct snd_info_buffer {
  	char *buffer;		/* pointer to begin of buffer */
7e4eeec8a   Takashi Iwai   [ALSA] Make buffe...
32
33
34
  	unsigned int curr;	/* current position in buffer */
  	unsigned int size;	/* current size */
  	unsigned int len;	/* total length of buffer */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
35
36
37
  	int stop;		/* stop flag */
  	int error;		/* error code */
  };
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
38
39
40
41
42
43
  #define SNDRV_INFO_CONTENT_TEXT		0
  #define SNDRV_INFO_CONTENT_DATA		1
  
  struct snd_info_entry;
  
  struct snd_info_entry_text {
fd64138c0   Jaroslav Kysela   ALSA: include/sou...
44
45
46
47
  	void (*read)(struct snd_info_entry *entry,
  		     struct snd_info_buffer *buffer);
  	void (*write)(struct snd_info_entry *entry,
  		      struct snd_info_buffer *buffer);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
48
49
50
  };
  
  struct snd_info_entry_ops {
fd64138c0   Jaroslav Kysela   ALSA: include/sou...
51
52
53
54
  	int (*open)(struct snd_info_entry *entry,
  		    unsigned short mode, void **file_private_data);
  	int (*release)(struct snd_info_entry *entry,
  		       unsigned short mode, void *file_private_data);
24e4a1211   Takashi Iwai   ALSA: info - Use ...
55
56
57
58
59
60
61
62
63
64
65
66
  	ssize_t (*read)(struct snd_info_entry *entry, void *file_private_data,
  			struct file *file, char __user *buf,
  			size_t count, loff_t pos);
  	ssize_t (*write)(struct snd_info_entry *entry, void *file_private_data,
  			 struct file *file, const char __user *buf,
  			 size_t count, loff_t pos);
  	loff_t (*llseek)(struct snd_info_entry *entry,
  			 void *file_private_data, struct file *file,
  			 loff_t offset, int orig);
  	unsigned int (*poll)(struct snd_info_entry *entry,
  			     void *file_private_data, struct file *file,
  			     poll_table *wait);
fd64138c0   Jaroslav Kysela   ALSA: include/sou...
67
68
69
70
71
  	int (*ioctl)(struct snd_info_entry *entry, void *file_private_data,
  		     struct file *file, unsigned int cmd, unsigned long arg);
  	int (*mmap)(struct snd_info_entry *entry, void *file_private_data,
  		    struct inode *inode, struct file *file,
  		    struct vm_area_struct *vma);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
72
73
74
75
  };
  
  struct snd_info_entry {
  	const char *name;
d161a13f9   Al Viro   switch procfs to ...
76
  	umode_t mode;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
77
78
  	long size;
  	unsigned short content;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
79
80
81
82
  	union {
  		struct snd_info_entry_text text;
  		struct snd_info_entry_ops *ops;
  	} c;
24c1f9318   Takashi Iwai   [ALSA] Remove xxx...
83
84
  	struct snd_info_entry *parent;
  	struct snd_card *card;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
85
86
  	struct module *module;
  	void *private_data;
24c1f9318   Takashi Iwai   [ALSA] Remove xxx...
87
  	void (*private_free)(struct snd_info_entry *entry);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
88
  	struct proc_dir_entry *p;
1a60d4c5a   Ingo Molnar   [ALSA] semaphore ...
89
  	struct mutex access;
746d4a02e   Takashi Iwai   [ALSA] Fix discon...
90
91
  	struct list_head children;
  	struct list_head list;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
92
  };
cd6a65036   Jie Yang   ALSA: replace CON...
93
  #if defined(CONFIG_SND_OSSEMUL) && defined(CONFIG_SND_PROC_FS)
24c1f9318   Takashi Iwai   [ALSA] Remove xxx...
94
  int snd_info_minor_register(void);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
95
  #else
a0dca822e   Takashi Iwai   ALSA: core: Clean...
96
  #define snd_info_minor_register()	0
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
97
  #endif
cd6a65036   Jie Yang   ALSA: replace CON...
98
  #ifdef CONFIG_SND_PROC_FS
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
99

24c1f9318   Takashi Iwai   [ALSA] Remove xxx...
100
  extern struct snd_info_entry *snd_seq_root;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
101
  #ifdef CONFIG_SND_OSSEMUL
24c1f9318   Takashi Iwai   [ALSA] Remove xxx...
102
  extern struct snd_info_entry *snd_oss_root;
36b9cdfea   Marcin Ślusarz   [ALSA] info_oss: ...
103
  void snd_card_info_read_oss(struct snd_info_buffer *buffer);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
104
105
  #else
  #define snd_oss_root NULL
36b9cdfea   Marcin Ślusarz   [ALSA] info_oss: ...
106
  static inline void snd_card_info_read_oss(struct snd_info_buffer *buffer) {}
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
107
  #endif
4adb7bcbc   Takashi Iwai   ALSA: core: Use s...
108
109
110
111
112
113
114
115
116
117
118
  /**
   * snd_iprintf - printf on the procfs buffer
   * @buf: the procfs buffer
   * @fmt: the printf format
   *
   * Outputs the string on the procfs buffer just like printf().
   *
   * Return: zero for success, or a negative error code.
   */
  #define snd_iprintf(buf, fmt, args...) \
  	seq_printf((struct seq_file *)(buf)->buffer, fmt, ##args)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
119
120
  int snd_info_init(void);
  int snd_info_done(void);
fd64138c0   Jaroslav Kysela   ALSA: include/sou...
121
  int snd_info_get_line(struct snd_info_buffer *buffer, char *line, int len);
4f7454a99   Takashi Iwai   ALSA: Add const p...
122
  const char *snd_info_get_str(char *dest, const char *src, int len);
fd64138c0   Jaroslav Kysela   ALSA: include/sou...
123
  struct snd_info_entry *snd_info_create_module_entry(struct module *module,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
124
  					       const char *name,
fd64138c0   Jaroslav Kysela   ALSA: include/sou...
125
126
  					       struct snd_info_entry *parent);
  struct snd_info_entry *snd_info_create_card_entry(struct snd_card *card,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
127
  					     const char *name,
fd64138c0   Jaroslav Kysela   ALSA: include/sou...
128
129
130
131
132
133
134
135
136
137
138
  					     struct snd_info_entry *parent);
  void snd_info_free_entry(struct snd_info_entry *entry);
  int snd_info_store_text(struct snd_info_entry *entry);
  int snd_info_restore_text(struct snd_info_entry *entry);
  
  int snd_info_card_create(struct snd_card *card);
  int snd_info_card_register(struct snd_card *card);
  int snd_info_card_free(struct snd_card *card);
  void snd_info_card_disconnect(struct snd_card *card);
  void snd_info_card_id_change(struct snd_card *card);
  int snd_info_register(struct snd_info_entry *entry);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
139
140
  
  /* for card drivers */
c560a6797   Takashi Iwai   ALSA: core: Remov...
141
142
143
144
145
146
  static inline int snd_card_proc_new(struct snd_card *card, const char *name,
  				    struct snd_info_entry **entryp)
  {
  	*entryp = snd_info_create_card_entry(card, name, card->proc_root);
  	return *entryp ? 0 : -ENOMEM;
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
147

24c1f9318   Takashi Iwai   [ALSA] Remove xxx...
148
  static inline void snd_info_set_text_ops(struct snd_info_entry *entry, 
fd64138c0   Jaroslav Kysela   ALSA: include/sou...
149
150
  	void *private_data,
  	void (*read)(struct snd_info_entry *, struct snd_info_buffer *))
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
151
152
  {
  	entry->private_data = private_data;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
153
154
  	entry->c.text.read = read;
  }
e28563cce   Takashi Iwai   [ALSA] Optimize f...
155
  int snd_info_check_reserved_words(const char *str);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
156
157
158
159
160
  
  #else
  
  #define snd_seq_root NULL
  #define snd_oss_root NULL
fd64138c0   Jaroslav Kysela   ALSA: include/sou...
161
  static inline int snd_iprintf(struct snd_info_buffer *buffer, char *fmt, ...) { return 0; }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
162
163
  static inline int snd_info_init(void) { return 0; }
  static inline int snd_info_done(void) { return 0; }
fd64138c0   Jaroslav Kysela   ALSA: include/sou...
164
  static inline int snd_info_get_line(struct snd_info_buffer *buffer, char *line, int len) { return 0; }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
165
  static inline char *snd_info_get_str(char *dest, char *src, int len) { return NULL; }
fd64138c0   Jaroslav Kysela   ALSA: include/sou...
166
167
168
169
170
171
172
173
174
175
  static inline struct snd_info_entry *snd_info_create_module_entry(struct module *module, const char *name, struct snd_info_entry *parent) { return NULL; }
  static inline struct snd_info_entry *snd_info_create_card_entry(struct snd_card *card, const char *name, struct snd_info_entry *parent) { return NULL; }
  static inline void snd_info_free_entry(struct snd_info_entry *entry) { ; }
  
  static inline int snd_info_card_create(struct snd_card *card) { return 0; }
  static inline int snd_info_card_register(struct snd_card *card) { return 0; }
  static inline int snd_info_card_free(struct snd_card *card) { return 0; }
  static inline void snd_info_card_disconnect(struct snd_card *card) { }
  static inline void snd_info_card_id_change(struct snd_card *card) { }
  static inline int snd_info_register(struct snd_info_entry *entry) { return 0; }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
176

e28563cce   Takashi Iwai   [ALSA] Optimize f...
177
178
179
180
  static inline int snd_card_proc_new(struct snd_card *card, const char *name,
  				    struct snd_info_entry **entryp) { return -EINVAL; }
  static inline void snd_info_set_text_ops(struct snd_info_entry *entry __attribute__((unused)),
  					 void *private_data,
e28563cce   Takashi Iwai   [ALSA] Optimize f...
181
  					 void (*read)(struct snd_info_entry *, struct snd_info_buffer *)) {}
e28563cce   Takashi Iwai   [ALSA] Optimize f...
182
  static inline int snd_info_check_reserved_words(const char *str) { return 1; }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
183
184
185
186
187
188
  
  #endif
  
  /*
   * OSS info part
   */
cd6a65036   Jie Yang   ALSA: replace CON...
189
  #if defined(CONFIG_SND_OSSEMUL) && defined(CONFIG_SND_PROC_FS)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
190
191
192
193
194
195
196
197
  
  #define SNDRV_OSS_INFO_DEV_AUDIO	0
  #define SNDRV_OSS_INFO_DEV_SYNTH	1
  #define SNDRV_OSS_INFO_DEV_MIDI		2
  #define SNDRV_OSS_INFO_DEV_TIMERS	4
  #define SNDRV_OSS_INFO_DEV_MIXERS	5
  
  #define SNDRV_OSS_INFO_DEV_COUNT	6
24c1f9318   Takashi Iwai   [ALSA] Remove xxx...
198
  int snd_oss_info_register(int dev, int num, char *string);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
199
  #define snd_oss_info_unregister(dev, num) snd_oss_info_register(dev, num, NULL)
cd6a65036   Jie Yang   ALSA: replace CON...
200
  #endif /* CONFIG_SND_OSSEMUL && CONFIG_SND_PROC_FS */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
201
202
  
  #endif /* __SOUND_INFO_H */