Module Name:    src
Committed By:   jmcneill
Date:           Sun Nov 20 14:26:34 UTC 2011

Modified Files:
        src/sys/arch/hpcmips/vr [jmcneill-audiomp3]: vraiu.c

Log Message:
adapt to audiomp api changes


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.12.80.1 src/sys/arch/hpcmips/vr/vraiu.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/hpcmips/vr/vraiu.c
diff -u src/sys/arch/hpcmips/vr/vraiu.c:1.12 src/sys/arch/hpcmips/vr/vraiu.c:1.12.80.1
--- src/sys/arch/hpcmips/vr/vraiu.c:1.12	Sun Mar  4 05:59:54 2007
+++ src/sys/arch/hpcmips/vr/vraiu.c	Sun Nov 20 14:26:34 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: vraiu.c,v 1.12 2007/03/04 05:59:54 christos Exp $	*/
+/*	$NetBSD: vraiu.c,v 1.12.80.1 2011/11/20 14:26:34 jmcneill Exp $	*/
 
 /*
  * Copyright (c) 2001 HAMAJIMA Katsuomi. All rights reserved.
@@ -26,12 +26,11 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vraiu.c,v 1.12 2007/03/04 05:59:54 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vraiu.c,v 1.12.80.1 2011/11/20 14:26:34 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/device.h>
-#include <sys/malloc.h>
 #include <sys/bswap.h>
 
 #include <machine/cpu.h>
@@ -61,6 +60,8 @@ int vraiu_debug = VRAIU_DEBUG;
 
 struct vraiu_softc {
 	struct device		sc_dev;
+	kmutex_t		sc_lock;
+	kmutex_t		sc_intr_lock;
 	bus_space_tag_t		sc_iot;
 	bus_space_handle_t	sc_ioh;
 	bus_dma_tag_t		sc_dmat;
@@ -116,6 +117,7 @@ int vraiu_query_devinfo(void *, mixer_de
 int vraiu_set_params(void *, int, int, audio_params_t *, audio_params_t *,
 		     stream_filter_list_t *, stream_filter_list_t *);
 int vraiu_get_props(void *);
+void vraiu_get_locks(void *, kmutex_t **, kmutex_t **);
 
 const struct audio_hw_if vraiu_hw_if = {
 	vraiu_open,
@@ -142,6 +144,11 @@ const struct audio_hw_if vraiu_hw_if = {
 	NULL,
 	NULL,
 	vraiu_get_props,
+	NULL,
+	NULL,
+	NULL,
+	NULL,
+	vraiu_get_locks,
 };
 
 /*
@@ -187,6 +194,8 @@ vraiu_attach(struct device *parent, stru
 	sc->sc_ac = va->va_ac;
 	sc->sc_dmat = &vrdcu_bus_dma_tag;
 	sc->sc_volume = 127;
+	mutex_init(&sc->sc_lock, MUTEX_DEFAULT, IPL_NONE);
+	mutex_init(&sc->sc_intr_lock, MUTEX_DEFAULT, IPL_SCHED);
 
 	if (!sc->sc_cc) {
 		printf(" not configured: cmu not found\n");
@@ -208,7 +217,7 @@ vraiu_attach(struct device *parent, stru
 
 	/* install interrupt handler and enable interrupt */
 	if (!(sc->sc_handler = vrip_intr_establish(va->va_vc, va->va_unit,
-	    0, IPL_AUDIO, vraiu_intr, sc))) {
+	    0, IPL_SCHED, vraiu_intr, sc))) {
 		printf(": can't map interrupt line.\n");
 		return;
 	}
@@ -221,19 +230,19 @@ vraiu_attach(struct device *parent, stru
 							 AIUINT_INTSIDLE), 0);
 
 	if (bus_dmamem_alloc(sc->sc_dmat, AUDIO_BUF_SIZE, 0, 0, &segs, 1,
-			     &rsegs, BUS_DMA_NOWAIT)) {
+			     &rsegs, BUS_DMA_WAITOK)) {
 		printf(": can't allocate memory.\n");
 		return;
 	}
 	if (bus_dmamem_map(sc->sc_dmat, &segs, rsegs, AUDIO_BUF_SIZE,
 			   (void **)&sc->sc_buf,
-			   BUS_DMA_NOWAIT | BUS_DMA_COHERENT)) {
+			   BUS_DMA_WAITOK | BUS_DMA_COHERENT)) {
 		printf(": can't map memory.\n");
 		bus_dmamem_free(sc->sc_dmat, &segs, rsegs);
 		return;
 	}
 	if (bus_dmamap_create(sc->sc_dmat, AUDIO_BUF_SIZE, 1, AUDIO_BUF_SIZE,
-			      0, BUS_DMA_NOWAIT, &sc->sc_dmap)) {
+			      0, BUS_DMA_WAITOK, &sc->sc_dmap)) {
 		printf(": can't create DMA map.\n");
 		bus_dmamem_unmap(sc->sc_dmat, (void *)sc->sc_buf,
 				 AUDIO_BUF_SIZE);
@@ -241,7 +250,7 @@ vraiu_attach(struct device *parent, stru
 		return;
 	}
 	if (bus_dmamap_load(sc->sc_dmat, sc->sc_dmap, sc->sc_buf,
-				   AUDIO_BUF_SIZE, NULL, BUS_DMA_NOWAIT)) {
+				   AUDIO_BUF_SIZE, NULL, BUS_DMA_WAITOK)) {
 		printf(": can't load DMA map.\n");
 		bus_dmamap_destroy(sc->sc_dmat, sc->sc_dmap);
 		bus_dmamem_unmap(sc->sc_dmat, (void *)sc->sc_buf,
@@ -626,6 +635,9 @@ vraiu_intr(void* self)
 
 	DPRINTFN(2, ("vraiu_intr"));
 	sc = self;
+
+	mutex_spin_enter(&sc->sc_intr_lock);
+
 	vrip_intr_setmask2(sc->sc_vrip, sc->sc_handler, AIUINT_INTSEND, 0);
 	vrip_intr_getstatus2(sc->sc_vrip, sc->sc_handler, &reg);
 	if (reg & AIUINT_INTSEND) {
@@ -639,6 +651,9 @@ vraiu_intr(void* self)
 		bus_space_write_2(sc->sc_iot, sc->sc_ioh, INT_REG_W, SENDINTR);
 	}
 	DPRINTFN(2, ("\n"));
+
+	mutex_spin_exit(&sc->sc_intr_lock);
+
 	return 0;
 }
 
@@ -757,6 +772,18 @@ vraiu_get_props(void *self)
 	return 0;
 }
 
+void
+vraiu_get_locks(void *self, kmutex_t **intr, kmutex_t **thread)
+{
+	struct vraiu_softc *sc;
+
+	DPRINTFN(3, ("vraiu_get_locks\n"));
+	sc = self;
+
+	*intr = &sc->sc_intr_lock;
+	*thread = &sc->sc_lock;
+}
+
 unsigned char mulaw_to_lin[] = {
 	0x02, 0x06, 0x0a, 0x0e, 0x12, 0x16, 0x1a, 0x1e,
 	0x22, 0x26, 0x2a, 0x2e, 0x32, 0x36, 0x3a, 0x3e,

Reply via email to