11da177e4SLinus Torvalds #ifndef __SOUND_CORE_H 21da177e4SLinus Torvalds #define __SOUND_CORE_H 31da177e4SLinus Torvalds 41da177e4SLinus Torvalds /* 51da177e4SLinus Torvalds * Main header file for the ALSA driver 6c1017a4cSJaroslav Kysela * Copyright (c) 1994-2001 by Jaroslav Kysela <perex@perex.cz> 71da177e4SLinus Torvalds * 81da177e4SLinus Torvalds * 91da177e4SLinus Torvalds * This program is free software; you can redistribute it and/or modify 101da177e4SLinus Torvalds * it under the terms of the GNU General Public License as published by 111da177e4SLinus Torvalds * the Free Software Foundation; either version 2 of the License, or 121da177e4SLinus Torvalds * (at your option) any later version. 131da177e4SLinus Torvalds * 141da177e4SLinus Torvalds * This program is distributed in the hope that it will be useful, 151da177e4SLinus Torvalds * but WITHOUT ANY WARRANTY; without even the implied warranty of 161da177e4SLinus Torvalds * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 171da177e4SLinus Torvalds * GNU General Public License for more details. 181da177e4SLinus Torvalds * 191da177e4SLinus Torvalds * You should have received a copy of the GNU General Public License 201da177e4SLinus Torvalds * along with this program; if not, write to the Free Software 211da177e4SLinus Torvalds * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 221da177e4SLinus Torvalds * 231da177e4SLinus Torvalds */ 241da177e4SLinus Torvalds 251da177e4SLinus Torvalds #include <linux/sched.h> /* wake_up() */ 261a60d4c5SIngo Molnar #include <linux/mutex.h> /* struct mutex */ 271da177e4SLinus Torvalds #include <linux/rwsem.h> /* struct rw_semaphore */ 281da177e4SLinus Torvalds #include <linux/pm.h> /* pm_message_t */ 299d19f48cSTakashi Iwai #include <linux/device.h> 305ef03460STakashi Iwai #include <linux/stringify.h> 311da177e4SLinus Torvalds 329004acc7STakashi Iwai /* number of supported soundcards */ 339004acc7STakashi Iwai #ifdef CONFIG_SND_DYNAMIC_MINORS 349004acc7STakashi Iwai #define SNDRV_CARDS 32 359004acc7STakashi Iwai #else 369004acc7STakashi Iwai #define SNDRV_CARDS 8 /* don't change - minor numbers */ 379004acc7STakashi Iwai #endif 389004acc7STakashi Iwai 399004acc7STakashi Iwai #define CONFIG_SND_MAJOR 116 /* standard configuration */ 409004acc7STakashi Iwai 411da177e4SLinus Torvalds /* forward declarations */ 421da177e4SLinus Torvalds #ifdef CONFIG_PCI 431da177e4SLinus Torvalds struct pci_dev; 441da177e4SLinus Torvalds #endif 45de477254SPaul Gortmaker struct module; 461da177e4SLinus Torvalds 471da177e4SLinus Torvalds /* device allocation stuff */ 481da177e4SLinus Torvalds 491da177e4SLinus Torvalds #define SNDRV_DEV_TYPE_RANGE_SIZE 0x1000 501da177e4SLinus Torvalds 51512bbd6aSTakashi Iwai typedef int __bitwise snd_device_type_t; 52512bbd6aSTakashi Iwai #define SNDRV_DEV_TOPLEVEL ((__force snd_device_type_t) 0) 53512bbd6aSTakashi Iwai #define SNDRV_DEV_CONTROL ((__force snd_device_type_t) 1) 54512bbd6aSTakashi Iwai #define SNDRV_DEV_LOWLEVEL_PRE ((__force snd_device_type_t) 2) 55512bbd6aSTakashi Iwai #define SNDRV_DEV_LOWLEVEL_NORMAL ((__force snd_device_type_t) 0x1000) 56512bbd6aSTakashi Iwai #define SNDRV_DEV_PCM ((__force snd_device_type_t) 0x1001) 57512bbd6aSTakashi Iwai #define SNDRV_DEV_RAWMIDI ((__force snd_device_type_t) 0x1002) 58512bbd6aSTakashi Iwai #define SNDRV_DEV_TIMER ((__force snd_device_type_t) 0x1003) 59512bbd6aSTakashi Iwai #define SNDRV_DEV_SEQUENCER ((__force snd_device_type_t) 0x1004) 60512bbd6aSTakashi Iwai #define SNDRV_DEV_HWDEP ((__force snd_device_type_t) 0x1005) 61512bbd6aSTakashi Iwai #define SNDRV_DEV_INFO ((__force snd_device_type_t) 0x1006) 62512bbd6aSTakashi Iwai #define SNDRV_DEV_BUS ((__force snd_device_type_t) 0x1007) 63512bbd6aSTakashi Iwai #define SNDRV_DEV_CODEC ((__force snd_device_type_t) 0x1008) 64e76d8ceaSMark Brown #define SNDRV_DEV_JACK ((__force snd_device_type_t) 0x1009) 653eafc959SOmair Mohammed Abdullah #define SNDRV_DEV_COMPRESS ((__force snd_device_type_t) 0x100A) 66512bbd6aSTakashi Iwai #define SNDRV_DEV_LOWLEVEL ((__force snd_device_type_t) 0x2000) 671da177e4SLinus Torvalds 68512bbd6aSTakashi Iwai typedef int __bitwise snd_device_state_t; 69512bbd6aSTakashi Iwai #define SNDRV_DEV_BUILD ((__force snd_device_state_t) 0) 70512bbd6aSTakashi Iwai #define SNDRV_DEV_REGISTERED ((__force snd_device_state_t) 1) 71512bbd6aSTakashi Iwai #define SNDRV_DEV_DISCONNECTED ((__force snd_device_state_t) 2) 721da177e4SLinus Torvalds 73512bbd6aSTakashi Iwai typedef int __bitwise snd_device_cmd_t; 74512bbd6aSTakashi Iwai #define SNDRV_DEV_CMD_PRE ((__force snd_device_cmd_t) 0) 75512bbd6aSTakashi Iwai #define SNDRV_DEV_CMD_NORMAL ((__force snd_device_cmd_t) 1) 76512bbd6aSTakashi Iwai #define SNDRV_DEV_CMD_POST ((__force snd_device_cmd_t) 2) 771da177e4SLinus Torvalds 78512bbd6aSTakashi Iwai struct snd_device; 791da177e4SLinus Torvalds 80512bbd6aSTakashi Iwai struct snd_device_ops { 81512bbd6aSTakashi Iwai int (*dev_free)(struct snd_device *dev); 82512bbd6aSTakashi Iwai int (*dev_register)(struct snd_device *dev); 83512bbd6aSTakashi Iwai int (*dev_disconnect)(struct snd_device *dev); 84512bbd6aSTakashi Iwai }; 851da177e4SLinus Torvalds 86512bbd6aSTakashi Iwai struct snd_device { 871da177e4SLinus Torvalds struct list_head list; /* list of registered devices */ 88512bbd6aSTakashi Iwai struct snd_card *card; /* card which holds this device */ 891da177e4SLinus Torvalds snd_device_state_t state; /* state of the device */ 901da177e4SLinus Torvalds snd_device_type_t type; /* device type */ 911da177e4SLinus Torvalds void *device_data; /* device structure */ 92512bbd6aSTakashi Iwai struct snd_device_ops *ops; /* operations */ 931da177e4SLinus Torvalds }; 941da177e4SLinus Torvalds 95512bbd6aSTakashi Iwai #define snd_device(n) list_entry(n, struct snd_device, list) 961da177e4SLinus Torvalds 971da177e4SLinus Torvalds /* main structure for soundcard */ 981da177e4SLinus Torvalds 99512bbd6aSTakashi Iwai struct snd_card { 100d5750f67SHenrik Kretzschmar int number; /* number of soundcard (index to 101d5750f67SHenrik Kretzschmar snd_cards) */ 1021da177e4SLinus Torvalds 1031da177e4SLinus Torvalds char id[16]; /* id string of this card */ 1041da177e4SLinus Torvalds char driver[16]; /* driver name */ 1051da177e4SLinus Torvalds char shortname[32]; /* short name of this soundcard */ 1061da177e4SLinus Torvalds char longname[80]; /* name of this soundcard */ 1071da177e4SLinus Torvalds char mixername[80]; /* mixer name */ 108ff33f230STakashi Iwai char components[128]; /* card components delimited with 109d5750f67SHenrik Kretzschmar space */ 1101da177e4SLinus Torvalds struct module *module; /* top-level module */ 1111da177e4SLinus Torvalds 1121da177e4SLinus Torvalds void *private_data; /* private data for soundcard */ 113512bbd6aSTakashi Iwai void (*private_free) (struct snd_card *card); /* callback for freeing of 114d5750f67SHenrik Kretzschmar private data */ 1151da177e4SLinus Torvalds struct list_head devices; /* devices */ 1161da177e4SLinus Torvalds 1171da177e4SLinus Torvalds unsigned int last_numid; /* last used numeric ID */ 1181da177e4SLinus Torvalds struct rw_semaphore controls_rwsem; /* controls list lock */ 1191da177e4SLinus Torvalds rwlock_t ctl_files_rwlock; /* ctl_files list lock */ 1201da177e4SLinus Torvalds int controls_count; /* count of all controls */ 1211da177e4SLinus Torvalds int user_ctl_count; /* count of all user controls */ 1221da177e4SLinus Torvalds struct list_head controls; /* all controls for this card */ 1231da177e4SLinus Torvalds struct list_head ctl_files; /* active control files */ 1241da177e4SLinus Torvalds 125512bbd6aSTakashi Iwai struct snd_info_entry *proc_root; /* root for soundcard specific files */ 126512bbd6aSTakashi Iwai struct snd_info_entry *proc_id; /* the card id */ 1271da177e4SLinus Torvalds struct proc_dir_entry *proc_root_link; /* number link to real id */ 1281da177e4SLinus Torvalds 129118dd6bfSTakashi Iwai struct list_head files_list; /* all files associated to this card */ 130d5750f67SHenrik Kretzschmar struct snd_shutdown_f_ops *s_f_ops; /* file operations in the shutdown 131d5750f67SHenrik Kretzschmar state */ 1321da177e4SLinus Torvalds spinlock_t files_lock; /* lock the files for this card */ 1331da177e4SLinus Torvalds int shutdown; /* this card is going down */ 134c461482cSTakashi Iwai int free_on_last_close; /* free in context of file_release */ 1351da177e4SLinus Torvalds wait_queue_head_t shutdown_sleep; 1367d2aae1eSTakashi Iwai struct device *dev; /* device assigned to this card */ 1377d2aae1eSTakashi Iwai struct device *card_dev; /* cardX object for sysfs */ 1381da177e4SLinus Torvalds 1391da177e4SLinus Torvalds #ifdef CONFIG_PM 1401da177e4SLinus Torvalds unsigned int power_state; /* power state */ 1411a60d4c5SIngo Molnar struct mutex power_lock; /* power lock */ 1421da177e4SLinus Torvalds wait_queue_head_t power_sleep; 1431da177e4SLinus Torvalds #endif 1441da177e4SLinus Torvalds 1451da177e4SLinus Torvalds #if defined(CONFIG_SND_MIXER_OSS) || defined(CONFIG_SND_MIXER_OSS_MODULE) 146512bbd6aSTakashi Iwai struct snd_mixer_oss *mixer_oss; 1471da177e4SLinus Torvalds int mixer_oss_change_count; 1481da177e4SLinus Torvalds #endif 1491da177e4SLinus Torvalds }; 1501da177e4SLinus Torvalds 1511da177e4SLinus Torvalds #ifdef CONFIG_PM 152512bbd6aSTakashi Iwai static inline void snd_power_lock(struct snd_card *card) 1531da177e4SLinus Torvalds { 1541a60d4c5SIngo Molnar mutex_lock(&card->power_lock); 1551da177e4SLinus Torvalds } 1561da177e4SLinus Torvalds 157512bbd6aSTakashi Iwai static inline void snd_power_unlock(struct snd_card *card) 1581da177e4SLinus Torvalds { 1591a60d4c5SIngo Molnar mutex_unlock(&card->power_lock); 1601da177e4SLinus Torvalds } 1611da177e4SLinus Torvalds 162512bbd6aSTakashi Iwai static inline unsigned int snd_power_get_state(struct snd_card *card) 1631da177e4SLinus Torvalds { 1641da177e4SLinus Torvalds return card->power_state; 1651da177e4SLinus Torvalds } 1661da177e4SLinus Torvalds 167512bbd6aSTakashi Iwai static inline void snd_power_change_state(struct snd_card *card, unsigned int state) 1681da177e4SLinus Torvalds { 1691da177e4SLinus Torvalds card->power_state = state; 1701da177e4SLinus Torvalds wake_up(&card->power_sleep); 1711da177e4SLinus Torvalds } 172d5750f67SHenrik Kretzschmar 173d5750f67SHenrik Kretzschmar /* init.c */ 174cbac4b0cSTakashi Iwai int snd_power_wait(struct snd_card *card, unsigned int power_state); 175d5750f67SHenrik Kretzschmar 1761da177e4SLinus Torvalds #else /* ! CONFIG_PM */ 1771da177e4SLinus Torvalds 1781da177e4SLinus Torvalds #define snd_power_lock(card) do { (void)(card); } while (0) 1791da177e4SLinus Torvalds #define snd_power_unlock(card) do { (void)(card); } while (0) 1806fdb94bdSLinus Torvalds static inline int snd_power_wait(struct snd_card *card, unsigned int state) { return 0; } 181363129eaSMike Frysinger #define snd_power_get_state(card) ({ (void)(card); SNDRV_CTL_POWER_D0; }) 1821da177e4SLinus Torvalds #define snd_power_change_state(card, state) do { (void)(card); } while (0) 1831da177e4SLinus Torvalds 1841da177e4SLinus Torvalds #endif /* CONFIG_PM */ 1851da177e4SLinus Torvalds 186512bbd6aSTakashi Iwai struct snd_minor { 1872af677fcSClemens Ladisch int type; /* SNDRV_DEVICE_TYPE_XXX */ 1886983b724SClemens Ladisch int card; /* card number */ 1891da177e4SLinus Torvalds int device; /* device number */ 19099ac48f5SArjan van de Ven const struct file_operations *f_ops; /* file operations */ 191f87135f5SClemens Ladisch void *private_data; /* private data for f_ops->open */ 192d80f19faSGreg Kroah-Hartman struct device *dev; /* device for sysfs */ 1931da177e4SLinus Torvalds }; 1941da177e4SLinus Torvalds 1957d2aae1eSTakashi Iwai /* return a device pointer linked to each sound device as a parent */ 1967d2aae1eSTakashi Iwai static inline struct device *snd_card_get_device_link(struct snd_card *card) 1977d2aae1eSTakashi Iwai { 1987d2aae1eSTakashi Iwai return card ? card->card_dev : NULL; 1997d2aae1eSTakashi Iwai } 2007d2aae1eSTakashi Iwai 2011da177e4SLinus Torvalds /* sound.c */ 2021da177e4SLinus Torvalds 203f1902860SClemens Ladisch extern int snd_major; 2041da177e4SLinus Torvalds extern int snd_ecards_limit; 205d80f19faSGreg Kroah-Hartman extern struct class *sound_class; 2061da177e4SLinus Torvalds 2071da177e4SLinus Torvalds void snd_request_card(int card); 2081da177e4SLinus Torvalds 20912b131c4SJohannes Berg int snd_register_device_for_dev(int type, struct snd_card *card, 21012b131c4SJohannes Berg int dev, 21112b131c4SJohannes Berg const struct file_operations *f_ops, 21212b131c4SJohannes Berg void *private_data, 21312b131c4SJohannes Berg const char *name, 21412b131c4SJohannes Berg struct device *device); 21512b131c4SJohannes Berg 21612b131c4SJohannes Berg /** 21712b131c4SJohannes Berg * snd_register_device - Register the ALSA device file for the card 21812b131c4SJohannes Berg * @type: the device type, SNDRV_DEVICE_TYPE_XXX 21912b131c4SJohannes Berg * @card: the card instance 22012b131c4SJohannes Berg * @dev: the device index 22112b131c4SJohannes Berg * @f_ops: the file operations 22212b131c4SJohannes Berg * @private_data: user pointer for f_ops->open() 22312b131c4SJohannes Berg * @name: the device file name 22412b131c4SJohannes Berg * 22512b131c4SJohannes Berg * Registers an ALSA device file for the given card. 22612b131c4SJohannes Berg * The operators have to be set in reg parameter. 22712b131c4SJohannes Berg * 22812b131c4SJohannes Berg * This function uses the card's device pointer to link to the 22912b131c4SJohannes Berg * correct &struct device. 23012b131c4SJohannes Berg * 23112b131c4SJohannes Berg * Returns zero if successful, or a negative error code on failure. 23212b131c4SJohannes Berg */ 23312b131c4SJohannes Berg static inline int snd_register_device(int type, struct snd_card *card, int dev, 23412b131c4SJohannes Berg const struct file_operations *f_ops, 23512b131c4SJohannes Berg void *private_data, 23612b131c4SJohannes Berg const char *name) 23712b131c4SJohannes Berg { 23812b131c4SJohannes Berg return snd_register_device_for_dev(type, card, dev, f_ops, 23912b131c4SJohannes Berg private_data, name, 240c2902c8aSTakashi Iwai snd_card_get_device_link(card)); 24112b131c4SJohannes Berg } 24212b131c4SJohannes Berg 243512bbd6aSTakashi Iwai int snd_unregister_device(int type, struct snd_card *card, int dev); 244f87135f5SClemens Ladisch void *snd_lookup_minor_data(unsigned int minor, int type); 2459d19f48cSTakashi Iwai int snd_add_device_sysfs_file(int type, struct snd_card *card, int dev, 246d80f19faSGreg Kroah-Hartman struct device_attribute *attr); 2471da177e4SLinus Torvalds 2481da177e4SLinus Torvalds #ifdef CONFIG_SND_OSSEMUL 2492af677fcSClemens Ladisch int snd_register_oss_device(int type, struct snd_card *card, int dev, 25099ac48f5SArjan van de Ven const struct file_operations *f_ops, void *private_data, 251f87135f5SClemens Ladisch const char *name); 252512bbd6aSTakashi Iwai int snd_unregister_oss_device(int type, struct snd_card *card, int dev); 253f87135f5SClemens Ladisch void *snd_lookup_oss_minor_data(unsigned int minor, int type); 2541da177e4SLinus Torvalds #endif 2551da177e4SLinus Torvalds 2561da177e4SLinus Torvalds int snd_minor_info_init(void); 2571da177e4SLinus Torvalds int snd_minor_info_done(void); 2581da177e4SLinus Torvalds 2591da177e4SLinus Torvalds /* sound_oss.c */ 2601da177e4SLinus Torvalds 2611da177e4SLinus Torvalds #ifdef CONFIG_SND_OSSEMUL 2621da177e4SLinus Torvalds int snd_minor_info_oss_init(void); 2631da177e4SLinus Torvalds int snd_minor_info_oss_done(void); 2641da177e4SLinus Torvalds #else 265ad5fada5SPavel Machek static inline int snd_minor_info_oss_init(void) { return 0; } 266ad5fada5SPavel Machek static inline int snd_minor_info_oss_done(void) { return 0; } 2671da177e4SLinus Torvalds #endif 2681da177e4SLinus Torvalds 2691da177e4SLinus Torvalds /* memory.c */ 2701da177e4SLinus Torvalds 2711da177e4SLinus Torvalds int copy_to_user_fromio(void __user *dst, const volatile void __iomem *src, size_t count); 2721da177e4SLinus Torvalds int copy_from_user_toio(volatile void __iomem *dst, const void __user *src, size_t count); 2731da177e4SLinus Torvalds 2741da177e4SLinus Torvalds /* init.c */ 2751da177e4SLinus Torvalds 276512bbd6aSTakashi Iwai extern struct snd_card *snd_cards[SNDRV_CARDS]; 277746df948STakashi Iwai int snd_card_locked(int card); 2781da177e4SLinus Torvalds #if defined(CONFIG_SND_MIXER_OSS) || defined(CONFIG_SND_MIXER_OSS_MODULE) 2791da177e4SLinus Torvalds #define SND_MIXER_OSS_NOTIFY_REGISTER 0 2801da177e4SLinus Torvalds #define SND_MIXER_OSS_NOTIFY_DISCONNECT 1 2811da177e4SLinus Torvalds #define SND_MIXER_OSS_NOTIFY_FREE 2 282512bbd6aSTakashi Iwai extern int (*snd_mixer_oss_notify_callback)(struct snd_card *card, int cmd); 2831da177e4SLinus Torvalds #endif 2841da177e4SLinus Torvalds 28553fb1e63STakashi Iwai int snd_card_create(int idx, const char *id, 28653fb1e63STakashi Iwai struct module *module, int extra_size, 28753fb1e63STakashi Iwai struct snd_card **card_ret); 28853fb1e63STakashi Iwai 289512bbd6aSTakashi Iwai int snd_card_disconnect(struct snd_card *card); 290512bbd6aSTakashi Iwai int snd_card_free(struct snd_card *card); 291c461482cSTakashi Iwai int snd_card_free_when_closed(struct snd_card *card); 29210a8ebbbSJaroslav Kysela void snd_card_set_id(struct snd_card *card, const char *id); 293512bbd6aSTakashi Iwai int snd_card_register(struct snd_card *card); 2941da177e4SLinus Torvalds int snd_card_info_init(void); 2951da177e4SLinus Torvalds int snd_card_info_done(void); 296512bbd6aSTakashi Iwai int snd_component_add(struct snd_card *card, const char *component); 297512bbd6aSTakashi Iwai int snd_card_file_add(struct snd_card *card, struct file *file); 298512bbd6aSTakashi Iwai int snd_card_file_remove(struct snd_card *card, struct file *file); 2991da177e4SLinus Torvalds 3007d2aae1eSTakashi Iwai #define snd_card_set_dev(card, devptr) ((card)->dev = (devptr)) 3011da177e4SLinus Torvalds 3021da177e4SLinus Torvalds /* device.c */ 3031da177e4SLinus Torvalds 304512bbd6aSTakashi Iwai int snd_device_new(struct snd_card *card, snd_device_type_t type, 305512bbd6aSTakashi Iwai void *device_data, struct snd_device_ops *ops); 306512bbd6aSTakashi Iwai int snd_device_register(struct snd_card *card, void *device_data); 307512bbd6aSTakashi Iwai int snd_device_register_all(struct snd_card *card); 308512bbd6aSTakashi Iwai int snd_device_disconnect(struct snd_card *card, void *device_data); 309512bbd6aSTakashi Iwai int snd_device_disconnect_all(struct snd_card *card); 310512bbd6aSTakashi Iwai int snd_device_free(struct snd_card *card, void *device_data); 311512bbd6aSTakashi Iwai int snd_device_free_all(struct snd_card *card, snd_device_cmd_t cmd); 3121da177e4SLinus Torvalds 3131da177e4SLinus Torvalds /* isadma.c */ 3141da177e4SLinus Torvalds 315276bd31cSAl Viro #ifdef CONFIG_ISA_DMA_API 3161da177e4SLinus Torvalds #define DMA_MODE_NO_ENABLE 0x0100 3171da177e4SLinus Torvalds 3181da177e4SLinus Torvalds void snd_dma_program(unsigned long dma, unsigned long addr, unsigned int size, unsigned short mode); 3191da177e4SLinus Torvalds void snd_dma_disable(unsigned long dma); 3201da177e4SLinus Torvalds unsigned int snd_dma_pointer(unsigned long dma, unsigned int size); 321276bd31cSAl Viro #endif 3221da177e4SLinus Torvalds 3231da177e4SLinus Torvalds /* misc.c */ 324b709e574STakashi Iwai struct resource; 325b1d5776dSTakashi Iwai void release_and_free_resource(struct resource *res); 3261da177e4SLinus Torvalds 3271da177e4SLinus Torvalds /* --- */ 3281da177e4SLinus Torvalds 32936ce99c1STakashi Iwai #if defined(CONFIG_SND_DEBUG) || defined(CONFIG_SND_VERBOSE_PRINTK) 330b9075fa9SJoe Perches __printf(4, 5) 33136ce99c1STakashi Iwai void __snd_printk(unsigned int level, const char *file, int line, 332b9075fa9SJoe Perches const char *format, ...); 33336ce99c1STakashi Iwai #else 33436ce99c1STakashi Iwai #define __snd_printk(level, file, line, format, args...) \ 335cf0baf16STakashi Iwai printk(format, ##args) 33636ce99c1STakashi Iwai #endif 33736ce99c1STakashi Iwai 3381da177e4SLinus Torvalds /** 3391da177e4SLinus Torvalds * snd_printk - printk wrapper 3401da177e4SLinus Torvalds * @fmt: format string 3411da177e4SLinus Torvalds * 342f66fcedcSTakashi Iwai * Works like printk() but prints the file and the line of the caller 3431da177e4SLinus Torvalds * when configured with CONFIG_SND_VERBOSE_PRINTK. 3441da177e4SLinus Torvalds */ 3451da177e4SLinus Torvalds #define snd_printk(fmt, args...) \ 34636ce99c1STakashi Iwai __snd_printk(0, __FILE__, __LINE__, fmt, ##args) 3471da177e4SLinus Torvalds 3481da177e4SLinus Torvalds #ifdef CONFIG_SND_DEBUG 3491da177e4SLinus Torvalds /** 3501da177e4SLinus Torvalds * snd_printd - debug printk 3510863afb3SMartin Waitz * @fmt: format string 3521da177e4SLinus Torvalds * 353edab938eSPavel Machek * Works like snd_printk() for debugging purposes. 3541da177e4SLinus Torvalds * Ignored when CONFIG_SND_DEBUG is not set. 3551da177e4SLinus Torvalds */ 3561da177e4SLinus Torvalds #define snd_printd(fmt, args...) \ 35736ce99c1STakashi Iwai __snd_printk(1, __FILE__, __LINE__, fmt, ##args) 3587c22f1aaSTakashi Iwai 359f66fcedcSTakashi Iwai /** 360f66fcedcSTakashi Iwai * snd_BUG - give a BUG warning message and stack trace 361f66fcedcSTakashi Iwai * 362f66fcedcSTakashi Iwai * Calls WARN() if CONFIG_SND_DEBUG is set. 363f66fcedcSTakashi Iwai * Ignored when CONFIG_SND_DEBUG is not set. 364f66fcedcSTakashi Iwai */ 365bdbecf50STakashi Iwai #define snd_BUG() WARN(1, "BUG?\n") 366f66fcedcSTakashi Iwai 367f66fcedcSTakashi Iwai /** 368f66fcedcSTakashi Iwai * snd_BUG_ON - debugging check macro 369f66fcedcSTakashi Iwai * @cond: condition to evaluate 370f66fcedcSTakashi Iwai * 371f66fcedcSTakashi Iwai * When CONFIG_SND_DEBUG is set, this macro evaluates the given condition, 372f66fcedcSTakashi Iwai * and call WARN() and returns the value if it's non-zero. 373f66fcedcSTakashi Iwai * 374f66fcedcSTakashi Iwai * When CONFIG_SND_DEBUG is not set, this just returns zero, and the given 375f66fcedcSTakashi Iwai * condition is ignored. 376f66fcedcSTakashi Iwai * 377f66fcedcSTakashi Iwai * NOTE: the argument won't be evaluated at all when CONFIG_SND_DEBUG=n. 378f66fcedcSTakashi Iwai * Thus, don't put any statement that influences on the code behavior, 379f66fcedcSTakashi Iwai * such as pre/post increment, to the argument of this macro. 380f66fcedcSTakashi Iwai * If you want to evaluate and give a warning, use standard WARN_ON(). 381f66fcedcSTakashi Iwai */ 3825ef03460STakashi Iwai #define snd_BUG_ON(cond) WARN((cond), "BUG? (%s)\n", __stringify(cond)) 3831da177e4SLinus Torvalds 3841da177e4SLinus Torvalds #else /* !CONFIG_SND_DEBUG */ 3851da177e4SLinus Torvalds 386fcef7836SAndrew Morton #define snd_printd(fmt, args...) do { } while (0) 387fcef7836SAndrew Morton #define snd_BUG() do { } while (0) 388945eed02STakashi Iwai static inline int __snd_bug_on(int cond) 389fcef7836SAndrew Morton { 390fcef7836SAndrew Morton return 0; 391fcef7836SAndrew Morton } 392945eed02STakashi Iwai #define snd_BUG_ON(cond) __snd_bug_on(0 && (cond)) /* always false */ 3931da177e4SLinus Torvalds 3941da177e4SLinus Torvalds #endif /* CONFIG_SND_DEBUG */ 3951da177e4SLinus Torvalds 39662cf872aSTakashi Iwai #ifdef CONFIG_SND_DEBUG_VERBOSE 3971da177e4SLinus Torvalds /** 3981da177e4SLinus Torvalds * snd_printdd - debug printk 3991da177e4SLinus Torvalds * @format: format string 4001da177e4SLinus Torvalds * 401edab938eSPavel Machek * Works like snd_printk() for debugging purposes. 40262cf872aSTakashi Iwai * Ignored when CONFIG_SND_DEBUG_VERBOSE is not set. 4031da177e4SLinus Torvalds */ 40436ce99c1STakashi Iwai #define snd_printdd(format, args...) \ 40536ce99c1STakashi Iwai __snd_printk(2, __FILE__, __LINE__, format, ##args) 4061da177e4SLinus Torvalds #else 40736ce99c1STakashi Iwai #define snd_printdd(format, args...) do { } while (0) 4081da177e4SLinus Torvalds #endif 4091da177e4SLinus Torvalds 4101da177e4SLinus Torvalds 4111da177e4SLinus Torvalds #define SNDRV_OSS_VERSION ((3<<16)|(8<<8)|(1<<4)|(0)) /* 3.8.1a */ 4121da177e4SLinus Torvalds 4131da177e4SLinus Torvalds /* for easier backward-porting */ 4141da177e4SLinus Torvalds #if defined(CONFIG_GAMEPORT) || defined(CONFIG_GAMEPORT_MODULE) 4151da177e4SLinus Torvalds #define gameport_set_dev_parent(gp,xdev) ((gp)->dev.parent = (xdev)) 4161da177e4SLinus Torvalds #define gameport_set_port_data(gp,r) ((gp)->port_data = (r)) 4171da177e4SLinus Torvalds #define gameport_get_port_data(gp) (gp)->port_data 4181da177e4SLinus Torvalds #endif 4191da177e4SLinus Torvalds 420*8422fa11SAxel Lin #ifdef CONFIG_PCI 421d9ea472cSTakashi Iwai /* PCI quirk list helper */ 422d9ea472cSTakashi Iwai struct snd_pci_quirk { 423d9ea472cSTakashi Iwai unsigned short subvendor; /* PCI subvendor ID */ 424d9ea472cSTakashi Iwai unsigned short subdevice; /* PCI subdevice ID */ 4258bd4bb7aSTakashi Iwai unsigned short subdevice_mask; /* bitmask to match */ 426d9ea472cSTakashi Iwai int value; /* value */ 42762cf872aSTakashi Iwai #ifdef CONFIG_SND_DEBUG_VERBOSE 428d9ea472cSTakashi Iwai const char *name; /* name of the device (optional) */ 429d9ea472cSTakashi Iwai #endif 430d9ea472cSTakashi Iwai }; 431d9ea472cSTakashi Iwai 4328bd4bb7aSTakashi Iwai #define _SND_PCI_QUIRK_ID_MASK(vend, mask, dev) \ 4338bd4bb7aSTakashi Iwai .subvendor = (vend), .subdevice = (dev), .subdevice_mask = (mask) 434d9ea472cSTakashi Iwai #define _SND_PCI_QUIRK_ID(vend, dev) \ 4358bd4bb7aSTakashi Iwai _SND_PCI_QUIRK_ID_MASK(vend, 0xffff, dev) 436d9ea472cSTakashi Iwai #define SND_PCI_QUIRK_ID(vend,dev) {_SND_PCI_QUIRK_ID(vend, dev)} 43762cf872aSTakashi Iwai #ifdef CONFIG_SND_DEBUG_VERBOSE 438d9ea472cSTakashi Iwai #define SND_PCI_QUIRK(vend,dev,xname,val) \ 439d9ea472cSTakashi Iwai {_SND_PCI_QUIRK_ID(vend, dev), .value = (val), .name = (xname)} 4408bd4bb7aSTakashi Iwai #define SND_PCI_QUIRK_VENDOR(vend, xname, val) \ 4418bd4bb7aSTakashi Iwai {_SND_PCI_QUIRK_ID_MASK(vend, 0, 0), .value = (val), .name = (xname)} 4428bd4bb7aSTakashi Iwai #define SND_PCI_QUIRK_MASK(vend, mask, dev, xname, val) \ 4438bd4bb7aSTakashi Iwai {_SND_PCI_QUIRK_ID_MASK(vend, mask, dev), \ 4448bd4bb7aSTakashi Iwai .value = (val), .name = (xname)} 445d9ea472cSTakashi Iwai #else 446d9ea472cSTakashi Iwai #define SND_PCI_QUIRK(vend,dev,xname,val) \ 447d9ea472cSTakashi Iwai {_SND_PCI_QUIRK_ID(vend, dev), .value = (val)} 4488bd4bb7aSTakashi Iwai #define SND_PCI_QUIRK_MASK(vend, mask, dev, xname, val) \ 4498bd4bb7aSTakashi Iwai {_SND_PCI_QUIRK_ID_MASK(vend, mask, dev), .value = (val)} 4508bd4bb7aSTakashi Iwai #define SND_PCI_QUIRK_VENDOR(vend, xname, val) \ 4518bd4bb7aSTakashi Iwai {_SND_PCI_QUIRK_ID_MASK(vend, 0, 0), .value = (val)} 452d9ea472cSTakashi Iwai #endif 453d9ea472cSTakashi Iwai 454d9ea472cSTakashi Iwai const struct snd_pci_quirk * 455d9ea472cSTakashi Iwai snd_pci_quirk_lookup(struct pci_dev *pci, const struct snd_pci_quirk *list); 456d9ea472cSTakashi Iwai 457d1458279STakashi Iwai const struct snd_pci_quirk * 458d1458279STakashi Iwai snd_pci_quirk_lookup_id(u16 vendor, u16 device, 459d1458279STakashi Iwai const struct snd_pci_quirk *list); 460*8422fa11SAxel Lin #endif 461d9ea472cSTakashi Iwai 4621da177e4SLinus Torvalds #endif /* __SOUND_CORE_H */ 463