2 * OSS emulation layer for the mixer interface
3 * Copyright (c) by Jaroslav Kysela <perex@suse.cz>
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.
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.
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
22 #include <sound/driver.h>
23 #include <linux/init.h>
24 #include <linux/slab.h>
25 #include <linux/time.h>
26 #include <sound/core.h>
27 #include <sound/minors.h>
28 #include <sound/control.h>
29 #include <sound/info.h>
30 #include <sound/mixer_oss.h>
31 #include <linux/soundcard.h>
33 #define OSS_ALSAEMULVER _SIOR ('M', 249, int)
35 MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>");
36 MODULE_DESCRIPTION("Mixer OSS emulation for ALSA.");
37 MODULE_LICENSE("GPL");
38 MODULE_ALIAS_SNDRV_MINOR(SNDRV_MINOR_OSS_MIXER);
40 static int snd_mixer_oss_open(struct inode *inode, struct file *file)
42 int cardnum = SNDRV_MINOR_OSS_CARD(iminor(inode));
44 snd_mixer_oss_file_t *fmixer;
47 if ((card = snd_cards[cardnum]) == NULL)
49 if (card->mixer_oss == NULL)
51 err = snd_card_file_add(card, file);
54 fmixer = (snd_mixer_oss_file_t *)snd_kcalloc(sizeof(*fmixer), GFP_KERNEL);
56 snd_card_file_remove(card, file);
60 fmixer->mixer = card->mixer_oss;
61 file->private_data = fmixer;
62 if (!try_module_get(card->module)) {
64 snd_card_file_remove(card, file);
70 static int snd_mixer_oss_release(struct inode *inode, struct file *file)
72 snd_mixer_oss_file_t *fmixer;
74 if (file->private_data) {
75 fmixer = (snd_mixer_oss_file_t *) file->private_data;
76 module_put(fmixer->card->module);
77 snd_card_file_remove(fmixer->card, file);
83 static int snd_mixer_oss_info(snd_mixer_oss_file_t *fmixer,
86 snd_card_t *card = fmixer->card;
87 snd_mixer_oss_t *mixer = fmixer->mixer;
88 struct mixer_info info;
90 memset(&info, 0, sizeof(info));
91 strlcpy(info.id, mixer && mixer->id[0] ? mixer->id : card->driver, sizeof(info.id));
92 strlcpy(info.name, mixer && mixer->name[0] ? mixer->name : card->mixername, sizeof(info.name));
93 info.modify_counter = card->mixer_oss_change_count;
94 if (copy_to_user(_info, &info, sizeof(info)))
99 static int snd_mixer_oss_info_obsolete(snd_mixer_oss_file_t *fmixer,
100 _old_mixer_info *_info)
102 snd_card_t *card = fmixer->card;
103 snd_mixer_oss_t *mixer = fmixer->mixer;
104 _old_mixer_info info;
106 memset(&info, 0, sizeof(info));
107 strlcpy(info.id, mixer && mixer->id[0] ? mixer->id : card->driver, sizeof(info.id));
108 strlcpy(info.name, mixer && mixer->name[0] ? mixer->name : card->mixername, sizeof(info.name));
109 if (copy_to_user(_info, &info, sizeof(info)))
114 static int snd_mixer_oss_caps(snd_mixer_oss_file_t *fmixer)
116 snd_mixer_oss_t *mixer = fmixer->mixer;
121 if (mixer->get_recsrc && mixer->put_recsrc)
122 result |= SOUND_CAP_EXCL_INPUT;
126 static int snd_mixer_oss_devmask(snd_mixer_oss_file_t *fmixer)
128 snd_mixer_oss_t *mixer = fmixer->mixer;
129 snd_mixer_oss_slot_t *pslot;
134 for (chn = 0; chn < 31; chn++) {
135 pslot = &mixer->slots[chn];
136 if (pslot->put_volume || pslot->put_recsrc)
142 static int snd_mixer_oss_stereodevs(snd_mixer_oss_file_t *fmixer)
144 snd_mixer_oss_t *mixer = fmixer->mixer;
145 snd_mixer_oss_slot_t *pslot;
150 for (chn = 0; chn < 31; chn++) {
151 pslot = &mixer->slots[chn];
152 if (pslot->put_volume && pslot->stereo)
158 static int snd_mixer_oss_recmask(snd_mixer_oss_file_t *fmixer)
160 snd_mixer_oss_t *mixer = fmixer->mixer;
165 if (mixer->put_recsrc && mixer->get_recsrc) { /* exclusive */
166 result = mixer->mask_recsrc;
168 snd_mixer_oss_slot_t *pslot;
170 for (chn = 0; chn < 31; chn++) {
171 pslot = &mixer->slots[chn];
172 if (pslot->put_recsrc)
179 static int snd_mixer_oss_get_recsrc(snd_mixer_oss_file_t *fmixer)
181 snd_mixer_oss_t *mixer = fmixer->mixer;
186 if (mixer->put_recsrc && mixer->get_recsrc) { /* exclusive */
188 if ((err = mixer->get_recsrc(fmixer, &result)) < 0)
190 result = 1 << result;
192 snd_mixer_oss_slot_t *pslot;
194 for (chn = 0; chn < 31; chn++) {
195 pslot = &mixer->slots[chn];
196 if (pslot->get_recsrc) {
198 pslot->get_recsrc(fmixer, pslot, &active);
204 return mixer->oss_recsrc = result;
207 static int snd_mixer_oss_set_recsrc(snd_mixer_oss_file_t *fmixer, int recsrc)
209 snd_mixer_oss_t *mixer = fmixer->mixer;
210 snd_mixer_oss_slot_t *pslot;
216 if (mixer->get_recsrc && mixer->put_recsrc) { /* exclusive input */
217 if (recsrc & ~mixer->oss_recsrc)
218 recsrc &= ~mixer->oss_recsrc;
219 mixer->put_recsrc(fmixer, ffz(~recsrc));
220 mixer->get_recsrc(fmixer, &result);
221 result = 1 << result;
223 for (chn = 0; chn < 31; chn++) {
224 pslot = &mixer->slots[chn];
225 if (pslot->put_recsrc) {
226 active = (recsrc & (1 << chn)) ? 1 : 0;
227 pslot->put_recsrc(fmixer, pslot, active);
231 for (chn = 0; chn < 31; chn++) {
232 pslot = &mixer->slots[chn];
233 if (pslot->get_recsrc) {
235 pslot->get_recsrc(fmixer, pslot, &active);
244 static int snd_mixer_oss_get_volume(snd_mixer_oss_file_t *fmixer, int slot)
246 snd_mixer_oss_t *mixer = fmixer->mixer;
247 snd_mixer_oss_slot_t *pslot;
248 int result = 0, left, right;
250 if (mixer == NULL || slot > 30)
252 pslot = &mixer->slots[slot];
253 left = pslot->volume[0];
254 right = pslot->volume[1];
255 if (pslot->get_volume)
256 result = pslot->get_volume(fmixer, pslot, &left, &right);
259 snd_assert(left >= 0 && left <= 100, return -EIO);
260 snd_assert(right >= 0 && right <= 100, return -EIO);
262 pslot->volume[0] = left;
263 pslot->volume[1] = right;
264 result = (left & 0xff) | ((right & 0xff) << 8);
269 static int snd_mixer_oss_set_volume(snd_mixer_oss_file_t *fmixer,
270 int slot, int volume)
272 snd_mixer_oss_t *mixer = fmixer->mixer;
273 snd_mixer_oss_slot_t *pslot;
274 int result = 0, left = volume & 0xff, right = (volume >> 8) & 0xff;
276 if (mixer == NULL || slot > 30)
278 pslot = &mixer->slots[slot];
285 if (pslot->put_volume)
286 result = pslot->put_volume(fmixer, pslot, left, right);
289 pslot->volume[0] = left;
290 pslot->volume[1] = right;
291 return (left & 0xff) | ((right & 0xff) << 8);
294 static int snd_mixer_oss_ioctl1(snd_mixer_oss_file_t *fmixer, unsigned int cmd, unsigned long arg)
298 snd_assert(fmixer != NULL, return -ENXIO);
299 if (((cmd >> 8) & 0xff) == 'M') {
301 case SOUND_MIXER_INFO:
302 return snd_mixer_oss_info(fmixer, (mixer_info *)arg);
303 case SOUND_OLD_MIXER_INFO:
304 return snd_mixer_oss_info_obsolete(fmixer, (_old_mixer_info *)arg);
305 case SOUND_MIXER_WRITE_RECSRC:
306 if (get_user(tmp, (int *)arg))
308 tmp = snd_mixer_oss_set_recsrc(fmixer, tmp);
311 return put_user(tmp, (int *)arg);
313 return put_user(SNDRV_OSS_VERSION, (int *) arg);
314 case OSS_ALSAEMULVER:
315 return put_user(1, (int *) arg);
316 case SOUND_MIXER_READ_DEVMASK:
317 tmp = snd_mixer_oss_devmask(fmixer);
320 return put_user(tmp, (int *)arg);
321 case SOUND_MIXER_READ_STEREODEVS:
322 tmp = snd_mixer_oss_stereodevs(fmixer);
325 return put_user(tmp, (int *)arg);
326 case SOUND_MIXER_READ_RECMASK:
327 tmp = snd_mixer_oss_recmask(fmixer);
330 return put_user(tmp, (int *)arg);
331 case SOUND_MIXER_READ_CAPS:
332 tmp = snd_mixer_oss_caps(fmixer);
335 return put_user(tmp, (int *)arg);
336 case SOUND_MIXER_READ_RECSRC:
337 tmp = snd_mixer_oss_get_recsrc(fmixer);
340 return put_user(tmp, (int *)arg);
344 if (get_user(tmp, (int *)arg))
346 tmp = snd_mixer_oss_set_volume(fmixer, cmd & 0xff, tmp);
349 return put_user(tmp, (int *)arg);
350 } else if (cmd & SIOC_OUT) {
351 tmp = snd_mixer_oss_get_volume(fmixer, cmd & 0xff);
354 return put_user(tmp, (int *)arg);
359 int snd_mixer_oss_ioctl(struct inode *inode, struct file *file,
360 unsigned int cmd, unsigned long arg)
362 return snd_mixer_oss_ioctl1((snd_mixer_oss_file_t *) file->private_data, cmd, arg);
365 int snd_mixer_oss_ioctl_card(snd_card_t *card, unsigned int cmd, unsigned long arg)
367 snd_mixer_oss_file_t fmixer;
369 snd_assert(card != NULL, return -ENXIO);
370 if (card->mixer_oss == NULL)
372 memset(&fmixer, 0, sizeof(fmixer));
374 fmixer.mixer = card->mixer_oss;
375 return snd_mixer_oss_ioctl1(&fmixer, cmd, arg);
382 static struct file_operations snd_mixer_oss_f_ops =
384 .owner = THIS_MODULE,
385 .open = snd_mixer_oss_open,
386 .release = snd_mixer_oss_release,
387 .ioctl = snd_mixer_oss_ioctl,
390 static snd_minor_t snd_mixer_oss_reg =
393 .f_ops = &snd_mixer_oss_f_ops,
400 static long snd_mixer_oss_conv(long val, long omin, long omax, long nmin, long nmax)
402 long orange = omax - omin, nrange = nmax - nmin;
406 return ((nrange * (val - omin)) + (orange / 2)) / orange + nmin;
409 /* convert from alsa native to oss values (0-100) */
410 static long snd_mixer_oss_conv1(long val, long min, long max, int *old)
412 if (val == snd_mixer_oss_conv(*old, 0, 100, min, max))
414 return snd_mixer_oss_conv(val, min, max, 0, 100);
417 /* convert from oss to alsa native values */
418 static long snd_mixer_oss_conv2(long val, long min, long max)
420 return snd_mixer_oss_conv(val, 0, 100, min, max);
424 static void snd_mixer_oss_recsrce_set(snd_card_t *card, int slot)
426 snd_mixer_oss_t *mixer = card->mixer_oss;
428 mixer->mask_recsrc |= 1 << slot;
431 static int snd_mixer_oss_recsrce_get(snd_card_t *card, int slot)
433 snd_mixer_oss_t *mixer = card->mixer_oss;
434 if (mixer && (mixer->mask_recsrc & (1 << slot)))
440 #define SNDRV_MIXER_OSS_SIGNATURE 0x65999250
442 #define SNDRV_MIXER_OSS_ITEM_GLOBAL 0
443 #define SNDRV_MIXER_OSS_ITEM_GSWITCH 1
444 #define SNDRV_MIXER_OSS_ITEM_GROUTE 2
445 #define SNDRV_MIXER_OSS_ITEM_GVOLUME 3
446 #define SNDRV_MIXER_OSS_ITEM_PSWITCH 4
447 #define SNDRV_MIXER_OSS_ITEM_PROUTE 5
448 #define SNDRV_MIXER_OSS_ITEM_PVOLUME 6
449 #define SNDRV_MIXER_OSS_ITEM_CSWITCH 7
450 #define SNDRV_MIXER_OSS_ITEM_CROUTE 8
451 #define SNDRV_MIXER_OSS_ITEM_CVOLUME 9
452 #define SNDRV_MIXER_OSS_ITEM_CAPTURE 10
454 #define SNDRV_MIXER_OSS_ITEM_COUNT 11
456 #define SNDRV_MIXER_OSS_PRESENT_GLOBAL (1<<0)
457 #define SNDRV_MIXER_OSS_PRESENT_GSWITCH (1<<1)
458 #define SNDRV_MIXER_OSS_PRESENT_GROUTE (1<<2)
459 #define SNDRV_MIXER_OSS_PRESENT_GVOLUME (1<<3)
460 #define SNDRV_MIXER_OSS_PRESENT_PSWITCH (1<<4)
461 #define SNDRV_MIXER_OSS_PRESENT_PROUTE (1<<5)
462 #define SNDRV_MIXER_OSS_PRESENT_PVOLUME (1<<6)
463 #define SNDRV_MIXER_OSS_PRESENT_CSWITCH (1<<7)
464 #define SNDRV_MIXER_OSS_PRESENT_CROUTE (1<<8)
465 #define SNDRV_MIXER_OSS_PRESENT_CVOLUME (1<<9)
466 #define SNDRV_MIXER_OSS_PRESENT_CAPTURE (1<<10)
469 unsigned int signature;
470 unsigned int present;
471 unsigned int channels;
472 unsigned int numid[SNDRV_MIXER_OSS_ITEM_COUNT];
473 unsigned int capture_item;
474 struct snd_mixer_oss_assign_table *assigned;
475 unsigned int allocated: 1;
478 #define ID_UNKNOWN ((unsigned int)-1)
480 static snd_kcontrol_t *snd_mixer_oss_test_id(snd_mixer_oss_t *mixer, const char *name, int index)
482 snd_card_t * card = mixer->card;
483 snd_ctl_elem_id_t id;
485 memset(&id, 0, sizeof(id));
486 id.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
487 strcpy(id.name, name);
489 return snd_ctl_find_id(card, &id);
492 static void snd_mixer_oss_get_volume1_vol(snd_mixer_oss_file_t *fmixer,
493 snd_mixer_oss_slot_t *pslot,
495 int *left, int *right)
497 snd_ctl_elem_info_t *uinfo;
498 snd_ctl_elem_value_t *uctl;
499 snd_kcontrol_t *kctl;
500 snd_card_t *card = fmixer->card;
502 if (numid == ID_UNKNOWN)
504 down_read(&card->controls_rwsem);
505 if ((kctl = snd_ctl_find_numid(card, numid)) == NULL) {
506 up_read(&card->controls_rwsem);
509 uinfo = snd_kcalloc(sizeof(*uinfo), GFP_KERNEL);
510 uctl = snd_kcalloc(sizeof(*uctl), GFP_KERNEL);
511 if (uinfo == NULL || uctl == NULL)
513 snd_runtime_check(!kctl->info(kctl, uinfo), goto __unalloc);
514 snd_runtime_check(!kctl->get(kctl, uctl), goto __unalloc);
515 snd_runtime_check(uinfo->type != SNDRV_CTL_ELEM_TYPE_BOOLEAN || uinfo->value.integer.min != 0 || uinfo->value.integer.max != 1, return);
516 *left = snd_mixer_oss_conv1(uctl->value.integer.value[0], uinfo->value.integer.min, uinfo->value.integer.max, &pslot->volume[0]);
517 if (uinfo->count > 1)
518 *right = snd_mixer_oss_conv1(uctl->value.integer.value[1], uinfo->value.integer.min, uinfo->value.integer.max, &pslot->volume[1]);
520 up_read(&card->controls_rwsem);
527 static void snd_mixer_oss_get_volume1_sw(snd_mixer_oss_file_t *fmixer,
528 snd_mixer_oss_slot_t *pslot,
530 int *left, int *right,
533 snd_ctl_elem_info_t *uinfo;
534 snd_ctl_elem_value_t *uctl;
535 snd_kcontrol_t *kctl;
536 snd_card_t *card = fmixer->card;
538 if (numid == ID_UNKNOWN)
540 down_read(&card->controls_rwsem);
541 if ((kctl = snd_ctl_find_numid(card, numid)) == NULL) {
542 up_read(&card->controls_rwsem);
545 uinfo = snd_kcalloc(sizeof(*uinfo), GFP_KERNEL);
546 uctl = snd_kcalloc(sizeof(*uctl), GFP_KERNEL);
547 if (uinfo == NULL || uctl == NULL)
549 snd_runtime_check(!kctl->info(kctl, uinfo), goto __unalloc);
550 snd_runtime_check(!kctl->get(kctl, uctl), goto __unalloc);
551 if (!uctl->value.integer.value[0]) {
553 if (uinfo->count == 1)
556 if (uinfo->count > 1 && !uctl->value.integer.value[route ? 3 : 1])
559 up_read(&card->controls_rwsem);
566 static int snd_mixer_oss_get_volume1(snd_mixer_oss_file_t *fmixer,
567 snd_mixer_oss_slot_t *pslot,
568 int *left, int *right)
570 struct slot *slot = (struct slot *)pslot->private_data;
572 *left = *right = 100;
573 if (slot->present & SNDRV_MIXER_OSS_PRESENT_PVOLUME) {
574 snd_mixer_oss_get_volume1_vol(fmixer, pslot, slot->numid[SNDRV_MIXER_OSS_ITEM_PVOLUME], left, right);
575 } else if (slot->present & SNDRV_MIXER_OSS_PRESENT_GVOLUME) {
576 snd_mixer_oss_get_volume1_vol(fmixer, pslot, slot->numid[SNDRV_MIXER_OSS_ITEM_GVOLUME], left, right);
577 } else if (slot->present & SNDRV_MIXER_OSS_PRESENT_GLOBAL) {
578 snd_mixer_oss_get_volume1_vol(fmixer, pslot, slot->numid[SNDRV_MIXER_OSS_ITEM_GLOBAL], left, right);
580 if (slot->present & SNDRV_MIXER_OSS_PRESENT_PSWITCH) {
581 snd_mixer_oss_get_volume1_sw(fmixer, pslot, slot->numid[SNDRV_MIXER_OSS_ITEM_PSWITCH], left, right, 0);
582 } else if (slot->present & SNDRV_MIXER_OSS_PRESENT_GSWITCH) {
583 snd_mixer_oss_get_volume1_sw(fmixer, pslot, slot->numid[SNDRV_MIXER_OSS_ITEM_GSWITCH], left, right, 0);
584 } else if (slot->present & SNDRV_MIXER_OSS_PRESENT_PROUTE) {
585 snd_mixer_oss_get_volume1_sw(fmixer, pslot, slot->numid[SNDRV_MIXER_OSS_ITEM_PROUTE], left, right, 1);
586 } else if (slot->present & SNDRV_MIXER_OSS_PRESENT_GROUTE) {
587 snd_mixer_oss_get_volume1_sw(fmixer, pslot, slot->numid[SNDRV_MIXER_OSS_ITEM_GROUTE], left, right, 1);
592 static void snd_mixer_oss_put_volume1_vol(snd_mixer_oss_file_t *fmixer,
593 snd_mixer_oss_slot_t *pslot,
597 snd_ctl_elem_info_t *uinfo;
598 snd_ctl_elem_value_t *uctl;
599 snd_kcontrol_t *kctl;
600 snd_card_t *card = fmixer->card;
603 if (numid == ID_UNKNOWN)
605 down_read(&card->controls_rwsem);
606 if ((kctl = snd_ctl_find_numid(card, numid)) == NULL)
608 uinfo = snd_kcalloc(sizeof(*uinfo), GFP_KERNEL);
609 uctl = snd_kcalloc(sizeof(*uctl), GFP_KERNEL);
610 if (uinfo == NULL || uctl == NULL)
612 snd_runtime_check(!kctl->info(kctl, uinfo), goto __unalloc);
613 snd_runtime_check(uinfo->type != SNDRV_CTL_ELEM_TYPE_BOOLEAN || uinfo->value.integer.min != 0 || uinfo->value.integer.max != 1, return);
614 uctl->value.integer.value[0] = snd_mixer_oss_conv2(left, uinfo->value.integer.min, uinfo->value.integer.max);
615 if (uinfo->count > 1)
616 uctl->value.integer.value[1] = snd_mixer_oss_conv2(right, uinfo->value.integer.min, uinfo->value.integer.max);
617 snd_runtime_check((res = kctl->put(kctl, uctl)) >= 0, goto __unalloc);
619 snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_VALUE, &kctl->id);
621 up_read(&card->controls_rwsem);
628 static void snd_mixer_oss_put_volume1_sw(snd_mixer_oss_file_t *fmixer,
629 snd_mixer_oss_slot_t *pslot,
634 snd_ctl_elem_info_t *uinfo;
635 snd_ctl_elem_value_t *uctl;
636 snd_kcontrol_t *kctl;
637 snd_card_t *card = fmixer->card;
640 if (numid == ID_UNKNOWN)
642 down_read(&card->controls_rwsem);
643 if ((kctl = snd_ctl_find_numid(card, numid)) == NULL) {
644 up_read(&fmixer->card->controls_rwsem);
647 uinfo = snd_kcalloc(sizeof(*uinfo), GFP_KERNEL);
648 uctl = snd_kcalloc(sizeof(*uctl), GFP_KERNEL);
649 if (uinfo == NULL || uctl == NULL)
651 snd_runtime_check(!kctl->info(kctl, uinfo), goto __unalloc);
652 if (uinfo->count > 1) {
653 uctl->value.integer.value[0] = left > 0 ? 1 : 0;
654 uctl->value.integer.value[route ? 3 : 1] = right > 0 ? 1 : 0;
656 uctl->value.integer.value[1] =
657 uctl->value.integer.value[2] = 0;
660 uctl->value.integer.value[0] = (left > 0 || right > 0) ? 1 : 0;
662 snd_runtime_check((res = kctl->put(kctl, uctl)) >= 0, goto __unalloc);
664 snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_VALUE, &kctl->id);
666 up_read(&card->controls_rwsem);
673 static int snd_mixer_oss_put_volume1(snd_mixer_oss_file_t *fmixer,
674 snd_mixer_oss_slot_t *pslot,
677 struct slot *slot = (struct slot *)pslot->private_data;
679 if (slot->present & SNDRV_MIXER_OSS_PRESENT_PVOLUME) {
680 snd_mixer_oss_put_volume1_vol(fmixer, pslot, slot->numid[SNDRV_MIXER_OSS_ITEM_PVOLUME], left, right);
681 if (slot->present & SNDRV_MIXER_OSS_PRESENT_CVOLUME)
682 snd_mixer_oss_put_volume1_vol(fmixer, pslot, slot->numid[SNDRV_MIXER_OSS_ITEM_CVOLUME], left, right);
683 } else if (slot->present & SNDRV_MIXER_OSS_PRESENT_GVOLUME) {
684 snd_mixer_oss_put_volume1_vol(fmixer, pslot, slot->numid[SNDRV_MIXER_OSS_ITEM_GVOLUME], left, right);
685 } else if (slot->present & SNDRV_MIXER_OSS_PRESENT_GLOBAL) {
686 snd_mixer_oss_put_volume1_vol(fmixer, pslot, slot->numid[SNDRV_MIXER_OSS_ITEM_GLOBAL], left, right);
689 if (slot->present & SNDRV_MIXER_OSS_PRESENT_PSWITCH)
690 snd_mixer_oss_put_volume1_sw(fmixer, pslot, slot->numid[SNDRV_MIXER_OSS_ITEM_PSWITCH], left, right, 0);
691 if (slot->present & SNDRV_MIXER_OSS_PRESENT_GSWITCH)
692 snd_mixer_oss_put_volume1_sw(fmixer, pslot, slot->numid[SNDRV_MIXER_OSS_ITEM_GSWITCH], left, right, 0);
693 if (slot->present & SNDRV_MIXER_OSS_PRESENT_PROUTE)
694 snd_mixer_oss_put_volume1_sw(fmixer, pslot, slot->numid[SNDRV_MIXER_OSS_ITEM_PROUTE], left, right, 1);
695 if (slot->present & SNDRV_MIXER_OSS_PRESENT_GROUTE)
696 snd_mixer_oss_put_volume1_sw(fmixer, pslot, slot->numid[SNDRV_MIXER_OSS_ITEM_GROUTE], left, right, 1);
698 if (slot->present & SNDRV_MIXER_OSS_PRESENT_PSWITCH) {
699 snd_mixer_oss_put_volume1_sw(fmixer, pslot, slot->numid[SNDRV_MIXER_OSS_ITEM_PSWITCH], left, right, 0);
700 } else if (slot->present & SNDRV_MIXER_OSS_PRESENT_GSWITCH) {
701 snd_mixer_oss_put_volume1_sw(fmixer, pslot, slot->numid[SNDRV_MIXER_OSS_ITEM_GSWITCH], left, right, 0);
702 } else if (slot->present & SNDRV_MIXER_OSS_PRESENT_PROUTE) {
703 snd_mixer_oss_put_volume1_sw(fmixer, pslot, slot->numid[SNDRV_MIXER_OSS_ITEM_PROUTE], left, right, 1);
704 } else if (slot->present & SNDRV_MIXER_OSS_PRESENT_GROUTE) {
705 snd_mixer_oss_put_volume1_sw(fmixer, pslot, slot->numid[SNDRV_MIXER_OSS_ITEM_GROUTE], left, right, 1);
711 static int snd_mixer_oss_get_recsrc1_sw(snd_mixer_oss_file_t *fmixer,
712 snd_mixer_oss_slot_t *pslot,
715 struct slot *slot = (struct slot *)pslot->private_data;
719 snd_mixer_oss_get_volume1_sw(fmixer, pslot, slot->numid[SNDRV_MIXER_OSS_ITEM_CSWITCH], &left, &right, 0);
720 *active = (left || right) ? 1 : 0;
724 static int snd_mixer_oss_get_recsrc1_route(snd_mixer_oss_file_t *fmixer,
725 snd_mixer_oss_slot_t *pslot,
728 struct slot *slot = (struct slot *)pslot->private_data;
732 snd_mixer_oss_get_volume1_sw(fmixer, pslot, slot->numid[SNDRV_MIXER_OSS_ITEM_CROUTE], &left, &right, 1);
733 *active = (left || right) ? 1 : 0;
737 static int snd_mixer_oss_put_recsrc1_sw(snd_mixer_oss_file_t *fmixer,
738 snd_mixer_oss_slot_t *pslot,
741 struct slot *slot = (struct slot *)pslot->private_data;
743 snd_mixer_oss_put_volume1_sw(fmixer, pslot, slot->numid[SNDRV_MIXER_OSS_ITEM_CSWITCH], active, active, 0);
747 static int snd_mixer_oss_put_recsrc1_route(snd_mixer_oss_file_t *fmixer,
748 snd_mixer_oss_slot_t *pslot,
751 struct slot *slot = (struct slot *)pslot->private_data;
753 snd_mixer_oss_put_volume1_sw(fmixer, pslot, slot->numid[SNDRV_MIXER_OSS_ITEM_CROUTE], active, active, 1);
757 static int snd_mixer_oss_get_recsrc2(snd_mixer_oss_file_t *fmixer, unsigned int *active_index)
759 snd_card_t *card = fmixer->card;
760 snd_mixer_oss_t *mixer = fmixer->mixer;
761 snd_kcontrol_t *kctl;
762 snd_mixer_oss_slot_t *pslot;
764 snd_ctl_elem_info_t *uinfo;
765 snd_ctl_elem_value_t *uctl;
768 uinfo = snd_kcalloc(sizeof(*uinfo), GFP_KERNEL);
769 uctl = snd_kcalloc(sizeof(*uctl), GFP_KERNEL);
770 if (uinfo == NULL || uctl == NULL) {
774 down_read(&card->controls_rwsem);
775 kctl = snd_mixer_oss_test_id(mixer, "Capture Source", 0);
776 snd_runtime_check(kctl != NULL, err = -ENOENT; goto __unlock);
777 snd_runtime_check(!(err = kctl->info(kctl, uinfo)), goto __unlock);
778 snd_runtime_check(!(err = kctl->get(kctl, uctl)), goto __unlock);
779 for (idx = 0; idx < 32; idx++) {
780 if (!(mixer->mask_recsrc & (1 << idx)))
782 pslot = &mixer->slots[idx];
783 slot = (struct slot *)pslot->private_data;
784 if (slot->signature != SNDRV_MIXER_OSS_SIGNATURE)
786 if (!(slot->present & SNDRV_MIXER_OSS_PRESENT_CAPTURE))
788 if (slot->capture_item == uctl->value.enumerated.item[0]) {
795 up_read(&card->controls_rwsem);
803 static int snd_mixer_oss_put_recsrc2(snd_mixer_oss_file_t *fmixer, unsigned int active_index)
805 snd_card_t *card = fmixer->card;
806 snd_mixer_oss_t *mixer = fmixer->mixer;
807 snd_kcontrol_t *kctl;
808 snd_mixer_oss_slot_t *pslot;
809 struct slot *slot = NULL;
810 snd_ctl_elem_info_t *uinfo;
811 snd_ctl_elem_value_t *uctl;
815 uinfo = snd_kcalloc(sizeof(*uinfo), GFP_KERNEL);
816 uctl = snd_kcalloc(sizeof(*uctl), GFP_KERNEL);
817 if (uinfo == NULL || uctl == NULL) {
821 down_read(&card->controls_rwsem);
822 kctl = snd_mixer_oss_test_id(mixer, "Capture Source", 0);
823 snd_runtime_check(kctl != NULL, err = -ENOENT; goto __unlock);
824 snd_runtime_check(!(err = kctl->info(kctl, uinfo)), goto __unlock);
825 for (idx = 0; idx < 32; idx++) {
826 if (!(mixer->mask_recsrc & (1 << idx)))
828 pslot = &mixer->slots[idx];
829 slot = (struct slot *)pslot->private_data;
830 if (slot->signature != SNDRV_MIXER_OSS_SIGNATURE)
832 if (!(slot->present & SNDRV_MIXER_OSS_PRESENT_CAPTURE))
834 if (idx == active_index)
838 snd_runtime_check(slot != NULL, goto __unlock);
839 for (idx = 0; idx < uinfo->count; idx++)
840 uctl->value.enumerated.item[idx] = slot->capture_item;
841 snd_runtime_check((err = kctl->put(kctl, uctl)) >= 0, );
843 snd_ctl_notify(fmixer->card, SNDRV_CTL_EVENT_MASK_VALUE, &kctl->id);
846 up_read(&card->controls_rwsem);
854 struct snd_mixer_oss_assign_table {
860 static int snd_mixer_oss_build_test(snd_mixer_oss_t *mixer, struct slot *slot, const char *name, int index, int item)
862 snd_ctl_elem_info_t info;
863 snd_kcontrol_t *kcontrol;
864 snd_card_t *card = mixer->card;
867 down_read(&card->controls_rwsem);
868 kcontrol = snd_mixer_oss_test_id(mixer, name, index);
869 if (kcontrol == NULL) {
870 up_read(&card->controls_rwsem);
873 if ((err = kcontrol->info(kcontrol, &info)) < 0) {
874 up_read(&card->controls_rwsem);
877 slot->numid[item] = kcontrol->id.numid;
878 up_read(&card->controls_rwsem);
879 if (info.count > slot->channels)
880 slot->channels = info.count;
881 slot->present |= 1 << item;
885 static void snd_mixer_oss_slot_free(snd_mixer_oss_slot_t *chn)
887 struct slot *p = (struct slot *)chn->private_data;
889 if (p->allocated && p->assigned) {
890 kfree(p->assigned->name);
897 static void mixer_slot_clear(snd_mixer_oss_slot_t *rslot)
899 int idx = rslot->number; /* remember this */
900 if (rslot->private_free)
901 rslot->private_free(rslot);
902 memset(rslot, 0, sizeof(*rslot));
907 * build an OSS mixer element.
908 * ptr_allocated means the entry is dynamically allocated (change via proc file).
909 * when replace_old = 1, the old entry is replaced with the new one.
911 static int snd_mixer_oss_build_input(snd_mixer_oss_t *mixer, struct snd_mixer_oss_assign_table *ptr, int ptr_allocated, int replace_old)
915 snd_kcontrol_t *kctl;
916 snd_mixer_oss_slot_t *rslot;
919 /* check if already assigned */
920 if (mixer->slots[ptr->oss_id].get_volume && ! replace_old)
923 memset(&slot, 0, sizeof(slot));
924 memset(slot.numid, 0xff, sizeof(slot.numid)); /* ID_UNKNOWN */
925 if (snd_mixer_oss_build_test(mixer, &slot, ptr->name, ptr->index,
926 SNDRV_MIXER_OSS_ITEM_GLOBAL))
928 sprintf(str, "%s Switch", ptr->name);
929 if (snd_mixer_oss_build_test(mixer, &slot, str, ptr->index,
930 SNDRV_MIXER_OSS_ITEM_GSWITCH))
932 sprintf(str, "%s Route", ptr->name);
933 if (snd_mixer_oss_build_test(mixer, &slot, str, ptr->index,
934 SNDRV_MIXER_OSS_ITEM_GROUTE))
936 sprintf(str, "%s Volume", ptr->name);
937 if (snd_mixer_oss_build_test(mixer, &slot, str, ptr->index,
938 SNDRV_MIXER_OSS_ITEM_GVOLUME))
940 sprintf(str, "%s Playback Switch", ptr->name);
941 if (snd_mixer_oss_build_test(mixer, &slot, str, ptr->index,
942 SNDRV_MIXER_OSS_ITEM_PSWITCH))
944 sprintf(str, "%s Playback Route", ptr->name);
945 if (snd_mixer_oss_build_test(mixer, &slot, str, ptr->index,
946 SNDRV_MIXER_OSS_ITEM_PROUTE))
948 sprintf(str, "%s Playback Volume", ptr->name);
949 if (snd_mixer_oss_build_test(mixer, &slot, str, ptr->index,
950 SNDRV_MIXER_OSS_ITEM_PVOLUME))
952 sprintf(str, "%s Capture Switch", ptr->name);
953 if (snd_mixer_oss_build_test(mixer, &slot, str, ptr->index,
954 SNDRV_MIXER_OSS_ITEM_CSWITCH))
956 sprintf(str, "%s Capture Route", ptr->name);
957 if (snd_mixer_oss_build_test(mixer, &slot, str, ptr->index,
958 SNDRV_MIXER_OSS_ITEM_CROUTE))
960 sprintf(str, "%s Capture Volume", ptr->name);
961 if (snd_mixer_oss_build_test(mixer, &slot, str, ptr->index,
962 SNDRV_MIXER_OSS_ITEM_CVOLUME))
964 down_read(&mixer->card->controls_rwsem);
965 if (ptr->index == 0 && (kctl = snd_mixer_oss_test_id(mixer, "Capture Source", 0)) != NULL) {
966 snd_ctl_elem_info_t uinfo;
968 memset(&uinfo, 0, sizeof(uinfo));
969 if (kctl->info(kctl, &uinfo))
971 strcpy(str, ptr->name);
972 if (!strcmp(str, "Master"))
974 if (!strcmp(str, "Master Mono"))
975 strcpy(str, "Mix Mono");
976 slot.capture_item = 0;
977 if (!strcmp(uinfo.value.enumerated.name, str)) {
978 slot.present |= SNDRV_MIXER_OSS_PRESENT_CAPTURE;
980 for (slot.capture_item = 1; slot.capture_item < uinfo.value.enumerated.items; slot.capture_item++) {
981 uinfo.value.enumerated.item = slot.capture_item;
982 if (kctl->info(kctl, &uinfo)) {
983 up_read(&mixer->card->controls_rwsem);
986 if (!strcmp(uinfo.value.enumerated.name, str)) {
987 slot.present |= SNDRV_MIXER_OSS_PRESENT_CAPTURE;
993 up_read(&mixer->card->controls_rwsem);
994 if (slot.present != 0) {
995 pslot = (struct slot *)kmalloc(sizeof(slot), GFP_KERNEL);
996 snd_runtime_check(pslot != NULL, return -ENOMEM);
998 pslot->signature = SNDRV_MIXER_OSS_SIGNATURE;
999 pslot->assigned = ptr;
1000 pslot->allocated = ptr_allocated;
1001 rslot = &mixer->slots[ptr->oss_id];
1002 mixer_slot_clear(rslot);
1003 rslot->stereo = slot.channels > 1 ? 1 : 0;
1004 rslot->get_volume = snd_mixer_oss_get_volume1;
1005 rslot->put_volume = snd_mixer_oss_put_volume1;
1006 /* note: ES18xx have both Capture Source and XX Capture Volume !!! */
1007 if (slot.present & SNDRV_MIXER_OSS_PRESENT_CSWITCH) {
1008 rslot->get_recsrc = snd_mixer_oss_get_recsrc1_sw;
1009 rslot->put_recsrc = snd_mixer_oss_put_recsrc1_sw;
1010 } else if (slot.present & SNDRV_MIXER_OSS_PRESENT_CROUTE) {
1011 rslot->get_recsrc = snd_mixer_oss_get_recsrc1_route;
1012 rslot->put_recsrc = snd_mixer_oss_put_recsrc1_route;
1013 } else if (slot.present & SNDRV_MIXER_OSS_PRESENT_CAPTURE) {
1014 mixer->mask_recsrc |= 1 << ptr->oss_id;
1016 rslot->private_data = pslot;
1017 rslot->private_free = snd_mixer_oss_slot_free;
1025 #define MIXER_VOL(name) [SOUND_MIXER_##name] = #name
1026 static char *oss_mixer_names[SNDRV_OSS_MAX_MIXERS] = {
1044 MIXER_VOL(DIGITAL1),
1045 MIXER_VOL(DIGITAL2),
1046 MIXER_VOL(DIGITAL3),
1048 MIXER_VOL(PHONEOUT),
1058 static void snd_mixer_oss_proc_read(snd_info_entry_t *entry,
1059 snd_info_buffer_t * buffer)
1061 snd_mixer_oss_t *mixer = snd_magic_cast(snd_mixer_oss_t, entry->private_data, return);
1064 down(&mixer->reg_mutex);
1065 for (i = 0; i < SNDRV_OSS_MAX_MIXERS; i++) {
1068 if (! oss_mixer_names[i])
1070 p = (struct slot *)mixer->slots[i].private_data;
1071 snd_iprintf(buffer, "%s ", oss_mixer_names[i]);
1072 if (p && p->assigned)
1073 snd_iprintf(buffer, "\"%s\" %d\n",
1075 p->assigned->index);
1077 snd_iprintf(buffer, "\"\" 0\n");
1079 up(&mixer->reg_mutex);
1082 static void snd_mixer_oss_proc_write(snd_info_entry_t *entry,
1083 snd_info_buffer_t * buffer)
1085 snd_mixer_oss_t *mixer = snd_magic_cast(snd_mixer_oss_t, entry->private_data, return);
1086 char line[128], str[32], idxstr[16], *cptr;
1088 struct snd_mixer_oss_assign_table *tbl;
1091 while (!snd_info_get_line(buffer, line, sizeof(line))) {
1092 cptr = snd_info_get_str(str, line, sizeof(str));
1093 for (ch = 0; ch < SNDRV_OSS_MAX_MIXERS; ch++)
1094 if (oss_mixer_names[ch] && strcmp(oss_mixer_names[ch], str) == 0)
1096 if (ch >= SNDRV_OSS_MAX_MIXERS) {
1097 snd_printk(KERN_ERR "mixer_oss: invalid OSS volume '%s'\n", str);
1100 cptr = snd_info_get_str(str, cptr, sizeof(str));
1102 /* remove the entry */
1103 down(&mixer->reg_mutex);
1104 mixer_slot_clear(&mixer->slots[ch]);
1105 up(&mixer->reg_mutex);
1108 snd_info_get_str(idxstr, cptr, sizeof(idxstr));
1109 idx = simple_strtoul(idxstr, NULL, 10);
1110 if (idx >= 0x4000) { /* too big */
1111 snd_printk(KERN_ERR "mixer_oss: invalid index %d\n", idx);
1114 down(&mixer->reg_mutex);
1115 slot = (struct slot *)mixer->slots[ch].private_data;
1116 if (slot && slot->assigned &&
1117 slot->assigned->index == idx && ! strcmp(slot->assigned->name, str))
1120 tbl = kmalloc(sizeof(*tbl), GFP_KERNEL);
1122 snd_printk(KERN_ERR "mixer_oss: no memory\n");
1126 tbl->name = snd_kmalloc_strdup(str, GFP_KERNEL);
1132 if (snd_mixer_oss_build_input(mixer, tbl, 1, 1) <= 0) {
1137 up(&mixer->reg_mutex);
1141 static void snd_mixer_oss_proc_init(snd_mixer_oss_t *mixer)
1143 snd_info_entry_t *entry;
1145 entry = snd_info_create_card_entry(mixer->card, "oss_mixer",
1146 mixer->card->proc_root);
1149 entry->content = SNDRV_INFO_CONTENT_TEXT;
1150 entry->mode = S_IFREG | S_IRUGO | S_IWUSR;
1151 entry->c.text.read_size = 8192;
1152 entry->c.text.read = snd_mixer_oss_proc_read;
1153 entry->c.text.write_size = 8192;
1154 entry->c.text.write = snd_mixer_oss_proc_write;
1155 entry->private_data = mixer;
1156 if (snd_info_register(entry) < 0) {
1157 snd_info_free_entry(entry);
1160 mixer->proc_entry = entry;
1163 static void snd_mixer_oss_proc_done(snd_mixer_oss_t *mixer)
1165 if (mixer->proc_entry) {
1166 snd_info_unregister(mixer->proc_entry);
1167 mixer->proc_entry = NULL;
1171 static void snd_mixer_oss_build(snd_mixer_oss_t *mixer)
1173 static struct snd_mixer_oss_assign_table table[] = {
1174 { SOUND_MIXER_VOLUME, "Master", 0 },
1175 { SOUND_MIXER_VOLUME, "Front", 0 }, /* fallback */
1176 { SOUND_MIXER_BASS, "Tone Control - Bass", 0 },
1177 { SOUND_MIXER_TREBLE, "Tone Control - Treble", 0 },
1178 { SOUND_MIXER_SYNTH, "Synth", 0 },
1179 { SOUND_MIXER_SYNTH, "FM", 0 }, /* fallback */
1180 { SOUND_MIXER_SYNTH, "Music", 0 }, /* fallback */
1181 { SOUND_MIXER_PCM, "PCM", 0 },
1182 { SOUND_MIXER_SPEAKER, "PC Speaker", 0 },
1183 { SOUND_MIXER_LINE, "Line", 0 },
1184 { SOUND_MIXER_MIC, "Mic", 0 },
1185 { SOUND_MIXER_CD, "CD", 0 },
1186 { SOUND_MIXER_IMIX, "Monitor Mix", 0 },
1187 { SOUND_MIXER_ALTPCM, "PCM", 1 },
1188 { SOUND_MIXER_ALTPCM, "Headphone", 0 }, /* fallback */
1189 { SOUND_MIXER_ALTPCM, "Wave", 0 }, /* fallback */
1190 { SOUND_MIXER_RECLEV, "-- nothing --", 0 },
1191 { SOUND_MIXER_IGAIN, "Capture", 0 },
1192 { SOUND_MIXER_OGAIN, "Playback", 0 },
1193 { SOUND_MIXER_LINE1, "Aux", 0 },
1194 { SOUND_MIXER_LINE2, "Aux", 1 },
1195 { SOUND_MIXER_LINE3, "Aux", 2 },
1196 { SOUND_MIXER_DIGITAL1, "Digital", 0 },
1197 { SOUND_MIXER_DIGITAL1, "IEC958", 0 }, /* fallback */
1198 { SOUND_MIXER_DIGITAL1, "IEC958 Optical", 0 }, /* fallback */
1199 { SOUND_MIXER_DIGITAL1, "IEC958 Coaxial", 0 }, /* fallback */
1200 { SOUND_MIXER_DIGITAL2, "Digital", 1 },
1201 { SOUND_MIXER_DIGITAL3, "Digital", 2 },
1202 { SOUND_MIXER_PHONEIN, "Phone", 0 },
1203 { SOUND_MIXER_PHONEOUT, "Master Mono", 0 },
1204 { SOUND_MIXER_PHONEOUT, "Phone", 0 }, /* fallback */
1205 { SOUND_MIXER_VIDEO, "Video", 0 },
1206 { SOUND_MIXER_RADIO, "Radio", 0 },
1207 { SOUND_MIXER_MONITOR, "Monitor", 0 }
1211 for (idx = 0; idx < sizeof(table) / sizeof(struct snd_mixer_oss_assign_table); idx++)
1212 snd_mixer_oss_build_input(mixer, &table[idx], 0, 0);
1213 if (mixer->mask_recsrc) {
1214 mixer->get_recsrc = snd_mixer_oss_get_recsrc2;
1215 mixer->put_recsrc = snd_mixer_oss_put_recsrc2;
1223 static int snd_mixer_oss_free1(void *private)
1225 snd_mixer_oss_t *mixer = snd_magic_cast(snd_mixer_oss_t, private, return -ENXIO);
1229 snd_assert(mixer != NULL, return -ENXIO);
1231 snd_assert(mixer == card->mixer_oss, return -ENXIO);
1232 card->mixer_oss = NULL;
1233 for (idx = 0; idx < SNDRV_OSS_MAX_MIXERS; idx++) {
1234 snd_mixer_oss_slot_t *chn = &mixer->slots[idx];
1235 if (chn->private_free)
1236 chn->private_free(chn);
1238 snd_magic_kfree(mixer);
1242 static int snd_mixer_oss_notify_handler(snd_card_t * card, int cmd)
1244 snd_mixer_oss_t *mixer;
1246 if (cmd == SND_MIXER_OSS_NOTIFY_REGISTER) {
1250 mixer = snd_magic_kcalloc(snd_mixer_oss_t, sizeof(snd_mixer_oss_t), GFP_KERNEL);
1253 init_MUTEX(&mixer->reg_mutex);
1254 sprintf(name, "mixer%i%i", card->number, 0);
1255 if ((err = snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_MIXER,
1259 snd_printk("unable to register OSS mixer device %i:%i\n", card->number, 0);
1260 snd_magic_kfree(mixer);
1263 mixer->oss_dev_alloc = 1;
1265 if (*card->mixername)
1266 strlcpy(mixer->name, card->mixername, sizeof(mixer->name));
1268 strlcpy(mixer->name, name, sizeof(mixer->name));
1269 #ifdef SNDRV_OSS_INFO_DEV_MIXERS
1270 snd_oss_info_register(SNDRV_OSS_INFO_DEV_MIXERS,
1274 for (idx = 0; idx < SNDRV_OSS_MAX_MIXERS; idx++)
1275 mixer->slots[idx].number = idx;
1276 card->mixer_oss = mixer;
1277 snd_mixer_oss_build(mixer);
1278 snd_mixer_oss_proc_init(mixer);
1279 } else if (cmd == SND_MIXER_OSS_NOTIFY_DISCONNECT) {
1280 mixer = card->mixer_oss;
1281 if (mixer == NULL || !mixer->oss_dev_alloc)
1283 snd_unregister_oss_device(SNDRV_OSS_DEVICE_TYPE_MIXER, mixer->card, 0);
1284 mixer->oss_dev_alloc = 0;
1286 mixer = card->mixer_oss;
1289 #ifdef SNDRV_OSS_INFO_DEV_MIXERS
1290 snd_oss_info_unregister(SNDRV_OSS_INFO_DEV_MIXERS, mixer->card->number);
1292 if (mixer->oss_dev_alloc)
1293 snd_unregister_oss_device(SNDRV_OSS_DEVICE_TYPE_MIXER, mixer->card, 0);
1294 snd_mixer_oss_proc_done(mixer);
1295 return snd_mixer_oss_free1(mixer);
1300 static int __init alsa_mixer_oss_init(void)
1304 snd_mixer_oss_notify_callback = snd_mixer_oss_notify_handler;
1305 for (idx = 0; idx < SNDRV_CARDS; idx++) {
1307 snd_mixer_oss_notify_handler(snd_cards[idx], SND_MIXER_OSS_NOTIFY_REGISTER);
1312 static void __exit alsa_mixer_oss_exit(void)
1316 snd_mixer_oss_notify_callback = NULL;
1317 for (idx = 0; idx < SNDRV_CARDS; idx++) {
1319 snd_mixer_oss_notify_handler(snd_cards[idx], SND_MIXER_OSS_NOTIFY_FREE);
1323 module_init(alsa_mixer_oss_init)
1324 module_exit(alsa_mixer_oss_exit)
1326 EXPORT_SYMBOL(snd_mixer_oss_ioctl_card);