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 258bfb181cSTakashi Iwai #include <linux/device.h> 261da177e4SLinus Torvalds #include <linux/sched.h> /* wake_up() */ 271a60d4c5SIngo Molnar #include <linux/mutex.h> /* struct mutex */ 281da177e4SLinus Torvalds #include <linux/rwsem.h> /* struct rw_semaphore */ 291da177e4SLinus Torvalds #include <linux/pm.h> /* pm_message_t */ 305ef03460STakashi Iwai #include <linux/stringify.h> 31bcbb1553STim Gardner #include <linux/printk.h> 321da177e4SLinus Torvalds 339004acc7STakashi Iwai /* number of supported soundcards */ 349004acc7STakashi Iwai #ifdef CONFIG_SND_DYNAMIC_MINORS 357bb2491bSTakashi Iwai #define SNDRV_CARDS CONFIG_SND_MAX_CARDS 369004acc7STakashi Iwai #else 379004acc7STakashi Iwai #define SNDRV_CARDS 8 /* don't change - minor numbers */ 389004acc7STakashi Iwai #endif 399004acc7STakashi Iwai 409004acc7STakashi Iwai #define CONFIG_SND_MAJOR 116 /* standard configuration */ 419004acc7STakashi Iwai 421da177e4SLinus Torvalds /* forward declarations */ 431da177e4SLinus Torvalds struct pci_dev; 44de477254SPaul Gortmaker struct module; 45f2464064STakashi Iwai struct completion; 461da177e4SLinus Torvalds 471da177e4SLinus Torvalds /* device allocation stuff */ 481da177e4SLinus Torvalds 49289ca025STakashi Iwai /* type of the object used in snd_device_*() 50289ca025STakashi Iwai * this also defines the calling order 51289ca025STakashi Iwai */ 529ce50543STakashi Iwai enum snd_device_type { 53289ca025STakashi Iwai SNDRV_DEV_LOWLEVEL, 54289ca025STakashi Iwai SNDRV_DEV_CONTROL, 55289ca025STakashi Iwai SNDRV_DEV_INFO, 56289ca025STakashi Iwai SNDRV_DEV_BUS, 57289ca025STakashi Iwai SNDRV_DEV_CODEC, 589ce50543STakashi Iwai SNDRV_DEV_PCM, 59289ca025STakashi Iwai SNDRV_DEV_COMPRESS, 609ce50543STakashi Iwai SNDRV_DEV_RAWMIDI, 619ce50543STakashi Iwai SNDRV_DEV_TIMER, 629ce50543STakashi Iwai SNDRV_DEV_SEQUENCER, 639ce50543STakashi Iwai SNDRV_DEV_HWDEP, 649ce50543STakashi Iwai SNDRV_DEV_JACK, 659ce50543STakashi Iwai }; 661da177e4SLinus Torvalds 679ce50543STakashi Iwai enum snd_device_state { 689ce50543STakashi Iwai SNDRV_DEV_BUILD, 699ce50543STakashi Iwai SNDRV_DEV_REGISTERED, 709ce50543STakashi Iwai SNDRV_DEV_DISCONNECTED, 719ce50543STakashi Iwai }; 721da177e4SLinus Torvalds 73512bbd6aSTakashi Iwai struct snd_device; 741da177e4SLinus Torvalds 75512bbd6aSTakashi Iwai struct snd_device_ops { 76512bbd6aSTakashi Iwai int (*dev_free)(struct snd_device *dev); 77512bbd6aSTakashi Iwai int (*dev_register)(struct snd_device *dev); 78512bbd6aSTakashi Iwai int (*dev_disconnect)(struct snd_device *dev); 79512bbd6aSTakashi Iwai }; 801da177e4SLinus Torvalds 81512bbd6aSTakashi Iwai struct snd_device { 821da177e4SLinus Torvalds struct list_head list; /* list of registered devices */ 83512bbd6aSTakashi Iwai struct snd_card *card; /* card which holds this device */ 849ce50543STakashi Iwai enum snd_device_state state; /* state of the device */ 859ce50543STakashi Iwai enum snd_device_type type; /* device type */ 861da177e4SLinus Torvalds void *device_data; /* device structure */ 87512bbd6aSTakashi Iwai struct snd_device_ops *ops; /* operations */ 881da177e4SLinus Torvalds }; 891da177e4SLinus Torvalds 90512bbd6aSTakashi Iwai #define snd_device(n) list_entry(n, struct snd_device, list) 911da177e4SLinus Torvalds 921da177e4SLinus Torvalds /* main structure for soundcard */ 931da177e4SLinus Torvalds 94512bbd6aSTakashi Iwai struct snd_card { 95d5750f67SHenrik Kretzschmar int number; /* number of soundcard (index to 96d5750f67SHenrik Kretzschmar snd_cards) */ 971da177e4SLinus Torvalds 981da177e4SLinus Torvalds char id[16]; /* id string of this card */ 991da177e4SLinus Torvalds char driver[16]; /* driver name */ 1001da177e4SLinus Torvalds char shortname[32]; /* short name of this soundcard */ 1011da177e4SLinus Torvalds char longname[80]; /* name of this soundcard */ 1021da177e4SLinus Torvalds char mixername[80]; /* mixer name */ 103ff33f230STakashi Iwai char components[128]; /* card components delimited with 104d5750f67SHenrik Kretzschmar space */ 1051da177e4SLinus Torvalds struct module *module; /* top-level module */ 1061da177e4SLinus Torvalds 1071da177e4SLinus Torvalds void *private_data; /* private data for soundcard */ 108512bbd6aSTakashi Iwai void (*private_free) (struct snd_card *card); /* callback for freeing of 109d5750f67SHenrik Kretzschmar private data */ 1101da177e4SLinus Torvalds struct list_head devices; /* devices */ 1111da177e4SLinus Torvalds 1120fcd9f4bSTakashi Iwai struct device ctl_dev; /* control device */ 1131da177e4SLinus Torvalds unsigned int last_numid; /* last used numeric ID */ 1141da177e4SLinus Torvalds struct rw_semaphore controls_rwsem; /* controls list lock */ 1151da177e4SLinus Torvalds rwlock_t ctl_files_rwlock; /* ctl_files list lock */ 1161da177e4SLinus Torvalds int controls_count; /* count of all controls */ 1171da177e4SLinus Torvalds int user_ctl_count; /* count of all user controls */ 1181da177e4SLinus Torvalds struct list_head controls; /* all controls for this card */ 1191da177e4SLinus Torvalds struct list_head ctl_files; /* active control files */ 12007f4d9d7SLars-Peter Clausen struct mutex user_ctl_lock; /* protects user controls against 12107f4d9d7SLars-Peter Clausen concurrent access */ 1221da177e4SLinus Torvalds 123512bbd6aSTakashi Iwai struct snd_info_entry *proc_root; /* root for soundcard specific files */ 124512bbd6aSTakashi Iwai struct snd_info_entry *proc_id; /* the card id */ 1251da177e4SLinus Torvalds struct proc_dir_entry *proc_root_link; /* number link to real id */ 1261da177e4SLinus Torvalds 127118dd6bfSTakashi Iwai struct list_head files_list; /* all files associated to this card */ 128d5750f67SHenrik Kretzschmar struct snd_shutdown_f_ops *s_f_ops; /* file operations in the shutdown 129d5750f67SHenrik Kretzschmar state */ 1301da177e4SLinus Torvalds spinlock_t files_lock; /* lock the files for this card */ 1311da177e4SLinus Torvalds int shutdown; /* this card is going down */ 132f2464064STakashi Iwai struct completion *release_completion; 1337d2aae1eSTakashi Iwai struct device *dev; /* device assigned to this card */ 1348bfb181cSTakashi Iwai struct device card_dev; /* cardX object for sysfs */ 1358bfb181cSTakashi Iwai bool registered; /* card_dev is registered? */ 1361da177e4SLinus Torvalds 1371da177e4SLinus Torvalds #ifdef CONFIG_PM 1381da177e4SLinus Torvalds unsigned int power_state; /* power state */ 1391a60d4c5SIngo Molnar struct mutex power_lock; /* power lock */ 1401da177e4SLinus Torvalds wait_queue_head_t power_sleep; 1411da177e4SLinus Torvalds #endif 1421da177e4SLinus Torvalds 1431da177e4SLinus Torvalds #if defined(CONFIG_SND_MIXER_OSS) || defined(CONFIG_SND_MIXER_OSS_MODULE) 144512bbd6aSTakashi Iwai struct snd_mixer_oss *mixer_oss; 1451da177e4SLinus Torvalds int mixer_oss_change_count; 1461da177e4SLinus Torvalds #endif 1471da177e4SLinus Torvalds }; 1481da177e4SLinus Torvalds 1498bfb181cSTakashi Iwai #define dev_to_snd_card(p) container_of(p, struct snd_card, card_dev) 1508bfb181cSTakashi Iwai 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 */ 193a0830dbdSTakashi Iwai struct snd_card *card_ptr; /* assigned card instance */ 1941da177e4SLinus Torvalds }; 1951da177e4SLinus Torvalds 1967d2aae1eSTakashi Iwai /* return a device pointer linked to each sound device as a parent */ 1977d2aae1eSTakashi Iwai static inline struct device *snd_card_get_device_link(struct snd_card *card) 1987d2aae1eSTakashi Iwai { 1998bfb181cSTakashi Iwai return card ? &card->card_dev : NULL; 2007d2aae1eSTakashi Iwai } 2017d2aae1eSTakashi Iwai 2021da177e4SLinus Torvalds /* sound.c */ 2031da177e4SLinus Torvalds 204f1902860SClemens Ladisch extern int snd_major; 2051da177e4SLinus Torvalds extern int snd_ecards_limit; 206d80f19faSGreg Kroah-Hartman extern struct class *sound_class; 2071da177e4SLinus Torvalds 2081da177e4SLinus Torvalds void snd_request_card(int card); 2091da177e4SLinus Torvalds 2104b440be6STakashi Iwai void snd_device_initialize(struct device *dev, struct snd_card *card); 2114b440be6STakashi Iwai 212*40a4b263STakashi Iwai int snd_register_device(int type, struct snd_card *card, int dev, 21312b131c4SJohannes Berg const struct file_operations *f_ops, 214*40a4b263STakashi Iwai void *private_data, struct device *device); 215*40a4b263STakashi Iwai int snd_unregister_device(struct device *dev); 216f87135f5SClemens Ladisch void *snd_lookup_minor_data(unsigned int minor, int type); 217caa751baSTakashi Iwai struct device *snd_get_device(int type, struct snd_card *card, int dev); 2181da177e4SLinus Torvalds 2191da177e4SLinus Torvalds #ifdef CONFIG_SND_OSSEMUL 2202af677fcSClemens Ladisch int snd_register_oss_device(int type, struct snd_card *card, int dev, 22180d7d771STakashi Iwai const struct file_operations *f_ops, void *private_data); 222512bbd6aSTakashi Iwai int snd_unregister_oss_device(int type, struct snd_card *card, int dev); 223f87135f5SClemens Ladisch void *snd_lookup_oss_minor_data(unsigned int minor, int type); 2241da177e4SLinus Torvalds #endif 2251da177e4SLinus Torvalds 2261da177e4SLinus Torvalds int snd_minor_info_init(void); 2271da177e4SLinus Torvalds int snd_minor_info_done(void); 2281da177e4SLinus Torvalds 2291da177e4SLinus Torvalds /* sound_oss.c */ 2301da177e4SLinus Torvalds 2311da177e4SLinus Torvalds #ifdef CONFIG_SND_OSSEMUL 2321da177e4SLinus Torvalds int snd_minor_info_oss_init(void); 2331da177e4SLinus Torvalds int snd_minor_info_oss_done(void); 2341da177e4SLinus Torvalds #else 235ad5fada5SPavel Machek static inline int snd_minor_info_oss_init(void) { return 0; } 236ad5fada5SPavel Machek static inline int snd_minor_info_oss_done(void) { return 0; } 2371da177e4SLinus Torvalds #endif 2381da177e4SLinus Torvalds 2391da177e4SLinus Torvalds /* memory.c */ 2401da177e4SLinus Torvalds 2411da177e4SLinus Torvalds int copy_to_user_fromio(void __user *dst, const volatile void __iomem *src, size_t count); 2421da177e4SLinus Torvalds int copy_from_user_toio(volatile void __iomem *dst, const void __user *src, size_t count); 2431da177e4SLinus Torvalds 2441da177e4SLinus Torvalds /* init.c */ 2451da177e4SLinus Torvalds 246512bbd6aSTakashi Iwai extern struct snd_card *snd_cards[SNDRV_CARDS]; 247746df948STakashi Iwai int snd_card_locked(int card); 2481da177e4SLinus Torvalds #if defined(CONFIG_SND_MIXER_OSS) || defined(CONFIG_SND_MIXER_OSS_MODULE) 2491da177e4SLinus Torvalds #define SND_MIXER_OSS_NOTIFY_REGISTER 0 2501da177e4SLinus Torvalds #define SND_MIXER_OSS_NOTIFY_DISCONNECT 1 2511da177e4SLinus Torvalds #define SND_MIXER_OSS_NOTIFY_FREE 2 252512bbd6aSTakashi Iwai extern int (*snd_mixer_oss_notify_callback)(struct snd_card *card, int cmd); 2531da177e4SLinus Torvalds #endif 2541da177e4SLinus Torvalds 255393aa9c1STakashi Iwai int snd_card_new(struct device *parent, int idx, const char *xid, 25653fb1e63STakashi Iwai struct module *module, int extra_size, 25753fb1e63STakashi Iwai struct snd_card **card_ret); 25853fb1e63STakashi Iwai 259512bbd6aSTakashi Iwai int snd_card_disconnect(struct snd_card *card); 260512bbd6aSTakashi Iwai int snd_card_free(struct snd_card *card); 261c461482cSTakashi Iwai int snd_card_free_when_closed(struct snd_card *card); 26210a8ebbbSJaroslav Kysela void snd_card_set_id(struct snd_card *card, const char *id); 263512bbd6aSTakashi Iwai int snd_card_register(struct snd_card *card); 2641da177e4SLinus Torvalds int snd_card_info_init(void); 2651da177e4SLinus Torvalds int snd_card_info_done(void); 266512bbd6aSTakashi Iwai int snd_component_add(struct snd_card *card, const char *component); 267512bbd6aSTakashi Iwai int snd_card_file_add(struct snd_card *card, struct file *file); 268512bbd6aSTakashi Iwai int snd_card_file_remove(struct snd_card *card, struct file *file); 269f2464064STakashi Iwai #define snd_card_unref(card) put_device(&(card)->card_dev) 2701da177e4SLinus Torvalds 2717d2aae1eSTakashi Iwai #define snd_card_set_dev(card, devptr) ((card)->dev = (devptr)) 2721da177e4SLinus Torvalds 2731da177e4SLinus Torvalds /* device.c */ 2741da177e4SLinus Torvalds 2759ce50543STakashi Iwai int snd_device_new(struct snd_card *card, enum snd_device_type type, 276512bbd6aSTakashi Iwai void *device_data, struct snd_device_ops *ops); 277512bbd6aSTakashi Iwai int snd_device_register(struct snd_card *card, void *device_data); 278512bbd6aSTakashi Iwai int snd_device_register_all(struct snd_card *card); 279512bbd6aSTakashi Iwai int snd_device_disconnect_all(struct snd_card *card); 28072620d60STakashi Iwai void snd_device_free(struct snd_card *card, void *device_data); 28172620d60STakashi Iwai void snd_device_free_all(struct snd_card *card); 2821da177e4SLinus Torvalds 2831da177e4SLinus Torvalds /* isadma.c */ 2841da177e4SLinus Torvalds 285276bd31cSAl Viro #ifdef CONFIG_ISA_DMA_API 2861da177e4SLinus Torvalds #define DMA_MODE_NO_ENABLE 0x0100 2871da177e4SLinus Torvalds 2881da177e4SLinus Torvalds void snd_dma_program(unsigned long dma, unsigned long addr, unsigned int size, unsigned short mode); 2891da177e4SLinus Torvalds void snd_dma_disable(unsigned long dma); 2901da177e4SLinus Torvalds unsigned int snd_dma_pointer(unsigned long dma, unsigned int size); 291276bd31cSAl Viro #endif 2921da177e4SLinus Torvalds 2931da177e4SLinus Torvalds /* misc.c */ 294b709e574STakashi Iwai struct resource; 295b1d5776dSTakashi Iwai void release_and_free_resource(struct resource *res); 2961da177e4SLinus Torvalds 2971da177e4SLinus Torvalds /* --- */ 2981da177e4SLinus Torvalds 299fae3d88aSFengguang Wu /* sound printk debug levels */ 300fae3d88aSFengguang Wu enum { 301fae3d88aSFengguang Wu SND_PR_ALWAYS, 302fae3d88aSFengguang Wu SND_PR_DEBUG, 303fae3d88aSFengguang Wu SND_PR_VERBOSE, 304fae3d88aSFengguang Wu }; 305fae3d88aSFengguang Wu 30636ce99c1STakashi Iwai #if defined(CONFIG_SND_DEBUG) || defined(CONFIG_SND_VERBOSE_PRINTK) 307b9075fa9SJoe Perches __printf(4, 5) 30836ce99c1STakashi Iwai void __snd_printk(unsigned int level, const char *file, int line, 309b9075fa9SJoe Perches const char *format, ...); 31036ce99c1STakashi Iwai #else 31136ce99c1STakashi Iwai #define __snd_printk(level, file, line, format, args...) \ 312cf0baf16STakashi Iwai printk(format, ##args) 31336ce99c1STakashi Iwai #endif 31436ce99c1STakashi Iwai 3151da177e4SLinus Torvalds /** 3161da177e4SLinus Torvalds * snd_printk - printk wrapper 3171da177e4SLinus Torvalds * @fmt: format string 3181da177e4SLinus Torvalds * 319f66fcedcSTakashi Iwai * Works like printk() but prints the file and the line of the caller 3201da177e4SLinus Torvalds * when configured with CONFIG_SND_VERBOSE_PRINTK. 3211da177e4SLinus Torvalds */ 3221da177e4SLinus Torvalds #define snd_printk(fmt, args...) \ 32336ce99c1STakashi Iwai __snd_printk(0, __FILE__, __LINE__, fmt, ##args) 3241da177e4SLinus Torvalds 3251da177e4SLinus Torvalds #ifdef CONFIG_SND_DEBUG 3261da177e4SLinus Torvalds /** 3271da177e4SLinus Torvalds * snd_printd - debug printk 3280863afb3SMartin Waitz * @fmt: format string 3291da177e4SLinus Torvalds * 330edab938eSPavel Machek * Works like snd_printk() for debugging purposes. 3311da177e4SLinus Torvalds * Ignored when CONFIG_SND_DEBUG is not set. 3321da177e4SLinus Torvalds */ 3331da177e4SLinus Torvalds #define snd_printd(fmt, args...) \ 33436ce99c1STakashi Iwai __snd_printk(1, __FILE__, __LINE__, fmt, ##args) 335fae3d88aSFengguang Wu #define _snd_printd(level, fmt, args...) \ 336fae3d88aSFengguang Wu __snd_printk(level, __FILE__, __LINE__, fmt, ##args) 3377c22f1aaSTakashi Iwai 338f66fcedcSTakashi Iwai /** 339f66fcedcSTakashi Iwai * snd_BUG - give a BUG warning message and stack trace 340f66fcedcSTakashi Iwai * 341f66fcedcSTakashi Iwai * Calls WARN() if CONFIG_SND_DEBUG is set. 342f66fcedcSTakashi Iwai * Ignored when CONFIG_SND_DEBUG is not set. 343f66fcedcSTakashi Iwai */ 344bdbecf50STakashi Iwai #define snd_BUG() WARN(1, "BUG?\n") 345f66fcedcSTakashi Iwai 346f66fcedcSTakashi Iwai /** 347bcbb1553STim Gardner * Suppress high rates of output when CONFIG_SND_DEBUG is enabled. 348bcbb1553STim Gardner */ 349bcbb1553STim Gardner #define snd_printd_ratelimit() printk_ratelimit() 350bcbb1553STim Gardner 351bcbb1553STim Gardner /** 352f66fcedcSTakashi Iwai * snd_BUG_ON - debugging check macro 353f66fcedcSTakashi Iwai * @cond: condition to evaluate 354f66fcedcSTakashi Iwai * 355d5702162SChristine Spang * Has the same behavior as WARN_ON when CONFIG_SND_DEBUG is set, 356d5702162SChristine Spang * otherwise just evaluates the conditional and returns the value. 357f66fcedcSTakashi Iwai */ 358d5702162SChristine Spang #define snd_BUG_ON(cond) WARN_ON((cond)) 3591da177e4SLinus Torvalds 3601da177e4SLinus Torvalds #else /* !CONFIG_SND_DEBUG */ 3611da177e4SLinus Torvalds 36286b27237STakashi Iwai __printf(1, 2) 36386b27237STakashi Iwai static inline void snd_printd(const char *format, ...) {} 36486b27237STakashi Iwai __printf(2, 3) 36586b27237STakashi Iwai static inline void _snd_printd(int level, const char *format, ...) {} 36686b27237STakashi Iwai 367fcef7836SAndrew Morton #define snd_BUG() do { } while (0) 368d5702162SChristine Spang 369d5702162SChristine Spang #define snd_BUG_ON(condition) ({ \ 370d5702162SChristine Spang int __ret_warn_on = !!(condition); \ 371d5702162SChristine Spang unlikely(__ret_warn_on); \ 372d5702162SChristine Spang }) 3731da177e4SLinus Torvalds 374bcbb1553STim Gardner static inline bool snd_printd_ratelimit(void) { return false; } 375bcbb1553STim Gardner 3761da177e4SLinus Torvalds #endif /* CONFIG_SND_DEBUG */ 3771da177e4SLinus Torvalds 37862cf872aSTakashi Iwai #ifdef CONFIG_SND_DEBUG_VERBOSE 3791da177e4SLinus Torvalds /** 3801da177e4SLinus Torvalds * snd_printdd - debug printk 3811da177e4SLinus Torvalds * @format: format string 3821da177e4SLinus Torvalds * 383edab938eSPavel Machek * Works like snd_printk() for debugging purposes. 38462cf872aSTakashi Iwai * Ignored when CONFIG_SND_DEBUG_VERBOSE is not set. 3851da177e4SLinus Torvalds */ 38636ce99c1STakashi Iwai #define snd_printdd(format, args...) \ 38736ce99c1STakashi Iwai __snd_printk(2, __FILE__, __LINE__, format, ##args) 3881da177e4SLinus Torvalds #else 38986b27237STakashi Iwai __printf(1, 2) 39086b27237STakashi Iwai static inline void snd_printdd(const char *format, ...) {} 3911da177e4SLinus Torvalds #endif 3921da177e4SLinus Torvalds 3931da177e4SLinus Torvalds 3941da177e4SLinus Torvalds #define SNDRV_OSS_VERSION ((3<<16)|(8<<8)|(1<<4)|(0)) /* 3.8.1a */ 3951da177e4SLinus Torvalds 3961da177e4SLinus Torvalds /* for easier backward-porting */ 3971da177e4SLinus Torvalds #if defined(CONFIG_GAMEPORT) || defined(CONFIG_GAMEPORT_MODULE) 3981da177e4SLinus Torvalds #define gameport_set_dev_parent(gp,xdev) ((gp)->dev.parent = (xdev)) 3991da177e4SLinus Torvalds #define gameport_set_port_data(gp,r) ((gp)->port_data = (r)) 4001da177e4SLinus Torvalds #define gameport_get_port_data(gp) (gp)->port_data 4011da177e4SLinus Torvalds #endif 4021da177e4SLinus Torvalds 403d9ea472cSTakashi Iwai /* PCI quirk list helper */ 404d9ea472cSTakashi Iwai struct snd_pci_quirk { 405d9ea472cSTakashi Iwai unsigned short subvendor; /* PCI subvendor ID */ 406d9ea472cSTakashi Iwai unsigned short subdevice; /* PCI subdevice ID */ 4078bd4bb7aSTakashi Iwai unsigned short subdevice_mask; /* bitmask to match */ 408d9ea472cSTakashi Iwai int value; /* value */ 40962cf872aSTakashi Iwai #ifdef CONFIG_SND_DEBUG_VERBOSE 410d9ea472cSTakashi Iwai const char *name; /* name of the device (optional) */ 411d9ea472cSTakashi Iwai #endif 412d9ea472cSTakashi Iwai }; 413d9ea472cSTakashi Iwai 4148bd4bb7aSTakashi Iwai #define _SND_PCI_QUIRK_ID_MASK(vend, mask, dev) \ 4158bd4bb7aSTakashi Iwai .subvendor = (vend), .subdevice = (dev), .subdevice_mask = (mask) 416d9ea472cSTakashi Iwai #define _SND_PCI_QUIRK_ID(vend, dev) \ 4178bd4bb7aSTakashi Iwai _SND_PCI_QUIRK_ID_MASK(vend, 0xffff, dev) 418d9ea472cSTakashi Iwai #define SND_PCI_QUIRK_ID(vend,dev) {_SND_PCI_QUIRK_ID(vend, dev)} 41962cf872aSTakashi Iwai #ifdef CONFIG_SND_DEBUG_VERBOSE 420d9ea472cSTakashi Iwai #define SND_PCI_QUIRK(vend,dev,xname,val) \ 421d9ea472cSTakashi Iwai {_SND_PCI_QUIRK_ID(vend, dev), .value = (val), .name = (xname)} 4228bd4bb7aSTakashi Iwai #define SND_PCI_QUIRK_VENDOR(vend, xname, val) \ 4238bd4bb7aSTakashi Iwai {_SND_PCI_QUIRK_ID_MASK(vend, 0, 0), .value = (val), .name = (xname)} 4248bd4bb7aSTakashi Iwai #define SND_PCI_QUIRK_MASK(vend, mask, dev, xname, val) \ 4258bd4bb7aSTakashi Iwai {_SND_PCI_QUIRK_ID_MASK(vend, mask, dev), \ 4268bd4bb7aSTakashi Iwai .value = (val), .name = (xname)} 42786b27237STakashi Iwai #define snd_pci_quirk_name(q) ((q)->name) 428d9ea472cSTakashi Iwai #else 429d9ea472cSTakashi Iwai #define SND_PCI_QUIRK(vend,dev,xname,val) \ 430d9ea472cSTakashi Iwai {_SND_PCI_QUIRK_ID(vend, dev), .value = (val)} 4318bd4bb7aSTakashi Iwai #define SND_PCI_QUIRK_MASK(vend, mask, dev, xname, val) \ 4328bd4bb7aSTakashi Iwai {_SND_PCI_QUIRK_ID_MASK(vend, mask, dev), .value = (val)} 4338bd4bb7aSTakashi Iwai #define SND_PCI_QUIRK_VENDOR(vend, xname, val) \ 4348bd4bb7aSTakashi Iwai {_SND_PCI_QUIRK_ID_MASK(vend, 0, 0), .value = (val)} 43586b27237STakashi Iwai #define snd_pci_quirk_name(q) "" 436d9ea472cSTakashi Iwai #endif 437d9ea472cSTakashi Iwai 438f0a220deSDylan Reid #ifdef CONFIG_PCI 439d9ea472cSTakashi Iwai const struct snd_pci_quirk * 440d9ea472cSTakashi Iwai snd_pci_quirk_lookup(struct pci_dev *pci, const struct snd_pci_quirk *list); 441d9ea472cSTakashi Iwai 442d1458279STakashi Iwai const struct snd_pci_quirk * 443d1458279STakashi Iwai snd_pci_quirk_lookup_id(u16 vendor, u16 device, 444d1458279STakashi Iwai const struct snd_pci_quirk *list); 445f0a220deSDylan Reid #else 446f0a220deSDylan Reid static inline const struct snd_pci_quirk * 447f0a220deSDylan Reid snd_pci_quirk_lookup(struct pci_dev *pci, const struct snd_pci_quirk *list) 448f0a220deSDylan Reid { 449f0a220deSDylan Reid return NULL; 450f0a220deSDylan Reid } 451f0a220deSDylan Reid 452f0a220deSDylan Reid static inline const struct snd_pci_quirk * 453f0a220deSDylan Reid snd_pci_quirk_lookup_id(u16 vendor, u16 device, 454f0a220deSDylan Reid const struct snd_pci_quirk *list) 455f0a220deSDylan Reid { 456f0a220deSDylan Reid return NULL; 457f0a220deSDylan Reid } 4588422fa11SAxel Lin #endif 459d9ea472cSTakashi Iwai 4601da177e4SLinus Torvalds #endif /* __SOUND_CORE_H */ 461