fm801.c (71506) | fm801.c (74763) |
---|---|
1/* 2 * Copyright (c) 2000 Dmitry Dicky diwil@dataart.com 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 9 unchanged lines hidden (view full) --- 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * | 1/* 2 * Copyright (c) 2000 Dmitry Dicky diwil@dataart.com 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 9 unchanged lines hidden (view full) --- 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * |
26 * $FreeBSD: head/sys/dev/sound/pci/fm801.c 71506 2001-01-24 01:36:15Z cg $ | 26 * $FreeBSD: head/sys/dev/sound/pci/fm801.c 74763 2001-03-24 23:10:29Z cg $ |
27 */ 28 29#include <dev/sound/pcm/sound.h> 30#include <dev/sound/pcm/ac97.h> 31#include <pci/pcireg.h> 32#include <pci/pcivar.h> 33 34#define PCI_VENDOR_FORTEMEDIA 0x1319 --- 62 unchanged lines hidden (view full) --- 97#define FM_INTSTATUS_MPU 0x8000 98 99#define FM801_BUFFSIZE 1024*4 /* Other values do not work!!! */ 100 101/* debug purposes */ 102#define DPRINT if(0) printf 103 104/* | 27 */ 28 29#include <dev/sound/pcm/sound.h> 30#include <dev/sound/pcm/ac97.h> 31#include <pci/pcireg.h> 32#include <pci/pcivar.h> 33 34#define PCI_VENDOR_FORTEMEDIA 0x1319 --- 62 unchanged lines hidden (view full) --- 97#define FM_INTSTATUS_MPU 0x8000 98 99#define FM801_BUFFSIZE 1024*4 /* Other values do not work!!! */ 100 101/* debug purposes */ 102#define DPRINT if(0) printf 103 104/* |
105static int fm801ch_setup(pcm_channel *c); | 105static int fm801ch_setup(struct pcm_channel *c); |
106*/ 107 108static u_int32_t fmts[] = { 109 AFMT_U8, 110 AFMT_STEREO | AFMT_U8, 111 AFMT_S16_LE, 112 AFMT_STEREO | AFMT_S16_LE, 113 0 114}; 115 | 106*/ 107 108static u_int32_t fmts[] = { 109 AFMT_U8, 110 AFMT_STEREO | AFMT_U8, 111 AFMT_S16_LE, 112 AFMT_STEREO | AFMT_S16_LE, 113 0 114}; 115 |
116static pcmchan_caps fm801ch_caps = { | 116static struct pcmchan_caps fm801ch_caps = { |
117 4000, 48000, 118 fmts, 0 119}; 120 121struct fm801_info; 122 123struct fm801_chinfo { 124 struct fm801_info *parent; | 117 4000, 48000, 118 fmts, 0 119}; 120 121struct fm801_info; 122 123struct fm801_chinfo { 124 struct fm801_info *parent; |
125 pcm_channel *channel; 126 snd_dbuf *buffer; | 125 struct pcm_channel *channel; 126 struct snd_dbuf *buffer; |
127 u_int32_t spd, dir, fmt; /* speed, direction, format */ 128 u_int32_t shift; 129}; 130 131struct fm801_info { 132 int type; 133 bus_space_tag_t st; 134 bus_space_handle_t sh; --- 178 unchanged lines hidden (view full) --- 313 314 DPRINT("fm801_intr clear\n\n"); 315 fm801_wr(fm801, FM_INTSTATUS, intsrc & (FM_INTSTATUS_PLAY | FM_INTSTATUS_REC), 2); 316} 317 318/* -------------------------------------------------------------------- */ 319/* channel interface */ 320static void * | 127 u_int32_t spd, dir, fmt; /* speed, direction, format */ 128 u_int32_t shift; 129}; 130 131struct fm801_info { 132 int type; 133 bus_space_tag_t st; 134 bus_space_handle_t sh; --- 178 unchanged lines hidden (view full) --- 313 314 DPRINT("fm801_intr clear\n\n"); 315 fm801_wr(fm801, FM_INTSTATUS, intsrc & (FM_INTSTATUS_PLAY | FM_INTSTATUS_REC), 2); 316} 317 318/* -------------------------------------------------------------------- */ 319/* channel interface */ 320static void * |
321fm801ch_init(kobj_t obj, void *devinfo, snd_dbuf *b, pcm_channel *c, int dir) | 321fm801ch_init(kobj_t obj, void *devinfo, struct snd_dbuf *b, struct pcm_channel *c, int dir) |
322{ 323 struct fm801_info *fm801 = (struct fm801_info *)devinfo; 324 struct fm801_chinfo *ch = (dir == PCMDIR_PLAY)? &fm801->pch : &fm801->rch; 325 326 DPRINT("fm801ch_init, direction = %d\n", dir); 327 ch->parent = fm801; 328 ch->channel = c; 329 ch->buffer = b; --- 169 unchanged lines hidden (view full) --- 499 result = fm801_rd(fm801, 500 (fm801->rec_flip&1) ? 501 FM_REC_DMABUF2:FM_REC_DMABUF1, 4) - fm801->rec_start; 502 } 503 504 return result; 505} 506 | 322{ 323 struct fm801_info *fm801 = (struct fm801_info *)devinfo; 324 struct fm801_chinfo *ch = (dir == PCMDIR_PLAY)? &fm801->pch : &fm801->rch; 325 326 DPRINT("fm801ch_init, direction = %d\n", dir); 327 ch->parent = fm801; 328 ch->channel = c; 329 ch->buffer = b; --- 169 unchanged lines hidden (view full) --- 499 result = fm801_rd(fm801, 500 (fm801->rec_flip&1) ? 501 FM_REC_DMABUF2:FM_REC_DMABUF1, 4) - fm801->rec_start; 502 } 503 504 return result; 505} 506 |
507static pcmchan_caps * | 507static struct pcmchan_caps * |
508fm801ch_getcaps(kobj_t obj, void *data) 509{ 510 return &fm801ch_caps; 511} 512 513static kobj_method_t fm801ch_methods[] = { 514 KOBJMETHOD(channel_init, fm801ch_init), 515 KOBJMETHOD(channel_setformat, fm801ch_setformat), --- 94 unchanged lines hidden (view full) --- 610 codec = AC97_CREATE(dev, fm801, fm801_ac97); 611 if (codec == NULL) goto oops; 612 613 if (mixer_init(dev, ac97_getmixerclass(), codec) == -1) goto oops; 614 615 fm801->irqid = 0; 616 fm801->irq = bus_alloc_resource(dev, SYS_RES_IRQ, &fm801->irqid, 617 0, ~0, 1, RF_ACTIVE | RF_SHAREABLE); | 508fm801ch_getcaps(kobj_t obj, void *data) 509{ 510 return &fm801ch_caps; 511} 512 513static kobj_method_t fm801ch_methods[] = { 514 KOBJMETHOD(channel_init, fm801ch_init), 515 KOBJMETHOD(channel_setformat, fm801ch_setformat), --- 94 unchanged lines hidden (view full) --- 610 codec = AC97_CREATE(dev, fm801, fm801_ac97); 611 if (codec == NULL) goto oops; 612 613 if (mixer_init(dev, ac97_getmixerclass(), codec) == -1) goto oops; 614 615 fm801->irqid = 0; 616 fm801->irq = bus_alloc_resource(dev, SYS_RES_IRQ, &fm801->irqid, 617 0, ~0, 1, RF_ACTIVE | RF_SHAREABLE); |
618 if (!fm801->irq || 619 bus_setup_intr(dev, fm801->irq, INTR_TYPE_TTY, 620 fm801_intr, fm801, &fm801->ih)) { | 618 if (!fm801->irq || snd_setup_intr(dev, fm801->irq, 0, fm801_intr, fm801, &fm801->ih)) { |
621 device_printf(dev, "unable to map interrupt\n"); 622 goto oops; 623 } 624 625 if (bus_dma_tag_create(/*parent*/NULL, /*alignment*/2, /*boundary*/0, 626 /*lowaddr*/BUS_SPACE_MAXADDR_32BIT, 627 /*highaddr*/BUS_SPACE_MAXADDR, 628 /*filter*/NULL, /*filterarg*/NULL, --- 69 unchanged lines hidden (view full) --- 698 DEVMETHOD(device_attach, fm801_pci_attach), 699 DEVMETHOD(device_detach, fm801_pci_detach), 700 { 0, 0} 701}; 702 703static driver_t fm801_driver = { 704 "pcm", 705 fm801_methods, | 619 device_printf(dev, "unable to map interrupt\n"); 620 goto oops; 621 } 622 623 if (bus_dma_tag_create(/*parent*/NULL, /*alignment*/2, /*boundary*/0, 624 /*lowaddr*/BUS_SPACE_MAXADDR_32BIT, 625 /*highaddr*/BUS_SPACE_MAXADDR, 626 /*filter*/NULL, /*filterarg*/NULL, --- 69 unchanged lines hidden (view full) --- 696 DEVMETHOD(device_attach, fm801_pci_attach), 697 DEVMETHOD(device_detach, fm801_pci_detach), 698 { 0, 0} 699}; 700 701static driver_t fm801_driver = { 702 "pcm", 703 fm801_methods, |
706 sizeof(snddev_info), | 704 sizeof(struct snddev_info), |
707}; 708 709static devclass_t pcm_devclass; 710 711DRIVER_MODULE(fm801, pci, fm801_driver, pcm_devclass, 0, 0); | 705}; 706 707static devclass_t pcm_devclass; 708 709DRIVER_MODULE(fm801, pci, fm801_driver, pcm_devclass, 0, 0); |