core.h revision 5ef03460a6ffc1d3ee6b6f2abc6765d3e224cf89
11da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#ifndef __SOUND_CORE_H
21da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define __SOUND_CORE_H
31da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
41da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/*
51da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *  Main header file for the ALSA driver
6c1017a4cdb68ae5368fbc9ee42c77f1f5dca8916Jaroslav Kysela *  Copyright (c) 1994-2001 by Jaroslav Kysela <perex@perex.cz>
71da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *
81da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *
91da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *   This program is free software; you can redistribute it and/or modify
101da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *   it under the terms of the GNU General Public License as published by
111da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *   the Free Software Foundation; either version 2 of the License, or
121da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *   (at your option) any later version.
131da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *
141da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *   This program is distributed in the hope that it will be useful,
151da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *   but WITHOUT ANY WARRANTY; without even the implied warranty of
161da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
171da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *   GNU General Public License for more details.
181da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *
191da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *   You should have received a copy of the GNU General Public License
201da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *   along with this program; if not, write to the Free Software
211da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
221da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *
231da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */
241da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
259004acc70e8c49c50c4c7b652f906f1e0ed5709dTakashi Iwai#include <linux/module.h>
261da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <linux/sched.h>		/* wake_up() */
271a60d4c5a0c4028559585a74e48593b16e1ca9b2Ingo Molnar#include <linux/mutex.h>		/* struct mutex */
281da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <linux/rwsem.h>		/* struct rw_semaphore */
291da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <linux/pm.h>			/* pm_message_t */
309d19f48cfe2570562c2c6226780a7ca627b0f1f1Takashi Iwai#include <linux/device.h>
315ef03460a6ffc1d3ee6b6f2abc6765d3e224cf89Takashi Iwai#include <linux/stringify.h>
321da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
339004acc70e8c49c50c4c7b652f906f1e0ed5709dTakashi Iwai/* number of supported soundcards */
349004acc70e8c49c50c4c7b652f906f1e0ed5709dTakashi Iwai#ifdef CONFIG_SND_DYNAMIC_MINORS
359004acc70e8c49c50c4c7b652f906f1e0ed5709dTakashi Iwai#define SNDRV_CARDS 32
369004acc70e8c49c50c4c7b652f906f1e0ed5709dTakashi Iwai#else
379004acc70e8c49c50c4c7b652f906f1e0ed5709dTakashi Iwai#define SNDRV_CARDS 8		/* don't change - minor numbers */
389004acc70e8c49c50c4c7b652f906f1e0ed5709dTakashi Iwai#endif
399004acc70e8c49c50c4c7b652f906f1e0ed5709dTakashi Iwai
409004acc70e8c49c50c4c7b652f906f1e0ed5709dTakashi Iwai#define CONFIG_SND_MAJOR	116	/* standard configuration */
419004acc70e8c49c50c4c7b652f906f1e0ed5709dTakashi Iwai
421da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* forward declarations */
431da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#ifdef CONFIG_PCI
441da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstruct pci_dev;
451da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#endif
461da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#ifdef CONFIG_SBUS
471da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstruct sbus_dev;
481da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#endif
491da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
501da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* device allocation stuff */
511da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
521da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define SNDRV_DEV_TYPE_RANGE_SIZE		0x1000
531da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
54512bbd6a85230f16389f0dd51925472e72fc8a91Takashi Iwaitypedef int __bitwise snd_device_type_t;
55512bbd6a85230f16389f0dd51925472e72fc8a91Takashi Iwai#define	SNDRV_DEV_TOPLEVEL	((__force snd_device_type_t) 0)
56512bbd6a85230f16389f0dd51925472e72fc8a91Takashi Iwai#define	SNDRV_DEV_CONTROL	((__force snd_device_type_t) 1)
57512bbd6a85230f16389f0dd51925472e72fc8a91Takashi Iwai#define	SNDRV_DEV_LOWLEVEL_PRE	((__force snd_device_type_t) 2)
58512bbd6a85230f16389f0dd51925472e72fc8a91Takashi Iwai#define	SNDRV_DEV_LOWLEVEL_NORMAL ((__force snd_device_type_t) 0x1000)
59512bbd6a85230f16389f0dd51925472e72fc8a91Takashi Iwai#define	SNDRV_DEV_PCM		((__force snd_device_type_t) 0x1001)
60512bbd6a85230f16389f0dd51925472e72fc8a91Takashi Iwai#define	SNDRV_DEV_RAWMIDI	((__force snd_device_type_t) 0x1002)
61512bbd6a85230f16389f0dd51925472e72fc8a91Takashi Iwai#define	SNDRV_DEV_TIMER		((__force snd_device_type_t) 0x1003)
62512bbd6a85230f16389f0dd51925472e72fc8a91Takashi Iwai#define	SNDRV_DEV_SEQUENCER	((__force snd_device_type_t) 0x1004)
63512bbd6a85230f16389f0dd51925472e72fc8a91Takashi Iwai#define	SNDRV_DEV_HWDEP		((__force snd_device_type_t) 0x1005)
64512bbd6a85230f16389f0dd51925472e72fc8a91Takashi Iwai#define	SNDRV_DEV_INFO		((__force snd_device_type_t) 0x1006)
65512bbd6a85230f16389f0dd51925472e72fc8a91Takashi Iwai#define	SNDRV_DEV_BUS		((__force snd_device_type_t) 0x1007)
66512bbd6a85230f16389f0dd51925472e72fc8a91Takashi Iwai#define	SNDRV_DEV_CODEC		((__force snd_device_type_t) 0x1008)
67e76d8ceaaff9d7fc1ba2b1963a9f34151832223bMark Brown#define	SNDRV_DEV_JACK          ((__force snd_device_type_t) 0x1009)
68512bbd6a85230f16389f0dd51925472e72fc8a91Takashi Iwai#define	SNDRV_DEV_LOWLEVEL	((__force snd_device_type_t) 0x2000)
69512bbd6a85230f16389f0dd51925472e72fc8a91Takashi Iwai
70512bbd6a85230f16389f0dd51925472e72fc8a91Takashi Iwaitypedef int __bitwise snd_device_state_t;
71512bbd6a85230f16389f0dd51925472e72fc8a91Takashi Iwai#define	SNDRV_DEV_BUILD		((__force snd_device_state_t) 0)
72512bbd6a85230f16389f0dd51925472e72fc8a91Takashi Iwai#define	SNDRV_DEV_REGISTERED	((__force snd_device_state_t) 1)
73512bbd6a85230f16389f0dd51925472e72fc8a91Takashi Iwai#define	SNDRV_DEV_DISCONNECTED	((__force snd_device_state_t) 2)
74512bbd6a85230f16389f0dd51925472e72fc8a91Takashi Iwai
75512bbd6a85230f16389f0dd51925472e72fc8a91Takashi Iwaitypedef int __bitwise snd_device_cmd_t;
76512bbd6a85230f16389f0dd51925472e72fc8a91Takashi Iwai#define	SNDRV_DEV_CMD_PRE	((__force snd_device_cmd_t) 0)
77512bbd6a85230f16389f0dd51925472e72fc8a91Takashi Iwai#define	SNDRV_DEV_CMD_NORMAL	((__force snd_device_cmd_t) 1)
78512bbd6a85230f16389f0dd51925472e72fc8a91Takashi Iwai#define	SNDRV_DEV_CMD_POST	((__force snd_device_cmd_t) 2)
79512bbd6a85230f16389f0dd51925472e72fc8a91Takashi Iwai
80512bbd6a85230f16389f0dd51925472e72fc8a91Takashi Iwaistruct snd_device;
81512bbd6a85230f16389f0dd51925472e72fc8a91Takashi Iwai
82512bbd6a85230f16389f0dd51925472e72fc8a91Takashi Iwaistruct snd_device_ops {
83512bbd6a85230f16389f0dd51925472e72fc8a91Takashi Iwai	int (*dev_free)(struct snd_device *dev);
84512bbd6a85230f16389f0dd51925472e72fc8a91Takashi Iwai	int (*dev_register)(struct snd_device *dev);
85512bbd6a85230f16389f0dd51925472e72fc8a91Takashi Iwai	int (*dev_disconnect)(struct snd_device *dev);
86512bbd6a85230f16389f0dd51925472e72fc8a91Takashi Iwai};
87512bbd6a85230f16389f0dd51925472e72fc8a91Takashi Iwai
88512bbd6a85230f16389f0dd51925472e72fc8a91Takashi Iwaistruct snd_device {
891da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	struct list_head list;		/* list of registered devices */
90512bbd6a85230f16389f0dd51925472e72fc8a91Takashi Iwai	struct snd_card *card;		/* card which holds this device */
911da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	snd_device_state_t state;	/* state of the device */
921da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	snd_device_type_t type;		/* device type */
931da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	void *device_data;		/* device structure */
94512bbd6a85230f16389f0dd51925472e72fc8a91Takashi Iwai	struct snd_device_ops *ops;	/* operations */
951da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds};
961da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
97512bbd6a85230f16389f0dd51925472e72fc8a91Takashi Iwai#define snd_device(n) list_entry(n, struct snd_device, list)
981da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
991da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* monitor files for graceful shutdown (hotplug) */
1001da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
1011da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstruct snd_monitor_file {
1021da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	struct file *file;
1031da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	struct snd_monitor_file *next;
104a9edfc60227a1dc5c741666ff252a6055b73b184Karsten Wiese	const struct file_operations *disconnected_f_op;
105a9edfc60227a1dc5c741666ff252a6055b73b184Karsten Wiese	struct list_head shutdown_list;
1061da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds};
1071da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
1081da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* main structure for soundcard */
1091da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
110512bbd6a85230f16389f0dd51925472e72fc8a91Takashi Iwaistruct snd_card {
111d5750f67853350373fc1d5698c3a58ea16eddf4cHenrik Kretzschmar	int number;			/* number of soundcard (index to
112d5750f67853350373fc1d5698c3a58ea16eddf4cHenrik Kretzschmar								snd_cards) */
1131da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
1141da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	char id[16];			/* id string of this card */
1151da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	char driver[16];		/* driver name */
1161da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	char shortname[32];		/* short name of this soundcard */
1171da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	char longname[80];		/* name of this soundcard */
1181da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	char mixername[80];		/* mixer name */
119d5750f67853350373fc1d5698c3a58ea16eddf4cHenrik Kretzschmar	char components[80];		/* card components delimited with
120d5750f67853350373fc1d5698c3a58ea16eddf4cHenrik Kretzschmar								space */
1211da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	struct module *module;		/* top-level module */
1221da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
1231da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	void *private_data;		/* private data for soundcard */
124512bbd6a85230f16389f0dd51925472e72fc8a91Takashi Iwai	void (*private_free) (struct snd_card *card); /* callback for freeing of
125d5750f67853350373fc1d5698c3a58ea16eddf4cHenrik Kretzschmar								private data */
1261da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	struct list_head devices;	/* devices */
1271da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
1281da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	unsigned int last_numid;	/* last used numeric ID */
1291da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	struct rw_semaphore controls_rwsem;	/* controls list lock */
1301da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	rwlock_t ctl_files_rwlock;	/* ctl_files list lock */
1311da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	int controls_count;		/* count of all controls */
1321da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	int user_ctl_count;		/* count of all user controls */
1331da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	struct list_head controls;	/* all controls for this card */
1341da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	struct list_head ctl_files;	/* active control files */
1351da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
136512bbd6a85230f16389f0dd51925472e72fc8a91Takashi Iwai	struct snd_info_entry *proc_root;	/* root for soundcard specific files */
137512bbd6a85230f16389f0dd51925472e72fc8a91Takashi Iwai	struct snd_info_entry *proc_id;	/* the card id */
1381da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	struct proc_dir_entry *proc_root_link;	/* number link to real id */
1391da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
1401da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	struct snd_monitor_file *files; /* all files associated to this card */
141d5750f67853350373fc1d5698c3a58ea16eddf4cHenrik Kretzschmar	struct snd_shutdown_f_ops *s_f_ops; /* file operations in the shutdown
142d5750f67853350373fc1d5698c3a58ea16eddf4cHenrik Kretzschmar								state */
1431da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	spinlock_t files_lock;		/* lock the files for this card */
1441da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	int shutdown;			/* this card is going down */
145c461482c8072bb073e6146db320d3da85cdc89adTakashi Iwai	int free_on_last_close;		/* free in context of file_release */
1461da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	wait_queue_head_t shutdown_sleep;
1477d2aae1e88660cf09be913e9754e45189dc33412Takashi Iwai	struct device *dev;		/* device assigned to this card */
1487d2aae1e88660cf09be913e9754e45189dc33412Takashi Iwai#ifndef CONFIG_SYSFS_DEPRECATED
1497d2aae1e88660cf09be913e9754e45189dc33412Takashi Iwai	struct device *card_dev;	/* cardX object for sysfs */
1507d2aae1e88660cf09be913e9754e45189dc33412Takashi Iwai#endif
1511da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
1521da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#ifdef CONFIG_PM
1531da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	unsigned int power_state;	/* power state */
1541a60d4c5a0c4028559585a74e48593b16e1ca9b2Ingo Molnar	struct mutex power_lock;	/* power lock */
1551da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	wait_queue_head_t power_sleep;
1561da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#endif
1571da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
1581da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#if defined(CONFIG_SND_MIXER_OSS) || defined(CONFIG_SND_MIXER_OSS_MODULE)
159512bbd6a85230f16389f0dd51925472e72fc8a91Takashi Iwai	struct snd_mixer_oss *mixer_oss;
1601da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	int mixer_oss_change_count;
1611da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#endif
1621da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds};
1631da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
1641da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#ifdef CONFIG_PM
165512bbd6a85230f16389f0dd51925472e72fc8a91Takashi Iwaistatic inline void snd_power_lock(struct snd_card *card)
1661da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{
1671a60d4c5a0c4028559585a74e48593b16e1ca9b2Ingo Molnar	mutex_lock(&card->power_lock);
1681da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds}
1691da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
170512bbd6a85230f16389f0dd51925472e72fc8a91Takashi Iwaistatic inline void snd_power_unlock(struct snd_card *card)
1711da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{
1721a60d4c5a0c4028559585a74e48593b16e1ca9b2Ingo Molnar	mutex_unlock(&card->power_lock);
1731da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds}
1741da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
175512bbd6a85230f16389f0dd51925472e72fc8a91Takashi Iwaistatic inline unsigned int snd_power_get_state(struct snd_card *card)
1761da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{
1771da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	return card->power_state;
1781da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds}
1791da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
180512bbd6a85230f16389f0dd51925472e72fc8a91Takashi Iwaistatic inline void snd_power_change_state(struct snd_card *card, unsigned int state)
1811da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{
1821da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	card->power_state = state;
1831da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	wake_up(&card->power_sleep);
1841da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds}
185d5750f67853350373fc1d5698c3a58ea16eddf4cHenrik Kretzschmar
186d5750f67853350373fc1d5698c3a58ea16eddf4cHenrik Kretzschmar/* init.c */
187cbac4b0cb62d01cb0aaec7778410b8856f01186bTakashi Iwaiint snd_power_wait(struct snd_card *card, unsigned int power_state);
188d5750f67853350373fc1d5698c3a58ea16eddf4cHenrik Kretzschmar
1891da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#else /* ! CONFIG_PM */
1901da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
1911da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define snd_power_lock(card)		do { (void)(card); } while (0)
1921da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define snd_power_unlock(card)		do { (void)(card); } while (0)
1936fdb94bd95dc7a2effcbffa7a1d9e792cade57b6Linus Torvaldsstatic inline int snd_power_wait(struct snd_card *card, unsigned int state) { return 0; }
1941da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define snd_power_get_state(card)	SNDRV_CTL_POWER_D0
1951da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define snd_power_change_state(card, state)	do { (void)(card); } while (0)
1961da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
1971da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#endif /* CONFIG_PM */
1981da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
199512bbd6a85230f16389f0dd51925472e72fc8a91Takashi Iwaistruct snd_minor {
2002af677fc884fc6dc79e65c99050ea607ac8bab9bClemens Ladisch	int type;			/* SNDRV_DEVICE_TYPE_XXX */
2016983b7240cd229787c3ee00e663ea94ea649d96aClemens Ladisch	int card;			/* card number */
2021da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	int device;			/* device number */
20399ac48f54a91d02140c497edc31dc57d4bc5c85dArjan van de Ven	const struct file_operations *f_ops;	/* file operations */
204f87135f56cb266e031f5ec081dfbde7e43f55e80Clemens Ladisch	void *private_data;		/* private data for f_ops->open */
205d80f19fab89cba8a6d16193154c8ff3edab00942Greg Kroah-Hartman	struct device *dev;		/* device for sysfs */
2061da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds};
2071da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
2087d2aae1e88660cf09be913e9754e45189dc33412Takashi Iwai/* return a device pointer linked to each sound device as a parent */
2097d2aae1e88660cf09be913e9754e45189dc33412Takashi Iwaistatic inline struct device *snd_card_get_device_link(struct snd_card *card)
2107d2aae1e88660cf09be913e9754e45189dc33412Takashi Iwai{
2117d2aae1e88660cf09be913e9754e45189dc33412Takashi Iwai#ifdef CONFIG_SYSFS_DEPRECATED
2127d2aae1e88660cf09be913e9754e45189dc33412Takashi Iwai	return card ? card->dev : NULL;
2137d2aae1e88660cf09be913e9754e45189dc33412Takashi Iwai#else
2147d2aae1e88660cf09be913e9754e45189dc33412Takashi Iwai	return card ? card->card_dev : NULL;
2157d2aae1e88660cf09be913e9754e45189dc33412Takashi Iwai#endif
2167d2aae1e88660cf09be913e9754e45189dc33412Takashi Iwai}
2177d2aae1e88660cf09be913e9754e45189dc33412Takashi Iwai
2181da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* sound.c */
2191da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
220f1902860161ff212c515e7ea629e880fec856a37Clemens Ladischextern int snd_major;
2211da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsextern int snd_ecards_limit;
222d80f19fab89cba8a6d16193154c8ff3edab00942Greg Kroah-Hartmanextern struct class *sound_class;
2231da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
2241da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsvoid snd_request_card(int card);
2251da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
22612b131c4cf3eb1dc8a60082a434b7b100774c2e7Johannes Bergint snd_register_device_for_dev(int type, struct snd_card *card,
22712b131c4cf3eb1dc8a60082a434b7b100774c2e7Johannes Berg				int dev,
22812b131c4cf3eb1dc8a60082a434b7b100774c2e7Johannes Berg				const struct file_operations *f_ops,
22912b131c4cf3eb1dc8a60082a434b7b100774c2e7Johannes Berg				void *private_data,
23012b131c4cf3eb1dc8a60082a434b7b100774c2e7Johannes Berg				const char *name,
23112b131c4cf3eb1dc8a60082a434b7b100774c2e7Johannes Berg				struct device *device);
23212b131c4cf3eb1dc8a60082a434b7b100774c2e7Johannes Berg
23312b131c4cf3eb1dc8a60082a434b7b100774c2e7Johannes Berg/**
23412b131c4cf3eb1dc8a60082a434b7b100774c2e7Johannes Berg * snd_register_device - Register the ALSA device file for the card
23512b131c4cf3eb1dc8a60082a434b7b100774c2e7Johannes Berg * @type: the device type, SNDRV_DEVICE_TYPE_XXX
23612b131c4cf3eb1dc8a60082a434b7b100774c2e7Johannes Berg * @card: the card instance
23712b131c4cf3eb1dc8a60082a434b7b100774c2e7Johannes Berg * @dev: the device index
23812b131c4cf3eb1dc8a60082a434b7b100774c2e7Johannes Berg * @f_ops: the file operations
23912b131c4cf3eb1dc8a60082a434b7b100774c2e7Johannes Berg * @private_data: user pointer for f_ops->open()
24012b131c4cf3eb1dc8a60082a434b7b100774c2e7Johannes Berg * @name: the device file name
24112b131c4cf3eb1dc8a60082a434b7b100774c2e7Johannes Berg *
24212b131c4cf3eb1dc8a60082a434b7b100774c2e7Johannes Berg * Registers an ALSA device file for the given card.
24312b131c4cf3eb1dc8a60082a434b7b100774c2e7Johannes Berg * The operators have to be set in reg parameter.
24412b131c4cf3eb1dc8a60082a434b7b100774c2e7Johannes Berg *
24512b131c4cf3eb1dc8a60082a434b7b100774c2e7Johannes Berg * This function uses the card's device pointer to link to the
24612b131c4cf3eb1dc8a60082a434b7b100774c2e7Johannes Berg * correct &struct device.
24712b131c4cf3eb1dc8a60082a434b7b100774c2e7Johannes Berg *
24812b131c4cf3eb1dc8a60082a434b7b100774c2e7Johannes Berg * Returns zero if successful, or a negative error code on failure.
24912b131c4cf3eb1dc8a60082a434b7b100774c2e7Johannes Berg */
25012b131c4cf3eb1dc8a60082a434b7b100774c2e7Johannes Bergstatic inline int snd_register_device(int type, struct snd_card *card, int dev,
25112b131c4cf3eb1dc8a60082a434b7b100774c2e7Johannes Berg				      const struct file_operations *f_ops,
25212b131c4cf3eb1dc8a60082a434b7b100774c2e7Johannes Berg				      void *private_data,
25312b131c4cf3eb1dc8a60082a434b7b100774c2e7Johannes Berg				      const char *name)
25412b131c4cf3eb1dc8a60082a434b7b100774c2e7Johannes Berg{
25512b131c4cf3eb1dc8a60082a434b7b100774c2e7Johannes Berg	return snd_register_device_for_dev(type, card, dev, f_ops,
25612b131c4cf3eb1dc8a60082a434b7b100774c2e7Johannes Berg					   private_data, name,
257c2902c8ae06762d941fab64198467f78cab6f8cdTakashi Iwai					   snd_card_get_device_link(card));
25812b131c4cf3eb1dc8a60082a434b7b100774c2e7Johannes Berg}
25912b131c4cf3eb1dc8a60082a434b7b100774c2e7Johannes Berg
260512bbd6a85230f16389f0dd51925472e72fc8a91Takashi Iwaiint snd_unregister_device(int type, struct snd_card *card, int dev);
261f87135f56cb266e031f5ec081dfbde7e43f55e80Clemens Ladischvoid *snd_lookup_minor_data(unsigned int minor, int type);
2629d19f48cfe2570562c2c6226780a7ca627b0f1f1Takashi Iwaiint snd_add_device_sysfs_file(int type, struct snd_card *card, int dev,
263d80f19fab89cba8a6d16193154c8ff3edab00942Greg Kroah-Hartman			      struct device_attribute *attr);
2641da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
2651da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#ifdef CONFIG_SND_OSSEMUL
2662af677fc884fc6dc79e65c99050ea607ac8bab9bClemens Ladischint snd_register_oss_device(int type, struct snd_card *card, int dev,
26799ac48f54a91d02140c497edc31dc57d4bc5c85dArjan van de Ven			    const struct file_operations *f_ops, void *private_data,
268f87135f56cb266e031f5ec081dfbde7e43f55e80Clemens Ladisch			    const char *name);
269512bbd6a85230f16389f0dd51925472e72fc8a91Takashi Iwaiint snd_unregister_oss_device(int type, struct snd_card *card, int dev);
270f87135f56cb266e031f5ec081dfbde7e43f55e80Clemens Ladischvoid *snd_lookup_oss_minor_data(unsigned int minor, int type);
2711da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#endif
2721da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
2731da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsint snd_minor_info_init(void);
2741da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsint snd_minor_info_done(void);
2751da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
2761da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* sound_oss.c */
2771da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
2781da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#ifdef CONFIG_SND_OSSEMUL
2791da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsint snd_minor_info_oss_init(void);
2801da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsint snd_minor_info_oss_done(void);
2811da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#else
282ad5fada51d33b408ad3d2d0848ef6744b5daf06fPavel Machekstatic inline int snd_minor_info_oss_init(void) { return 0; }
283ad5fada51d33b408ad3d2d0848ef6744b5daf06fPavel Machekstatic inline int snd_minor_info_oss_done(void) { return 0; }
2841da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#endif
2851da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
2861da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* memory.c */
2871da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
2881da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsint copy_to_user_fromio(void __user *dst, const volatile void __iomem *src, size_t count);
2891da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsint copy_from_user_toio(volatile void __iomem *dst, const void __user *src, size_t count);
2901da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
2911da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* init.c */
2921da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
293512bbd6a85230f16389f0dd51925472e72fc8a91Takashi Iwaiextern struct snd_card *snd_cards[SNDRV_CARDS];
294746df94898554b3d8e91d855e934852e626c701cTakashi Iwaiint snd_card_locked(int card);
2951da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#if defined(CONFIG_SND_MIXER_OSS) || defined(CONFIG_SND_MIXER_OSS_MODULE)
2961da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define SND_MIXER_OSS_NOTIFY_REGISTER	0
2971da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define SND_MIXER_OSS_NOTIFY_DISCONNECT	1
2981da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define SND_MIXER_OSS_NOTIFY_FREE	2
299512bbd6a85230f16389f0dd51925472e72fc8a91Takashi Iwaiextern int (*snd_mixer_oss_notify_callback)(struct snd_card *card, int cmd);
3001da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#endif
3011da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
302512bbd6a85230f16389f0dd51925472e72fc8a91Takashi Iwaistruct snd_card *snd_card_new(int idx, const char *id,
3031da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds			 struct module *module, int extra_size);
304512bbd6a85230f16389f0dd51925472e72fc8a91Takashi Iwaiint snd_card_disconnect(struct snd_card *card);
305512bbd6a85230f16389f0dd51925472e72fc8a91Takashi Iwaiint snd_card_free(struct snd_card *card);
306c461482c8072bb073e6146db320d3da85cdc89adTakashi Iwaiint snd_card_free_when_closed(struct snd_card *card);
307512bbd6a85230f16389f0dd51925472e72fc8a91Takashi Iwaiint snd_card_register(struct snd_card *card);
3081da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsint snd_card_info_init(void);
3091da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsint snd_card_info_done(void);
310512bbd6a85230f16389f0dd51925472e72fc8a91Takashi Iwaiint snd_component_add(struct snd_card *card, const char *component);
311512bbd6a85230f16389f0dd51925472e72fc8a91Takashi Iwaiint snd_card_file_add(struct snd_card *card, struct file *file);
312512bbd6a85230f16389f0dd51925472e72fc8a91Takashi Iwaiint snd_card_file_remove(struct snd_card *card, struct file *file);
3131da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
3141da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#ifndef snd_card_set_dev
315edab938e63e463da86e4aa7b94628ce8f2b8a137Pavel Machek#define snd_card_set_dev(card, devptr) ((card)->dev = (devptr))
3161da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#endif
3171da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
3181da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* device.c */
3191da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
320512bbd6a85230f16389f0dd51925472e72fc8a91Takashi Iwaiint snd_device_new(struct snd_card *card, snd_device_type_t type,
321512bbd6a85230f16389f0dd51925472e72fc8a91Takashi Iwai		   void *device_data, struct snd_device_ops *ops);
322512bbd6a85230f16389f0dd51925472e72fc8a91Takashi Iwaiint snd_device_register(struct snd_card *card, void *device_data);
323512bbd6a85230f16389f0dd51925472e72fc8a91Takashi Iwaiint snd_device_register_all(struct snd_card *card);
324512bbd6a85230f16389f0dd51925472e72fc8a91Takashi Iwaiint snd_device_disconnect(struct snd_card *card, void *device_data);
325512bbd6a85230f16389f0dd51925472e72fc8a91Takashi Iwaiint snd_device_disconnect_all(struct snd_card *card);
326512bbd6a85230f16389f0dd51925472e72fc8a91Takashi Iwaiint snd_device_free(struct snd_card *card, void *device_data);
327512bbd6a85230f16389f0dd51925472e72fc8a91Takashi Iwaiint snd_device_free_all(struct snd_card *card, snd_device_cmd_t cmd);
3281da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
3291da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* isadma.c */
3301da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
331276bd31ce5af01350465861af7aa6a25864eb108Al Viro#ifdef CONFIG_ISA_DMA_API
3321da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define DMA_MODE_NO_ENABLE	0x0100
3331da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
3341da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsvoid snd_dma_program(unsigned long dma, unsigned long addr, unsigned int size, unsigned short mode);
3351da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsvoid snd_dma_disable(unsigned long dma);
3361da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsunsigned int snd_dma_pointer(unsigned long dma, unsigned int size);
337276bd31ce5af01350465861af7aa6a25864eb108Al Viro#endif
3381da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
3391da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* misc.c */
340b709e57440b9d5f38b8c73e1310127d51777bba0Takashi Iwaistruct resource;
341b1d5776d865951c213a1caaab5d8bf5de7615dbdTakashi Iwaivoid release_and_free_resource(struct resource *res);
3421da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
3431da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#ifdef CONFIG_SND_VERBOSE_PRINTK
3441da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsvoid snd_verbose_printk(const char *file, int line, const char *format, ...)
3451da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds     __attribute__ ((format (printf, 3, 4)));
3461da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#endif
3471da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#if defined(CONFIG_SND_DEBUG) && defined(CONFIG_SND_VERBOSE_PRINTK)
3481da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsvoid snd_verbose_printd(const char *file, int line, const char *format, ...)
3491da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds     __attribute__ ((format (printf, 3, 4)));
3501da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#endif
3511da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
3521da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* --- */
3531da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
3541da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#ifdef CONFIG_SND_VERBOSE_PRINTK
3551da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/**
3561da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * snd_printk - printk wrapper
3571da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * @fmt: format string
3581da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *
3591da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Works like print() but prints the file and the line of the caller
3601da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * when configured with CONFIG_SND_VERBOSE_PRINTK.
3611da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */
3621da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define snd_printk(fmt, args...) \
3631da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	snd_verbose_printk(__FILE__, __LINE__, fmt ,##args)
3641da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#else
3651da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define snd_printk(fmt, args...) \
3661da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	printk(fmt ,##args)
3671da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#endif
3681da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
3691da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#ifdef CONFIG_SND_DEBUG
3701da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
3711da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define __ASTRING__(x) #x
3721da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
3731da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#ifdef CONFIG_SND_VERBOSE_PRINTK
3741da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/**
3751da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * snd_printd - debug printk
3760863afb32b77fc89c7110b3d10fb048cb56bb1b5Martin Waitz * @fmt: format string
3771da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *
378edab938e63e463da86e4aa7b94628ce8f2b8a137Pavel Machek * Works like snd_printk() for debugging purposes.
3791da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Ignored when CONFIG_SND_DEBUG is not set.
3801da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */
3811da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define snd_printd(fmt, args...) \
3821da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	snd_verbose_printd(__FILE__, __LINE__, fmt ,##args)
3831da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#else
3841da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define snd_printd(fmt, args...) \
3851da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	printk(fmt ,##args)
3861da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#endif
3871da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/**
388d5750f67853350373fc1d5698c3a58ea16eddf4cHenrik Kretzschmar * snd_assert - run-time assertion macro
3891da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * @expr: expression
3901da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *
3911da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * This macro checks the expression in run-time and invokes the commands
3921da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * given in the rest arguments if the assertion is failed.
3931da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * When CONFIG_SND_DEBUG is not set, the expression is executed but
3941da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * not checked.
3951da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */
3967c22f1aaa23370bf9ba2dd3abbccbed70dced216Takashi Iwai#define snd_assert(expr, args...) do {					\
3977c22f1aaa23370bf9ba2dd3abbccbed70dced216Takashi Iwai	if (unlikely(!(expr))) {					\
3987c22f1aaa23370bf9ba2dd3abbccbed70dced216Takashi Iwai		snd_printk(KERN_ERR "BUG? (%s)\n", __ASTRING__(expr));	\
3997c22f1aaa23370bf9ba2dd3abbccbed70dced216Takashi Iwai		dump_stack();						\
4007c22f1aaa23370bf9ba2dd3abbccbed70dced216Takashi Iwai		args;							\
4017c22f1aaa23370bf9ba2dd3abbccbed70dced216Takashi Iwai	}								\
4021da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds} while (0)
4037c22f1aaa23370bf9ba2dd3abbccbed70dced216Takashi Iwai
4047c22f1aaa23370bf9ba2dd3abbccbed70dced216Takashi Iwai#define snd_BUG() do {				\
4057c22f1aaa23370bf9ba2dd3abbccbed70dced216Takashi Iwai	snd_printk(KERN_ERR "BUG?\n");		\
4067c22f1aaa23370bf9ba2dd3abbccbed70dced216Takashi Iwai	dump_stack();				\
4071da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds} while (0)
4081da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
4095ef03460a6ffc1d3ee6b6f2abc6765d3e224cf89Takashi Iwai#define snd_BUG_ON(cond)	WARN((cond), "BUG? (%s)\n", __stringify(cond))
4105ef03460a6ffc1d3ee6b6f2abc6765d3e224cf89Takashi Iwai
4111da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#else /* !CONFIG_SND_DEBUG */
4121da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
4131da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define snd_printd(fmt, args...)	/* nothing */
4141da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define snd_assert(expr, args...)	(void)(expr)
4157c22f1aaa23370bf9ba2dd3abbccbed70dced216Takashi Iwai#define snd_BUG()			/* nothing */
4165ef03460a6ffc1d3ee6b6f2abc6765d3e224cf89Takashi Iwai#define snd_BUG_ON(cond)	({/*(void)(cond);*/ 0;})  /* always false */
4171da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
4181da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#endif /* CONFIG_SND_DEBUG */
4191da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
42062cf872a8eec1f11aacbec0ac3fe3698bfa9b403Takashi Iwai#ifdef CONFIG_SND_DEBUG_VERBOSE
4211da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/**
4221da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * snd_printdd - debug printk
4231da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * @format: format string
4241da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *
425edab938e63e463da86e4aa7b94628ce8f2b8a137Pavel Machek * Works like snd_printk() for debugging purposes.
42662cf872a8eec1f11aacbec0ac3fe3698bfa9b403Takashi Iwai * Ignored when CONFIG_SND_DEBUG_VERBOSE is not set.
4271da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */
4281da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define snd_printdd(format, args...) snd_printk(format, ##args)
4291da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#else
4301da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define snd_printdd(format, args...) /* nothing */
4311da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#endif
4321da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
4331da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
4341da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define SNDRV_OSS_VERSION         ((3<<16)|(8<<8)|(1<<4)|(0))	/* 3.8.1a */
4351da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
4361da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* for easier backward-porting */
4371da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#if defined(CONFIG_GAMEPORT) || defined(CONFIG_GAMEPORT_MODULE)
4381da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#ifndef gameport_set_dev_parent
4391da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define gameport_set_dev_parent(gp,xdev) ((gp)->dev.parent = (xdev))
4401da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define gameport_set_port_data(gp,r) ((gp)->port_data = (r))
4411da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define gameport_get_port_data(gp) (gp)->port_data
4421da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#endif
4431da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#endif
4441da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
445d9ea472c743ccd7344055cb118bc210befbd8007Takashi Iwai/* PCI quirk list helper */
446d9ea472c743ccd7344055cb118bc210befbd8007Takashi Iwaistruct snd_pci_quirk {
447d9ea472c743ccd7344055cb118bc210befbd8007Takashi Iwai	unsigned short subvendor;	/* PCI subvendor ID */
448d9ea472c743ccd7344055cb118bc210befbd8007Takashi Iwai	unsigned short subdevice;	/* PCI subdevice ID */
449d9ea472c743ccd7344055cb118bc210befbd8007Takashi Iwai	int value;			/* value */
45062cf872a8eec1f11aacbec0ac3fe3698bfa9b403Takashi Iwai#ifdef CONFIG_SND_DEBUG_VERBOSE
451d9ea472c743ccd7344055cb118bc210befbd8007Takashi Iwai	const char *name;		/* name of the device (optional) */
452d9ea472c743ccd7344055cb118bc210befbd8007Takashi Iwai#endif
453d9ea472c743ccd7344055cb118bc210befbd8007Takashi Iwai};
454d9ea472c743ccd7344055cb118bc210befbd8007Takashi Iwai
455d9ea472c743ccd7344055cb118bc210befbd8007Takashi Iwai#define _SND_PCI_QUIRK_ID(vend,dev) \
456d9ea472c743ccd7344055cb118bc210befbd8007Takashi Iwai	.subvendor = (vend), .subdevice = (dev)
457d9ea472c743ccd7344055cb118bc210befbd8007Takashi Iwai#define SND_PCI_QUIRK_ID(vend,dev) {_SND_PCI_QUIRK_ID(vend, dev)}
45862cf872a8eec1f11aacbec0ac3fe3698bfa9b403Takashi Iwai#ifdef CONFIG_SND_DEBUG_VERBOSE
459d9ea472c743ccd7344055cb118bc210befbd8007Takashi Iwai#define SND_PCI_QUIRK(vend,dev,xname,val) \
460d9ea472c743ccd7344055cb118bc210befbd8007Takashi Iwai	{_SND_PCI_QUIRK_ID(vend, dev), .value = (val), .name = (xname)}
461d9ea472c743ccd7344055cb118bc210befbd8007Takashi Iwai#else
462d9ea472c743ccd7344055cb118bc210befbd8007Takashi Iwai#define SND_PCI_QUIRK(vend,dev,xname,val) \
463d9ea472c743ccd7344055cb118bc210befbd8007Takashi Iwai	{_SND_PCI_QUIRK_ID(vend, dev), .value = (val)}
464d9ea472c743ccd7344055cb118bc210befbd8007Takashi Iwai#endif
465d9ea472c743ccd7344055cb118bc210befbd8007Takashi Iwai
466d9ea472c743ccd7344055cb118bc210befbd8007Takashi Iwaiconst struct snd_pci_quirk *
467d9ea472c743ccd7344055cb118bc210befbd8007Takashi Iwaisnd_pci_quirk_lookup(struct pci_dev *pci, const struct snd_pci_quirk *list);
468d9ea472c743ccd7344055cb118bc210befbd8007Takashi Iwai
469d9ea472c743ccd7344055cb118bc210befbd8007Takashi Iwai
4701da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#endif /* __SOUND_CORE_H */
471