Module Name: src
Committed By: mrg
Date: Sun Nov 20 10:56:19 UTC 2011
Modified Files:
src/sys/arch/sparc/dev [jmcneill-audiomp3]: audioamd.c
src/sys/dev/ic [jmcneill-audiomp3]: am7930.c am7930var.h
src/sys/dev/tc [jmcneill-audiomp3]: bba.c
Log Message:
port the am7930 drivers to audiomp. sparc and pmax GENERIC builds,
but i am unable to test these drivers.
To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.26.4.1 src/sys/arch/sparc/dev/audioamd.c
cvs rdiff -u -r1.50 -r1.50.56.1 src/sys/dev/ic/am7930.c
cvs rdiff -u -r1.12 -r1.12.4.1 src/sys/dev/ic/am7930var.h
cvs rdiff -u -r1.38 -r1.38.4.1 src/sys/dev/tc/bba.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/sparc/dev/audioamd.c
diff -u src/sys/arch/sparc/dev/audioamd.c:1.26 src/sys/arch/sparc/dev/audioamd.c:1.26.4.1
--- src/sys/arch/sparc/dev/audioamd.c:1.26 Sat Jun 4 01:27:57 2011
+++ src/sys/arch/sparc/dev/audioamd.c Sun Nov 20 10:56:18 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: audioamd.c,v 1.26 2011/06/04 01:27:57 tsutsui Exp $ */
+/* $NetBSD: audioamd.c,v 1.26.4.1 2011/11/20 10:56:18 mrg Exp $ */
/* NetBSD: am7930_sparc.c,v 1.44 1999/03/14 22:29:00 jonathan Exp */
/*
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: audioamd.c,v 1.26 2011/06/04 01:27:57 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audioamd.c,v 1.26.4.1 2011/11/20 10:56:18 mrg Exp $");
#include "audio.h"
#if NAUDIO > 0
@@ -148,6 +148,7 @@ struct am7930_glue audioamd_glue = {
int audioamd_start_output(void *, void *, int, void (*)(void *), void *);
int audioamd_start_input(void *, void *, int, void (*)(void *), void *);
int audioamd_getdev(void *, struct audio_device *);
+void audioamd_get_locks(void *opaque, kmutex_t **intr, kmutex_t **thread);
const struct audio_hw_if sa_hw_if = {
am7930_open,
@@ -177,6 +178,8 @@ const struct audio_hw_if sa_hw_if = {
0,
0,
0,
+ 0,
+ audioamd_get_locks,
};
struct audio_device audioamd_device = {
@@ -558,4 +561,14 @@ audioamd_getdev(void *addr, struct audio
return 0;
}
+void
+audioamd_get_locks(void *opaque, kmutex_t **intr, kmutex_t **thread)
+{
+ struct audioamd_softc *asc = opaque;
+ struct am7930_softc *sc = &asc->sc_am7930;
+
+ *intr = &sc->sc_intr_lock;
+ *thread = &sc->sc_lock;
+}
+
#endif /* NAUDIO > 0 */
Index: src/sys/dev/ic/am7930.c
diff -u src/sys/dev/ic/am7930.c:1.50 src/sys/dev/ic/am7930.c:1.50.56.1
--- src/sys/dev/ic/am7930.c:1.50 Fri Oct 19 11:59:46 2007
+++ src/sys/dev/ic/am7930.c Sun Nov 20 10:56:18 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: am7930.c,v 1.50 2007/10/19 11:59:46 ad Exp $ */
+/* $NetBSD: am7930.c,v 1.50.56.1 2011/11/20 10:56:18 mrg Exp $ */
/*
* Copyright (c) 1995 Rolf Grossmann
@@ -36,7 +36,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: am7930.c,v 1.50 2007/10/19 11:59:46 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: am7930.c,v 1.50.56.1 2011/11/20 10:56:18 mrg Exp $");
#include "audio.h"
#if NAUDIO > 0
@@ -190,6 +190,9 @@ am7930_init(struct am7930_softc *sc, int
AM7930_MCR4_INT_ENABLE);
}
+ mutex_init(&sc->sc_lock, MUTEX_DEFAULT, IPL_NONE);
+ /* We used to take splaudio() in commit_settings */
+ mutex_init(&sc->sc_intr_lock, MUTEX_DEFAULT, IPL_VM);
}
int
@@ -288,7 +291,7 @@ am7930_commit_settings(void *addr)
struct am7930_softc *sc;
uint16_t ger, gr, gx, stgr;
uint8_t mmr2, mmr3;
- int s, level;
+ int level;
DPRINTF(("sa_commit.\n"));
sc = addr;
@@ -304,7 +307,7 @@ am7930_commit_settings(void *addr)
gr = gx_coeff[level];
}
- s = splaudio();
+ mutex_enter(&sc->sc_intr_lock);
mmr2 = AM7930_IREAD(sc, AM7930_IREG_MAP_MMR2);
if (sc->sc_out_port == AUDIOAMD_SPEAKER_VOL)
@@ -329,7 +332,7 @@ am7930_commit_settings(void *addr)
AM7930_IWRITE16(sc, AM7930_IREG_MAP_GR, gr);
AM7930_IWRITE16(sc, AM7930_IREG_MAP_GER, ger);
- splx(s);
+ mutex_exit(&sc->sc_intr_lock);
return 0;
}
Index: src/sys/dev/ic/am7930var.h
diff -u src/sys/dev/ic/am7930var.h:1.12 src/sys/dev/ic/am7930var.h:1.12.4.1
--- src/sys/dev/ic/am7930var.h:1.12 Sat Jun 4 01:27:57 2011
+++ src/sys/dev/ic/am7930var.h Sun Nov 20 10:56:18 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: am7930var.h,v 1.12 2011/06/04 01:27:57 tsutsui Exp $ */
+/* $NetBSD: am7930var.h,v 1.12.4.1 2011/11/20 10:56:18 mrg Exp $ */
struct am7930_softc;
@@ -24,6 +24,9 @@ struct am7930_softc {
uint8_t sc_mic_mute;
struct am7930_glue *sc_glue;
+
+ kmutex_t sc_lock;
+ kmutex_t sc_intr_lock;
};
extern int am7930debug;
Index: src/sys/dev/tc/bba.c
diff -u src/sys/dev/tc/bba.c:1.38 src/sys/dev/tc/bba.c:1.38.4.1
--- src/sys/dev/tc/bba.c:1.38 Sat Jun 4 01:27:57 2011
+++ src/sys/dev/tc/bba.c Sun Nov 20 10:56:19 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: bba.c,v 1.38 2011/06/04 01:27:57 tsutsui Exp $ */
+/* $NetBSD: bba.c,v 1.38.4.1 2011/11/20 10:56:19 mrg Exp $ */
/*
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -29,13 +29,13 @@
/* maxine/alpha baseboard audio (bba) */
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bba.c,v 1.38 2011/06/04 01:27:57 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bba.c,v 1.38.4.1 2011/11/20 10:56:19 mrg Exp $");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/device.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
#include <sys/bus.h>
#include <machine/autoconf.h>
@@ -111,10 +111,10 @@ static void bba_onclose(struct am7930_so
static stream_filter_factory_t bba_output_conv;
static stream_filter_factory_t bba_input_conv;
-static int bba_output_conv_fetch_to(stream_fetcher_t *, audio_stream_t *,
- int);
-static int bba_input_conv_fetch_to(stream_fetcher_t *, audio_stream_t *,
- int);
+static int bba_output_conv_fetch_to(struct audio_softc *, stream_fetcher_t *,
+ audio_stream_t *, int);
+static int bba_input_conv_fetch_to(struct audio_softc *, stream_fetcher_t *,
+ audio_stream_t *, int);
struct am7930_glue bba_glue = {
bba_codec_iread,
@@ -136,8 +136,8 @@ static int bba_round_blocksize(void *, i
static int bba_halt_output(void *);
static int bba_halt_input(void *);
static int bba_getdev(void *, struct audio_device *);
-static void *bba_allocm(void *, int, size_t, struct malloc_type *, int);
-static void bba_freem(void *, void *, struct malloc_type *);
+static void *bba_allocm(void *, int, size_t);
+static void bba_freem(void *, void *, size_t);
static size_t bba_round_buffersize(void *, int, size_t);
static int bba_get_props(void *);
static paddr_t bba_mappage(void *, void *, off_t, int);
@@ -147,6 +147,8 @@ static int bba_trigger_output(void *, vo
static int bba_trigger_input(void *, void *, void *, int,
void (*)(void *), void *,
const audio_params_t *);
+static void bba_get_locks(void *opaque, kmutex_t **intr,
+ kmutex_t **thread);
static const struct audio_hw_if sa_hw_if = {
am7930_open,
@@ -176,6 +178,8 @@ static const struct audio_hw_if sa_hw_if
bba_trigger_output, /* md */
bba_trigger_input, /* md */
0,
+ 0,
+ bba_get_locks,
};
static struct audio_device bba_device = {
@@ -288,8 +292,7 @@ bba_reset(struct bba_softc *sc, int rese
static void *
-bba_allocm(void *addr, int direction, size_t size,
- struct malloc_type *pool, int flags)
+bba_allocm(void *addr, int direction, size_t size)
{
struct am7930_softc *asc;
struct bba_softc *sc;
@@ -297,30 +300,28 @@ bba_allocm(void *addr, int direction, si
int rseg;
void *kva;
struct bba_mem *m;
- int w;
int state;
DPRINTF(("bba_allocm: size = %zu\n", size));
asc = addr;
sc = addr;
state = 0;
- w = (flags & M_NOWAIT) ? BUS_DMA_NOWAIT : BUS_DMA_WAITOK;
if (bus_dmamem_alloc(sc->sc_dmat, size, BBA_DMABUF_ALIGN,
- BBA_DMABUF_BOUNDARY, &seg, 1, &rseg, w)) {
+ BBA_DMABUF_BOUNDARY, &seg, 1, &rseg, BUS_DMA_WAITOK)) {
aprint_error_dev(asc->sc_dev, "can't allocate DMA buffer\n");
goto bad;
}
state |= 1;
if (bus_dmamem_map(sc->sc_dmat, &seg, rseg, size,
- &kva, w | BUS_DMA_COHERENT)) {
+ &kva, BUS_DMA_WAITOK | BUS_DMA_COHERENT)) {
aprint_error_dev(asc->sc_dev, "can't map DMA buffer\n");
goto bad;
}
state |= 2;
- m = malloc(sizeof(struct bba_mem), pool, flags);
+ m = kmem_alloc(sizeof(struct bba_mem), KM_SLEEP);
if (m == NULL)
goto bad;
m->addr = seg.ds_addr;
@@ -341,7 +342,7 @@ bad:
static void
-bba_freem(void *addr, void *ptr, struct malloc_type *pool)
+bba_freem(void *addr, void *ptr, size_t size)
{
struct bba_softc *sc;
struct bba_mem **mp, *m;
@@ -364,7 +365,7 @@ bba_freem(void *addr, void *ptr, struct
seg.ds_addr = m->addr;
seg.ds_len = m->size;
bus_dmamem_free(sc->sc_dmat, &seg, 1);
- free(m, pool);
+ kmem_free(m, sizeof(struct bba_mem));
}
@@ -573,16 +574,26 @@ bad:
return 1;
}
+static void
+bba_get_locks(void *opaque, kmutex_t **intr, kmutex_t **thread)
+{
+ struct bba_softc *bsc = opaque;
+ struct am7930_softc *sc = &bsc->sc_am7930;
+
+ *intr = &sc->sc_intr_lock;
+ *thread = &sc->sc_lock;
+}
+
static int
bba_intr(void *addr)
{
struct bba_softc *sc;
struct bba_dma_state *d;
tc_addr_t nphys;
- int s, mask;
+ int mask;
sc = addr;
- s = splaudio();
+ mutex_enter(&sc->sc_am7930.sc_intr_lock);
mask = bus_space_read_4(sc->sc_bst, sc->sc_bsh, IOASIC_INTR);
@@ -605,7 +616,7 @@ bba_intr(void *addr)
(*d->intr)(d->intr_arg);
}
- splx(s);
+ mutex_exit(&sc->sc_am7930.sc_intr_lock);
return 0;
}
@@ -649,14 +660,14 @@ bba_input_conv(struct audio_softc *sc, c
}
static int
-bba_input_conv_fetch_to(stream_fetcher_t *self, audio_stream_t *dst,
- int max_used)
+bba_input_conv_fetch_to(struct audio_softc *sc, stream_fetcher_t *self,
+ audio_stream_t *dst, int max_used)
{
stream_filter_t *this;
int m, err;
this = (stream_filter_t *)self;
- if ((err = this->prev->fetch_to(this->prev, this->src, max_used * 4)))
+ if ((err = this->prev->fetch_to(sc, this->prev, this->src, max_used * 4)))
return err;
m = dst->end - dst->start;
m = min(m, max_used);
@@ -674,15 +685,15 @@ bba_output_conv(struct audio_softc *sc,
}
static int
-bba_output_conv_fetch_to(stream_fetcher_t *self, audio_stream_t *dst,
- int max_used)
+bba_output_conv_fetch_to(struct audio_softc *sc, stream_fetcher_t *self,
+ audio_stream_t *dst, int max_used)
{
stream_filter_t *this;
int m, err;
this = (stream_filter_t *)self;
max_used = (max_used + 3) & ~3;
- if ((err = this->prev->fetch_to(this->prev, this->src, max_used / 4)))
+ if ((err = this->prev->fetch_to(sc, this->prev, this->src, max_used / 4)))
return err;
m = (dst->end - dst->start) & ~3;
m = min(m, max_used);