Source-Changes-HG archive

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

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



details:   https://anonhg.NetBSD.org/src/rev/3fa8148ecb21
branches:  jmcneill-audiomp3
changeset: 771344:3fa8148ecb21
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Sun Nov 20 12:07:27 2011 +0000

description:
adapt to audiomp api changes

diffstat:

 sys/arch/sgimips/hpc/haltwo.c    |  63 ++++++++++++++++++++++++++-------------
 sys/arch/sgimips/hpc/haltwovar.h |   4 +-
 2 files changed, 45 insertions(+), 22 deletions(-)

diffs (205 lines):

diff -r 5a3cf0420f20 -r 3fa8148ecb21 sys/arch/sgimips/hpc/haltwo.c
--- a/sys/arch/sgimips/hpc/haltwo.c     Sun Nov 20 12:07:13 2011 +0000
+++ b/sys/arch/sgimips/hpc/haltwo.c     Sun Nov 20 12:07:27 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: haltwo.c,v 1.20 2011/07/01 18:53:46 dyoung Exp $ */
+/* $NetBSD: haltwo.c,v 1.20.4.1 2011/11/20 12:07:27 jmcneill Exp $ */
 
 /*
  * Copyright (c) 2003 Ilpo Ruotsalainen
@@ -30,13 +30,13 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: haltwo.c,v 1.20 2011/07/01 18:53:46 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: haltwo.c,v 1.20.4.1 2011/11/20 12:07:27 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/device.h>
 #include <sys/audioio.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
 #include <dev/audio_if.h>
 #include <dev/auconv.h>
 #include <dev/mulaw.h>
@@ -68,13 +68,14 @@
 static int haltwo_set_port(void *, mixer_ctrl_t *);
 static int haltwo_get_port(void *, mixer_ctrl_t *);
 static int haltwo_query_devinfo(void *, mixer_devinfo_t *);
-static void *haltwo_malloc(void *, int, size_t, struct malloc_type *, int);
-static void haltwo_free(void *, void *, struct malloc_type *);
+static void *haltwo_malloc(void *, int, size_t);
+static void haltwo_free(void *, void *, size_t);
 static int haltwo_get_props(void *);
 static int haltwo_trigger_output(void *, void *, void *, int, void (*)(void *),
        void *, const audio_params_t *);
 static int haltwo_trigger_input(void *, void *, void *, int, void (*)(void *),
        void *, const audio_params_t *);
+static void haltwo_get_locks(void *, kmutex_t **, kmutex_t **);
 static bool haltwo_shutdown(device_t, int);
 
 static const struct audio_hw_if haltwo_hw_if = {
@@ -104,7 +105,9 @@
        haltwo_get_props,
        haltwo_trigger_output,
        haltwo_trigger_input,
-       NULL  /* dev_ioctl */
+       NULL, /* dev_ioctl */
+       NULL, /* powerstate */
+       haltwo_get_locks,
 };
 
 static const struct audio_device haltwo_device = {
@@ -300,6 +303,9 @@
        sc->sc_st = haa->ha_st;
        sc->sc_dma_tag = haa->ha_dmat;
 
+       mutex_init(&sc->sc_lock, MUTEX_DEFAULT, IPL_NONE);
+       mutex_init(&sc->sc_intr_lock, MUTEX_DEFAULT, IPL_SCHED);
+
        if (bus_space_subregion(haa->ha_st, haa->ha_sh, haa->ha_devoff,
            HPC3_PBUS_CH0_DEVREGS_SIZE, &sc->sc_ctl_sh)) {
                aprint_error(": unable to map control registers\n");
@@ -325,7 +331,7 @@
 
        rev = haltwo_read(sc, ctl, HAL2_REG_CTL_REV);
 
-       if (cpu_intr_establish(haa->ha_irq, IPL_AUDIO, haltwo_intr, sc)
+       if (cpu_intr_establish(haa->ha_irq, IPL_SCHED, haltwo_intr, sc)
            == NULL) {
                aprint_error(": unable to establish interrupt\n");
                return;
@@ -372,6 +378,9 @@
 
        sc = v;
        ret = 0;
+
+       mutex_spin_enter(&sc->sc_intr_lock);
+
        if (bus_space_read_4(sc->sc_st, sc->sc_dma_sh, HPC3_PBUS_CH0_CTL)
            & HPC3_PBUS_DMACTL_IRQ) {
                sc->sc_dac.intr(sc->sc_dac.intr_arg);
@@ -380,6 +389,8 @@
        } else
                DPRINTF(("haltwo_intr: Huh?\n"));
 
+       mutex_spin_exit(&sc->sc_intr_lock);
+
        return ret;
 }
 
@@ -637,26 +648,25 @@
        p->size = size;
 
        /* XXX Check align/boundary XXX */
-       /* XXX Pass flags and use them instead BUS_DMA_NOWAIT? XXX */
        err = bus_dmamem_alloc(sc->sc_dma_tag, p->size, 0, 0, p->dma_segs,
-           HALTWO_MAX_DMASEGS, &p->dma_segcount, BUS_DMA_NOWAIT);
+           HALTWO_MAX_DMASEGS, &p->dma_segcount, BUS_DMA_WAITOK);
        if (err)
                goto out;
 
        /* XXX BUS_DMA_COHERENT? XXX */
        err = bus_dmamem_map(sc->sc_dma_tag, p->dma_segs, p->dma_segcount,
-           p->size, &p->kern_addr, BUS_DMA_NOWAIT | BUS_DMA_COHERENT);
+           p->size, &p->kern_addr, BUS_DMA_WAITOK | BUS_DMA_COHERENT);
        if (err)
                goto out_free;
 
        /* XXX Just guessing ... XXX */
        err = bus_dmamap_create(sc->sc_dma_tag, p->size, HALTWO_MAX_DMASEGS,
-           PAGE_SIZE, 0, BUS_DMA_NOWAIT, &p->dma_map);
+           PAGE_SIZE, 0, BUS_DMA_WAITOK, &p->dma_map);
        if (err)
                goto out_free;
 
        err = bus_dmamap_load(sc->sc_dma_tag, p->dma_map, p->kern_addr,
-           p->size, NULL, BUS_DMA_NOWAIT);
+           p->size, NULL, BUS_DMA_WAITOK);
        if (err)
                goto out_destroy;
 
