1 #ifndef __SOUND_INFO_H 2 #define __SOUND_INFO_H 3 4 /* 5 * Header file for info interface 6 * Copyright (c) by Jaroslav Kysela <[email protected]> 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 #include <linux/seq_file.h> 27 28 /* buffer for information */ 29 struct snd_info_buffer { 30 char *buffer; /* pointer to begin of buffer */ 31 unsigned int curr; /* current position in buffer */ 32 unsigned int size; /* current size */ 33 unsigned int len; /* total length of buffer */ 34 int stop; /* stop flag */ 35 int error; /* error code */ 36 }; 37 38 #define SNDRV_INFO_CONTENT_TEXT 0 39 #define SNDRV_INFO_CONTENT_DATA 1 40 41 struct snd_info_entry; 42 43 struct snd_info_entry_text { 44 void (*read)(struct snd_info_entry *entry, 45 struct snd_info_buffer *buffer); 46 void (*write)(struct snd_info_entry *entry, 47 struct snd_info_buffer *buffer); 48 }; 49 50 struct snd_info_entry_ops { 51 int (*open)(struct snd_info_entry *entry, 52 unsigned short mode, void **file_private_data); 53 int (*release)(struct snd_info_entry *entry, 54 unsigned short mode, void *file_private_data); 55 ssize_t (*read)(struct snd_info_entry *entry, void *file_private_data, 56 struct file *file, char __user *buf, 57 size_t count, loff_t pos); 58 ssize_t (*write)(struct snd_info_entry *entry, void *file_private_data, 59 struct file *file, const char __user *buf, 60 size_t count, loff_t pos); 61 loff_t (*llseek)(struct snd_info_entry *entry, 62 void *file_private_data, struct file *file, 63 loff_t offset, int orig); 64 unsigned int (*poll)(struct snd_info_entry *entry, 65 void *file_private_data, struct file *file, 66 poll_table *wait); 67 int (*ioctl)(struct snd_info_entry *entry, void *file_private_data, 68 struct file *file, unsigned int cmd, unsigned long arg); 69 int (*mmap)(struct snd_info_entry *entry, void *file_private_data, 70 struct inode *inode, struct file *file, 71 struct vm_area_struct *vma); 72 }; 73 74 struct snd_info_entry { 75 const char *name; 76 umode_t mode; 77 long size; 78 unsigned short content; 79 union { 80 struct snd_info_entry_text text; 81 struct snd_info_entry_ops *ops; 82 } c; 83 struct snd_info_entry *parent; 84 struct snd_card *card; 85 struct module *module; 86 void *private_data; 87 void (*private_free)(struct snd_info_entry *entry); 88 struct proc_dir_entry *p; 89 struct mutex access; 90 struct list_head children; 91 struct list_head list; 92 }; 93 94 #if defined(CONFIG_SND_OSSEMUL) && defined(CONFIG_PROC_FS) 95 int snd_info_minor_register(void); 96 int snd_info_minor_unregister(void); 97 #else 98 #define snd_info_minor_register() /* NOP */ 99 #define snd_info_minor_unregister() /* NOP */ 100 #endif 101 102 103 #ifdef CONFIG_PROC_FS 104 105 extern struct snd_info_entry *snd_seq_root; 106 #ifdef CONFIG_SND_OSSEMUL 107 extern struct snd_info_entry *snd_oss_root; 108 void snd_card_info_read_oss(struct snd_info_buffer *buffer); 109 #else 110 #define snd_oss_root NULL 111 static inline void snd_card_info_read_oss(struct snd_info_buffer *buffer) {} 112 #endif 113 114 /** 115 * snd_iprintf - printf on the procfs buffer 116 * @buf: the procfs buffer 117 * @fmt: the printf format 118 * 119 * Outputs the string on the procfs buffer just like printf(). 120 * 121 * Return: zero for success, or a negative error code. 122 */ 123 #define snd_iprintf(buf, fmt, args...) \ 124 seq_printf((struct seq_file *)(buf)->buffer, fmt, ##args) 125 126 int snd_info_init(void); 127 int snd_info_done(void); 128 129 int snd_info_get_line(struct snd_info_buffer *buffer, char *line, int len); 130 const char *snd_info_get_str(char *dest, const char *src, int len); 131 struct snd_info_entry *snd_info_create_module_entry(struct module *module, 132 const char *name, 133 struct snd_info_entry *parent); 134 struct snd_info_entry *snd_info_create_card_entry(struct snd_card *card, 135 const char *name, 136 struct snd_info_entry *parent); 137 void snd_info_free_entry(struct snd_info_entry *entry); 138 int snd_info_store_text(struct snd_info_entry *entry); 139 int snd_info_restore_text(struct snd_info_entry *entry); 140 141 int snd_info_card_create(struct snd_card *card); 142 int snd_info_card_register(struct snd_card *card); 143 int snd_info_card_free(struct snd_card *card); 144 void snd_info_card_disconnect(struct snd_card *card); 145 void snd_info_card_id_change(struct snd_card *card); 146 int snd_info_register(struct snd_info_entry *entry); 147 148 /* for card drivers */ 149 int snd_card_proc_new(struct snd_card *card, const char *name, 150 struct snd_info_entry **entryp); 151 152 static inline void snd_info_set_text_ops(struct snd_info_entry *entry, 153 void *private_data, 154 void (*read)(struct snd_info_entry *, struct snd_info_buffer *)) 155 { 156 entry->private_data = private_data; 157 entry->c.text.read = read; 158 } 159 160 int snd_info_check_reserved_words(const char *str); 161 162 #else 163 164 #define snd_seq_root NULL 165 #define snd_oss_root NULL 166 167 static inline int snd_iprintf(struct snd_info_buffer *buffer, char *fmt, ...) { return 0; } 168 static inline int snd_info_init(void) { return 0; } 169 static inline int snd_info_done(void) { return 0; } 170 171 static inline int snd_info_get_line(struct snd_info_buffer *buffer, char *line, int len) { return 0; } 172 static inline char *snd_info_get_str(char *dest, char *src, int len) { return NULL; } 173 static inline struct snd_info_entry *snd_info_create_module_entry(struct module *module, const char *name, struct snd_info_entry *parent) { return NULL; } 174 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; } 175 static inline void snd_info_free_entry(struct snd_info_entry *entry) { ; } 176 177 static inline int snd_info_card_create(struct snd_card *card) { return 0; } 178 static inline int snd_info_card_register(struct snd_card *card) { return 0; } 179 static inline int snd_info_card_free(struct snd_card *card) { return 0; } 180 static inline void snd_info_card_disconnect(struct snd_card *card) { } 181 static inline void snd_info_card_id_change(struct snd_card *card) { } 182 static inline int snd_info_register(struct snd_info_entry *entry) { return 0; } 183 184 static inline int snd_card_proc_new(struct snd_card *card, const char *name, 185 struct snd_info_entry **entryp) { return -EINVAL; } 186 static inline void snd_info_set_text_ops(struct snd_info_entry *entry __attribute__((unused)), 187 void *private_data, 188 void (*read)(struct snd_info_entry *, struct snd_info_buffer *)) {} 189 static inline int snd_info_check_reserved_words(const char *str) { return 1; } 190 191 #endif 192 193 /* 194 * OSS info part 195 */ 196 197 #if defined(CONFIG_SND_OSSEMUL) && defined(CONFIG_PROC_FS) 198 199 #define SNDRV_OSS_INFO_DEV_AUDIO 0 200 #define SNDRV_OSS_INFO_DEV_SYNTH 1 201 #define SNDRV_OSS_INFO_DEV_MIDI 2 202 #define SNDRV_OSS_INFO_DEV_TIMERS 4 203 #define SNDRV_OSS_INFO_DEV_MIXERS 5 204 205 #define SNDRV_OSS_INFO_DEV_COUNT 6 206 207 int snd_oss_info_register(int dev, int num, char *string); 208 #define snd_oss_info_unregister(dev, num) snd_oss_info_register(dev, num, NULL) 209 210 #endif /* CONFIG_SND_OSSEMUL && CONFIG_PROC_FS */ 211 212 #endif /* __SOUND_INFO_H */ 213