1 /*
2 * Copyright (c) 1999 Cameron Grant <cg@freebsd.org>
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 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
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, WHETHER IN 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 THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 * $FreeBSD: releng/5.2/sys/dev/sound/pcm/buffer.h 123013 2003-11-27 19:51:44Z matk $
27 */
28
29 #define SND_DMA(b) (sndbuf_getflags((b)) & SNDBUF_F_DMA)
30 #define SNDBUF_LOCKASSERT(b)
31
32 #define SNDBUF_F_DMA 0x00000001
33 #define SNDBUF_F_XRUN 0x00000002
34 #define SNDBUF_F_RUNNING 0x00000004
35
36 #define SNDBUF_NAMELEN 48
37
38 struct snd_dbuf {
39 device_t dev;
40 u_int8_t *buf, *tmpbuf;
41 unsigned int bufsize, maxsize;
42 volatile int dl; /* transfer size */
43 volatile int rp; /* pointers to the ready area */
44 volatile int rl; /* length of ready area */
45 volatile int hp;
46 volatile u_int32_t total, prev_total;
47 int dmachan, dir; /* dma channel */
48 u_int32_t fmt, spd, bps;
49 unsigned int blksz, blkcnt;
50 int xrun;
51 u_int32_t flags;
52 bus_dmamap_t dmamap;
53 bus_dma_tag_t dmatag;
54 u_int32_t buf_addr;
55 struct selinfo sel;
56 char name[SNDBUF_NAMELEN];
57 };
58
59 struct snd_dbuf *sndbuf_create(device_t dev, char *drv, char *desc);
60 void sndbuf_destroy(struct snd_dbuf *b);
61
62 void sndbuf_dump(struct snd_dbuf *b, char *s, u_int32_t what);
63
64 int sndbuf_alloc(struct snd_dbuf *b, bus_dma_tag_t dmatag, unsigned int size);
65 int sndbuf_setup(struct snd_dbuf *b, void *buf, unsigned int size);
66 void sndbuf_free(struct snd_dbuf *b);
67 int sndbuf_resize(struct snd_dbuf *b, unsigned int blkcnt, unsigned int blksz);
68 int sndbuf_remalloc(struct snd_dbuf *b, unsigned int blkcnt, unsigned int blksz);
69 void sndbuf_reset(struct snd_dbuf *b);
70 void sndbuf_clear(struct snd_dbuf *b, unsigned int length);
71 void sndbuf_fillsilence(struct snd_dbuf *b);
72
73 u_int32_t sndbuf_getfmt(struct snd_dbuf *b);
74 int sndbuf_setfmt(struct snd_dbuf *b, u_int32_t fmt);
75 unsigned int sndbuf_getspd(struct snd_dbuf *b);
76 void sndbuf_setspd(struct snd_dbuf *b, unsigned int spd);
77 unsigned int sndbuf_getbps(struct snd_dbuf *b);
78
79 bus_addr_t sndbuf_getbufaddr(struct snd_dbuf *buf);
80
81 void *sndbuf_getbuf(struct snd_dbuf *b);
82 void *sndbuf_getbufofs(struct snd_dbuf *b, unsigned int ofs);
83 unsigned int sndbuf_getsize(struct snd_dbuf *b);
84 unsigned int sndbuf_getmaxsize(struct snd_dbuf *b);
85 unsigned int sndbuf_getalign(struct snd_dbuf *b);
86 unsigned int sndbuf_getblkcnt(struct snd_dbuf *b);
87 void sndbuf_setblkcnt(struct snd_dbuf *b, unsigned int blkcnt);
88 unsigned int sndbuf_getblksz(struct snd_dbuf *b);
89 void sndbuf_setblksz(struct snd_dbuf *b, unsigned int blksz);
90 unsigned int sndbuf_runsz(struct snd_dbuf *b);
91 void sndbuf_setrun(struct snd_dbuf *b, int go);
92 struct selinfo *sndbuf_getsel(struct snd_dbuf *b);
93
94 unsigned int sndbuf_getxrun(struct snd_dbuf *b);
95 void sndbuf_setxrun(struct snd_dbuf *b, unsigned int cnt);
96 unsigned int sndbuf_gethwptr(struct snd_dbuf *b);
97 void sndbuf_sethwptr(struct snd_dbuf *b, unsigned int ptr);
98 unsigned int sndbuf_getfree(struct snd_dbuf *b);
99 unsigned int sndbuf_getfreeptr(struct snd_dbuf *b);
100 unsigned int sndbuf_getready(struct snd_dbuf *b);
101 unsigned int sndbuf_getreadyptr(struct snd_dbuf *b);
102 unsigned int sndbuf_getblocks(struct snd_dbuf *b);
103 unsigned int sndbuf_getprevblocks(struct snd_dbuf *b);
104 unsigned int sndbuf_gettotal(struct snd_dbuf *b);
105 void sndbuf_updateprevtotal(struct snd_dbuf *b);
106
107 int sndbuf_acquire(struct snd_dbuf *b, u_int8_t *from, unsigned int count);
108 int sndbuf_dispose(struct snd_dbuf *b, u_int8_t *to, unsigned int count);
109 int sndbuf_feed(struct snd_dbuf *from, struct snd_dbuf *to, struct pcm_channel *channel, struct pcm_feeder *feeder, unsigned int count);
110
111 u_int32_t sndbuf_getflags(struct snd_dbuf *b);
112 void sndbuf_setflags(struct snd_dbuf *b, u_int32_t flags, int on);
113
114 int sndbuf_dmasetup(struct snd_dbuf *b, struct resource *drq);
115 int sndbuf_dmasetdir(struct snd_dbuf *b, int dir);
116 void sndbuf_dma(struct snd_dbuf *b, int go);
117 int sndbuf_dmaptr(struct snd_dbuf *b);
118 void sndbuf_dmabounce(struct snd_dbuf *b);
Cache object: 82f8e1c9fbb99b7710649ce682454753
|