31#ifdef HAVE_KERNEL_OPTION_HEADERS
47#define NM_BUFFSIZE 16384
49#define NM256AV_PCI_ID 0x800510c8
50#define NM256ZX_PCI_ID 0x800610c8
104#define NUM_BADCARDS (sizeof(badcards) / sizeof(u_int32_t))
136 bus_space_tag_t st = rman_get_bustag(sc->
reg);
137 bus_space_handle_t sh = rman_get_bushandle(sc->
reg);
141 return bus_space_read_1(st, sh,
regno);
143 return bus_space_read_2(st, sh,
regno);
145 return bus_space_read_4(st, sh,
regno);
154 bus_space_tag_t st = rman_get_bustag(sc->
reg);
155 bus_space_handle_t sh = rman_get_bushandle(sc->
reg);
173 bus_space_tag_t st = rman_get_bustag(sc->
buf);
174 bus_space_handle_t sh = rman_get_bushandle(sc->
buf);
178 return bus_space_read_1(st, sh,
regno);
180 return bus_space_read_2(st, sh,
regno);
182 return bus_space_read_4(st, sh,
regno);
191 bus_space_tag_t st = rman_get_bustag(sc->
buf);
192 bus_space_handle_t sh = rman_get_bushandle(sc->
buf);
231 nm_wr(sc, 0x6c0, 0x01, 1);
240 nm_wr(sc, 0x6cc, 0x87, 1);
242 nm_wr(sc, 0x6cc, 0x80, 1);
243 nm_wr(sc, 0x6cc, 0x00, 1);
258 device_printf(sc->
dev,
"ac97 codec not ready\n");
278 device_printf(sc->
dev,
"ac97 codec not ready\n");
284 KOBJMETHOD(ac97_read,
nm_rdcd),
285 KOBJMETHOD(ac97_write,
nm_wrcd),
315 for (i = 0; i < sz; i++)
331 for (x = 0; x < 8; x++)
335 if (x == 8)
return 1;
519 x =
nm_rd(sc, 0x400, 1);
520 nm_wr(sc, 0x400, x | 2, 1);
521 device_printf(sc->
dev,
"misc int 1\n");
526 x =
nm_rd(sc, 0x400, 1);
527 nm_wr(sc, 0x400, x & ~2, 1);
528 device_printf(sc->
dev,
"misc int 2\n");
532 device_printf(sc->
dev,
"unknown int\n");
564 sc->
buftop = (
nm_rd(sc, 0xa0b, 2)? 6144 : 4096) * 1024;
573 ofs = sc->
buftop - 0x0400;
577 device_printf(sc->
dev,
"buftop is 0x%08x\n", sc->
buftop);
580 if (i != 0 && i != 0xffffffff) {
582 device_printf(sc->
dev,
"buftop is changed to 0x%08x\n", i);
592 nm_wr(sc, 0, 0x11, 1);
594 nm_wr(sc, 0x214, 0, 2);
606 subdev = (pci_get_subdevice(
dev) << 16) | pci_get_subvendor(
dev);
607 switch (pci_get_devid(
dev)) {
616 if (!(sc = malloc(
sizeof(*sc), M_DEVBUF, M_NOWAIT | M_ZERO))) {
617 device_printf(
dev,
"cannot allocate softc\n");
622 sc->
reg = bus_alloc_resource_any(
dev, SYS_RES_MEMORY,
627 device_printf(
dev,
"unable to map register space\n");
637 nm_wr(sc, 0, 0x11, 1);
641 DEB(device_printf(
dev,
"subdev = 0x%x - badcard?\n",
644 bus_release_resource(
dev, SYS_RES_MEMORY, sc->
regid,
650 s =
"NeoMagic 256AV";
652 DEB(device_printf(
dev,
"this is a non-ac97 NM256AV, not attaching\n"));
657 s =
"NeoMagic 256ZX";
661 if (s) device_set_desc(
dev, s);
672 sc = malloc(
sizeof(*sc), M_DEVBUF, M_WAITOK | M_ZERO);
676 pci_enable_busmaster(
dev);
679 sc->
buf = bus_alloc_resource_any(
dev, SYS_RES_MEMORY, &sc->
bufid,
682 sc->
reg = bus_alloc_resource_any(
dev, SYS_RES_MEMORY, &sc->
regid,
685 if (!sc->
buf || !sc->
reg) {
686 device_printf(
dev,
"unable to map register space\n");
691 device_printf(
dev,
"unable to initialize the card\n");
696 if (codec == NULL)
goto bad;
700 sc->
irq = bus_alloc_resource_any(
dev, SYS_RES_IRQ, &sc->
irqid,
701 RF_ACTIVE | RF_SHAREABLE);
703 device_printf(
dev,
"unable to map interrupt\n");
708 rman_get_start(sc->
buf), rman_get_start(sc->
reg),
720 if (sc->
buf) bus_release_resource(
dev, SYS_RES_MEMORY, sc->
bufid, sc->
buf);
721 if (sc->
reg) bus_release_resource(
dev, SYS_RES_MEMORY, sc->
regid, sc->
reg);
722 if (sc->
ih) bus_teardown_intr(
dev, sc->
irq, sc->
ih);
723 if (sc->
irq) bus_release_resource(
dev, SYS_RES_IRQ, sc->
irqid, sc->
irq);
739 bus_release_resource(
dev, SYS_RES_MEMORY, sc->
bufid, sc->
buf);
740 bus_release_resource(
dev, SYS_RES_MEMORY, sc->
regid, sc->
reg);
741 bus_teardown_intr(
dev, sc->
irq, sc->
ih);
742 bus_release_resource(
dev, SYS_RES_IRQ, sc->
irqid, sc->
irq);
782 nm_wr(sc, 0, 0x11, 1);
783 nm_wr(sc, 0x214, 0, 2);
787 device_printf(
dev,
"unable to reinitialize the mixer\n");
kobj_class_t ac97_getmixerclass(void)
void ac97_destroy(struct ac97_info *codec)
#define AC97_CREATE(dev, devinfo, cls)
int sndbuf_setup(struct snd_dbuf *b, void *buf, unsigned int size)
void * sndbuf_getbuf(struct snd_dbuf *b)
void chn_intr(struct pcm_channel *c)
#define PCMTRIG_COMMON(x)
int mixer_init(device_t dev, kobj_class_t cls, void *devinfo)
int mixer_reinit(device_t dev)
static u_int16_t coefficientSizes[]
#define NM_TOTAL_COEFF_COUNT
static u_char coefficients[NM_TOTAL_COEFF_COUNT *4]
static u_int32_t nm_fmt[]
static u_int32_t nmchan_setspeed(kobj_t obj, void *data, u_int32_t speed)
static int nmchan_trigger(kobj_t obj, void *data, int go)
static int nm_pci_resume(device_t dev)
static u_int32_t badcards[]
MODULE_VERSION(snd_neomagic, 1)
static int nmchan_setformat(kobj_t obj, void *data, u_int32_t format)
static int nm_pci_attach(device_t dev)
static int nm_setch(struct sc_chinfo *ch)
static void nm_ackint(struct sc_info *sc, u_int32_t num)
static int nm_waitcd(struct sc_info *sc)
SND_DECLARE_FILE("$FreeBSD$")
static int nm_wrcd(kobj_t obj, void *devinfo, int regno, u_int32_t data)
static struct pcmchan_caps * nmchan_getcaps(kobj_t obj, void *data)
static kobj_method_t nm_ac97_methods[]
MODULE_DEPEND(snd_neomagic, sound, SOUND_MINVER, SOUND_PREFVER, SOUND_MAXVER)
static int nm_pci_suspend(device_t dev)
static u_int32_t nm_initcd(kobj_t obj, void *devinfo)
static int nmchan_free(kobj_t obj, void *data)
static void nm_wr(struct sc_info *, int, u_int32_t, int)
static int nm_init(struct sc_info *)
static u_int32_t nmchan_getptr(kobj_t obj, void *data)
static driver_t nm_driver
static u_int32_t nmchan_setblocksize(kobj_t obj, void *data, u_int32_t blocksize)
static device_method_t nm_methods[]
static u_int32_t nm_rd(struct sc_info *, int, int)
static kobj_method_t nmchan_methods[]
static int nm_pci_detach(device_t dev)
static int nm_pci_probe(device_t dev)
static u_int32_t nm_rdbuf(struct sc_info *, int, int)
static void nm_intr(void *)
static int nm_rdcd(kobj_t obj, void *devinfo, int regno)
static void nm_wrbuf(struct sc_info *, int, u_int32_t, int)
static void * nmchan_init(kobj_t obj, void *devinfo, struct snd_dbuf *b, struct pcm_channel *c, int dir)
static int nm_loadcoeff(struct sc_info *sc, int dir, int num)
static int samplerates[9]
DRIVER_MODULE(snd_neomagic, pci, nm_driver, pcm_devclass, 0, 0)
static struct pcmchan_caps nm_caps
#define NM2_MIXER_STATUS_OFFSET
#define NM_PRESENCE_VALUE
#define NM2_MIXER_READY_MASK
#define NM_MIXER_PRESENCE
#define NM_MIXER_STATUS_OFFSET
#define NM_RECORD_ENABLE_FLAG
#define NM_RATE_REG_OFFSET
#define NM_AUDIO_MUTE_BOTH
#define NM_RECORD_FREERUN
#define NM_PLAYBACK_FREERUN
#define NM_MIXER_READY_MASK
#define NM_MAX_COEFFICIENT
#define NM_PLAYBACK_REG_OFFSET
#define NM_AUDIO_MUTE_REG
#define NM_PLAYBACK_ENABLE_REG
#define NM_RECORD_ENABLE_REG
#define NM_RECORD_REG_OFFSET
#define NM_PLAYBACK_ENABLE_FLAG
void * pcm_getdevinfo(device_t dev)
int pcm_setstatus(device_t dev, char *str)
int pcm_addchan(device_t dev, int dir, kobj_class_t cls, void *devinfo)
int pcm_unregister(device_t dev)
int pcm_register(device_t dev, void *devinfo, int numplay, int numrec)
int snd_setup_intr(device_t dev, struct resource *res, int flags, driver_intr_t hand, void *param, void **cookiep)
#define SND_FORMAT(f, c, e)
struct pcm_channel * channel