Source-Changes-HG archive

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

[src/trunk]: src/sys/dev split sbus audiocs code up so we can share it with t...



details:   https://anonhg.NetBSD.org/src/rev/c6c1030fcb04
branches:  trunk
changeset: 473489:c6c1030fcb04
user:      mrg <mrg%NetBSD.org@localhost>
date:      Sat Jun 05 14:29:10 1999 +0000

description:
split sbus audiocs code up so we can share it with the ebus.  XXX ebus DMA is probably different.

diffstat:

 sys/dev/ic/apcdmareg.h     |  111 +++++
 sys/dev/ic/cs4231.c        |  825 ++++++++++++++++++++++++++++++++++++++++
 sys/dev/ic/cs4231var.h     |   71 +++
 sys/dev/sbus/cs4231_sbus.c |  928 +--------------------------------------------
 sys/dev/sbus/files.sbus    |    7 +-
 5 files changed, 1022 insertions(+), 920 deletions(-)

diffs (truncated from 2012 to 300 lines):

diff -r 0996e77eedbc -r c6c1030fcb04 sys/dev/ic/apcdmareg.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/dev/ic/apcdmareg.h    Sat Jun 05 14:29:10 1999 +0000
@@ -0,0 +1,111 @@
+/*     $NetBSD: apcdmareg.h,v 1.1 1999/06/05 14:29:10 mrg Exp $        */
+
+/*-
+ * Copyright (c) 1998, 1999 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Paul Kranenburg.
+ *
+ * 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 the NetBSD
+ *        Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``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 FOUNDATION OR CONTRIBUTORS
+ * 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.
+ */
+
+/*
+ * APC DMA hardware; from SunOS header
+ * Thanks to Derrick J. Brashear for additional info on the
+ * meaning of some of these bits.
+ */
+struct apc_dma {
+       volatile u_int32_t dmacsr;      /* APC CSR */
+       volatile u_int32_t lpad[3];     /* */
+       volatile u_int32_t dmacva;      /* Capture Virtual Address */
+       volatile u_int32_t dmacc;       /* Capture Count */
+       volatile u_int32_t dmacnva;     /* Capture Next Virtual Address */
+       volatile u_int32_t dmacnc;      /* Capture next count */
+       volatile u_int32_t dmapva;      /* Playback Virtual Address */
+       volatile u_int32_t dmapc;       /* Playback Count */
+       volatile u_int32_t dmapnva;     /* Playback Next VAddress */
+       volatile u_int32_t dmapnc;      /* Playback Next Count */
+};
+
+/*
+ * APC CSR Register bit definitions
+ */
+#define        APC_IP          0x00800000      /* Interrupt Pending */
+#define        APC_PI          0x00400000      /* Playback interrupt */
+#define        APC_CI          0x00200000      /* Capture interrupt */
+#define        APC_EI          0x00100000      /* General interrupt */
+#define        APC_IE          0x00080000      /* General ext int. enable */
+#define        APC_PIE         0x00040000      /* Playback ext intr */
+#define        APC_CIE         0x00020000      /* Capture ext intr */
+#define        APC_EIE         0x00010000      /* Error ext intr */
+#define        APC_PMI         0x00008000      /* Pipe empty interrupt */
+#define        APC_PM          0x00004000      /* Play pipe empty */
+#define        APC_PD          0x00002000      /* Playback NVA dirty */
+#define        APC_PMIE        0x00001000      /* play pipe empty Int enable */
+#define        APC_CM          0x00000800      /* Cap data dropped on floor */
+#define        APC_CD          0x00000400      /* Capture NVA dirty */
+#define        APC_CMI         0x00000200      /* Capture pipe empty interrupt */
+#define        APC_CMIE        0x00000100      /* Cap. pipe empty int enable */
+#define        APC_PPAUSE      0x00000080      /* Pause the play DMA */
+#define        APC_CPAUSE      0x00000040      /* Pause the capture DMA */
+#define        APC_CODEC_PDN   0x00000020      /* CODEC RESET */
+#define        PDMA_GO         0x00000008
+#define        CDMA_GO         0x00000004      /* bit 2 of the csr */
+#define        APC_RESET       0x00000001      /* Reset the chip */
+
+#define APC_BITS                                       \
+       "\20\30IP\27PI\26CI\25EI\24IE"                  \
+       "\23PIE\22CIE\21EIE\20PMI\17PM\16PD\15PMIE"     \
+       "\14CM\13CD\12CMI\11CMIE\10PPAUSE\7CPAUSE\6PDN\4PGO\3CGO"
+
+/*
+ * To start DMA, you write to dma[cp]nva and dma[cp]nc and set [CP]DMA_GO
+ * in dmacsr. dma[cp]va and dma[cp]c, when read, appear to be the live
+ * counter as the DMA operation progresses.
+ * Supposedly, you get an interrupt with the "dirty" bits (APC_PD,APC_CD)
+ * set, when the next DMA buffer can be programmed, while the current one
+ * is still in progress. We don't currently use this feature, since I
+ * haven't been able to make it work.. instead the next buffer goes in
+ * as soon as we see a "pipe empty" (APC_PM) interrupt.
+ */
+
+/* It's not clear if there's a maximum DMA size.. */
+#define APC_MAX                (sc->sc_blksz)/*(16*1024)*/
+
+/*
+ * List of device memory allocations (see cs4231_malloc/cs4231_free).
+ */
+struct cs_dma {
+       struct  cs_dma *next;
+       caddr_t addr;
+       bus_dma_segment_t segs[1];
+       int     nsegs;
+       size_t  size;
+};
diff -r 0996e77eedbc -r c6c1030fcb04 sys/dev/ic/cs4231.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/dev/ic/cs4231.c       Sat Jun 05 14:29:10 1999 +0000
@@ -0,0 +1,825 @@
+/*     $NetBSD: cs4231.c,v 1.1 1999/06/05 14:29:10 mrg Exp $   */
+
+/*-
+ * Copyright (c) 1998, 1999 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Paul Kranenburg.
+ *
+ * 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 the NetBSD
+ *        Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``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 FOUNDATION OR CONTRIBUTORS
+ * 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 <sys/malloc.h>
+
+#include <machine/autoconf.h>
+#include <machine/cpu.h>
+
+#include <sys/audioio.h>
+#include <dev/audio_if.h>
+
+#include <dev/ic/ad1848reg.h>
+#include <dev/ic/cs4231reg.h>
+#include <dev/ic/ad1848var.h>
+#include <dev/ic/cs4231var.h>
+#include <dev/ic/apcdmareg.h>
+
+/*---*/
+#define CSAUDIO_DAC_LVL                0
+#define CSAUDIO_LINE_IN_LVL    1
+#define CSAUDIO_MONO_LVL       2
+#define CSAUDIO_CD_LVL         3
+#define CSAUDIO_MONITOR_LVL    4
+#define CSAUDIO_OUT_LVL                5
+#define CSAUDIO_LINE_IN_MUTE   6
+#define CSAUDIO_DAC_MUTE       7
+#define CSAUDIO_CD_MUTE                8
+#define CSAUDIO_MONO_MUTE      9
+#define CSAUDIO_MONITOR_MUTE   10
+#define CSAUDIO_REC_LVL                11
+#define CSAUDIO_RECORD_SOURCE  12
+
+#define CSAUDIO_INPUT_CLASS    13
+#define CSAUDIO_OUTPUT_CLASS   14
+#define CSAUDIO_RECORD_CLASS   15
+#define CSAUDIO_MONITOR_CLASS  16
+
+#ifdef AUDIO_DEBUG
+int     cs4231debug = 0;
+#define DPRINTF(x)      if (cs4231debug) printf x
+#else
+#define DPRINTF(x)
+#endif
+
+struct audio_device cs4231_device = {
+       "cs4231",
+       "x",
+       "audio"
+};
+
+
+/*
+ * Define our interface to the higher level audio driver.
+ */
+int    cs4231_open __P((void *, int));
+void   cs4231_close __P((void *));
+size_t cs4231_round_buffersize __P((void *, int, size_t));
+int    cs4231_round_blocksize __P((void *, int));
+int    cs4231_halt_output __P((void *));
+int    cs4231_halt_input __P((void *));
+int    cs4231_getdev __P((void *, struct audio_device *));
+int    cs4231_set_port __P((void *, mixer_ctrl_t *));
+int    cs4231_get_port __P((void *, mixer_ctrl_t *));
+int    cs4231_query_devinfo __P((void *, mixer_devinfo_t *));
+int    cs4231_get_props __P((void *));
+
+void   *cs4231_malloc __P((void *, int, size_t, int, int));
+void   cs4231_free __P((void *, void *, int));
+int    cs4231_trigger_output __P((void *, void *, void *, int,
+                                  void (*)(void *), void *,
+                                  struct audio_params *));
+int    cs4231_trigger_input __P((void *, void *, void *, int,
+                                 void (*)(void *), void *,
+                                 struct audio_params *));
+
+#ifdef AUDIO_DEBUG
+static void    cs4231_regdump __P((char *, struct cs4231_softc *));
+#endif
+
+int
+cs4231_read(sc, index)
+       struct ad1848_softc     *sc;
+       int                     index;
+{
+       return bus_space_read_1(sc->sc_iot, sc->sc_ioh, (index << 2));
+}
+
+void
+cs4231_write(sc, index, value)
+       struct ad1848_softc     *sc;
+       int                     index, value;
+{
+       bus_space_write_1(sc->sc_iot, sc->sc_ioh, (index << 2), value);
+}
+
+struct audio_hw_if audiocs_hw_if = {
+       cs4231_open,
+       cs4231_close,
+       0,
+       ad1848_query_encoding,
+       ad1848_set_params,
+       cs4231_round_blocksize,
+       ad1848_commit_settings,
+       0,
+       0,
+       NULL,
+       NULL,
+       cs4231_halt_output,
+       cs4231_halt_input,
+       0,
+       cs4231_getdev,
+       0,
+       cs4231_set_port,
+       cs4231_get_port,
+       cs4231_query_devinfo,
+       cs4231_malloc,
+       cs4231_free,
+       cs4231_round_buffersize,
+        0,
+       cs4231_get_props,
+       cs4231_trigger_output,
+       cs4231_trigger_input
+};
+
+
+#ifdef AUDIO_DEBUG
+static void
+cs4231_regdump(label, sc)
+       char *label;
+       struct cs4231_softc *sc;
+{
+       char bits[128];
+       volatile struct apc_dma *dma = sc->sc_dmareg;
+
+       printf("cs4231regdump(%s): regs:", label);
+       printf("dmapva: 0x%x; ", dma->dmapva);
+       printf("dmapc: 0x%x; ", dma->dmapc);
+       printf("dmapnva: 0x%x; ", dma->dmapnva);
+       printf("dmapnc: 0x%x\n", dma->dmapnc);



Home | Main Index | Thread Index | Old Index