ossaudio: Implement SNDCTL_DSP_(SET|GET)TRIGGER.

This commit is contained in:
nia 2020-04-19 13:44:50 +00:00
parent 3c531f4f39
commit 8e9e149d7d
2 changed files with 49 additions and 76 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: ossaudio.c,v 1.42 2020/04/19 11:27:40 nia Exp $ */
/* $NetBSD: ossaudio.c,v 1.43 2020/04/19 13:44:50 nia Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
__RCSID("$NetBSD: ossaudio.c,v 1.42 2020/04/19 11:27:40 nia Exp $");
__RCSID("$NetBSD: ossaudio.c,v 1.43 2020/04/19 13:44:50 nia Exp $");
/*
* This is an OSS (Linux) sound API emulator.
@ -501,43 +501,35 @@ audio_ioctl(int fd, unsigned long com, void *argp)
retval = ioctl(fd, AUDIO_GETPROPS, &idata);
if (retval < 0)
return retval;
idat = DSP_CAP_TRIGGER; /* pretend we have trigger */
idat = DSP_CAP_TRIGGER;
if (idata & AUDIO_PROP_FULLDUPLEX)
idat |= DSP_CAP_DUPLEX;
if (idata & AUDIO_PROP_MMAP)
idat |= DSP_CAP_MMAP;
INTARG = idat;
break;
#if 0
case SNDCTL_DSP_SETTRIGGER:
retval = ioctl(fd, AUDIO_GETBUFINFO, &tmpinfo);
if (retval < 0)
return retval;
AUDIO_INITINFO(&tmpinfo);
if (tmpinfo.mode & AUMODE_PLAY)
tmpinfo.play.pause = (INTARG & PCM_ENABLE_OUTPUT) == 0;
if (tmpinfo.mode & AUMODE_RECORD)
tmpinfo.record.pause = (INTARG & PCM_ENABLE_INPUT) == 0;
(void)ioctl(fd, AUDIO_SETINFO, &tmpinfo);
/* FALLTHRU */
case SNDCTL_DSP_GETTRIGGER:
retval = ioctl(fd, AUDIO_GETBUFINFO, &tmpinfo);
if (retval < 0)
return retval;
idat = (tmpinfo.play.pause ? 0 : PCM_ENABLE_OUTPUT) |
(tmpinfo.record.pause ? 0 : PCM_ENABLE_INPUT);
retval = copyout(&idat, SCARG(uap, data), sizeof idat);
if (retval < 0)
return retval;
idat = 0;
if ((tmpinfo.mode & AUMODE_PLAY) && !tmpinfo.play.pause)
idat |= PCM_ENABLE_OUTPUT;
if ((tmpinfo.mode & AUMODE_RECORD) && !tmpinfo.record.pause)
idat |= PCM_ENABLE_INPUT;
INTARG = idat;
break;
case SNDCTL_DSP_SETTRIGGER:
AUDIO_INITINFO(&tmpinfo);
retval = copyin(SCARG(uap, data), &idat, sizeof idat);
if (retval < 0)
return retval;
tmpinfo.play.pause = (idat & PCM_ENABLE_OUTPUT) == 0;
tmpinfo.record.pause = (idat & PCM_ENABLE_INPUT) == 0;
(void) ioctl(fd, AUDIO_SETINFO, &tmpinfo);
retval = copyout(&idat, SCARG(uap, data), sizeof idat);
if (retval < 0)
return retval;
break;
#else
case SNDCTL_DSP_GETTRIGGER:
case SNDCTL_DSP_SETTRIGGER:
/* XXX Do nothing for now. */
INTARG = PCM_ENABLE_OUTPUT;
break;
#endif
case SNDCTL_DSP_GETIPTR:
retval = ioctl(fd, AUDIO_GETIOFFS, &tmpoffs);
if (retval < 0)

View File

