| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: ossaudio.c,v 1.81 2020/04/15 16:39:06 nia Exp $ */ | | 1 | /* $NetBSD: ossaudio.c,v 1.82 2020/04/19 13:44:51 nia Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 1997, 2008 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 1997, 2008 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * Redistribution and use in source and binary forms, with or without | | 7 | * Redistribution and use in source and binary forms, with or without |
8 | * modification, are permitted provided that the following conditions | | 8 | * modification, are permitted provided that the following conditions |
9 | * are met: | | 9 | * are met: |
10 | * 1. Redistributions of source code must retain the above copyright | | 10 | * 1. Redistributions of source code must retain the above copyright |
11 | * notice, this list of conditions and the following disclaimer. | | 11 | * notice, this list of conditions and the following disclaimer. |
12 | * 2. Redistributions in binary form must reproduce the above copyright | | 12 | * 2. Redistributions in binary form must reproduce the above copyright |
13 | * notice, this list of conditions and the following disclaimer in the | | 13 | * notice, this list of conditions and the following disclaimer in the |
14 | * documentation and/or other materials provided with the distribution. | | 14 | * documentation and/or other materials provided with the distribution. |
| @@ -17,27 +17,27 @@ | | | @@ -17,27 +17,27 @@ |
17 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | | 17 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
18 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | | 18 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
19 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | | 19 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS |
20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | | 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | | 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
26 | * POSSIBILITY OF SUCH DAMAGE. | | 26 | * POSSIBILITY OF SUCH DAMAGE. |
27 | */ | | 27 | */ |
28 | | | 28 | |
29 | #include <sys/cdefs.h> | | 29 | #include <sys/cdefs.h> |
30 | __KERNEL_RCSID(0, "$NetBSD: ossaudio.c,v 1.81 2020/04/15 16:39:06 nia Exp $"); | | 30 | __KERNEL_RCSID(0, "$NetBSD: ossaudio.c,v 1.82 2020/04/19 13:44:51 nia Exp $"); |
31 | | | 31 | |
32 | #include <sys/param.h> | | 32 | #include <sys/param.h> |
33 | #include <sys/proc.h> | | 33 | #include <sys/proc.h> |
34 | #include <sys/systm.h> | | 34 | #include <sys/systm.h> |
35 | #include <sys/file.h> | | 35 | #include <sys/file.h> |
36 | #include <sys/vnode.h> | | 36 | #include <sys/vnode.h> |
37 | #include <sys/filedesc.h> | | 37 | #include <sys/filedesc.h> |
38 | #include <sys/ioctl.h> | | 38 | #include <sys/ioctl.h> |
39 | #include <sys/mount.h> | | 39 | #include <sys/mount.h> |
40 | #include <sys/kernel.h> | | 40 | #include <sys/kernel.h> |
41 | #include <sys/audioio.h> | | 41 | #include <sys/audioio.h> |
42 | #include <sys/midiio.h> | | 42 | #include <sys/midiio.h> |
43 | #include <sys/kauth.h> | | 43 | #include <sys/kauth.h> |
| @@ -705,99 +705,80 @@ oss_ioctl_audio(struct lwp *l, const str | | | @@ -705,99 +705,80 @@ oss_ioctl_audio(struct lwp *l, const str |
705 | if (error) { | | 705 | if (error) { |
706 | DPRINTF(("%s: FIONBIO %d\n", | | 706 | DPRINTF(("%s: FIONBIO %d\n", |
707 | __func__, error)); | | 707 | __func__, error)); |
708 | goto out; | | 708 | goto out; |
709 | } | | 709 | } |
710 | break; | | 710 | break; |
711 | case OSS_SNDCTL_DSP_GETCAPS: | | 711 | case OSS_SNDCTL_DSP_GETCAPS: |
712 | error = ioctlf(fp, AUDIO_GETPROPS, &idata); | | 712 | error = ioctlf(fp, AUDIO_GETPROPS, &idata); |
713 | if (error) { | | 713 | if (error) { |
714 | DPRINTF(("%s: AUDIO_GETPROPS %d\n", | | 714 | DPRINTF(("%s: AUDIO_GETPROPS %d\n", |
715 | __func__, error)); | | 715 | __func__, error)); |
716 | goto out; | | 716 | goto out; |
717 | } | | 717 | } |
718 | idat = OSS_DSP_CAP_TRIGGER; /* pretend we have trigger */ | | 718 | idat = OSS_DSP_CAP_TRIGGER; |
719 | if (idata & AUDIO_PROP_FULLDUPLEX) | | 719 | if (idata & AUDIO_PROP_FULLDUPLEX) |
720 | idat |= OSS_DSP_CAP_DUPLEX; | | 720 | idat |= OSS_DSP_CAP_DUPLEX; |
721 | if (idata & AUDIO_PROP_MMAP) | | 721 | if (idata & AUDIO_PROP_MMAP) |
722 | idat |= OSS_DSP_CAP_MMAP; | | 722 | idat |= OSS_DSP_CAP_MMAP; |
723 | DPRINTF(("%s: SNDCL_DSP_GETCAPS %s duplex, %smmap\n", | | 723 | DPRINTF(("%s: SNDCL_DSP_GETCAPS %s duplex, %smmap\n", |
724 | __func__, (idat & OSS_DSP_CAP_DUPLEX) ? "full" : "half", | | 724 | __func__, (idat & OSS_DSP_CAP_DUPLEX) ? "full" : "half", |
725 | (idat & OSS_DSP_CAP_MMAP) ? "" : "no ")); | | 725 | (idat & OSS_DSP_CAP_MMAP) ? "" : "no ")); |
726 | error = copyout(&idat, SCARG(uap, data), sizeof idat); | | 726 | error = copyout(&idat, SCARG(uap, data), sizeof idat); |
727 | if (error) { | | 727 | if (error) { |
728 | DPRINTF(("%s: SNDCTL_DSP_GETCAPS %x = %d\n", __func__, | | 728 | DPRINTF(("%s: SNDCTL_DSP_GETCAPS %x = %d\n", __func__, |
729 | idat, error)); | | 729 | idat, error)); |
730 | goto out; | | 730 | goto out; |
731 | } | | 731 | } |
732 | break; | | 732 | break; |
733 | #if 0 | | | |
734 | case OSS_SNDCTL_DSP_GETTRIGGER: | | | |
735 | error = ioctlf(fp, AUDIO_GETBUFINFO, &tmpinfo); | | | |
736 | if (error) { | | | |
737 | DPRINTF(("%s: AUDIO_GETBUFINFO %d\n", | | | |
738 | __func__, error)); | | | |
739 | goto out; | | | |
740 | } | | | |
741 | idat = (tmpinfo.play.pause ? 0 : OSS_PCM_ENABLE_OUTPUT) | | | | |
742 | (tmpinfo.record.pause ? 0 : OSS_PCM_ENABLE_INPUT); | | | |
743 | error = copyout(&idat, SCARG(uap, data), sizeof idat); | | | |
744 | if (error) { | | | |
745 | DPRINTF(("%s: SNDCTL_DSP_SETRIGGER %x = %d\n", | | | |
746 | __func__, idat, error)); | | | |
747 | goto out; | | | |
748 | } | | | |
749 | break; | | | |
750 | case OSS_SNDCTL_DSP_SETTRIGGER: | | 733 | case OSS_SNDCTL_DSP_SETTRIGGER: |
751 | error = ioctlf(fp, AUDIO_GETBUFINFO, &tmpinfo, p); | | 734 | error = copyin(SCARG(uap, data), &idat, sizeof idat); |
752 | if (error) { | | 735 | if (error) { |
753 | DPRINTF(("%s: AUDIO_GETBUFINFO %d\n", | | 736 | DPRINTF(("%s: SNDCTL_DSP_SETTRIGGER: %d\n", |
754 | __func__, error)); | | 737 | __func__, error)); |
755 | goto out; | | 738 | goto out; |
756 | } | | 739 | } |
757 | error = copyin(SCARG(uap, data), &idat, sizeof idat); | | 740 | error = ioctlf(fp, AUDIO_GETBUFINFO, &tmpinfo); |
758 | if (error) { | | 741 | if (error) { |
759 | DPRINTF(("%s: AUDIO_GETBUFINFO %d\n", | | 742 | DPRINTF(("%s: AUDIO_GETBUFINFO %d\n", |
760 | __func__, error)); | | 743 | __func__, error)); |
761 | goto out; | | 744 | goto out; |
762 | } | | 745 | } |
763 | tmpinfo.play.pause = (idat & OSS_PCM_ENABLE_OUTPUT) == 0; | | 746 | AUDIO_INITINFO(&tmpinfo); |
764 | tmpinfo.record.pause = (idat & OSS_PCM_ENABLE_INPUT) == 0; | | 747 | if (tmpinfo.mode & AUMODE_PLAY) |
765 | error = ioctlf(fp, AUDIO_SETINFO, &tmpinfo); | | 748 | tmpinfo.play.pause = (idat & OSS_PCM_ENABLE_OUTPUT) == 0; |
| | | 749 | if (tmpinfo.mode & AUMODE_RECORD) |
| | | 750 | tmpinfo.record.pause = (idat & OSS_PCM_ENABLE_INPUT) == 0; |
| | | 751 | (void)ioctlf(fp, AUDIO_SETINFO, &tmpinfo); |
| | | 752 | /* FALLTHRU */ |
| | | 753 | case OSS_SNDCTL_DSP_GETTRIGGER: |
| | | 754 | error = ioctlf(fp, AUDIO_GETBUFINFO, &tmpinfo); |
766 | if (error) { | | 755 | if (error) { |
767 | DPRINTF(("%s: AUDIO_SETINFO %d\n", | | 756 | DPRINTF(("%s: AUDIO_GETBUFINFO %d\n", |
768 | __func__, error)); | | 757 | __func__, error)); |
769 | goto out; | | 758 | goto out; |
770 | } | | 759 | } |
| | | 760 | idat = 0; |
| | | 761 | if ((tmpinfo.mode & AUMODE_PLAY) && !tmpinfo.play.pause) |
| | | 762 | idat |= OSS_PCM_ENABLE_OUTPUT; |
| | | 763 | if ((tmpinfo.mode & AUMODE_RECORD) && !tmpinfo.record.pause) |
| | | 764 | idat |= OSS_PCM_ENABLE_INPUT; |
771 | error = copyout(&idat, SCARG(uap, data), sizeof idat); | | 765 | error = copyout(&idat, SCARG(uap, data), sizeof idat); |
772 | if (error) { | | 766 | if (error) { |
773 | DPRINTF(("%s: SNDCTL_DSP_SETRIGGER %x = %d\n", | | 767 | DPRINTF(("%s: SNDCTL_DSP_GETTRIGGER = %x = %d\n", |
774 | __func__, idat, error)); | | | |
775 | goto out; | | | |
776 | } | | | |
777 | break; | | | |
778 | #else | | | |
779 | case OSS_SNDCTL_DSP_GETTRIGGER: | | | |
780 | case OSS_SNDCTL_DSP_SETTRIGGER: | | | |
781 | /* XXX Do nothing for now. */ | | | |
782 | idat = OSS_PCM_ENABLE_OUTPUT; | | | |
783 | error = copyout(&idat, SCARG(uap, data), sizeof idat); | | | |
784 | if (error) { | | | |
785 | DPRINTF(("%s: SNDCTL_DSP_{GET,SET}RIGGER %x = %d\n", | | | |
786 | __func__, idat, error)); | | 768 | __func__, idat, error)); |
787 | goto out; | | 769 | goto out; |
788 | } | | 770 | } |
789 | break; | | 771 | break; |
790 | #endif | | | |
791 | case OSS_SNDCTL_DSP_GETIPTR: | | 772 | case OSS_SNDCTL_DSP_GETIPTR: |
792 | error = ioctlf(fp, AUDIO_GETIOFFS, &tmpoffs); | | 773 | error = ioctlf(fp, AUDIO_GETIOFFS, &tmpoffs); |
793 | if (error) { | | 774 | if (error) { |
794 | DPRINTF(("%s: AUDIO_GETIOFFS %d\n", | | 775 | DPRINTF(("%s: AUDIO_GETIOFFS %d\n", |
795 | __func__, error)); | | 776 | __func__, error)); |
796 | goto out; | | 777 | goto out; |
797 | } | | 778 | } |
798 | cntinfo.bytes = tmpoffs.samples; | | 779 | cntinfo.bytes = tmpoffs.samples; |
799 | cntinfo.blocks = tmpoffs.deltablks; | | 780 | cntinfo.blocks = tmpoffs.deltablks; |
800 | cntinfo.ptr = tmpoffs.offset; | | 781 | cntinfo.ptr = tmpoffs.offset; |
801 | error = copyout(&cntinfo, SCARG(uap, data), sizeof cntinfo); | | 782 | error = copyout(&cntinfo, SCARG(uap, data), sizeof cntinfo); |
802 | if (error) { | | 783 | if (error) { |
803 | DPRINTF(("%s: SNDCTL_DSP_GETIPTR %d\n", | | 784 | DPRINTF(("%s: SNDCTL_DSP_GETIPTR %d\n", |