| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: uaudio.c,v 1.125 2011/12/09 05:03:18 mrg Exp $ */ | | 1 | /* $NetBSD: uaudio.c,v 1.126 2011/12/13 12:26:32 mrg Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 1999 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 1999 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation | | 7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Lennart Augustsson (lennart@augustsson.net) at | | 8 | * by Lennart Augustsson (lennart@augustsson.net) at |
9 | * Carlstedt Research & Technology. | | 9 | * Carlstedt Research & Technology. |
10 | * | | 10 | * |
11 | * Redistribution and use in source and binary forms, with or without | | 11 | * Redistribution and use in source and binary forms, with or without |
12 | * modification, are permitted provided that the following conditions | | 12 | * modification, are permitted provided that the following conditions |
13 | * are met: | | 13 | * are met: |
14 | * 1. Redistributions of source code must retain the above copyright | | 14 | * 1. Redistributions of source code must retain the above copyright |
| @@ -27,27 +27,27 @@ | | | @@ -27,27 +27,27 @@ |
27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
30 | * POSSIBILITY OF SUCH DAMAGE. | | 30 | * POSSIBILITY OF SUCH DAMAGE. |
31 | */ | | 31 | */ |
32 | | | 32 | |
33 | /* | | 33 | /* |
34 | * USB audio specs: http://www.usb.org/developers/devclass_docs/audio10.pdf | | 34 | * USB audio specs: http://www.usb.org/developers/devclass_docs/audio10.pdf |
35 | * http://www.usb.org/developers/devclass_docs/frmts10.pdf | | 35 | * http://www.usb.org/developers/devclass_docs/frmts10.pdf |
36 | * http://www.usb.org/developers/devclass_docs/termt10.pdf | | 36 | * http://www.usb.org/developers/devclass_docs/termt10.pdf |
37 | */ | | 37 | */ |
38 | | | 38 | |
39 | #include <sys/cdefs.h> | | 39 | #include <sys/cdefs.h> |
40 | __KERNEL_RCSID(0, "$NetBSD: uaudio.c,v 1.125 2011/12/09 05:03:18 mrg Exp $"); | | 40 | __KERNEL_RCSID(0, "$NetBSD: uaudio.c,v 1.126 2011/12/13 12:26:32 mrg Exp $"); |
41 | | | 41 | |
42 | #include <sys/param.h> | | 42 | #include <sys/param.h> |
43 | #include <sys/systm.h> | | 43 | #include <sys/systm.h> |
44 | #include <sys/kernel.h> | | 44 | #include <sys/kernel.h> |
45 | #include <sys/malloc.h> | | 45 | #include <sys/malloc.h> |
46 | #include <sys/device.h> | | 46 | #include <sys/device.h> |
47 | #include <sys/ioctl.h> | | 47 | #include <sys/ioctl.h> |
48 | #include <sys/file.h> | | 48 | #include <sys/file.h> |
49 | #include <sys/reboot.h> /* for bootverbose */ | | 49 | #include <sys/reboot.h> /* for bootverbose */ |
50 | #include <sys/select.h> | | 50 | #include <sys/select.h> |
51 | #include <sys/proc.h> | | 51 | #include <sys/proc.h> |
52 | #include <sys/vnode.h> | | 52 | #include <sys/vnode.h> |
53 | #include <sys/poll.h> | | 53 | #include <sys/poll.h> |
| @@ -2455,45 +2455,41 @@ uaudio_bsd2value(struct mixerctl *mc, in | | | @@ -2455,45 +2455,41 @@ uaudio_bsd2value(struct mixerctl *mc, in |
2455 | val = (val + mc->delta/2) * mc->mul / 255 + mc->minval; | | 2455 | val = (val + mc->delta/2) * mc->mul / 255 + mc->minval; |
2456 | DPRINTFN_CLEAN(5, "val'=%d\n", val); | | 2456 | DPRINTFN_CLEAN(5, "val'=%d\n", val); |
2457 | return val; | | 2457 | return val; |
2458 | } | | 2458 | } |
2459 | | | 2459 | |
2460 | Static int | | 2460 | Static int |
2461 | uaudio_ctl_get(struct uaudio_softc *sc, int which, struct mixerctl *mc, | | 2461 | uaudio_ctl_get(struct uaudio_softc *sc, int which, struct mixerctl *mc, |
2462 | int chan) | | 2462 | int chan) |
2463 | { | | 2463 | { |
2464 | int val; | | 2464 | int val; |
2465 | | | 2465 | |
2466 | DPRINTFN(5,"which=%d chan=%d\n", which, chan); | | 2466 | DPRINTFN(5,"which=%d chan=%d\n", which, chan); |
2467 | KERNEL_LOCK(1, curlwp); | | 2467 | KERNEL_LOCK(1, curlwp); |
2468 | mutex_exit(&sc->sc_lock); | | | |
2469 | val = uaudio_get(sc, which, UT_READ_CLASS_INTERFACE, mc->wValue[chan], | | 2468 | val = uaudio_get(sc, which, UT_READ_CLASS_INTERFACE, mc->wValue[chan], |
2470 | mc->wIndex, MIX_SIZE(mc->type)); | | 2469 | mc->wIndex, MIX_SIZE(mc->type)); |
2471 | mutex_enter(&sc->sc_lock); | | | |
2472 | KERNEL_UNLOCK_ONE(curlwp); | | 2470 | KERNEL_UNLOCK_ONE(curlwp); |
2473 | return uaudio_value2bsd(mc, val); | | 2471 | return uaudio_value2bsd(mc, val); |
2474 | } | | 2472 | } |
2475 | | | 2473 | |
2476 | Static void | | 2474 | Static void |
2477 | uaudio_ctl_set(struct uaudio_softc *sc, int which, struct mixerctl *mc, | | 2475 | uaudio_ctl_set(struct uaudio_softc *sc, int which, struct mixerctl *mc, |
2478 | int chan, int val) | | 2476 | int chan, int val) |
2479 | { | | 2477 | { |
2480 | | | 2478 | |
2481 | val = uaudio_bsd2value(mc, val); | | 2479 | val = uaudio_bsd2value(mc, val); |
2482 | KERNEL_LOCK(1, curlwp); | | 2480 | KERNEL_LOCK(1, curlwp); |
2483 | mutex_exit(&sc->sc_lock); | | | |
2484 | uaudio_set(sc, which, UT_WRITE_CLASS_INTERFACE, mc->wValue[chan], | | 2481 | uaudio_set(sc, which, UT_WRITE_CLASS_INTERFACE, mc->wValue[chan], |
2485 | mc->wIndex, MIX_SIZE(mc->type), val); | | 2482 | mc->wIndex, MIX_SIZE(mc->type), val); |
2486 | mutex_enter(&sc->sc_lock); | | | |
2487 | KERNEL_UNLOCK_ONE(curlwp); | | 2483 | KERNEL_UNLOCK_ONE(curlwp); |
2488 | } | | 2484 | } |
2489 | | | 2485 | |
2490 | Static int | | 2486 | Static int |
2491 | uaudio_mixer_get_port(void *addr, mixer_ctrl_t *cp) | | 2487 | uaudio_mixer_get_port(void *addr, mixer_ctrl_t *cp) |
2492 | { | | 2488 | { |
2493 | struct uaudio_softc *sc; | | 2489 | struct uaudio_softc *sc; |
2494 | struct mixerctl *mc; | | 2490 | struct mixerctl *mc; |
2495 | int i, n, vals[MIX_MAX_CHAN], val; | | 2491 | int i, n, vals[MIX_MAX_CHAN], val; |
2496 | | | 2492 | |
2497 | DPRINTFN(2, "index=%d\n", cp->dev); | | 2493 | DPRINTFN(2, "index=%d\n", cp->dev); |
2498 | sc = addr; | | 2494 | sc = addr; |
2499 | if (sc->sc_dying) | | 2495 | if (sc->sc_dying) |