info.h 7.0 KB
Newer Older
L
Linus Torvalds 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
#ifndef __SOUND_INFO_H
#define __SOUND_INFO_H

/*
 *  Header file for info interface
 *  Copyright (c) by Jaroslav Kysela <perex@suse.cz>
 *
 *
 *   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>

/* buffer for information */
struct snd_info_buffer {
	char *buffer;		/* pointer to begin of buffer */
	char *curr;		/* current position in buffer */
	unsigned long size;	/* current size */
	unsigned long len;	/* total length of buffer */
	int stop;		/* stop flag */
	int error;		/* error code */
};

#define SNDRV_INFO_CONTENT_TEXT		0
#define SNDRV_INFO_CONTENT_DATA		1

struct snd_info_entry;

struct snd_info_entry_text {
	unsigned long read_size;
	unsigned long write_size;
45 46
	void (*read) (struct snd_info_entry *entry, struct snd_info_buffer *buffer);
	void (*write) (struct snd_info_entry *entry, struct snd_info_buffer *buffer);
L
Linus Torvalds 已提交
47 48 49
};

struct snd_info_entry_ops {
50
	int (*open) (struct snd_info_entry *entry,
L
Linus Torvalds 已提交
51
		     unsigned short mode, void **file_private_data);
52
	int (*release) (struct snd_info_entry * entry,
L
Linus Torvalds 已提交
53
			unsigned short mode, void *file_private_data);
54
	long (*read) (struct snd_info_entry *entry, void *file_private_data,
L
Linus Torvalds 已提交
55 56
		      struct file * file, char __user *buf,
		      unsigned long count, unsigned long pos);
57
	long (*write) (struct snd_info_entry *entry, void *file_private_data,
L
Linus Torvalds 已提交
58 59
		       struct file * file, const char __user *buf,
		       unsigned long count, unsigned long pos);
60
	long long (*llseek) (struct snd_info_entry *entry, void *file_private_data,
L
Linus Torvalds 已提交
61
			    struct file * file, long long offset, int orig);
62
	unsigned int (*poll) (struct snd_info_entry *entry, void *file_private_data,
L
Linus Torvalds 已提交
63
			      struct file * file, poll_table * wait);
64
	int (*ioctl) (struct snd_info_entry *entry, void *file_private_data,
L
Linus Torvalds 已提交
65
		      struct file * file, unsigned int cmd, unsigned long arg);
66
	int (*mmap) (struct snd_info_entry *entry, void *file_private_data,
L
Linus Torvalds 已提交
67 68 69 70 71 72 73 74 75 76 77 78 79 80
		     struct inode * inode, struct file * file,
		     struct vm_area_struct * vma);
};

struct snd_info_entry {
	const char *name;
	mode_t mode;
	long size;
	unsigned short content;
	unsigned short disconnected: 1;
	union {
		struct snd_info_entry_text text;
		struct snd_info_entry_ops *ops;
	} c;
81 82
	struct snd_info_entry *parent;
	struct snd_card *card;
L
Linus Torvalds 已提交
83 84
	struct module *module;
	void *private_data;
85
	void (*private_free)(struct snd_info_entry *entry);
L
Linus Torvalds 已提交
86 87 88 89 90
	struct proc_dir_entry *p;
	struct semaphore access;
};

#if defined(CONFIG_SND_OSSEMUL) && defined(CONFIG_PROC_FS)
91 92
int snd_info_minor_register(void);
int snd_info_minor_unregister(void);
L
Linus Torvalds 已提交
93 94 95 96 97 98 99 100
#else
#define snd_info_minor_register() /* NOP */
#define snd_info_minor_unregister() /* NOP */
#endif


#ifdef CONFIG_PROC_FS

101
extern struct snd_info_entry *snd_seq_root;
L
Linus Torvalds 已提交
102
#ifdef CONFIG_SND_OSSEMUL
103
extern struct snd_info_entry *snd_oss_root;
L
Linus Torvalds 已提交
104 105 106 107
#else
#define snd_oss_root NULL
#endif

108
int snd_iprintf(struct snd_info_buffer * buffer, char *fmt,...) __attribute__ ((format (printf, 2, 3)));
L
Linus Torvalds 已提交
109 110 111
int snd_info_init(void);
int snd_info_done(void);

112
int snd_info_get_line(struct snd_info_buffer * buffer, char *line, int len);
L
Linus Torvalds 已提交
113
char *snd_info_get_str(char *dest, char *src, int len);
114
struct snd_info_entry *snd_info_create_module_entry(struct module * module,
L
Linus Torvalds 已提交
115
					       const char *name,
116 117
					       struct snd_info_entry * parent);
struct snd_info_entry *snd_info_create_card_entry(struct snd_card * card,
L
Linus Torvalds 已提交
118
					     const char *name,
119 120 121 122
					     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);
L
Linus Torvalds 已提交
123

124 125 126 127 128
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);
int snd_info_register(struct snd_info_entry * entry);
int snd_info_unregister(struct snd_info_entry * entry);
L
Linus Torvalds 已提交
129 130

/* for card drivers */
131
int snd_card_proc_new(struct snd_card *card, const char *name, struct snd_info_entry **entryp);
L
Linus Torvalds 已提交
132

133
static inline void snd_info_set_text_ops(struct snd_info_entry *entry, 
L
Linus Torvalds 已提交
134 135
					 void *private_data,
					 long read_size,
136
					 void (*read)(struct snd_info_entry *, struct snd_info_buffer *))
L
Linus Torvalds 已提交
137 138 139 140 141 142
{
	entry->private_data = private_data;
	entry->c.text.read_size = read_size;
	entry->c.text.read = read;
}

143
int snd_info_check_reserved_words(const char *str);
L
Linus Torvalds 已提交
144 145 146 147 148 149

#else

#define snd_seq_root NULL
#define snd_oss_root NULL

150
static inline int snd_iprintf(struct snd_info_buffer * buffer, char *fmt,...) { return 0; }
L
Linus Torvalds 已提交
151 152 153
static inline int snd_info_init(void) { return 0; }
static inline int snd_info_done(void) { return 0; }

154
static inline int snd_info_get_line(struct snd_info_buffer * buffer, char *line, int len) { return 0; }
L
Linus Torvalds 已提交
155
static inline char *snd_info_get_str(char *dest, char *src, int len) { return NULL; }
156 157 158
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) { ; }
L
Linus Torvalds 已提交
159

160 161 162 163 164
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 int snd_info_register(struct snd_info_entry * entry) { return 0; }
static inline int snd_info_unregister(struct snd_info_entry * entry) { return 0; }
L
Linus Torvalds 已提交
165

166 167 168 169 170 171 172 173
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,
					 long read_size,
					 void (*read)(struct snd_info_entry *, struct snd_info_buffer *)) {}

static inline int snd_info_check_reserved_words(const char *str) { return 1; }
L
Linus Torvalds 已提交
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190

#endif

/*
 * OSS info part
 */

#if defined(CONFIG_SND_OSSEMUL) && defined(CONFIG_PROC_FS)

#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

191
int snd_oss_info_register(int dev, int num, char *string);
L
Linus Torvalds 已提交
192 193 194 195 196
#define snd_oss_info_unregister(dev, num) snd_oss_info_register(dev, num, NULL)

#endif /* CONFIG_SND_OSSEMUL && CONFIG_PROC_FS */

#endif /* __SOUND_INFO_H */