Source-Changes-HG archive

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

[src/trunk]: src/sys emuxki(4): import a list of board definitions



details:   https://anonhg.NetBSD.org/src/rev/19315a3f0928
branches:  trunk
changeset: 369905:19315a3f0928
user:      khorben <khorben%NetBSD.org@localhost>
date:      Wed Sep 07 03:34:43 2022 +0000

description:
emuxki(4): import a list of board definitions

This is inspired by the cxdtv(4) driver.

Tested on NetBSD/amd64 with a Sound Blaster Live! Value (CT4870, PCI)
and with a Sound Blaster Audigy Rx 7.1 (SB1550, PCIe).

Additional sound cards sponsored by the NetBSD Foundation; thanks!

diffstat:

 sys/dev/pci/emuxki.c            |   62 +++++-------
 sys/dev/pci/emuxki_boards.c     |  190 ++++++++++++++++++++++++++++++++++++++++
 sys/dev/pci/emuxki_boards.h     |   58 ++++++++++++
 sys/dev/pci/emuxkivar.h         |    5 +-
 sys/modules/emuxki/Makefile.inc |    3 +-
 5 files changed, 281 insertions(+), 37 deletions(-)

diffs (truncated from 436 to 300 lines):

diff -r 3c2f6f18828b -r 19315a3f0928 sys/dev/pci/emuxki.c
--- a/sys/dev/pci/emuxki.c      Wed Sep 07 02:41:39 2022 +0000
+++ b/sys/dev/pci/emuxki.c      Wed Sep 07 03:34:43 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: emuxki.c,v 1.75 2022/09/07 01:00:37 khorben Exp $      */
+/*     $NetBSD: emuxki.c,v 1.76 2022/09/07 03:34:43 khorben Exp $      */
 
 /*-
  * Copyright (c) 2001, 2007 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: emuxki.c,v 1.75 2022/09/07 01:00:37 khorben Exp $");
+__KERNEL_RCSID(0, "$NetBSD: emuxki.c,v 1.76 2022/09/07 03:34:43 khorben Exp $");
 
 #include <sys/param.h>
 #include <sys/device.h>
@@ -56,6 +56,7 @@
 
 #include <dev/pci/emuxkireg.h>
 #include <dev/pci/emuxkivar.h>
+#include <dev/pci/emuxki_boards.h>
 
 /* #define EMUXKI_DEBUG 1 */
 #ifdef EMUXKI_DEBUG
@@ -74,7 +75,6 @@
  */
 
 #define EMU_PCI_CBIO           (0x10)
-#define EMU_SUBSYS_APS         (0x40011102)
 
 /* blackmagic */
 #define X1(x)          ((sc->sc_type & EMUXKI_AUDIGY) ? EMU_A_##x : EMU_##x)
@@ -357,20 +357,17 @@
 emuxki_match(device_t parent, cfdata_t match, void *aux)
 {
        struct pci_attach_args *pa;
+       pcireg_t reg;
 
        pa = aux;
-       if (PCI_VENDOR(pa->pa_id) != PCI_VENDOR_CREATIVELABS)
-               return 0;
 
-       switch (PCI_PRODUCT(pa->pa_id)) {
-       case PCI_PRODUCT_CREATIVELABS_SBLIVE:
-       case PCI_PRODUCT_CREATIVELABS_SBLIVE2:
-       case PCI_PRODUCT_CREATIVELABS_AUDIGY:
-       case PCI_PRODUCT_CREATIVELABS_SBAUDIGY4:
+       reg = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_SUBSYS_ID_REG);
+       if (emuxki_board_lookup(PCI_VENDOR(pa->pa_id),
+                               PCI_PRODUCT(pa->pa_id), reg,
+                               PCI_REVISION(pa->pa_class)) != NULL)
                return 1;
-       default:
-               return 0;
-       }
+
+       return 0;
 }
 
 static void
