blob: 74f6996769c7db6d706d77a60be3eabf8cec0d25 [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
6 * Copyright (c) by Jaroslav Kysela <perex@suse.cz>
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>
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 {
Takashi Iwai24c1f932005-11-17 13:58:48 +010043 void (*read) (struct snd_info_entry *entry, struct snd_info_buffer *buffer);
44 void (*write) (struct snd_info_entry *entry, struct snd_info_buffer *buffer);
Linus Torvalds1da177e2005-04-16 15:20:36 -070045};
46
47struct snd_info_entry_ops {
Takashi Iwai24c1f932005-11-17 13:58:48 +010048 int (*open) (struct snd_info_entry *entry,
Linus Torvalds1da177e2005-04-16 15:20:36 -070049 unsigned short mode, void **file_private_data);
Takashi Iwai24c1f932005-11-17 13:58:48 +010050 int (*release) (struct snd_info_entry * entry,
Linus Torvalds1da177e2005-04-16 15:20:36 -070051 unsigned short mode, void *file_private_data);
Takashi Iwai24c1f932005-11-17 13:58:48 +010052 long (*read) (struct snd_info_entry *entry, void *file_private_data,
Linus Torvalds1da177e2005-04-16 15:20:36 -070053 struct file * file, char __user *buf,
54 unsigned long count, unsigned long pos);
Takashi Iwai24c1f932005-11-17 13:58:48 +010055 long (*write) (struct snd_info_entry *entry, void *file_private_data,
Linus Torvalds1da177e2005-04-16 15:20:36 -070056 struct file * file, const char __user *buf,
57 unsigned long count, unsigned long pos);
Takashi Iwai24c1f932005-11-17 13:58:48 +010058 long long (*llseek) (struct snd_info_entry *entry, void *file_private_data,
Linus Torvalds1da177e2005-04-16 15:20:36 -070059 struct file * file, long long offset, int orig);
Takashi Iwai24c1f932005-11-17 13:58:48 +010060 unsigned int (*poll) (struct snd_info_entry *entry, void *file_private_data,
Linus Torvalds1da177e2005-04-16 15:20:36 -070061 struct file * file, poll_table * wait);
Takashi Iwai24c1f932005-11-17 13:58:48 +010062 int (*ioctl) (struct snd_info_entry *entry, void *file_private_data,
Linus Torvalds1da177e2005-04-16 15:20:36 -070063 struct file * file, unsigned int cmd, unsigned long arg);
Takashi Iwai24c1f932005-11-17 13:58:48 +010064 int (*mmap) (struct snd_info_entry *entry, void *file_private_data,
Linus Torvalds1da177e2005-04-16 15:20:36 -070065 struct inode * inode, struct file * file,
66 struct vm_area_struct * vma);
67};
68
69struct snd_info_entry {
70 const char *name;
71 mode_t mode;
72 long size;
73 unsigned short content;
74 unsigned short disconnected: 1;
75 union {
76 struct snd_info_entry_text text;
77 struct snd_info_entry_ops *ops;
78 } c;
Takashi Iwai24c1f932005-11-17 13:58:48 +010079 struct snd_info_entry *parent;
80 struct snd_card *card;
Linus Torvalds1da177e2005-04-16 15:20:36 -070081 struct module *module;
82 void *private_data;
Takashi Iwai24c1f932005-11-17 13:58:48 +010083 void (*private_free)(struct snd_info_entry *entry);
Linus Torvalds1da177e2005-04-16 15:20:36 -070084 struct proc_dir_entry *p;
Ingo Molnar1a60d4c2006-01-16 16:29:08 +010085 struct mutex access;
Linus Torvalds1da177e2005-04-16 15:20:36 -070086};
87
Linus Torvalds1da177e2005-04-16 15:20:36 -070088#if defined(CONFIG_SND_OSSEMUL) && defined(CONFIG_PROC_FS)
Takashi Iwai24c1f932005-11-17 13:58:48 +010089int snd_info_minor_register(void);
90int snd_info_minor_unregister(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -070091#else
92#define snd_info_minor_register() /* NOP */
93#define snd_info_minor_unregister() /* NOP */
94#endif
95
96
97#ifdef CONFIG_PROC_FS
98
Takashi Iwai24c1f932005-11-17 13:58:48 +010099extern struct snd_info_entry *snd_seq_root;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100#ifdef CONFIG_SND_OSSEMUL
Takashi Iwai24c1f932005-11-17 13:58:48 +0100101extern struct snd_info_entry *snd_oss_root;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102#else
103#define snd_oss_root NULL
104#endif
105
Takashi Iwai24c1f932005-11-17 13:58:48 +0100106int snd_iprintf(struct snd_info_buffer * buffer, char *fmt,...) __attribute__ ((format (printf, 2, 3)));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700107int snd_info_init(void);
108int snd_info_done(void);
109
Takashi Iwai24c1f932005-11-17 13:58:48 +0100110int snd_info_get_line(struct snd_info_buffer * buffer, char *line, int len);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700111char *snd_info_get_str(char *dest, char *src, int len);
Takashi Iwai24c1f932005-11-17 13:58:48 +0100112struct snd_info_entry *snd_info_create_module_entry(struct module * module,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700113 const char *name,
Takashi Iwai24c1f932005-11-17 13:58:48 +0100114 struct snd_info_entry * parent);
115struct snd_info_entry *snd_info_create_card_entry(struct snd_card * card,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700116 const char *name,
Takashi Iwai24c1f932005-11-17 13:58:48 +0100117 struct snd_info_entry * parent);
118void snd_info_free_entry(struct snd_info_entry * entry);
119int snd_info_store_text(struct snd_info_entry * entry);
120int snd_info_restore_text(struct snd_info_entry * entry);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700121
Takashi Iwai24c1f932005-11-17 13:58:48 +0100122int snd_info_card_create(struct snd_card * card);
123int snd_info_card_register(struct snd_card * card);
124int snd_info_card_free(struct snd_card * card);
125int snd_info_register(struct snd_info_entry * entry);
126int snd_info_unregister(struct snd_info_entry * entry);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700127
128/* for card drivers */
Takashi Iwai24c1f932005-11-17 13:58:48 +0100129int snd_card_proc_new(struct snd_card *card, const char *name, struct snd_info_entry **entryp);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700130
Takashi Iwai24c1f932005-11-17 13:58:48 +0100131static inline void snd_info_set_text_ops(struct snd_info_entry *entry,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700132 void *private_data,
Takashi Iwai24c1f932005-11-17 13:58:48 +0100133 void (*read)(struct snd_info_entry *, struct snd_info_buffer *))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700134{
135 entry->private_data = private_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700136 entry->c.text.read = read;
137}
138
Takashi Iwaie28563c2005-12-01 10:42:42 +0100139int snd_info_check_reserved_words(const char *str);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700140
141#else
142
143#define snd_seq_root NULL
144#define snd_oss_root NULL
145
Takashi Iwai24c1f932005-11-17 13:58:48 +0100146static inline int snd_iprintf(struct snd_info_buffer * buffer, char *fmt,...) { return 0; }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700147static inline int snd_info_init(void) { return 0; }
148static inline int snd_info_done(void) { return 0; }
149
Takashi Iwai24c1f932005-11-17 13:58:48 +0100150static inline int snd_info_get_line(struct snd_info_buffer * buffer, char *line, int len) { return 0; }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700151static inline char *snd_info_get_str(char *dest, char *src, int len) { return NULL; }
Takashi Iwai24c1f932005-11-17 13:58:48 +0100152static inline struct snd_info_entry *snd_info_create_module_entry(struct module * module, const char *name, struct snd_info_entry * parent) { return NULL; }
153static inline struct snd_info_entry *snd_info_create_card_entry(struct snd_card * card, const char *name, struct snd_info_entry * parent) { return NULL; }
154static inline void snd_info_free_entry(struct snd_info_entry * entry) { ; }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700155
Takashi Iwai24c1f932005-11-17 13:58:48 +0100156static inline int snd_info_card_create(struct snd_card * card) { return 0; }
157static inline int snd_info_card_register(struct snd_card * card) { return 0; }
158static inline int snd_info_card_free(struct snd_card * card) { return 0; }
159static inline int snd_info_register(struct snd_info_entry * entry) { return 0; }
160static inline int snd_info_unregister(struct snd_info_entry * entry) { return 0; }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700161
Takashi Iwaie28563c2005-12-01 10:42:42 +0100162static inline int snd_card_proc_new(struct snd_card *card, const char *name,
163 struct snd_info_entry **entryp) { return -EINVAL; }
164static inline void snd_info_set_text_ops(struct snd_info_entry *entry __attribute__((unused)),
165 void *private_data,
Takashi Iwaie28563c2005-12-01 10:42:42 +0100166 void (*read)(struct snd_info_entry *, struct snd_info_buffer *)) {}
167
168static inline int snd_info_check_reserved_words(const char *str) { return 1; }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700169
170#endif
171
172/*
173 * OSS info part
174 */
175
176#if defined(CONFIG_SND_OSSEMUL) && defined(CONFIG_PROC_FS)
177
178#define SNDRV_OSS_INFO_DEV_AUDIO 0
179#define SNDRV_OSS_INFO_DEV_SYNTH 1
180#define SNDRV_OSS_INFO_DEV_MIDI 2
181#define SNDRV_OSS_INFO_DEV_TIMERS 4
182#define SNDRV_OSS_INFO_DEV_MIXERS 5
183
184#define SNDRV_OSS_INFO_DEV_COUNT 6
185
Takashi Iwai24c1f932005-11-17 13:58:48 +0100186int snd_oss_info_register(int dev, int num, char *string);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700187#define snd_oss_info_unregister(dev, num) snd_oss_info_register(dev, num, NULL)
188
189#endif /* CONFIG_SND_OSSEMUL && CONFIG_PROC_FS */
190
191#endif /* __SOUND_INFO_H */