summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/compat/freebsd/freebsd_ioctl.c45
-rw-r--r--sys/compat/freebsd/freebsd_ioctl.h10
-rw-r--r--sys/compat/linux/files.linux5
-rw-r--r--sys/compat/linux/linux_audio.c203
-rw-r--r--sys/compat/linux/linux_audio.h71
-rw-r--r--sys/compat/linux/linux_ioctl.c11
6 files changed, 63 insertions, 282 deletions
diff --git a/sys/compat/freebsd/freebsd_ioctl.c b/sys/compat/freebsd/freebsd_ioctl.c
index dc110965ae4..d11839d53e8 100644
--- a/sys/compat/freebsd/freebsd_ioctl.c
+++ b/sys/compat/freebsd/freebsd_ioctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: freebsd_ioctl.c,v 1.2 1996/08/02 20:34:46 niklas Exp $ */
+/* $OpenBSD: freebsd_ioctl.c,v 1.3 1998/04/26 21:22:29 provos Exp $ */
/* $NetBSD: freebsd_ioctl.c,v 1.1 1995/10/10 01:19:31 mycroft Exp $ */
/*
@@ -43,6 +43,33 @@
#include <compat/freebsd/freebsd_util.h>
#include <compat/freebsd/freebsd_ioctl.h>
+#include <compat/ossaudio/ossaudio.h>
+#include <compat/ossaudio/ossaudiovar.h>
+
+/* The FreeBSD and OSS(Linux) encodings of ioctl R/W differ. */
+static void freebsd_to_oss(struct freebsd_sys_ioctl_args *,
+ struct oss_sys_ioctl_args *);
+
+static void
+freebsd_to_oss(uap, rap)
+struct freebsd_sys_ioctl_args *uap;
+struct oss_sys_ioctl_args *rap;
+{
+ u_long ocmd, ncmd;
+
+ ocmd = SCARG(uap, com);
+ ncmd = ocmd &~ FREEBSD_IOC_DIRMASK;
+ switch(ocmd & FREEBSD_IOC_DIRMASK) {
+ case FREEBSD_IOC_VOID: ncmd |= OSS_IOC_VOID; break;
+ case FREEBSD_IOC_OUT: ncmd |= OSS_IOC_OUT; break;
+ case FREEBSD_IOC_IN: ncmd |= OSS_IOC_IN; break;
+ case FREEBSD_IOC_INOUT: ncmd |= OSS_IOC_INOUT; break;
+ }
+ SCARG(rap, fd) = SCARG(uap, fd);
+ SCARG(rap, com) = ncmd;
+ SCARG(rap, data) = SCARG(uap, data);
+}
+
int
freebsd_sys_ioctl(p, v, retval)
struct proc *p;
@@ -54,6 +81,7 @@ freebsd_sys_ioctl(p, v, retval)
syscallarg(u_long) com;
syscallarg(caddr_t) data;
} */ *uap = v;
+ struct oss_sys_ioctl_args ap;
/*
* XXX - <sys/cdio.h>'s incompatibility
@@ -63,5 +91,18 @@ freebsd_sys_ioctl(p, v, retval)
/* XXX - <sys/mtio.h> */
/* XXX - <sys/scsiio.h> */
/* XXX - should convert machine dependent ioctl()s */
- return sys_ioctl(p, uap, retval);
+
+ switch (FREEBSD_IOCGROUP(SCARG(uap, com))) {
+ case 'M':
+ freebsd_to_oss(uap, &ap);
+ return oss_ioctl_mixer(p, &ap, retval);
+ case 'Q':
+ freebsd_to_oss(uap, &ap);
+ return oss_ioctl_sequencer(p, &ap, retval);
+ case 'P':
+ freebsd_to_oss(uap, &ap);
+ return oss_ioctl_audio(p, &ap, retval);
+ default:
+ return sys_ioctl(p, uap, retval);
+ }
}
diff --git a/sys/compat/freebsd/freebsd_ioctl.h b/sys/compat/freebsd/freebsd_ioctl.h
index 721e66af625..43c1332c5b6 100644
--- a/sys/compat/freebsd/freebsd_ioctl.h
+++ b/sys/compat/freebsd/freebsd_ioctl.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: freebsd_ioctl.h,v 1.2 1996/08/02 20:34:46 niklas Exp $ */
+/* $OpenBSD: freebsd_ioctl.h,v 1.3 1998/04/26 21:22:30 provos Exp $ */
/* $NetBSD: freebsd_ioctl.h,v 1.1 1995/10/10 01:19:32 mycroft Exp $ */
/*
@@ -35,4 +35,12 @@
#ifndef _FREEBSD_IOCTL_H
#define _FREEBSD_IOCTL_H
+#define FREEBSD_IOCGROUP(x) (((x) >> 8) & 0xff)
+
+#define FREEBSD_IOC_DIRMASK 0xe0000000
+#define FREEBSD_IOC_VOID 0x20000000
+#define FREEBSD_IOC_OUT 0x40000000
+#define FREEBSD_IOC_IN 0x80000000
+#define FREEBSD_IOC_INOUT (FREEBSD_IOC_IN|FREEBSD_IOC_OUT)
+
#endif /* !_FREEBSD_IOCTL_H */
diff --git a/sys/compat/linux/files.linux b/sys/compat/linux/files.linux
index ab657e0efbe..c4bc64b8e5d 100644
--- a/sys/compat/linux/files.linux
+++ b/sys/compat/linux/files.linux
@@ -1,4 +1,4 @@
-# $OpenBSD: files.linux,v 1.5 1997/12/07 22:59:13 provos Exp $
+# $OpenBSD: files.linux,v 1.6 1998/04/26 21:22:20 provos Exp $
# $NetBSD: files.linux,v 1.4 1996/03/08 04:55:59 mycroft Exp $
#
# Config.new file description for machine-independent Linux compat code.
@@ -7,7 +7,7 @@
# ports should define any machine-specific files they need in their
# own file lists.
-file compat/linux/linux_audio.c compat_linux
+file compat/linux/linux_cdrom.c compat_linux
file compat/linux/linux_error.c compat_linux
file compat/linux/linux_exec.c compat_linux
file compat/linux/linux_file.c compat_linux
@@ -19,5 +19,4 @@ file compat/linux/linux_socket.c compat_linux
file compat/linux/linux_syscalls.c compat_linux
file compat/linux/linux_sysent.c compat_linux
file compat/linux/linux_termios.c compat_linux
-file compat/linux/linux_cdrom.c compat_linux
file compat/linux/linux_mount.c compat_linux
diff --git a/sys/compat/linux/linux_audio.c b/sys/compat/linux/linux_audio.c
deleted file mode 100644
index 8b13d4c4bdd..00000000000
--- a/sys/compat/linux/linux_audio.c
+++ /dev/null
@@ -1,203 +0,0 @@
-/* $OpenBSD: linux_audio.c,v 1.3 1996/09/16 15:34:27 mickey Exp $ */
-
-#include <sys/param.h>
-#include <sys/proc.h>
-#include <sys/systm.h>
-#include <sys/file.h>
-#include <sys/filedesc.h>
-#include <sys/ioctl.h>
-#include <sys/mount.h>
-#include <sys/audioio.h>
-
-#include <sys/syscallargs.h>
-
-#include <compat/linux/linux_types.h>
-#include <compat/linux/linux_ioctl.h>
-#include <compat/linux/linux_signal.h>
-#include <compat/linux/linux_syscallargs.h>
-#include <compat/linux/linux_audio.h>
-
-int
-linux_ioctl_audio(p, uap, retval)
- register struct proc *p;
- register struct linux_sys_ioctl_args /* {
- syscallarg(int) fd;
- syscallarg(u_long) com;
- syscallarg(caddr_t) data;
- } */ *uap;
- register_t *retval;
-{
- register struct file *fp;
- register struct filedesc *fdp;
- u_long com;
- struct audio_info tmpinfo;
- int idat;
- int error;
-
- fdp = p->p_fd;
- if ((u_int)SCARG(uap, fd) >= fdp->fd_nfiles ||
- (fp = fdp->fd_ofiles[SCARG(uap, fd)]) == NULL)
- return (EBADF);
-
- if ((fp->f_flag & (FREAD | FWRITE)) == 0)
- return (EBADF);
-
- com = SCARG(uap, com);
- retval[0] = 0;
-
- switch (com) {
- case LINUX_SNDCTL_DSP_RESET:
- error = (*fp->f_ops->fo_ioctl)(fp, AUDIO_FLUSH, (caddr_t)0, p);
- if (error)
- return error;
- break;
- case LINUX_SNDCTL_DSP_SYNC:
- case LINUX_SNDCTL_DSP_POST:
- error = (*fp->f_ops->fo_ioctl)(fp, AUDIO_DRAIN, (caddr_t)0, p);
- if (error)
- return error;
- break;
- case LINUX_SNDCTL_DSP_SPEED:
- AUDIO_INITINFO(&tmpinfo);
- error = copyin(SCARG(uap, data), &idat, sizeof idat);
- if (error)
- return error;
- tmpinfo.play.sample_rate =
- tmpinfo.record.sample_rate = idat;
- (void) (*fp->f_ops->fo_ioctl)(fp, AUDIO_SETINFO, (caddr_t)&tmpinfo, p);
- error = (*fp->f_ops->fo_ioctl)(fp, AUDIO_GETINFO, (caddr_t)&tmpinfo, p);
- if (error)
- return error;
- idat = tmpinfo.play.sample_rate;
- error = copyout(&idat, SCARG(uap, data), sizeof idat);
- if (error)
- return error;
- break;
- case LINUX_SNDCTL_DSP_WRITE_CHANNELS:
- AUDIO_INITINFO(&tmpinfo);
- error = copyin(SCARG(uap, data), &idat, sizeof idat);
- if (error)
- return error;
- tmpinfo.play.channels = idat;
- (void) (*fp->f_ops->fo_ioctl)(fp, AUDIO_SETINFO, (caddr_t)&tmpinfo, p);
- error = (*fp->f_ops->fo_ioctl)(fp, AUDIO_GETINFO, (caddr_t)&tmpinfo, p);
- if (error)
- return error;
- idat = tmpinfo.play.channels;
- error = copyout(&idat, SCARG(uap, data), sizeof idat);
- if (error)
- return error;
- break;
- case LINUX_SNDCTL_DSP_STEREO:
- AUDIO_INITINFO(&tmpinfo);
- error = copyin(SCARG(uap, data), &idat, sizeof idat);
- if (error)
- return error;
- tmpinfo.play.channels =
- tmpinfo.record.channels = idat ? 2 : 1;
- (void) (*fp->f_ops->fo_ioctl)(fp, AUDIO_SETINFO, (caddr_t)&tmpinfo, p);
- error = (*fp->f_ops->fo_ioctl)(fp, AUDIO_GETINFO, (caddr_t)&tmpinfo, p);
- if (error)
- return error;
- idat = tmpinfo.play.channels - 1;
- error = copyout(&idat, SCARG(uap, data), sizeof idat);
- if (error)
- return error;
- break;
- case LINUX_SNDCTL_DSP_GETBLKSIZE:
- error = (*fp->f_ops->fo_ioctl)(fp, AUDIO_GETINFO, (caddr_t)&tmpinfo, p);
- if (error)
- return error;
- idat = tmpinfo.blocksize;
- error = copyout(&idat, SCARG(uap, data), sizeof idat);
- if (error)
- return error;
- break;
- case LINUX_SNDCTL_DSP_SETFMT:
- AUDIO_INITINFO(&tmpinfo);
- error = copyin(SCARG(uap, data), &idat, sizeof idat);
- if (error)
- return error;
- switch (idat) {
- case LINUX_AFMT_MU_LAW:
- tmpinfo.play.precision =
- tmpinfo.record.precision = 8;
- tmpinfo.play.encoding =
- tmpinfo.record.encoding = AUDIO_ENCODING_ULAW;
- break;
- case LINUX_AFMT_A_LAW:
- tmpinfo.play.precision =
- tmpinfo.record.precision = 8;
- tmpinfo.play.encoding =
- tmpinfo.record.encoding = AUDIO_ENCODING_ALAW;
- break;
- case LINUX_AFMT_U8:
- tmpinfo.play.precision =
- tmpinfo.record.precision = 8;
- tmpinfo.play.encoding =
- tmpinfo.record.encoding = AUDIO_ENCODING_LINEAR;
- break;
- case LINUX_AFMT_S16_LE:
- tmpinfo.play.precision =
- tmpinfo.record.precision = 16;
- tmpinfo.play.encoding =
- tmpinfo.record.encoding = AUDIO_ENCODING_LINEAR;
- break;
- default:
- return EINVAL;
- }
- (void) (*fp->f_ops->fo_ioctl)(fp, AUDIO_SETINFO, (caddr_t)&tmpinfo, p);
- error = (*fp->f_ops->fo_ioctl)(fp, AUDIO_GETINFO, (caddr_t)&tmpinfo, p);
- if (error)
- return error;
- switch(tmpinfo.play.encoding) {
- case AUDIO_ENCODING_LINEAR:
- if (tmpinfo.play.precision == 8)
- idat = LINUX_AFMT_U8;
- else if (tmpinfo.play.precision == 16)
- idat = LINUX_AFMT_S16_LE;
- else return EINVAL;
- break;
- case AUDIO_ENCODING_ULAW:
- idat = LINUX_AFMT_MU_LAW;
- break;
- case AUDIO_ENCODING_ALAW:
- idat = LINUX_AFMT_A_LAW;
- break;
- default:
- return EINVAL;
- }
- error = copyout(&idat, SCARG(uap, data), sizeof idat);
- if (error)
- return error;
- break;
- case LINUX_SNDCTL_DSP_SETFRAGMENT:
- AUDIO_INITINFO(&tmpinfo);
- error = copyin(SCARG(uap, data), &idat, sizeof idat);
- if (error)
- return error;
- if ((idat & 0xffff) < 4 || (idat & 0xffff) > 17)
- return EINVAL;
- tmpinfo.blocksize = 1 << (idat & 0xffff);
- tmpinfo.hiwat = (idat >> 16) & 0xffff;
- (void) (*fp->f_ops->fo_ioctl)(fp, AUDIO_SETINFO, (caddr_t)&tmpinfo, p);
- error = (*fp->f_ops->fo_ioctl)(fp, AUDIO_GETINFO, (caddr_t)&tmpinfo, p);
- if (error)
- return error;
- idat = tmpinfo.blocksize;
- error = copyout(&idat, SCARG(uap, data), sizeof idat);
- if (error)
- return error;
- break;
- case LINUX_SNDCTL_DSP_GETFMTS:
- idat = LINUX_AFMT_MU_LAW | LINUX_AFMT_U8 | LINUX_AFMT_S16_LE;
- error = copyout(&idat, SCARG(uap, data), sizeof idat);
- if (error)
- return error;
- break;
- default:
- return EINVAL;
- }
-
- return 0;
-}
diff --git a/sys/compat/linux/linux_audio.h b/sys/compat/linux/linux_audio.h
deleted file mode 100644
index fc91ec3ed68..00000000000
--- a/sys/compat/linux/linux_audio.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/* $OpenBSD: linux_audio.h,v 1.3 1996/09/16 15:34:28 mickey Exp $ */
-
-#define LINUX_IOCPARM_MASK 0x7f /* parameters must be < 128 bytes */
-#define LINUX_IOC_VOID 0x00000000 /* no parameters */
-#define LINUX_IOC_IN 0x40000000 /* copy in parameters */
-#define LINUX_IOC_OUT 0x80000000 /* copy out parameters */
-#define LINUX_IOC_INOUT (LINUX_IOC_IN | LINUX_IOC_OUT)
-#define _LINUX_IOCTL(w,x,y,z) ((int)((w)|(((z)&LINUX_IOCPARM_MASK)<<16)|((x)<<8)|(y)))
-#if 0
-#define _LINUX_IO(x,y) _LINUX_IOCTL(LINUX_IOC_VOID, x, y, 0)
-#endif
-#define _LINUX_IOR(x,y,t) _LINUX_IOCTL(LINUX_IOC_OUT, x, y, sizeof(t))
-#define _LINUX_IOW(x,y,t) _LINUX_IOCTL(LINUX_IOC_IN, x, y, sizeof(t))
-#define _LINUX_IOWR(x,y,t) _LINUX_IOCTL(LINUX_IOC_INOUT, x, y, sizeof(t))
-
-#define LINUX_SNDCTL_DSP_RESET _LINUX_IO('P', 0)
-#define LINUX_SNDCTL_DSP_SYNC _LINUX_IO('P', 1)
-#define LINUX_SNDCTL_DSP_SPEED _LINUX_IOWR('P', 2, int)
-#define LINUX_SNDCTL_DSP_STEREO _LINUX_IOWR('P', 3, int)
-#define LINUX_SNDCTL_DSP_GETBLKSIZE _LINUX_IOWR('P', 4, int)
-#define LINUX_SNDCTL_DSP_SETFMT _LINUX_IOWR('P', 5, int)
-#define LINUX_SNDCTL_DSP_WRITE_CHANNELS _LINUX_IOWR('P', 6, int)
-#define LINUX_SNDCTL_DSP_POST _LINUX_IO('P', 8)
-#define LINUX_SNDCTL_DSP_SETFRAGMENT _LINUX_IOWR('P', 10, int)
-#define LINUX_SNDCTL_DSP_GETFMTS _LINUX_IOR('P', 11, int)
-
-#define LINUX_AFMT_QUERY 0x00000000 /* Return current fmt */
-#define LINUX_AFMT_MU_LAW 0x00000001
-#define LINUX_AFMT_A_LAW 0x00000002
-#define LINUX_AFMT_IMA_ADPCM 0x00000004
-#define LINUX_AFMT_U8 0x00000008
-#define LINUX_AFMT_S16_LE 0x00000010 /* Little endian signed 16 */
-#define LINUX_AFMT_S16_BE 0x00000020 /* Big endian signed 16 */
-#define LINUX_AFMT_S8 0x00000040
-#define LINUX_AFMT_U16_LE 0x00000080 /* Little endian U16 */
-#define LINUX_AFMT_U16_BE 0x00000100 /* Big endian U16 */
-#define LINUX_AFMT_MPEG 0x00000200 /* MPEG (2) audio */
-#define LINUX_IOCPARM_MASK 0x7f /* parameters must be < 128 bytes */
-#define LINUX_IOC_VOID 0x00000000 /* no parameters */
-#define LINUX_IOC_IN 0x40000000 /* copy in parameters */
-#define LINUX_IOC_OUT 0x80000000 /* copy out parameters */
-#define LINUX_IOC_INOUT (LINUX_IOC_IN | LINUX_IOC_OUT)
-#define _LINUX_IOCTL(w,x,y,z) ((int)((w)|(((z)&LINUX_IOCPARM_MASK)<<16)|((x)<<8)|(y)))
-#if 0
-#define _LINUX_IO(x,y) _LINUX_IOCTL(LINUX_IOC_VOID, x, y, 0)
-#endif
-#define _LINUX_IOR(x,y,t) _LINUX_IOCTL(LINUX_IOC_OUT, x, y, sizeof(t))
-#define _LINUX_IOW(x,y,t) _LINUX_IOCTL(LINUX_IOC_IN, x, y, sizeof(t))
-#define _LINUX_IOWR(x,y,t) _LINUX_IOCTL(LINUX_IOC_INOUT, x, y, sizeof(t))
-
-#define LINUX_SNDCTL_DSP_RESET _LINUX_IO('P', 0)
-#define LINUX_SNDCTL_DSP_SYNC _LINUX_IO('P', 1)
-#define LINUX_SNDCTL_DSP_SPEED _LINUX_IOWR('P', 2, int)
-#define LINUX_SNDCTL_DSP_STEREO _LINUX_IOWR('P', 3, int)
-#define LINUX_SNDCTL_DSP_GETBLKSIZE _LINUX_IOWR('P', 4, int)
-#define LINUX_SNDCTL_DSP_SETFMT _LINUX_IOWR('P', 5, int)
-#define LINUX_SNDCTL_DSP_POST _LINUX_IO('P', 8)
-#define LINUX_SNDCTL_DSP_SETFRAGMENT _LINUX_IOWR('P', 10, int)
-#define LINUX_SNDCTL_DSP_GETFMTS _LINUX_IOR('P', 11, int)
-
-#define LINUX_AFMT_QUERY 0x00000000 /* Return current fmt */
-#define LINUX_AFMT_MU_LAW 0x00000001
-#define LINUX_AFMT_A_LAW 0x00000002
-#define LINUX_AFMT_IMA_ADPCM 0x00000004
-#define LINUX_AFMT_U8 0x00000008
-#define LINUX_AFMT_S16_LE 0x00000010 /* Little endian signed 16 */
-#define LINUX_AFMT_S16_BE 0x00000020 /* Big endian signed 16 */
-#define LINUX_AFMT_S8 0x00000040
-#define LINUX_AFMT_U16_LE 0x00000080 /* Little endian U16 */
-#define LINUX_AFMT_U16_BE 0x00000100 /* Big endian U16 */
-#define LINUX_AFMT_MPEG 0x00000200 /* MPEG (2) audio */
diff --git a/sys/compat/linux/linux_ioctl.c b/sys/compat/linux/linux_ioctl.c
index 53101061dc3..6ba4c31a411 100644
--- a/sys/compat/linux/linux_ioctl.c
+++ b/sys/compat/linux/linux_ioctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: linux_ioctl.c,v 1.6 1997/12/07 22:59:15 provos Exp $ */
+/* $OpenBSD: linux_ioctl.c,v 1.7 1998/04/26 21:22:22 provos Exp $ */
/* $NetBSD: linux_ioctl.c,v 1.14 1996/04/05 00:01:28 christos Exp $ */
/*
@@ -49,6 +49,9 @@
#include <compat/linux/linux_syscallargs.h>
#include <compat/linux/linux_ioctl.h>
+#include <compat/ossaudio/ossaudio.h>
+#define LINUX_TO_OSS(v) (v) /* do nothing, same ioctl() encoding */
+
/*
* Most ioctl command are just converted to their NetBSD values,
* and passed on. The ones that take structure pointers and (flag)
@@ -69,8 +72,12 @@ linux_sys_ioctl(p, v, retval)
} */ *uap = v;
switch (LINUX_IOCGROUP(SCARG(uap, com))) {
+ case 'M':
+ return oss_ioctl_mixer(p, LINUX_TO_OSS(v), retval);
+ case 'Q':
+ return oss_ioctl_sequencer(p, LINUX_TO_OSS(v), retval);
case 'P':
- return linux_ioctl_audio(p, uap, retval);
+ return oss_ioctl_audio(p, LINUX_TO_OSS(v), retval);
case 'T':
return linux_ioctl_termios(p, uap, retval);
case 'S':