Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef __SOUND_CORE_H |
| 2 | #define __SOUND_CORE_H |
| 3 | |
| 4 | /* |
| 5 | * Main header file for the ALSA driver |
| 6 | * Copyright (c) 1994-2001 by Jaroslav Kysela <perex@suse.cz> |
| 7 | * |
| 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/sched.h> /* wake_up() */ |
| 26 | #include <asm/semaphore.h> /* struct semaphore */ |
| 27 | #include <linux/rwsem.h> /* struct rw_semaphore */ |
| 28 | #include <linux/workqueue.h> /* struct workqueue_struct */ |
| 29 | #include <linux/pm.h> /* pm_message_t */ |
| 30 | |
| 31 | /* Typedef's */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | typedef struct sndrv_interval snd_interval_t; |
| 33 | typedef enum sndrv_card_type snd_card_type; |
| 34 | typedef struct sndrv_xferi snd_xferi_t; |
| 35 | typedef struct sndrv_xfern snd_xfern_t; |
| 36 | typedef struct sndrv_xferv snd_xferv_t; |
| 37 | |
| 38 | /* forward declarations */ |
| 39 | #ifdef CONFIG_PCI |
| 40 | struct pci_dev; |
| 41 | #endif |
| 42 | #ifdef CONFIG_SBUS |
| 43 | struct sbus_dev; |
| 44 | #endif |
| 45 | |
| 46 | /* device allocation stuff */ |
| 47 | |
| 48 | #define SNDRV_DEV_TYPE_RANGE_SIZE 0x1000 |
| 49 | |
| 50 | typedef enum { |
| 51 | SNDRV_DEV_TOPLEVEL = (0*SNDRV_DEV_TYPE_RANGE_SIZE), |
| 52 | SNDRV_DEV_CONTROL, |
| 53 | SNDRV_DEV_LOWLEVEL_PRE, |
| 54 | SNDRV_DEV_LOWLEVEL_NORMAL = (1*SNDRV_DEV_TYPE_RANGE_SIZE), |
| 55 | SNDRV_DEV_PCM, |
| 56 | SNDRV_DEV_RAWMIDI, |
| 57 | SNDRV_DEV_TIMER, |
| 58 | SNDRV_DEV_SEQUENCER, |
| 59 | SNDRV_DEV_HWDEP, |
| 60 | SNDRV_DEV_INFO, |
| 61 | SNDRV_DEV_BUS, |
| 62 | SNDRV_DEV_CODEC, |
| 63 | SNDRV_DEV_LOWLEVEL = (2*SNDRV_DEV_TYPE_RANGE_SIZE) |
| 64 | } snd_device_type_t; |
| 65 | |
| 66 | typedef enum { |
| 67 | SNDRV_DEV_BUILD, |
| 68 | SNDRV_DEV_REGISTERED, |
| 69 | SNDRV_DEV_DISCONNECTED |
| 70 | } snd_device_state_t; |
| 71 | |
| 72 | typedef enum { |
| 73 | SNDRV_DEV_CMD_PRE = 0, |
| 74 | SNDRV_DEV_CMD_NORMAL = 1, |
| 75 | SNDRV_DEV_CMD_POST = 2 |
| 76 | } snd_device_cmd_t; |
| 77 | |
| 78 | typedef struct _snd_card snd_card_t; |
| 79 | typedef struct _snd_device snd_device_t; |
| 80 | |
| 81 | typedef int (snd_dev_free_t)(snd_device_t *device); |
| 82 | typedef int (snd_dev_register_t)(snd_device_t *device); |
| 83 | typedef int (snd_dev_disconnect_t)(snd_device_t *device); |
| 84 | typedef int (snd_dev_unregister_t)(snd_device_t *device); |
| 85 | |
| 86 | typedef 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 | |
| 93 | struct _snd_device { |
| 94 | struct list_head list; /* list of registered devices */ |
| 95 | snd_card_t *card; /* card which holds this device */ |
| 96 | snd_device_state_t state; /* state of the device */ |
| 97 | snd_device_type_t type; /* device type */ |
| 98 | void *device_data; /* device structure */ |
| 99 | snd_device_ops_t *ops; /* operations */ |
| 100 | }; |
| 101 | |
| 102 | #define snd_device(n) list_entry(n, snd_device_t, list) |
| 103 | |
| 104 | /* various typedefs */ |
| 105 | |
| 106 | typedef struct snd_info_entry snd_info_entry_t; |
| 107 | typedef struct _snd_pcm snd_pcm_t; |
| 108 | typedef struct _snd_pcm_str snd_pcm_str_t; |
| 109 | typedef struct _snd_pcm_substream snd_pcm_substream_t; |
| 110 | typedef struct _snd_mixer snd_kmixer_t; |
| 111 | typedef struct _snd_rawmidi snd_rawmidi_t; |
| 112 | typedef struct _snd_ctl_file snd_ctl_file_t; |
| 113 | typedef struct _snd_kcontrol snd_kcontrol_t; |
| 114 | typedef struct _snd_timer snd_timer_t; |
| 115 | typedef struct _snd_timer_instance snd_timer_instance_t; |
| 116 | typedef struct _snd_hwdep snd_hwdep_t; |
| 117 | #if defined(CONFIG_SND_MIXER_OSS) || defined(CONFIG_SND_MIXER_OSS_MODULE) |
| 118 | typedef struct _snd_oss_mixer snd_mixer_oss_t; |
| 119 | #endif |
| 120 | |
| 121 | /* monitor files for graceful shutdown (hotplug) */ |
| 122 | |
| 123 | struct snd_monitor_file { |
| 124 | struct file *file; |
| 125 | struct snd_monitor_file *next; |
| 126 | }; |
| 127 | |
Henrik Kretzschmar | d5750f6 | 2005-06-29 19:31:06 +0200 | [diff] [blame] | 128 | struct snd_shutdown_f_ops; /* define it later in init.c */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 129 | |
| 130 | /* main structure for soundcard */ |
| 131 | |
| 132 | struct _snd_card { |
Henrik Kretzschmar | d5750f6 | 2005-06-29 19:31:06 +0200 | [diff] [blame] | 133 | int number; /* number of soundcard (index to |
| 134 | snd_cards) */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 135 | |
| 136 | char id[16]; /* id string of this card */ |
| 137 | char driver[16]; /* driver name */ |
| 138 | char shortname[32]; /* short name of this soundcard */ |
| 139 | char longname[80]; /* name of this soundcard */ |
| 140 | char mixername[80]; /* mixer name */ |
Henrik Kretzschmar | d5750f6 | 2005-06-29 19:31:06 +0200 | [diff] [blame] | 141 | char components[80]; /* card components delimited with |
| 142 | space */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 143 | struct module *module; /* top-level module */ |
| 144 | |
| 145 | void *private_data; /* private data for soundcard */ |
Henrik Kretzschmar | d5750f6 | 2005-06-29 19:31:06 +0200 | [diff] [blame] | 146 | void (*private_free) (snd_card_t *card); /* callback for freeing of |
| 147 | private data */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 148 | struct list_head devices; /* devices */ |
| 149 | |
| 150 | unsigned int last_numid; /* last used numeric ID */ |
| 151 | struct rw_semaphore controls_rwsem; /* controls list lock */ |
| 152 | rwlock_t ctl_files_rwlock; /* ctl_files list lock */ |
| 153 | int controls_count; /* count of all controls */ |
| 154 | int user_ctl_count; /* count of all user controls */ |
| 155 | struct list_head controls; /* all controls for this card */ |
| 156 | struct list_head ctl_files; /* active control files */ |
| 157 | |
| 158 | snd_info_entry_t *proc_root; /* root for soundcard specific files */ |
| 159 | snd_info_entry_t *proc_id; /* the card id */ |
| 160 | struct proc_dir_entry *proc_root_link; /* number link to real id */ |
| 161 | |
| 162 | struct snd_monitor_file *files; /* all files associated to this card */ |
Henrik Kretzschmar | d5750f6 | 2005-06-29 19:31:06 +0200 | [diff] [blame] | 163 | struct snd_shutdown_f_ops *s_f_ops; /* file operations in the shutdown |
| 164 | state */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 165 | spinlock_t files_lock; /* lock the files for this card */ |
| 166 | int shutdown; /* this card is going down */ |
| 167 | wait_queue_head_t shutdown_sleep; |
| 168 | struct work_struct free_workq; /* for free in workqueue */ |
| 169 | struct device *dev; |
Takashi Iwai | ecbcfe3 | 2005-09-05 17:15:37 +0200 | [diff] [blame] | 170 | #ifdef CONFIG_SND_GENERIC_DRIVER |
| 171 | struct snd_generic_device *generic_dev; |
| 172 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 173 | |
| 174 | #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 */ |
| 179 | struct semaphore power_lock; /* power lock */ |
| 180 | wait_queue_head_t power_sleep; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 181 | #endif |
| 182 | |
| 183 | #if defined(CONFIG_SND_MIXER_OSS) || defined(CONFIG_SND_MIXER_OSS_MODULE) |
| 184 | snd_mixer_oss_t *mixer_oss; |
| 185 | int mixer_oss_change_count; |
| 186 | #endif |
| 187 | }; |
| 188 | |
| 189 | #ifdef CONFIG_PM |
| 190 | static inline void snd_power_lock(snd_card_t *card) |
| 191 | { |
| 192 | down(&card->power_lock); |
| 193 | } |
| 194 | |
| 195 | static inline void snd_power_unlock(snd_card_t *card) |
| 196 | { |
| 197 | up(&card->power_lock); |
| 198 | } |
| 199 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 200 | static inline unsigned int snd_power_get_state(snd_card_t *card) |
| 201 | { |
| 202 | return card->power_state; |
| 203 | } |
| 204 | |
| 205 | static inline void snd_power_change_state(snd_card_t *card, unsigned int state) |
| 206 | { |
| 207 | card->power_state = state; |
| 208 | wake_up(&card->power_sleep); |
| 209 | } |
Henrik Kretzschmar | d5750f6 | 2005-06-29 19:31:06 +0200 | [diff] [blame] | 210 | |
| 211 | /* init.c */ |
| 212 | int snd_power_wait(snd_card_t *card, unsigned int power_state, struct file *file); |
| 213 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 214 | int 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); |
| 218 | int 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) |
| 224 | struct pci_dev; |
| 225 | int snd_card_pci_suspend(struct pci_dev *dev, pm_message_t state); |
| 226 | int 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 | |
| 230 | #else /* ! CONFIG_PM */ |
| 231 | |
| 232 | #define snd_power_lock(card) do { (void)(card); } while (0) |
| 233 | #define snd_power_unlock(card) do { (void)(card); } while (0) |
| 234 | static inline int snd_power_wait(snd_card_t *card, unsigned int state, struct file *file) { return 0; } |
| 235 | #define snd_power_get_state(card) SNDRV_CTL_POWER_D0 |
| 236 | #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 | |
| 242 | #endif /* CONFIG_PM */ |
| 243 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 244 | struct _snd_minor { |
| 245 | struct list_head list; /* list of all minors per card */ |
| 246 | int number; /* minor number */ |
| 247 | int device; /* device number */ |
| 248 | const char *comment; /* for /proc/asound/devices */ |
| 249 | struct file_operations *f_ops; /* file operations */ |
Henrik Kretzschmar | d5750f6 | 2005-06-29 19:31:06 +0200 | [diff] [blame] | 250 | char name[0]; /* device name (keep at the end of |
| 251 | structure) */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 252 | }; |
| 253 | |
| 254 | typedef struct _snd_minor snd_minor_t; |
| 255 | |
| 256 | /* sound.c */ |
| 257 | |
| 258 | extern int snd_ecards_limit; |
| 259 | |
| 260 | void snd_request_card(int card); |
| 261 | |
| 262 | int snd_register_device(int type, snd_card_t *card, int dev, snd_minor_t *reg, const char *name); |
| 263 | int snd_unregister_device(int type, snd_card_t *card, int dev); |
| 264 | |
| 265 | #ifdef CONFIG_SND_OSSEMUL |
| 266 | int snd_register_oss_device(int type, snd_card_t *card, int dev, snd_minor_t *reg, const char *name); |
| 267 | int snd_unregister_oss_device(int type, snd_card_t *card, int dev); |
| 268 | #endif |
| 269 | |
| 270 | int snd_minor_info_init(void); |
| 271 | int snd_minor_info_done(void); |
| 272 | |
| 273 | /* sound_oss.c */ |
| 274 | |
| 275 | #ifdef CONFIG_SND_OSSEMUL |
| 276 | int snd_minor_info_oss_init(void); |
| 277 | int snd_minor_info_oss_done(void); |
| 278 | int snd_oss_init_module(void); |
| 279 | #else |
| 280 | #define snd_minor_info_oss_init() /*NOP*/ |
| 281 | #define snd_minor_info_oss_done() /*NOP*/ |
| 282 | #define snd_oss_init_module() 0 |
| 283 | #endif |
| 284 | |
| 285 | /* memory.c */ |
| 286 | |
| 287 | #ifdef CONFIG_SND_DEBUG_MEMORY |
| 288 | void snd_memory_init(void); |
| 289 | void snd_memory_done(void); |
| 290 | int snd_memory_info_init(void); |
| 291 | int snd_memory_info_done(void); |
Al Viro | dd0fc66 | 2005-10-07 07:46:04 +0100 | [diff] [blame] | 292 | void *snd_hidden_kmalloc(size_t size, gfp_t flags); |
| 293 | void *snd_hidden_kzalloc(size_t size, gfp_t flags); |
| 294 | void *snd_hidden_kcalloc(size_t n, size_t size, gfp_t flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 295 | void snd_hidden_kfree(const void *obj); |
Al Viro | dd0fc66 | 2005-10-07 07:46:04 +0100 | [diff] [blame] | 296 | char *snd_hidden_kstrdup(const char *s, gfp_t flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 297 | #define kmalloc(size, flags) snd_hidden_kmalloc(size, flags) |
Pekka Enberg | 8db08ea | 2005-09-06 15:18:36 -0700 | [diff] [blame] | 298 | #define kzalloc(size, flags) snd_hidden_kzalloc(size, flags) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 299 | #define kcalloc(n, size, flags) snd_hidden_kcalloc(n, size, flags) |
| 300 | #define kfree(obj) snd_hidden_kfree(obj) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 301 | #define kmalloc_nocheck(size, flags) snd_wrapper_kmalloc(size, flags) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 302 | #define kfree_nocheck(obj) snd_wrapper_kfree(obj) |
Paulo Marques | 543537b | 2005-06-23 00:09:02 -0700 | [diff] [blame] | 303 | #define kstrdup(s, flags) snd_hidden_kstrdup(s, flags) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 304 | #else |
| 305 | #define snd_memory_init() /*NOP*/ |
| 306 | #define snd_memory_done() /*NOP*/ |
| 307 | #define snd_memory_info_init() /*NOP*/ |
| 308 | #define snd_memory_info_done() /*NOP*/ |
| 309 | #define kmalloc_nocheck(size, flags) kmalloc(size, flags) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 310 | #define kfree_nocheck(obj) kfree(obj) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 311 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 312 | int copy_to_user_fromio(void __user *dst, const volatile void __iomem *src, size_t count); |
| 313 | int copy_from_user_toio(volatile void __iomem *dst, const void __user *src, size_t count); |
| 314 | |
| 315 | /* init.c */ |
| 316 | |
| 317 | extern unsigned int snd_cards_lock; |
| 318 | extern snd_card_t *snd_cards[SNDRV_CARDS]; |
| 319 | extern rwlock_t snd_card_rwlock; |
| 320 | #if defined(CONFIG_SND_MIXER_OSS) || defined(CONFIG_SND_MIXER_OSS_MODULE) |
| 321 | #define SND_MIXER_OSS_NOTIFY_REGISTER 0 |
| 322 | #define SND_MIXER_OSS_NOTIFY_DISCONNECT 1 |
| 323 | #define SND_MIXER_OSS_NOTIFY_FREE 2 |
| 324 | extern int (*snd_mixer_oss_notify_callback)(snd_card_t *card, int cmd); |
| 325 | #endif |
| 326 | |
| 327 | snd_card_t *snd_card_new(int idx, const char *id, |
| 328 | struct module *module, int extra_size); |
| 329 | int snd_card_disconnect(snd_card_t *card); |
| 330 | int snd_card_free(snd_card_t *card); |
| 331 | int snd_card_free_in_thread(snd_card_t *card); |
| 332 | int snd_card_register(snd_card_t *card); |
| 333 | int snd_card_info_init(void); |
| 334 | int snd_card_info_done(void); |
| 335 | int snd_component_add(snd_card_t *card, const char *component); |
| 336 | int snd_card_file_add(snd_card_t *card, struct file *file); |
| 337 | int snd_card_file_remove(snd_card_t *card, struct file *file); |
| 338 | |
| 339 | #ifndef snd_card_set_dev |
| 340 | #define snd_card_set_dev(card,devptr) ((card)->dev = (devptr)) |
| 341 | #endif |
Takashi Iwai | ecbcfe3 | 2005-09-05 17:15:37 +0200 | [diff] [blame] | 342 | /* register a generic device (for ISA, etc) */ |
| 343 | int snd_card_set_generic_dev(snd_card_t *card); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 344 | |
| 345 | /* device.c */ |
| 346 | |
| 347 | int snd_device_new(snd_card_t *card, snd_device_type_t type, |
| 348 | void *device_data, snd_device_ops_t *ops); |
| 349 | int snd_device_register(snd_card_t *card, void *device_data); |
| 350 | int snd_device_register_all(snd_card_t *card); |
| 351 | int snd_device_disconnect(snd_card_t *card, void *device_data); |
| 352 | int snd_device_disconnect_all(snd_card_t *card); |
| 353 | int snd_device_free(snd_card_t *card, void *device_data); |
| 354 | int snd_device_free_all(snd_card_t *card, snd_device_cmd_t cmd); |
| 355 | |
| 356 | /* isadma.c */ |
| 357 | |
Al Viro | 276bd31 | 2005-08-23 22:45:06 +0100 | [diff] [blame] | 358 | #ifdef CONFIG_ISA_DMA_API |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 359 | #define DMA_MODE_NO_ENABLE 0x0100 |
| 360 | |
| 361 | void snd_dma_program(unsigned long dma, unsigned long addr, unsigned int size, unsigned short mode); |
| 362 | void snd_dma_disable(unsigned long dma); |
| 363 | unsigned int snd_dma_pointer(unsigned long dma, unsigned int size); |
Al Viro | 276bd31 | 2005-08-23 22:45:06 +0100 | [diff] [blame] | 364 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 365 | |
| 366 | /* misc.c */ |
Takashi Iwai | b1d5776 | 2005-10-10 11:56:31 +0200 | [diff] [blame^] | 367 | void release_and_free_resource(struct resource *res); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 368 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 369 | #ifdef CONFIG_SND_VERBOSE_PRINTK |
| 370 | void snd_verbose_printk(const char *file, int line, const char *format, ...) |
| 371 | __attribute__ ((format (printf, 3, 4))); |
| 372 | #endif |
| 373 | #if defined(CONFIG_SND_DEBUG) && defined(CONFIG_SND_VERBOSE_PRINTK) |
| 374 | void snd_verbose_printd(const char *file, int line, const char *format, ...) |
| 375 | __attribute__ ((format (printf, 3, 4))); |
| 376 | #endif |
| 377 | |
| 378 | /* --- */ |
| 379 | |
| 380 | #ifdef CONFIG_SND_VERBOSE_PRINTK |
| 381 | /** |
| 382 | * snd_printk - printk wrapper |
| 383 | * @fmt: format string |
| 384 | * |
| 385 | * Works like print() but prints the file and the line of the caller |
| 386 | * when configured with CONFIG_SND_VERBOSE_PRINTK. |
| 387 | */ |
| 388 | #define snd_printk(fmt, args...) \ |
| 389 | snd_verbose_printk(__FILE__, __LINE__, fmt ,##args) |
| 390 | #else |
| 391 | #define snd_printk(fmt, args...) \ |
| 392 | printk(fmt ,##args) |
| 393 | #endif |
| 394 | |
| 395 | #ifdef CONFIG_SND_DEBUG |
| 396 | |
| 397 | #define __ASTRING__(x) #x |
| 398 | |
| 399 | #ifdef CONFIG_SND_VERBOSE_PRINTK |
| 400 | /** |
| 401 | * snd_printd - debug printk |
| 402 | * @format: format string |
| 403 | * |
| 404 | * Compiled only when Works like snd_printk() for debugging purpose. |
| 405 | * Ignored when CONFIG_SND_DEBUG is not set. |
| 406 | */ |
| 407 | #define snd_printd(fmt, args...) \ |
| 408 | snd_verbose_printd(__FILE__, __LINE__, fmt ,##args) |
| 409 | #else |
| 410 | #define snd_printd(fmt, args...) \ |
| 411 | printk(fmt ,##args) |
| 412 | #endif |
| 413 | /** |
Henrik Kretzschmar | d5750f6 | 2005-06-29 19:31:06 +0200 | [diff] [blame] | 414 | * snd_assert - run-time assertion macro |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 415 | * @expr: expression |
| 416 | * @args...: the action |
| 417 | * |
| 418 | * This macro checks the expression in run-time and invokes the commands |
| 419 | * given in the rest arguments if the assertion is failed. |
| 420 | * When CONFIG_SND_DEBUG is not set, the expression is executed but |
| 421 | * not checked. |
| 422 | */ |
Takashi Iwai | 7c22f1a | 2005-10-10 11:46:31 +0200 | [diff] [blame] | 423 | #define snd_assert(expr, args...) do { \ |
| 424 | if (unlikely(!(expr))) { \ |
| 425 | snd_printk(KERN_ERR "BUG? (%s)\n", __ASTRING__(expr)); \ |
| 426 | dump_stack(); \ |
| 427 | args; \ |
| 428 | } \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 429 | } while (0) |
Takashi Iwai | 7c22f1a | 2005-10-10 11:46:31 +0200 | [diff] [blame] | 430 | |
| 431 | #define snd_BUG() do { \ |
| 432 | snd_printk(KERN_ERR "BUG?\n"); \ |
| 433 | dump_stack(); \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 434 | } while (0) |
| 435 | |
| 436 | #else /* !CONFIG_SND_DEBUG */ |
| 437 | |
| 438 | #define snd_printd(fmt, args...) /* nothing */ |
| 439 | #define snd_assert(expr, args...) (void)(expr) |
Takashi Iwai | 7c22f1a | 2005-10-10 11:46:31 +0200 | [diff] [blame] | 440 | #define snd_BUG() /* nothing */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 441 | |
| 442 | #endif /* CONFIG_SND_DEBUG */ |
| 443 | |
| 444 | #ifdef CONFIG_SND_DEBUG_DETECT |
| 445 | /** |
| 446 | * snd_printdd - debug printk |
| 447 | * @format: format string |
| 448 | * |
| 449 | * Compiled only when Works like snd_printk() for debugging purpose. |
| 450 | * Ignored when CONFIG_SND_DEBUG_DETECT is not set. |
| 451 | */ |
| 452 | #define snd_printdd(format, args...) snd_printk(format, ##args) |
| 453 | #else |
| 454 | #define snd_printdd(format, args...) /* nothing */ |
| 455 | #endif |
| 456 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 457 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 458 | #define SNDRV_OSS_VERSION ((3<<16)|(8<<8)|(1<<4)|(0)) /* 3.8.1a */ |
| 459 | |
| 460 | /* for easier backward-porting */ |
| 461 | #if defined(CONFIG_GAMEPORT) || defined(CONFIG_GAMEPORT_MODULE) |
| 462 | #ifndef gameport_set_dev_parent |
| 463 | #define gameport_set_dev_parent(gp,xdev) ((gp)->dev.parent = (xdev)) |
| 464 | #define gameport_set_port_data(gp,r) ((gp)->port_data = (r)) |
| 465 | #define gameport_get_port_data(gp) (gp)->port_data |
| 466 | #endif |
| 467 | #endif |
| 468 | |
| 469 | #endif /* __SOUND_CORE_H */ |