Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/pci add Trident 4DWAVE based (4DWAVE DX/NX, SiS 7018, ...



details:   https://anonhg.NetBSD.org/src/rev/1ac5a6260bb7
branches:  trunk
changeset: 517718:1ac5a6260bb7
user:      someya <someya%NetBSD.org@localhost>
date:      Sun Nov 18 03:16:02 2001 +0000

description:
add Trident 4DWAVE based (4DWAVE DX/NX,SiS 7018,ALi M5451) PCI audio driver

diffstat:

 sys/dev/pci/autri.c    |  1617 ++++++++++++++++++++++++++++++++++++++++++++++++
 sys/dev/pci/autrireg.h |   169 +++++
 sys/dev/pci/autrivar.h |   103 +++
 sys/dev/pci/files.pci  |     7 +-
 4 files changed, 1895 insertions(+), 1 deletions(-)

diffs (truncated from 1922 to 300 lines):

diff -r db764e87ccfe -r 1ac5a6260bb7 sys/dev/pci/autri.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/dev/pci/autri.c       Sun Nov 18 03:16:02 2001 +0000
@@ -0,0 +1,1617 @@
+/*     $NetBSD: autri.c,v 1.1 2001/11/18 03:16:02 someya Exp $ */
+
+/*
+ * Copyright (c) 2001 SOMEYA Yoshihiko and KUROSAWA Takahiro.
+ * 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.
+ *
+ * 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.
+ */
+
+/* 
+ * Trident 4DWAVE-DX/NX, SiS 7018, ALi M5451 Sound Driver
+ * 
+ * The register information is taken from the ALSA driver.
+ *
+ * Documentation links:
+ * - ftp://ftp.alsa-project.org/pub/manuals/trident/
+ */
+
+#include "midi.h"
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/fcntl.h>
+#include <sys/malloc.h>
+#include <sys/device.h>
+#include <sys/proc.h>
+
+#include <dev/pci/pcidevs.h>
+#include <dev/pci/pcireg.h>
+#include <dev/pci/pcivar.h>
+
+#include <sys/audioio.h>
+#include <dev/audio_if.h>
+#include <dev/midi_if.h>
+#include <dev/mulaw.h>
+#include <dev/auconv.h>
+#include <dev/ic/ac97reg.h>
+#include <dev/ic/ac97var.h>
+#include <dev/ic/mpuvar.h>
+
+#include <machine/bus.h>
+#include <machine/intr.h>
+
+#include <dev/pci/autrireg.h>
+#include <dev/pci/autrivar.h>
+
+#ifdef AUDIO_DEBUG
+# define DPRINTF(x)    if (autridebug) printf x
+# define DPRINTFN(n,x) if (autridebug > (n)) printf x
+int autridebug = 0;
+#else
+# define DPRINTF(x)
+# define DPRINTFN(n,x)
+#endif
+
+int    autri_match __P((struct device *, struct cfdata *, void *));
+void   autri_attach __P((struct device *, struct device *, void *));
+int    autri_intr __P((void *));
+
+#define DMAADDR(p) ((p)->map->dm_segs[0].ds_addr)
+#define KERNADDR(p) ((void *)((p)->addr))
+
+int     autri_allocmem __P((struct autri_softc *, size_t,
+                          size_t, struct autri_dma *));
+int     autri_freemem __P((struct autri_softc *, struct autri_dma *));
+
+#define TWRITE1(sc, r, x) bus_space_write_1((sc)->memt, (sc)->memh, (r), (x))
+#define TWRITE2(sc, r, x) bus_space_write_2((sc)->memt, (sc)->memh, (r), (x))
+#define TWRITE4(sc, r, x) bus_space_write_4((sc)->memt, (sc)->memh, (r), (x))
+#define TREAD1(sc, r) bus_space_read_1((sc)->memt, (sc)->memh, (r))
+#define TREAD2(sc, r) bus_space_read_2((sc)->memt, (sc)->memh, (r))
+#define TREAD4(sc, r) bus_space_read_4((sc)->memt, (sc)->memh, (r))
+
+static __inline void autri_reg_set_1 __P((struct autri_softc *,
+                                     int, uint8_t));
+static __inline void autri_reg_clear_1 __P((struct autri_softc *,
+                                     int, uint8_t));
+static __inline void autri_reg_set_4 __P((struct autri_softc *,
+                                     int, uint32_t));
+static __inline void autri_reg_clear_4 __P((struct autri_softc *,
+                                     int, uint32_t));
+
+int    autri_attach_codec __P((void *sc, struct ac97_codec_if *));
+int    autri_read_codec __P((void *sc, u_int8_t a, u_int16_t *d));
+int    autri_write_codec __P((void *sc, u_int8_t a, u_int16_t d));
+void   autri_reset_codec __P((void *sc));
+
+static void autri_powerhook(int why,void *addr);
+static int  autri_init __P((void *sc));
+static struct autri_dma *autri_find_dma __P((struct autri_softc *, void *));
+static void autri_setup_channel __P((struct autri_softc *sc,int mode,
+                                   struct audio_params *param));
+static void autri_enable_interrupt __P((struct autri_softc *sc, int ch));
+static void autri_disable_interrupt __P((struct autri_softc *sc, int ch));
+static void autri_startch __P((struct autri_softc *sc, int ch, int ch_intr));
+static void autri_stopch __P((struct autri_softc *sc, int ch, int ch_intr));
+static void autri_enable_loop_interrupt __P((void *sc));
+#if 0
+static void autri_disable_loop_interrupt __P((void *sc));
+#endif
+
+struct cfattach autri_ca = {
+       sizeof(struct autri_softc), autri_match, autri_attach
+};
+
+int    autri_open __P((void *, int));
+void   autri_close __P((void *));
+int    autri_query_encoding __P((void *, struct audio_encoding *));
+int    autri_set_params __P((void *, int, int,
+                           struct audio_params *, struct audio_params *));
+int    autri_round_blocksize __P((void *, int));
+int    autri_trigger_output __P((void *, void *, void *, int, void (*)(void *),
+                               void *, struct audio_params *));
+int    autri_trigger_input __P((void *, void *, void *, int, void (*)(void *),
+                              void *, struct audio_params *));
+int    autri_halt_output __P((void *));
+int    autri_halt_input __P((void *));
+int    autri_getdev __P((void *, struct audio_device *));
+int    autri_mixer_set_port __P((void *, mixer_ctrl_t *));
+int    autri_mixer_get_port __P((void *, mixer_ctrl_t *));
+void*  autri_malloc __P((void *, int, size_t, int, int));
+void   autri_free __P((void *, void *, int));
+size_t autri_round_buffersize __P((void *, int, size_t));
+paddr_t autri_mappage __P((void *, void *, off_t, int));
+int    autri_get_props __P((void *));
+int    autri_query_devinfo __P((void *addr, mixer_devinfo_t *dip));
+
+int     autri_get_portnum_by_name __P((struct autri_softc *, char *, char *,
+                                    char *));
+
+static struct audio_hw_if autri_hw_if = {
+        autri_open,
+       autri_close,
+       NULL,                   /* drain */
+       autri_query_encoding,
+       autri_set_params,
+       autri_round_blocksize,
+       NULL,                   /* commit_settings */
+       NULL,                   /* init_output */
+       NULL,                   /* init_input */
+       NULL,                   /* start_output */
+       NULL,                   /* start_input */
+       autri_halt_output,
+       autri_halt_input,
+       NULL,                   /* speaker_ctl */
+       autri_getdev,
+       NULL,                   /* setfd */
+       autri_mixer_set_port,
+       autri_mixer_get_port,
+       autri_query_devinfo,
+       autri_malloc,
+       autri_free,
+       autri_round_buffersize,
+       autri_mappage,
+       autri_get_props,
+       autri_trigger_output,
+       autri_trigger_input,
+       NULL,                   /* dev_ioctl */
+};
+
+#if NMIDI > 0
+void   autri_midi_close(void *);
+void   autri_midi_getinfo(void *, struct midi_info *);
+int    autri_midi_open(void *, int, void (*)(void *, int),
+                          void (*)(void *), void *);
+int    autri_midi_output(void *, int);
+
+struct midi_hw_if autri_midi_hw_if = {
+       autri_midi_open,
+       autri_midi_close,
+       autri_midi_output,
+       autri_midi_getinfo,
+       NULL,                   /* ioctl */
+};
+#endif
+
+/*
+ * register set/clear bit
+ */
+static __inline void
+autri_reg_set_1(sc, no, mask)
+       struct autri_softc *sc;
+       int no;
+       uint8_t mask;
+{
+       bus_space_write_1(sc->memt, sc->memh, no,
+           (bus_space_read_1(sc->memt, sc->memh, no) | mask));
+}
+
+static __inline void
+autri_reg_clear_1(sc, no, mask)
+       struct autri_softc *sc;
+       int no;
+       uint8_t mask;
+{
+       bus_space_write_1(sc->memt, sc->memh, no,
+           (bus_space_read_1(sc->memt, sc->memh, no) & ~mask));
+}
+
+static __inline void
+autri_reg_set_4(sc, no, mask)
+       struct autri_softc *sc;
+       int no;
+       uint32_t mask;
+{
+       bus_space_write_4(sc->memt, sc->memh, no,
+           (bus_space_read_4(sc->memt, sc->memh, no) | mask));
+}
+
+static __inline void
+autri_reg_clear_4(sc, no, mask)
+       struct autri_softc *sc;
+       int no;
+       uint32_t mask;
+{
+       bus_space_write_4(sc->memt, sc->memh, no,
+           (bus_space_read_4(sc->memt, sc->memh, no) & ~mask));
+}
+
+/*
+ * AC'97 codec
+ */
+int
+autri_attach_codec(sc_, codec_if)
+       void *sc_;
+       struct ac97_codec_if *codec_if;
+{
+       struct autri_codec_softc *sc = sc_;
+
+       DPRINTF(("autri_attach_codec()\n"));
+
+       sc->codec_if = codec_if;
+       return 0;
+}
+
+int
+autri_read_codec(sc_, index, data)
+       void *sc_;
+       u_int8_t index;
+       u_int16_t *data;
+{
+       struct autri_codec_softc *codec = sc_;
+       struct autri_softc *sc = codec->sc;
+       u_int32_t status, addr, cmd, busy;
+       u_int16_t count;
+
+       /*DPRINTF(("sc->sc->type : 0x%X",sc->sc->type));*/
+
+       switch (sc->sc_devid) {
+       case AUTRI_DEVICE_ID_4DWAVE_DX:
+               addr = AUTRI_DX_ACR1;
+               cmd  = AUTRI_DX_ACR1_CMD_READ;
+               busy = AUTRI_DX_ACR1_BUSY_READ;
+               break;
+       case AUTRI_DEVICE_ID_4DWAVE_NX:
+               addr = AUTRI_NX_ACR2;
+               cmd  = AUTRI_NX_ACR2_CMD_READ;
+               busy = AUTRI_NX_ACR2_BUSY_READ | AUTRI_NX_ACR2_RECV_WAIT;
+               break;
+       case AUTRI_DEVICE_ID_SIS_7018:
+               addr = AUTRI_SIS_ACRD;
+               cmd  = AUTRI_SIS_ACRD_CMD_READ;
+               busy = AUTRI_SIS_ACRD_BUSY_READ | AUTRI_SIS_ACRD_AUDIO_BUSY;
+               break;
+       case AUTRI_DEVICE_ID_ALI_M5451:
+               if (sc->sc_revision > 0x01)
+                       addr = AUTRI_ALI_ACWR;
+               else
+                       addr = AUTRI_ALI_ACRD;
+               cmd  = AUTRI_ALI_ACRD_CMD_READ;
+               busy = AUTRI_ALI_ACRD_BUSY_READ;
+               break;
+       default:
+               printf("%s: autri_read_codec : unknown device\n",
+                      sc->sc_dev.dv_xname);
+               return -1;
+       }



Home | Main Index | Thread Index | Old Index