1#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 */
30	unsigned int curr;	/* current position in buffer */
31	unsigned int size;	/* current size */
32	unsigned int len;	/* total length of buffer */
33	int stop;		/* stop flag */
34	int error;		/* error code */
35};
36
37#define SNDRV_INFO_CONTENT_TEXT		0
38#define SNDRV_INFO_CONTENT_DATA		1
39
40struct snd_info_entry;
41
42struct snd_info_entry_text {
43	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);
45};
46
47struct snd_info_entry_ops {
48	int (*open) (struct snd_info_entry *entry,
49		     unsigned short mode, void **file_private_data);
50	int (*release) (struct snd_info_entry * entry,
51			unsigned short mode, void *file_private_data);
52	long (*read) (struct snd_info_entry *entry, void *file_private_data,
53		      struct file * file, char __user *buf,
54		      unsigned long count, unsigned long pos);
55	long (*write) (struct snd_info_entry *entry, void *file_private_data,
56		       struct file * file, const char __user *buf,
57		       unsigned long count, unsigned long pos);
58	long long (*llseek) (struct snd_info_entry *entry, void *file_private_data,
59			    struct file * file, long long offset, int orig);
60	unsigned int (*poll) (struct snd_info_entry *entry, void *file_private_data,
61			      struct file * file, poll_table * wait);
62	int (*ioctl) (struct snd_info_entry *entry, void *file_private_data,
63		      struct file * file, unsigned int cmd, unsigned long arg);
64	int (*mmap) (struct snd_info_entry *entry, void *file_private_data,
65		     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	union {
75		struct snd_info_entry_text text;
76		struct snd_info_entry_ops *ops;
77	} c;
78	struct snd_info_entry *parent;
79	struct snd_card *card;
80	struct module *module;
81	void *private_data;
82	void (*private_free)(struct snd_info_entry *entry);
83	struct proc_dir_entry *p;
84	struct mutex access;
85	struct list_head children;
86	struct list_head list;
87};
88
89#if defined(CONFIG_SND_OSSEMUL) && defined(CONFIG_PROC_FS)
90int snd_info_minor_register(void);
91int snd_info_minor_unregister(void);
92#else
93#define snd_info_minor_register() /* NOP */
94#define snd_info_minor_unregister() /* NOP */
95#endif
96
97
98#ifdef CONFIG_PROC_FS
99
100extern struct snd_info_entry *snd_seq_root;
101#ifdef CONFIG_SND_OSSEMUL
102extern struct snd_info_entry *snd_oss_root;
103#else
104#define snd_oss_root NULL
105#endif
106
107int snd_iprintf(struct snd_info_buffer * buffer, char *fmt,...) __attribute__ ((format (printf, 2, 3)));
108int snd_info_init(void);
109int snd_info_done(void);
110
111int snd_info_get_line(struct snd_info_buffer * buffer, char *line, int len);
112char *snd_info_get_str(char *dest, char *src, int len);
113struct snd_info_entry *snd_info_create_module_entry(struct module * module,
114					       const char *name,
115					       struct snd_info_entry * parent);
116struct snd_info_entry *snd_info_create_card_entry(struct snd_card * card,
117					     const char *name,
118					     struct snd_info_entry * parent);
119void snd_info_free_entry(struct snd_info_entry * entry);
120int snd_info_store_text(struct snd_info_entry * entry);
121int snd_info_restore_text(struct snd_info_entry * entry);
122
123int snd_info_card_create(struct snd_card * card);
124int snd_info_card_register(struct snd_card * card);
125int snd_info_card_free(struct snd_card * card);
126void snd_info_card_disconnect(struct snd_card * card);
127int snd_info_register(struct snd_info_entry * entry);
128
129/* for card drivers */
130int snd_card_proc_new(struct snd_card *card, const char *name, struct snd_info_entry **entryp);
131
132static inline void snd_info_set_text_ops(struct snd_info_entry *entry,
133					 void *private_data,
134					 void (*read)(struct snd_info_entry *, struct snd_info_buffer *))
135{
136	entry->private_data = private_data;
137	entry->c.text.read = read;
138}
139
140int snd_info_check_reserved_words(const char *str);
141
142#else
143
144#define snd_seq_root NULL
145#define snd_oss_root NULL
146
147static inline int snd_iprintf(struct snd_info_buffer * buffer, char *fmt,...) { return 0; }
148static inline int snd_info_init(void) { return 0; }
149static inline int snd_info_done(void) { return 0; }
150
151static inline int snd_info_get_line(struct snd_info_buffer * buffer, char *line, int len) { return 0; }
152static inline char *snd_info_get_str(char *dest, char *src, int len) { return NULL; }
153static inline struct snd_info_entry *snd_info_create_module_entry(struct module * module, const char *name, struct snd_info_entry * parent) { return NULL; }
154static inline struct snd_info_entry *snd_info_create_card_entry(struct snd_card * card, const char *name, struct snd_info_entry * parent) { return NULL; }
155static inline void snd_info_free_entry(struct snd_info_entry * entry) { ; }
156
157static inline int snd_info_card_create(struct snd_card * card) { return 0; }
158static inline int snd_info_card_register(struct snd_card * card) { return 0; }
159static inline int snd_info_card_free(struct snd_card * card) { return 0; }
160static inline void snd_info_card_disconnect(struct snd_card * card) { }
161static inline int snd_info_register(struct snd_info_entry * entry) { return 0; }
162
163static inline int snd_card_proc_new(struct snd_card *card, const char *name,
164				    struct snd_info_entry **entryp) { return -EINVAL; }
165static inline void snd_info_set_text_ops(struct snd_info_entry *entry __attribute__((unused)),
166					 void *private_data,
167					 void (*read)(struct snd_info_entry *, struct snd_info_buffer *)) {}
168
169static inline int snd_info_check_reserved_words(const char *str) { return 1; }
170
171#endif
172
173/*
174 * OSS info part
175 */
176
177#if defined(CONFIG_SND_OSSEMUL) && defined(CONFIG_PROC_FS)
178
179#define SNDRV_OSS_INFO_DEV_AUDIO	0
180#define SNDRV_OSS_INFO_DEV_SYNTH	1
181#define SNDRV_OSS_INFO_DEV_MIDI		2
182#define SNDRV_OSS_INFO_DEV_TIMERS	4
183#define SNDRV_OSS_INFO_DEV_MIXERS	5
184
185#define SNDRV_OSS_INFO_DEV_COUNT	6
186
187int snd_oss_info_register(int dev, int num, char *string);
188#define snd_oss_info_unregister(dev, num) snd_oss_info_register(dev, num, NULL)
189
190#endif /* CONFIG_SND_OSSEMUL && CONFIG_PROC_FS */
191
192#endif /* __SOUND_INFO_H */
193