Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Initialization routines |
| 3 | * Copyright (c) by Jaroslav Kysela <perex@suse.cz> |
| 4 | * |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; either version 2 of the License, or |
| 9 | * (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program; if not, write to the Free Software |
| 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 19 | * |
| 20 | */ |
| 21 | |
| 22 | #include <sound/driver.h> |
| 23 | #include <linux/init.h> |
| 24 | #include <linux/sched.h> |
| 25 | #include <linux/file.h> |
| 26 | #include <linux/slab.h> |
| 27 | #include <linux/time.h> |
| 28 | #include <linux/ctype.h> |
| 29 | #include <linux/pci.h> |
| 30 | #include <linux/pm.h> |
Russell King | d052d1b | 2005-10-29 19:07:23 +0100 | [diff] [blame] | 31 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | #include <sound/core.h> |
| 33 | #include <sound/control.h> |
| 34 | #include <sound/info.h> |
| 35 | |
| 36 | struct snd_shutdown_f_ops { |
| 37 | struct file_operations f_ops; |
| 38 | struct snd_shutdown_f_ops *next; |
| 39 | }; |
| 40 | |
Takashi Iwai | 6581f4e | 2006-05-17 17:14:51 +0200 | [diff] [blame] | 41 | static unsigned int snd_cards_lock; /* locked for registering/using */ |
| 42 | struct snd_card *snd_cards[SNDRV_CARDS]; |
Takashi Iwai | c0d3fb3 | 2006-04-28 15:13:39 +0200 | [diff] [blame] | 43 | EXPORT_SYMBOL(snd_cards); |
| 44 | |
Takashi Iwai | 746df94 | 2006-05-15 19:49:05 +0200 | [diff] [blame] | 45 | static DEFINE_MUTEX(snd_card_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | |
| 47 | #if defined(CONFIG_SND_MIXER_OSS) || defined(CONFIG_SND_MIXER_OSS_MODULE) |
Takashi Iwai | 512bbd6 | 2005-11-17 13:51:18 +0100 | [diff] [blame] | 48 | int (*snd_mixer_oss_notify_callback)(struct snd_card *card, int free_flag); |
Takashi Iwai | c0d3fb3 | 2006-04-28 15:13:39 +0200 | [diff] [blame] | 49 | EXPORT_SYMBOL(snd_mixer_oss_notify_callback); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | #endif |
| 51 | |
Takashi Iwai | e28563c | 2005-12-01 10:42:42 +0100 | [diff] [blame] | 52 | #ifdef CONFIG_PROC_FS |
Takashi Iwai | 512bbd6 | 2005-11-17 13:51:18 +0100 | [diff] [blame] | 53 | static void snd_card_id_read(struct snd_info_entry *entry, |
| 54 | struct snd_info_buffer *buffer) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 55 | { |
| 56 | snd_iprintf(buffer, "%s\n", entry->card->id); |
| 57 | } |
| 58 | |
Takashi Iwai | e28563c | 2005-12-01 10:42:42 +0100 | [diff] [blame] | 59 | static inline int init_info_for_card(struct snd_card *card) |
| 60 | { |
| 61 | int err; |
| 62 | struct snd_info_entry *entry; |
| 63 | |
| 64 | if ((err = snd_info_card_register(card)) < 0) { |
| 65 | snd_printd("unable to create card info\n"); |
| 66 | return err; |
| 67 | } |
| 68 | if ((entry = snd_info_create_card_entry(card, "id", card->proc_root)) == NULL) { |
| 69 | snd_printd("unable to create card entry\n"); |
| 70 | return err; |
| 71 | } |
Takashi Iwai | e28563c | 2005-12-01 10:42:42 +0100 | [diff] [blame] | 72 | entry->c.text.read = snd_card_id_read; |
| 73 | if (snd_info_register(entry) < 0) { |
| 74 | snd_info_free_entry(entry); |
| 75 | entry = NULL; |
| 76 | } |
| 77 | card->proc_id = entry; |
| 78 | return 0; |
| 79 | } |
| 80 | #else /* !CONFIG_PROC_FS */ |
| 81 | #define init_info_for_card(card) |
| 82 | #endif |
| 83 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 84 | /** |
| 85 | * snd_card_new - create and initialize a soundcard structure |
| 86 | * @idx: card index (address) [0 ... (SNDRV_CARDS-1)] |
| 87 | * @xid: card identification (ASCII string) |
| 88 | * @module: top level module for locking |
| 89 | * @extra_size: allocate this extra size after the main soundcard structure |
| 90 | * |
| 91 | * Creates and initializes a soundcard structure. |
| 92 | * |
Takashi Iwai | 512bbd6 | 2005-11-17 13:51:18 +0100 | [diff] [blame] | 93 | * Returns kmallocated snd_card structure. Creates the ALSA control interface |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 94 | * (which is blocked until snd_card_register function is called). |
| 95 | */ |
Takashi Iwai | 512bbd6 | 2005-11-17 13:51:18 +0100 | [diff] [blame] | 96 | struct snd_card *snd_card_new(int idx, const char *xid, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 97 | struct module *module, int extra_size) |
| 98 | { |
Takashi Iwai | 512bbd6 | 2005-11-17 13:51:18 +0100 | [diff] [blame] | 99 | struct snd_card *card; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 100 | int err; |
| 101 | |
| 102 | if (extra_size < 0) |
| 103 | extra_size = 0; |
Takashi Iwai | ca2c096 | 2005-09-09 14:20:23 +0200 | [diff] [blame] | 104 | card = kzalloc(sizeof(*card) + extra_size, GFP_KERNEL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 105 | if (card == NULL) |
| 106 | return NULL; |
| 107 | if (xid) { |
| 108 | if (!snd_info_check_reserved_words(xid)) |
| 109 | goto __error; |
| 110 | strlcpy(card->id, xid, sizeof(card->id)); |
| 111 | } |
| 112 | err = 0; |
Takashi Iwai | 746df94 | 2006-05-15 19:49:05 +0200 | [diff] [blame] | 113 | mutex_lock(&snd_card_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 114 | if (idx < 0) { |
| 115 | int idx2; |
| 116 | for (idx2 = 0; idx2 < SNDRV_CARDS; idx2++) |
| 117 | if (~snd_cards_lock & idx & 1<<idx2) { |
| 118 | idx = idx2; |
| 119 | if (idx >= snd_ecards_limit) |
| 120 | snd_ecards_limit = idx + 1; |
| 121 | break; |
| 122 | } |
| 123 | } else if (idx < snd_ecards_limit) { |
| 124 | if (snd_cards_lock & (1 << idx)) |
| 125 | err = -ENODEV; /* invalid */ |
| 126 | } else if (idx < SNDRV_CARDS) |
| 127 | snd_ecards_limit = idx + 1; /* increase the limit */ |
| 128 | else |
| 129 | err = -ENODEV; |
| 130 | if (idx < 0 || err < 0) { |
Takashi Iwai | 746df94 | 2006-05-15 19:49:05 +0200 | [diff] [blame] | 131 | mutex_unlock(&snd_card_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 132 | snd_printk(KERN_ERR "cannot find the slot for index %d (range 0-%i)\n", idx, snd_ecards_limit - 1); |
| 133 | goto __error; |
| 134 | } |
| 135 | snd_cards_lock |= 1 << idx; /* lock it */ |
Takashi Iwai | 746df94 | 2006-05-15 19:49:05 +0200 | [diff] [blame] | 136 | mutex_unlock(&snd_card_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 137 | card->number = idx; |
| 138 | card->module = module; |
| 139 | INIT_LIST_HEAD(&card->devices); |
| 140 | init_rwsem(&card->controls_rwsem); |
| 141 | rwlock_init(&card->ctl_files_rwlock); |
| 142 | INIT_LIST_HEAD(&card->controls); |
| 143 | INIT_LIST_HEAD(&card->ctl_files); |
| 144 | spin_lock_init(&card->files_lock); |
| 145 | init_waitqueue_head(&card->shutdown_sleep); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 146 | #ifdef CONFIG_PM |
Ingo Molnar | 1a60d4c | 2006-01-16 16:29:08 +0100 | [diff] [blame] | 147 | mutex_init(&card->power_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 148 | init_waitqueue_head(&card->power_sleep); |
| 149 | #endif |
| 150 | /* the control interface cannot be accessed from the user space until */ |
| 151 | /* snd_cards_bitmask and snd_cards are set with snd_card_register */ |
| 152 | if ((err = snd_ctl_create(card)) < 0) { |
| 153 | snd_printd("unable to register control minors\n"); |
| 154 | goto __error; |
| 155 | } |
| 156 | if ((err = snd_info_card_create(card)) < 0) { |
| 157 | snd_printd("unable to create card info\n"); |
| 158 | goto __error_ctl; |
| 159 | } |
| 160 | if (extra_size > 0) |
Takashi Iwai | 512bbd6 | 2005-11-17 13:51:18 +0100 | [diff] [blame] | 161 | card->private_data = (char *)card + sizeof(struct snd_card); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 162 | return card; |
| 163 | |
| 164 | __error_ctl: |
| 165 | snd_device_free_all(card, SNDRV_DEV_CMD_PRE); |
| 166 | __error: |
| 167 | kfree(card); |
| 168 | return NULL; |
| 169 | } |
| 170 | |
Takashi Iwai | c0d3fb3 | 2006-04-28 15:13:39 +0200 | [diff] [blame] | 171 | EXPORT_SYMBOL(snd_card_new); |
| 172 | |
Takashi Iwai | 746df94 | 2006-05-15 19:49:05 +0200 | [diff] [blame] | 173 | /* return non-zero if a card is already locked */ |
| 174 | int snd_card_locked(int card) |
| 175 | { |
| 176 | int locked; |
| 177 | |
| 178 | mutex_lock(&snd_card_mutex); |
| 179 | locked = snd_cards_lock & (1 << card); |
| 180 | mutex_unlock(&snd_card_mutex); |
| 181 | return locked; |
| 182 | } |
| 183 | |
Clemens Ladisch | b3b0abe | 2006-03-03 14:08:43 +0100 | [diff] [blame] | 184 | static loff_t snd_disconnect_llseek(struct file *file, loff_t offset, int orig) |
| 185 | { |
| 186 | return -ENODEV; |
| 187 | } |
| 188 | |
| 189 | static ssize_t snd_disconnect_read(struct file *file, char __user *buf, |
| 190 | size_t count, loff_t *offset) |
| 191 | { |
| 192 | return -ENODEV; |
| 193 | } |
| 194 | |
| 195 | static ssize_t snd_disconnect_write(struct file *file, const char __user *buf, |
| 196 | size_t count, loff_t *offset) |
| 197 | { |
| 198 | return -ENODEV; |
| 199 | } |
| 200 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 201 | static unsigned int snd_disconnect_poll(struct file * file, poll_table * wait) |
| 202 | { |
| 203 | return POLLERR | POLLNVAL; |
| 204 | } |
| 205 | |
Clemens Ladisch | b3b0abe | 2006-03-03 14:08:43 +0100 | [diff] [blame] | 206 | static long snd_disconnect_ioctl(struct file *file, |
| 207 | unsigned int cmd, unsigned long arg) |
| 208 | { |
| 209 | return -ENODEV; |
| 210 | } |
| 211 | |
| 212 | static int snd_disconnect_mmap(struct file *file, struct vm_area_struct *vma) |
| 213 | { |
| 214 | return -ENODEV; |
| 215 | } |
| 216 | |
| 217 | static int snd_disconnect_fasync(int fd, struct file *file, int on) |
| 218 | { |
| 219 | return -ENODEV; |
| 220 | } |
| 221 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 222 | /** |
| 223 | * snd_card_disconnect - disconnect all APIs from the file-operations (user space) |
| 224 | * @card: soundcard structure |
| 225 | * |
| 226 | * Disconnects all APIs from the file-operations (user space). |
| 227 | * |
| 228 | * Returns zero, otherwise a negative error code. |
| 229 | * |
| 230 | * Note: The current implementation replaces all active file->f_op with special |
| 231 | * dummy file operations (they do nothing except release). |
| 232 | */ |
Takashi Iwai | 512bbd6 | 2005-11-17 13:51:18 +0100 | [diff] [blame] | 233 | int snd_card_disconnect(struct snd_card *card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 234 | { |
| 235 | struct snd_monitor_file *mfile; |
| 236 | struct file *file; |
| 237 | struct snd_shutdown_f_ops *s_f_ops; |
Arjan van de Ven | 99ac48f | 2006-03-28 01:56:41 -0800 | [diff] [blame] | 238 | struct file_operations *f_ops; |
| 239 | const struct file_operations *old_f_ops; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 240 | int err; |
| 241 | |
| 242 | spin_lock(&card->files_lock); |
| 243 | if (card->shutdown) { |
| 244 | spin_unlock(&card->files_lock); |
| 245 | return 0; |
| 246 | } |
| 247 | card->shutdown = 1; |
| 248 | spin_unlock(&card->files_lock); |
| 249 | |
| 250 | /* phase 1: disable fops (user space) operations for ALSA API */ |
Takashi Iwai | 746df94 | 2006-05-15 19:49:05 +0200 | [diff] [blame] | 251 | mutex_lock(&snd_card_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 252 | snd_cards[card->number] = NULL; |
Takashi Iwai | 746df94 | 2006-05-15 19:49:05 +0200 | [diff] [blame] | 253 | mutex_unlock(&snd_card_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 254 | |
| 255 | /* phase 2: replace file->f_op with special dummy operations */ |
| 256 | |
| 257 | spin_lock(&card->files_lock); |
| 258 | mfile = card->files; |
| 259 | while (mfile) { |
| 260 | file = mfile->file; |
| 261 | |
| 262 | /* it's critical part, use endless loop */ |
| 263 | /* we have no room to fail */ |
| 264 | s_f_ops = kmalloc(sizeof(struct snd_shutdown_f_ops), GFP_ATOMIC); |
| 265 | if (s_f_ops == NULL) |
| 266 | panic("Atomic allocation failed for snd_shutdown_f_ops!"); |
| 267 | |
| 268 | f_ops = &s_f_ops->f_ops; |
| 269 | |
| 270 | memset(f_ops, 0, sizeof(*f_ops)); |
| 271 | f_ops->owner = file->f_op->owner; |
| 272 | f_ops->release = file->f_op->release; |
Clemens Ladisch | b3b0abe | 2006-03-03 14:08:43 +0100 | [diff] [blame] | 273 | f_ops->llseek = snd_disconnect_llseek; |
| 274 | f_ops->read = snd_disconnect_read; |
| 275 | f_ops->write = snd_disconnect_write; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 276 | f_ops->poll = snd_disconnect_poll; |
Clemens Ladisch | b3b0abe | 2006-03-03 14:08:43 +0100 | [diff] [blame] | 277 | f_ops->unlocked_ioctl = snd_disconnect_ioctl; |
| 278 | #ifdef CONFIG_COMPAT |
| 279 | f_ops->compat_ioctl = snd_disconnect_ioctl; |
| 280 | #endif |
| 281 | f_ops->mmap = snd_disconnect_mmap; |
| 282 | f_ops->fasync = snd_disconnect_fasync; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 283 | |
| 284 | s_f_ops->next = card->s_f_ops; |
| 285 | card->s_f_ops = s_f_ops; |
| 286 | |
| 287 | f_ops = fops_get(f_ops); |
| 288 | |
| 289 | old_f_ops = file->f_op; |
| 290 | file->f_op = f_ops; /* must be atomic */ |
| 291 | fops_put(old_f_ops); |
| 292 | |
| 293 | mfile = mfile->next; |
| 294 | } |
| 295 | spin_unlock(&card->files_lock); |
| 296 | |
| 297 | /* phase 3: notify all connected devices about disconnection */ |
| 298 | /* at this point, they cannot respond to any calls except release() */ |
| 299 | |
| 300 | #if defined(CONFIG_SND_MIXER_OSS) || defined(CONFIG_SND_MIXER_OSS_MODULE) |
| 301 | if (snd_mixer_oss_notify_callback) |
| 302 | snd_mixer_oss_notify_callback(card, SND_MIXER_OSS_NOTIFY_DISCONNECT); |
| 303 | #endif |
| 304 | |
| 305 | /* notify all devices that we are disconnected */ |
| 306 | err = snd_device_disconnect_all(card); |
| 307 | if (err < 0) |
| 308 | snd_printk(KERN_ERR "not all devices for card %i can be disconnected\n", card->number); |
| 309 | |
Takashi Iwai | 746d4a0 | 2006-06-23 14:37:59 +0200 | [diff] [blame] | 310 | snd_info_card_disconnect(card); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 311 | return 0; |
| 312 | } |
| 313 | |
Takashi Iwai | c0d3fb3 | 2006-04-28 15:13:39 +0200 | [diff] [blame] | 314 | EXPORT_SYMBOL(snd_card_disconnect); |
| 315 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 316 | /** |
| 317 | * snd_card_free - frees given soundcard structure |
| 318 | * @card: soundcard structure |
| 319 | * |
| 320 | * This function releases the soundcard structure and the all assigned |
| 321 | * devices automatically. That is, you don't have to release the devices |
| 322 | * by yourself. |
| 323 | * |
| 324 | * Returns zero. Frees all associated devices and frees the control |
| 325 | * interface associated to given soundcard. |
| 326 | */ |
Takashi Iwai | c461482 | 2006-06-23 14:38:23 +0200 | [diff] [blame] | 327 | static int snd_card_do_free(struct snd_card *card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 328 | { |
| 329 | struct snd_shutdown_f_ops *s_f_ops; |
| 330 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 331 | #if defined(CONFIG_SND_MIXER_OSS) || defined(CONFIG_SND_MIXER_OSS_MODULE) |
| 332 | if (snd_mixer_oss_notify_callback) |
| 333 | snd_mixer_oss_notify_callback(card, SND_MIXER_OSS_NOTIFY_FREE); |
| 334 | #endif |
| 335 | if (snd_device_free_all(card, SNDRV_DEV_CMD_PRE) < 0) { |
| 336 | snd_printk(KERN_ERR "unable to free all devices (pre)\n"); |
| 337 | /* Fatal, but this situation should never occur */ |
| 338 | } |
| 339 | if (snd_device_free_all(card, SNDRV_DEV_CMD_NORMAL) < 0) { |
| 340 | snd_printk(KERN_ERR "unable to free all devices (normal)\n"); |
| 341 | /* Fatal, but this situation should never occur */ |
| 342 | } |
| 343 | if (snd_device_free_all(card, SNDRV_DEV_CMD_POST) < 0) { |
| 344 | snd_printk(KERN_ERR "unable to free all devices (post)\n"); |
| 345 | /* Fatal, but this situation should never occur */ |
| 346 | } |
| 347 | if (card->private_free) |
| 348 | card->private_free(card); |
Takashi Iwai | 746d4a0 | 2006-06-23 14:37:59 +0200 | [diff] [blame] | 349 | snd_info_free_entry(card->proc_id); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 350 | if (snd_info_card_free(card) < 0) { |
| 351 | snd_printk(KERN_WARNING "unable to free card info\n"); |
| 352 | /* Not fatal error */ |
| 353 | } |
| 354 | while (card->s_f_ops) { |
| 355 | s_f_ops = card->s_f_ops; |
| 356 | card->s_f_ops = s_f_ops->next; |
| 357 | kfree(s_f_ops); |
| 358 | } |
Takashi Iwai | c461482 | 2006-06-23 14:38:23 +0200 | [diff] [blame] | 359 | kfree(card); |
| 360 | return 0; |
| 361 | } |
| 362 | |
| 363 | static int snd_card_free_prepare(struct snd_card *card) |
| 364 | { |
| 365 | if (card == NULL) |
| 366 | return -EINVAL; |
| 367 | (void) snd_card_disconnect(card); |
Takashi Iwai | 746df94 | 2006-05-15 19:49:05 +0200 | [diff] [blame] | 368 | mutex_lock(&snd_card_mutex); |
Takashi Iwai | c461482 | 2006-06-23 14:38:23 +0200 | [diff] [blame] | 369 | snd_cards[card->number] = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 370 | snd_cards_lock &= ~(1 << card->number); |
Takashi Iwai | 746df94 | 2006-05-15 19:49:05 +0200 | [diff] [blame] | 371 | mutex_unlock(&snd_card_mutex); |
Takashi Iwai | c461482 | 2006-06-23 14:38:23 +0200 | [diff] [blame] | 372 | #ifdef CONFIG_PM |
| 373 | wake_up(&card->power_sleep); |
| 374 | #endif |
| 375 | return 0; |
| 376 | } |
| 377 | |
| 378 | int snd_card_free_when_closed(struct snd_card *card) |
| 379 | { |
| 380 | int free_now = 0; |
| 381 | int ret = snd_card_free_prepare(card); |
| 382 | if (ret) |
| 383 | return ret; |
| 384 | |
| 385 | spin_lock(&card->files_lock); |
| 386 | if (card->files == NULL) |
| 387 | free_now = 1; |
| 388 | else |
| 389 | card->free_on_last_close = 1; |
| 390 | spin_unlock(&card->files_lock); |
| 391 | |
| 392 | if (free_now) |
| 393 | snd_card_do_free(card); |
| 394 | return 0; |
| 395 | } |
| 396 | |
| 397 | EXPORT_SYMBOL(snd_card_free_when_closed); |
| 398 | |
| 399 | int snd_card_free(struct snd_card *card) |
| 400 | { |
| 401 | int ret = snd_card_free_prepare(card); |
| 402 | if (ret) |
| 403 | return ret; |
| 404 | |
| 405 | /* wait, until all devices are ready for the free operation */ |
| 406 | wait_event(card->shutdown_sleep, card->files == NULL); |
| 407 | snd_card_do_free(card); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 408 | return 0; |
| 409 | } |
| 410 | |
Takashi Iwai | c0d3fb3 | 2006-04-28 15:13:39 +0200 | [diff] [blame] | 411 | EXPORT_SYMBOL(snd_card_free); |
| 412 | |
Takashi Iwai | 512bbd6 | 2005-11-17 13:51:18 +0100 | [diff] [blame] | 413 | static void choose_default_id(struct snd_card *card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 414 | { |
Clemens Ladisch | d001544 | 2005-11-20 14:09:05 +0100 | [diff] [blame] | 415 | int i, len, idx_flag = 0, loops = SNDRV_CARDS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 416 | char *id, *spos; |
| 417 | |
| 418 | id = spos = card->shortname; |
| 419 | while (*id != '\0') { |
| 420 | if (*id == ' ') |
| 421 | spos = id + 1; |
| 422 | id++; |
| 423 | } |
| 424 | id = card->id; |
| 425 | while (*spos != '\0' && !isalnum(*spos)) |
| 426 | spos++; |
| 427 | if (isdigit(*spos)) |
| 428 | *id++ = isalpha(card->shortname[0]) ? card->shortname[0] : 'D'; |
| 429 | while (*spos != '\0' && (size_t)(id - card->id) < sizeof(card->id) - 1) { |
| 430 | if (isalnum(*spos)) |
| 431 | *id++ = *spos; |
| 432 | spos++; |
| 433 | } |
| 434 | *id = '\0'; |
| 435 | |
| 436 | id = card->id; |
| 437 | |
| 438 | if (*id == '\0') |
| 439 | strcpy(id, "default"); |
| 440 | |
| 441 | while (1) { |
| 442 | if (loops-- == 0) { |
| 443 | snd_printk(KERN_ERR "unable to choose default card id (%s)\n", id); |
| 444 | strcpy(card->id, card->proc_root->name); |
| 445 | return; |
| 446 | } |
| 447 | if (!snd_info_check_reserved_words(id)) |
| 448 | goto __change; |
| 449 | for (i = 0; i < snd_ecards_limit; i++) { |
| 450 | if (snd_cards[i] && !strcmp(snd_cards[i]->id, id)) |
| 451 | goto __change; |
| 452 | } |
| 453 | break; |
| 454 | |
| 455 | __change: |
| 456 | len = strlen(id); |
Clemens Ladisch | d001544 | 2005-11-20 14:09:05 +0100 | [diff] [blame] | 457 | if (idx_flag) { |
| 458 | if (id[len-1] != '9') |
| 459 | id[len-1]++; |
| 460 | else |
| 461 | id[len-1] = 'A'; |
| 462 | } else if ((size_t)len <= sizeof(card->id) - 3) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 463 | strcat(id, "_1"); |
| 464 | idx_flag++; |
| 465 | } else { |
| 466 | spos = id + len - 2; |
| 467 | if ((size_t)len <= sizeof(card->id) - 2) |
| 468 | spos++; |
| 469 | *spos++ = '_'; |
| 470 | *spos++ = '1'; |
| 471 | *spos++ = '\0'; |
| 472 | idx_flag++; |
| 473 | } |
| 474 | } |
| 475 | } |
| 476 | |
| 477 | /** |
| 478 | * snd_card_register - register the soundcard |
| 479 | * @card: soundcard structure |
| 480 | * |
| 481 | * This function registers all the devices assigned to the soundcard. |
| 482 | * Until calling this, the ALSA control interface is blocked from the |
| 483 | * external accesses. Thus, you should call this function at the end |
| 484 | * of the initialization of the card. |
| 485 | * |
| 486 | * Returns zero otherwise a negative error code if the registrain failed. |
| 487 | */ |
Takashi Iwai | 512bbd6 | 2005-11-17 13:51:18 +0100 | [diff] [blame] | 488 | int snd_card_register(struct snd_card *card) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 489 | { |
| 490 | int err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 491 | |
Takashi Iwai | 7c22f1a | 2005-10-10 11:46:31 +0200 | [diff] [blame] | 492 | snd_assert(card != NULL, return -EINVAL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 493 | if ((err = snd_device_register_all(card)) < 0) |
| 494 | return err; |
Takashi Iwai | 746df94 | 2006-05-15 19:49:05 +0200 | [diff] [blame] | 495 | mutex_lock(&snd_card_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 496 | if (snd_cards[card->number]) { |
| 497 | /* already registered */ |
Takashi Iwai | 746df94 | 2006-05-15 19:49:05 +0200 | [diff] [blame] | 498 | mutex_unlock(&snd_card_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 499 | return 0; |
| 500 | } |
| 501 | if (card->id[0] == '\0') |
| 502 | choose_default_id(card); |
| 503 | snd_cards[card->number] = card; |
Takashi Iwai | 746df94 | 2006-05-15 19:49:05 +0200 | [diff] [blame] | 504 | mutex_unlock(&snd_card_mutex); |
Takashi Iwai | e28563c | 2005-12-01 10:42:42 +0100 | [diff] [blame] | 505 | init_info_for_card(card); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 506 | #if defined(CONFIG_SND_MIXER_OSS) || defined(CONFIG_SND_MIXER_OSS_MODULE) |
| 507 | if (snd_mixer_oss_notify_callback) |
| 508 | snd_mixer_oss_notify_callback(card, SND_MIXER_OSS_NOTIFY_REGISTER); |
| 509 | #endif |
| 510 | return 0; |
| 511 | } |
| 512 | |
Takashi Iwai | c0d3fb3 | 2006-04-28 15:13:39 +0200 | [diff] [blame] | 513 | EXPORT_SYMBOL(snd_card_register); |
| 514 | |
Takashi Iwai | e28563c | 2005-12-01 10:42:42 +0100 | [diff] [blame] | 515 | #ifdef CONFIG_PROC_FS |
Takashi Iwai | 6581f4e | 2006-05-17 17:14:51 +0200 | [diff] [blame] | 516 | static struct snd_info_entry *snd_card_info_entry; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 517 | |
Takashi Iwai | a381a7a | 2005-11-17 15:55:49 +0100 | [diff] [blame] | 518 | static void snd_card_info_read(struct snd_info_entry *entry, |
| 519 | struct snd_info_buffer *buffer) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 520 | { |
| 521 | int idx, count; |
Takashi Iwai | 512bbd6 | 2005-11-17 13:51:18 +0100 | [diff] [blame] | 522 | struct snd_card *card; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 523 | |
| 524 | for (idx = count = 0; idx < SNDRV_CARDS; idx++) { |
Takashi Iwai | 746df94 | 2006-05-15 19:49:05 +0200 | [diff] [blame] | 525 | mutex_lock(&snd_card_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 526 | if ((card = snd_cards[idx]) != NULL) { |
| 527 | count++; |
Clemens Ladisch | d001544 | 2005-11-20 14:09:05 +0100 | [diff] [blame] | 528 | snd_iprintf(buffer, "%2i [%-15s]: %s - %s\n", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 529 | idx, |
| 530 | card->id, |
| 531 | card->driver, |
| 532 | card->shortname); |
Clemens Ladisch | d001544 | 2005-11-20 14:09:05 +0100 | [diff] [blame] | 533 | snd_iprintf(buffer, " %s\n", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 534 | card->longname); |
| 535 | } |
Takashi Iwai | 746df94 | 2006-05-15 19:49:05 +0200 | [diff] [blame] | 536 | mutex_unlock(&snd_card_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 537 | } |
| 538 | if (!count) |
| 539 | snd_iprintf(buffer, "--- no soundcards ---\n"); |
| 540 | } |
| 541 | |
Takashi Iwai | e28563c | 2005-12-01 10:42:42 +0100 | [diff] [blame] | 542 | #ifdef CONFIG_SND_OSSEMUL |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 543 | |
Takashi Iwai | 512bbd6 | 2005-11-17 13:51:18 +0100 | [diff] [blame] | 544 | void snd_card_info_read_oss(struct snd_info_buffer *buffer) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 545 | { |
| 546 | int idx, count; |
Takashi Iwai | 512bbd6 | 2005-11-17 13:51:18 +0100 | [diff] [blame] | 547 | struct snd_card *card; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 548 | |
| 549 | for (idx = count = 0; idx < SNDRV_CARDS; idx++) { |
Takashi Iwai | 746df94 | 2006-05-15 19:49:05 +0200 | [diff] [blame] | 550 | mutex_lock(&snd_card_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 551 | if ((card = snd_cards[idx]) != NULL) { |
| 552 | count++; |
| 553 | snd_iprintf(buffer, "%s\n", card->longname); |
| 554 | } |
Takashi Iwai | 746df94 | 2006-05-15 19:49:05 +0200 | [diff] [blame] | 555 | mutex_unlock(&snd_card_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 556 | } |
| 557 | if (!count) { |
| 558 | snd_iprintf(buffer, "--- no soundcards ---\n"); |
| 559 | } |
| 560 | } |
| 561 | |
| 562 | #endif |
| 563 | |
| 564 | #ifdef MODULE |
Takashi Iwai | 512bbd6 | 2005-11-17 13:51:18 +0100 | [diff] [blame] | 565 | static struct snd_info_entry *snd_card_module_info_entry; |
| 566 | static void snd_card_module_info_read(struct snd_info_entry *entry, |
| 567 | struct snd_info_buffer *buffer) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 568 | { |
| 569 | int idx; |
Takashi Iwai | 512bbd6 | 2005-11-17 13:51:18 +0100 | [diff] [blame] | 570 | struct snd_card *card; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 571 | |
| 572 | for (idx = 0; idx < SNDRV_CARDS; idx++) { |
Takashi Iwai | 746df94 | 2006-05-15 19:49:05 +0200 | [diff] [blame] | 573 | mutex_lock(&snd_card_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 574 | if ((card = snd_cards[idx]) != NULL) |
Clemens Ladisch | d001544 | 2005-11-20 14:09:05 +0100 | [diff] [blame] | 575 | snd_iprintf(buffer, "%2i %s\n", |
| 576 | idx, card->module->name); |
Takashi Iwai | 746df94 | 2006-05-15 19:49:05 +0200 | [diff] [blame] | 577 | mutex_unlock(&snd_card_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 578 | } |
| 579 | } |
| 580 | #endif |
| 581 | |
| 582 | int __init snd_card_info_init(void) |
| 583 | { |
Takashi Iwai | 512bbd6 | 2005-11-17 13:51:18 +0100 | [diff] [blame] | 584 | struct snd_info_entry *entry; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 585 | |
| 586 | entry = snd_info_create_module_entry(THIS_MODULE, "cards", NULL); |
Takashi Iwai | 7c22f1a | 2005-10-10 11:46:31 +0200 | [diff] [blame] | 587 | if (! entry) |
| 588 | return -ENOMEM; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 589 | entry->c.text.read = snd_card_info_read; |
| 590 | if (snd_info_register(entry) < 0) { |
| 591 | snd_info_free_entry(entry); |
| 592 | return -ENOMEM; |
| 593 | } |
| 594 | snd_card_info_entry = entry; |
| 595 | |
| 596 | #ifdef MODULE |
| 597 | entry = snd_info_create_module_entry(THIS_MODULE, "modules", NULL); |
| 598 | if (entry) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 599 | entry->c.text.read = snd_card_module_info_read; |
| 600 | if (snd_info_register(entry) < 0) |
| 601 | snd_info_free_entry(entry); |
| 602 | else |
| 603 | snd_card_module_info_entry = entry; |
| 604 | } |
| 605 | #endif |
| 606 | |
| 607 | return 0; |
| 608 | } |
| 609 | |
| 610 | int __exit snd_card_info_done(void) |
| 611 | { |
Takashi Iwai | 746d4a0 | 2006-06-23 14:37:59 +0200 | [diff] [blame] | 612 | snd_info_free_entry(snd_card_info_entry); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 613 | #ifdef MODULE |
Takashi Iwai | 746d4a0 | 2006-06-23 14:37:59 +0200 | [diff] [blame] | 614 | snd_info_free_entry(snd_card_module_info_entry); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 615 | #endif |
| 616 | return 0; |
| 617 | } |
| 618 | |
Takashi Iwai | e28563c | 2005-12-01 10:42:42 +0100 | [diff] [blame] | 619 | #endif /* CONFIG_PROC_FS */ |
| 620 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 621 | /** |
| 622 | * snd_component_add - add a component string |
| 623 | * @card: soundcard structure |
| 624 | * @component: the component id string |
| 625 | * |
| 626 | * This function adds the component id string to the supported list. |
| 627 | * The component can be referred from the alsa-lib. |
| 628 | * |
| 629 | * Returns zero otherwise a negative error code. |
| 630 | */ |
| 631 | |
Takashi Iwai | 512bbd6 | 2005-11-17 13:51:18 +0100 | [diff] [blame] | 632 | int snd_component_add(struct snd_card *card, const char *component) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 633 | { |
| 634 | char *ptr; |
| 635 | int len = strlen(component); |
| 636 | |
| 637 | ptr = strstr(card->components, component); |
| 638 | if (ptr != NULL) { |
| 639 | if (ptr[len] == '\0' || ptr[len] == ' ') /* already there */ |
| 640 | return 1; |
| 641 | } |
| 642 | if (strlen(card->components) + 1 + len + 1 > sizeof(card->components)) { |
| 643 | snd_BUG(); |
| 644 | return -ENOMEM; |
| 645 | } |
| 646 | if (card->components[0] != '\0') |
| 647 | strcat(card->components, " "); |
| 648 | strcat(card->components, component); |
| 649 | return 0; |
| 650 | } |
| 651 | |
Takashi Iwai | c0d3fb3 | 2006-04-28 15:13:39 +0200 | [diff] [blame] | 652 | EXPORT_SYMBOL(snd_component_add); |
| 653 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 654 | /** |
| 655 | * snd_card_file_add - add the file to the file list of the card |
| 656 | * @card: soundcard structure |
| 657 | * @file: file pointer |
| 658 | * |
| 659 | * This function adds the file to the file linked-list of the card. |
| 660 | * This linked-list is used to keep tracking the connection state, |
| 661 | * and to avoid the release of busy resources by hotplug. |
| 662 | * |
| 663 | * Returns zero or a negative error code. |
| 664 | */ |
Takashi Iwai | 512bbd6 | 2005-11-17 13:51:18 +0100 | [diff] [blame] | 665 | int snd_card_file_add(struct snd_card *card, struct file *file) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 666 | { |
| 667 | struct snd_monitor_file *mfile; |
| 668 | |
| 669 | mfile = kmalloc(sizeof(*mfile), GFP_KERNEL); |
| 670 | if (mfile == NULL) |
| 671 | return -ENOMEM; |
| 672 | mfile->file = file; |
| 673 | mfile->next = NULL; |
| 674 | spin_lock(&card->files_lock); |
| 675 | if (card->shutdown) { |
| 676 | spin_unlock(&card->files_lock); |
| 677 | kfree(mfile); |
| 678 | return -ENODEV; |
| 679 | } |
| 680 | mfile->next = card->files; |
| 681 | card->files = mfile; |
| 682 | spin_unlock(&card->files_lock); |
| 683 | return 0; |
| 684 | } |
| 685 | |
Takashi Iwai | c0d3fb3 | 2006-04-28 15:13:39 +0200 | [diff] [blame] | 686 | EXPORT_SYMBOL(snd_card_file_add); |
| 687 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 688 | /** |
| 689 | * snd_card_file_remove - remove the file from the file list |
| 690 | * @card: soundcard structure |
| 691 | * @file: file pointer |
| 692 | * |
| 693 | * This function removes the file formerly added to the card via |
| 694 | * snd_card_file_add() function. |
Takashi Iwai | 2b29b13 | 2006-06-23 14:38:26 +0200 | [diff] [blame] | 695 | * If all files are removed and snd_card_free_when_closed() was |
| 696 | * called beforehand, it processes the pending release of |
| 697 | * resources. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 698 | * |
| 699 | * Returns zero or a negative error code. |
| 700 | */ |
Takashi Iwai | 512bbd6 | 2005-11-17 13:51:18 +0100 | [diff] [blame] | 701 | int snd_card_file_remove(struct snd_card *card, struct file *file) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 702 | { |
| 703 | struct snd_monitor_file *mfile, *pfile = NULL; |
Takashi Iwai | c461482 | 2006-06-23 14:38:23 +0200 | [diff] [blame] | 704 | int last_close = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 705 | |
| 706 | spin_lock(&card->files_lock); |
| 707 | mfile = card->files; |
| 708 | while (mfile) { |
| 709 | if (mfile->file == file) { |
| 710 | if (pfile) |
| 711 | pfile->next = mfile->next; |
| 712 | else |
| 713 | card->files = mfile->next; |
| 714 | break; |
| 715 | } |
| 716 | pfile = mfile; |
| 717 | mfile = mfile->next; |
| 718 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 719 | if (card->files == NULL) |
Takashi Iwai | c461482 | 2006-06-23 14:38:23 +0200 | [diff] [blame] | 720 | last_close = 1; |
| 721 | spin_unlock(&card->files_lock); |
| 722 | if (last_close) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 723 | wake_up(&card->shutdown_sleep); |
Takashi Iwai | c461482 | 2006-06-23 14:38:23 +0200 | [diff] [blame] | 724 | if (card->free_on_last_close) |
| 725 | snd_card_do_free(card); |
| 726 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 727 | if (!mfile) { |
| 728 | snd_printk(KERN_ERR "ALSA card file remove problem (%p)\n", file); |
| 729 | return -ENOENT; |
| 730 | } |
| 731 | kfree(mfile); |
| 732 | return 0; |
| 733 | } |
| 734 | |
Takashi Iwai | c0d3fb3 | 2006-04-28 15:13:39 +0200 | [diff] [blame] | 735 | EXPORT_SYMBOL(snd_card_file_remove); |
| 736 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 737 | #ifdef CONFIG_PM |
| 738 | /** |
| 739 | * snd_power_wait - wait until the power-state is changed. |
| 740 | * @card: soundcard structure |
| 741 | * @power_state: expected power state |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 742 | * |
| 743 | * Waits until the power-state is changed. |
| 744 | * |
| 745 | * Note: the power lock must be active before call. |
| 746 | */ |
Takashi Iwai | cbac4b0 | 2006-03-27 12:38:07 +0200 | [diff] [blame] | 747 | int snd_power_wait(struct snd_card *card, unsigned int power_state) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 748 | { |
| 749 | wait_queue_t wait; |
| 750 | int result = 0; |
| 751 | |
| 752 | /* fastpath */ |
| 753 | if (snd_power_get_state(card) == power_state) |
| 754 | return 0; |
| 755 | init_waitqueue_entry(&wait, current); |
| 756 | add_wait_queue(&card->power_sleep, &wait); |
| 757 | while (1) { |
| 758 | if (card->shutdown) { |
| 759 | result = -ENODEV; |
| 760 | break; |
| 761 | } |
| 762 | if (snd_power_get_state(card) == power_state) |
| 763 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 764 | set_current_state(TASK_UNINTERRUPTIBLE); |
| 765 | snd_power_unlock(card); |
| 766 | schedule_timeout(30 * HZ); |
| 767 | snd_power_lock(card); |
| 768 | } |
| 769 | remove_wait_queue(&card->power_sleep, &wait); |
| 770 | return result; |
| 771 | } |
| 772 | |
Takashi Iwai | c0d3fb3 | 2006-04-28 15:13:39 +0200 | [diff] [blame] | 773 | EXPORT_SYMBOL(snd_power_wait); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 774 | #endif /* CONFIG_PM */ |