Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/jmcneill-audiomp3]: src/sys adapt to audiomp api changes



details:   https://anonhg.NetBSD.org/src/rev/2aa267053ecd
branches:  jmcneill-audiomp3
changeset: 771371:2aa267053ecd
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Sun Nov 20 16:18:15 2011 +0000

description:
adapt to audiomp api changes

diffstat:

 sys/arch/x68k/dev/vs.c    |  59 +++++++++++++++++++++++++++++++---------------
 sys/arch/x68k/dev/vsvar.h |   4 ++-
 sys/dev/ic/msm6258.c      |  30 ++++++++++++-----------
 3 files changed, 59 insertions(+), 34 deletions(-)

diffs (truncated from 321 to 300 lines):

diff -r 9b1d9915e8d4 -r 2aa267053ecd sys/arch/x68k/dev/vs.c
--- a/sys/arch/x68k/dev/vs.c    Sun Nov 20 16:07:27 2011 +0000
+++ b/sys/arch/x68k/dev/vs.c    Sun Nov 20 16:18:15 2011 +0000
@@ -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 @@
 #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 @@
        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 @@
        vs_trigger_output,
        vs_trigger_input,
        NULL,
+       NULL,
+       vs_get_locks,
 };
 
 static struct audio_device vs_device = {
@@ -229,6 +233,8 @@
        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 @@
 
        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 @@
                printf("vs_dmaintr: spurious interrupt\n");
        }
 
+       mutex_spin_exit(&sc->sc_intr_lock);
+
        return 1;
 }
 
@@ -617,38 +628,37 @@
 
 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 @@
 }
 
 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 @@
 }
 
 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 @@
                if (KVADDR(p) == addr) {
                        vs_freemem(p);
                        *pp = p->vd_next;
-                       free(p, type);
+                       kmem_free(p, sizeof(*p));
                        return;
                }
        }
@@ -792,4 +801,16 @@
        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*/
diff -r 9b1d9915e8d4 -r 2aa267053ecd sys/arch/x68k/dev/vsvar.h
--- a/sys/arch/x68k/dev/vsvar.h Sun Nov 20 16:07:27 2011 +0000
+++ b/sys/arch/x68k/dev/vsvar.h Sun Nov 20 16:18:15 2011 +0000
@@ -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_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;
diff -r 9b1d9915e8d4 -r 2aa267053ecd sys/dev/ic/msm6258.c
--- a/sys/dev/ic/msm6258.c      Sun Nov 20 16:07:27 2011 +0000
+++ b/sys/dev/ic/msm6258.c      Sun Nov 20 16:18:15 2011 +0000
@@ -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 @@
 };
 
 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 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 @@
 msm6258_dtor(struct stream_filter *this)
 {
        if (this != NULL)
-               free(this, M_DEVBUF);
+               kmem_free(this, sizeof(struct msm6258_codecvar));
 }
 
 /*
@@ -132,15 +134,15 @@
 
 #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 @@
 
        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 @@
 
        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)))



Home | Main Index | Thread Index | Old Index