0001
0002 #ifndef __SOUND_INFO_H
0003 #define __SOUND_INFO_H
0004
0005
0006
0007
0008
0009
0010 #include <linux/poll.h>
0011 #include <linux/seq_file.h>
0012 #include <sound/core.h>
0013
0014
0015 struct snd_info_buffer {
0016 char *buffer;
0017 unsigned int curr;
0018 unsigned int size;
0019 unsigned int len;
0020 int stop;
0021 int error;
0022 };
0023
0024 #define SNDRV_INFO_CONTENT_TEXT 0
0025 #define SNDRV_INFO_CONTENT_DATA 1
0026
0027 struct snd_info_entry;
0028
0029 struct snd_info_entry_text {
0030 void (*read)(struct snd_info_entry *entry,
0031 struct snd_info_buffer *buffer);
0032 void (*write)(struct snd_info_entry *entry,
0033 struct snd_info_buffer *buffer);
0034 };
0035
0036 struct snd_info_entry_ops {
0037 int (*open)(struct snd_info_entry *entry,
0038 unsigned short mode, void **file_private_data);
0039 int (*release)(struct snd_info_entry *entry,
0040 unsigned short mode, void *file_private_data);
0041 ssize_t (*read)(struct snd_info_entry *entry, void *file_private_data,
0042 struct file *file, char __user *buf,
0043 size_t count, loff_t pos);
0044 ssize_t (*write)(struct snd_info_entry *entry, void *file_private_data,
0045 struct file *file, const char __user *buf,
0046 size_t count, loff_t pos);
0047 loff_t (*llseek)(struct snd_info_entry *entry,
0048 void *file_private_data, struct file *file,
0049 loff_t offset, int orig);
0050 __poll_t (*poll)(struct snd_info_entry *entry,
0051 void *file_private_data, struct file *file,
0052 poll_table *wait);
0053 int (*ioctl)(struct snd_info_entry *entry, void *file_private_data,
0054 struct file *file, unsigned int cmd, unsigned long arg);
0055 int (*mmap)(struct snd_info_entry *entry, void *file_private_data,
0056 struct inode *inode, struct file *file,
0057 struct vm_area_struct *vma);
0058 };
0059
0060 struct snd_info_entry {
0061 const char *name;
0062 umode_t mode;
0063 long size;
0064 unsigned short content;
0065 union {
0066 struct snd_info_entry_text text;
0067 const struct snd_info_entry_ops *ops;
0068 } c;
0069 struct snd_info_entry *parent;
0070 struct module *module;
0071 void *private_data;
0072 void (*private_free)(struct snd_info_entry *entry);
0073 struct proc_dir_entry *p;
0074 struct mutex access;
0075 struct list_head children;
0076 struct list_head list;
0077 };
0078
0079 #if defined(CONFIG_SND_OSSEMUL) && defined(CONFIG_SND_PROC_FS)
0080 int snd_info_minor_register(void);
0081 #else
0082 #define snd_info_minor_register() 0
0083 #endif
0084
0085
0086 #ifdef CONFIG_SND_PROC_FS
0087
0088 extern struct snd_info_entry *snd_seq_root;
0089 #ifdef CONFIG_SND_OSSEMUL
0090 extern struct snd_info_entry *snd_oss_root;
0091 void snd_card_info_read_oss(struct snd_info_buffer *buffer);
0092 #else
0093 #define snd_oss_root NULL
0094 static inline void snd_card_info_read_oss(struct snd_info_buffer *buffer) {}
0095 #endif
0096
0097
0098
0099
0100
0101
0102
0103
0104
0105
0106 #define snd_iprintf(buf, fmt, args...) \
0107 seq_printf((struct seq_file *)(buf)->buffer, fmt, ##args)
0108
0109 int snd_info_init(void);
0110 int snd_info_done(void);
0111
0112 int snd_info_get_line(struct snd_info_buffer *buffer, char *line, int len);
0113 const char *snd_info_get_str(char *dest, const char *src, int len);
0114 struct snd_info_entry *snd_info_create_module_entry(struct module *module,
0115 const char *name,
0116 struct snd_info_entry *parent);
0117 struct snd_info_entry *snd_info_create_card_entry(struct snd_card *card,
0118 const char *name,
0119 struct snd_info_entry *parent);
0120 void snd_info_free_entry(struct snd_info_entry *entry);
0121 int snd_info_store_text(struct snd_info_entry *entry);
0122 int snd_info_restore_text(struct snd_info_entry *entry);
0123
0124 int snd_info_card_create(struct snd_card *card);
0125 int snd_info_card_register(struct snd_card *card);
0126 int snd_info_card_free(struct snd_card *card);
0127 void snd_info_card_disconnect(struct snd_card *card);
0128 void snd_info_card_id_change(struct snd_card *card);
0129 int snd_info_register(struct snd_info_entry *entry);
0130
0131
0132 static inline int snd_card_proc_new(struct snd_card *card, const char *name,
0133 struct snd_info_entry **entryp)
0134 {
0135 *entryp = snd_info_create_card_entry(card, name, card->proc_root);
0136 return *entryp ? 0 : -ENOMEM;
0137 }
0138
0139 static inline void snd_info_set_text_ops(struct snd_info_entry *entry,
0140 void *private_data,
0141 void (*read)(struct snd_info_entry *, struct snd_info_buffer *))
0142 {
0143 entry->private_data = private_data;
0144 entry->c.text.read = read;
0145 }
0146
0147 int snd_card_rw_proc_new(struct snd_card *card, const char *name,
0148 void *private_data,
0149 void (*read)(struct snd_info_entry *,
0150 struct snd_info_buffer *),
0151 void (*write)(struct snd_info_entry *entry,
0152 struct snd_info_buffer *buffer));
0153
0154 int snd_info_check_reserved_words(const char *str);
0155
0156 #else
0157
0158 #define snd_seq_root NULL
0159 #define snd_oss_root NULL
0160
0161 static inline int snd_iprintf(struct snd_info_buffer *buffer, char *fmt, ...) { return 0; }
0162 static inline int snd_info_init(void) { return 0; }
0163 static inline int snd_info_done(void) { return 0; }
0164
0165 static inline int snd_info_get_line(struct snd_info_buffer *buffer, char *line, int len) { return 0; }
0166 static inline char *snd_info_get_str(char *dest, char *src, int len) { return NULL; }
0167 static inline struct snd_info_entry *snd_info_create_module_entry(struct module *module, const char *name, struct snd_info_entry *parent) { return NULL; }
0168 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; }
0169 static inline void snd_info_free_entry(struct snd_info_entry *entry) { ; }
0170
0171 static inline int snd_info_card_create(struct snd_card *card) { return 0; }
0172 static inline int snd_info_card_register(struct snd_card *card) { return 0; }
0173 static inline int snd_info_card_free(struct snd_card *card) { return 0; }
0174 static inline void snd_info_card_disconnect(struct snd_card *card) { }
0175 static inline void snd_info_card_id_change(struct snd_card *card) { }
0176 static inline int snd_info_register(struct snd_info_entry *entry) { return 0; }
0177
0178 static inline int snd_card_proc_new(struct snd_card *card, const char *name,
0179 struct snd_info_entry **entryp) { return -EINVAL; }
0180 static inline void snd_info_set_text_ops(struct snd_info_entry *entry __attribute__((unused)),
0181 void *private_data,
0182 void (*read)(struct snd_info_entry *, struct snd_info_buffer *)) {}
0183 static inline int snd_card_rw_proc_new(struct snd_card *card, const char *name,
0184 void *private_data,
0185 void (*read)(struct snd_info_entry *,
0186 struct snd_info_buffer *),
0187 void (*write)(struct snd_info_entry *entry,
0188 struct snd_info_buffer *buffer))
0189 {
0190 return 0;
0191 }
0192 static inline int snd_info_check_reserved_words(const char *str) { return 1; }
0193
0194 #endif
0195
0196
0197
0198
0199
0200
0201
0202
0203
0204
0205
0206 static inline int
0207 snd_card_ro_proc_new(struct snd_card *card, const char *name,
0208 void *private_data,
0209 void (*read)(struct snd_info_entry *,
0210 struct snd_info_buffer *))
0211 {
0212 return snd_card_rw_proc_new(card, name, private_data, read, NULL);
0213 }
0214
0215
0216
0217
0218
0219 #if defined(CONFIG_SND_OSSEMUL) && defined(CONFIG_SND_PROC_FS)
0220
0221 #define SNDRV_OSS_INFO_DEV_AUDIO 0
0222 #define SNDRV_OSS_INFO_DEV_SYNTH 1
0223 #define SNDRV_OSS_INFO_DEV_MIDI 2
0224 #define SNDRV_OSS_INFO_DEV_TIMERS 4
0225 #define SNDRV_OSS_INFO_DEV_MIXERS 5
0226
0227 #define SNDRV_OSS_INFO_DEV_COUNT 6
0228
0229 int snd_oss_info_register(int dev, int num, char *string);
0230 #define snd_oss_info_unregister(dev, num) snd_oss_info_register(dev, num, NULL)
0231
0232 #endif
0233
0234 #endif