Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/sparc Adapt to new am7930 driver. PR 10033 from Gr...
details: https://anonhg.NetBSD.org/src/rev/96e1f3c052f5
branches: trunk
changeset: 485612:96e1f3c052f5
user: augustss <augustss%NetBSD.org@localhost>
date: Tue May 02 06:35:12 2000 +0000
description:
Adapt to new am7930 driver. PR 10033 from Gregory McGarry.
diffstat:
sys/arch/sparc/conf/files.sparc | 11 +-
sys/arch/sparc/dev/audioamd.c | 521 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 527 insertions(+), 5 deletions(-)
diffs (truncated from 550 to 300 lines):
diff -r 1398e2e403db -r 96e1f3c052f5 sys/arch/sparc/conf/files.sparc
--- a/sys/arch/sparc/conf/files.sparc Tue May 02 06:30:49 2000 +0000
+++ b/sys/arch/sparc/conf/files.sparc Tue May 02 06:35:12 2000 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: files.sparc,v 1.90 2000/03/19 14:19:17 pk Exp $
+# $NetBSD: files.sparc,v 1.91 2000/05/02 06:35:12 augustss Exp $
# @(#)files.sparc 8.1 (Berkeley) 7/19/93
# sparc-specific configuration info
@@ -146,10 +146,11 @@
attach esp at obio with esp_obio
file arch/sparc/dev/esp_obio.c esp_obio
-attach audioamd at mainbus with audioamd_mainbus
-attach audioamd at sbus with audioamd_sbus
-file arch/sparc/dev/am7930_sparc.c audioamd
-file arch/sparc/sparc/amd7930intr.s audioamd
+device audioamd: audio, am7930
+attach audioamd at mainbus with audioamd_mainbus
+attach audioamd at sbus with audioamd_sbus
+file arch/sparc/dev/audioamd.c audioamd
+file arch/sparc/sparc/am7930intr.s audioamd
# Brooktree DAC attribute
define bt_dac
diff -r 1398e2e403db -r 96e1f3c052f5 sys/arch/sparc/dev/audioamd.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/sparc/dev/audioamd.c Tue May 02 06:35:12 2000 +0000
@@ -0,0 +1,521 @@
+/* $NetBSD: audioamd.c,v 1.1 2000/05/02 06:35:14 augustss Exp $ */
+/* NetBSD: am7930_sparc.c,v 1.44 1999/03/14 22:29:00 jonathan Exp */
+
+/*
+ * Copyright (c) 1995 Rolf Grossmann
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Rolf Grossmann.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "audio.h"
+#if NAUDIO > 0
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/errno.h>
+#include <sys/device.h>
+
+#include <machine/bus.h>
+#include <machine/autoconf.h>
+#include <machine/cpu.h>
+
+#include <sys/audioio.h>
+#include <dev/audio_if.h>
+
+#include <dev/ic/am7930reg.h>
+#include <dev/ic/am7930var.h>
+
+#define AUDIO_ROM_NAME "audio"
+
+#ifdef AUDIO_DEBUG
+#define DPRINTF(x) if (am7930debug) printf x
+#define DPRINTFN(n,x) if (am7930debug>(n)) printf x
+#else
+#define DPRINTF(x)
+#define DPRINTFN(n,x)
+#endif /* AUDIO_DEBUG */
+
+
+/* interrupt interfaces */
+#ifdef AUDIO_C_HANDLER
+int am7930hwintr __P((void *));
+#if defined(SUN4M)
+#define AUDIO_SET_SWINTR do { \
+ if (CPU_ISSUN4M) \
+ raise(0, 4); \
+ else \
+ ienab_bis(IE_L4); \
+} while(0);
+#else
+#define AUDIO_SET_SWINTR ienab_bis(IE_L4)
+#endif /* defined(SUN4M) */
+#else
+struct auio *auiop;
+#endif /* AUDIO_C_HANDLER */
+int am7930swintr __P((void *));
+
+/*
+ * pdma state
+ */
+struct auio {
+ bus_space_tag_t au_bt; /* bus tag */
+ bus_space_handle_t au_bh; /* handle to chip registers */
+
+ u_int8_t *au_rdata; /* record data */
+ u_int8_t *au_rend; /* end of record data */
+ u_int8_t *au_pdata; /* play data */
+ u_int8_t *au_pend; /* end of play data */
+ struct evcnt au_intrcnt; /* statistics */
+};
+
+/*
+ * interrupt-handler status
+ */
+struct am7930_intrhand {
+ int (*ih_fun) __P((void *));
+ void *ih_arg;
+};
+
+struct audioamd_softc {
+ struct am7930_softc sc_am7930; /* glue to MI code */
+
+ bus_space_tag_t sc_bt; /* bus cookie */
+ bus_space_handle_t sc_bh; /* device registers */
+
+ struct am7930_intrhand sc_ih; /* interrupt vector (hw or sw) */
+ void (*sc_rintr)(void*); /* input completion intr handler */
+ void *sc_rarg; /* arg for sc_rintr() */
+ void (*sc_pintr)(void*); /* output completion intr handler */
+ void *sc_parg; /* arg for sc_pintr() */
+
+ /* sc_au is special in that the hardware interrupt handler uses it */
+ struct auio sc_au; /* recv and xmit buffers, etc */
+#define sc_intrcnt sc_au.au_intrcnt /* statistics */
+};
+
+void audioamd_mainbus_attach __P((struct device *,
+ struct device *, void *));
+int audioamd_mainbus_match __P((struct device *, struct cfdata *, void *));
+void audioamd_sbus_attach __P((struct device *, struct device *, void *));
+int audioamd_sbus_match __P((struct device *, struct cfdata *, void *));
+void audioamd_attach(struct audioamd_softc *sc, int);
+
+struct cfattach audioamd_mainbus_ca = {
+ sizeof(struct audioamd_softc),
+ audioamd_mainbus_match,
+ audioamd_mainbus_attach
+};
+
+struct cfattach audioamd_sbus_ca = {
+ sizeof(struct audioamd_softc),
+ audioamd_sbus_match,
+ audioamd_sbus_attach
+};
+
+/*
+ * Define our interface into the am7930 MI driver.
+ */
+
+u_int8_t audioamd_codec_iread __P((struct am7930_softc *, int));
+u_int16_t audioamd_codec_iread16 __P((struct am7930_softc *, int));
+void audioamd_codec_iwrite __P((struct am7930_softc *, int, u_int8_t));
+void audioamd_codec_iwrite16 __P((struct am7930_softc *, int, u_int16_t));
+void audioamd_onopen __P((struct am7930_softc *sc));
+void audioamd_onclose __P((struct am7930_softc *sc));
+
+struct am7930_glue audioamd_glue = {
+ audioamd_codec_iread,
+ audioamd_codec_iwrite,
+ audioamd_codec_iread16,
+ audioamd_codec_iwrite16,
+ audioamd_onopen,
+ audioamd_onclose,
+ 0,
+ 0,
+ 0,
+};
+
+/*
+ * Define our interface to the higher level audio driver.
+ */
+int audioamd_start_output __P((void *, void *, int, void (*)(void *),
+ void *));
+int audioamd_start_input __P((void *, void *, int, void (*)(void *),
+ void *));
+
+struct audio_hw_if sa_hw_if = {
+ am7930_open,
+ am7930_close,
+ 0,
+ am7930_query_encoding,
+ am7930_set_params,
+ am7930_round_blocksize,
+ am7930_commit_settings,
+ 0,
+ 0,
+ audioamd_start_output, /* md */
+ audioamd_start_input, /* md */
+ am7930_halt_output,
+ am7930_halt_input,
+ 0,
+ audioamd_getdev,
+ 0,
+ am7930_set_port,
+ am7930_get_port,
+ am7930_query_devinfo,
+ 0,
+ 0,
+ 0,
+ 0,
+ am7930_get_props,
+};
+
+struct audio_device audioamd_device = {
+ "am7930",
+ "x",
+ "audioamd"
+};
+
+
+int
+audioamd_mainbus_match(parent, cf, aux)
+ struct device *parent;
+ struct cfdata *cf;
+ void *aux;
+{
+ struct mainbus_attach_args *ma = aux;
+
+ if (CPU_ISSUN4)
+ return (0);
+ return (strcmp(AUDIO_ROM_NAME, ma->ma_name) == 0);
+}
+
+int
+audioamd_sbus_match(parent, cf, aux)
+ struct device *parent;
+ struct cfdata *cf;
+ void *aux;
+{
+ struct sbus_attach_args *sa = aux;
+
+ return (strcmp(AUDIO_ROM_NAME, sa->sa_name) == 0);
+}
+
+void
+audioamd_mainbus_attach(parent, self, aux)
+ struct device *parent, *self;
+ void *aux;
+{
+ struct mainbus_attach_args *ma = aux;
+ struct audioamd_softc *sc = (struct audioamd_softc *)self;
+ bus_space_handle_t bh;
+
+ sc->sc_bt = ma->ma_bustag;
+
+ if (bus_space_map2(
+ ma->ma_bustag,
+ ma->ma_iospace,
+ ma->ma_paddr,
+ sizeof(struct am7930),
+ BUS_SPACE_MAP_LINEAR,
+ 0,
+ &bh) != 0) {
+ printf("%s: cannot map registers\n", self->dv_xname);
+ return;
+ }
+ sc->sc_bh = bh;
+ audioamd_attach(sc, ma->ma_pri);
+}
+
+
+void
+audioamd_sbus_attach(parent, self, aux)
+ struct device *parent, *self;
+ void *aux;
+{
+ struct sbus_attach_args *sa = aux;
+ struct audioamd_softc *sc = (struct audioamd_softc *)self;
+ bus_space_handle_t bh;
+
+ sc->sc_bt = sa->sa_bustag;
+
+ if (sbus_bus_map(
+ sa->sa_bustag,
+ sa->sa_slot,
+ sa->sa_offset,
+ sizeof(struct am7930),
+ 0, 0,
Home |
Main Index |
Thread Index |
Old Index