blob: 8ea5c7497c03df2e83865d49fb87b783035ed921 [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 */
30 char *curr; /* current position in buffer */
31 unsigned long size; /* current size */
32 unsigned long len; /* total length of buffer */
33 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 {
43 unsigned long read_size;
44 unsigned long write_size;
Takashi Iwai24c1f932005-11-17 13:58:48 +010045 void (*read) (struct snd_info_entry *entry, struct snd_info_buffer *buffer);
46 void (*write) (struct snd_info_entry *entry, struct snd_info_buffer *buffer);
Linus Torvalds1da177e2005-04-16 15:20:36 -070047};
48
49struct snd_info_entry_ops {
Takashi Iwai24c1f932005-11-17 13:58:48 +010050 int (*open) (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 int (*release) (struct snd_info_entry * entry,
Linus Torvalds1da177e2005-04-16 15:20:36 -070053 unsigned short mode, void *file_private_data);
Takashi Iwai24c1f932005-11-17 13:58:48 +010054 long (*read) (struct snd_info_entry *entry, void *file_private_data,
Linus Torvalds1da177e2005-04-16 15:20:36 -070055 struct file * file, char __user *buf,
56 unsigned long count, unsigned long pos);
Takashi Iwai24c1f932005-11-17 13:58:48 +010057 long (*write) (struct snd_info_entry *entry, void *file_private_data,
Linus Torvalds1da177e2005-04-16 15:20:36 -070058 struct file * file, const char __user *buf,
59 unsigned long count, unsigned long pos);
Takashi Iwai24c1f932005-11-17 13:58:48 +010060 long long (*llseek) (struct snd_info_entry *entry, void *file_private_data,
Linus Torvalds1da177e2005-04-16 15:20:36 -070061 struct file * file, long long offset, int orig);
Takashi Iwai24c1f932005-11-17 13:58:48 +010062 unsigned int (*poll) (struct snd_info_entry *entry, void *file_private_data,
Linus Torvalds1da177e2005-04-16 15:20:36 -070063 struct file * file, poll_table * wait);
Takashi Iwai24c1f932005-11-17 13:58:48 +010064 int (*ioctl) (struct snd_info_entry *entry, void *file_private_data,
Linus Torvalds1da177e2005-04-16 15:20:36 -070065 struct file * file, unsigned int cmd, unsigned long arg);
Takashi Iwai24c1f932005-11-17 13:58:48 +010066 int (*mmap) (struct snd_info_entry *entry, void *file_private_data,
Linus Torvalds1da177e2005-04-16 15:20:36 -070067 struct inode * inode, struct file * file,
68 struct vm_area_struct * vma);
69};
70
71struct snd_info_entry {
72 const char *name;
73 mode_t mode;
74 long size;
75 unsigned short content;
76 unsigned short disconnected: 1;
77 union {
78 struct snd_info_entry_text text;
79 struct snd_info_entry_ops *ops;
80 } c;
Takashi Iwai24c1f932005-11-17 13:58:48 +010081 struct snd_info_entry *parent;
82 struct snd_card *card;
Linus Torvalds1da177e2005-04-16 15:20:36 -070083 struct module *module;
84 void *private_data;
Takashi Iwai24c1f932005-11-17 13:58:48 +010085 void (*private_free)(struct snd_info_entry *entry);
Linus Torvalds1da177e2005-04-16 15:20:36 -070086 struct proc_dir_entry *p;
87 struct semaphore access;
88};
89
Linus Torvalds1da177e2005-04-16 15:20:36 -070090#if defined(CONFIG_SND_OSSEMUL) && defined(CONFIG_PROC_FS)
Takashi Iwai24c1f932005-11-17 13:58:48 +010091int snd_info_minor_register(void);
92int snd_info_minor_unregister(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -070093#else
94#define snd_info_minor_register() /* NOP */
95#define snd_info_minor_unregister() /* NOP */
96#endif
97
98
99#ifdef CONFIG_PROC_FS
100
Takashi Iwai24c1f932005-11-17 13:58:48 +0100101extern struct snd_info_entry *snd_seq_root;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102#ifdef CONFIG_SND_OSSEMUL
Takashi Iwai24c1f932005-11-17 13:58:48 +0100103extern struct snd_info_entry *snd_oss_root;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104#else
105#define snd_oss_root NULL
106#endif
107
Takashi Iwai24c1f932005-11-17 13:58:48 +0100108int snd_iprintf(struct snd_info_buffer * buffer, char *fmt,...) __attribute__ ((format (printf, 2, 3)));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700109int snd_info_init(void);
110int snd_info_done(void);
111
Takashi Iwai24c1f932005-11-17 13:58:48 +0100112int snd_info_get_line(struct snd_info_buffer * buffer, char *line, int len);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700113char *snd_info_get_str(char *dest, char *src, int len);
Takashi Iwai24c1f932005-11-17 13:58:48 +0100114struct snd_info_entry *snd_info_create_module_entry(struct module * module,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115 const char *name,
Takashi Iwai24c1f932005-11-17 13:58:48 +0100116 struct snd_info_entry * parent);
117struct snd_info_entry *snd_info_create_card_entry(struct snd_card * card,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700118 const char *name,
Takashi Iwai24c1f932005-11-17 13:58:48 +0100119 struct snd_info_entry * parent);
120void snd_info_free_entry(struct snd_info_entry * entry);
121int snd_info_store_text(struct snd_info_entry * entry);
122int snd_info_restore_text(struct snd_info_entry * entry);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700123
Takashi Iwai24c1f932005-11-17 13:58:48 +0100124int snd_info_card_create(struct snd_card * card);
125int snd_info_card_register(struct snd_card * card);
126int snd_info_card_free(struct snd_card * card);
127int snd_info_register(struct snd_info_entry * entry);
128int snd_info_unregister(struct snd_info_entry * entry);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700129
130/* for card drivers */
Takashi Iwai24c1f932005-11-17 13:58:48 +0100131int snd_card_proc_new(struct snd_card *card, const char *name, struct snd_info_entry **entryp);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700132
Takashi Iwai24c1f932005-11-17 13:58:48 +0100133static inline void snd_info_set_text_ops(struct snd_info_entry *entry,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700134 void *private_data,
135 long read_size,
Takashi Iwai24c1f932005-11-17 13:58:48 +0100136 void (*read)(struct snd_info_entry *, struct snd_info_buffer *))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700137{
138 entry->private_data = private_data;
139 entry->c.text.read_size = read_size;
140 entry->c.text.read = read;
141}
142
Takashi Iwaie28563c2005-12-01 10:42:42 +0100143int snd_info_check_reserved_words(const char *str);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700144
145#else
146
147#define snd_seq_root NULL
148#define snd_oss_root NULL
149
Takashi Iwai24c1f932005-11-17 13:58:48 +0100150static inline int snd_iprintf(struct snd_info_buffer * buffer, char *fmt,...) { return 0; }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700151static inline int snd_info_init(void) { return 0; }
152static inline int snd_info_done(void) { return 0; }
153
Takashi Iwai24c1f932005-11-17 13:58:48 +0100154static inline int snd_info_get_line(struct snd_info_buffer * buffer, char *line, int len) { return 0; }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700155static inline char *snd_info_get_str(char *dest, char *src, int len) { return NULL; }
Takashi Iwai24c1f932005-11-17 13:58:48 +0100156static inline struct snd_info_entry *snd_info_create_module_entry(struct module * module, const char *name, struct snd_info_entry * parent) { return NULL; }
157static inline struct snd_info_entry *snd_info_create_card_entry(struct snd_card * card, const char *name, struct snd_info_entry * parent) { return NULL; }
158static inline void snd_info_free_entry(struct snd_info_entry * entry) { ; }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700159
Takashi Iwai24c1f932005-11-17 13:58:48 +0100160static inline int snd_info_card_create(struct snd_card * card) { return 0; }
161static inline int snd_info_card_register(struct snd_card * card) { return 0; }
162static inline int snd_info_card_free(struct snd_card * card) { return 0; }
163static inline int snd_info_register(struct snd_info_entry * entry) { return 0; }
164static inline int snd_info_unregister(struct snd_info_entry * entry) { return 0; }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700165
Takashi Iwaie28563c2005-12-01 10:42:42 +0100166static inline int snd_card_proc_new(struct snd_card *card, const char *name,
167 struct snd_info_entry **entryp) { return -EINVAL; }
168static inline void snd_info_set_text_ops(struct snd_info_entry *entry __attribute__((unused)),
169 void *private_data,
170 long read_size,
171 void (*read)(struct snd_info_entry *, struct snd_info_buffer *)) {}
172
173static inline int snd_info_check_reserved_words(const char *str) { return 1; }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700174
175#endif
176
177/*
178 * OSS info part
179 */
180
181#if defined(CONFIG_SND_OSSEMUL) && defined(CONFIG_PROC_FS)
182
183#define SNDRV_OSS_INFO_DEV_AUDIO 0
184#define SNDRV_OSS_INFO_DEV_SYNTH 1
185#define SNDRV_OSS_INFO_DEV_MIDI 2
186#define SNDRV_OSS_INFO_DEV_TIMERS 4
187#define SNDRV_OSS_INFO_DEV_MIXERS 5
188
189#define SNDRV_OSS_INFO_DEV_COUNT 6
190
Takashi Iwai24c1f932005-11-17 13:58:48 +0100191int snd_oss_info_register(int dev, int num, char *string);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700192#define snd_oss_info_unregister(dev, num) snd_oss_info_register(dev, num, NULL)
193
194#endif /* CONFIG_SND_OSSEMUL && CONFIG_PROC_FS */
195
196#endif /* __SOUND_INFO_H */