source: GPL/trunk/alsa-kernel/include/sound/info.h

Last change on this file was 772, checked in by David Azarewicz, 6 months ago

Merge in changes from 6.6-LTS branch.
Fixed additional 25+ problems.

File size: 8.2 KB
Line 
1/* SPDX-License-Identifier: GPL-2.0-or-later */
2#ifndef __SOUND_INFO_H
3#define __SOUND_INFO_H
4
5/*
6 * Header file for info interface
7 * Copyright (c) by Jaroslav Kysela <perex@perex.cz>
8 */
9
10#include <linux/poll.h>
11#include <linux/seq_file.h>
12#include <sound/core.h>
13
14/* buffer for information */
15struct snd_info_buffer {
16 char *buffer; /* pointer to begin of buffer */
17 unsigned int curr; /* current position in buffer */
18 unsigned int size; /* current size */
19 unsigned int len; /* total length of buffer */
20 int stop; /* stop flag */
21 int error; /* error code */
22};
23
24#define SNDRV_INFO_CONTENT_TEXT 0
25#define SNDRV_INFO_CONTENT_DATA 1
26
27struct snd_info_entry;
28
29struct snd_info_entry_text {
30 void (*read)(struct snd_info_entry *entry,
31 struct snd_info_buffer *buffer);
32 void (*write)(struct snd_info_entry *entry,
33 struct snd_info_buffer *buffer);
34};
35
36struct snd_info_entry_ops {
37 int (*open)(struct snd_info_entry *entry,
38 unsigned short mode, void **file_private_data);
39 int (*release)(struct snd_info_entry *entry,
40 unsigned short mode, void *file_private_data);
41 ssize_t (*read)(struct snd_info_entry *entry, void *file_private_data,
42 struct file *file, char __user *buf,
43 size_t count, loff_t pos);
44 ssize_t (*write)(struct snd_info_entry *entry, void *file_private_data,
45 struct file *file, const char __user *buf,
46 size_t count, loff_t pos);
47 loff_t (*llseek)(struct snd_info_entry *entry,
48 void *file_private_data, struct file *file,
49 loff_t offset, int orig);
50 __poll_t (*poll)(struct snd_info_entry *entry,
51 void *file_private_data, struct file *file,
52 poll_table *wait);
53 int (*ioctl)(struct snd_info_entry *entry, void *file_private_data,
54 struct file *file, unsigned int cmd, unsigned long arg);
55 int (*mmap)(struct snd_info_entry *entry, void *file_private_data,
56 struct inode *inode, struct file *file,
57 struct vm_area_struct *vma);
58};
59
60struct snd_info_entry {
61 const char *name;
62 umode_t mode;
63 long size;
64 unsigned short content;
65 union {
66 struct snd_info_entry_text text;
67 const struct snd_info_entry_ops *ops;
68 } c;
69 struct snd_info_entry *parent;
70 struct module *module;
71 void *private_data;
72 void (*private_free)(struct snd_info_entry *entry);
73 struct proc_dir_entry *p;
74 struct mutex access;
75 struct list_head children;
76 struct list_head list;
77};
78
79#if (defined(CONFIG_SND_OSSEMUL) && defined(CONFIG_SND_PROC_FS)) || defined(TARGET_OS2)
80int snd_info_minor_register(void);
81#else
82#define snd_info_minor_register() 0
83#endif
84
85
86#if defined(CONFIG_SND_PROC_FS)
87
88extern struct snd_info_entry *snd_seq_root;
89#ifdef CONFIG_SND_OSSEMUL
90extern struct snd_info_entry *snd_oss_root;
91void snd_card_info_read_oss(struct snd_info_buffer *buffer);
92#else
93#define snd_oss_root NULL
94static inline void snd_card_info_read_oss(struct snd_info_buffer *buffer) {}
95#endif
96
97/**
98 * snd_iprintf - printf on the procfs buffer
99 * @buf: the procfs buffer
100 * @fmt: the printf format
101 *
102 * Outputs the string on the procfs buffer just like printf().
103 *
104 * Return: zero for success, or a negative error code.
105 */
106#ifndef TARGET_OS2
107#define snd_iprintf(buf, fmt, args...) \
108 seq_printf((struct seq_file *)(buf)->buffer, fmt, ##args)
109#else
110static inline int snd_iprintf(struct snd_info_buffer *buffer, char *fmt, ...) { return 0; }
111#endif
112
113int snd_info_init(void);
114int snd_info_done(void);
115
116int snd_info_get_line(struct snd_info_buffer *buffer, char *line, int len);
117const char *snd_info_get_str(char *dest, const char *src, int len);
118struct snd_info_entry *snd_info_create_module_entry(struct module *module,
119 const char *name,
120 struct snd_info_entry *parent);
121struct snd_info_entry *snd_info_create_card_entry(struct snd_card *card,
122 const char *name,
123 struct snd_info_entry *parent);
124void snd_info_free_entry(struct snd_info_entry *entry);
125
126int snd_info_card_create(struct snd_card *card);
127int snd_info_card_register(struct snd_card *card);
128int snd_info_card_free(struct snd_card *card);
129void snd_info_card_disconnect(struct snd_card *card);
130void snd_info_card_id_change(struct snd_card *card);
131int snd_info_register(struct snd_info_entry *entry);
132
133/* for card drivers */
134static inline int snd_card_proc_new(struct snd_card *card, const char *name,
135 struct snd_info_entry **entryp)
136{
137 *entryp = snd_info_create_card_entry(card, name, card->proc_root);
138 return *entryp ? 0 : -ENOMEM;
139}
140
141static inline void snd_info_set_text_ops(struct snd_info_entry *entry,
142 void *private_data,
143 void (*read)(struct snd_info_entry *, struct snd_info_buffer *))
144{
145 entry->private_data = private_data;
146 entry->c.text.read = read;
147}
148
149int snd_card_rw_proc_new(struct snd_card *card, const char *name,
150 void *private_data,
151 void (*read)(struct snd_info_entry *,
152 struct snd_info_buffer *),
153 void (*write)(struct snd_info_entry *entry,
154 struct snd_info_buffer *buffer));
155
156int snd_info_check_reserved_words(const char *str);
157
158#else
159
160#define snd_seq_root NULL
161#define snd_oss_root NULL
162
163static inline int snd_iprintf(struct snd_info_buffer *buffer, char *fmt, ...) { return 0; }
164static inline int snd_info_init(void) { return 0; }
165static inline int snd_info_done(void) { return 0; }
166
167static inline int snd_info_get_line(struct snd_info_buffer *buffer, char *line, int len) { return 0; }
168static inline char *snd_info_get_str(char *dest, char *src, int len) { return NULL; }
169static inline struct snd_info_entry *snd_info_create_module_entry(struct module *module, const char *name, struct snd_info_entry *parent) { return NULL; }
170static inline struct snd_info_entry *snd_info_create_card_entry(struct snd_card *card, const char *name, struct snd_info_entry *parent) { return NULL; }
171static inline void snd_info_free_entry(struct snd_info_entry *entry) { ; }
172
173static inline int snd_info_card_create(struct snd_card *card) { return 0; }
174static inline int snd_info_card_register(struct snd_card *card) { return 0; }
175static inline int snd_info_card_free(struct snd_card *card) { return 0; }
176static inline void snd_info_card_disconnect(struct snd_card *card) { }
177static inline void snd_info_card_id_change(struct snd_card *card) { }
178static inline int snd_info_register(struct snd_info_entry *entry) { return 0; }
179
180static inline int snd_card_proc_new(struct snd_card *card, const char *name,
181 struct snd_info_entry **entryp) { return -EINVAL; }
182static inline void snd_info_set_text_ops(struct snd_info_entry *entry /*__attribute__((unused))*/,
183 void *private_data,
184 void (*read)(struct snd_info_entry *, struct snd_info_buffer *)) {}
185static inline int snd_card_rw_proc_new(struct snd_card *card, const char *name,
186 void *private_data,
187 void (*read)(struct snd_info_entry *,
188 struct snd_info_buffer *),
189 void (*write)(struct snd_info_entry *entry,
190 struct snd_info_buffer *buffer))
191{
192 return 0;
193}
194static inline int snd_info_check_reserved_words(const char *str) { return 1; }
195
196#endif
197
198/**
199 * snd_card_ro_proc_new - Create a read-only text proc file entry for the card
200 * @card: the card instance
201 * @name: the file name
202 * @private_data: the arbitrary private data
203 * @read: the read callback
204 *
205 * This proc file entry will be registered via snd_card_register() call, and
206 * it will be removed automatically at the card removal, too.
207 */
208static inline int
209snd_card_ro_proc_new(struct snd_card *card, const char *name,
210 void *private_data,
211 void (*read)(struct snd_info_entry *,
212 struct snd_info_buffer *))
213{
214 return snd_card_rw_proc_new(card, name, private_data, read, NULL);
215}
216
217/*
218 * OSS info part
219 */
220
221#if (defined(CONFIG_SND_OSSEMUL) && defined(CONFIG_SND_PROC_FS)) || defined(TARGET_OS2)
222
223#define SNDRV_OSS_INFO_DEV_AUDIO 0
224#define SNDRV_OSS_INFO_DEV_SYNTH 1
225#define SNDRV_OSS_INFO_DEV_MIDI 2
226#define SNDRV_OSS_INFO_DEV_TIMERS 4
227#define SNDRV_OSS_INFO_DEV_MIXERS 5
228
229#define SNDRV_OSS_INFO_DEV_COUNT 6
230
231int snd_oss_info_register(int dev, int num, char *string);
232#define snd_oss_info_unregister(dev, num) snd_oss_info_register(dev, num, NULL)
233
234#endif /* CONFIG_SND_OSSEMUL && CONFIG_SND_PROC_FS */
235
236#endif /* __SOUND_INFO_H */
Note: See TracBrowser for help on using the repository browser.