Module Name:    src
Committed By:   mrg
Date:           Sun Nov 20 12:58:45 UTC 2011

Modified Files:
        src/sys/arch/arm/iomd [jmcneill-audiomp3]: vidcaudio.c

Log Message:
port to audiomp: get_locks support, stream filter updates, remove IPL_AUDIO

not run time tested.


To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.46.40.1 src/sys/arch/arm/iomd/vidcaudio.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/arm/iomd/vidcaudio.c
diff -u src/sys/arch/arm/iomd/vidcaudio.c:1.46 src/sys/arch/arm/iomd/vidcaudio.c:1.46.40.1
--- src/sys/arch/arm/iomd/vidcaudio.c:1.46	Sat Mar  1 16:17:47 2008
+++ src/sys/arch/arm/iomd/vidcaudio.c	Sun Nov 20 12:58:45 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: vidcaudio.c,v 1.46 2008/03/01 16:17:47 chris Exp $	*/
+/*	$NetBSD: vidcaudio.c,v 1.46.40.1 2011/11/20 12:58:45 mrg Exp $	*/
 
 /*
  * Copyright (c) 1995 Melvin Tang-Richardson
@@ -65,7 +65,7 @@
 
 #include <sys/param.h>	/* proc.h */
 
-__KERNEL_RCSID(0, "$NetBSD: vidcaudio.c,v 1.46 2008/03/01 16:17:47 chris Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vidcaudio.c,v 1.46.40.1 2011/11/20 12:58:45 mrg Exp $");
 
 #include <sys/audioio.h>
 #include <sys/conf.h>   /* autoconfig functions */
@@ -120,6 +120,9 @@ struct vidcaudio_softc {
 	void	(*sc_pintr)(void *);
 	void	*sc_parg;
 	int	sc_pcountdown;
+
+	kmutex_t	sc_lock;
+	kmutex_t	sc_intr_lock;
 };
 
 static int  vidcaudio_probe(struct device *, struct cfdata *, void *);
@@ -132,8 +135,9 @@ static void vidcaudio_ctrl(int);
 static void vidcaudio_stereo(int, int);
 static stream_filter_factory_t mulaw_to_vidc;
 static stream_filter_factory_t mulaw_to_vidc_stereo;
-static int mulaw_to_vidc_fetch_to(stream_fetcher_t *, audio_stream_t *, int);
-static int mulaw_to_vidc_stereo_fetch_to(stream_fetcher_t *,
+static int mulaw_to_vidc_fetch_to(struct audio_softc *, stream_fetcher_t *,
+    audio_stream_t *, int);
+static int mulaw_to_vidc_stereo_fetch_to(struct audio_softc *, stream_fetcher_t *,
     audio_stream_t *, int);
 
 CFATTACH_DECL(vidcaudio, sizeof(struct vidcaudio_softc),
@@ -154,6 +158,7 @@ static int    vidcaudio_set_port(void *,
 static int    vidcaudio_get_port(void *, mixer_ctrl_t *);
 static int    vidcaudio_query_devinfo(void *, mixer_devinfo_t *);
 static int    vidcaudio_get_props(void *);
+static void   vidcaudio_get_locks(void *, kmutex_t **, kmutex_t **);
 
 static struct audio_device vidcaudio_device = {
 	"ARM VIDC",
@@ -189,6 +194,8 @@ static const struct audio_hw_if vidcaudi
 	vidcaudio_trigger_output,
 	vidcaudio_trigger_input,
 	NULL,
+	NULL,
+	vidcaudio_get_locks,
 };
 
 static int
@@ -240,10 +247,13 @@ vidcaudio_attach(struct device *parent, 
 	else
 		aprint_normal(": 8-bit internal DAC\n");
 
+	mutex_init(&sc->sc_lock, MUTEX_DEFAULT, IPL_NONE);
+	mutex_init(&sc->sc_intr_lock, MUTEX_DEFAULT, IPL_SCHED);
+
 	/* Install the irq handler for the DMA interrupt */
 	sc->sc_ih.ih_func = vidcaudio_intr;
 	sc->sc_ih.ih_arg = sc;
-	sc->sc_ih.ih_level = IPL_AUDIO;
+	sc->sc_ih.ih_level = IPL_SCHED;
 	sc->sc_ih.ih_name = self->dv_xname;
 
 	if (irq_claim(sc->sc_dma_intr, &sc->sc_ih) != 0) {
@@ -322,13 +332,14 @@ mulaw_to_vidc(struct audio_softc *sc, co
 }
 
 static int
-mulaw_to_vidc_fetch_to(stream_fetcher_t *self, audio_stream_t *dst, int max_used)
+mulaw_to_vidc_fetch_to(struct audio_softc *sc, stream_fetcher_t *self,
+		       audio_stream_t *dst, int max_used)
 {
 	stream_filter_t *this;
 	int m, err;
 
 	this = (stream_filter_t *)self;
-	if ((err = this->prev->fetch_to(this->prev, this->src, max_used)))
+	if ((err = this->prev->fetch_to(sc, this->prev, this->src, max_used)))
 		return err;
 	m = dst->end - dst->start;
 	m = min(m, max_used);
@@ -347,15 +358,15 @@ mulaw_to_vidc_stereo(struct audio_softc 
 }
 
 static int
-mulaw_to_vidc_stereo_fetch_to(stream_fetcher_t *self, audio_stream_t *dst,
-			      int max_used)
+mulaw_to_vidc_stereo_fetch_to(struct audio_softc *sc, stream_fetcher_t *self,
+			      audio_stream_t *dst, int max_used)
 {
 	stream_filter_t *this;
 	int m, err;
 
 	this = (stream_filter_t *)self;
 	max_used = (max_used + 1) & ~1;
-	if ((err = this->prev->fetch_to(this->prev, this->src, max_used / 2)))
+	if ((err = this->prev->fetch_to(sc, this->prev, this->src, max_used / 2)))
 		return err;
 	m = (dst->end - dst->start) & ~1;
 	m = min(m, max_used);
@@ -556,6 +567,15 @@ vidcaudio_get_props(void *addr)
 }
 
 static void
+vidcaudio_get_locks(void *opaque, kmutex_t **intr, kmutex_t **thread)
+{
+	struct vidcaudio_softc *sc = opaque;
+
+	*intr = &sc->sc_intr_lock;
+	*thread = &sc->sc_lock;
+}
+
+static void
 vidcaudio_rate(int rate)
 {
 
@@ -585,10 +605,14 @@ vidcaudio_intr(void *arg)
 	paddr_t pnext, pend;
 
 	sc = arg;
+	mutex_spin_enter(&sc->sc_intr_lock);
+
 	status = IOMD_READ_BYTE(IOMD_SD0ST);
 	DPRINTF(("I[%x]", status));
-	if ((status & IOMD_DMAST_INT) == 0)
+	if ((status & IOMD_DMAST_INT) == 0) {
+		mutex_spin_exit(&sc->sc_intr_lock);
 		return 0;
+	}
 
 	pnext = sc->sc_ppages[sc->sc_poffset >> PGSHIFT] |
 	    (sc->sc_poffset & PGOFSET);
@@ -621,5 +645,6 @@ vidcaudio_intr(void *arg)
 	else
 		(*sc->sc_pintr)(sc->sc_parg);
 
+	mutex_spin_exit(&sc->sc_intr_lock);
 	return 1;
 }

Reply via email to