sndbuf_alloc() now accept dmaflags argument which will be forwarded to
internal bus_dmammem_alloc() for greater flexibility on setting up DMA / page attributes.
This commit is contained in:
parent
e492b75981
commit
2e334adf6a
@ -318,7 +318,7 @@ ad1816chan_init(kobj_t obj, void *devinfo, struct snd_dbuf *b, struct pcm_channe
|
||||
ch->parent = ad1816;
|
||||
ch->channel = c;
|
||||
ch->buffer = b;
|
||||
if (sndbuf_alloc(ch->buffer, ad1816->parent_dmat, ad1816->bufsize) != 0)
|
||||
if (sndbuf_alloc(ch->buffer, ad1816->parent_dmat, 0, ad1816->bufsize) != 0)
|
||||
return NULL;
|
||||
return ch;
|
||||
}
|
||||
|
@ -563,7 +563,7 @@ esschan_init(kobj_t obj, void *devinfo, struct snd_dbuf *b, struct pcm_channel *
|
||||
ch->parent = sc;
|
||||
ch->channel = c;
|
||||
ch->buffer = b;
|
||||
if (sndbuf_alloc(ch->buffer, sc->parent_dmat, sc->bufsize) != 0)
|
||||
if (sndbuf_alloc(ch->buffer, sc->parent_dmat, 0, sc->bufsize) != 0)
|
||||
return NULL;
|
||||
ch->dir = dir;
|
||||
ch->hwch = 1;
|
||||
|
@ -1152,7 +1152,7 @@ msschan_init(kobj_t obj, void *devinfo, struct snd_dbuf *b, struct pcm_channel *
|
||||
ch->channel = c;
|
||||
ch->buffer = b;
|
||||
ch->dir = dir;
|
||||
if (sndbuf_alloc(ch->buffer, mss->parent_dmat, mss->bufsize) != 0)
|
||||
if (sndbuf_alloc(ch->buffer, mss->parent_dmat, 0, mss->bufsize) != 0)
|
||||
return NULL;
|
||||
sndbuf_dmasetup(ch->buffer, (dir == PCMDIR_PLAY)? mss->drq1 : mss->drq2);
|
||||
return ch;
|
||||
|
@ -681,7 +681,7 @@ sb16chan_init(kobj_t obj, void *devinfo, struct snd_dbuf *b, struct pcm_channel
|
||||
ch->buffer = b;
|
||||
ch->dir = dir;
|
||||
|
||||
if (sndbuf_alloc(ch->buffer, sb->parent_dmat, sb->bufsize) != 0)
|
||||
if (sndbuf_alloc(ch->buffer, sb->parent_dmat, 0, sb->bufsize) != 0)
|
||||
return NULL;
|
||||
|
||||
return ch;
|
||||
|
@ -599,7 +599,7 @@ sbchan_init(kobj_t obj, void *devinfo, struct snd_dbuf *b, struct pcm_channel *c
|
||||
ch->channel = c;
|
||||
ch->dir = dir;
|
||||
ch->buffer = b;
|
||||
if (sndbuf_alloc(ch->buffer, sb->parent_dmat, sb->bufsize) != 0)
|
||||
if (sndbuf_alloc(ch->buffer, sb->parent_dmat, 0, sb->bufsize) != 0)
|
||||
return NULL;
|
||||
sndbuf_dmasetup(ch->buffer, sb->drq);
|
||||
return ch;
|
||||
|
@ -221,7 +221,7 @@ alschan_init(kobj_t obj, void *devinfo,
|
||||
ch->buffer = b;
|
||||
snd_mtxunlock(sc->lock);
|
||||
|
||||
if (sndbuf_alloc(ch->buffer, sc->parent_dmat, sc->bufsz) != 0)
|
||||
if (sndbuf_alloc(ch->buffer, sc->parent_dmat, 0, sc->bufsz) != 0)
|
||||
return NULL;
|
||||
|
||||
return ch;
|
||||
|
@ -459,7 +459,7 @@ atiixp_chan_init(kobj_t obj, void *devinfo, struct snd_dbuf *b,
|
||||
|
||||
atiixp_unlock(sc);
|
||||
|
||||
if (sndbuf_alloc(ch->buffer, sc->parent_dmat, sc->bufsz) == -1)
|
||||
if (sndbuf_alloc(ch->buffer, sc->parent_dmat, 0, sc->bufsz) == -1)
|
||||
return (NULL);
|
||||
|
||||
atiixp_lock(sc);
|
||||
|
@ -332,7 +332,7 @@ au88x0_chan_init(kobj_t obj, void *arg,
|
||||
struct au88x0_info *aui = arg;
|
||||
struct au88x0_chan_info *auci = au88x0_channel(aui, dir);
|
||||
|
||||
if (sndbuf_alloc(buf, aui->aui_dmat, aui->aui_bufsize) != 0)
|
||||
if (sndbuf_alloc(buf, aui->aui_dmat, 0, aui->aui_bufsize) != 0)
|
||||
return (NULL);
|
||||
auci->auci_aui = aui;
|
||||
auci->auci_pcmchan = chan;
|
||||
|
@ -303,7 +303,7 @@ auchan_init(kobj_t obj, void *devinfo, struct snd_dbuf *b, struct pcm_channel *c
|
||||
ch->channel = c;
|
||||
ch->buffer = b;
|
||||
ch->dir = dir;
|
||||
if (sndbuf_alloc(ch->buffer, au->parent_dmat, AU_BUFFSIZE) != 0)
|
||||
if (sndbuf_alloc(ch->buffer, au->parent_dmat, 0, AU_BUFFSIZE) != 0)
|
||||
return NULL;
|
||||
return ch;
|
||||
}
|
||||
|
@ -349,7 +349,7 @@ cmichan_init(kobj_t obj, void *devinfo,
|
||||
ch->spd = DSP_DEFAULT_SPEED;
|
||||
ch->buffer = b;
|
||||
ch->dma_active = 0;
|
||||
if (sndbuf_alloc(ch->buffer, sc->parent_dmat, sc->bufsz) != 0) {
|
||||
if (sndbuf_alloc(ch->buffer, sc->parent_dmat, 0, sc->bufsz) != 0) {
|
||||
DEB(printf("cmichan_init failed\n"));
|
||||
return NULL;
|
||||
}
|
||||
|
@ -314,7 +314,7 @@ cs4281chan_init(kobj_t obj, void *devinfo, struct snd_dbuf *b, struct pcm_channe
|
||||
struct sc_chinfo *ch = (dir == PCMDIR_PLAY) ? &sc->pch : &sc->rch;
|
||||
|
||||
ch->buffer = b;
|
||||
if (sndbuf_alloc(ch->buffer, sc->parent_dmat, sc->bufsz) != 0) {
|
||||
if (sndbuf_alloc(ch->buffer, sc->parent_dmat, 0, sc->bufsz) != 0) {
|
||||
return NULL;
|
||||
}
|
||||
ch->parent = sc;
|
||||
|
@ -534,7 +534,7 @@ csachan_init(kobj_t obj, void *devinfo, struct snd_dbuf *b, struct pcm_channel *
|
||||
ch->channel = c;
|
||||
ch->buffer = b;
|
||||
ch->dir = dir;
|
||||
if (sndbuf_alloc(ch->buffer, csa->parent_dmat, CS461x_BUFFSIZE) != 0)
|
||||
if (sndbuf_alloc(ch->buffer, csa->parent_dmat, 0, CS461x_BUFFSIZE) != 0)
|
||||
return NULL;
|
||||
return ch;
|
||||
}
|
||||
|
@ -490,7 +490,7 @@ ds1pchan_init(kobj_t obj, void *devinfo, struct snd_dbuf *b, struct pcm_channel
|
||||
ch->fmt = AFMT_U8;
|
||||
ch->spd = 8000;
|
||||
ch->run = 0;
|
||||
if (sndbuf_alloc(ch->buffer, sc->buffer_dmat, sc->bufsz) != 0)
|
||||
if (sndbuf_alloc(ch->buffer, sc->buffer_dmat, 0, sc->bufsz) != 0)
|
||||
return NULL;
|
||||
else {
|
||||
ch->lsnum = sc->pslotfree;
|
||||
@ -621,7 +621,7 @@ ds1rchan_init(kobj_t obj, void *devinfo, struct snd_dbuf *b, struct pcm_channel
|
||||
ch->dir = dir;
|
||||
ch->fmt = AFMT_U8;
|
||||
ch->spd = 8000;
|
||||
if (sndbuf_alloc(ch->buffer, sc->buffer_dmat, sc->bufsz) != 0)
|
||||
if (sndbuf_alloc(ch->buffer, sc->buffer_dmat, 0, sc->bufsz) != 0)
|
||||
return NULL;
|
||||
else {
|
||||
ch->slot = (ch->num == DS1_RECPRIMARY)? sc->rbank + 2: sc->rbank;
|
||||
|
@ -895,7 +895,7 @@ emurchan_init(kobj_t obj, void *devinfo, struct snd_dbuf *b,
|
||||
break;
|
||||
}
|
||||
sc->rnum++;
|
||||
if (sndbuf_alloc(ch->buffer, sc->parent_dmat, sc->bufsz) != 0)
|
||||
if (sndbuf_alloc(ch->buffer, sc->parent_dmat, 0, sc->bufsz) != 0)
|
||||
return NULL;
|
||||
else {
|
||||
snd_mtxlock(sc->lock);
|
||||
|
@ -602,7 +602,7 @@ emurchan_init(kobj_t obj __unused, void *devinfo, struct snd_dbuf *b, struct pcm
|
||||
ch->irqmask = INTE_ADCBUFENABLE;
|
||||
ch->iprmask = IPR_ADCBUFFULL | IPR_ADCBUFHALFFULL;
|
||||
|
||||
if (sndbuf_alloc(ch->buffer, emu_gettag(sc->card), sc->bufsz) != 0)
|
||||
if (sndbuf_alloc(ch->buffer, emu_gettag(sc->card), 0, sc->bufsz) != 0)
|
||||
return (NULL);
|
||||
else {
|
||||
emu_wrptr(sc->card, 0, ch->basereg, sndbuf_getbufaddr(ch->buffer));
|
||||
@ -761,7 +761,7 @@ emufxrchan_init(kobj_t obj __unused, void *devinfo, struct snd_dbuf *b, struct p
|
||||
ch->channel = c;
|
||||
ch->blksz = sc->bufsz;
|
||||
|
||||
if (sndbuf_alloc(ch->buffer, emu_gettag(sc->card), sc->bufsz) != 0)
|
||||
if (sndbuf_alloc(ch->buffer, emu_gettag(sc->card), 0, sc->bufsz) != 0)
|
||||
return (NULL);
|
||||
else {
|
||||
emu_wrptr(sc->card, 0, ch->basereg, sndbuf_getbufaddr(ch->buffer));
|
||||
|
@ -471,7 +471,7 @@ eschan_init(kobj_t obj, void *devinfo, struct snd_dbuf *b,
|
||||
ch->blksz = ch->bufsz / ch->blkcnt;
|
||||
ch->dir = dir;
|
||||
ES_UNLOCK(es);
|
||||
if (sndbuf_alloc(ch->buffer, es->parent_dmat, ch->bufsz) != 0)
|
||||
if (sndbuf_alloc(ch->buffer, es->parent_dmat, 0, ch->bufsz) != 0)
|
||||
return (NULL);
|
||||
ES_LOCK(es);
|
||||
if (dir == PCMDIR_PLAY) {
|
||||
|
@ -334,7 +334,7 @@ fm801ch_init(kobj_t obj, void *devinfo, struct snd_dbuf *b, struct pcm_channel *
|
||||
ch->channel = c;
|
||||
ch->buffer = b;
|
||||
ch->dir = dir;
|
||||
if (sndbuf_alloc(ch->buffer, fm801->parent_dmat, fm801->bufsz) != 0)
|
||||
if (sndbuf_alloc(ch->buffer, fm801->parent_dmat, 0, fm801->bufsz) != 0)
|
||||
return NULL;
|
||||
return (void *)ch;
|
||||
}
|
||||
|
@ -2710,7 +2710,7 @@ hdac_channel_init(kobj_t obj, void *data, struct snd_dbuf *b,
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
if (sndbuf_alloc(ch->b, sc->chan_dmat, sc->chan_size) != 0)
|
||||
if (sndbuf_alloc(ch->b, sc->chan_dmat, 0, sc->chan_size) != 0)
|
||||
return (NULL);
|
||||
|
||||
hdac_dma_attr((vm_offset_t)ch->b->buf, sndbuf_getmaxsize(ch->b),
|
||||
|
@ -393,7 +393,7 @@ ichchan_init(kobj_t obj, void *devinfo, struct snd_dbuf *b, struct pcm_channel *
|
||||
ch->spdreg = 0;
|
||||
|
||||
ICH_UNLOCK(sc);
|
||||
if (sndbuf_alloc(ch->buffer, sc->dmat, sc->bufsz) != 0)
|
||||
if (sndbuf_alloc(ch->buffer, sc->dmat, 0, sc->bufsz) != 0)
|
||||
return (NULL);
|
||||
|
||||
ICH_LOCK(sc);
|
||||
|
@ -407,7 +407,7 @@ m3_pchan_init(kobj_t kobj, void *devinfo, struct snd_dbuf *b, struct pcm_channel
|
||||
ch->fmt = AFMT_U8;
|
||||
ch->spd = DSP_DEFAULT_SPEED;
|
||||
M3_UNLOCK(sc); /* XXX */
|
||||
if (sndbuf_alloc(ch->buffer, sc->parent_dmat, sc->bufsz) != 0) {
|
||||
if (sndbuf_alloc(ch->buffer, sc->parent_dmat, 0, sc->bufsz) != 0) {
|
||||
device_printf(sc->dev, "m3_pchan_init chn_allocbuf failed\n");
|
||||
return (NULL);
|
||||
}
|
||||
@ -756,7 +756,7 @@ m3_rchan_init(kobj_t kobj, void *devinfo, struct snd_dbuf *b, struct pcm_channel
|
||||
ch->fmt = AFMT_U8;
|
||||
ch->spd = DSP_DEFAULT_SPEED;
|
||||
M3_UNLOCK(sc); /* XXX */
|
||||
if (sndbuf_alloc(ch->buffer, sc->parent_dmat, sc->bufsz) != 0) {
|
||||
if (sndbuf_alloc(ch->buffer, sc->parent_dmat, 0, sc->bufsz) != 0) {
|
||||
device_printf(sc->dev, "m3_rchan_init chn_allocbuf failed\n");
|
||||
return (NULL);
|
||||
}
|
||||
|
@ -538,7 +538,7 @@ esschan_init(kobj_t obj, void *devinfo, struct snd_dbuf *b, struct pcm_channel *
|
||||
ch->channel = c;
|
||||
ch->buffer = b;
|
||||
ch->dir = dir;
|
||||
if (sndbuf_alloc(ch->buffer, sc->parent_dmat, sc->bufsz) != 0)
|
||||
if (sndbuf_alloc(ch->buffer, sc->parent_dmat, 0, sc->bufsz) != 0)
|
||||
return NULL;
|
||||
ch->hwch = 1;
|
||||
if ((dir == PCMDIR_PLAY) && (sc->duplex))
|
||||
|
@ -494,7 +494,7 @@ trpchan_init(kobj_t obj, void *devinfo, struct snd_dbuf *b, struct pcm_channel *
|
||||
ch->buffer = b;
|
||||
ch->parent = tr;
|
||||
ch->channel = c;
|
||||
if (sndbuf_alloc(ch->buffer, tr->parent_dmat, tr->bufsz) != 0)
|
||||
if (sndbuf_alloc(ch->buffer, tr->parent_dmat, 0, tr->bufsz) != 0)
|
||||
return NULL;
|
||||
|
||||
return ch;
|
||||
@ -602,7 +602,7 @@ trrchan_init(kobj_t obj, void *devinfo, struct snd_dbuf *b, struct pcm_channel *
|
||||
ch->buffer = b;
|
||||
ch->parent = tr;
|
||||
ch->channel = c;
|
||||
if (sndbuf_alloc(ch->buffer, tr->parent_dmat, tr->bufsz) != 0)
|
||||
if (sndbuf_alloc(ch->buffer, tr->parent_dmat, 0, tr->bufsz) != 0)
|
||||
return NULL;
|
||||
|
||||
return ch;
|
||||
|
@ -671,7 +671,7 @@ via8233wr_init(kobj_t obj, void *devinfo, struct snd_dbuf *b,
|
||||
via_wr(via, ch->rbase + VIA_WR_RP_SGD_FORMAT, WR_FIFO_ENABLE, 1);
|
||||
snd_mtxunlock(via->lock);
|
||||
|
||||
if (sndbuf_alloc(ch->buffer, via->parent_dmat, via->bufsz) != 0)
|
||||
if (sndbuf_alloc(ch->buffer, via->parent_dmat, 0, via->bufsz) != 0)
|
||||
return (NULL);
|
||||
|
||||
snd_mtxlock(via->lock);
|
||||
@ -705,7 +705,7 @@ via8233dxs_init(kobj_t obj, void *devinfo, struct snd_dbuf *b,
|
||||
via->n_dxs_registered++;
|
||||
snd_mtxunlock(via->lock);
|
||||
|
||||
if (sndbuf_alloc(ch->buffer, via->parent_dmat, via->bufsz) != 0)
|
||||
if (sndbuf_alloc(ch->buffer, via->parent_dmat, 0, via->bufsz) != 0)
|
||||
return (NULL);
|
||||
|
||||
snd_mtxlock(via->lock);
|
||||
@ -730,7 +730,7 @@ via8233msgd_init(kobj_t obj, void *devinfo, struct snd_dbuf *b,
|
||||
ch->rbase = VIA_MC_SGD_STATUS;
|
||||
ch->blkcnt = via->blkcnt;
|
||||
|
||||
if (sndbuf_alloc(ch->buffer, via->parent_dmat, via->bufsz) != 0)
|
||||
if (sndbuf_alloc(ch->buffer, via->parent_dmat, 0, via->bufsz) != 0)
|
||||
return (NULL);
|
||||
|
||||
snd_mtxlock(via->lock);
|
||||
|
@ -270,7 +270,7 @@ viachan_init(kobj_t obj, void *devinfo, struct snd_dbuf *b, struct pcm_channel *
|
||||
ch->dir = dir;
|
||||
snd_mtxunlock(via->lock);
|
||||
|
||||
if (sndbuf_alloc(ch->buffer, via->parent_dmat, via->bufsz) != 0)
|
||||
if (sndbuf_alloc(ch->buffer, via->parent_dmat, 0, via->bufsz) != 0)
|
||||
return NULL;
|
||||
|
||||
return ch;
|
||||
|
@ -192,7 +192,7 @@ svchan_init(kobj_t obj, void *devinfo, struct snd_dbuf *b, struct pcm_channel *c
|
||||
ch->channel = c;
|
||||
ch->dir = dir;
|
||||
|
||||
if (sndbuf_alloc(b, sc->parent_dmat, sc->bufsz) != 0) {
|
||||
if (sndbuf_alloc(b, sc->parent_dmat, 0, sc->bufsz) != 0) {
|
||||
DEB(printf("svchan_init failed\n"));
|
||||
return NULL;
|
||||
}
|
||||
|
@ -78,16 +78,18 @@ sndbuf_setmap(void *arg, bus_dma_segment_t *segs, int nseg, int error)
|
||||
*/
|
||||
|
||||
int
|
||||
sndbuf_alloc(struct snd_dbuf *b, bus_dma_tag_t dmatag, unsigned int size)
|
||||
sndbuf_alloc(struct snd_dbuf *b, bus_dma_tag_t dmatag, int dmaflags,
|
||||
unsigned int size)
|
||||
{
|
||||
int ret;
|
||||
|
||||
b->dmatag = dmatag;
|
||||
b->dmaflags = dmaflags | BUS_DMA_NOWAIT;
|
||||
b->maxsize = size;
|
||||
b->bufsize = b->maxsize;
|
||||
b->buf_addr = 0;
|
||||
b->flags |= SNDBUF_F_MANAGED;
|
||||
if (bus_dmamem_alloc(b->dmatag, (void **)&b->buf, BUS_DMA_NOWAIT,
|
||||
if (bus_dmamem_alloc(b->dmatag, (void **)&b->buf, b->dmaflags,
|
||||
&b->dmamap)) {
|
||||
sndbuf_free(b);
|
||||
return (ENOMEM);
|
||||
|
@ -54,6 +54,7 @@ struct snd_dbuf {
|
||||
u_int32_t flags;
|
||||
bus_dmamap_t dmamap;
|
||||
bus_dma_tag_t dmatag;
|
||||
int dmaflags;
|
||||
u_int32_t buf_addr;
|
||||
struct selinfo sel;
|
||||
struct pcm_channel *channel;
|
||||
@ -65,7 +66,7 @@ void sndbuf_destroy(struct snd_dbuf *b);
|
||||
|
||||
void sndbuf_dump(struct snd_dbuf *b, char *s, u_int32_t what);
|
||||
|
||||
int sndbuf_alloc(struct snd_dbuf *b, bus_dma_tag_t dmatag, unsigned int size);
|
||||
int sndbuf_alloc(struct snd_dbuf *b, bus_dma_tag_t dmatag, int dmaflags, unsigned int size);
|
||||
int sndbuf_setup(struct snd_dbuf *b, void *buf, unsigned int size);
|
||||
void sndbuf_free(struct snd_dbuf *b);
|
||||
int sndbuf_resize(struct snd_dbuf *b, unsigned int blkcnt, unsigned int blksz);
|
||||
|
@ -1036,7 +1036,7 @@ cs4231_chan_init(kobj_t obj, void *dev, struct snd_dbuf *b,
|
||||
else
|
||||
dmat = sc->sc_dmat[0];
|
||||
}
|
||||
if (sndbuf_alloc(ch->buffer, dmat, sc->sc_bufsz) != 0)
|
||||
if (sndbuf_alloc(ch->buffer, dmat, 0, sc->sc_bufsz) != 0)
|
||||
return (NULL);
|
||||
DPRINTF(("%s channel addr: 0x%lx\n", dir == PCMDIR_PLAY ? "playback" :
|
||||
"capture", sndbuf_getbufaddr(ch->buffer)));
|
||||
|
Loading…
Reference in New Issue
Block a user