xref: /freebsd/sys/dev/sound/pcm/buffer.h (revision fc60109d91df9f84c660fbbea790f607aea4501e)
1350a5fafSCameron Grant /*
2350a5fafSCameron Grant  * Copyright (c) 1999 Cameron Grant <gandalf@vilnya.demon.co.uk>
3350a5fafSCameron Grant  * All rights reserved.
4350a5fafSCameron Grant  *
5350a5fafSCameron Grant  * Redistribution and use in source and binary forms, with or without
6350a5fafSCameron Grant  * modification, are permitted provided that the following conditions
7350a5fafSCameron Grant  * are met:
8350a5fafSCameron Grant  * 1. Redistributions of source code must retain the above copyright
9350a5fafSCameron Grant  *    notice, this list of conditions and the following disclaimer.
10350a5fafSCameron Grant  * 2. Redistributions in binary form must reproduce the above copyright
11350a5fafSCameron Grant  *    notice, this list of conditions and the following disclaimer in the
12350a5fafSCameron Grant  *    documentation and/or other materials provided with the distribution.
13350a5fafSCameron Grant  *
14350a5fafSCameron Grant  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15350a5fafSCameron Grant  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16350a5fafSCameron Grant  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17350a5fafSCameron Grant  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18350a5fafSCameron Grant  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19350a5fafSCameron Grant  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20350a5fafSCameron Grant  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21350a5fafSCameron Grant  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22350a5fafSCameron Grant  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23350a5fafSCameron Grant  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24350a5fafSCameron Grant  * SUCH DAMAGE.
25350a5fafSCameron Grant  *
26350a5fafSCameron Grant  * $FreeBSD$
27350a5fafSCameron Grant  */
28350a5fafSCameron Grant 
2966ef8af5SCameron Grant #define ISA_DMA(b) (sndbuf_getflags((b)) & SNDBUF_F_ISADMA)
3066ef8af5SCameron Grant #define SNDBUF_LOCKASSERT(b)
31350a5fafSCameron Grant 
3266ef8af5SCameron Grant #define	SNDBUF_F_ISADMA		0x00000001
3366ef8af5SCameron Grant #define	SNDBUF_F_XRUN		0x00000002
3466ef8af5SCameron Grant #define	SNDBUF_F_RUNNING	0x00000004
35350a5fafSCameron Grant 
3666ef8af5SCameron Grant struct snd_dbuf *sndbuf_create(char *drv, char *desc);
3766ef8af5SCameron Grant void sndbuf_destroy(struct snd_dbuf *b);
3866ef8af5SCameron Grant 
3966ef8af5SCameron Grant void sndbuf_dump(struct snd_dbuf *b, char *s, u_int32_t what);
4066ef8af5SCameron Grant 
4166ef8af5SCameron Grant int sndbuf_alloc(struct snd_dbuf *b, bus_dma_tag_t dmatag, unsigned int size);
4266ef8af5SCameron Grant int sndbuf_setup(struct snd_dbuf *b, void *buf, unsigned int size);
4366ef8af5SCameron Grant void sndbuf_free(struct snd_dbuf *b);
4466ef8af5SCameron Grant int sndbuf_resize(struct snd_dbuf *b, unsigned int blkcnt, unsigned int blksz);
4566ef8af5SCameron Grant int sndbuf_remalloc(struct snd_dbuf *b, unsigned int blkcnt, unsigned int blksz);
4666ef8af5SCameron Grant void sndbuf_reset(struct snd_dbuf *b);
4766ef8af5SCameron Grant void sndbuf_clear(struct snd_dbuf *b, unsigned int length);
48fc60109dSCameron Grant void sndbuf_fillsilence(struct snd_dbuf *b);
4966ef8af5SCameron Grant 
5066ef8af5SCameron Grant u_int32_t sndbuf_getfmt(struct snd_dbuf *b);
5166ef8af5SCameron Grant int sndbuf_setfmt(struct snd_dbuf *b, u_int32_t fmt);
5266ef8af5SCameron Grant unsigned int sndbuf_getspd(struct snd_dbuf *b);
5366ef8af5SCameron Grant void sndbuf_setspd(struct snd_dbuf *b, unsigned int spd);
5466ef8af5SCameron Grant unsigned int sndbuf_getbps(struct snd_dbuf *b);
5566ef8af5SCameron Grant 
5666ef8af5SCameron Grant void *sndbuf_getbuf(struct snd_dbuf *b);
5766ef8af5SCameron Grant void *sndbuf_getbufofs(struct snd_dbuf *b, unsigned int ofs);
5866ef8af5SCameron Grant unsigned int sndbuf_getsize(struct snd_dbuf *b);
5966ef8af5SCameron Grant unsigned int sndbuf_getmaxsize(struct snd_dbuf *b);
6066ef8af5SCameron Grant unsigned int sndbuf_getalign(struct snd_dbuf *b);
6166ef8af5SCameron Grant unsigned int sndbuf_getblkcnt(struct snd_dbuf *b);
6266ef8af5SCameron Grant void sndbuf_setblkcnt(struct snd_dbuf *b, unsigned int blkcnt);
6366ef8af5SCameron Grant unsigned int sndbuf_getblksz(struct snd_dbuf *b);
6466ef8af5SCameron Grant void sndbuf_setblksz(struct snd_dbuf *b, unsigned int blksz);
6566ef8af5SCameron Grant unsigned int sndbuf_runsz(struct snd_dbuf *b);
6666ef8af5SCameron Grant void sndbuf_setrun(struct snd_dbuf *b, int go);
6766ef8af5SCameron Grant struct selinfo *sndbuf_getsel(struct snd_dbuf *b);
6866ef8af5SCameron Grant 
6966ef8af5SCameron Grant unsigned int sndbuf_getxrun(struct snd_dbuf *b);
7066ef8af5SCameron Grant void sndbuf_setxrun(struct snd_dbuf *b, unsigned int cnt);
7166ef8af5SCameron Grant unsigned int sndbuf_gethwptr(struct snd_dbuf *b);
7266ef8af5SCameron Grant void sndbuf_sethwptr(struct snd_dbuf *b, unsigned int ptr);
7366ef8af5SCameron Grant unsigned int sndbuf_getfree(struct snd_dbuf *b);
7466ef8af5SCameron Grant unsigned int sndbuf_getfreeptr(struct snd_dbuf *b);
7566ef8af5SCameron Grant unsigned int sndbuf_getready(struct snd_dbuf *b);
7666ef8af5SCameron Grant unsigned int sndbuf_getreadyptr(struct snd_dbuf *b);
7766ef8af5SCameron Grant unsigned int sndbuf_getblocks(struct snd_dbuf *b);
7866ef8af5SCameron Grant unsigned int sndbuf_getprevblocks(struct snd_dbuf *b);
7966ef8af5SCameron Grant unsigned int sndbuf_gettotal(struct snd_dbuf *b);
8066ef8af5SCameron Grant void sndbuf_updateprevtotal(struct snd_dbuf *b);
8166ef8af5SCameron Grant 
8266ef8af5SCameron Grant int sndbuf_acquire(struct snd_dbuf *b, u_int8_t *from, unsigned int count);
8366ef8af5SCameron Grant int sndbuf_dispose(struct snd_dbuf *b, u_int8_t *to, unsigned int count);
8466ef8af5SCameron Grant int sndbuf_uiomove(struct snd_dbuf *b, struct uio *uio, unsigned int count);
8566ef8af5SCameron Grant int sndbuf_feed(struct snd_dbuf *from, struct snd_dbuf *to, struct pcm_channel *channel, struct pcm_feeder *feeder, unsigned int count);
8666ef8af5SCameron Grant 
8766ef8af5SCameron Grant u_int32_t sndbuf_getflags(struct snd_dbuf *b);
8866ef8af5SCameron Grant void sndbuf_setflags(struct snd_dbuf *b, u_int32_t flags, int on);
8966ef8af5SCameron Grant 
9066ef8af5SCameron Grant int sndbuf_isadmasetup(struct snd_dbuf *b, struct resource *drq);
9166ef8af5SCameron Grant int sndbuf_isadmasetdir(struct snd_dbuf *b, int dir);
9266ef8af5SCameron Grant void sndbuf_isadma(struct snd_dbuf *b, int go);
9366ef8af5SCameron Grant int sndbuf_isadmaptr(struct snd_dbuf *b);
9466ef8af5SCameron Grant void sndbuf_isadmabounce(struct snd_dbuf *b);
95350a5fafSCameron Grant 
96350a5fafSCameron Grant 
97