t4dwave.c (59323) | t4dwave.c (60958) |
---|---|
1/* 2 * Copyright (c) 1999 Cameron Grant <gandalf@vilnya.demon.co.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) 1999 Cameron Grant <gandalf@vilnya.demon.co.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/t4dwave.c 59323 2000-04-17 16:57:12Z cg $ | 26 * $FreeBSD: head/sys/dev/sound/pci/t4dwave.c 60958 2000-05-26 21:15:47Z cg $ |
27 */ 28 29#include <dev/sound/pcm/sound.h> 30#include <dev/sound/pcm/ac97.h> 31#include <dev/sound/pci/t4dwave.h> 32 33#include <pci/pcireg.h> 34#include <pci/pcivar.h> --- 12 unchanged lines hidden (view full) --- 47 48/* channel registers */ 49struct tr_chinfo { 50 u_int32_t cso, alpha, fms, fmc, ec; 51 u_int32_t lba; 52 u_int32_t eso, delta; 53 u_int32_t rvol, cvol; 54 u_int32_t gvsel, pan, vol, ctrl; | 27 */ 28 29#include <dev/sound/pcm/sound.h> 30#include <dev/sound/pcm/ac97.h> 31#include <dev/sound/pci/t4dwave.h> 32 33#include <pci/pcireg.h> 34#include <pci/pcivar.h> --- 12 unchanged lines hidden (view full) --- 47 48/* channel registers */ 49struct tr_chinfo { 50 u_int32_t cso, alpha, fms, fmc, ec; 51 u_int32_t lba; 52 u_int32_t eso, delta; 53 u_int32_t rvol, cvol; 54 u_int32_t gvsel, pan, vol, ctrl; |
55 int index; | 55 int index, ss; |
56 snd_dbuf *buffer; 57 pcm_channel *channel; 58 struct tr_info *parent; 59}; 60 61/* device private data */ 62struct tr_info { 63 u_int32_t type; --- 369 unchanged lines hidden (view full) --- 433 434static int 435trchan_setformat(void *data, u_int32_t format) 436{ 437 struct tr_chinfo *ch = data; 438 struct tr_info *tr = ch->parent; 439 u_int32_t bits = tr_fmttobits(format); 440 | 56 snd_dbuf *buffer; 57 pcm_channel *channel; 58 struct tr_info *parent; 59}; 60 61/* device private data */ 62struct tr_info { 63 u_int32_t type; --- 369 unchanged lines hidden (view full) --- 433 434static int 435trchan_setformat(void *data, u_int32_t format) 436{ 437 struct tr_chinfo *ch = data; 438 struct tr_info *tr = ch->parent; 439 u_int32_t bits = tr_fmttobits(format); 440 |
441 ch->ss = 1; 442 ch->ss <<= (format & AFMT_STEREO)? 1 : 0; 443 ch->ss <<= (format & AFMT_16BIT)? 1 : 0; |
|
441 if (ch->index >= 0) { 442 tr_rdch(tr, ch->index, ch); | 444 if (ch->index >= 0) { 445 tr_rdch(tr, ch->index, ch); |
443 ch->eso = (ch->buffer->bufsize / ch->buffer->sample_size) - 1; | 446 ch->eso = (ch->buffer->bufsize / ch->ss) - 1; |
444 ch->ctrl = bits | 0x01; 445 tr_wrch(tr, ch->index, ch); 446 } else { 447 u_int32_t i; 448 /* set # of samples between interrupts */ 449 i = (TR_INTSAMPLES >> ((bits & 0x08)? 1 : 0)) - 1; 450 tr_wr(tr, TR_REG_SBBL, i | (i << 16), 4); 451 /* set sample format */ --- 31 unchanged lines hidden (view full) --- 483} 484 485static int 486trchan_trigger(void *data, int go) 487{ 488 struct tr_chinfo *ch = data; 489 struct tr_info *tr = ch->parent; 490 | 447 ch->ctrl = bits | 0x01; 448 tr_wrch(tr, ch->index, ch); 449 } else { 450 u_int32_t i; 451 /* set # of samples between interrupts */ 452 i = (TR_INTSAMPLES >> ((bits & 0x08)? 1 : 0)) - 1; 453 tr_wr(tr, TR_REG_SBBL, i | (i << 16), 4); 454 /* set sample format */ --- 31 unchanged lines hidden (view full) --- 486} 487 488static int 489trchan_trigger(void *data, int go) 490{ 491 struct tr_chinfo *ch = data; 492 struct tr_info *tr = ch->parent; 493 |
491 if (go == PCMTRIG_EMLDMAWR) return 0; | 494 if (go == PCMTRIG_EMLDMAWR || go == PCMTRIG_EMLDMARD) 495 return 0; 496 |
492 if (ch->index >= 0) { 493 if (go == PCMTRIG_START) { 494 tr_rdch(tr, ch->index, ch); 495 ch->cso = 0; 496 tr_wrch(tr, ch->index, ch); 497 tr_startch(tr, ch->index); 498 } else tr_stopch(tr, ch->index); 499 } else { 500 u_int32_t i = tr_rd(tr, TR_REG_SBCTRL, 1) & ~7; 501 tr_wr(tr, TR_REG_SBCTRL, i | (go == PCMTRIG_START)? 1 : 0, 1); 502 } 503 return 0; 504} 505 506static int 507trchan_getptr(void *data) 508{ 509 struct tr_chinfo *ch = data; 510 struct tr_info *tr = ch->parent; | 497 if (ch->index >= 0) { 498 if (go == PCMTRIG_START) { 499 tr_rdch(tr, ch->index, ch); 500 ch->cso = 0; 501 tr_wrch(tr, ch->index, ch); 502 tr_startch(tr, ch->index); 503 } else tr_stopch(tr, ch->index); 504 } else { 505 u_int32_t i = tr_rd(tr, TR_REG_SBCTRL, 1) & ~7; 506 tr_wr(tr, TR_REG_SBCTRL, i | (go == PCMTRIG_START)? 1 : 0, 1); 507 } 508 return 0; 509} 510 511static int 512trchan_getptr(void *data) 513{ 514 struct tr_chinfo *ch = data; 515 struct tr_info *tr = ch->parent; |
516 |
|
511 if (ch->index >= 0) { 512 tr_rdch(tr, ch->index, ch); | 517 if (ch->index >= 0) { 518 tr_rdch(tr, ch->index, ch); |
513 return ch->cso * ch->buffer->sample_size; | 519 return ch->cso * ch->ss; |
514 } else return tr_rd(tr, TR_REG_DMAR0, 4) - vtophys(ch->buffer->buf); 515} 516 517static pcmchan_caps * 518trchan_getcaps(void *data) 519{ 520 struct tr_chinfo *ch = data; 521 return (ch->index >= 0)? &tr_playcaps : &tr_reccaps; --- 174 unchanged lines hidden --- | 520 } else return tr_rd(tr, TR_REG_DMAR0, 4) - vtophys(ch->buffer->buf); 521} 522 523static pcmchan_caps * 524trchan_getcaps(void *data) 525{ 526 struct tr_chinfo *ch = data; 527 return (ch->index >= 0)? &tr_playcaps : &tr_reccaps; --- 174 unchanged lines hidden --- |