toccata.c revision 1.2.4.3 1 1.2.4.3 nathanw /* $NetBSD: toccata.c,v 1.2.4.3 2002/04/01 07:39:00 nathanw Exp $ */
2 1.2.4.2 nathanw
3 1.2.4.2 nathanw /*-
4 1.2.4.2 nathanw * Copyright (c) 1998, 1999, 2001, 2002 The NetBSD Foundation, Inc.
5 1.2.4.2 nathanw * All rights reserved.
6 1.2.4.2 nathanw *
7 1.2.4.2 nathanw * This code is derived from software contributed to The NetBSD Foundation
8 1.2.4.2 nathanw * by Paul Kranenburg and Ignatios Souvatzis.
9 1.2.4.2 nathanw *
10 1.2.4.2 nathanw * Redistribution and use in source and binary forms, with or without
11 1.2.4.2 nathanw * modification, are permitted provided that the following conditions
12 1.2.4.2 nathanw * are met:
13 1.2.4.2 nathanw * 1. Redistributions of source code must retain the above copyright
14 1.2.4.2 nathanw * notice, this list of conditions and the following disclaimer.
15 1.2.4.2 nathanw * 2. Redistributions in binary form must reproduce the above copyright
16 1.2.4.2 nathanw * notice, this list of conditions and the following disclaimer in the
17 1.2.4.2 nathanw * documentation and/or other materials provided with the distribution.
18 1.2.4.2 nathanw * 3. All advertising materials mentioning features or use of this software
19 1.2.4.2 nathanw * must display the following acknowledgement:
20 1.2.4.2 nathanw * This product includes software developed by the NetBSD
21 1.2.4.2 nathanw * Foundation, Inc. and its contributors.
22 1.2.4.2 nathanw * 4. Neither the name of The NetBSD Foundation nor the names of its
23 1.2.4.2 nathanw * contributors may be used to endorse or promote products derived
24 1.2.4.2 nathanw * from this software without specific prior written permission.
25 1.2.4.2 nathanw *
26 1.2.4.2 nathanw * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 1.2.4.2 nathanw * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 1.2.4.2 nathanw * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 1.2.4.2 nathanw * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 1.2.4.2 nathanw * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 1.2.4.2 nathanw * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 1.2.4.2 nathanw * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 1.2.4.2 nathanw * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 1.2.4.2 nathanw * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 1.2.4.2 nathanw * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 1.2.4.2 nathanw * POSSIBILITY OF SUCH DAMAGE.
37 1.2.4.2 nathanw */
38 1.2.4.2 nathanw
39 1.2.4.2 nathanw #include <sys/cdefs.h>
40 1.2.4.3 nathanw __KERNEL_RCSID(0, "$NetBSD: toccata.c,v 1.2.4.3 2002/04/01 07:39:00 nathanw Exp $");
41 1.2.4.2 nathanw
42 1.2.4.2 nathanw #include <sys/types.h>
43 1.2.4.2 nathanw #include <sys/param.h>
44 1.2.4.2 nathanw #include <sys/systm.h>
45 1.2.4.2 nathanw #include <sys/kernel.h>
46 1.2.4.2 nathanw #include <sys/device.h>
47 1.2.4.2 nathanw #include <sys/fcntl.h> /* FREAD */
48 1.2.4.2 nathanw
49 1.2.4.2 nathanw #include <machine/bus.h>
50 1.2.4.2 nathanw
51 1.2.4.2 nathanw #include <sys/audioio.h>
52 1.2.4.2 nathanw #include <dev/audio_if.h>
53 1.2.4.2 nathanw
54 1.2.4.2 nathanw
55 1.2.4.2 nathanw #include <dev/ic/ad1848reg.h>
56 1.2.4.2 nathanw #include <dev/ic/ad1848var.h>
57 1.2.4.2 nathanw
58 1.2.4.2 nathanw #include <amiga/dev/zbusvar.h>
59 1.2.4.2 nathanw #include <amiga/amiga/isr.h>
60 1.2.4.2 nathanw
61 1.2.4.2 nathanw
62 1.2.4.2 nathanw /* Register offsets. XXX All of this is guesswork. */
63 1.2.4.2 nathanw
64 1.2.4.2 nathanw /*
65 1.2.4.2 nathanw * The Toccata board consists of: GALs for ZBus AutoConfig(tm) glue, GALs
66 1.2.4.2 nathanw * that interface the FIFO chips and the audio codec chip to the ZBus,
67 1.2.4.2 nathanw * an AD1848 (or AD1845), and 2 Integrated Device Technology 7202LA
68 1.2.4.2 nathanw * (1024x9bit FIFO) chips.
69 1.2.4.2 nathanw */
70 1.2.4.2 nathanw
71 1.2.4.2 nathanw #define TOCC_FIFO_STAT 0x1ffe
72 1.2.4.2 nathanw #define TOCC_FIFO_DATA 0x2000
73 1.2.4.2 nathanw
74 1.2.4.2 nathanw /*
75 1.2.4.2 nathanw * I don't know whether the AD1848 PIO data registers are connected... and
76 1.2.4.2 nathanw * at 2 or 3 accesses to read or write a data byte in the best case, I better
77 1.2.4.2 nathanw * don't even think about it. The AD1848 address/status and data port are
78 1.2.4.2 nathanw * here:
79 1.2.4.2 nathanw */
80 1.2.4.2 nathanw #define TOCC_CODEC_ADDR 0x67FF
81 1.2.4.2 nathanw #define TOCC_CODEC_STAT TOCC_CODEC_ADDR
82 1.2.4.2 nathanw #define TOCC_CODEC_REG 0x6801
83 1.2.4.2 nathanw
84 1.2.4.2 nathanw /* fifo status bits, read */
85 1.2.4.2 nathanw
86 1.2.4.2 nathanw #define TOCC_FIFO_INT 0x80 /* active low; together with one of those: */
87 1.2.4.2 nathanw
88 1.2.4.2 nathanw #define TOCC_FIFO_PBHE 0x08 /* playback fifo is half empty (active high) */
89 1.2.4.2 nathanw #define TOCC_FIFO_CPHF 0x04 /* capture fifo is half full (active high) */
90 1.2.4.2 nathanw
91 1.2.4.2 nathanw /* fifo status bits, write */
92 1.2.4.2 nathanw
93 1.2.4.2 nathanw /*
94 1.2.4.2 nathanw * seems to work like this:
95 1.2.4.2 nathanw * init: write 2; delay; write 1
96 1.2.4.2 nathanw *
97 1.2.4.2 nathanw * capture: write 1; write 1+4+8+0x40 (0x4D)
98 1.2.4.2 nathanw * capt. int: read 512 bytes out of fifo.
99 1.2.4.2 nathanw * capt. int off by writing 1+4+8 (0x0D)
100 1.2.4.2 nathanw *
101 1.2.4.2 nathanw * playback: write 1; write 1 + 0x10; (0x11)
102 1.2.4.2 nathanw * 3/4 fill fifo with silence; init codec;
103 1.2.4.2 nathanw * write 1+4+0x10+0x80 (0x95)
104 1.2.4.2 nathanw * pb int: write 512 bytes to fifo
105 1.2.4.2 nathanw * pb int off by writing 1+4+0x10 (0x15)
106 1.2.4.2 nathanw */
107 1.2.4.2 nathanw
108 1.2.4.2 nathanw #define TOCC_RST 0x02
109 1.2.4.2 nathanw #define TOCC_ACT 0x01
110 1.2.4.2 nathanw #define TOCC_MAGIC 0x04
111 1.2.4.2 nathanw
112 1.2.4.2 nathanw #define TOCC_PB_INTENA 0x80
113 1.2.4.2 nathanw #define TOCC_PB_FILL 0x10
114 1.2.4.2 nathanw
115 1.2.4.2 nathanw #define TOCC_PB_PREP (TOCC_ACT + TOCC_PB_FILL)
116 1.2.4.2 nathanw #define TOCC_PB_TAIL (TOCC_PB_PREP + TOCC_MAGIC)
117 1.2.4.2 nathanw #define TOCC_PB_MAIN (TOCC_PB_TAIL + TOCC_PB_INTENA)
118 1.2.4.2 nathanw
119 1.2.4.2 nathanw #define TOCC_CP_INTENA 0x40
120 1.2.4.2 nathanw #define TOCC_CP_RUN 0x08
121 1.2.4.2 nathanw
122 1.2.4.2 nathanw #define TOCC_CP_TAIL (TOCC_ACT + TOCC_CP_RUN)
123 1.2.4.2 nathanw #define TOCC_CP_MAIN (TOCC_CP_TAIL + TOCC_CP_INTENA + TOCC_MAGIC)
124 1.2.4.2 nathanw
125 1.2.4.2 nathanw /*
126 1.2.4.2 nathanw * For the port stuff. Similar to the cs4231 table, but MONO is not wired
127 1.2.4.2 nathanw * on the Toccata, which was designed for the AD1848. Also we know how
128 1.2.4.2 nathanw * to handle input.
129 1.2.4.2 nathanw */
130 1.2.4.2 nathanw
131 1.2.4.2 nathanw #define TOCCATA_INPUT_CLASS 0
132 1.2.4.2 nathanw #define TOCCATA_OUTPUT_CLASS 1
133 1.2.4.2 nathanw #define TOCCATA_MONITOR_CLASS 2
134 1.2.4.2 nathanw #define TOCCATA_RECORD_CLASS 3
135 1.2.4.2 nathanw
136 1.2.4.2 nathanw #define TOCCATA_RECORD_SOURCE 4
137 1.2.4.2 nathanw #define TOCCATA_REC_LVL 5
138 1.2.4.2 nathanw
139 1.2.4.2 nathanw #define TOCCATA_MIC_IN_LVL 6
140 1.2.4.2 nathanw
141 1.2.4.2 nathanw #define TOCCATA_AUX1_LVL 7
142 1.2.4.2 nathanw #define TOCCATA_AUX1_MUTE 8
143 1.2.4.2 nathanw
144 1.2.4.2 nathanw #define TOCCATA_AUX2_LVL 9
145 1.2.4.2 nathanw #define TOCCATA_AUX2_MUTE 10
146 1.2.4.2 nathanw
147 1.2.4.2 nathanw #define TOCCATA_MONITOR_LVL 11
148 1.2.4.2 nathanw #define TOCCATA_MONITOR_MUTE 12
149 1.2.4.2 nathanw #define TOCCATA_OUTPUT_LVL 13
150 1.2.4.2 nathanw
151 1.2.4.2 nathanw /* only on AD1845 in mode 2 */
152 1.2.4.2 nathanw
153 1.2.4.2 nathanw #define TOCCATA_LINE_IN_LVL 14
154 1.2.4.2 nathanw #define TOCCATA_LINE_IN_MUTE 15
155 1.2.4.2 nathanw
156 1.2.4.2 nathanw /* special, need support */
157 1.2.4.2 nathanw #define TOCCATA_MIC_LVL 16
158 1.2.4.2 nathanw #define TOCCATA_MIC_MUTE 17
159 1.2.4.2 nathanw
160 1.2.4.2 nathanw
161 1.2.4.2 nathanw
162 1.2.4.2 nathanw /* prototypes */
163 1.2.4.2 nathanw
164 1.2.4.2 nathanw int toccata_intr(void *);
165 1.2.4.2 nathanw int toccata_readreg(struct ad1848_softc *, int);
166 1.2.4.2 nathanw void toccata_writereg(struct ad1848_softc *, int, int);
167 1.2.4.2 nathanw
168 1.2.4.2 nathanw int toccata_round_blocksize(void *, int);
169 1.2.4.2 nathanw size_t toccata_round_buffersize(void *, int, size_t);
170 1.2.4.2 nathanw
171 1.2.4.2 nathanw int toccata_open(void *, int);
172 1.2.4.2 nathanw void toccata_close(void *);
173 1.2.4.2 nathanw int toccata_getdev(void *, struct audio_device *);
174 1.2.4.2 nathanw int toccata_get_props(void *);
175 1.2.4.2 nathanw
176 1.2.4.2 nathanw int toccata_halt_input(void *);
177 1.2.4.2 nathanw int toccata_halt_output(void *);
178 1.2.4.2 nathanw int toccata_start_input(void *, void *, int, void (*)(void *), void *);
179 1.2.4.2 nathanw int toccata_start_output(void *, void *, int, void (*)(void *), void *);
180 1.2.4.2 nathanw
181 1.2.4.2 nathanw /* I suspect those should be in a shared file */
182 1.2.4.2 nathanw int toccata_set_port(void *, mixer_ctrl_t *);
183 1.2.4.2 nathanw int toccata_get_port(void *, mixer_ctrl_t *);
184 1.2.4.2 nathanw int toccata_query_devinfo(void *, mixer_devinfo_t *);
185 1.2.4.2 nathanw
186 1.2.4.2 nathanw struct audio_hw_if audiocs_hw_if = {
187 1.2.4.2 nathanw toccata_open,
188 1.2.4.2 nathanw toccata_close,
189 1.2.4.2 nathanw 0, /*
190 1.2.4.2 nathanw * XXX toccata_drain could be written:
191 1.2.4.2 nathanw * sleep for play interupt. This loses less then 512 bytes of
192 1.2.4.2 nathanw * sample data, otherwise up to 1024.
193 1.2.4.2 nathanw */
194 1.2.4.2 nathanw ad1848_query_encoding,
195 1.2.4.2 nathanw ad1848_set_params,
196 1.2.4.2 nathanw toccata_round_blocksize,
197 1.2.4.2 nathanw ad1848_commit_settings,
198 1.2.4.2 nathanw 0, /* init_output */ /* XXX need this to prefill? */
199 1.2.4.2 nathanw 0, /* init_input */
200 1.2.4.2 nathanw toccata_start_output,
201 1.2.4.2 nathanw toccata_start_input,
202 1.2.4.2 nathanw toccata_halt_output,
203 1.2.4.2 nathanw toccata_halt_input,
204 1.2.4.2 nathanw 0, /* speaker */
205 1.2.4.2 nathanw toccata_getdev,
206 1.2.4.2 nathanw 0, /* setfd */
207 1.2.4.2 nathanw toccata_set_port,
208 1.2.4.2 nathanw toccata_get_port,
209 1.2.4.2 nathanw toccata_query_devinfo,
210 1.2.4.2 nathanw 0, /* alloc/free */
211 1.2.4.2 nathanw 0,
212 1.2.4.2 nathanw toccata_round_buffersize, /* round_buffer */
213 1.2.4.2 nathanw 0, /* mappage */
214 1.2.4.2 nathanw toccata_get_props,
215 1.2.4.2 nathanw 0, /* trigger_output */
216 1.2.4.2 nathanw 0,
217 1.2.4.2 nathanw };
218 1.2.4.2 nathanw
219 1.2.4.2 nathanw struct toccata_softc {
220 1.2.4.2 nathanw struct ad1848_softc sc_ad;
221 1.2.4.2 nathanw struct isr sc_isr;
222 1.2.4.2 nathanw volatile u_int8_t *sc_boardp; /* only need a few addresses! */
223 1.2.4.2 nathanw
224 1.2.4.2 nathanw void (*sc_captmore)(void *);
225 1.2.4.2 nathanw void *sc_captarg;
226 1.2.4.2 nathanw void *sc_captbuf;
227 1.2.4.2 nathanw int sc_captbufsz;
228 1.2.4.2 nathanw
229 1.2.4.2 nathanw void (*sc_playmore)(void *);
230 1.2.4.2 nathanw void *sc_playarg;
231 1.2.4.2 nathanw };
232 1.2.4.2 nathanw
233 1.2.4.2 nathanw int toccata_match (struct device *, struct cfdata *, void *);
234 1.2.4.2 nathanw void toccata_attach (struct device *, struct device *, void *);
235 1.2.4.2 nathanw
236 1.2.4.2 nathanw struct cfattach toccata_ca = {
237 1.2.4.2 nathanw sizeof(struct toccata_softc), toccata_match, toccata_attach
238 1.2.4.2 nathanw };
239 1.2.4.2 nathanw
240 1.2.4.2 nathanw int
241 1.2.4.2 nathanw toccata_match(struct device *parent, struct cfdata *cfp, void *aux) {
242 1.2.4.2 nathanw struct zbus_args *zap;
243 1.2.4.2 nathanw
244 1.2.4.2 nathanw zap = aux;
245 1.2.4.2 nathanw
246 1.2.4.2 nathanw if (zap->manid != 18260)
247 1.2.4.2 nathanw return (0);
248 1.2.4.2 nathanw
249 1.2.4.2 nathanw if (zap->prodid != 12)
250 1.2.4.2 nathanw return (0);
251 1.2.4.2 nathanw
252 1.2.4.2 nathanw return (1);
253 1.2.4.2 nathanw }
254 1.2.4.2 nathanw
255 1.2.4.2 nathanw void
256 1.2.4.2 nathanw toccata_attach(struct device *parent, struct device *self, void *aux) {
257 1.2.4.2 nathanw struct toccata_softc *sc;
258 1.2.4.2 nathanw struct ad1848_softc *asc;
259 1.2.4.2 nathanw struct zbus_args *zap;
260 1.2.4.2 nathanw
261 1.2.4.2 nathanw volatile u_int8_t *boardp;
262 1.2.4.2 nathanw
263 1.2.4.2 nathanw sc = (struct toccata_softc *)self;
264 1.2.4.2 nathanw asc = &sc->sc_ad;
265 1.2.4.2 nathanw zap = aux;
266 1.2.4.2 nathanw
267 1.2.4.2 nathanw boardp = (volatile u_int8_t *)zap->va;
268 1.2.4.2 nathanw sc->sc_boardp = boardp;
269 1.2.4.2 nathanw
270 1.2.4.2 nathanw *boardp = TOCC_RST;
271 1.2.4.2 nathanw delay(500000); /* look up value */
272 1.2.4.2 nathanw *boardp = TOCC_ACT;
273 1.2.4.2 nathanw
274 1.2.4.2 nathanw asc->parent = sc;
275 1.2.4.2 nathanw asc->sc_readreg = toccata_readreg;
276 1.2.4.2 nathanw asc->sc_writereg = toccata_writereg;
277 1.2.4.2 nathanw
278 1.2.4.2 nathanw asc->chip_name = "ad1848";
279 1.2.4.2 nathanw asc->mode = 1;
280 1.2.4.2 nathanw ad1848_attach(asc);
281 1.2.4.2 nathanw printf("\n");
282 1.2.4.2 nathanw
283 1.2.4.2 nathanw sc->sc_captbuf = 0;
284 1.2.4.2 nathanw sc->sc_playmore = 0;
285 1.2.4.2 nathanw
286 1.2.4.2 nathanw sc->sc_isr.isr_ipl = 6;
287 1.2.4.2 nathanw sc->sc_isr.isr_arg = sc;
288 1.2.4.2 nathanw sc->sc_isr.isr_intr = toccata_intr;
289 1.2.4.2 nathanw add_isr(&sc->sc_isr);
290 1.2.4.2 nathanw
291 1.2.4.2 nathanw audio_attach_mi(&audiocs_hw_if, sc, &asc->sc_dev);
292 1.2.4.2 nathanw
293 1.2.4.2 nathanw }
294 1.2.4.2 nathanw
295 1.2.4.2 nathanw /* interupt handler */
296 1.2.4.2 nathanw
297 1.2.4.2 nathanw int
298 1.2.4.2 nathanw toccata_intr(void *tag) {
299 1.2.4.2 nathanw struct toccata_softc *sc;
300 1.2.4.2 nathanw u_int8_t *buf;
301 1.2.4.2 nathanw volatile u_int8_t *fifo;
302 1.2.4.2 nathanw u_int8_t status;
303 1.2.4.2 nathanw int i;
304 1.2.4.2 nathanw
305 1.2.4.2 nathanw sc = tag;
306 1.2.4.2 nathanw status = *(sc->sc_boardp);
307 1.2.4.2 nathanw
308 1.2.4.2 nathanw if (status & TOCC_FIFO_INT) /* active low */
309 1.2.4.2 nathanw return 0;
310 1.2.4.2 nathanw
311 1.2.4.2 nathanw if (status & TOCC_FIFO_PBHE) {
312 1.2.4.2 nathanw if (sc->sc_playmore) {
313 1.2.4.2 nathanw (*sc->sc_playmore)(sc->sc_playarg);
314 1.2.4.2 nathanw return 1;
315 1.2.4.2 nathanw }
316 1.2.4.2 nathanw } else if (status & TOCC_FIFO_CPHF) {
317 1.2.4.2 nathanw if (sc->sc_captbuf) {
318 1.2.4.2 nathanw buf = sc->sc_captbuf;
319 1.2.4.2 nathanw fifo = sc->sc_boardp + TOCC_FIFO_DATA;
320 1.2.4.2 nathanw
321 1.2.4.2 nathanw for (i = sc->sc_captbufsz/4 - 1; i>=0; --i) {
322 1.2.4.2 nathanw *buf++ = *fifo;
323 1.2.4.2 nathanw *buf++ = *fifo;
324 1.2.4.2 nathanw *buf++ = *fifo;
325 1.2.4.2 nathanw *buf++ = *fifo;
326 1.2.4.2 nathanw }
327 1.2.4.2 nathanw
328 1.2.4.2 nathanw /* XXX if (sc->sc_captmore) { */
329 1.2.4.2 nathanw (*sc->sc_captmore)(sc->sc_captarg);
330 1.2.4.2 nathanw return 1;
331 1.2.4.2 nathanw }
332 1.2.4.2 nathanw }
333 1.2.4.2 nathanw
334 1.2.4.2 nathanw /*
335 1.2.4.2 nathanw * Something is wrong; switch interupts off to avoid wedging the
336 1.2.4.2 nathanw * machine, and notify the alpha tester.
337 1.2.4.2 nathanw * Normally, the halt_* functions should have switched off the
338 1.2.4.2 nathanw * FIFO interupt.
339 1.2.4.2 nathanw */
340 1.2.4.2 nathanw #ifdef DEBUG
341 1.2.4.3 nathanw printf("%s: got unexpected interupt %x\n", sc->sc_ad.sc_dev.dv_xname,
342 1.2.4.3 nathanw status);
343 1.2.4.2 nathanw #endif
344 1.2.4.2 nathanw *sc->sc_boardp = TOCC_ACT;
345 1.2.4.2 nathanw return 1;
346 1.2.4.2 nathanw }
347 1.2.4.2 nathanw
348 1.2.4.2 nathanw /* support for ad1848 functions */
349 1.2.4.2 nathanw
350 1.2.4.2 nathanw int
351 1.2.4.2 nathanw toccata_readreg(struct ad1848_softc *asc, int offset) {
352 1.2.4.2 nathanw struct toccata_softc *sc = (struct toccata_softc *)asc;
353 1.2.4.2 nathanw
354 1.2.4.2 nathanw return (*(sc->sc_boardp + TOCC_CODEC_ADDR +
355 1.2.4.2 nathanw offset * (TOCC_CODEC_REG - TOCC_CODEC_ADDR)));
356 1.2.4.2 nathanw }
357 1.2.4.2 nathanw
358 1.2.4.2 nathanw void
359 1.2.4.2 nathanw toccata_writereg(struct ad1848_softc *asc, int offset, int value) {
360 1.2.4.2 nathanw struct toccata_softc *sc = (struct toccata_softc *)asc;
361 1.2.4.2 nathanw
362 1.2.4.2 nathanw *(sc->sc_boardp + TOCC_CODEC_ADDR +
363 1.2.4.2 nathanw offset * (TOCC_CODEC_REG - TOCC_CODEC_ADDR)) = value;
364 1.2.4.2 nathanw }
365 1.2.4.2 nathanw
366 1.2.4.2 nathanw /* our own copy of open/close; we don't ever enable the ad1848 interupts */
367 1.2.4.2 nathanw int
368 1.2.4.2 nathanw toccata_open(void *addr, int flags) {
369 1.2.4.2 nathanw struct toccata_softc *sc;
370 1.2.4.2 nathanw struct ad1848_softc *asc;
371 1.2.4.2 nathanw
372 1.2.4.2 nathanw sc = addr;
373 1.2.4.2 nathanw asc = &sc->sc_ad;
374 1.2.4.2 nathanw
375 1.2.4.2 nathanw asc->open_mode = flags;
376 1.2.4.2 nathanw /* If recording && monitoring, the playback part is also used. */
377 1.2.4.2 nathanw if (flags & FREAD && asc->mute[AD1848_MONITOR_CHANNEL] == 0)
378 1.2.4.2 nathanw ad1848_mute_wave_output(asc, WAVE_UNMUTE1, 1);
379 1.2.4.2 nathanw
380 1.2.4.2 nathanw #ifdef AUDIO_DEBUG
381 1.2.4.2 nathanw if (ad1848debug)
382 1.2.4.2 nathanw ad1848_dump_regs(asc);
383 1.2.4.2 nathanw #endif
384 1.2.4.2 nathanw
385 1.2.4.2 nathanw return 0;
386 1.2.4.2 nathanw }
387 1.2.4.2 nathanw
388 1.2.4.2 nathanw void
389 1.2.4.2 nathanw toccata_close(void *addr) {
390 1.2.4.2 nathanw struct toccata_softc *sc = addr;
391 1.2.4.2 nathanw struct ad1848_softc *asc = &sc->sc_ad;
392 1.2.4.2 nathanw unsigned reg;
393 1.2.4.2 nathanw
394 1.2.4.2 nathanw asc->open_mode = 0;
395 1.2.4.2 nathanw
396 1.2.4.2 nathanw ad1848_mute_wave_output(asc, WAVE_UNMUTE1, 0);
397 1.2.4.2 nathanw
398 1.2.4.2 nathanw reg = ad_read(&sc->sc_ad, SP_INTERFACE_CONFIG);
399 1.2.4.2 nathanw ad_write(&sc->sc_ad, SP_INTERFACE_CONFIG,
400 1.2.4.2 nathanw (reg & ~(CAPTURE_ENABLE|PLAYBACK_ENABLE)));
401 1.2.4.2 nathanw
402 1.2.4.2 nathanw /* Disable interrupts */
403 1.2.4.2 nathanw *sc->sc_boardp = TOCC_ACT;
404 1.2.4.2 nathanw #ifdef AUDIO_DEBUG
405 1.2.4.2 nathanw if (ad1848debug)
406 1.2.4.2 nathanw ad1848_dump_regs(asc);
407 1.2.4.2 nathanw #endif
408 1.2.4.2 nathanw }
409 1.2.4.2 nathanw
410 1.2.4.2 nathanw int
411 1.2.4.2 nathanw toccata_round_blocksize(void *addr, int blk) {
412 1.2.4.2 nathanw int ret;
413 1.2.4.2 nathanw
414 1.2.4.2 nathanw ret = blk > 512 ? 512 : (blk & -4);
415 1.2.4.2 nathanw
416 1.2.4.2 nathanw return ret;
417 1.2.4.2 nathanw }
418 1.2.4.2 nathanw
419 1.2.4.2 nathanw size_t
420 1.2.4.2 nathanw toccata_round_buffersize(void *addr, int direction, size_t suggested) {
421 1.2.4.2 nathanw int ret;
422 1.2.4.2 nathanw
423 1.2.4.2 nathanw ret = suggested & -4;
424 1.2.4.2 nathanw
425 1.2.4.2 nathanw return (ret);
426 1.2.4.2 nathanw }
427 1.2.4.2 nathanw
428 1.2.4.2 nathanw struct audio_device toccata_device = {
429 1.2.4.2 nathanw "toccata", "x", "audio"
430 1.2.4.2 nathanw };
431 1.2.4.2 nathanw
432 1.2.4.2 nathanw int
433 1.2.4.2 nathanw toccata_getdev(void *addr, struct audio_device *retp) {
434 1.2.4.2 nathanw *retp = toccata_device;
435 1.2.4.2 nathanw return (0);
436 1.2.4.2 nathanw }
437 1.2.4.2 nathanw
438 1.2.4.2 nathanw int
439 1.2.4.2 nathanw toccata_get_props(void *addr) {
440 1.2.4.2 nathanw return (0);
441 1.2.4.2 nathanw }
442 1.2.4.2 nathanw
443 1.2.4.2 nathanw int
444 1.2.4.2 nathanw toccata_halt_input(void *addr) {
445 1.2.4.2 nathanw struct toccata_softc *sc;
446 1.2.4.2 nathanw struct ad1848_softc *asc;
447 1.2.4.2 nathanw unsigned reg;
448 1.2.4.2 nathanw
449 1.2.4.2 nathanw sc = addr;
450 1.2.4.2 nathanw asc = &sc->sc_ad;
451 1.2.4.2 nathanw
452 1.2.4.2 nathanw /* we're half_duplex; be brutal */
453 1.2.4.2 nathanw *sc->sc_boardp = TOCC_CP_TAIL;
454 1.2.4.2 nathanw sc->sc_captmore = 0;
455 1.2.4.2 nathanw sc->sc_captbuf = 0;
456 1.2.4.2 nathanw
457 1.2.4.2 nathanw reg = ad_read(&sc->sc_ad, SP_INTERFACE_CONFIG);
458 1.2.4.2 nathanw ad_write(&sc->sc_ad, SP_INTERFACE_CONFIG, (reg & ~CAPTURE_ENABLE));
459 1.2.4.2 nathanw
460 1.2.4.2 nathanw return 0;
461 1.2.4.2 nathanw }
462 1.2.4.2 nathanw
463 1.2.4.2 nathanw int
464 1.2.4.2 nathanw toccata_start_input(void *addr, void *block, int blksize,
465 1.2.4.2 nathanw void (*intr)(void *), void *intrarg) {
466 1.2.4.2 nathanw
467 1.2.4.2 nathanw struct toccata_softc *sc;
468 1.2.4.2 nathanw unsigned reg;
469 1.2.4.2 nathanw volatile u_int8_t *cmd;
470 1.2.4.2 nathanw
471 1.2.4.2 nathanw sc = addr;
472 1.2.4.2 nathanw cmd = sc->sc_boardp;
473 1.2.4.2 nathanw
474 1.2.4.2 nathanw if (sc->sc_captmore == 0) {
475 1.2.4.2 nathanw
476 1.2.4.2 nathanw /* we're half-duplex, be brutal */
477 1.2.4.2 nathanw *cmd = TOCC_ACT;
478 1.2.4.2 nathanw *cmd = TOCC_CP_MAIN;
479 1.2.4.2 nathanw
480 1.2.4.2 nathanw reg = ad_read(&sc->sc_ad, SP_INTERFACE_CONFIG);
481 1.2.4.2 nathanw ad_write(&sc->sc_ad, SP_INTERFACE_CONFIG,
482 1.2.4.2 nathanw (reg | CAPTURE_ENABLE));
483 1.2.4.2 nathanw
484 1.2.4.2 nathanw }
485 1.2.4.2 nathanw
486 1.2.4.2 nathanw sc->sc_captarg = intrarg;
487 1.2.4.2 nathanw sc->sc_captmore = intr;
488 1.2.4.2 nathanw sc->sc_captbuf = (u_int8_t *)block;
489 1.2.4.2 nathanw sc->sc_captbufsz = blksize;
490 1.2.4.2 nathanw
491 1.2.4.2 nathanw return 0;
492 1.2.4.2 nathanw }
493 1.2.4.2 nathanw
494 1.2.4.2 nathanw int
495 1.2.4.2 nathanw toccata_halt_output(void *addr) {
496 1.2.4.2 nathanw struct toccata_softc *sc;
497 1.2.4.2 nathanw struct ad1848_softc *asc;
498 1.2.4.2 nathanw unsigned reg;
499 1.2.4.2 nathanw
500 1.2.4.2 nathanw sc = addr;
501 1.2.4.2 nathanw asc = &sc->sc_ad;
502 1.2.4.2 nathanw
503 1.2.4.2 nathanw /* we're half_duplex; be brutal */
504 1.2.4.2 nathanw *sc->sc_boardp = TOCC_PB_TAIL;
505 1.2.4.2 nathanw sc->sc_playmore = 0;
506 1.2.4.2 nathanw
507 1.2.4.2 nathanw reg = ad_read(&sc->sc_ad, SP_INTERFACE_CONFIG);
508 1.2.4.2 nathanw ad_write(&sc->sc_ad, SP_INTERFACE_CONFIG, (reg & ~PLAYBACK_ENABLE));
509 1.2.4.2 nathanw
510 1.2.4.2 nathanw return 0;
511 1.2.4.2 nathanw }
512 1.2.4.2 nathanw
513 1.2.4.2 nathanw int
514 1.2.4.2 nathanw toccata_start_output(void *addr, void *block, int blksize,
515 1.2.4.2 nathanw void (*intr)(void*), void *intrarg) {
516 1.2.4.2 nathanw
517 1.2.4.2 nathanw struct toccata_softc *sc;
518 1.2.4.2 nathanw unsigned reg;
519 1.2.4.2 nathanw int i;
520 1.2.4.2 nathanw volatile u_int8_t *cmd, *fifo;
521 1.2.4.2 nathanw u_int8_t *buf;
522 1.2.4.2 nathanw
523 1.2.4.2 nathanw sc = addr;
524 1.2.4.2 nathanw buf = block;
525 1.2.4.2 nathanw
526 1.2.4.2 nathanw cmd = sc->sc_boardp;
527 1.2.4.2 nathanw fifo = sc->sc_boardp + TOCC_FIFO_DATA;
528 1.2.4.2 nathanw
529 1.2.4.2 nathanw if (sc->sc_playmore == 0) {
530 1.2.4.2 nathanw *cmd = TOCC_ACT;
531 1.2.4.2 nathanw *cmd = TOCC_PB_PREP;
532 1.2.4.2 nathanw }
533 1.2.4.2 nathanw
534 1.2.4.2 nathanw /*
535 1.2.4.2 nathanw * We rounded the blocksize to a multiple of 4 bytes. Modest
536 1.2.4.2 nathanw * unrolling saves 2% of cputime playing 48000 16bit stereo
537 1.2.4.2 nathanw * on 68040/25MHz.
538 1.2.4.2 nathanw */
539 1.2.4.2 nathanw
540 1.2.4.2 nathanw for (i = blksize/4 - 1; i>=0; --i) {
541 1.2.4.2 nathanw *fifo = *buf++;
542 1.2.4.2 nathanw *fifo = *buf++;
543 1.2.4.2 nathanw *fifo = *buf++;
544 1.2.4.2 nathanw *fifo = *buf++;
545 1.2.4.2 nathanw }
546 1.2.4.2 nathanw
547 1.2.4.2 nathanw if (sc->sc_playmore == 0) {
548 1.2.4.2 nathanw reg = ad_read(&sc->sc_ad, SP_INTERFACE_CONFIG);
549 1.2.4.2 nathanw ad_write(&sc->sc_ad, SP_INTERFACE_CONFIG,
550 1.2.4.2 nathanw (reg | PLAYBACK_ENABLE));
551 1.2.4.2 nathanw
552 1.2.4.2 nathanw /* we're half-duplex, be brutal */
553 1.2.4.2 nathanw *sc->sc_boardp = TOCC_PB_MAIN;
554 1.2.4.2 nathanw }
555 1.2.4.2 nathanw
556 1.2.4.2 nathanw sc->sc_playarg = intrarg;
557 1.2.4.2 nathanw sc->sc_playmore = intr;
558 1.2.4.2 nathanw
559 1.2.4.2 nathanw return 0;
560 1.2.4.2 nathanw }
561 1.2.4.2 nathanw
562 1.2.4.2 nathanw static ad1848_devmap_t csmapping[] = {
563 1.2.4.2 nathanw { TOCCATA_MIC_IN_LVL, AD1848_KIND_MICGAIN, -1 },
564 1.2.4.2 nathanw { TOCCATA_AUX1_LVL, AD1848_KIND_LVL, AD1848_AUX1_CHANNEL },
565 1.2.4.2 nathanw { TOCCATA_AUX1_MUTE, AD1848_KIND_MUTE, AD1848_AUX1_CHANNEL },
566 1.2.4.2 nathanw { TOCCATA_AUX2_LVL, AD1848_KIND_LVL, AD1848_AUX2_CHANNEL },
567 1.2.4.2 nathanw { TOCCATA_AUX2_MUTE, AD1848_KIND_MUTE, AD1848_AUX2_CHANNEL },
568 1.2.4.2 nathanw { TOCCATA_OUTPUT_LVL, AD1848_KIND_LVL, AD1848_DAC_CHANNEL },
569 1.2.4.2 nathanw { TOCCATA_MONITOR_LVL, AD1848_KIND_LVL, AD1848_MONITOR_CHANNEL },
570 1.2.4.2 nathanw { TOCCATA_MONITOR_MUTE, AD1848_KIND_MUTE, AD1848_MONITOR_CHANNEL },
571 1.2.4.2 nathanw { TOCCATA_REC_LVL, AD1848_KIND_RECORDGAIN, -1 },
572 1.2.4.2 nathanw { TOCCATA_RECORD_SOURCE, AD1848_KIND_RECORDSOURCE, -1 },
573 1.2.4.2 nathanw /* only in mode 2: */
574 1.2.4.2 nathanw { TOCCATA_LINE_IN_LVL, AD1848_KIND_LVL, AD1848_LINE_CHANNEL },
575 1.2.4.2 nathanw { TOCCATA_LINE_IN_MUTE, AD1848_KIND_MUTE, AD1848_LINE_CHANNEL },
576 1.2.4.2 nathanw };
577 1.2.4.2 nathanw
578 1.2.4.2 nathanw #define nummap (sizeof(csmapping) / sizeof(csmapping[0]))
579 1.2.4.2 nathanw
580 1.2.4.2 nathanw int
581 1.2.4.2 nathanw toccata_set_port(void *addr, mixer_ctrl_t *cp) {
582 1.2.4.2 nathanw struct ad1848_softc *ac = addr;
583 1.2.4.2 nathanw
584 1.2.4.2 nathanw /* printf("set_port(%d)\n", cp->dev); */
585 1.2.4.2 nathanw return (ad1848_mixer_set_port(ac, csmapping,
586 1.2.4.2 nathanw ac->mode == 2 ? nummap : nummap - 2, cp));
587 1.2.4.2 nathanw }
588 1.2.4.2 nathanw
589 1.2.4.2 nathanw int
590 1.2.4.2 nathanw toccata_get_port(void *addr, mixer_ctrl_t *cp) {
591 1.2.4.2 nathanw struct ad1848_softc *ac = addr;
592 1.2.4.2 nathanw
593 1.2.4.2 nathanw /* printf("get_port(%d)\n", cp->dev); */
594 1.2.4.2 nathanw return (ad1848_mixer_get_port(ac, csmapping,
595 1.2.4.2 nathanw ac->mode == 2 ? nummap : nummap - 2, cp));
596 1.2.4.2 nathanw }
597 1.2.4.2 nathanw
598 1.2.4.2 nathanw int
599 1.2.4.2 nathanw toccata_query_devinfo(void *addr, mixer_devinfo_t *dip) {
600 1.2.4.2 nathanw
601 1.2.4.2 nathanw printf("toccata_query_devinfo(%2d)\n", dip->index);
602 1.2.4.2 nathanw
603 1.2.4.2 nathanw switch(dip->index) {
604 1.2.4.2 nathanw case TOCCATA_MIC_IN_LVL: /* Microphone */
605 1.2.4.2 nathanw dip->type = AUDIO_MIXER_VALUE;
606 1.2.4.2 nathanw dip->mixer_class = TOCCATA_INPUT_CLASS;
607 1.2.4.2 nathanw dip->prev = dip->next = AUDIO_MIXER_LAST;
608 1.2.4.2 nathanw strcpy(dip->label.name, AudioNmicrophone);
609 1.2.4.2 nathanw dip->un.v.num_channels = 1;
610 1.2.4.2 nathanw strcpy(dip->un.v.units.name, AudioNvolume);
611 1.2.4.2 nathanw break;
612 1.2.4.2 nathanw #if 0
613 1.2.4.2 nathanw
614 1.2.4.2 nathanw case TOCCATA_MONO_LVL: /* mono/microphone mixer */
615 1.2.4.2 nathanw dip->type = AUDIO_MIXER_VALUE;
616 1.2.4.2 nathanw dip->mixer_class = TOCCATA_INPUT_CLASS;
617 1.2.4.2 nathanw dip->prev = AUDIO_MIXER_LAST;
618 1.2.4.2 nathanw dip->next = TOCCATA_MONO_MUTE;
619 1.2.4.2 nathanw strcpy(dip->label.name, AudioNmicrophone);
620 1.2.4.2 nathanw dip->un.v.num_channels = 1;
621 1.2.4.2 nathanw strcpy(dip->un.v.units.name, AudioNvolume);
622 1.2.4.2 nathanw break;
623 1.2.4.2 nathanw #endif
624 1.2.4.2 nathanw
625 1.2.4.2 nathanw case TOCCATA_AUX1_LVL: /* dacout */
626 1.2.4.2 nathanw dip->type = AUDIO_MIXER_VALUE;
627 1.2.4.2 nathanw dip->mixer_class = TOCCATA_INPUT_CLASS;
628 1.2.4.2 nathanw dip->prev = AUDIO_MIXER_LAST;
629 1.2.4.2 nathanw dip->next = TOCCATA_AUX1_MUTE;
630 1.2.4.2 nathanw strcpy(dip->label.name, "aux1");
631 1.2.4.2 nathanw dip->un.v.num_channels = 2;
632 1.2.4.2 nathanw strcpy(dip->un.v.units.name, AudioNvolume);
633 1.2.4.2 nathanw break;
634 1.2.4.2 nathanw
635 1.2.4.2 nathanw case TOCCATA_AUX1_MUTE:
636 1.2.4.2 nathanw dip->mixer_class = TOCCATA_INPUT_CLASS;
637 1.2.4.2 nathanw dip->type = AUDIO_MIXER_ENUM;
638 1.2.4.2 nathanw dip->prev = TOCCATA_AUX1_LVL;
639 1.2.4.2 nathanw dip->next = AUDIO_MIXER_LAST;
640 1.2.4.2 nathanw goto mute;
641 1.2.4.2 nathanw
642 1.2.4.2 nathanw
643 1.2.4.2 nathanw
644 1.2.4.2 nathanw case TOCCATA_AUX2_LVL:
645 1.2.4.2 nathanw dip->type = AUDIO_MIXER_VALUE;
646 1.2.4.2 nathanw dip->mixer_class = TOCCATA_INPUT_CLASS;
647 1.2.4.2 nathanw dip->prev = AUDIO_MIXER_LAST;
648 1.2.4.2 nathanw dip->next = TOCCATA_AUX2_MUTE;
649 1.2.4.2 nathanw strcpy(dip->label.name, "aux2");
650 1.2.4.2 nathanw dip->un.v.num_channels = 2;
651 1.2.4.2 nathanw strcpy(dip->un.v.units.name, AudioNvolume);
652 1.2.4.2 nathanw break;
653 1.2.4.2 nathanw
654 1.2.4.2 nathanw case TOCCATA_AUX2_MUTE:
655 1.2.4.2 nathanw dip->mixer_class = TOCCATA_INPUT_CLASS;
656 1.2.4.2 nathanw dip->type = AUDIO_MIXER_ENUM;
657 1.2.4.2 nathanw dip->prev = TOCCATA_AUX2_LVL;
658 1.2.4.2 nathanw dip->next = AUDIO_MIXER_LAST;
659 1.2.4.2 nathanw goto mute;
660 1.2.4.2 nathanw
661 1.2.4.2 nathanw
662 1.2.4.2 nathanw case TOCCATA_MONITOR_LVL: /* monitor level */
663 1.2.4.2 nathanw dip->type = AUDIO_MIXER_VALUE;
664 1.2.4.2 nathanw dip->mixer_class = TOCCATA_MONITOR_CLASS;
665 1.2.4.2 nathanw dip->next = TOCCATA_MONITOR_MUTE;
666 1.2.4.2 nathanw dip->prev = AUDIO_MIXER_LAST;
667 1.2.4.2 nathanw strcpy(dip->label.name, AudioNmonitor);
668 1.2.4.2 nathanw dip->un.v.num_channels = 1;
669 1.2.4.2 nathanw strcpy(dip->un.v.units.name, AudioNvolume);
670 1.2.4.2 nathanw break;
671 1.2.4.2 nathanw
672 1.2.4.2 nathanw case TOCCATA_OUTPUT_LVL: /* output volume */
673 1.2.4.2 nathanw dip->type = AUDIO_MIXER_VALUE;
674 1.2.4.2 nathanw dip->mixer_class = TOCCATA_OUTPUT_CLASS;
675 1.2.4.2 nathanw dip->prev = dip->next = AUDIO_MIXER_LAST;
676 1.2.4.2 nathanw strcpy(dip->label.name, AudioNmaster);
677 1.2.4.2 nathanw dip->un.v.num_channels = 2;
678 1.2.4.2 nathanw strcpy(dip->un.v.units.name, AudioNvolume);
679 1.2.4.2 nathanw break;
680 1.2.4.2 nathanw #if 0
681 1.2.4.2 nathanw case TOCCATA_LINE_IN_LVL: /* line */
682 1.2.4.2 nathanw dip->type = AUDIO_MIXER_VALUE;
683 1.2.4.2 nathanw dip->mixer_class = TOCCATA_INPUT_CLASS;
684 1.2.4.2 nathanw dip->prev = AUDIO_MIXER_LAST;
685 1.2.4.2 nathanw dip->next = TOCCATA_LINE_IN_MUTE;
686 1.2.4.2 nathanw strcpy(dip->label.name, AudioNline);
687 1.2.4.2 nathanw dip->un.v.num_channels = 2;
688 1.2.4.2 nathanw strcpy(dip->un.v.units.name, AudioNvolume);
689 1.2.4.2 nathanw break;
690 1.2.4.2 nathanw
691 1.2.4.2 nathanw case TOCCATA_LINE_IN_MUTE:
692 1.2.4.2 nathanw dip->mixer_class = TOCCATA_INPUT_CLASS;
693 1.2.4.2 nathanw dip->type = AUDIO_MIXER_ENUM;
694 1.2.4.2 nathanw dip->prev = TOCCATA_LINE_IN_LVL;
695 1.2.4.2 nathanw dip->next = AUDIO_MIXER_LAST;
696 1.2.4.2 nathanw goto mute;
697 1.2.4.2 nathanw #endif
698 1.2.4.2 nathanw case TOCCATA_MONITOR_MUTE:
699 1.2.4.2 nathanw dip->mixer_class = TOCCATA_MONITOR_CLASS;
700 1.2.4.2 nathanw dip->type = AUDIO_MIXER_ENUM;
701 1.2.4.2 nathanw dip->prev = TOCCATA_MONITOR_LVL;
702 1.2.4.2 nathanw dip->next = AUDIO_MIXER_LAST;
703 1.2.4.2 nathanw mute:
704 1.2.4.2 nathanw strcpy(dip->label.name, AudioNmute);
705 1.2.4.2 nathanw dip->un.e.num_mem = 2;
706 1.2.4.2 nathanw strcpy(dip->un.e.member[0].label.name, AudioNoff);
707 1.2.4.2 nathanw dip->un.e.member[0].ord = 0;
708 1.2.4.2 nathanw strcpy(dip->un.e.member[1].label.name, AudioNon);
709 1.2.4.2 nathanw dip->un.e.member[1].ord = 1;
710 1.2.4.2 nathanw break;
711 1.2.4.2 nathanw
712 1.2.4.2 nathanw case TOCCATA_REC_LVL: /* record level */
713 1.2.4.2 nathanw dip->type = AUDIO_MIXER_VALUE;
714 1.2.4.2 nathanw dip->mixer_class = TOCCATA_INPUT_CLASS;
715 1.2.4.2 nathanw dip->prev = AUDIO_MIXER_LAST;
716 1.2.4.2 nathanw dip->next = TOCCATA_RECORD_SOURCE;
717 1.2.4.2 nathanw strcpy(dip->label.name, AudioNrecord);
718 1.2.4.2 nathanw dip->un.v.num_channels = 2;
719 1.2.4.2 nathanw strcpy(dip->un.v.units.name, AudioNvolume);
720 1.2.4.2 nathanw break;
721 1.2.4.2 nathanw
722 1.2.4.2 nathanw case TOCCATA_RECORD_SOURCE:
723 1.2.4.2 nathanw dip->mixer_class = TOCCATA_RECORD_CLASS;
724 1.2.4.2 nathanw dip->type = AUDIO_MIXER_ENUM;
725 1.2.4.2 nathanw dip->prev = TOCCATA_REC_LVL;
726 1.2.4.2 nathanw dip->next = AUDIO_MIXER_LAST;
727 1.2.4.2 nathanw strcpy(dip->label.name, AudioNsource);
728 1.2.4.2 nathanw dip->un.e.num_mem = 4;
729 1.2.4.2 nathanw strcpy(dip->un.e.member[0].label.name, AudioNmicrophone);
730 1.2.4.2 nathanw dip->un.e.member[1].ord = MIC_IN_PORT;
731 1.2.4.2 nathanw strcpy(dip->un.e.member[1].label.name, AudioNline);
732 1.2.4.2 nathanw dip->un.e.member[3].ord = LINE_IN_PORT;
733 1.2.4.2 nathanw strcpy(dip->un.e.member[2].label.name, "aux1");
734 1.2.4.2 nathanw dip->un.e.member[2].ord = AUX1_IN_PORT;
735 1.2.4.2 nathanw strcpy(dip->un.e.member[3].label.name, AudioNoutput);
736 1.2.4.2 nathanw dip->un.e.member[0].ord = DAC_IN_PORT;
737 1.2.4.2 nathanw break;
738 1.2.4.2 nathanw
739 1.2.4.2 nathanw case TOCCATA_INPUT_CLASS: /* input class descriptor */
740 1.2.4.2 nathanw dip->type = AUDIO_MIXER_CLASS;
741 1.2.4.2 nathanw dip->mixer_class = TOCCATA_INPUT_CLASS;
742 1.2.4.2 nathanw dip->next = dip->prev = AUDIO_MIXER_LAST;
743 1.2.4.2 nathanw strcpy(dip->label.name, AudioCinputs);
744 1.2.4.2 nathanw break;
745 1.2.4.2 nathanw
746 1.2.4.2 nathanw case TOCCATA_OUTPUT_CLASS: /* output class descriptor */
747 1.2.4.2 nathanw dip->type = AUDIO_MIXER_CLASS;
748 1.2.4.2 nathanw dip->mixer_class = TOCCATA_OUTPUT_CLASS;
749 1.2.4.2 nathanw dip->next = dip->prev = AUDIO_MIXER_LAST;
750 1.2.4.2 nathanw strcpy(dip->label.name, AudioCoutputs);
751 1.2.4.2 nathanw break;
752 1.2.4.2 nathanw
753 1.2.4.2 nathanw case TOCCATA_MONITOR_CLASS: /* monitor class descriptor */
754 1.2.4.2 nathanw dip->type = AUDIO_MIXER_CLASS;
755 1.2.4.2 nathanw dip->mixer_class = TOCCATA_MONITOR_CLASS;
756 1.2.4.2 nathanw dip->next = dip->prev = AUDIO_MIXER_LAST;
757 1.2.4.2 nathanw strcpy(dip->label.name, AudioCmonitor);
758 1.2.4.2 nathanw break;
759 1.2.4.2 nathanw
760 1.2.4.2 nathanw case TOCCATA_RECORD_CLASS: /* record source class */
761 1.2.4.2 nathanw dip->type = AUDIO_MIXER_CLASS;
762 1.2.4.2 nathanw dip->mixer_class = TOCCATA_RECORD_CLASS;
763 1.2.4.2 nathanw dip->next = dip->prev = AUDIO_MIXER_LAST;
764 1.2.4.2 nathanw strcpy(dip->label.name, AudioCrecord);
765 1.2.4.2 nathanw break;
766 1.2.4.2 nathanw
767 1.2.4.2 nathanw default:
768 1.2.4.2 nathanw return ENXIO;
769 1.2.4.2 nathanw /*NOTREACHED*/
770 1.2.4.2 nathanw }
771 1.2.4.2 nathanw
772 1.2.4.2 nathanw return (0);
773 1.2.4.2 nathanw }
774