summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/audio.c99
-rw-r--r--sys/dev/audio_if.h3
-rw-r--r--sys/dev/audiovar.h6
-rw-r--r--sys/dev/ccd.c42
-rw-r--r--sys/dev/ccdvar.h44
-rw-r--r--sys/dev/cons.c2
-rw-r--r--sys/dev/cons.h2
-rw-r--r--sys/dev/vnd.c2
8 files changed, 125 insertions, 75 deletions
diff --git a/sys/dev/audio.c b/sys/dev/audio.c
index 0daedec302c..4d2857a4fef 100644
--- a/sys/dev/audio.c
+++ b/sys/dev/audio.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: audio.c,v 1.4 1996/02/27 09:43:15 niklas Exp $ */
-/* $NetBSD: audio.c,v 1.17 1996/02/16 02:25:43 mycroft Exp $ */
+/* $OpenBSD: audio.c,v 1.5 1996/03/02 00:29:19 niklas Exp $ */
+/* $NetBSD: audio.c,v 1.20 1996/02/20 11:47:22 mycroft Exp $ */
/*
* Copyright (c) 1991-1993 Regents of the University of California.
@@ -626,7 +626,7 @@ audio_init_play(sc)
int s = splaudio();
sc->sc_mode |= AUMODE_PLAY;
- sc->sc_rblks = 0;
+ sc->sc_rblks = sc->sc_wblks = 0;
if (sc->hw_if->speaker_ctl)
sc->hw_if->speaker_ctl(sc->hw_hdl, SPKR_ON);
splx(s);
@@ -647,7 +647,7 @@ audio_drain(sc)
* timeout.
*/
error = audio_sleep_timo(&sc->sc_wchan, "aud dr", 60*hz);
- if (error != 0)
+ if (error)
return (error);
}
return (0);
@@ -738,7 +738,7 @@ audio_read(dev, uio, ioflag)
return (EWOULDBLOCK);
}
error = audio_sleep(&sc->sc_rchan, "aud hr");
- if (error != 0) {
+ if (error) {
splx(s);
return (error);
}
@@ -747,7 +747,9 @@ audio_read(dev, uio, ioflag)
error = audio_silence_copyout(sc, blocksize, uio);
if (error)
break;
+ s = splaudio();
--sc->sc_rblks;
+ splx(s);
} while (uio->uio_resid >= blocksize);
return (error);
}
@@ -763,7 +765,7 @@ audio_read(dev, uio, ioflag)
audiostartr(sc);
error = audio_sleep(&sc->sc_rchan, "aud rd");
splx(s);
- if (error != 0)
+ if (error)
return (error);
}
hp = cb->hp;
@@ -796,6 +798,7 @@ audio_clear(sc)
}
AU_RING_INIT(&sc->rr);
AU_RING_INIT(&sc->pr);
+ sc->sc_rblks = sc->sc_wblks = 0;
splx(s);
}
@@ -1028,16 +1031,26 @@ audio_write(dev, uio, ioflag)
/* wrap the ring buffer if at end */
s = splaudio();
- if (tp >= cb->ep)
- tp = cb->bp;
- cb->tp = tp;
- ++cb->nblk; /* account for buffer filled */
+ if ((sc->sc_mode & AUMODE_PLAY_ALL) == 0 && sc->sc_wblks)
+ /*
+ * discard the block if we sent out a silence
+ * packet that hasn't yet been countered
+ * by user data. (They must supply enough
+ * data to catch up to "real time").
+ */
+ sc->sc_wblks--;
+ else {
+ if (tp >= cb->ep)
+ tp = cb->bp;
+ cb->tp = tp;
+ ++cb->nblk; /* account for buffer filled */
- /*
- * If output isn't active, start it up.
- */
- if (sc->sc_pbus == 0)
- audiostartp(sc);
+ /*
+ * If output isn't active, start it up.
+ */
+ if (sc->sc_pbus == 0)
+ audiostartp(sc);
+ }
splx(s);
}
return (error);
@@ -1060,6 +1073,15 @@ audio_ioctl(dev, cmd, addr, flag, p)
IOCPARM_LEN(cmd), IOCGROUP(cmd), cmd&0xff));
switch (cmd) {
+ case FIOASYNC:
+ if (*(int *)addr) {
+ if (sc->sc_async)
+ return (EBUSY);
+ sc->sc_async = p;
+ } else
+ sc->sc_async = 0;
+ break;
+
case AUDIO_FLUSH:
DPRINTF(("AUDIO_FLUSH\n"));
audio_clear(sc);
@@ -1075,11 +1097,15 @@ audio_ioctl(dev, cmd, addr, flag, p)
break;
/*
- * Number of read samples dropped. We don't know where or
+ * Number of read (write) samples dropped. We don't know where or
* when they were dropped.
*/
case AUDIO_RERROR:
- *(int *)addr = sc->rr.cb_drops != 0;
+ *(int *)addr = sc->rr.cb_drops;
+ break;
+
+ case AUDIO_PERROR:
+ *(int *)addr = sc->pr.cb_drops;
break;
/*
@@ -1310,7 +1336,8 @@ audio_pint(sc)
audio_pint, (void *)sc)) {
DPRINTF(("audio_pint zero failed: %d\n", err));
audio_clear(sc);
- }
+ } else
+ ++sc->sc_wblks;
}
#ifdef AUDIO_DEBUG
@@ -1321,6 +1348,8 @@ audio_pint(sc)
if (cb->nblk <= sc->sc_lowat) {
audio_wakeup(&sc->sc_wchan);
selwakeup(&sc->sc_wsel);
+ if (sc->sc_async)
+ psignal(sc->sc_async, SIGIO);
}
}
@@ -1332,6 +1361,8 @@ audio_pint(sc)
if (hw->full_duplex) {
audio_wakeup(&sc->sc_rchan);
selwakeup(&sc->sc_rsel);
+ if (sc->sc_async)
+ psignal(sc->sc_async, SIGIO);
}
}
@@ -1386,6 +1417,8 @@ audio_rint(sc)
audio_wakeup(&sc->sc_rchan);
selwakeup(&sc->sc_rsel);
+ if (sc->sc_async)
+ psignal(sc->sc_async, SIGIO);
}
}
@@ -1408,7 +1441,7 @@ audiosetinfo(sc, ai)
audio_clear(sc);
cleared = 1;
error = hw->set_out_sr(sc->hw_hdl, p->sample_rate);
- if (error != 0)
+ if (error)
return(error);
sc->sc_50ms = 50 * hw->get_out_sr(sc->hw_hdl) / 1000;
}
@@ -1417,7 +1450,7 @@ audiosetinfo(sc, ai)
audio_clear(sc);
cleared = 1;
error = hw->set_in_sr(sc->hw_hdl, r->sample_rate);
- if (error != 0)
+ if (error)
return(error);
sc->sc_50ms = 50 * hw->get_in_sr(sc->hw_hdl) / 1000;
}
@@ -1426,7 +1459,7 @@ audiosetinfo(sc, ai)
audio_clear(sc);
cleared = 1;
error = hw->set_encoding(sc->hw_hdl, p->encoding);
- if (error != 0)
+ if (error)
return(error);
sc->sc_pencoding = p->encoding;
}
@@ -1435,7 +1468,7 @@ audiosetinfo(sc, ai)
audio_clear(sc);
cleared = 1;
error = hw->set_encoding(sc->hw_hdl, r->encoding);
- if (error != 0)
+ if (error)
return(error);
sc->sc_rencoding = r->encoding;
}
@@ -1444,7 +1477,7 @@ audiosetinfo(sc, ai)
audio_clear(sc);
cleared = 1;
error = hw->set_precision(sc->hw_hdl, p->precision);
- if (error != 0)
+ if (error)
return(error);
sc->sc_blksize = audio_blocksize = audio_calc_blksize(sc);
@@ -1458,7 +1491,7 @@ audiosetinfo(sc, ai)
audio_clear(sc);
cleared = 1;
error = hw->set_precision(sc->hw_hdl, r->precision);
- if (error != 0)
+ if (error)
return(error);
sc->sc_blksize = audio_blocksize = audio_calc_blksize(sc);
@@ -1472,7 +1505,7 @@ audiosetinfo(sc, ai)
audio_clear(sc);
cleared = 1;
error = hw->set_channels(sc->hw_hdl, p->channels);
- if (error != 0)
+ if (error)
return(error);
sc->sc_blksize = audio_blocksize = audio_calc_blksize(sc);
@@ -1486,7 +1519,7 @@ audiosetinfo(sc, ai)
audio_clear(sc);
cleared = 1;
error = hw->set_channels(sc->hw_hdl, r->channels);
- if (error != 0)
+ if (error)
return(error);
sc->sc_blksize = audio_blocksize = audio_calc_blksize(sc);
@@ -1500,7 +1533,7 @@ audiosetinfo(sc, ai)
audio_clear(sc);
cleared = 1;
error = hw->set_out_port(sc->hw_hdl, p->port);
- if (error != 0)
+ if (error)
return(error);
}
if (r->port != ~0) {
@@ -1508,7 +1541,7 @@ audiosetinfo(sc, ai)
audio_clear(sc);
cleared = 1;
error = hw->set_in_port(sc->hw_hdl, r->port);
- if (error != 0)
+ if (error)
return(error);
}
if (p->gain != ~0) {
@@ -1516,14 +1549,18 @@ audiosetinfo(sc, ai)
ct.type = AUDIO_MIXER_VALUE;
ct.un.value.num_channels = 1;
ct.un.value.level[AUDIO_MIXER_LEVEL_MONO] = p->gain;
- hw->set_port(sc->hw_hdl, &ct);
+ error = hw->set_port(sc->hw_hdl, &ct);
+ if (error)
+ return(error);
}
if (r->gain != ~0) {
ct.dev = hw->get_in_port(sc->hw_hdl);
ct.type = AUDIO_MIXER_VALUE;
ct.un.value.num_channels = 1;
ct.un.value.level[AUDIO_MIXER_LEVEL_MONO] = r->gain;
- hw->set_port(sc->hw_hdl, &ct);
+ error = hw->set_port(sc->hw_hdl, &ct);
+ if (error)
+ return(error);
}
if (p->pause != (u_char)~0) {
@@ -1593,7 +1630,7 @@ audiosetinfo(sc, ai)
audio_init_record(sc);
}
error = hw->commit_settings(sc->hw_hdl);
- if (error != 0)
+ if (error)
return (error);
if (cleared) {
diff --git a/sys/dev/audio_if.h b/sys/dev/audio_if.h
index ec7d76320c8..8ac5462a43e 100644
--- a/sys/dev/audio_if.h
+++ b/sys/dev/audio_if.h
@@ -1,4 +1,5 @@
-/* $NetBSD: audio_if.h,v 1.5 1995/07/19 19:58:23 brezak Exp $ */
+/* $OpenBSD: audio_if.h,v 1.3 1996/03/02 00:29:20 niklas Exp $ */
+/* $NetBSD: audio_if.h,v 1.6 1995/12/24 02:30:58 mycroft Exp $ */
/*
* Copyright (c) 1994 Havard Eidnes.
diff --git a/sys/dev/audiovar.h b/sys/dev/audiovar.h
index 1b7587d6aaa..ca1d6321c06 100644
--- a/sys/dev/audiovar.h
+++ b/sys/dev/audiovar.h
@@ -1,5 +1,5 @@
-/* $OpenBSD: audiovar.h,v 1.2 1996/02/27 09:43:17 niklas Exp $ */
-/* $NetBSD: audiovar.h,v 1.5 1996/02/16 02:25:44 mycroft Exp $ */
+/* $OpenBSD: audiovar.h,v 1.3 1996/03/02 00:29:21 niklas Exp $ */
+/* $NetBSD: audiovar.h,v 1.7 1996/02/20 10:00:33 mycroft Exp $ */
/*
* Copyright (c) 1991-1993 Regents of the University of California.
@@ -94,6 +94,7 @@ struct audio_softc {
struct selinfo sc_wsel; /* write selector */
struct selinfo sc_rsel; /* read selector */
+ struct proc *sc_async; /* process who wants SIGIO */
/* Sleep channels for reading and writing. */
int sc_rchan;
@@ -117,6 +118,7 @@ struct audio_softc {
int sc_hiwat; /* xmit high water mark (for wakeup) */
int sc_rblks; /* number of phantom record blocks */
+ int sc_wblks; /* number of output silence blocks */
int sc_pencoding; /* current encoding; play */
int sc_rencoding; /* current encoding; record */
};
diff --git a/sys/dev/ccd.c b/sys/dev/ccd.c
index cab34525248..fd51cd82240 100644
--- a/sys/dev/ccd.c
+++ b/sys/dev/ccd.c
@@ -1,10 +1,13 @@
-/* $OpenBSD: ccd.c,v 1.6 1996/02/27 09:43:17 niklas Exp $ */
-/* $NetBSD: ccd.c,v 1.27 1996/02/11 18:04:01 thorpej Exp $ */
+/* $OpenBSD: ccd.c,v 1.7 1996/03/02 00:29:21 niklas Exp $ */
+/* $NetBSD: ccd.c,v 1.28 1996/02/28 01:08:28 thorpej Exp $ */
-/*
- * Copyright (c) 1995, 1996 Jason R. Thorpe.
+/*-
+ * Copyright (c) 1996 The NetBSD Foundation, Inc.
* All rights reserved.
*
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe.
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@@ -15,22 +18,23 @@
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
- * This product includes software developed for the NetBSD Project
- * by Jason R. Thorpe.
- * 4. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
+ * This product includes software developed by the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
*/
/*
diff --git a/sys/dev/ccdvar.h b/sys/dev/ccdvar.h
index 0c10ecbccab..7a1514bedf1 100644
--- a/sys/dev/ccdvar.h
+++ b/sys/dev/ccdvar.h
@@ -1,9 +1,13 @@
-/* $NetBSD: ccdvar.h,v 1.9 1996/01/07 22:03:30 thorpej Exp $ */
+/* $OpenBSD: ccdvar.h,v 1.3 1996/03/02 00:29:23 niklas Exp $ */
+/* $NetBSD: ccdvar.h,v 1.11 1996/02/28 01:08:32 thorpej Exp $ */
-/*
- * Copyright (c) 1995 Jason R. Thorpe.
+/*-
+ * Copyright (c) 1996 The NetBSD Foundation, Inc.
* All rights reserved.
*
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe.
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@@ -14,22 +18,23 @@
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
- * This product includes software developed for the NetBSD Project
- * by Jason R. Thorpe.
- * 4. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
+ * This product includes software developed by the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
*/
/*
@@ -110,9 +115,10 @@ struct ccd_ioctl {
/* ccd_flags */
#define CCDF_SWAP 0x01 /* interleave should be dmmax */
#define CCDF_UNIFORM 0x02 /* use LCCD of sizes for uniform interleave */
+#define CCDF_MIRROR 0x04 /* enable data mirroring */
/* Mask of user-settable ccd flags. */
-#define CCDF_USERMASK (CCDF_SWAP|CCDF_UNIFORM)
+#define CCDF_USERMASK (CCDF_SWAP|CCDF_UNIFORM|CCDF_MIRROR)
/*
* Component info table.
diff --git a/sys/dev/cons.c b/sys/dev/cons.c
index 3643121b7db..b6427e1237c 100644
--- a/sys/dev/cons.c
+++ b/sys/dev/cons.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cons.c,v 1.3 1996/02/27 09:43:19 niklas Exp $ */
+/* $OpenBSD: cons.c,v 1.4 1996/03/02 00:29:23 niklas Exp $ */
/* $NetBSD: cons.c,v 1.29 1996/02/04 02:04:08 christos Exp $ */
/*
diff --git a/sys/dev/cons.h b/sys/dev/cons.h
index 155c2aa30cf..186664b220d 100644
--- a/sys/dev/cons.h
+++ b/sys/dev/cons.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cons.h,v 1.3 1996/02/27 09:43:19 niklas Exp $ */
+/* $OpenBSD: cons.h,v 1.4 1996/03/02 00:29:24 niklas Exp $ */
/* $NetBSD: cons.h,v 1.13 1996/02/04 02:04:17 christos Exp $ */
/*
diff --git a/sys/dev/vnd.c b/sys/dev/vnd.c
index 262d1a19dbd..0eb6a69fc01 100644
--- a/sys/dev/vnd.c
+++ b/sys/dev/vnd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vnd.c,v 1.4 1996/02/27 09:43:20 niklas Exp $ */
+/* $OpenBSD: vnd.c,v 1.5 1996/03/02 00:29:25 niklas Exp $ */
/* $NetBSD: vnd.c,v 1.24 1996/02/10 00:11:44 christos Exp $ */
/*