aboutsummaryrefslogtreecommitdiffstats
path: root/include/sound/core.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/sound/core.h')
-rw-r--r--include/sound/core.h223
1 files changed, 83 insertions, 140 deletions
diff --git a/include/sound/core.h b/include/sound/core.h
index 2be65ad2fd83..90ac6132ea3b 100644
--- a/include/sound/core.h
+++ b/include/sound/core.h
@@ -28,13 +28,6 @@
28#include <linux/workqueue.h> /* struct workqueue_struct */ 28#include <linux/workqueue.h> /* struct workqueue_struct */
29#include <linux/pm.h> /* pm_message_t */ 29#include <linux/pm.h> /* pm_message_t */
30 30
31/* Typedef's */
32typedef struct sndrv_interval snd_interval_t;
33typedef enum sndrv_card_type snd_card_type;
34typedef struct sndrv_xferi snd_xferi_t;
35typedef struct sndrv_xfern snd_xfern_t;
36typedef struct sndrv_xferv snd_xferv_t;
37
38/* forward declarations */ 31/* forward declarations */
39#ifdef CONFIG_PCI 32#ifdef CONFIG_PCI
40struct pci_dev; 33struct pci_dev;
@@ -47,76 +40,50 @@ struct sbus_dev;
47 40
48#define SNDRV_DEV_TYPE_RANGE_SIZE 0x1000 41#define SNDRV_DEV_TYPE_RANGE_SIZE 0x1000
49 42
50typedef enum { 43typedef int __bitwise snd_device_type_t;
51 SNDRV_DEV_TOPLEVEL = (0*SNDRV_DEV_TYPE_RANGE_SIZE), 44#define SNDRV_DEV_TOPLEVEL ((__force snd_device_type_t) 0)
52 SNDRV_DEV_CONTROL, 45#define SNDRV_DEV_CONTROL ((__force snd_device_type_t) 1)
53 SNDRV_DEV_LOWLEVEL_PRE, 46#define SNDRV_DEV_LOWLEVEL_PRE ((__force snd_device_type_t) 2)
54 SNDRV_DEV_LOWLEVEL_NORMAL = (1*SNDRV_DEV_TYPE_RANGE_SIZE), 47#define SNDRV_DEV_LOWLEVEL_NORMAL ((__force snd_device_type_t) 0x1000)
55 SNDRV_DEV_PCM, 48#define SNDRV_DEV_PCM ((__force snd_device_type_t) 0x1001)
56 SNDRV_DEV_RAWMIDI, 49#define SNDRV_DEV_RAWMIDI ((__force snd_device_type_t) 0x1002)
57 SNDRV_DEV_TIMER, 50#define SNDRV_DEV_TIMER ((__force snd_device_type_t) 0x1003)
58 SNDRV_DEV_SEQUENCER, 51#define SNDRV_DEV_SEQUENCER ((__force snd_device_type_t) 0x1004)
59 SNDRV_DEV_HWDEP, 52#define SNDRV_DEV_HWDEP ((__force snd_device_type_t) 0x1005)
60 SNDRV_DEV_INFO, 53#define SNDRV_DEV_INFO ((__force snd_device_type_t) 0x1006)
61 SNDRV_DEV_BUS, 54#define SNDRV_DEV_BUS ((__force snd_device_type_t) 0x1007)
62 SNDRV_DEV_CODEC, 55#define SNDRV_DEV_CODEC ((__force snd_device_type_t) 0x1008)
63 SNDRV_DEV_LOWLEVEL = (2*SNDRV_DEV_TYPE_RANGE_SIZE) 56#define SNDRV_DEV_LOWLEVEL ((__force snd_device_type_t) 0x2000)
64} snd_device_type_t; 57
65 58typedef int __bitwise snd_device_state_t;
66typedef enum { 59#define SNDRV_DEV_BUILD ((__force snd_device_state_t) 0)
67 SNDRV_DEV_BUILD, 60#define SNDRV_DEV_REGISTERED ((__force snd_device_state_t) 1)
68 SNDRV_DEV_REGISTERED, 61#define SNDRV_DEV_DISCONNECTED ((__force snd_device_state_t) 2)
69 SNDRV_DEV_DISCONNECTED 62
70} snd_device_state_t; 63typedef int __bitwise snd_device_cmd_t;
71 64#define SNDRV_DEV_CMD_PRE ((__force snd_device_cmd_t) 0)
72typedef enum { 65#define SNDRV_DEV_CMD_NORMAL ((__force snd_device_cmd_t) 1)
73 SNDRV_DEV_CMD_PRE = 0, 66#define SNDRV_DEV_CMD_POST ((__force snd_device_cmd_t) 2)
74 SNDRV_DEV_CMD_NORMAL = 1, 67
75 SNDRV_DEV_CMD_POST = 2 68struct snd_device;
76} snd_device_cmd_t; 69
77 70struct snd_device_ops {
78typedef struct _snd_card snd_card_t; 71 int (*dev_free)(struct snd_device *dev);
79typedef struct _snd_device snd_device_t; 72 int (*dev_register)(struct snd_device *dev);
80 73 int (*dev_disconnect)(struct snd_device *dev);
81typedef int (snd_dev_free_t)(snd_device_t *device); 74 int (*dev_unregister)(struct snd_device *dev);
82typedef int (snd_dev_register_t)(snd_device_t *device); 75};
83typedef int (snd_dev_disconnect_t)(snd_device_t *device); 76
84typedef int (snd_dev_unregister_t)(snd_device_t *device); 77struct snd_device {
85
86typedef struct {
87 snd_dev_free_t *dev_free;
88 snd_dev_register_t *dev_register;
89 snd_dev_disconnect_t *dev_disconnect;
90 snd_dev_unregister_t *dev_unregister;
91} snd_device_ops_t;
92
93struct _snd_device {
94 struct list_head list; /* list of registered devices */ 78 struct list_head list; /* list of registered devices */
95 snd_card_t *card; /* card which holds this device */ 79 struct snd_card *card; /* card which holds this device */
96 snd_device_state_t state; /* state of the device */ 80 snd_device_state_t state; /* state of the device */
97 snd_device_type_t type; /* device type */ 81 snd_device_type_t type; /* device type */
98 void *device_data; /* device structure */ 82 void *device_data; /* device structure */
99 snd_device_ops_t *ops; /* operations */ 83 struct snd_device_ops *ops; /* operations */
100}; 84};
101 85
102#define snd_device(n) list_entry(n, snd_device_t, list) 86#define snd_device(n) list_entry(n, struct snd_device, list)
103
104/* various typedefs */
105
106typedef struct snd_info_entry snd_info_entry_t;
107typedef struct _snd_pcm snd_pcm_t;
108typedef struct _snd_pcm_str snd_pcm_str_t;
109typedef struct _snd_pcm_substream snd_pcm_substream_t;
110typedef struct _snd_mixer snd_kmixer_t;
111typedef struct _snd_rawmidi snd_rawmidi_t;
112typedef struct _snd_ctl_file snd_ctl_file_t;
113typedef struct _snd_kcontrol snd_kcontrol_t;
114typedef struct _snd_timer snd_timer_t;
115typedef struct _snd_timer_instance snd_timer_instance_t;
116typedef struct _snd_hwdep snd_hwdep_t;
117#if defined(CONFIG_SND_MIXER_OSS) || defined(CONFIG_SND_MIXER_OSS_MODULE)
118typedef struct _snd_oss_mixer snd_mixer_oss_t;
119#endif
120 87
121/* monitor files for graceful shutdown (hotplug) */ 88/* monitor files for graceful shutdown (hotplug) */
122 89
@@ -129,7 +96,7 @@ struct snd_shutdown_f_ops; /* define it later in init.c */
129 96
130/* main structure for soundcard */ 97/* main structure for soundcard */
131 98
132struct _snd_card { 99struct snd_card {
133 int number; /* number of soundcard (index to 100 int number; /* number of soundcard (index to
134 snd_cards) */ 101 snd_cards) */
135 102
@@ -143,7 +110,7 @@ struct _snd_card {
143 struct module *module; /* top-level module */ 110 struct module *module; /* top-level module */
144 111
145 void *private_data; /* private data for soundcard */ 112 void *private_data; /* private data for soundcard */
146 void (*private_free) (snd_card_t *card); /* callback for freeing of 113 void (*private_free) (struct snd_card *card); /* callback for freeing of
147 private data */ 114 private data */
148 struct list_head devices; /* devices */ 115 struct list_head devices; /* devices */
149 116
@@ -155,8 +122,8 @@ struct _snd_card {
155 struct list_head controls; /* all controls for this card */ 122 struct list_head controls; /* all controls for this card */
156 struct list_head ctl_files; /* active control files */ 123 struct list_head ctl_files; /* active control files */
157 124
158 snd_info_entry_t *proc_root; /* root for soundcard specific files */ 125 struct snd_info_entry *proc_root; /* root for soundcard specific files */
159 snd_info_entry_t *proc_id; /* the card id */ 126 struct snd_info_entry *proc_id; /* the card id */
160 struct proc_dir_entry *proc_root_link; /* number link to real id */ 127 struct proc_dir_entry *proc_root_link; /* number link to real id */
161 128
162 struct snd_monitor_file *files; /* all files associated to this card */ 129 struct snd_monitor_file *files; /* all files associated to this card */
@@ -167,92 +134,64 @@ struct _snd_card {
167 wait_queue_head_t shutdown_sleep; 134 wait_queue_head_t shutdown_sleep;
168 struct work_struct free_workq; /* for free in workqueue */ 135 struct work_struct free_workq; /* for free in workqueue */
169 struct device *dev; 136 struct device *dev;
170#ifdef CONFIG_SND_GENERIC_DRIVER
171 struct snd_generic_device *generic_dev;
172#endif
173 137
174#ifdef CONFIG_PM 138#ifdef CONFIG_PM
175 int (*pm_suspend)(snd_card_t *card, pm_message_t state);
176 int (*pm_resume)(snd_card_t *card);
177 void *pm_private_data;
178 unsigned int power_state; /* power state */ 139 unsigned int power_state; /* power state */
179 struct semaphore power_lock; /* power lock */ 140 struct semaphore power_lock; /* power lock */
180 wait_queue_head_t power_sleep; 141 wait_queue_head_t power_sleep;
181#endif 142#endif
182 143
183#if defined(CONFIG_SND_MIXER_OSS) || defined(CONFIG_SND_MIXER_OSS_MODULE) 144#if defined(CONFIG_SND_MIXER_OSS) || defined(CONFIG_SND_MIXER_OSS_MODULE)
184 snd_mixer_oss_t *mixer_oss; 145 struct snd_mixer_oss *mixer_oss;
185 int mixer_oss_change_count; 146 int mixer_oss_change_count;
186#endif 147#endif
187}; 148};
188 149
189#ifdef CONFIG_PM 150#ifdef CONFIG_PM
190static inline void snd_power_lock(snd_card_t *card) 151static inline void snd_power_lock(struct snd_card *card)
191{ 152{
192 down(&card->power_lock); 153 down(&card->power_lock);
193} 154}
194 155
195static inline void snd_power_unlock(snd_card_t *card) 156static inline void snd_power_unlock(struct snd_card *card)
196{ 157{
197 up(&card->power_lock); 158 up(&card->power_lock);
198} 159}
199 160
200static inline unsigned int snd_power_get_state(snd_card_t *card) 161static inline unsigned int snd_power_get_state(struct snd_card *card)
201{ 162{
202 return card->power_state; 163 return card->power_state;
203} 164}
204 165
205static inline void snd_power_change_state(snd_card_t *card, unsigned int state) 166static inline void snd_power_change_state(struct snd_card *card, unsigned int state)
206{ 167{
207 card->power_state = state; 168 card->power_state = state;
208 wake_up(&card->power_sleep); 169 wake_up(&card->power_sleep);
209} 170}
210 171
211/* init.c */ 172/* init.c */
212int snd_power_wait(snd_card_t *card, unsigned int power_state, struct file *file); 173int snd_power_wait(struct snd_card *card, unsigned int power_state, struct file *file);
213
214int snd_card_set_pm_callback(snd_card_t *card,
215 int (*suspend)(snd_card_t *, pm_message_t),
216 int (*resume)(snd_card_t *),
217 void *private_data);
218int snd_card_set_generic_pm_callback(snd_card_t *card,
219 int (*suspend)(snd_card_t *, pm_message_t),
220 int (*resume)(snd_card_t *),
221 void *private_data);
222#define snd_card_set_isa_pm_callback(card,suspend,resume,data) \
223 snd_card_set_generic_pm_callback(card, suspend, resume, data)
224struct pci_dev;
225int snd_card_pci_suspend(struct pci_dev *dev, pm_message_t state);
226int snd_card_pci_resume(struct pci_dev *dev);
227#define SND_PCI_PM_CALLBACKS \
228 .suspend = snd_card_pci_suspend, .resume = snd_card_pci_resume
229 174
230#else /* ! CONFIG_PM */ 175#else /* ! CONFIG_PM */
231 176
232#define snd_power_lock(card) do { (void)(card); } while (0) 177#define snd_power_lock(card) do { (void)(card); } while (0)
233#define snd_power_unlock(card) do { (void)(card); } while (0) 178#define snd_power_unlock(card) do { (void)(card); } while (0)
234static inline int snd_power_wait(snd_card_t *card, unsigned int state, struct file *file) { return 0; } 179static inline int snd_power_wait(struct snd_card *card, unsigned int state, struct file *file) { return 0; }
235#define snd_power_get_state(card) SNDRV_CTL_POWER_D0 180#define snd_power_get_state(card) SNDRV_CTL_POWER_D0
236#define snd_power_change_state(card, state) do { (void)(card); } while (0) 181#define snd_power_change_state(card, state) do { (void)(card); } while (0)
237#define snd_card_set_pm_callback(card,suspend,resume,data)
238#define snd_card_set_generic_pm_callback(card,suspend,resume,data)
239#define snd_card_set_isa_pm_callback(card,suspend,resume,data)
240#define SND_PCI_PM_CALLBACKS
241 182
242#endif /* CONFIG_PM */ 183#endif /* CONFIG_PM */
243 184
244struct _snd_minor { 185struct snd_minor {
245 struct list_head list; /* list of all minors per card */ 186 int type; /* SNDRV_DEVICE_TYPE_XXX */
246 int number; /* minor number */ 187 int card; /* card number */
247 int device; /* device number */ 188 int device; /* device number */
248 const char *comment; /* for /proc/asound/devices */
249 struct file_operations *f_ops; /* file operations */ 189 struct file_operations *f_ops; /* file operations */
190 void *private_data; /* private data for f_ops->open */
250 char name[0]; /* device name (keep at the end of 191 char name[0]; /* device name (keep at the end of
251 structure) */ 192 structure) */
252}; 193};
253 194
254typedef struct _snd_minor snd_minor_t;
255
256/* sound.c */ 195/* sound.c */
257 196
258extern int snd_major; 197extern int snd_major;
@@ -260,12 +199,18 @@ extern int snd_ecards_limit;
260 199
261void snd_request_card(int card); 200void snd_request_card(int card);
262 201
263int snd_register_device(int type, snd_card_t *card, int dev, snd_minor_t *reg, const char *name); 202int snd_register_device(int type, struct snd_card *card, int dev,
264int snd_unregister_device(int type, snd_card_t *card, int dev); 203 struct file_operations *f_ops, void *private_data,
204 const char *name);
205int snd_unregister_device(int type, struct snd_card *card, int dev);
206void *snd_lookup_minor_data(unsigned int minor, int type);
265 207
266#ifdef CONFIG_SND_OSSEMUL 208#ifdef CONFIG_SND_OSSEMUL
267int snd_register_oss_device(int type, snd_card_t *card, int dev, snd_minor_t *reg, const char *name); 209int snd_register_oss_device(int type, struct snd_card *card, int dev,
268int snd_unregister_oss_device(int type, snd_card_t *card, int dev); 210 struct file_operations *f_ops, void *private_data,
211 const char *name);
212int snd_unregister_oss_device(int type, struct snd_card *card, int dev);
213void *snd_lookup_oss_minor_data(unsigned int minor, int type);
269#endif 214#endif
270 215
271int snd_minor_info_init(void); 216int snd_minor_info_init(void);
@@ -276,11 +221,9 @@ int snd_minor_info_done(void);
276#ifdef CONFIG_SND_OSSEMUL 221#ifdef CONFIG_SND_OSSEMUL
277int snd_minor_info_oss_init(void); 222int snd_minor_info_oss_init(void);
278int snd_minor_info_oss_done(void); 223int snd_minor_info_oss_done(void);
279int snd_oss_init_module(void);
280#else 224#else
281#define snd_minor_info_oss_init() /*NOP*/ 225#define snd_minor_info_oss_init() /*NOP*/
282#define snd_minor_info_oss_done() /*NOP*/ 226#define snd_minor_info_oss_done() /*NOP*/
283#define snd_oss_init_module() 0
284#endif 227#endif
285 228
286/* memory.c */ 229/* memory.c */
@@ -291,43 +234,41 @@ int copy_from_user_toio(volatile void __iomem *dst, const void __user *src, size
291/* init.c */ 234/* init.c */
292 235
293extern unsigned int snd_cards_lock; 236extern unsigned int snd_cards_lock;
294extern snd_card_t *snd_cards[SNDRV_CARDS]; 237extern struct snd_card *snd_cards[SNDRV_CARDS];
295extern rwlock_t snd_card_rwlock; 238extern rwlock_t snd_card_rwlock;
296#if defined(CONFIG_SND_MIXER_OSS) || defined(CONFIG_SND_MIXER_OSS_MODULE) 239#if defined(CONFIG_SND_MIXER_OSS) || defined(CONFIG_SND_MIXER_OSS_MODULE)
297#define SND_MIXER_OSS_NOTIFY_REGISTER 0 240#define SND_MIXER_OSS_NOTIFY_REGISTER 0
298#define SND_MIXER_OSS_NOTIFY_DISCONNECT 1 241#define SND_MIXER_OSS_NOTIFY_DISCONNECT 1
299#define SND_MIXER_OSS_NOTIFY_FREE 2 242#define SND_MIXER_OSS_NOTIFY_FREE 2
300extern int (*snd_mixer_oss_notify_callback)(snd_card_t *card, int cmd); 243extern int (*snd_mixer_oss_notify_callback)(struct snd_card *card, int cmd);
301#endif 244#endif
302 245
303snd_card_t *snd_card_new(int idx, const char *id, 246struct snd_card *snd_card_new(int idx, const char *id,
304 struct module *module, int extra_size); 247 struct module *module, int extra_size);
305int snd_card_disconnect(snd_card_t *card); 248int snd_card_disconnect(struct snd_card *card);
306int snd_card_free(snd_card_t *card); 249int snd_card_free(struct snd_card *card);
307int snd_card_free_in_thread(snd_card_t *card); 250int snd_card_free_in_thread(struct snd_card *card);
308int snd_card_register(snd_card_t *card); 251int snd_card_register(struct snd_card *card);
309int snd_card_info_init(void); 252int snd_card_info_init(void);
310int snd_card_info_done(void); 253int snd_card_info_done(void);
311int snd_component_add(snd_card_t *card, const char *component); 254int snd_component_add(struct snd_card *card, const char *component);
312int snd_card_file_add(snd_card_t *card, struct file *file); 255int snd_card_file_add(struct snd_card *card, struct file *file);
313int snd_card_file_remove(snd_card_t *card, struct file *file); 256int snd_card_file_remove(struct snd_card *card, struct file *file);
314 257
315#ifndef snd_card_set_dev 258#ifndef snd_card_set_dev
316#define snd_card_set_dev(card,devptr) ((card)->dev = (devptr)) 259#define snd_card_set_dev(card,devptr) ((card)->dev = (devptr))
317#endif 260#endif
318/* register a generic device (for ISA, etc) */
319int snd_card_set_generic_dev(snd_card_t *card);
320 261
321/* device.c */ 262/* device.c */
322 263
323int snd_device_new(snd_card_t *card, snd_device_type_t type, 264int snd_device_new(struct snd_card *card, snd_device_type_t type,
324 void *device_data, snd_device_ops_t *ops); 265 void *device_data, struct snd_device_ops *ops);
325int snd_device_register(snd_card_t *card, void *device_data); 266int snd_device_register(struct snd_card *card, void *device_data);
326int snd_device_register_all(snd_card_t *card); 267int snd_device_register_all(struct snd_card *card);
327int snd_device_disconnect(snd_card_t *card, void *device_data); 268int snd_device_disconnect(struct snd_card *card, void *device_data);
328int snd_device_disconnect_all(snd_card_t *card); 269int snd_device_disconnect_all(struct snd_card *card);
329int snd_device_free(snd_card_t *card, void *device_data); 270int snd_device_free(struct snd_card *card, void *device_data);
330int snd_device_free_all(snd_card_t *card, snd_device_cmd_t cmd); 271int snd_device_free_all(struct snd_card *card, snd_device_cmd_t cmd);
331 272
332/* isadma.c */ 273/* isadma.c */
333 274
@@ -443,4 +384,6 @@ void snd_verbose_printd(const char *file, int line, const char *format, ...)
443#endif 384#endif
444#endif 385#endif
445 386
387#include "typedefs.h"
388
446#endif /* __SOUND_CORE_H */ 389#endif /* __SOUND_CORE_H */