Module Name:    src
Committed By:   jmcneill
Date:           Sun Nov 20 12:07:27 UTC 2011

Modified Files:
        src/sys/arch/sgimips/hpc [jmcneill-audiomp3]: haltwo.c haltwovar.h

Log Message:
adapt to audiomp api changes


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.20.4.1 src/sys/arch/sgimips/hpc/haltwo.c
cvs rdiff -u -r1.7 -r1.7.6.1 src/sys/arch/sgimips/hpc/haltwovar.h

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/sgimips/hpc/haltwo.c
diff -u src/sys/arch/sgimips/hpc/haltwo.c:1.20 src/sys/arch/sgimips/hpc/haltwo.c:1.20.4.1
--- src/sys/arch/sgimips/hpc/haltwo.c:1.20	Fri Jul  1 18:53:46 2011
+++ src/sys/arch/sgimips/hpc/haltwo.c	Sun Nov 20 12:07:27 2011
@@ -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_getdev(void *, struct 
 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 @@ static const struct audio_hw_if haltwo_h
 	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 @@ haltwo_attach(device_t parent, device_t 
 	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 @@ haltwo_attach(device_t parent, device_t 
 
 	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 @@ haltwo_intr(void *v)
 
 	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 @@ haltwo_intr(void *v)
 	} else
 		DPRINTF(("haltwo_intr: Huh?\n"));
 
+	mutex_spin_exit(&sc->sc_intr_lock);
+
 	return ret;
 }
 
@@ -637,26 +648,25 @@ haltwo_alloc_dmamem(struct haltwo_softc 
 	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 @@ out:
 }
 
 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 @@ haltwo_malloc(void *v, int direction, si
 }
 
 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 @@ haltwo_free(void *v, void *addr, struct 
 	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 @@ haltwo_trigger_input(void *v, void *star
 	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)
 {

Index: src/sys/arch/sgimips/hpc/haltwovar.h
diff -u src/sys/arch/sgimips/hpc/haltwovar.h:1.7 src/sys/arch/sgimips/hpc/haltwovar.h:1.7.6.1
--- src/sys/arch/sgimips/hpc/haltwovar.h:1.7	Tue Jan 25 13:31:41 2011
+++ src/sys/arch/sgimips/hpc/haltwovar.h	Sun Nov 20 12:07:27 2011
@@ -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_codec {
 
 struct haltwo_softc {
 	device_t sc_dev;
+	kmutex_t sc_lock;
+	kmutex_t sc_intr_lock;
 
 	bus_space_tag_t sc_st;
 

Reply via email to