Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | #ifndef __SOUND_INFO_H |
2 | #define __SOUND_INFO_H | |
3 | ||
4 | /* | |
5 | * Header file for info interface | |
c1017a4c | 6 | * Copyright (c) by Jaroslav Kysela <perex@perex.cz> |
1da177e4 LT |
7 | * |
8 | * | |
9 | * This program is free software; you can redistribute it and/or modify | |
10 | * it under the terms of the GNU General Public License as published by | |
11 | * the Free Software Foundation; either version 2 of the License, or | |
12 | * (at your option) any later version. | |
13 | * | |
14 | * This program is distributed in the hope that it will be useful, | |
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | * GNU General Public License for more details. | |
18 | * | |
19 | * You should have received a copy of the GNU General Public License | |
20 | * along with this program; if not, write to the Free Software | |
21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
22 | * | |
23 | */ | |
24 | ||
25 | #include <linux/poll.h> | |
4adb7bcb | 26 | #include <linux/seq_file.h> |
c560a679 | 27 | #include <sound/core.h> |
1da177e4 LT |
28 | |
29 | /* buffer for information */ | |
30 | struct snd_info_buffer { | |
31 | char *buffer; /* pointer to begin of buffer */ | |
7e4eeec8 TI |
32 | unsigned int curr; /* current position in buffer */ |
33 | unsigned int size; /* current size */ | |
34 | unsigned int len; /* total length of buffer */ | |
1da177e4 LT |
35 | int stop; /* stop flag */ |
36 | int error; /* error code */ | |
37 | }; | |
38 | ||
1da177e4 LT |
39 | #define SNDRV_INFO_CONTENT_TEXT 0 |
40 | #define SNDRV_INFO_CONTENT_DATA 1 | |
41 | ||
42 | struct snd_info_entry; | |
43 | ||
44 | struct snd_info_entry_text { | |
fd64138c JK |
45 | void (*read)(struct snd_info_entry *entry, |
46 | struct snd_info_buffer *buffer); | |
47 | void (*write)(struct snd_info_entry *entry, | |
48 | struct snd_info_buffer *buffer); | |
1da177e4 LT |
49 | }; |
50 | ||
51 | struct snd_info_entry_ops { | |
fd64138c JK |
52 | int (*open)(struct snd_info_entry *entry, |
53 | unsigned short mode, void **file_private_data); | |
54 | int (*release)(struct snd_info_entry *entry, | |
55 | unsigned short mode, void *file_private_data); | |
24e4a121 TI |
56 | ssize_t (*read)(struct snd_info_entry *entry, void *file_private_data, |
57 | struct file *file, char __user *buf, | |
58 | size_t count, loff_t pos); | |
59 | ssize_t (*write)(struct snd_info_entry *entry, void *file_private_data, | |
60 | struct file *file, const char __user *buf, | |
61 | size_t count, loff_t pos); | |
62 | loff_t (*llseek)(struct snd_info_entry *entry, | |
63 | void *file_private_data, struct file *file, | |
64 | loff_t offset, int orig); | |
65 | unsigned int (*poll)(struct snd_info_entry *entry, | |
66 | void *file_private_data, struct file *file, | |
67 | poll_table *wait); | |
fd64138c JK |
68 | int (*ioctl)(struct snd_info_entry *entry, void *file_private_data, |
69 | struct file *file, unsigned int cmd, unsigned long arg); | |
70 | int (*mmap)(struct snd_info_entry *entry, void *file_private_data, | |
71 | struct inode *inode, struct file *file, | |
72 | struct vm_area_struct *vma); | |
1da177e4 LT |
73 | }; |
74 | ||
75 | struct snd_info_entry { | |
76 | const char *name; | |
d161a13f | 77 | umode_t mode; |
1da177e4 LT |
78 | long size; |
79 | unsigned short content; | |
1da177e4 LT |
80 | union { |
81 | struct snd_info_entry_text text; | |
82 | struct snd_info_entry_ops *ops; | |
83 | } c; | |
24c1f931 TI |
84 | struct snd_info_entry *parent; |
85 | struct snd_card *card; | |
1da177e4 LT |
86 | struct module *module; |
87 | void *private_data; | |
24c1f931 | 88 | void (*private_free)(struct snd_info_entry *entry); |
1da177e4 | 89 | struct proc_dir_entry *p; |
1a60d4c5 | 90 | struct mutex access; |
746d4a02 TI |
91 | struct list_head children; |
92 | struct list_head list; | |
1da177e4 LT |
93 | }; |
94 | ||
cd6a6503 | 95 | #if defined(CONFIG_SND_OSSEMUL) && defined(CONFIG_SND_PROC_FS) |
24c1f931 | 96 | int snd_info_minor_register(void); |
1da177e4 | 97 | #else |
a0dca822 | 98 | #define snd_info_minor_register() 0 |
1da177e4 LT |
99 | #endif |
100 | ||
101 | ||
cd6a6503 | 102 | #ifdef CONFIG_SND_PROC_FS |
1da177e4 | 103 | |
24c1f931 | 104 | extern struct snd_info_entry *snd_seq_root; |
1da177e4 | 105 | #ifdef CONFIG_SND_OSSEMUL |
24c1f931 | 106 | extern struct snd_info_entry *snd_oss_root; |
36b9cdfe | 107 | void snd_card_info_read_oss(struct snd_info_buffer *buffer); |
1da177e4 LT |
108 | #else |
109 | #define snd_oss_root NULL | |
36b9cdfe | 110 | static inline void snd_card_info_read_oss(struct snd_info_buffer *buffer) {} |
1da177e4 LT |
111 | #endif |
112 | ||
4adb7bcb TI |
113 | /** |
114 | * snd_iprintf - printf on the procfs buffer | |
115 | * @buf: the procfs buffer | |
116 | * @fmt: the printf format | |
117 | * | |
118 | * Outputs the string on the procfs buffer just like printf(). | |
119 | * | |
120 | * Return: zero for success, or a negative error code. | |
121 | */ | |
122 | #define snd_iprintf(buf, fmt, args...) \ | |
123 | seq_printf((struct seq_file *)(buf)->buffer, fmt, ##args) | |
124 | ||
1da177e4 LT |
125 | int snd_info_init(void); |
126 | int snd_info_done(void); | |
127 | ||
fd64138c | 128 | int snd_info_get_line(struct snd_info_buffer *buffer, char *line, int len); |
4f7454a9 | 129 | const char *snd_info_get_str(char *dest, const char *src, int len); |
fd64138c | 130 | struct snd_info_entry *snd_info_create_module_entry(struct module *module, |
1da177e4 | 131 | const char *name, |
fd64138c JK |
132 | struct snd_info_entry *parent); |
133 | struct snd_info_entry *snd_info_create_card_entry(struct snd_card *card, | |
1da177e4 | 134 | const char *name, |
fd64138c JK |
135 | struct snd_info_entry *parent); |
136 | void snd_info_free_entry(struct snd_info_entry *entry); | |
137 | int snd_info_store_text(struct snd_info_entry *entry); | |
138 | int snd_info_restore_text(struct snd_info_entry *entry); | |
139 | ||
140 | int snd_info_card_create(struct snd_card *card); | |
141 | int snd_info_card_register(struct snd_card *card); | |
142 | int snd_info_card_free(struct snd_card *card); | |
143 | void snd_info_card_disconnect(struct snd_card *card); | |
144 | void snd_info_card_id_change(struct snd_card *card); | |
145 | int snd_info_register(struct snd_info_entry *entry); | |
1da177e4 LT |
146 | |
147 | /* for card drivers */ | |
c560a679 TI |
148 | static inline int snd_card_proc_new(struct snd_card *card, const char *name, |
149 | struct snd_info_entry **entryp) | |
150 | { | |
151 | *entryp = snd_info_create_card_entry(card, name, card->proc_root); | |
152 | return *entryp ? 0 : -ENOMEM; | |
153 | } | |
1da177e4 | 154 | |
24c1f931 | 155 | static inline void snd_info_set_text_ops(struct snd_info_entry *entry, |
fd64138c JK |
156 | void *private_data, |
157 | void (*read)(struct snd_info_entry *, struct snd_info_buffer *)) | |
1da177e4 LT |
158 | { |
159 | entry->private_data = private_data; | |
1da177e4 LT |
160 | entry->c.text.read = read; |
161 | } | |
162 | ||
e28563cc | 163 | int snd_info_check_reserved_words(const char *str); |
1da177e4 LT |
164 | |
165 | #else | |
166 | ||
167 | #define snd_seq_root NULL | |
168 | #define snd_oss_root NULL | |
169 | ||
fd64138c | 170 | static inline int snd_iprintf(struct snd_info_buffer *buffer, char *fmt, ...) { return 0; } |
1da177e4 LT |
171 | static inline int snd_info_init(void) { return 0; } |
172 | static inline int snd_info_done(void) { return 0; } | |
173 | ||
fd64138c | 174 | static inline int snd_info_get_line(struct snd_info_buffer *buffer, char *line, int len) { return 0; } |
1da177e4 | 175 | static inline char *snd_info_get_str(char *dest, char *src, int len) { return NULL; } |
fd64138c JK |
176 | static inline struct snd_info_entry *snd_info_create_module_entry(struct module *module, const char *name, struct snd_info_entry *parent) { return NULL; } |
177 | 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; } | |
178 | static inline void snd_info_free_entry(struct snd_info_entry *entry) { ; } | |
179 | ||
180 | static inline int snd_info_card_create(struct snd_card *card) { return 0; } | |
181 | static inline int snd_info_card_register(struct snd_card *card) { return 0; } | |
182 | static inline int snd_info_card_free(struct snd_card *card) { return 0; } | |
183 | static inline void snd_info_card_disconnect(struct snd_card *card) { } | |
184 | static inline void snd_info_card_id_change(struct snd_card *card) { } | |
185 | static inline int snd_info_register(struct snd_info_entry *entry) { return 0; } | |
1da177e4 | 186 | |
e28563cc TI |
187 | static inline int snd_card_proc_new(struct snd_card *card, const char *name, |
188 | struct snd_info_entry **entryp) { return -EINVAL; } | |
189 | static inline void snd_info_set_text_ops(struct snd_info_entry *entry __attribute__((unused)), | |
190 | void *private_data, | |
e28563cc | 191 | void (*read)(struct snd_info_entry *, struct snd_info_buffer *)) {} |
e28563cc | 192 | static inline int snd_info_check_reserved_words(const char *str) { return 1; } |
1da177e4 LT |
193 | |
194 | #endif | |
195 | ||
196 | /* | |
197 | * OSS info part | |
198 | */ | |
199 | ||
cd6a6503 | 200 | #if defined(CONFIG_SND_OSSEMUL) && defined(CONFIG_SND_PROC_FS) |
1da177e4 LT |
201 | |
202 | #define SNDRV_OSS_INFO_DEV_AUDIO 0 | |
203 | #define SNDRV_OSS_INFO_DEV_SYNTH 1 | |
204 | #define SNDRV_OSS_INFO_DEV_MIDI 2 | |
205 | #define SNDRV_OSS_INFO_DEV_TIMERS 4 | |
206 | #define SNDRV_OSS_INFO_DEV_MIXERS 5 | |
207 | ||
208 | #define SNDRV_OSS_INFO_DEV_COUNT 6 | |
209 | ||
24c1f931 | 210 | int snd_oss_info_register(int dev, int num, char *string); |
1da177e4 LT |
211 | #define snd_oss_info_unregister(dev, num) snd_oss_info_register(dev, num, NULL) |
212 | ||
cd6a6503 | 213 | #endif /* CONFIG_SND_OSSEMUL && CONFIG_SND_PROC_FS */ |
1da177e4 LT |
214 | |
215 | #endif /* __SOUND_INFO_H */ |