]>
git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/blob - include/sound/info.h
5 * Header file for info interface
6 * Copyright (c) by Jaroslav Kysela <perex@perex.cz>
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.
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.
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
25 #include <linux/poll.h>
26 #include <linux/seq_file.h>
27 #include <sound/core.h>
29 /* buffer for information */
30 struct snd_info_buffer
{
31 char *buffer
; /* pointer to begin of buffer */
32 unsigned int curr
; /* current position in buffer */
33 unsigned int size
; /* current size */
34 unsigned int len
; /* total length of buffer */
35 int stop
; /* stop flag */
36 int error
; /* error code */
39 #define SNDRV_INFO_CONTENT_TEXT 0
40 #define SNDRV_INFO_CONTENT_DATA 1
42 struct snd_info_entry
;
44 struct snd_info_entry_text
{
45 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
);
51 struct snd_info_entry_ops
{
52 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
);
56 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 __poll_t (*poll
)(struct snd_info_entry
*entry
,
66 void *file_private_data
, struct file
*file
,
68 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
);
75 struct snd_info_entry
{
79 unsigned short content
;
81 struct snd_info_entry_text text
;
82 struct snd_info_entry_ops
*ops
;
84 struct snd_info_entry
*parent
;
85 struct module
*module
;
87 void (*private_free
)(struct snd_info_entry
*entry
);
88 struct proc_dir_entry
*p
;
90 struct list_head children
;
91 struct list_head list
;
94 #if defined(CONFIG_SND_OSSEMUL) && defined(CONFIG_SND_PROC_FS)
95 int snd_info_minor_register(void);
97 #define snd_info_minor_register() 0
101 #ifdef CONFIG_SND_PROC_FS
103 extern struct snd_info_entry
*snd_seq_root
;
104 #ifdef CONFIG_SND_OSSEMUL
105 extern struct snd_info_entry
*snd_oss_root
;
106 void snd_card_info_read_oss(struct snd_info_buffer
*buffer
);
108 #define snd_oss_root NULL
109 static inline void snd_card_info_read_oss(struct snd_info_buffer
*buffer
) {}
113 * snd_iprintf - printf on the procfs buffer
114 * @buf: the procfs buffer
115 * @fmt: the printf format
117 * Outputs the string on the procfs buffer just like printf().
119 * Return: zero for success, or a negative error code.
121 #define snd_iprintf(buf, fmt, args...) \
122 seq_printf((struct seq_file *)(buf)->buffer, fmt, ##args)
124 int snd_info_init(void);
125 int snd_info_done(void);
127 int snd_info_get_line(struct snd_info_buffer
*buffer
, char *line
, int len
);
128 const char *snd_info_get_str(char *dest
, const char *src
, int len
);
129 struct snd_info_entry
*snd_info_create_module_entry(struct module
*module
,
131 struct snd_info_entry
*parent
);
132 struct snd_info_entry
*snd_info_create_card_entry(struct snd_card
*card
,
134 struct snd_info_entry
*parent
);
135 void snd_info_free_entry(struct snd_info_entry
*entry
);
136 int snd_info_store_text(struct snd_info_entry
*entry
);
137 int snd_info_restore_text(struct snd_info_entry
*entry
);
139 int snd_info_card_create(struct snd_card
*card
);
140 int snd_info_card_register(struct snd_card
*card
);
141 int snd_info_card_free(struct snd_card
*card
);
142 void snd_info_card_disconnect(struct snd_card
*card
);
143 void snd_info_card_id_change(struct snd_card
*card
);
144 int snd_info_register(struct snd_info_entry
*entry
);
146 /* for card drivers */
147 static inline int snd_card_proc_new(struct snd_card
*card
, const char *name
,
148 struct snd_info_entry
**entryp
)
150 *entryp
= snd_info_create_card_entry(card
, name
, card
->proc_root
);
151 return *entryp
? 0 : -ENOMEM
;
154 static inline void snd_info_set_text_ops(struct snd_info_entry
*entry
,
156 void (*read
)(struct snd_info_entry
*, struct snd_info_buffer
*))
158 entry
->private_data
= private_data
;
159 entry
->c
.text
.read
= read
;
162 int snd_card_rw_proc_new(struct snd_card
*card
, const char *name
,
164 void (*read
)(struct snd_info_entry
*,
165 struct snd_info_buffer
*),
166 void (*write
)(struct snd_info_entry
*entry
,
167 struct snd_info_buffer
*buffer
));
169 int snd_info_check_reserved_words(const char *str
);
173 #define snd_seq_root NULL
174 #define snd_oss_root NULL
176 static inline int snd_iprintf(struct snd_info_buffer
*buffer
, char *fmt
, ...) { return 0; }
177 static inline int snd_info_init(void) { return 0; }
178 static inline int snd_info_done(void) { return 0; }
180 static inline int snd_info_get_line(struct snd_info_buffer
*buffer
, char *line
, int len
) { return 0; }
181 static inline char *snd_info_get_str(char *dest
, char *src
, int len
) { return NULL
; }
182 static inline struct snd_info_entry
*snd_info_create_module_entry(struct module
*module
, const char *name
, struct snd_info_entry
*parent
) { return NULL
; }
183 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
; }
184 static inline void snd_info_free_entry(struct snd_info_entry
*entry
) { ; }
186 static inline int snd_info_card_create(struct snd_card
*card
) { return 0; }
187 static inline int snd_info_card_register(struct snd_card
*card
) { return 0; }
188 static inline int snd_info_card_free(struct snd_card
*card
) { return 0; }
189 static inline void snd_info_card_disconnect(struct snd_card
*card
) { }
190 static inline void snd_info_card_id_change(struct snd_card
*card
) { }
191 static inline int snd_info_register(struct snd_info_entry
*entry
) { return 0; }
193 static inline int snd_card_proc_new(struct snd_card
*card
, const char *name
,
194 struct snd_info_entry
**entryp
) { return -EINVAL
; }
195 static inline void snd_info_set_text_ops(struct snd_info_entry
*entry
__attribute__((unused
)),
197 void (*read
)(struct snd_info_entry
*, struct snd_info_buffer
*)) {}
198 static inline int snd_card_rw_proc_new(struct snd_card
*card
, const char *name
,
200 void (*read
)(struct snd_info_entry
*,
201 struct snd_info_buffer
*),
202 void (*write
)(struct snd_info_entry
*entry
,
203 struct snd_info_buffer
*buffer
))
207 static inline int snd_info_check_reserved_words(const char *str
) { return 1; }
212 * snd_card_ro_proc_new - Create a read-only text proc file entry for the card
213 * @card: the card instance
214 * @name: the file name
215 * @private_data: the arbitrary private data
216 * @read: the read callback
218 * This proc file entry will be registered via snd_card_register() call, and
219 * it will be removed automatically at the card removal, too.
222 snd_card_ro_proc_new(struct snd_card
*card
, const char *name
,
224 void (*read
)(struct snd_info_entry
*,
225 struct snd_info_buffer
*))
227 return snd_card_rw_proc_new(card
, name
, private_data
, read
, NULL
);
234 #if defined(CONFIG_SND_OSSEMUL) && defined(CONFIG_SND_PROC_FS)
236 #define SNDRV_OSS_INFO_DEV_AUDIO 0
237 #define SNDRV_OSS_INFO_DEV_SYNTH 1
238 #define SNDRV_OSS_INFO_DEV_MIDI 2
239 #define SNDRV_OSS_INFO_DEV_TIMERS 4
240 #define SNDRV_OSS_INFO_DEV_MIXERS 5
242 #define SNDRV_OSS_INFO_DEV_COUNT 6
244 int snd_oss_info_register(int dev
, int num
, char *string
);
245 #define snd_oss_info_unregister(dev, num) snd_oss_info_register(dev, num, NULL)
247 #endif /* CONFIG_SND_OSSEMUL && CONFIG_SND_PROC_FS */
249 #endif /* __SOUND_INFO_H */