Module Name: src
Committed By: jmcneill
Date: Sun Nov 20 16:18:15 UTC 2011
Modified Files:
src/sys/arch/x68k/dev [jmcneill-audiomp3]: vs.c vsvar.h
src/sys/dev/ic [jmcneill-audiomp3]: msm6258.c
Log Message:
adapt to audiomp api changes
To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.34.4.1 src/sys/arch/x68k/dev/vs.c
cvs rdiff -u -r1.10 -r1.10.4.1 src/sys/arch/x68k/dev/vsvar.h
cvs rdiff -u -r1.16 -r1.16.4.1 src/sys/dev/ic/msm6258.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/x68k/dev/vs.c
diff -u src/sys/arch/x68k/dev/vs.c:1.34 src/sys/arch/x68k/dev/vs.c:1.34.4.1
--- src/sys/arch/x68k/dev/vs.c:1.34 Sun Oct 16 03:10:18 2011
+++ src/sys/arch/x68k/dev/vs.c Sun Nov 20 16:18:15 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: vs.c,v 1.34 2011/10/16 03:10:18 isaki Exp $ */
+/* $NetBSD: vs.c,v 1.34.4.1 2011/11/20 16:18:15 jmcneill Exp $ */
/*
* Copyright (c) 2001 Tetsuya Isaki. All rights reserved.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vs.c,v 1.34 2011/10/16 03:10:18 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vs.c,v 1.34.4.1 2011/11/20 16:18:15 jmcneill Exp $");
#include "audio.h"
#include "vs.h"
@@ -39,6 +39,7 @@ __KERNEL_RCSID(0, "$NetBSD: vs.c,v 1.34
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/device.h>
+#include <sys/kmem.h>
#include <sys/audioio.h>
#include <dev/audio_if.h>
@@ -83,17 +84,18 @@ static int vs_trigger_input(void *, voi
void (*)(void *), void *, const audio_params_t *);
static int vs_halt_output(void *);
static int vs_halt_input(void *);
-static int vs_allocmem(struct vs_softc *, size_t, size_t, size_t, int,
+static int vs_allocmem(struct vs_softc *, size_t, size_t, size_t,
struct vs_dma *);
static void vs_freemem(struct vs_dma *);
static int vs_getdev(void *, struct audio_device *);
static int vs_set_port(void *, mixer_ctrl_t *);
static int vs_get_port(void *, mixer_ctrl_t *);
static int vs_query_devinfo(void *, mixer_devinfo_t *);
-static void *vs_allocm(void *, int, size_t, struct malloc_type *, int);
-static void vs_freem(void *, void *, struct malloc_type *);
+static void *vs_allocm(void *, int, size_t);
+static void vs_freem(void *, void *, size_t);
static size_t vs_round_buffersize(void *, int, size_t);
static int vs_get_props(void *);
+static void vs_get_locks(void *, kmutex_t **, kmutex_t **);
/* lower functions */
static int vs_round_sr(u_long);
@@ -135,6 +137,8 @@ static const struct audio_hw_if vs_hw_if
vs_trigger_output,
vs_trigger_input,
NULL,
+ NULL,
+ vs_get_locks,
};
static struct audio_device vs_device = {
@@ -229,6 +233,8 @@ vs_attach(device_t parent, device_t self
sc->sc_hw_if = &vs_hw_if;
sc->sc_addr = (void *) ia->ia_addr;
sc->sc_dmas = NULL;
+ mutex_init(&sc->sc_lock, MUTEX_DEFAULT, IPL_NONE);
+ mutex_init(&sc->sc_intr_lock, MUTEX_DEFAULT, IPL_SCHED);
/* XXX */
bus_space_map(iot, PPI_ADDR, PPI_MAPSIZE, BUS_SPACE_MAP_SHIFTED,
@@ -255,6 +261,9 @@ vs_dmaintr(void *hdl)
DPRINTF(2, ("vs_dmaintr\n"));
sc = hdl;
+
+ mutex_spin_enter(&sc->sc_intr_lock);
+
if (sc->sc_pintr) {
/* start next transfer */
sc->sc_current.dmap += sc->sc_current.blksize;
@@ -281,6 +290,8 @@ vs_dmaintr(void *hdl)
printf("vs_dmaintr: spurious interrupt\n");
}
+ mutex_spin_exit(&sc->sc_intr_lock);
+
return 1;
}
@@ -617,38 +628,37 @@ vs_halt_input(void *hdl)
static int
vs_allocmem(struct vs_softc *sc, size_t size, size_t align, size_t boundary,
- int flags, struct vs_dma *vd)
+ struct vs_dma *vd)
{
- int error, wait;
+ int error;
#ifdef DIAGNOSTIC
if (size > DMAC_MAXSEGSZ)
panic ("vs_allocmem: maximum size exceeded, %d", (int) size);
#endif
- wait = (flags & M_NOWAIT) ? BUS_DMA_NOWAIT : BUS_DMA_WAITOK;
vd->vd_size = size;
error = bus_dmamem_alloc(vd->vd_dmat, vd->vd_size, align, boundary,
vd->vd_segs,
sizeof (vd->vd_segs) / sizeof (vd->vd_segs[0]),
- &vd->vd_nsegs, wait);
+ &vd->vd_nsegs, BUS_DMA_WAITOK);
if (error)
goto out;
error = bus_dmamem_map(vd->vd_dmat, vd->vd_segs, vd->vd_nsegs,
vd->vd_size, &vd->vd_addr,
- wait | BUS_DMA_COHERENT);
+ BUS_DMA_WAITOK | BUS_DMA_COHERENT);
if (error)
goto free;
error = bus_dmamap_create(vd->vd_dmat, vd->vd_size, 1, DMAC_MAXSEGSZ,
- 0, wait, &vd->vd_map);
+ 0, BUS_DMA_WAITOK, &vd->vd_map);
if (error)
goto unmap;
error = bus_dmamap_load(vd->vd_dmat, vd->vd_map, vd->vd_addr,
- vd->vd_size, NULL, wait);
+ vd->vd_size, NULL, BUS_DMA_WAITOK);
if (error)
goto destroy;
@@ -712,21 +722,20 @@ vs_query_devinfo(void *hdl, mixer_devinf
}
static void *
-vs_allocm(void *hdl, int direction, size_t size, struct malloc_type *type,
- int flags)
+vs_allocm(void *hdl, int direction, size_t size)
{
struct vs_softc *sc;
struct vs_dma *vd;
int error;
- if ((vd = malloc(size, type, flags)) == NULL)
+ if ((vd = kmem_alloc(sizeof(*vd), KM_SLEEP)) == NULL)
return NULL;
sc = hdl;
vd->vd_dmat = sc->sc_dmat;
- error = vs_allocmem(sc, size, 32, 0, flags, vd);
+ error = vs_allocmem(sc, size, 32, 0, vd);
if (error) {
- free(vd, type);
+ kmem_free(vd, sizeof(*vd));
return NULL;
}
vd->vd_next = sc->sc_dmas;
@@ -736,7 +745,7 @@ vs_allocm(void *hdl, int direction, size
}
static void
-vs_freem(void *hdl, void *addr, struct malloc_type *type)
+vs_freem(void *hdl, void *addr, size_t size)
{
struct vs_softc *sc;
struct vs_dma *p, **pp;
@@ -746,7 +755,7 @@ vs_freem(void *hdl, void *addr, struct m
if (KVADDR(p) == addr) {
vs_freemem(p);
*pp = p->vd_next;
- free(p, type);
+ kmem_free(p, sizeof(*p));
return;
}
}
@@ -792,4 +801,16 @@ vs_get_props(void *hdl)
DPRINTF(1, ("vs_get_props\n"));
return 0 /* | dependent | half duplex | no mmap */;
}
+
+static void
+vs_get_locks(void *hdl, kmutex_t **intr, kmutex_t **thread)
+{
+ struct vs_softc *sc;
+
+ DPRINTF(1, ("vs_get_locks\n"));
+ sc = hdl;
+ *intr = &sc->sc_intr_lock;
+ *thread = &sc->sc_lock;
+}
+
#endif /* NAUDIO > 0 && NVS > 0*/
Index: src/sys/arch/x68k/dev/vsvar.h
diff -u src/sys/arch/x68k/dev/vsvar.h:1.10 src/sys/arch/x68k/dev/vsvar.h:1.10.4.1
--- src/sys/arch/x68k/dev/vsvar.h:1.10 Sun Oct 16 03:10:18 2011
+++ src/sys/arch/x68k/dev/vsvar.h Sun Nov 20 16:18:15 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: vsvar.h,v 1.10 2011/10/16 03:10:18 isaki Exp $ */
+/* $NetBSD: vsvar.h,v 1.10.4.1 2011/11/20 16:18:15 jmcneill Exp $ */
/*
* Copyright (c) 2001 Tetsuya Isaki. All rights reserved.
@@ -76,6 +76,8 @@ struct vs_dma {
struct vs_softc {
device_t sc_dev;
+ kmutex_t sc_lock;
+ kmutex_t sc_intr_lock;
bus_space_tag_t sc_iot;
bus_space_handle_t sc_ioh;
Index: src/sys/dev/ic/msm6258.c
diff -u src/sys/dev/ic/msm6258.c:1.16 src/sys/dev/ic/msm6258.c:1.16.4.1
--- src/sys/dev/ic/msm6258.c:1.16 Sun Oct 16 03:10:18 2011
+++ src/sys/dev/ic/msm6258.c Sun Nov 20 16:18:15 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: msm6258.c,v 1.16 2011/10/16 03:10:18 isaki Exp $ */
+/* $NetBSD: msm6258.c,v 1.16.4.1 2011/11/20 16:18:15 jmcneill Exp $ */
/*
* Copyright (c) 2001 Tetsuya Isaki. All rights reserved.
@@ -30,11 +30,11 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: msm6258.c,v 1.16 2011/10/16 03:10:18 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: msm6258.c,v 1.16.4.1 2011/11/20 16:18:15 jmcneill Exp $");
#include <sys/systm.h>
#include <sys/device.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
#include <sys/select.h>
#include <sys/audioio.h>
@@ -51,7 +51,8 @@ struct msm6258_codecvar {
};
static stream_filter_t *msm6258_factory
- (int (*)(stream_fetcher_t *, audio_stream_t *, int));
+ (struct audio_softc *,
+ int (*)(struct audio_softc *, stream_fetcher_t *, audio_stream_t *, int));
static void msm6258_dtor(struct stream_filter *);
static inline uint8_t pcm2adpcm_step(struct msm6258_codecvar *, int16_t);
static inline int16_t adpcm2pcm_step(struct msm6258_codecvar *, uint8_t);
@@ -75,11 +76,12 @@ static const int adpcm_estimstep[16] = {
};
static stream_filter_t *
-msm6258_factory(int (*fetch_to)(stream_fetcher_t *, audio_stream_t *, int))
+msm6258_factory(struct audio_softc *asc,
+ int (*fetch_to)(struct audio_softc *, stream_fetcher_t *, audio_stream_t *, int))
{
struct msm6258_codecvar *this;
- this = malloc(sizeof(*this), M_DEVBUF, M_WAITOK | M_ZERO);
+ this = kmem_alloc(sizeof(struct msm6258_codecvar), KM_SLEEP);
this->base.base.fetch_to = fetch_to;
this->base.dtor = msm6258_dtor;
this->base.set_fetcher = stream_filter_set_fetcher;
@@ -91,7 +93,7 @@ static void
msm6258_dtor(struct stream_filter *this)
{
if (this != NULL)
- free(this, M_DEVBUF);
+ kmem_free(this, sizeof(struct msm6258_codecvar));
}
/*
@@ -132,15 +134,15 @@ pcm2adpcm_step(struct msm6258_codecvar *
#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 *sc, const audio_params_t *from, \
const audio_params_t *to) \
{ \
- return msm6258_factory(name##_fetch_to); \
+ return msm6258_factory(sc, 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 *asc, stream_fetcher_t *self, audio_stream_t *dst, int max_used)
DEFINE_FILTER(msm6258_slinear16_to_adpcm)
{
@@ -152,7 +154,7 @@ DEFINE_FILTER(msm6258_slinear16_to_adpcm
this = (stream_filter_t *)self;
mc = (struct msm6258_codecvar *)self;
- if ((err = this->prev->fetch_to(this->prev, this->src, max_used * 4)))
+ if ((err = this->prev->fetch_to(asc, this->prev, this->src, max_used * 4)))
return err;
m = dst->end - dst->start;
m = min(m, max_used);
@@ -215,7 +217,7 @@ DEFINE_FILTER(msm6258_linear8_to_adpcm)
this = (stream_filter_t *)self;
mc = (struct msm6258_codecvar *)self;
- if ((err = this->prev->fetch_to(this->prev, this->src, max_used * 2)))
+ if ((err = this->prev->fetch_to(asc, this->prev, this->src, max_used * 2)))
return err;
m = dst->end - dst->start;
m = min(m, max_used);
@@ -286,7 +288,7 @@ DEFINE_FILTER(msm6258_adpcm_to_slinear16
this = (stream_filter_t *)self;
mc = (struct msm6258_codecvar *)self;
max_used = (max_used + 3) & ~3; /* round up multiple of 4 */
- if ((err = this->prev->fetch_to(this->prev, this->src, max_used / 4)))
+ if ((err = this->prev->fetch_to(asc, this->prev, this->src, max_used / 4)))
return err;
m = (dst->end - dst->start) & ~3;
m = min(m, max_used);
@@ -352,7 +354,7 @@ DEFINE_FILTER(msm6258_adpcm_to_linear8)
this = (stream_filter_t *)self;
mc = (struct msm6258_codecvar *)self;
max_used = (max_used + 1) & ~1; /* round up multiple of 4 */
- if ((err = this->prev->fetch_to(this->prev, this->src, max_used / 2)))
+ if ((err = this->prev->fetch_to(asc, this->prev, this->src, max_used / 2)))
return err;
m = (dst->end - dst->start) & ~1;
m = min(m, max_used);