Index: pci/neomagic.c =================================================================== RCS file: /usr/home/ncvs/src/sys/dev/sound/pci/neomagic.c,v retrieving revision 1.22 diff -u -r1.22 neomagic.c --- pci/neomagic.c 2001/03/24 23:10:28 1.22 +++ pci/neomagic.c 2001/04/10 13:13:29 @@ -92,6 +92,7 @@ 0x0007103c, 0x008f1028, 0x00dd1014, + 0x8005110a, }; #define NUM_BADCARDS (sizeof(badcards) / sizeof(u_int32_t)) @@ -553,8 +554,9 @@ static int nm_pci_probe(device_t dev) { + struct sc_info *sc = NULL; char *s = NULL; - u_int32_t subdev, i; + u_int32_t subdev, i, data; subdev = (pci_get_subdevice(dev) << 16) | pci_get_subvendor(dev); switch (pci_get_devid(dev)) { @@ -562,10 +564,50 @@ i = 0; while ((i < NUM_BADCARDS) && (badcards[i] != subdev)) i++; + + /* Try to catch other non-ac97 cards */ + + if (i == NUM_BADCARDS) { + if (!(sc = malloc(sizeof(*sc), M_DEVBUF, + M_NOWAIT | M_ZERO))) { + device_printf(dev, "cannot allocate softc\n"); + return ENXIO; + } + + data = pci_read_config(dev, PCIR_COMMAND, 2); + pci_write_config(dev, PCIR_COMMAND, data | + PCIM_CMD_PORTEN | PCIM_CMD_MEMEN | + PCIM_CMD_BUSMASTEREN, 2); + + sc->regid = PCIR_MAPS + 4; + sc->reg = bus_alloc_resource(dev, SYS_RES_MEMORY, + &sc->regid, 0, ~0, 1, + RF_ACTIVE); + + if (!sc->reg) { + device_printf(dev, "unable to map register space\n"); + pci_write_config(dev, PCIR_COMMAND, data, 2); + free(sc, M_DEVBUF); + return ENXIO; + } + + if ((nm_rd(sc, NM_MIXER_PRESENCE, 2) & + NM_PRESENCE_MASK) != NM_PRESENCE_VALUE) { + i = 0; /* non-ac97 card, but not listed */ + DEB(device_printf(dev, "subdev = 0x%x - badcard?\n", + subdev)); + } + pci_write_config(dev, PCIR_COMMAND, data, 2); + bus_release_resource(dev, SYS_RES_MEMORY, sc->regid, + sc->reg); + free(sc, M_DEVBUF); + } + if (i == NUM_BADCARDS) s = "NeoMagic 256AV"; DEB(else) DEB(device_printf(dev, "this is a non-ac97 NM256AV, not attaching\n")); + break; case NM256ZX_PCI_ID: Index: pci/neomagic.h =================================================================== RCS file: /usr/home/ncvs/src/sys/dev/sound/pci/neomagic.h,v retrieving revision 1.1 diff -u -r1.1 neomagic.h --- pci/neomagic.h 2000/01/09 08:14:11 1.1 +++ pci/neomagic.h 2001/04/09 16:54:18 @@ -42,6 +42,11 @@ /* The base offset of the mixer in the second memory area. */ #define NM_MIXER_OFFSET 0x600 +/* The base offset for the AC97 test */ +#define NM_MIXER_PRESENCE 0xa06 +#define NM_PRESENCE_MASK 0x050 +#define NM_PRESENCE_VALUE 0x040 + /* The maximum size of a coefficient entry. */ #define NM_MAX_COEFFICIENT 0x5000