@ -1,4 +1,4 @@
/* $NetBSD: ossaudio.c,v 1.81 2020/04/15 16:39:06 nia Exp $ */
/* $NetBSD: ossaudio.c,v 1.82 2020/04/19 13:44:51 nia Exp $ */
/*-
* Copyright (c) 1997, 2008 The NetBSD Foundation, Inc.
@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ossaudio.c,v 1.81 2020/04/15 16:39:06 nia Exp $");
__KERNEL_RCSID(0, "$NetBSD: ossaudio.c,v 1.82 2020/04/19 13:44:51 nia Exp $");
#include <sys/param.h>
#include <sys/proc.h>
@ -715,7 +715,7 @@ oss_ioctl_audio(struct lwp *l, const struct oss_sys_ioctl_args *uap, register_t
__func__, error));
goto out;
}
idat = OSS_DSP_CAP_TRIGGER; /* pretend we have trigger */
idat = OSS_DSP_CAP_TRIGGER;
if (idata & AUDIO_PROP_FULLDUPLEX)
idat |= OSS_DSP_CAP_DUPLEX;
if (idata & AUDIO_PROP_MMAP)
@ -730,7 +730,26 @@ oss_ioctl_audio(struct lwp *l, const struct oss_sys_ioctl_args *uap, register_t
goto out;
}
break;
#if 0
case OSS_SNDCTL_DSP_SETTRIGGER:
error = copyin(SCARG(uap, data), &idat, sizeof idat);
if (error) {
DPRINTF(("%s: SNDCTL_DSP_SETTRIGGER: %d\n",
__func__, error));
goto out;
}
error = ioctlf(fp, AUDIO_GETBUFINFO, &tmpinfo);
if (error) {
DPRINTF(("%s: AUDIO_GETBUFINFO %d\n",
__func__, error));
goto out;
}
AUDIO_INITINFO(&tmpinfo);
if (tmpinfo.mode & AUMODE_PLAY)
tmpinfo.play.pause = (idat & OSS_PCM_ENABLE_OUTPUT) == 0;
if (tmpinfo.mode & AUMODE_RECORD)
tmpinfo.record.pause = (idat & OSS_PCM_ENABLE_INPUT) == 0;
(void)ioctlf(fp, AUDIO_SETINFO, &tmpinfo);
/* FALLTHRU */
case OSS_SNDCTL_DSP_GETTRIGGER:
error = ioctlf(fp, AUDIO_GETBUFINFO, &tmpinfo);
if (error) {
@ -738,56 +757,18 @@ oss_ioctl_audio(struct lwp *l, const struct oss_sys_ioctl_args *uap, register_t
__func__, error));
goto out;
}
idat = (tmpinfo.play.pause ? 0 : OSS_PCM_ENABLE_OUTPUT) |
(tmpinfo.record.pause ? 0 : OSS_PCM_ENABLE_INPUT);
idat = 0;
if ((tmpinfo.mode & AUMODE_PLAY) && !tmpinfo.play.pause)
idat |= OSS_PCM_ENABLE_OUTPUT;
if ((tmpinfo.mode & AUMODE_RECORD) && !tmpinfo.record.pause)
idat |= OSS_PCM_ENABLE_INPUT;
error = copyout(&idat, SCARG(uap, data), sizeof idat);
if (error) {
DPRINTF(("%s: SNDCTL_DSP_SETRIGGER %x = %d\n",
DPRINTF(("%s: SNDCTL_DSP_GETTRIGGER = %x = %d\n",
__func__, idat, error));
goto out;
}
break;
case OSS_SNDCTL_DSP_SETTRIGGER:
error = ioctlf(fp, AUDIO_GETBUFINFO, &tmpinfo, p);
if (error) {
DPRINTF(("%s: AUDIO_GETBUFINFO %d\n",
__func__, error));
goto out;
}
error = copyin(SCARG(uap, data), &idat, sizeof idat);
if (error) {
DPRINTF(("%s: AUDIO_GETBUFINFO %d\n",
__func__, error));
goto out;
}
tmpinfo.play.pause = (idat & OSS_PCM_ENABLE_OUTPUT) == 0;
tmpinfo.record.pause = (idat & OSS_PCM_ENABLE_INPUT) == 0;
error = ioctlf(fp, AUDIO_SETINFO, &tmpinfo);
if (error) {
DPRINTF(("%s: AUDIO_SETINFO %d\n",
__func__, error));
goto out;
}
error = copyout(&idat, SCARG(uap, data), sizeof idat);
if (error) {
DPRINTF(("%s: SNDCTL_DSP_SETRIGGER %x = %d\n",
__func__, idat, error));
goto out;
}
break;
#else
case OSS_SNDCTL_DSP_GETTRIGGER:
case OSS_SNDCTL_DSP_SETTRIGGER:
/* XXX Do nothing for now. */
idat = OSS_PCM_ENABLE_OUTPUT;
error = copyout(&idat, SCARG(uap, data), sizeof idat);
if (error) {
DPRINTF(("%s: SNDCTL_DSP_{GET,SET}RIGGER %x = %d\n",
__func__, idat, error));
goto out;
}
break;
#endif
case OSS_SNDCTL_DSP_GETIPTR:
error = ioctlf(fp, AUDIO_GETIOFFS, &tmpoffs);
if (error) {