blob: 4e94cf1ff7621c65b83560eb5eb9fc428b23fef0 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef __SOUND_INFO_H
2#define __SOUND_INFO_H
3
4/*
5 * Header file for info interface
Jaroslav Kyselac1017a42007-10-15 09:50:19 +02006 * Copyright (c) by Jaroslav Kysela <perex@perex.cz>
Linus Torvalds1da177e2005-04-16 15:20:36 -07007 *
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>
26
27/* buffer for information */
28struct snd_info_buffer {
29 char *buffer; /* pointer to begin of buffer */
Takashi Iwai7e4eeec2006-04-28 15:13:40 +020030 unsigned int curr; /* current position in buffer */
31 unsigned int size; /* current size */
32 unsigned int len; /* total length of buffer */
Linus Torvalds1da177e2005-04-16 15:20:36 -070033 int stop; /* stop flag */
34 int error; /* error code */
35};
36
Linus Torvalds1da177e2005-04-16 15:20:36 -070037#define SNDRV_INFO_CONTENT_TEXT 0
38#define SNDRV_INFO_CONTENT_DATA 1
39
40struct snd_info_entry;
41
42struct snd_info_entry_text {
Jaroslav Kyselafd641382008-11-12 16:53:47 +010043 void (*read)(struct snd_info_entry *entry,
44 struct snd_info_buffer *buffer);
45 void (*write)(struct snd_info_entry *entry,
46 struct snd_info_buffer *buffer);
Linus Torvalds1da177e2005-04-16 15:20:36 -070047};
48
49struct snd_info_entry_ops {
Jaroslav Kyselafd641382008-11-12 16:53:47 +010050 int (*open)(struct snd_info_entry *entry,
51 unsigned short mode, void **file_private_data);
52 int (*release)(struct snd_info_entry *entry,
53 unsigned short mode, void *file_private_data);
Takashi Iwai24e4a122010-04-13 11:22:01 +020054 ssize_t (*read)(struct snd_info_entry *entry, void *file_private_data,
55 struct file *file, char __user *buf,
56 size_t count, loff_t pos);
57 ssize_t (*write)(struct snd_info_entry *entry, void *file_private_data,
58 struct file *file, const char __user *buf,
59 size_t count, loff_t pos);
60 loff_t (*llseek)(struct snd_info_entry *entry,
61 void *file_private_data, struct file *file,
62 loff_t offset, int orig);
63 unsigned int (*poll)(struct snd_info_entry *entry,
64 void *file_private_data, struct file *file,
65 poll_table *wait);
Jaroslav Kyselafd641382008-11-12 16:53:47 +010066 int (*ioctl)(struct snd_info_entry *entry, void *file_private_data,
67 struct file *file, unsigned int cmd, unsigned long arg);
68 int (*mmap)(struct snd_info_entry *entry, void *file_private_data,
69 struct inode *inode, struct file *file,
70 struct vm_area_struct *vma);
Linus Torvalds1da177e2005-04-16 15:20:36 -070071};
72
73struct snd_info_entry {
74 const char *name;
75 mode_t mode;
76 long size;
77 unsigned short content;
Linus Torvalds1da177e2005-04-16 15:20:36 -070078 union {
79 struct snd_info_entry_text text;
80 struct snd_info_entry_ops *ops;
81 } c;
Takashi Iwai24c1f932005-11-17 13:58:48 +010082 struct snd_info_entry *parent;
83 struct snd_card *card;
Linus Torvalds1da177e2005-04-16 15:20:36 -070084 struct module *module;
85 void *private_data;
Takashi Iwai24c1f932005-11-17 13:58:48 +010086 void (*private_free)(struct snd_info_entry *entry);
Linus Torvalds1da177e2005-04-16 15:20:36 -070087 struct proc_dir_entry *p;
Ingo Molnar1a60d4c2006-01-16 16:29:08 +010088 struct mutex access;
Takashi Iwai746d4a02006-06-23 14:37:59 +020089 struct list_head children;
90 struct list_head list;
Linus Torvalds1da177e2005-04-16 15:20:36 -070091};
92
Linus Torvalds1da177e2005-04-16 15:20:36 -070093#if defined(CONFIG_SND_OSSEMUL) && defined(CONFIG_PROC_FS)
Takashi Iwai24c1f932005-11-17 13:58:48 +010094int snd_info_minor_register(void);
95int snd_info_minor_unregister(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -070096#else
97#define snd_info_minor_register() /* NOP */
98#define snd_info_minor_unregister() /* NOP */
99#endif
100
101
102#ifdef CONFIG_PROC_FS
103
Takashi Iwai24c1f932005-11-17 13:58:48 +0100104extern struct snd_info_entry *snd_seq_root;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700105#ifdef CONFIG_SND_OSSEMUL
Takashi Iwai24c1f932005-11-17 13:58:48 +0100106extern struct snd_info_entry *snd_oss_root;
Marcin Ślusarz36b9cdf2007-12-14 12:58:45 +0100107void snd_card_info_read_oss(struct snd_info_buffer *buffer);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700108#else
109#define snd_oss_root NULL
Marcin Ślusarz36b9cdf2007-12-14 12:58:45 +0100110static inline void snd_card_info_read_oss(struct snd_info_buffer *buffer) {}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700111#endif
112
Takashi Iwai4f7454a2009-09-08 14:29:58 +0200113int snd_iprintf(struct snd_info_buffer *buffer, const char *fmt, ...) \
Jaroslav Kyselafd641382008-11-12 16:53:47 +0100114 __attribute__ ((format (printf, 2, 3)));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115int snd_info_init(void);
116int snd_info_done(void);
117
Jaroslav Kyselafd641382008-11-12 16:53:47 +0100118int snd_info_get_line(struct snd_info_buffer *buffer, char *line, int len);
Takashi Iwai4f7454a2009-09-08 14:29:58 +0200119const char *snd_info_get_str(char *dest, const char *src, int len);
Jaroslav Kyselafd641382008-11-12 16:53:47 +0100120struct snd_info_entry *snd_info_create_module_entry(struct module *module,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700121 const char *name,
Jaroslav Kyselafd641382008-11-12 16:53:47 +0100122 struct snd_info_entry *parent);
123struct snd_info_entry *snd_info_create_card_entry(struct snd_card *card,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700124 const char *name,
Jaroslav Kyselafd641382008-11-12 16:53:47 +0100125 struct snd_info_entry *parent);
126void snd_info_free_entry(struct snd_info_entry *entry);
127int snd_info_store_text(struct snd_info_entry *entry);
128int snd_info_restore_text(struct snd_info_entry *entry);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700129
Jaroslav Kyselafd641382008-11-12 16:53:47 +0100130int snd_info_card_create(struct snd_card *card);
131int snd_info_card_register(struct snd_card *card);
132int snd_info_card_free(struct snd_card *card);
133void snd_info_card_disconnect(struct snd_card *card);
134void snd_info_card_id_change(struct snd_card *card);
135int snd_info_register(struct snd_info_entry *entry);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700136
137/* for card drivers */
Jaroslav Kyselafd641382008-11-12 16:53:47 +0100138int snd_card_proc_new(struct snd_card *card, const char *name,
139 struct snd_info_entry **entryp);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700140
Takashi Iwai24c1f932005-11-17 13:58:48 +0100141static inline void snd_info_set_text_ops(struct snd_info_entry *entry,
Jaroslav Kyselafd641382008-11-12 16:53:47 +0100142 void *private_data,
143 void (*read)(struct snd_info_entry *, struct snd_info_buffer *))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700144{
145 entry->private_data = private_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146 entry->c.text.read = read;
147}
148
Takashi Iwaie28563c2005-12-01 10:42:42 +0100149int snd_info_check_reserved_words(const char *str);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700150
151#else
152
153#define snd_seq_root NULL
154#define snd_oss_root NULL
155
Jaroslav Kyselafd641382008-11-12 16:53:47 +0100156static inline int snd_iprintf(struct snd_info_buffer *buffer, char *fmt, ...) { return 0; }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700157static inline int snd_info_init(void) { return 0; }
158static inline int snd_info_done(void) { return 0; }
159
Jaroslav Kyselafd641382008-11-12 16:53:47 +0100160static inline int snd_info_get_line(struct snd_info_buffer *buffer, char *line, int len) { return 0; }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700161static inline char *snd_info_get_str(char *dest, char *src, int len) { return NULL; }
Jaroslav Kyselafd641382008-11-12 16:53:47 +0100162static inline struct snd_info_entry *snd_info_create_module_entry(struct module *module, const char *name, struct snd_info_entry *parent) { return NULL; }
163static inline struct snd_info_entry *snd_info_create_card_entry(struct snd_card *card, const char *name, struct snd_info_entry *parent) { return NULL; }
164static inline void snd_info_free_entry(struct snd_info_entry *entry) { ; }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700165
Jaroslav Kyselafd641382008-11-12 16:53:47 +0100166static inline int snd_info_card_create(struct snd_card *card) { return 0; }
167static inline int snd_info_card_register(struct snd_card *card) { return 0; }
168static inline int snd_info_card_free(struct snd_card *card) { return 0; }
169static inline void snd_info_card_disconnect(struct snd_card *card) { }
170static inline void snd_info_card_id_change(struct snd_card *card) { }
171static inline int snd_info_register(struct snd_info_entry *entry) { return 0; }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700172
Takashi Iwaie28563c2005-12-01 10:42:42 +0100173static inline int snd_card_proc_new(struct snd_card *card, const char *name,
174 struct snd_info_entry **entryp) { return -EINVAL; }
175static inline void snd_info_set_text_ops(struct snd_info_entry *entry __attribute__((unused)),
176 void *private_data,
Takashi Iwaie28563c2005-12-01 10:42:42 +0100177 void (*read)(struct snd_info_entry *, struct snd_info_buffer *)) {}
178
179static inline int snd_info_check_reserved_words(const char *str) { return 1; }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700180
181#endif
182
183/*
184 * OSS info part
185 */
186
187#if defined(CONFIG_SND_OSSEMUL) && defined(CONFIG_PROC_FS)
188
189#define SNDRV_OSS_INFO_DEV_AUDIO 0
190#define SNDRV_OSS_INFO_DEV_SYNTH 1
191#define SNDRV_OSS_INFO_DEV_MIDI 2
192#define SNDRV_OSS_INFO_DEV_TIMERS 4
193#define SNDRV_OSS_INFO_DEV_MIXERS 5
194
195#define SNDRV_OSS_INFO_DEV_COUNT 6
196
Takashi Iwai24c1f932005-11-17 13:58:48 +0100197int snd_oss_info_register(int dev, int num, char *string);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700198#define snd_oss_info_unregister(dev, num) snd_oss_info_register(dev, num, NULL)
199
200#endif /* CONFIG_SND_OSSEMUL && CONFIG_PROC_FS */
201
202#endif /* __SOUND_INFO_H */