@@ -378,6 +375,7 @@
 {
        struct emuxki_softc *sc;
        struct pci_attach_args *pa;
+       const struct emuxki_board *sb;
        pci_intr_handle_t ih;
        const char *intrstr;
        char intrbuf[PCI_INTRSTR_LEN];
@@ -387,7 +385,14 @@
        sc->sc_dev = self;
        pa = aux;
 
+       reg = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_SUBSYS_ID_REG);
+       sb = emuxki_board_lookup(PCI_VENDOR(pa->pa_id),
+                                     PCI_PRODUCT(pa->pa_id), reg,
+                                     PCI_REVISION(pa->pa_class));
+       KASSERT(sb != NULL);
+
        pci_aprint_devinfo(pa, "Audio controller");
+       aprint_normal_dev(self, "%s [%s]\n", sb->sb_name, sb->sb_board);
        DPRINTF("dmat=%p\n", (char *)pa->pa_dmat);
 
        mutex_init(&sc->sc_lock, MUTEX_DEFAULT, IPL_NONE);
@@ -434,28 +439,17 @@
        aprint_normal_dev(self, "interrupting at %s\n", intrstr);
 
        /* XXX it's unknown whether APS is made from Audigy as well */
-       if (PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_CREATIVELABS_SBAUDIGY4) {
-               sc->sc_type = EMUXKI_AUDIGY;
-               sc->sc_type |= EMUXKI_AUDIGY2;
-               sc->sc_type |= EMUXKI_AUDIGY2_VALUE;
-               strlcpy(sc->sc_audv.name, "Audigy2 (value)",
+       sc->sc_type = sb->sb_flags;
+       if (sc->sc_type & EMUXKI_AUDIGY2_CA0108) {
+               strlcpy(sc->sc_audv.name, "Audigy2+CA0108",
                    sizeof(sc->sc_audv.name));
-       } else if (PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_CREATIVELABS_AUDIGY) {
-               sc->sc_type = EMUXKI_AUDIGY;
-               if (PCI_REVISION(pa->pa_class) == 0x04) {
-                       sc->sc_type |= EMUXKI_AUDIGY2;
-                       strlcpy(sc->sc_audv.name, "Audigy2",
-                           sizeof(sc->sc_audv.name));
-               } else {
-                       strlcpy(sc->sc_audv.name, "Audigy",
-                           sizeof(sc->sc_audv.name));
-               }
-       } else if (pci_conf_read(pa->pa_pc, pa->pa_tag,
-           PCI_SUBSYS_ID_REG) == EMU_SUBSYS_APS) {
-               sc->sc_type = EMUXKI_APS;
+       } else if (sc->sc_type & EMUXKI_AUDIGY2) {
+               strlcpy(sc->sc_audv.name, "Audigy2", sizeof(sc->sc_audv.name));
+       } else if (sc->sc_type & EMUXKI_AUDIGY) {
+               strlcpy(sc->sc_audv.name, "Audigy", sizeof(sc->sc_audv.name));
+       } else if (sc->sc_type & EMUXKI_APS) {
                strlcpy(sc->sc_audv.name, "E-mu APS", sizeof(sc->sc_audv.name));
        } else {
-               sc->sc_type = EMUXKI_SBLIVE;
                strlcpy(sc->sc_audv.name, "SB Live!", sizeof(sc->sc_audv.name));
        }
        snprintf(sc->sc_audv.version, sizeof(sc->sc_audv.version), "0x%02x",
@@ -609,7 +603,7 @@
        emuxki_write(sc, 0, EMU_SPCS1, spcs);
        emuxki_write(sc, 0, EMU_SPCS2, spcs);
 
-       if (sc->sc_type & EMUXKI_AUDIGY2_VALUE) {
+       if (sc->sc_type & EMUXKI_AUDIGY2_CA0108) {
                /* Setup SRCMulti_I2S SamplingRate */
                emuxki_write(sc, 0, EMU_A2_SPDIF_SAMPLERATE,
                    emuxki_read(sc, 0, EMU_A2_SPDIF_SAMPLERATE) & 0xfffff1ff);
@@ -661,7 +655,7 @@
            EMU_INTE_VOLDECRENABLE |
            EMU_INTE_MUTEENABLE);
 
-       if (sc->sc_type & EMUXKI_AUDIGY2_VALUE) {
+       if (sc->sc_type & EMUXKI_AUDIGY2_CA0108) {
                emuxki_writeio_4(sc, EMU_A_IOCFG,
                    0x0060 | emuxki_readio_4(sc, EMU_A_IOCFG));
        } else if (sc->sc_type & EMUXKI_AUDIGY2) {
diff -r 3c2f6f18828b -r 19315a3f0928 sys/dev/pci/emuxki_boards.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/dev/pci/emuxki_boards.c       Wed Sep 07 03:34:43 2022 +0000
@@ -0,0 +1,190 @@
+/*     $NetBSD: emuxki_boards.c,v 1.1 2022/09/07 03:34:43 khorben Exp $        */
+
+/*-
+ * Copyright (c) 2001, 2007 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Yannick Montulet, and by Andrew Doran.
+ *
+ * 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 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 <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: emuxki_boards.c,v 1.1 2022/09/07 03:34:43 khorben Exp $");
+
+#include <dev/pci/emuxkivar.h>
+#include <dev/pci/emuxki_boards.h>
+
+/* generic fallbacks must be after any corresponding precise match */
+static const struct emuxki_board emuxki_boards[] = {
+       {
+               .sb_board = "SB1550",
+               .sb_name = "Sound Blaster Audigy Rx",
+               .sb_vendor = PCI_VENDOR_CREATIVELABS,
+               .sb_product = PCI_PRODUCT_CREATIVELABS_SBAUDIGY4,
+               .sb_subsystem = 0x10241102,
+               .sb_flags = EMUXKI_AUDIGY | EMUXKI_AUDIGY2 | EMUXKI_AUDIGY2_CA0108,
+       },
+       {
+               .sb_board = "SB0610",
+               .sb_name = "Sound Blaster Audigy 4",
+               .sb_vendor = PCI_VENDOR_CREATIVELABS,
+               .sb_product = PCI_PRODUCT_CREATIVELABS_SBAUDIGY4,
+               .sb_subsystem = 0x10211102,
+               .sb_flags = EMUXKI_AUDIGY | EMUXKI_AUDIGY2 | EMUXKI_AUDIGY2_CA0108,
+       },
+       {
+               .sb_board = "SB0400",
+               .sb_name = "Sound Blaster Audigy 2 Value",
+               .sb_vendor = PCI_VENDOR_CREATIVELABS,
+               .sb_product = PCI_PRODUCT_CREATIVELABS_SBAUDIGY4,
+               .sb_subsystem = 0x10011102,
+               .sb_flags = EMUXKI_AUDIGY | EMUXKI_AUDIGY2 | EMUXKI_AUDIGY2_CA0108,
+       },
+       {
+               .sb_board = "generic",
+               .sb_name = "Sound Blaster Audigy 2 Value",
+               .sb_vendor = PCI_VENDOR_CREATIVELABS,
+               .sb_product = PCI_PRODUCT_CREATIVELABS_SBAUDIGY4,
+               .sb_flags = EMUXKI_AUDIGY | EMUXKI_AUDIGY2 | EMUXKI_AUDIGY2_CA0108,
+       },
+       {
+               .sb_board = "SB0350",
+               .sb_name = "Sound Blaster Audigy 2 ZS",
+               .sb_vendor = PCI_VENDOR_CREATIVELABS,
+               .sb_product = PCI_PRODUCT_CREATIVELABS_AUDIGY,
+               .sb_subsystem = 0x20021102,
+               .sb_flags = EMUXKI_AUDIGY | EMUXKI_AUDIGY2,
+       },
+       {
+               .sb_board = "SB0350",
+               .sb_name = "Sound Blaster Audigy 2",
+               .sb_vendor = PCI_VENDOR_CREATIVELABS,
+               .sb_product = PCI_PRODUCT_CREATIVELABS_AUDIGY,
+               .sb_subsystem = 0x20051102,
+               .sb_flags = EMUXKI_AUDIGY | EMUXKI_AUDIGY2,
+       },
+       {
+               .sb_board = "SB0240",
+               .sb_name = "Sound Blaster Audigy 2",
+               .sb_vendor = PCI_VENDOR_CREATIVELABS,
+               .sb_product = PCI_PRODUCT_CREATIVELABS_AUDIGY,
+               .sb_subsystem = 0x10021102,
+               .sb_flags = EMUXKI_AUDIGY | EMUXKI_AUDIGY2,
+       },
+       {
+               .sb_board = "generic",
+               .sb_name = "Sound Blaster Audigy 2",
+               .sb_vendor = PCI_VENDOR_CREATIVELABS,
+               .sb_product = PCI_PRODUCT_CREATIVELABS_AUDIGY,
+               .sb_revision = 0x8,
+               .sb_flags = EMUXKI_AUDIGY | EMUXKI_AUDIGY2,
+       },
+       {
+               .sb_board = "generic",
+               .sb_name = "Sound Blaster Audigy 2",
+               .sb_vendor = PCI_VENDOR_CREATIVELABS,
+               .sb_product = PCI_PRODUCT_CREATIVELABS_AUDIGY,
+               .sb_revision = 0x4,
+               .sb_flags = EMUXKI_AUDIGY | EMUXKI_AUDIGY2,
+       },
+       {
+               .sb_board = "generic",
+               .sb_name = "Sound Blaster Audigy",
+               .sb_vendor = PCI_VENDOR_CREATIVELABS,
+               .sb_product = PCI_PRODUCT_CREATIVELABS_AUDIGY,
+               .sb_flags = EMUXKI_AUDIGY,
+       },
+       {
+               .sb_board = "generic",
+               .sb_name = "Sound Blaster Live! 2",
+               .sb_vendor = PCI_VENDOR_CREATIVELABS,
+               .sb_product = PCI_PRODUCT_CREATIVELABS_SBLIVE2,
+               .sb_flags = EMUXKI_SBLIVE,
+       },
+       {
+               .sb_board = "CT4870",
+               .sb_name = "Sound Blaster Live! Value",
+               .sb_vendor = PCI_VENDOR_CREATIVELABS,
+               .sb_product = PCI_PRODUCT_CREATIVELABS_SBLIVE,
+               .sb_subsystem = 0x80281102,
+               .sb_flags = EMUXKI_SBLIVE,
+       },
+       {
+               .sb_board = "CT4790",
+               .sb_name = "Sound Blaster PCI512",
+               .sb_vendor = PCI_VENDOR_CREATIVELABS,
+               .sb_product = PCI_PRODUCT_CREATIVELABS_SBLIVE,
+               .sb_subsystem = 0x80231102,
+               .sb_flags = EMUXKI_SBLIVE,
+       },
+       {
+               .sb_board = "PC545",
+               .sb_name = "Sound Blaster E-mu APS",
+               .sb_vendor = PCI_VENDOR_CREATIVELABS,
+               .sb_product = PCI_PRODUCT_CREATIVELABS_SBLIVE,
+               .sb_subsystem = 0x40011102,
+               .sb_flags = EMUXKI_APS,
+       },
+       {
+               .sb_board = "generic",
+               .sb_name = "Sound Blaster Live!",
+               .sb_vendor = PCI_VENDOR_CREATIVELABS,
+               .sb_product = PCI_PRODUCT_CREATIVELABS_SBLIVE,
+               .sb_flags = EMUXKI_SBLIVE,
+       },
+};



Home | Main Index | Thread Index | Old Index