31#ifdef HAVE_KERNEL_OPTION_HEADERS
40#define SND_DECLARE_FXDIV
41#include "snd_fxdiv_gen.h"
50 b = malloc(
sizeof(*
b), M_DEVBUF, M_WAITOK | M_ZERO);
68 return (
buf->buf_addr);
77 device_printf(
b->
dev,
"sndbuf_setmap %lx, %lx; ",
78 (u_long)segs[0].ds_addr, (u_long)segs[0].ds_len);
79 printf(
"%p -> %lx\n",
b->
buf, (u_long)segs[0].ds_addr);
125 b->
flags &= ~SNDBUF_F_MANAGED;
161#define SNDBUF_CACHE_SHIFT 5
192 printf(
"%s(): b=%p %p -> %p [%d -> %d : %d]\n",
200 printf(
"%s(): b=%p %d [%d] NOCHANGE\n",
242 printf(
"%s(): b=%p %d -> %d [%d]\n",
246 printf(
"%s(): b=%p %d [%d] NOCHANGE\n",
429 KASSERT(ofs < b->
bufsize, (
"%s: ofs invalid %d", __func__, ofs));
507 KASSERT((
b->
rl >= 0) && (
b->
rl <=
b->
bufsize), (
"%s: b->rl invalid %d", __func__,
b->
rl));
516 KASSERT((
b->
rp >= 0) && (
b->
rp <=
b->
bufsize), (
"%s: b->rp invalid %d", __func__,
b->
rp));
525 KASSERT((
b->
rl >= 0) && (
b->
rl <=
b->
bufsize), (
"%s: b->rl invalid %d", __func__,
b->
rl));
534 KASSERT((
b->
rp >= 0) && (
b->
rp <=
b->
bufsize), (
"%s: b->rp invalid %d", __func__,
b->
rp));
535 KASSERT((
b->
rl >= 0) && (
b->
rl <=
b->
bufsize), (
"%s: b->rl invalid %d", __func__,
b->
rl));
583 if (from == NULL || to == NULL || v == 0)
595 else if (
fmt & AFMT_MU_LAW)
597 else if (
fmt & AFMT_A_LAW)
623 KASSERT((
b->
rl >= 0) && (
b->
rl <=
b->
bufsize), (
"%s: b->rl invalid %d", __func__,
b->
rl));
635 KASSERT((
b->
rl >= 0) && (
b->
rl <=
b->
bufsize), (
"%s: b->rl invalid %d, count %d", __func__,
b->
rl,
count));
660 KASSERT((
b->
rl >= 0) && (
b->
rl <=
b->
bufsize), (
"%s: b->rl invalid %d", __func__,
b->
rl));
674 KASSERT((
b->
rl >= 0) && (
b->
rl <=
b->
bufsize), (
"%s: b->rl invalid %d, count %d", __func__,
b->
rl,
count));
680static uint32_t snd_feeder_maxfeed = 0;
681SYSCTL_UINT(_hw_snd, OID_AUTO, feeder_maxfeed, CTLFLAG_RD,
682 &snd_feeder_maxfeed, 0,
"maximum feeder count request");
684static uint32_t snd_feeder_maxcycle = 0;
685SYSCTL_UINT(_hw_snd, OID_AUTO, feeder_maxcycle, CTLFLAG_RD,
686 &snd_feeder_maxcycle, 0,
"maximum feeder cycle");
693 unsigned int cnt, maxfeed;
697 if (
count > snd_feeder_maxfeed)
698 snd_feeder_maxfeed =
count;
703 KASSERT(
count > 0, (
"can't feed 0 bytes"));
712 min(
count, maxfeed), from);
720 }
while (
count != 0);
723 if (cycle > snd_feeder_maxcycle)
724 snd_feeder_maxcycle = cycle;
739 printf(
" dl: %d, rp: %d, rl: %d, hp: %d",
b->
dl,
b->
rp,
b->
rl,
b->
hp);
743 printf(
" fmt: 0x%x, spd: %d",
b->
fmt,
b->
spd);
772 KASSERT(
b != NULL, (
"b is a null pointer"));
773 KASSERT(
b->
sl >= 0, (
"illegal shadow length"));
779#ifdef OSSV4_EXPERIMENT
794sndbuf_getpeaks(
struct snd_dbuf *
b,
int *lp,
int *rp)
SYSCTL_UINT(_hw_usb_atp, OID_AUTO, touch_timeout, CTLFLAG_RWTUN, &atp_touch_timeout, 125000, "age threshold in microseconds for a touch")
u_int32_t sndbuf_getflags(struct snd_dbuf *b)
int sndbuf_setup(struct snd_dbuf *b, void *buf, unsigned int size)
u_int64_t sndbuf_gettotal(struct snd_dbuf *b)
void sndbuf_clear(struct snd_dbuf *b, unsigned int length)
Zero out space in buffer free area.
u_int8_t sndbuf_zerodata(u_int32_t fmt)
unsigned int sndbuf_getspd(struct snd_dbuf *b)
int sndbuf_acquire(struct snd_dbuf *b, u_int8_t *from, unsigned int count)
Acquire buffer space to extend ready area.
int sndbuf_alloc(struct snd_dbuf *b, bus_dma_tag_t dmatag, int dmaflags, unsigned int size)
void * sndbuf_getbuf(struct snd_dbuf *b)
unsigned int sndbuf_getblkcnt(struct snd_dbuf *b)
#define SNDBUF_CACHE_SHIFT
bus_addr_t sndbuf_getbufaddr(struct snd_dbuf *buf)
unsigned int sndbuf_getalign(struct snd_dbuf *b)
void sndbuf_setblkcnt(struct snd_dbuf *b, unsigned int blkcnt)
void sndbuf_reset(struct snd_dbuf *b)
void sndbuf_setblksz(struct snd_dbuf *b, unsigned int blksz)
static void sndbuf_setmap(void *arg, bus_dma_segment_t *segs, int nseg, int error)
unsigned int sndbuf_getblksz(struct snd_dbuf *b)
void sndbuf_setspd(struct snd_dbuf *b, unsigned int spd)
void sndbuf_setxrun(struct snd_dbuf *b, unsigned int xrun)
u_int64_t sndbuf_getprevblocks(struct snd_dbuf *b)
SND_DECLARE_FILE("$FreeBSD$")
int sndbuf_remalloc(struct snd_dbuf *b, unsigned int blkcnt, unsigned int blksz)
unsigned int sndbuf_getallocsize(struct snd_dbuf *b)
unsigned int sndbuf_getfreeptr(struct snd_dbuf *b)
void sndbuf_fillsilence(struct snd_dbuf *b)
Zap buffer contents, resetting "ready area" fields.
int sndbuf_setfmt(struct snd_dbuf *b, u_int32_t fmt)
void sndbuf_updateprevtotal(struct snd_dbuf *b)
void sndbuf_dump(struct snd_dbuf *b, char *s, u_int32_t what)
unsigned int sndbuf_getfree(struct snd_dbuf *b)
unsigned int sndbuf_getmaxsize(struct snd_dbuf *b)
void sndbuf_destroy(struct snd_dbuf *b)
u_int32_t sndbuf_getfmt(struct snd_dbuf *b)
unsigned int sndbuf_getxrun(struct snd_dbuf *b)
unsigned int sndbuf_xbytes(unsigned int v, struct snd_dbuf *from, struct snd_dbuf *to)
unsigned int sndbuf_getready(struct snd_dbuf *b)
unsigned int sndbuf_getsize(struct snd_dbuf *b)
void sndbuf_softreset(struct snd_dbuf *b)
Reset buffer w/o flushing statistics.
void sndbuf_free(struct snd_dbuf *b)
struct snd_dbuf * sndbuf_create(device_t dev, char *drv, char *desc, struct pcm_channel *channel)
void sndbuf_setrun(struct snd_dbuf *b, int go)
void sndbuf_fillsilence_rl(struct snd_dbuf *b, u_int rl)
struct selinfo * sndbuf_getsel(struct snd_dbuf *b)
unsigned int sndbuf_gethwptr(struct snd_dbuf *b)
unsigned int sndbuf_getbps(struct snd_dbuf *b)
void * sndbuf_getbufofs(struct snd_dbuf *b, unsigned int ofs)
void sndbuf_clearshadow(struct snd_dbuf *b)
Clear the shadow buffer by filling with samples equal to zero.
void sndbuf_setflags(struct snd_dbuf *b, u_int32_t flags, int on)
u_int64_t sndbuf_getprevtotal(struct snd_dbuf *b)
int sndbuf_resize(struct snd_dbuf *b, unsigned int blkcnt, unsigned int blksz)
unsigned int sndbuf_runsz(struct snd_dbuf *b)
u_int64_t sndbuf_getblocks(struct snd_dbuf *b)
int sndbuf_feed(struct snd_dbuf *from, struct snd_dbuf *to, struct pcm_channel *channel, struct pcm_feeder *feeder, unsigned int count)
int sndbuf_dispose(struct snd_dbuf *b, u_int8_t *to, unsigned int count)
Dispose samples from channel buffer, increasing size of ready area.
unsigned int sndbuf_getreadyptr(struct snd_dbuf *b)
void sndbuf_sethwptr(struct snd_dbuf *b, unsigned int ptr)
static u_int32_t snd_xbytes(u_int32_t v, u_int32_t from, u_int32_t to)
#define SNDBUF_LOCKASSERT(b)
volatile u_int64_t prev_total
char name[SNDBUF_NAMELEN]
struct pcm_channel * channel