FreeBSD/Linux Kernel Cross Reference
sys/dev/audiovar.h
1 /* $NetBSD: audiovar.h,v 1.30 2004/01/31 00:07:56 fredb Exp $ */
2
3 /*-
4 * Copyright (c) 2002 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by TAMURA Kent
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed by the NetBSD
21 * Foundation, Inc. and its contributors.
22 * 4. Neither the name of The NetBSD Foundation nor the names of its
23 * contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 * POSSIBILITY OF SUCH DAMAGE.
37 */
38
39 /*
40 * Copyright (c) 1991-1993 Regents of the University of California.
41 * All rights reserved.
42 *
43 * Redistribution and use in source and binary forms, with or without
44 * modification, are permitted provided that the following conditions
45 * are met:
46 * 1. Redistributions of source code must retain the above copyright
47 * notice, this list of conditions and the following disclaimer.
48 * 2. Redistributions in binary form must reproduce the above copyright
49 * notice, this list of conditions and the following disclaimer in the
50 * documentation and/or other materials provided with the distribution.
51 * 3. All advertising materials mentioning features or use of this software
52 * must display the following acknowledgement:
53 * This product includes software developed by the Computer Systems
54 * Engineering Group at Lawrence Berkeley Laboratory.
55 * 4. Neither the name of the University nor of the Laboratory may be used
56 * to endorse or promote products derived from this software without
57 * specific prior written permission.
58 *
59 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
60 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
61 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
62 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
63 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
64 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
65 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
66 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
67 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
68 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
69 * SUCH DAMAGE.
70 *
71 * From: Header: audiovar.h,v 1.3 93/07/18 14:07:25 mccanne Exp (LBL)
72 */
73 #ifndef _SYS_DEV_AUDIOVAR_H_
74 #define _SYS_DEV_AUDIOVAR_H_
75
76 #include "aurateconv.h" /* generated by config(8) */
77
78 /*
79 * Initial/default block duration is both configurable and patchable.
80 */
81 #ifndef AUDIO_BLK_MS
82 #define AUDIO_BLK_MS 50 /* 50 ms */
83 #endif
84
85 #ifndef AU_RING_SIZE
86 #define AU_RING_SIZE 65536
87 #endif
88
89 #define AUMINBUF 512
90 #define AUMINBLK 32
91 #define AUMINNOBLK 3
92 struct audio_ringbuffer {
93 size_t bufsize; /* allocated memory */
94 int blksize; /* I/O block size (bytes) */
95 int maxblks; /* no of blocks in ring */
96 u_char *start; /* start of buffer area */
97 u_char *end; /* end of buffer area */
98 u_char *inp; /* input pointer (to buffer) */
99 u_char *outp; /* output pointer (from buffer) */
100 int used; /* no of used bytes */
101 int usedlow; /* start writer when used falls below this */
102 int usedhigh; /* stop writer when used goes above this */
103 u_long stamp; /* bytes transferred */
104 u_long stamp_last; /* old value of bytes transferred */
105 u_long drops; /* missed samples from over/underrun */
106 u_long pdrops; /* paused samples */
107 char pause; /* transfer is paused */
108 char copying; /* data is being copied */
109 char needfill; /* buffer needs filling when copying is done */
110 char mmapped; /* device is mmap()-ed */
111 };
112
113 #define AUDIO_N_PORTS 4
114
115 struct au_mixer_ports {
116 int index; /* index of port-selector mixerctl */
117 int master; /* index of master mixerctl */
118 int nports; /* number of selectable ports */
119 u_char isenum; /* selector is enum type */
120 u_int allports; /* all aumasks or'd */
121 u_int aumask[AUDIO_N_PORTS]; /* exposed value of "ports" */
122 u_int misel [AUDIO_N_PORTS]; /* ord of port, for selector */
123 u_int miport[AUDIO_N_PORTS]; /* index of port's mixerctl */
124 u_char isdual; /* has working mixerout */
125 int mixerout; /* ord of mixerout, for dual case */
126 int cur_port; /* the port that gain actually controls when
127 mixerout is selected, for dual case */
128 };
129
130 #if NAURATECONV > 0
131 struct auconv_context {
132 long count;
133 int32_t prev[AUDIO_MAX_CHANNELS];
134 uint8_t *ring_start;
135 uint8_t *ring_end;
136 };
137 #endif
138
139 /*
140 * Software state, per audio device.
141 */
142 struct audio_softc {
143 struct device dev;
144 void *hw_hdl; /* Hardware driver handle */
145 struct audio_hw_if *hw_if; /* Hardware interface */
146 struct device *sc_dev; /* Hardware device struct */
147 u_char sc_open; /* single use device */
148 #define AUOPEN_READ 0x01
149 #define AUOPEN_WRITE 0x02
150 u_char sc_mode; /* bitmask for RECORD/PLAY */
151
152 struct selinfo sc_wsel; /* write selector */
153 struct selinfo sc_rsel; /* read selector */
154 struct proc *sc_async_audio; /* process who wants audio SIGIO */
155 struct mixer_asyncs {
156 struct mixer_asyncs *next;
157 struct proc *proc;
158 } *sc_async_mixer; /* processes who want mixer SIGIO */
159
160 /* Sleep channels for reading and writing. */
161 int sc_rchan;
162 int sc_wchan;
163
164 /* Ring buffers, separate for record and play. */
165 struct audio_ringbuffer sc_rr; /* Record ring */
166 struct audio_ringbuffer sc_pr; /* Play ring */
167
168 #define MAX_SAMPLE_SIZE (AUDIO_MAX_CHANNELS * 24 / 8) /* 6channels x 24bit precision */
169 int sc_input_fragment_length;
170 u_char sc_input_fragment[MAX_SAMPLE_SIZE];
171 int sc_pconvbuffer_size;
172 u_char *sc_pconvbuffer;
173 #if NAURATECONV > 0
174 struct auconv_context sc_pconv;
175 #endif
176
177 int sc_rconvbuffer_size;
178 int sc_rconvbuffer_begin;
179 int sc_rconvbuffer_end;
180 u_char *sc_rconvbuffer;
181 #if NAURATECONV > 0
182 struct auconv_context sc_rconv;
183 #endif
184
185 u_char sc_blkset; /* Blocksize has been set */
186
187 u_char *sc_sil_start; /* start of silence in buffer */
188 int sc_sil_count; /* # of silence bytes */
189
190 u_char sc_rbus; /* input DMA in progress */
191 u_char sc_pbus; /* output DMA in progress */
192
193 struct audio_params sc_pparams; /* play encoding parameters */
194 struct audio_params sc_rparams; /* record encoding parameters */
195
196 int sc_eof; /* EOF, i.e. zero sized write, counter */
197 u_long sc_wstamp;
198 u_long sc_playdrop;
199
200 int sc_full_duplex; /* device in full duplex mode */
201
202 struct au_mixer_ports sc_inports, sc_outports;
203 int sc_monitor_port;
204
205 int sc_refcnt;
206 u_char sc_dying;
207
208 #ifdef AUDIO_INTR_TIME
209 u_long sc_pfirstintr; /* first time we saw a play interrupt */
210 int sc_pnintr; /* number of interrupts */
211 u_long sc_plastintr; /* last time we saw a play interrupt */
212 long sc_pblktime; /* nominal time between interrupts */
213 u_long sc_rfirstintr; /* first time we saw a rec interrupt */
214 int sc_rnintr; /* number of interrupts */
215 u_long sc_rlastintr; /* last time we saw a rec interrupt */
216 long sc_rblktime; /* nominal time between interrupts */
217 #endif
218 };
219
220 extern int auconv_check_params(const struct audio_params *);
221
222 #if NAURATECONV > 0
223 extern void auconv_init_context(struct auconv_context *, long, long, uint8_t *,
224 uint8_t *);
225 extern int auconv_play(struct auconv_context *, const struct audio_params *,
226 uint8_t *, const uint8_t *, int);
227 extern int auconv_record(struct auconv_context *, const struct audio_params *,
228 uint8_t *, const uint8_t *, int);
229 #endif /* NAURATECONV */
230 #endif /* _SYS_DEV_AUDIOVAR_H_ */
Cache object: 36388c67419de601fcf25eca6bd759c7
|