blob: ff8962ebece54b88abd59ce9aa85a2fb6f261b5c [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
Jaroslav Kyselac1017a42007-10-15 09:50:19 +02006 * Copyright (c) by Jaroslav Kysela <perex@perex.cz>
Linus Torvalds1da177e2005-04-16 15:20:36 -07007 *
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>
Takashi Iwai4adb7bc2015-04-22 16:10:22 +020026#include <linux/seq_file.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070027
28/* buffer for information */
29struct snd_info_buffer {
30 char *buffer; /* pointer to begin of buffer */
Takashi Iwai7e4eeec2006-04-28 15:13:40 +020031 unsigned int curr; /* current position in buffer */
32 unsigned int size; /* current size */
33 unsigned int len; /* total length of buffer */
Linus Torvalds1da177e2005-04-16 15:20:36 -070034 int stop; /* stop flag */
35 int error; /* error code */
36};
37
Linus Torvalds1da177e2005-04-16 15:20:36 -070038#define SNDRV_INFO_CONTENT_TEXT 0
39#define SNDRV_INFO_CONTENT_DATA 1
40
41struct snd_info_entry;
42
43struct snd_info_entry_text {
Jaroslav Kyselafd641382008-11-12 16:53:47 +010044 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);
Linus Torvalds1da177e2005-04-16 15:20:36 -070048};
49
50struct snd_info_entry_ops {
Jaroslav Kyselafd641382008-11-12 16:53:47 +010051 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);
Takashi Iwai24e4a122010-04-13 11:22:01 +020055 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);
Jaroslav Kyselafd641382008-11-12 16:53:47 +010067 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);
Linus Torvalds1da177e2005-04-16 15:20:36 -070072};
73
74struct snd_info_entry {
75 const char *name;
Al Virod161a132011-07-24 03:36:29 -040076 umode_t mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -070077 long size;
78 unsigned short content;
Linus Torvalds1da177e2005-04-16 15:20:36 -070079 union {
80 struct snd_info_entry_text text;
81 struct snd_info_entry_ops *ops;
82 } c;
Takashi Iwai24c1f932005-11-17 13:58:48 +010083 struct snd_info_entry *parent;
84 struct snd_card *card;
Linus Torvalds1da177e2005-04-16 15:20:36 -070085 struct module *module;
86 void *private_data;
Takashi Iwai24c1f932005-11-17 13:58:48 +010087 void (*private_free)(struct snd_info_entry *entry);
Linus Torvalds1da177e2005-04-16 15:20:36 -070088 struct proc_dir_entry *p;
Ingo Molnar1a60d4c2006-01-16 16:29:08 +010089 struct mutex access;
Takashi Iwai746d4a02006-06-23 14:37:59 +020090 struct list_head children;
91 struct list_head list;
Linus Torvalds1da177e2005-04-16 15:20:36 -070092};
93
Linus Torvalds1da177e2005-04-16 15:20:36 -070094#if defined(CONFIG_SND_OSSEMUL) && defined(CONFIG_PROC_FS)
Takashi Iwai24c1f932005-11-17 13:58:48 +010095int snd_info_minor_register(void);
96int snd_info_minor_unregister(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -070097#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
Takashi Iwai24c1f932005-11-17 13:58:48 +0100105extern struct snd_info_entry *snd_seq_root;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700106#ifdef CONFIG_SND_OSSEMUL
Takashi Iwai24c1f932005-11-17 13:58:48 +0100107extern struct snd_info_entry *snd_oss_root;
Marcin Ślusarz36b9cdf2007-12-14 12:58:45 +0100108void snd_card_info_read_oss(struct snd_info_buffer *buffer);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700109#else
110#define snd_oss_root NULL
Marcin Ślusarz36b9cdf2007-12-14 12:58:45 +0100111static inline void snd_card_info_read_oss(struct snd_info_buffer *buffer) {}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700112#endif
113
Takashi Iwai4adb7bc2015-04-22 16:10:22 +0200114/**
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
Linus Torvalds1da177e2005-04-16 15:20:36 -0700126int snd_info_init(void);
127int snd_info_done(void);
128
Jaroslav Kyselafd641382008-11-12 16:53:47 +0100129int snd_info_get_line(struct snd_info_buffer *buffer, char *line, int len);
Takashi Iwai4f7454a2009-09-08 14:29:58 +0200130const char *snd_info_get_str(char *dest, const char *src, int len);
Jaroslav Kyselafd641382008-11-12 16:53:47 +0100131struct snd_info_entry *snd_info_create_module_entry(struct module *module,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700132 const char *name,
Jaroslav Kyselafd641382008-11-12 16:53:47 +0100133 struct snd_info_entry *parent);
134struct snd_info_entry *snd_info_create_card_entry(struct snd_card *card,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700135 const char *name,
Jaroslav Kyselafd641382008-11-12 16:53:47 +0100136 struct snd_info_entry *parent);
137void snd_info_free_entry(struct snd_info_entry *entry);
138int snd_info_store_text(struct snd_info_entry *entry);
139int snd_info_restore_text(struct snd_info_entry *entry);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700140
Jaroslav Kyselafd641382008-11-12 16:53:47 +0100141int snd_info_card_create(struct snd_card *card);
142int snd_info_card_register(struct snd_card *card);
143int snd_info_card_free(struct snd_card *card);
144void snd_info_card_disconnect(struct snd_card *card);
145void snd_info_card_id_change(struct snd_card *card);
146int snd_info_register(struct snd_info_entry *entry);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700147
148/* for card drivers */
Jaroslav Kyselafd641382008-11-12 16:53:47 +0100149int snd_card_proc_new(struct snd_card *card, const char *name,
150 struct snd_info_entry **entryp);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700151
Takashi Iwai24c1f932005-11-17 13:58:48 +0100152static inline void snd_info_set_text_ops(struct snd_info_entry *entry,
Jaroslav Kyselafd641382008-11-12 16:53:47 +0100153 void *private_data,
154 void (*read)(struct snd_info_entry *, struct snd_info_buffer *))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700155{
156 entry->private_data = private_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700157 entry->c.text.read = read;
158}
159
Takashi Iwaie28563c2005-12-01 10:42:42 +0100160int snd_info_check_reserved_words(const char *str);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700161
162#else
163
164#define snd_seq_root NULL
165#define snd_oss_root NULL
166
Jaroslav Kyselafd641382008-11-12 16:53:47 +0100167static inline int snd_iprintf(struct snd_info_buffer *buffer, char *fmt, ...) { return 0; }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700168static inline int snd_info_init(void) { return 0; }
169static inline int snd_info_done(void) { return 0; }
170
Jaroslav Kyselafd641382008-11-12 16:53:47 +0100171static inline int snd_info_get_line(struct snd_info_buffer *buffer, char *line, int len) { return 0; }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700172static inline char *snd_info_get_str(char *dest, char *src, int len) { return NULL; }
Jaroslav Kyselafd641382008-11-12 16:53:47 +0100173static inline struct snd_info_entry *snd_info_create_module_entry(struct module *module, const char *name, struct snd_info_entry *parent) { return NULL; }
174static inline struct snd_info_entry *snd_info_create_card_entry(struct snd_card *card, const char *name, struct snd_info_entry *parent) { return NULL; }
175static inline void snd_info_free_entry(struct snd_info_entry *entry) { ; }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700176
Jaroslav Kyselafd641382008-11-12 16:53:47 +0100177static inline int snd_info_card_create(struct snd_card *card) { return 0; }
178static inline int snd_info_card_register(struct snd_card *card) { return 0; }
179static inline int snd_info_card_free(struct snd_card *card) { return 0; }
180static inline void snd_info_card_disconnect(struct snd_card *card) { }
181static inline void snd_info_card_id_change(struct snd_card *card) { }
182static inline int snd_info_register(struct snd_info_entry *entry) { return 0; }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700183
Takashi Iwaie28563c2005-12-01 10:42:42 +0100184static inline int snd_card_proc_new(struct snd_card *card, const char *name,
185 struct snd_info_entry **entryp) { return -EINVAL; }
186static inline void snd_info_set_text_ops(struct snd_info_entry *entry __attribute__((unused)),
187 void *private_data,
Takashi Iwaie28563c2005-12-01 10:42:42 +0100188 void (*read)(struct snd_info_entry *, struct snd_info_buffer *)) {}
Takashi Iwaie28563c2005-12-01 10:42:42 +0100189static inline int snd_info_check_reserved_words(const char *str) { return 1; }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700190
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
Takashi Iwai24c1f932005-11-17 13:58:48 +0100207int snd_oss_info_register(int dev, int num, char *string);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700208#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 */