cs4281.c (73770) | cs4281.c (74763) |
---|---|
1/* 2 * Copyright (c) 2000 Orion Hodson <O.Hodson@cs.ucl.ac.uk> 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, WHETHERIN 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 THEPOSSIBILITY OF 24 * SUCH DAMAGE. 25 * | 1/* 2 * Copyright (c) 2000 Orion Hodson <O.Hodson@cs.ucl.ac.uk> 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, WHETHERIN 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 THEPOSSIBILITY OF 24 * SUCH DAMAGE. 25 * |
26 * $FreeBSD: head/sys/dev/sound/pci/cs4281.c 73770 2001-03-05 17:30:43Z cg $ | 26 * $FreeBSD: head/sys/dev/sound/pci/cs4281.c 74763 2001-03-24 23:10:29Z cg $ |
27 * 28 * The order of pokes in the initiation sequence is based on Linux 29 * driver by Thomas Sailer, gw boynton (wesb@crystal.cirrus.com), tom 30 * woller (twoller@crystal.cirrus.com). Shingo Watanabe (nabe@nabechan.org) 31 * contributed towards power management. 32 */ 33 34#include <dev/sound/pcm/sound.h> --- 28 unchanged lines hidden (view full) --- 63/* Structures */ 64 65struct sc_info; 66 67/* channel registers */ 68struct sc_chinfo { 69 struct sc_info *parent; 70 | 27 * 28 * The order of pokes in the initiation sequence is based on Linux 29 * driver by Thomas Sailer, gw boynton (wesb@crystal.cirrus.com), tom 30 * woller (twoller@crystal.cirrus.com). Shingo Watanabe (nabe@nabechan.org) 31 * contributed towards power management. 32 */ 33 34#include <dev/sound/pcm/sound.h> --- 28 unchanged lines hidden (view full) --- 63/* Structures */ 64 65struct sc_info; 66 67/* channel registers */ 68struct sc_chinfo { 69 struct sc_info *parent; 70 |
71 snd_dbuf *buffer; 72 pcm_channel *channel; | 71 struct snd_dbuf *buffer; 72 struct pcm_channel *channel; |
73 74 u_int32_t spd, fmt, bps, blksz; 75 76 int dma_setup, dma_active, dma_chan; 77}; 78 79/* device private data */ 80struct sc_info { --- 48 unchanged lines hidden (view full) --- 129 AFMT_U16_LE | AFMT_STEREO, 130 AFMT_S16_BE, 131 AFMT_S16_BE | AFMT_STEREO, 132 AFMT_U16_BE, 133 AFMT_U16_BE | AFMT_STEREO, 134 0 135}; 136 | 73 74 u_int32_t spd, fmt, bps, blksz; 75 76 int dma_setup, dma_active, dma_chan; 77}; 78 79/* device private data */ 80struct sc_info { --- 48 unchanged lines hidden (view full) --- 129 AFMT_U16_LE | AFMT_STEREO, 130 AFMT_S16_BE, 131 AFMT_S16_BE | AFMT_STEREO, 132 AFMT_U16_BE, 133 AFMT_U16_BE | AFMT_STEREO, 134 0 135}; 136 |
137static pcmchan_caps cs4281_caps = {6024, 48000, cs4281_fmts, 0}; | 137static struct pcmchan_caps cs4281_caps = {6024, 48000, cs4281_fmts, 0}; |
138 139/* -------------------------------------------------------------------- */ 140/* Hardware */ 141 142static inline u_int32_t 143cs4281_rd(struct sc_info *sc, int regno) 144{ 145 return bus_space_read_4(sc->st, sc->sh, regno); --- 159 unchanged lines hidden (view full) --- 305 { 0, 0 } 306}; 307AC97_DECLARE(cs4281_ac97); 308 309/* ------------------------------------------------------------------------- */ 310/* shared rec/play channel interface */ 311 312static void * | 138 139/* -------------------------------------------------------------------- */ 140/* Hardware */ 141 142static inline u_int32_t 143cs4281_rd(struct sc_info *sc, int regno) 144{ 145 return bus_space_read_4(sc->st, sc->sh, regno); --- 159 unchanged lines hidden (view full) --- 305 { 0, 0 } 306}; 307AC97_DECLARE(cs4281_ac97); 308 309/* ------------------------------------------------------------------------- */ 310/* shared rec/play channel interface */ 311 312static void * |
313cs4281chan_init(kobj_t obj, void *devinfo, snd_dbuf *b, pcm_channel *c, int dir) | 313cs4281chan_init(kobj_t obj, void *devinfo, struct snd_dbuf *b, struct pcm_channel *c, int dir) |
314{ 315 struct sc_info *sc = devinfo; 316 struct sc_chinfo *ch = (dir == PCMDIR_PLAY) ? &sc->pch : &sc->rch; 317 318 ch->buffer = b; 319 if (sndbuf_alloc(ch->buffer, sc->parent_dmat, CS4281_BUFFER_SIZE) != 0) { 320 return NULL; 321 } --- 110 unchanged lines hidden (view full) --- 432 default: 433 break; 434 } 435 436 /* return 0 if ok */ 437 return 0; 438} 439 | 314{ 315 struct sc_info *sc = devinfo; 316 struct sc_chinfo *ch = (dir == PCMDIR_PLAY) ? &sc->pch : &sc->rch; 317 318 ch->buffer = b; 319 if (sndbuf_alloc(ch->buffer, sc->parent_dmat, CS4281_BUFFER_SIZE) != 0) { 320 return NULL; 321 } --- 110 unchanged lines hidden (view full) --- 432 default: 433 break; 434 } 435 436 /* return 0 if ok */ 437 return 0; 438} 439 |
440static pcmchan_caps * | 440static struct pcmchan_caps * |
441cs4281chan_getcaps(kobj_t obj, void *data) 442{ 443 return &cs4281_caps; 444} 445 446static kobj_method_t cs4281chan_methods[] = { 447 KOBJMETHOD(channel_init, cs4281chan_init), 448 KOBJMETHOD(channel_setformat, cs4281chan_setformat), --- 356 unchanged lines hidden (view full) --- 805 sc->irqid = 0; 806 sc->irq = bus_alloc_resource(dev, SYS_RES_IRQ, &sc->irqid, 807 0, ~0, 1, RF_ACTIVE | RF_SHAREABLE); 808 if (!sc->irq) { 809 device_printf(dev, "unable to allocate interrupt\n"); 810 goto bad; 811 } 812 | 441cs4281chan_getcaps(kobj_t obj, void *data) 442{ 443 return &cs4281_caps; 444} 445 446static kobj_method_t cs4281chan_methods[] = { 447 KOBJMETHOD(channel_init, cs4281chan_init), 448 KOBJMETHOD(channel_setformat, cs4281chan_setformat), --- 356 unchanged lines hidden (view full) --- 805 sc->irqid = 0; 806 sc->irq = bus_alloc_resource(dev, SYS_RES_IRQ, &sc->irqid, 807 0, ~0, 1, RF_ACTIVE | RF_SHAREABLE); 808 if (!sc->irq) { 809 device_printf(dev, "unable to allocate interrupt\n"); 810 goto bad; 811 } 812 |
813 if (bus_setup_intr(dev, sc->irq, INTR_TYPE_TTY, cs4281_intr, sc, &sc->ih)) { | 813 if (snd_setup_intr(dev, sc->irq, 0, cs4281_intr, sc, &sc->ih)) { |
814 device_printf(dev, "unable to setup interrupt\n"); 815 goto bad; 816 } 817 818 if (bus_dma_tag_create(/*parent*/NULL, /*alignment*/2, /*boundary*/0, 819 /*lowaddr*/BUS_SPACE_MAXADDR_32BIT, 820 /*highaddr*/BUS_SPACE_MAXADDR, 821 /*filter*/NULL, /*filterarg*/NULL, --- 135 unchanged lines hidden (view full) --- 957 DEVMETHOD(device_suspend, cs4281_pci_suspend), 958 DEVMETHOD(device_resume, cs4281_pci_resume), 959 { 0, 0 } 960}; 961 962static driver_t cs4281_driver = { 963 "pcm", 964 cs4281_methods, | 814 device_printf(dev, "unable to setup interrupt\n"); 815 goto bad; 816 } 817 818 if (bus_dma_tag_create(/*parent*/NULL, /*alignment*/2, /*boundary*/0, 819 /*lowaddr*/BUS_SPACE_MAXADDR_32BIT, 820 /*highaddr*/BUS_SPACE_MAXADDR, 821 /*filter*/NULL, /*filterarg*/NULL, --- 135 unchanged lines hidden (view full) --- 957 DEVMETHOD(device_suspend, cs4281_pci_suspend), 958 DEVMETHOD(device_resume, cs4281_pci_resume), 959 { 0, 0 } 960}; 961 962static driver_t cs4281_driver = { 963 "pcm", 964 cs4281_methods, |
965 sizeof(snddev_info), | 965 sizeof(struct snddev_info), |
966}; 967 968static devclass_t pcm_devclass; 969 970DRIVER_MODULE(snd_cs4281, pci, cs4281_driver, pcm_devclass, 0, 0); 971MODULE_DEPEND(snd_cs4281, snd_pcm, PCM_MINVER, PCM_PREFVER, PCM_MAXVER); 972MODULE_VERSION(snd_cs4281, 1); | 966}; 967 968static devclass_t pcm_devclass; 969 970DRIVER_MODULE(snd_cs4281, pci, cs4281_driver, pcm_devclass, 0, 0); 971MODULE_DEPEND(snd_cs4281, snd_pcm, PCM_MINVER, PCM_PREFVER, PCM_MAXVER); 972MODULE_VERSION(snd_cs4281, 1); |