Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/jmcneill-audiomp3]: src/sys/dev/isa port the changes from ad-audiomp2 br...
details: https://anonhg.NetBSD.org/src/rev/3f4b33bcabc5
branches: jmcneill-audiomp3
changeset: 771345:3f4b33bcabc5
user: mrg <mrg%NetBSD.org@localhost>
date: Sun Nov 20 12:08:19 2011 +0000
description:
port the changes from ad-audiomp2 branch. this mostly replaces the
changes i'd made to pcppi to achieve a similar result.
XXX: these actually could be pulled down to -current today, i think.
no actual dependancies on audiomp branch itself.
diffstat:
sys/dev/isa/pcppi.c | 86 ++++++++++++++++++++++++++-----------------------
sys/dev/isa/pcppivar.h | 9 +---
2 files changed, 49 insertions(+), 46 deletions(-)
diffs (224 lines):
diff -r 3fa8148ecb21 -r 3f4b33bcabc5 sys/dev/isa/pcppi.c
--- a/sys/dev/isa/pcppi.c Sun Nov 20 12:07:27 2011 +0000
+++ b/sys/dev/isa/pcppi.c Sun Nov 20 12:08:19 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pcppi.c,v 1.37 2011/05/24 09:28:03 mrg Exp $ */
+/* $NetBSD: pcppi.c,v 1.37.6.1 2011/11/20 12:08:19 mrg Exp $ */
/*
* Copyright (c) 1996 Carnegie-Mellon University.
@@ -28,7 +28,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pcppi.c,v 1.37 2011/05/24 09:28:03 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pcppi.c,v 1.37.6.1 2011/11/20 12:08:19 mrg Exp $");
#include "attimer.h"
@@ -42,6 +42,7 @@
#include <sys/bus.h>
#include <sys/mutex.h>
#include <sys/condvar.h>
+#include <sys/tty.h>
#include <dev/ic/attimervar.h>
@@ -66,16 +67,14 @@
DVF_DETACH_SHUTDOWN);
static int pcppisearch(device_t, cfdata_t, const int *, void *);
-static void pcppi_bell_stop_unlocked(void*);
-static void pcppi_bell_stop(void*);
+static void pcppi_bell_stop(struct pcppi_softc *);
+static void pcppi_bell_callout(void *);
#if NATTIMER > 0
static void pcppi_attach_speaker(device_t);
static void pcppi_detach_speaker(struct pcppi_softc *);
#endif
-#define PCPPIPRI (PZERO - 1)
-
int
pcppi_match(device_t parent, cfdata_t match, void *aux)
{
@@ -175,6 +174,7 @@
void
pcppi_childdet(device_t self, device_t child)
{
+
/* we hold no child references, so do nothing */
}
@@ -196,14 +196,16 @@
#if NPCKBD > 0
pckbd_unhook_bell(pcppi_pckbd_bell, sc);
#endif
+ mutex_spin_enter(&tty_lock);
pcppi_bell_stop(sc);
+ mutex_spin_exit(&tty_lock);
- callout_stop(&sc->sc_bell_ch);
+ callout_halt(&sc->sc_bell_ch, NULL);
callout_destroy(&sc->sc_bell_ch);
- bus_space_unmap(sc->sc_iot, sc->sc_ppi_ioh, sc->sc_size);
- mutex_destroy(&sc->sc_lock);
- cv_destroy(&sc->sc_stop_cv);
+ cv_destroy(&sc->sc_slp);
+
+ bus_space_unmap(sc->sc_iot, sc->sc_ppi_ioh, sc->sc_size);
return 0;
}
@@ -214,12 +216,11 @@
struct pcppi_attach_args pa;
device_t self = sc->sc_dv;
- callout_init(&sc->sc_bell_ch, 0);
+ callout_init(&sc->sc_bell_ch, CALLOUT_MPSAFE);
+ callout_setfunc(&sc->sc_bell_ch, pcppi_bell_callout, sc);
+ cv_init(&sc->sc_slp, "bell");
- sc->sc_bellactive = sc->sc_bellpitch = sc->sc_slp = 0;
-
- mutex_init(&sc->sc_lock, MUTEX_DEFAULT, IPL_VM);
- cv_init(&sc->sc_stop_cv, "bell");
+ sc->sc_bellactive = sc->sc_bellpitch = 0;
#if NPCKBD > 0
/* Provide a beeper for the PC Keyboard, if there isn't one already. */
@@ -274,21 +275,27 @@
void
pcppi_bell(pcppi_tag_t self, int pitch, int period, int slp)
{
+
+ mutex_spin_enter(&tty_lock);
+ pcppi_bell_locked(self, pitch, period, slp);
+ mutex_spin_exit(&tty_lock);
+}
+
+void
+pcppi_bell_locked(pcppi_tag_t self, int pitch, int period, int slp)
+{
struct pcppi_softc *sc = self;
- mutex_enter(&sc->sc_lock);
if (sc->sc_bellactive) {
if (sc->sc_timeout) {
sc->sc_timeout = 0;
callout_stop(&sc->sc_bell_ch);
}
- if (sc->sc_slp)
- cv_broadcast(&sc->sc_stop_cv);
+ cv_broadcast(&sc->sc_slp);
}
if (pitch == 0 || period == 0) {
- pcppi_bell_stop_unlocked(sc);
+ pcppi_bell_stop(sc);
sc->sc_bellpitch = 0;
- mutex_exit(&sc->sc_lock);
return;
}
if (!sc->sc_bellactive || sc->sc_bellpitch != pitch) {
@@ -306,24 +313,32 @@
sc->sc_bellactive = 1;
if (slp & PCPPI_BELL_POLL) {
delay((period * 1000000) / hz);
- pcppi_bell_stop_unlocked(sc);
+ pcppi_bell_stop(sc);
} else {
sc->sc_timeout = 1;
- callout_reset(&sc->sc_bell_ch, period, pcppi_bell_stop, sc);
+ callout_schedule(&sc->sc_bell_ch, period);
if (slp & PCPPI_BELL_SLEEP) {
- sc->sc_slp = 1;
- cv_wait_sig(&sc->sc_stop_cv, &sc->sc_lock);
- sc->sc_slp = 0;
+ cv_wait_sig(&sc->sc_slp, &tty_lock);
}
}
- mutex_exit(&sc->sc_lock);
}
static void
-pcppi_bell_stop_unlocked(void *arg)
+pcppi_bell_callout(void *arg)
{
struct pcppi_softc *sc = arg;
+ mutex_spin_enter(&tty_lock);
+ if (sc->sc_timeout != 0) {
+ pcppi_bell_stop(sc);
+ }
+ mutex_spin_exit(&tty_lock);
+}
+
+static void
+pcppi_bell_stop(struct pcppi_softc *sc)
+{
+
sc->sc_timeout = 0;
/* disable bell */
@@ -331,18 +346,7 @@
bus_space_read_1(sc->sc_iot, sc->sc_ppi_ioh, 0)
& ~PIT_SPKR);
sc->sc_bellactive = 0;
- if (sc->sc_slp)
- cv_broadcast(&sc->sc_stop_cv);
-}
-
-static void
-pcppi_bell_stop(void *arg)
-{
- struct pcppi_softc *sc = arg;
-
- mutex_enter(&sc->sc_lock);
- pcppi_bell_stop_unlocked(arg);
- mutex_exit(&sc->sc_lock);
+ cv_broadcast(&sc->sc_slp);
}
#if NPCKBD > 0
@@ -351,10 +355,12 @@
int poll)
{
+ KASSERT(mutex_owned(&tty_lock));
+
/*
* Comes in as ms, goes out at ticks; volume ignored.
*/
- pcppi_bell(arg, pitch, (period * hz) / 1000,
+ pcppi_bell_locked(arg, pitch, (period * hz) / 1000,
poll ? PCPPI_BELL_POLL : 0);
}
#endif /* NPCKBD > 0 */
diff -r 3fa8148ecb21 -r 3f4b33bcabc5 sys/dev/isa/pcppivar.h
--- a/sys/dev/isa/pcppivar.h Sun Nov 20 12:07:27 2011 +0000
+++ b/sys/dev/isa/pcppivar.h Sun Nov 20 12:08:19 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pcppivar.h,v 1.10.6.1 2011/11/19 21:49:38 jmcneill Exp $ */
+/* $NetBSD: pcppivar.h,v 1.10.6.2 2011/11/20 12:08:19 mrg Exp $ */
/*
* Copyright (c) 1996 Carnegie-Mellon University.
@@ -44,14 +44,11 @@
bus_size_t sc_size;
device_t sc_timer;
- struct callout sc_bell_ch;
-
int sc_bellactive, sc_bellpitch;
- int sc_slp;
int sc_timeout;
- kmutex_t sc_lock;
- kcondvar_t sc_stop_cv;
+ kcondvar_t sc_slp;
+ callout_t sc_bell_ch;
};
void pcppi_attach(struct pcppi_softc *);
Home |
Main Index |
Thread Index |
Old Index