@@ -673,21 +683,20 @@
 }
 
 static void *
-haltwo_malloc(void *v, int direction, size_t size, struct malloc_type *type,
-               int flags)
+haltwo_malloc(void *v, int direction, size_t size)
 {
        struct haltwo_softc *sc;
        struct haltwo_dmabuf *p;
 
        DPRINTF(("haltwo_malloc size = %d\n", size));
        sc = v;
-       p = malloc(sizeof(struct haltwo_dmabuf), type, flags);
-       if (!p)
-               return 0;
+       p = kmem_alloc(sizeof(*p), KM_SLEEP);
+       if (p == NULL)
+               return NULL;
 
        if (haltwo_alloc_dmamem(sc, size, p)) {
-               free(p, type);
-               return 0;
+               kmem_free(p, sizeof(*p));
+               return NULL;
        }
 
        p->next = sc->sc_dma_bufs;
@@ -697,7 +706,7 @@
 }
 
 static void
-haltwo_free(void *v, void *addr, struct malloc_type *type)
+haltwo_free(void *v, void *addr, size_t size)
 {
        struct haltwo_softc *sc;
        struct haltwo_dmabuf *p, **pp;
@@ -706,7 +715,7 @@
        for (pp = &sc->sc_dma_bufs; (p = *pp) != NULL; pp = &p->next) {
                if (p->kern_addr == addr) {
                        *pp = p->next;
-                       free(p, type);
+                       kmem_free(p, sizeof(*p));
                        return;
                }
        }
@@ -815,6 +824,18 @@
        return ENXIO;
 }
 
+static void
+haltwo_get_locks(void *v, kmutex_t **intr, kmutex_t **thread)
+{
+       struct haltwo_softc *sc;
+
+       DPRINTF(("haltwo_get_locks\n"));
+       sc = v;
+
+       *intr = &sc->sc_intr_lock;
+       *thread = &sc->sc_lock;
+}
+
 bool
 haltwo_shutdown(device_t self, int howto)
 {
diff -r 5a3cf0420f20 -r 3fa8148ecb21 sys/arch/sgimips/hpc/haltwovar.h
--- a/sys/arch/sgimips/hpc/haltwovar.h  Sun Nov 20 12:07:13 2011 +0000
+++ b/sys/arch/sgimips/hpc/haltwovar.h  Sun Nov 20 12:07:27 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: haltwovar.h,v 1.7 2011/01/25 13:31:41 tsutsui Exp $ */
+/* $NetBSD: haltwovar.h,v 1.7.6.1 2011/11/20 12:07:27 jmcneill Exp $ */
 
 /*
  * Copyright (c) 2003 Ilpo Ruotsalainen
@@ -61,6 +61,8 @@
 
 struct haltwo_softc {
        device_t sc_dev;
+       kmutex_t sc_lock;
+       kmutex_t sc_intr_lock;
 
        bus_space_tag_t sc_st;
 



Home | Main Index | Thread Index | Old Index