neomagic.c (193640) | neomagic.c (254263) |
---|---|
1/*- 2 * Copyright (c) 1999 Cameron Grant <cg@freebsd.org> 3 * All rights reserved. 4 * 5 * Derived from the public domain Linux driver 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 24 unchanged lines hidden (view full) --- 33#include <dev/sound/pcm/sound.h> 34#include <dev/sound/pcm/ac97.h> 35#include <dev/sound/pci/neomagic.h> 36#include <dev/sound/pci/neomagic-coeff.h> 37 38#include <dev/pci/pcireg.h> 39#include <dev/pci/pcivar.h> 40 | 1/*- 2 * Copyright (c) 1999 Cameron Grant <cg@freebsd.org> 3 * All rights reserved. 4 * 5 * Derived from the public domain Linux driver 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 24 unchanged lines hidden (view full) --- 33#include <dev/sound/pcm/sound.h> 34#include <dev/sound/pcm/ac97.h> 35#include <dev/sound/pci/neomagic.h> 36#include <dev/sound/pci/neomagic-coeff.h> 37 38#include <dev/pci/pcireg.h> 39#include <dev/pci/pcivar.h> 40 |
41SND_DECLARE_FILE("$FreeBSD: head/sys/dev/sound/pci/neomagic.c 193640 2009-06-07 19:12:08Z ariff $"); | 41SND_DECLARE_FILE("$FreeBSD: head/sys/dev/sound/pci/neomagic.c 254263 2013-08-12 23:30:01Z scottl $"); |
42 43/* -------------------------------------------------------------------- */ 44 45#define NM_BUFFSIZE 16384 46 47#define NM256AV_PCI_ID 0x800510c8 48#define NM256ZX_PCI_ID 0x800610c8 49 --- 544 unchanged lines hidden (view full) --- 594 return 0; 595} 596 597static int 598nm_pci_probe(device_t dev) 599{ 600 struct sc_info *sc = NULL; 601 char *s = NULL; | 42 43/* -------------------------------------------------------------------- */ 44 45#define NM_BUFFSIZE 16384 46 47#define NM256AV_PCI_ID 0x800510c8 48#define NM256ZX_PCI_ID 0x800610c8 49 --- 544 unchanged lines hidden (view full) --- 594 return 0; 595} 596 597static int 598nm_pci_probe(device_t dev) 599{ 600 struct sc_info *sc = NULL; 601 char *s = NULL; |
602 u_int32_t subdev, i, data; | 602 u_int32_t subdev, i; |
603 604 subdev = (pci_get_subdevice(dev) << 16) | pci_get_subvendor(dev); 605 switch (pci_get_devid(dev)) { 606 case NM256AV_PCI_ID: 607 i = 0; 608 while ((i < NUM_BADCARDS) && (badcards[i] != subdev)) 609 i++; 610 611 /* Try to catch other non-ac97 cards */ 612 613 if (i == NUM_BADCARDS) { 614 if (!(sc = malloc(sizeof(*sc), M_DEVBUF, M_NOWAIT | M_ZERO))) { 615 device_printf(dev, "cannot allocate softc\n"); 616 return ENXIO; 617 } 618 | 603 604 subdev = (pci_get_subdevice(dev) << 16) | pci_get_subvendor(dev); 605 switch (pci_get_devid(dev)) { 606 case NM256AV_PCI_ID: 607 i = 0; 608 while ((i < NUM_BADCARDS) && (badcards[i] != subdev)) 609 i++; 610 611 /* Try to catch other non-ac97 cards */ 612 613 if (i == NUM_BADCARDS) { 614 if (!(sc = malloc(sizeof(*sc), M_DEVBUF, M_NOWAIT | M_ZERO))) { 615 device_printf(dev, "cannot allocate softc\n"); 616 return ENXIO; 617 } 618 |
619 data = pci_read_config(dev, PCIR_COMMAND, 2); 620 pci_write_config(dev, PCIR_COMMAND, data | 621 PCIM_CMD_PORTEN | PCIM_CMD_MEMEN | 622 PCIM_CMD_BUSMASTEREN, 2); 623 | |
624 sc->regid = PCIR_BAR(1); 625 sc->reg = bus_alloc_resource_any(dev, SYS_RES_MEMORY, 626 &sc->regid, 627 RF_ACTIVE); 628 629 if (!sc->reg) { 630 device_printf(dev, "unable to map register space\n"); | 619 sc->regid = PCIR_BAR(1); 620 sc->reg = bus_alloc_resource_any(dev, SYS_RES_MEMORY, 621 &sc->regid, 622 RF_ACTIVE); 623 624 if (!sc->reg) { 625 device_printf(dev, "unable to map register space\n"); |
631 pci_write_config(dev, PCIR_COMMAND, data, 2); | |
632 free(sc, M_DEVBUF); 633 return ENXIO; 634 } 635 636 /* 637 * My Panasonic CF-M2EV needs resetting device 638 * before checking mixer is present or not. 639 * t.ichinoseki@nifty.com. 640 */ 641 nm_wr(sc, 0, 0x11, 1); /* reset device */ 642 if ((nm_rd(sc, NM_MIXER_PRESENCE, 2) & 643 NM_PRESENCE_MASK) != NM_PRESENCE_VALUE) { 644 i = 0; /* non-ac97 card, but not listed */ 645 DEB(device_printf(dev, "subdev = 0x%x - badcard?\n", 646 subdev)); 647 } | 626 free(sc, M_DEVBUF); 627 return ENXIO; 628 } 629 630 /* 631 * My Panasonic CF-M2EV needs resetting device 632 * before checking mixer is present or not. 633 * t.ichinoseki@nifty.com. 634 */ 635 nm_wr(sc, 0, 0x11, 1); /* reset device */ 636 if ((nm_rd(sc, NM_MIXER_PRESENCE, 2) & 637 NM_PRESENCE_MASK) != NM_PRESENCE_VALUE) { 638 i = 0; /* non-ac97 card, but not listed */ 639 DEB(device_printf(dev, "subdev = 0x%x - badcard?\n", 640 subdev)); 641 } |
648 pci_write_config(dev, PCIR_COMMAND, data, 2); | |
649 bus_release_resource(dev, SYS_RES_MEMORY, sc->regid, 650 sc->reg); 651 free(sc, M_DEVBUF); 652 } 653 654 if (i == NUM_BADCARDS) 655 s = "NeoMagic 256AV"; 656 DEB(else) --- 8 unchanged lines hidden (view full) --- 665 666 if (s) device_set_desc(dev, s); 667 return s? 0 : ENXIO; 668} 669 670static int 671nm_pci_attach(device_t dev) 672{ | 642 bus_release_resource(dev, SYS_RES_MEMORY, sc->regid, 643 sc->reg); 644 free(sc, M_DEVBUF); 645 } 646 647 if (i == NUM_BADCARDS) 648 s = "NeoMagic 256AV"; 649 DEB(else) --- 8 unchanged lines hidden (view full) --- 658 659 if (s) device_set_desc(dev, s); 660 return s? 0 : ENXIO; 661} 662 663static int 664nm_pci_attach(device_t dev) 665{ |
673 u_int32_t data; | |
674 struct sc_info *sc; 675 struct ac97_info *codec = 0; 676 char status[SND_STATUSLEN]; 677 678 sc = malloc(sizeof(*sc), M_DEVBUF, M_WAITOK | M_ZERO); 679 sc->dev = dev; 680 sc->type = pci_get_devid(dev); 681 | 666 struct sc_info *sc; 667 struct ac97_info *codec = 0; 668 char status[SND_STATUSLEN]; 669 670 sc = malloc(sizeof(*sc), M_DEVBUF, M_WAITOK | M_ZERO); 671 sc->dev = dev; 672 sc->type = pci_get_devid(dev); 673 |
682 data = pci_read_config(dev, PCIR_COMMAND, 2); 683 data |= (PCIM_CMD_PORTEN|PCIM_CMD_MEMEN|PCIM_CMD_BUSMASTEREN); 684 pci_write_config(dev, PCIR_COMMAND, data, 2); 685 data = pci_read_config(dev, PCIR_COMMAND, 2); | 674 pci_enable_busmaster(dev); |
686 687 sc->bufid = PCIR_BAR(0); 688 sc->buf = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &sc->bufid, 689 RF_ACTIVE); 690 sc->regid = PCIR_BAR(1); 691 sc->reg = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &sc->regid, 692 RF_ACTIVE); 693 --- 138 unchanged lines hidden --- | 675 676 sc->bufid = PCIR_BAR(0); 677 sc->buf = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &sc->bufid, 678 RF_ACTIVE); 679 sc->regid = PCIR_BAR(1); 680 sc->reg = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &sc->regid, 681 RF_ACTIVE); 682 --- 138 unchanged lines hidden --- |