blob: b6fcca24ea50e3d6240a1d80dc5df968fff2dc0f [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>
Takashi Iwaic560a672015-04-22 18:26:38 +020027#include <sound/core.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070028
29/* buffer for information */
30struct snd_info_buffer {
31 char *buffer; /* pointer to begin of buffer */
Takashi Iwai7e4eeec2006-04-28 15:13:40 +020032 unsigned int curr; /* current position in buffer */
33 unsigned int size; /* current size */
34 unsigned int len; /* total length of buffer */
Linus Torvalds1da177e2005-04-16 15:20:36 -070035 int stop; /* stop flag */
36 int error; /* error code */
37};
38
Linus Torvalds1da177e2005-04-16 15:20:36 -070039#define SNDRV_INFO_CONTENT_TEXT 0
40#define SNDRV_INFO_CONTENT_DATA 1
41
42struct snd_info_entry;
43
44struct snd_info_entry_text {
Jaroslav Kyselafd641382008-11-12 16:53:47 +010045 void (*read)(struct snd_info_entry *entry,
46 struct snd_info_buffer *buffer);
47 void (*write)(struct snd_info_entry *entry,
48 struct snd_info_buffer *buffer);
Linus Torvalds1da177e2005-04-16 15:20:36 -070049};
50
51struct snd_info_entry_ops {
Jaroslav Kyselafd641382008-11-12 16:53:47 +010052 int (*open)(struct snd_info_entry *entry,
53 unsigned short mode, void **file_private_data);
54 int (*release)(struct snd_info_entry *entry,
55 unsigned short mode, void *file_private_data);
Takashi Iwai24e4a122010-04-13 11:22:01 +020056 ssize_t (*read)(struct snd_info_entry *entry, void *file_private_data,
57 struct file *file, char __user *buf,
58 size_t count, loff_t pos);
59 ssize_t (*write)(struct snd_info_entry *entry, void *file_private_data,
60 struct file *file, const char __user *buf,
61 size_t count, loff_t pos);
62 loff_t (*llseek)(struct snd_info_entry *entry,
63 void *file_private_data, struct file *file,
64 loff_t offset, int orig);
65 unsigned int (*poll)(struct snd_info_entry *entry,
66 void *file_private_data, struct file *file,
67 poll_table *wait);
Jaroslav Kyselafd641382008-11-12 16:53:47 +010068 int (*ioctl)(struct snd_info_entry *entry, void *file_private_data,
69 struct file *file, unsigned int cmd, unsigned long arg);
70 int (*mmap)(struct snd_info_entry *entry, void *file_private_data,
71 struct inode *inode, struct file *file,
72 struct vm_area_struct *vma);
Linus Torvalds1da177e2005-04-16 15:20:36 -070073};
74
75struct snd_info_entry {
76 const char *name;
Al Virod161a132011-07-24 03:36:29 -040077 umode_t mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -070078 long size;
79 unsigned short content;
Linus Torvalds1da177e2005-04-16 15:20:36 -070080 union {
81 struct snd_info_entry_text text;
82 struct snd_info_entry_ops *ops;
83 } c;
Takashi Iwai24c1f932005-11-17 13:58:48 +010084 struct snd_info_entry *parent;
85 struct snd_card *card;
Linus Torvalds1da177e2005-04-16 15:20:36 -070086 struct module *module;
87 void *private_data;
Takashi Iwai24c1f932005-11-17 13:58:48 +010088 void (*private_free)(struct snd_info_entry *entry);
Linus Torvalds1da177e2005-04-16 15:20:36 -070089 struct proc_dir_entry *p;
Ingo Molnar1a60d4c2006-01-16 16:29:08 +010090 struct mutex access;
Takashi Iwai746d4a02006-06-23 14:37:59 +020091 struct list_head children;
92 struct list_head list;
Linus Torvalds1da177e2005-04-16 15:20:36 -070093};
94
Jie Yangcd6a6502015-05-27 19:45:45 +080095#if defined(CONFIG_SND_OSSEMUL) && defined(CONFIG_SND_PROC_FS)
Takashi Iwai24c1f932005-11-17 13:58:48 +010096int snd_info_minor_register(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -070097#else
Takashi Iwaia0dca822015-04-23 10:56:21 +020098#define snd_info_minor_register() 0
Linus Torvalds1da177e2005-04-16 15:20:36 -070099#endif
100
101
Jie Yangcd6a6502015-05-27 19:45:45 +0800102#ifdef CONFIG_SND_PROC_FS
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103
Takashi Iwai24c1f932005-11-17 13:58:48 +0100104extern struct snd_info_entry *snd_seq_root;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700105#ifdef CONFIG_SND_OSSEMUL
Takashi Iwai24c1f932005-11-17 13:58:48 +0100106extern struct snd_info_entry *snd_oss_root;
Marcin Ślusarz36b9cdf2007-12-14 12:58:45 +0100107void snd_card_info_read_oss(struct snd_info_buffer *buffer);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700108#else
109#define snd_oss_root NULL
Marcin Ślusarz36b9cdf2007-12-14 12:58:45 +0100110static inline void snd_card_info_read_oss(struct snd_info_buffer *buffer) {}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700111#endif
112
Takashi Iwai4adb7bc2015-04-22 16:10:22 +0200113/**
114 * snd_iprintf - printf on the procfs buffer
115 * @buf: the procfs buffer
116 * @fmt: the printf format
117 *
118 * Outputs the string on the procfs buffer just like printf().
119 *
120 * Return: zero for success, or a negative error code.
121 */
122#define snd_iprintf(buf, fmt, args...) \
123 seq_printf((struct seq_file *)(buf)->buffer, fmt, ##args)
124
Linus Torvalds1da177e2005-04-16 15:20:36 -0700125int snd_info_init(void);
126int snd_info_done(void);
127
Jaroslav Kyselafd641382008-11-12 16:53:47 +0100128int snd_info_get_line(struct snd_info_buffer *buffer, char *line, int len);
Takashi Iwai4f7454a2009-09-08 14:29:58 +0200129const char *snd_info_get_str(char *dest, const char *src, int len);
Jaroslav Kyselafd641382008-11-12 16:53:47 +0100130struct snd_info_entry *snd_info_create_module_entry(struct module *module,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700131 const char *name,
Jaroslav Kyselafd641382008-11-12 16:53:47 +0100132 struct snd_info_entry *parent);
133struct snd_info_entry *snd_info_create_card_entry(struct snd_card *card,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700134 const char *name,
Jaroslav Kyselafd641382008-11-12 16:53:47 +0100135 struct snd_info_entry *parent);
136void snd_info_free_entry(struct snd_info_entry *entry);
137int snd_info_store_text(struct snd_info_entry *entry);
138int snd_info_restore_text(struct snd_info_entry *entry);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700139
Jaroslav Kyselafd641382008-11-12 16:53:47 +0100140int snd_info_card_create(struct snd_card *card);
141int snd_info_card_register(struct snd_card *card);
142int snd_info_card_free(struct snd_card *card);
143void snd_info_card_disconnect(struct snd_card *card);
144void snd_info_card_id_change(struct snd_card *card);
145int snd_info_register(struct snd_info_entry *entry);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146
147/* for card drivers */
Takashi Iwaic560a672015-04-22 18:26:38 +0200148static inline int snd_card_proc_new(struct snd_card *card, const char *name,
149 struct snd_info_entry **entryp)
150{
151 *entryp = snd_info_create_card_entry(card, name, card->proc_root);
152 return *entryp ? 0 : -ENOMEM;
153}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700154
Takashi Iwai24c1f932005-11-17 13:58:48 +0100155static inline void snd_info_set_text_ops(struct snd_info_entry *entry,
Jaroslav Kyselafd641382008-11-12 16:53:47 +0100156 void *private_data,
157 void (*read)(struct snd_info_entry *, struct snd_info_buffer *))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700158{
159 entry->private_data = private_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700160 entry->c.text.read = read;
161}
162
Takashi Iwaie28563c2005-12-01 10:42:42 +0100163int snd_info_check_reserved_words(const char *str);
Banajit Goswami7aabab62016-12-15 19:18:30 -0800164struct snd_info_entry *snd_info_create_subdir(struct module *mod,
165 const char *name,
166 struct snd_info_entry *parent);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700167#else
168
169#define snd_seq_root NULL
170#define snd_oss_root NULL
171
Jaroslav Kyselafd641382008-11-12 16:53:47 +0100172static inline int snd_iprintf(struct snd_info_buffer *buffer, char *fmt, ...) { return 0; }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700173static inline int snd_info_init(void) { return 0; }
174static inline int snd_info_done(void) { return 0; }
175
Jaroslav Kyselafd641382008-11-12 16:53:47 +0100176static inline int snd_info_get_line(struct snd_info_buffer *buffer, char *line, int len) { return 0; }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700177static inline char *snd_info_get_str(char *dest, char *src, int len) { return NULL; }
Jaroslav Kyselafd641382008-11-12 16:53:47 +0100178static inline struct snd_info_entry *snd_info_create_module_entry(struct module *module, const char *name, struct snd_info_entry *parent) { return NULL; }
179static inline struct snd_info_entry *snd_info_create_card_entry(struct snd_card *card, const char *name, struct snd_info_entry *parent) { return NULL; }
180static inline void snd_info_free_entry(struct snd_info_entry *entry) { ; }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700181
Jaroslav Kyselafd641382008-11-12 16:53:47 +0100182static inline int snd_info_card_create(struct snd_card *card) { return 0; }
183static inline int snd_info_card_register(struct snd_card *card) { return 0; }
184static inline int snd_info_card_free(struct snd_card *card) { return 0; }
185static inline void snd_info_card_disconnect(struct snd_card *card) { }
186static inline void snd_info_card_id_change(struct snd_card *card) { }
187static inline int snd_info_register(struct snd_info_entry *entry) { return 0; }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700188
Takashi Iwaie28563c2005-12-01 10:42:42 +0100189static inline int snd_card_proc_new(struct snd_card *card, const char *name,
190 struct snd_info_entry **entryp) { return -EINVAL; }
191static inline void snd_info_set_text_ops(struct snd_info_entry *entry __attribute__((unused)),
192 void *private_data,
Takashi Iwaie28563c2005-12-01 10:42:42 +0100193 void (*read)(struct snd_info_entry *, struct snd_info_buffer *)) {}
Takashi Iwaie28563c2005-12-01 10:42:42 +0100194static inline int snd_info_check_reserved_words(const char *str) { return 1; }
Banajit Goswami7aabab62016-12-15 19:18:30 -0800195static inline struct snd_info_entry *snd_info_create_subdir(
196 struct module *mod, const char *name,
197 struct snd_info_entry *parent) { return NULL; }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700198#endif
199
200/*
201 * OSS info part
202 */
203
Jie Yangcd6a6502015-05-27 19:45:45 +0800204#if defined(CONFIG_SND_OSSEMUL) && defined(CONFIG_SND_PROC_FS)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700205
206#define SNDRV_OSS_INFO_DEV_AUDIO 0
207#define SNDRV_OSS_INFO_DEV_SYNTH 1
208#define SNDRV_OSS_INFO_DEV_MIDI 2
209#define SNDRV_OSS_INFO_DEV_TIMERS 4
210#define SNDRV_OSS_INFO_DEV_MIXERS 5
211
212#define SNDRV_OSS_INFO_DEV_COUNT 6
213
Takashi Iwai24c1f932005-11-17 13:58:48 +0100214int snd_oss_info_register(int dev, int num, char *string);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700215#define snd_oss_info_unregister(dev, num) snd_oss_info_register(dev, num, NULL)
216
Jie Yangcd6a6502015-05-27 19:45:45 +0800217#endif /* CONFIG_SND_OSSEMUL && CONFIG_SND_PROC_FS */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700218
219#endif /* __SOUND_INFO_H */