Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/jmcneill-audiomp3]: src/sys/arch/macppc/dev convert snapper
details: https://anonhg.NetBSD.org/src/rev/d54707ee574b
branches: jmcneill-audiomp3
changeset: 771391:d54707ee574b
user: macallan <macallan%NetBSD.org@localhost>
date: Tue Nov 22 05:54:54 2011 +0000
description:
convert snapper
code from mrg, tested on my iBook G4
diffstat:
sys/arch/macppc/dev/snapper.c | 46 +++++++++++++++++++++++++++++-------------
1 files changed, 32 insertions(+), 14 deletions(-)
diffs (161 lines):
diff -r 4bcbfd6328d5 -r d54707ee574b sys/arch/macppc/dev/snapper.c
--- a/sys/arch/macppc/dev/snapper.c Tue Nov 22 03:07:30 2011 +0000
+++ b/sys/arch/macppc/dev/snapper.c Tue Nov 22 05:54:54 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: snapper.c,v 1.36 2010/11/12 12:26:29 phx Exp $ */
+/* $NetBSD: snapper.c,v 1.36.10.1 2011/11/22 05:54:54 macallan Exp $ */
/* Id: snapper.c,v 1.11 2002/10/31 17:42:13 tsubai Exp */
/* Id: i2s.c,v 1.12 2005/01/15 14:32:35 tsubai Exp */
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: snapper.c,v 1.36 2010/11/12 12:26:29 phx Exp $");
+__KERNEL_RCSID(0, "$NetBSD: snapper.c,v 1.36.10.1 2011/11/22 05:54:54 macallan Exp $");
#include <sys/param.h>
#include <sys/audioio.h>
@@ -111,6 +111,9 @@
unsigned char dbdma_cmdspace[sizeof(struct dbdma_command) * 40 + 15];
struct dbdma_command *sc_odmacmd;
struct dbdma_command *sc_idmacmd;
+
+ kmutex_t sc_lock;
+ kmutex_t sc_intr_lock;
};
static int snapper_match(device_t, struct cfdata *, void *);
@@ -134,6 +137,7 @@
void *, const audio_params_t *);
static int snapper_trigger_input(void *, void *, void *, int, void (*)(void *),
void *, const audio_params_t *);
+static void snapper_get_locks(void *, kmutex_t **, kmutex_t **);
static void snapper_set_volume(struct snapper_softc *, u_int, u_int);
static int snapper_set_rate(struct snapper_softc *);
static void snapper_set_treble(struct snapper_softc *, u_int);
@@ -161,7 +165,7 @@
};
static stream_filter_t *snapper_filter_factory
- (int (*)(stream_fetcher_t *, audio_stream_t *, int));
+ (int (*)(struct audio_softc *sc, stream_fetcher_t *, audio_stream_t *, int));
static void snapper_filter_dtor(stream_filter_t *);
/* XXX We can't access the hw device softc from our audio
@@ -172,7 +176,7 @@
/* XXX why doesn't auconv define this? */
#define DEFINE_FILTER(name) \
static int \
-name##_fetch_to(stream_fetcher_t *, audio_stream_t *, int); \
+name##_fetch_to(struct audio_softc *, stream_fetcher_t *, audio_stream_t *, int); \
stream_filter_t * name(struct audio_softc *, \
const audio_params_t *, const audio_params_t *); \
stream_filter_t * \
@@ -182,7 +186,7 @@
return snapper_filter_factory(name##_fetch_to); \
} \
static int \
-name##_fetch_to(stream_fetcher_t *self, audio_stream_t *dst, int max_used)
+name##_fetch_to(struct audio_softc *sc, stream_fetcher_t *self, audio_stream_t *dst, int max_used)
DEFINE_FILTER(snapper_volume)
{
@@ -193,7 +197,7 @@
this = (stream_filter_t *)self;
max_used = (max_used + 1) & ~1;
- if ((err = this->prev->fetch_to(this->prev, this->src, max_used)))
+ if ((err = this->prev->fetch_to(sc, this->prev, this->src, max_used)))
return err;
m = (dst->end - dst->start) & ~1;
m = min(m, max_used);
@@ -226,7 +230,7 @@
panic("snapper_fixphase");
#endif
max_used = (max_used + 3) & ~2;
- if ((err = this->prev->fetch_to(this->prev, this->src, max_used)))
+ if ((err = this->prev->fetch_to(sc, this->prev, this->src, max_used)))
return err;
/* work in stereo frames (4 bytes) */
@@ -245,7 +249,7 @@
}
static stream_filter_t *
-snapper_filter_factory(int (*fetch_to)(stream_fetcher_t *, audio_stream_t *, int))
+snapper_filter_factory(int (*fetch_to)(struct audio_softc *sc, stream_fetcher_t *, audio_stream_t *, int))
{
struct snapper_codecvar *this;
@@ -299,7 +303,8 @@
snapper_trigger_output,
snapper_trigger_input,
NULL,
- NULL
+ NULL,
+ snapper_get_locks,
};
struct audio_device snapper_device = {
@@ -782,12 +787,15 @@
oirq_type = intr[3] ? IST_LEVEL : IST_EDGE;
iirq_type = intr[5] ? IST_LEVEL : IST_EDGE;
- /* intr_establish(cirq, cirq_type, IPL_AUDIO, snapper_intr, sc); */
- intr_establish(oirq, oirq_type, IPL_AUDIO, snapper_intr, sc);
- intr_establish(iirq, iirq_type, IPL_AUDIO, snapper_intr, sc);
+ /* intr_establish(cirq, cirq_type, IPL_BIO, snapper_intr, sc); */
+ intr_establish(oirq, oirq_type, IPL_SCHED, snapper_intr, sc);
+ intr_establish(iirq, iirq_type, IPL_SCHED, snapper_intr, sc);
aprint_normal(": irq %d,%d,%d\n", cirq, oirq, iirq);
+ mutex_init(&sc->sc_lock, MUTEX_DEFAULT, IPL_NONE);
+ mutex_init(&sc->sc_intr_lock, MUTEX_DEFAULT, IPL_SCHED);
+
/* PMF event handler */
pmf_device_register(sc->sc_dev, NULL, NULL);
@@ -847,6 +855,7 @@
int status;
sc = v;
+ mutex_spin_enter(&sc->sc_intr_lock);
cmd = sc->sc_odmacmd;
count = sc->sc_opages;
/* Fill used buffer(s). */
@@ -873,7 +882,7 @@
}
cmd++;
}
-
+ mutex_spin_exit(&sc->sc_intr_lock);
return 1;
}
@@ -1461,6 +1470,15 @@
}
static void
+snapper_get_locks(void *opaque, kmutex_t **intr, kmutex_t **thread)
+{
+ struct snapper_softc *sc = opaque;
+
+ *intr = &sc->sc_intr_lock;
+ *thread = &sc->sc_lock;
+}
+
+static void
snapper_set_volume(struct snapper_softc *sc, u_int left, u_int right)
{
u_char regs[6];
@@ -2098,7 +2116,7 @@
DPRINTF(" audio-hw-reset %p\n", audio_hw_reset);
if (headphone_detect_intr != -1)
- intr_establish(headphone_detect_intr, IST_EDGE, IPL_AUDIO,
+ intr_establish(headphone_detect_intr, IST_EDGE, IPL_SCHED,
snapper_cint, sc);
sc->sc_rate = 44100; /* default rate */
Home |
Main Index |
Thread Index |
Old Index