No empty .Rs/.Re
[netbsd-mini2440.git] / sys / dev / audiovar.h
blob3dbc290b3af6923f92e1622d8f287bca1ae56655
1 /* $NetBSD: audiovar.h,v 1.44 2008/04/01 19:25:53 drochner Exp $ */
3 /*-
4 * Copyright (c) 2002 The NetBSD Foundation, Inc.
5 * All rights reserved.
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by TAMURA Kent
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.
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
33 * Copyright (c) 1991-1993 Regents of the University of California.
34 * All rights reserved.
36 * Redistribution and use in source and binary forms, with or without
37 * modification, are permitted provided that the following conditions
38 * are met:
39 * 1. Redistributions of source code must retain the above copyright
40 * notice, this list of conditions and the following disclaimer.
41 * 2. Redistributions in binary form must reproduce the above copyright
42 * notice, this list of conditions and the following disclaimer in the
43 * documentation and/or other materials provided with the distribution.
44 * 3. All advertising materials mentioning features or use of this software
45 * must display the following acknowledgement:
46 * This product includes software developed by the Computer Systems
47 * Engineering Group at Lawrence Berkeley Laboratory.
48 * 4. Neither the name of the University nor of the Laboratory may be used
49 * to endorse or promote products derived from this software without
50 * specific prior written permission.
52 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
53 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
54 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
55 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
56 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
57 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
58 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
59 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
60 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
61 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
62 * SUCH DAMAGE.
64 * From: Header: audiovar.h,v 1.3 93/07/18 14:07:25 mccanne Exp (LBL)
66 #ifndef _SYS_DEV_AUDIOVAR_H_
67 #define _SYS_DEV_AUDIOVAR_H_
68 #include <dev/audio_if.h>
71 * Initial/default block duration is both configurable and patchable.
73 #ifndef AUDIO_BLK_MS
74 #define AUDIO_BLK_MS 50 /* 50 ms */
75 #endif
77 #ifndef AU_RING_SIZE
78 #define AU_RING_SIZE 65536
79 #endif
81 #define AUMINBUF 512
82 #define AUMINBLK 32
83 #define AUMINNOBLK 3
84 struct audio_ringbuffer {
85 audio_stream_t s;
86 int blksize; /* I/O block size (bytes) */
87 int maxblks; /* no of blocks in ring */
88 int usedlow; /* start writer when used falls below this */
89 int usedhigh; /* stop writer when used goes above this */
90 u_long stamp; /* bytes transferred */
91 u_long stamp_last; /* old value of bytes transferred */
92 u_long fstamp; /* bytes transferred from/to the buffer near to userland */
93 u_long drops; /* missed samples from over/underrun */
94 u_long pdrops; /* paused samples */
95 bool pause; /* transfer is paused */
96 bool copying; /* data is being copied */
97 bool needfill; /* buffer needs filling when copying is done */
98 bool mmapped; /* device is mmap()-ed */
101 #define AUDIO_N_PORTS 4
103 struct au_mixer_ports {
104 int index; /* index of port-selector mixerctl */
105 int master; /* index of master mixerctl */
106 int nports; /* number of selectable ports */
107 bool isenum; /* selector is enum type */
108 u_int allports; /* all aumasks or'd */
109 u_int aumask[AUDIO_N_PORTS]; /* exposed value of "ports" */
110 u_int misel [AUDIO_N_PORTS]; /* ord of port, for selector */
111 u_int miport[AUDIO_N_PORTS]; /* index of port's mixerctl */
112 bool isdual; /* has working mixerout */
113 int mixerout; /* ord of mixerout, for dual case */
114 int cur_port; /* the port that gain actually controls when
115 mixerout is selected, for dual case */
119 * Software state, per audio device.
121 struct audio_softc {
122 device_t dev;
123 void *hw_hdl; /* Hardware driver handle */
124 const struct audio_hw_if *hw_if; /* Hardware interface */
125 device_t sc_dev; /* Hardware device struct */
126 u_char sc_open; /* single use device */
127 #define AUOPEN_READ 0x01
128 #define AUOPEN_WRITE 0x02
129 u_char sc_mode; /* bitmask for RECORD/PLAY */
131 struct selinfo sc_wsel; /* write selector */
132 struct selinfo sc_rsel; /* read selector */
133 struct proc *sc_async_audio; /* process who wants audio SIGIO */
134 void *sc_sih_rd;
135 void *sc_sih_wr;
136 struct mixer_asyncs {
137 struct mixer_asyncs *next;
138 struct proc *proc;
139 } *sc_async_mixer; /* processes who want mixer SIGIO */
141 /* Sleep channels for reading and writing. */
142 int sc_rchan;
143 int sc_wchan;
145 bool sc_blkset; /* Blocksize has been set */
147 uint8_t *sc_sil_start; /* start of silence in buffer */
148 int sc_sil_count; /* # of silence bytes */
150 bool sc_rbus; /* input DMA in progress */
151 bool sc_pbus; /* output DMA in progress */
154 * userland
155 * | write(2) & uiomove(9)
156 * sc_pstreams[0] <sc_pparams> == sc_pustream;
157 * | sc_pfilters[0]
158 * sc_pstreams[1] <list_t::filters[n-1].param>
160 * sc_pstreams[n-1] <list_t::filters[1].param>
161 * | sc_pfilters[n-1]
162 * sc_pr <list_t::filters[0].param>
164 * hardware
166 audio_params_t sc_pparams; /* play encoding parameters */
167 audio_stream_t *sc_pustream; /* the first buffer */
168 int sc_npfilters; /* number of filters */
169 audio_stream_t sc_pstreams[AUDIO_MAX_FILTERS];
170 stream_filter_t *sc_pfilters[AUDIO_MAX_FILTERS];
171 struct audio_ringbuffer sc_pr; /* Play ring */
172 int sc_writing;
173 int sc_waitcomp;
174 int sc_changing;
177 * hardware
179 * sc_rr <list_t::filters[0].param>
180 * | sc_rfilters[0]
181 * sc_rstreams[0] <list_t::filters[1].param>
182 * | sc_rfilters[1]
183 * sc_rstreams[1] <list_t::filters[2].param>
185 * | sc_rfilters[n-1]
186 * sc_rstreams[n-1] <sc_rparams> == sc_rustream
187 * | uiomove(9) & read(2)
188 * userland
190 struct audio_ringbuffer sc_rr; /* Record ring */
191 int sc_nrfilters; /* number of filters */
192 stream_filter_t *sc_rfilters[AUDIO_MAX_FILTERS];
193 audio_stream_t sc_rstreams[AUDIO_MAX_FILTERS];
194 audio_stream_t *sc_rustream; /* the last buffer */
195 audio_params_t sc_rparams; /* record encoding parameters */
197 int sc_eof; /* EOF, i.e. zero sized write, counter */
198 u_long sc_wstamp; /* # of bytes read with read(2) */
199 u_long sc_playdrop;
201 int sc_full_duplex; /* device in full duplex mode */
203 struct au_mixer_ports sc_inports, sc_outports;
204 int sc_monitor_port;
206 int sc_refcnt;
207 int sc_opencnt;
208 bool sc_dying;
210 #ifdef AUDIO_INTR_TIME
211 u_long sc_pfirstintr; /* first time we saw a play interrupt */
212 int sc_pnintr; /* number of interrupts */
213 u_long sc_plastintr; /* last time we saw a play interrupt */
214 long sc_pblktime; /* nominal time between interrupts */
215 u_long sc_rfirstintr; /* first time we saw a rec interrupt */
216 int sc_rnintr; /* number of interrupts */
217 u_long sc_rlastintr; /* last time we saw a rec interrupt */
218 long sc_rblktime; /* nominal time between interrupts */
219 #endif
221 u_int sc_lastgain;
222 struct audio_info sc_lastinfo;
223 bool sc_lastinfovalid;
225 mixer_ctrl_t *sc_mixer_state;
226 int sc_nmixer_states;
229 #endif /* _SYS_DEV_AUDIOVAR_H_ */