xref: /openbsd-src/sys/dev/ic/am7930.c (revision d13be5d47e4149db2549a9828e244d59dbc43f15)
1 /*	$OpenBSD: am7930.c,v 1.3 2011/09/04 20:08:37 miod Exp $	*/
2 /*	$NetBSD: am7930.c,v 1.44 2001/11/13 13:14:34 lukem Exp $	*/
3 
4 /*
5  * Copyright (c) 1995 Rolf Grossmann
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the
15  *    documentation and/or other materials provided with the distribution.
16  * 3. All advertising materials mentioning features or use of this software
17  *    must display the following acknowledgement:
18  *      This product includes software developed by Rolf Grossmann.
19  * 4. The name of the author may not be used to endorse or promote products
20  *    derived from this software without specific prior written permission
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  */
33 
34 /*
35  * Front-end attachment independent layer for AMD 79c30
36  * audio driver.  No ISDN support.
37  */
38 
39 #include <sys/param.h>
40 #include <sys/systm.h>
41 #include <sys/errno.h>
42 #include <sys/ioctl.h>
43 #include <sys/device.h>
44 #include <sys/proc.h>
45 
46 #include <sys/audioio.h>
47 #include <dev/audio_if.h>
48 #include <dev/mulaw.h>
49 
50 #include <dev/ic/am7930reg.h>
51 #include <dev/ic/am7930var.h>
52 
53 #ifdef AUDIO_DEBUG
54 int	am7930debug = 0;
55 #define	DPRINTF(x)	if (am7930debug) printf x
56 #else
57 #define	DPRINTF(x)
58 #endif
59 
60 
61 /* The following tables stolen from former (4.4Lite's) sys/sparc/bsd_audio.c */
62 
63 /*
64  * gx, gr & stg gains.  this table must contain 256 elements with
65  * the 0th being "infinity" (the magic value 9008).  The remaining
66  * elements match sun's gain curve (but with higher resolution):
67  * -18 to 0dB in .16dB steps then 0 to 12dB in .08dB steps.
68  */
69 static const uint16_t gx_coeff[256] = {
70 	0x9008, 0x8e7c, 0x8e51, 0x8e45, 0x8d42, 0x8d3b, 0x8c36, 0x8c33,
71 	0x8b32, 0x8b2a, 0x8b2b, 0x8b2c, 0x8b25, 0x8b23, 0x8b22, 0x8b22,
72 	0x9122, 0x8b1a, 0x8aa3, 0x8aa3, 0x8b1c, 0x8aa6, 0x912d, 0x912b,
73 	0x8aab, 0x8b12, 0x8aaa, 0x8ab2, 0x9132, 0x8ab4, 0x913c, 0x8abb,
74 	0x9142, 0x9144, 0x9151, 0x8ad5, 0x8aeb, 0x8a79, 0x8a5a, 0x8a4a,
75 	0x8b03, 0x91c2, 0x91bb, 0x8a3f, 0x8a33, 0x91b2, 0x9212, 0x9213,
76 	0x8a2c, 0x921d, 0x8a23, 0x921a, 0x9222, 0x9223, 0x922d, 0x9231,
77 	0x9234, 0x9242, 0x925b, 0x92dd, 0x92c1, 0x92b3, 0x92ab, 0x92a4,
78 	0x92a2, 0x932b, 0x9341, 0x93d3, 0x93b2, 0x93a2, 0x943c, 0x94b2,
79 	0x953a, 0x9653, 0x9782, 0x9e21, 0x9d23, 0x9cd2, 0x9c23, 0x9baa,
80 	0x9bde, 0x9b33, 0x9b22, 0x9b1d, 0x9ab2, 0xa142, 0xa1e5, 0x9a3b,
81 	0xa213, 0xa1a2, 0xa231, 0xa2eb, 0xa313, 0xa334, 0xa421, 0xa54b,
82 	0xada4, 0xac23, 0xab3b, 0xaaab, 0xaa5c, 0xb1a3, 0xb2ca, 0xb3bd,
83 	0xbe24, 0xbb2b, 0xba33, 0xc32b, 0xcb5a, 0xd2a2, 0xe31d, 0x0808,
84 	0x72ba, 0x62c2, 0x5c32, 0x52db, 0x513e, 0x4cce, 0x43b2, 0x4243,
85 	0x41b4, 0x3b12, 0x3bc3, 0x3df2, 0x34bd, 0x3334, 0x32c2, 0x3224,
86 	0x31aa, 0x2a7b, 0x2aaa, 0x2b23, 0x2bba, 0x2c42, 0x2e23, 0x25bb,
87 	0x242b, 0x240f, 0x231a, 0x22bb, 0x2241, 0x2223, 0x221f, 0x1a33,
88 	0x1a4a, 0x1acd, 0x2132, 0x1b1b, 0x1b2c, 0x1b62, 0x1c12, 0x1c32,
89 	0x1d1b, 0x1e71, 0x16b1, 0x1522, 0x1434, 0x1412, 0x1352, 0x1323,
90 	0x1315, 0x12bc, 0x127a, 0x1235, 0x1226, 0x11a2, 0x1216, 0x0a2a,
91 	0x11bc, 0x11d1, 0x1163, 0x0ac2, 0x0ab2, 0x0aab, 0x0b1b, 0x0b23,
92 	0x0b33, 0x0c0f, 0x0bb3, 0x0c1b, 0x0c3e, 0x0cb1, 0x0d4c, 0x0ec1,
93 	0x079a, 0x0614, 0x0521, 0x047c, 0x0422, 0x03b1, 0x03e3, 0x0333,
94 	0x0322, 0x031c, 0x02aa, 0x02ba, 0x02f2, 0x0242, 0x0232, 0x0227,
95 	0x0222, 0x021b, 0x01ad, 0x0212, 0x01b2, 0x01bb, 0x01cb, 0x01f6,
96 	0x0152, 0x013a, 0x0133, 0x0131, 0x012c, 0x0123, 0x0122, 0x00a2,
97 	0x011b, 0x011e, 0x0114, 0x00b1, 0x00aa, 0x00b3, 0x00bd, 0x00ba,
98 	0x00c5, 0x00d3, 0x00f3, 0x0062, 0x0051, 0x0042, 0x003b, 0x0033,
99 	0x0032, 0x002a, 0x002c, 0x0025, 0x0023, 0x0022, 0x001a, 0x0021,
100 	0x001b, 0x001b, 0x001d, 0x0015, 0x0013, 0x0013, 0x0012, 0x0012,
101 	0x000a, 0x000a, 0x0011, 0x0011, 0x000b, 0x000b, 0x000c, 0x000e,
102 };
103 
104 /*
105  * second stage play gain.
106  */
107 static const uint16_t ger_coeff[] = {
108 	0x431f, /* 5. dB */
109 	0x331f, /* 5.5 dB */
110 	0x40dd, /* 6. dB */
111 	0x11dd, /* 6.5 dB */
112 	0x440f, /* 7. dB */
113 	0x411f, /* 7.5 dB */
114 	0x311f, /* 8. dB */
115 	0x5520, /* 8.5 dB */
116 	0x10dd, /* 9. dB */
117 	0x4211, /* 9.5 dB */
118 	0x410f, /* 10. dB */
119 	0x111f, /* 10.5 dB */
120 	0x600b, /* 11. dB */
121 	0x00dd, /* 11.5 dB */
122 	0x4210, /* 12. dB */
123 	0x110f, /* 13. dB */
124 	0x7200, /* 14. dB */
125 	0x2110, /* 15. dB */
126 	0x2200, /* 15.9 dB */
127 	0x000b, /* 16.9 dB */
128 	0x000f  /* 18. dB */
129 #define NGER (sizeof(ger_coeff) / sizeof(ger_coeff[0]))
130 };
131 
132 
133 /*
134  * Reset chip and set boot-time softc defaults.
135  */
136 void
137 am7930_init(struct am7930_softc *sc, int flag)
138 {
139 	DPRINTF(("am7930_init()\n"));
140 
141 	/* set boot defaults */
142 	sc->sc_rlevel = 128;
143 	sc->sc_plevel = 128;
144 	sc->sc_mlevel = 0;
145 	sc->sc_out_port = AUDIOAMD_SPEAKER_VOL;
146 	sc->sc_mic_mute = 0;
147 
148 	/* disable sample interrupts */
149 	AM7930_IWRITE(sc, AM7930_IREG_MUX_MCR4, 0);
150 
151 	/* initialise voice and data, and disable interrupts */
152 	AM7930_IWRITE(sc, AM7930_IREG_INIT,
153 	    AM7930_INIT_PMS_ACTIVE | AM7930_INIT_INT_DISABLE);
154 
155 	if (flag == AUDIOAMD_DMA_MODE) {
156 		/* configure PP for serial (SBP) mode */
157 		AM7930_IWRITE(sc, AM7930_IREG_PP_PPCR1, AM7930_PPCR1_SBP);
158 
159 		/*
160 		 * Initialise the MUX unit - route the MAP to the PP
161 		 */
162 		AM7930_IWRITE(sc, AM7930_IREG_MUX_MCR1,
163 		    (AM7930_MCRCHAN_BA << 4) | AM7930_MCRCHAN_BD);
164 		AM7930_IWRITE(sc, AM7930_IREG_MUX_MCR2, AM7930_MCRCHAN_NC);
165 		AM7930_IWRITE(sc, AM7930_IREG_MUX_MCR3, AM7930_MCRCHAN_NC);
166 	} else {
167 		/*
168 		 * Initialize the MUX unit.  We use MCR3 to route the MAP
169 		 * through channel Bb.  MCR1 and MCR2 are unused.
170 		 * Setting the INT enable bit in MCR4 will generate an
171 		 * interrupt on each converted audio sample.
172 		 */
173 		AM7930_IWRITE(sc, AM7930_IREG_MUX_MCR1, 0);
174 		AM7930_IWRITE(sc, AM7930_IREG_MUX_MCR2, 0);
175 		AM7930_IWRITE(sc, AM7930_IREG_MUX_MCR3,
176 		    (AM7930_MCRCHAN_BB << 4) | AM7930_MCRCHAN_BA);
177 		AM7930_IWRITE(sc, AM7930_IREG_MUX_MCR4,
178 		    AM7930_MCR4_INT_ENABLE);
179 	}
180 }
181 
182 int
183 am7930_open(void *addr, int flags)
184 {
185 	struct am7930_softc *sc = addr;
186 
187 	DPRINTF(("sa_open: unit %p\n", sc));
188 	if (sc->sc_open)
189 		return EBUSY;
190 	sc->sc_open = 1;
191 	sc->sc_locked = 0;
192 
193 	sc->sc_glue->onopen(sc);
194 	DPRINTF(("saopen: ok -> sc=%p\n",sc));
195 	return 0;
196 }
197 
198 void
199 am7930_close(void *addr)
200 {
201 	struct am7930_softc *sc = addr;
202 
203 	DPRINTF(("sa_close: sc=%p\n", sc));
204 	sc->sc_glue->onclose(sc);
205 	sc->sc_open = 0;
206 	DPRINTF(("sa_close: closed.\n"));
207 }
208 
209 int
210 am7930_set_params(void *addr, int setmode, int usemode,
211     struct audio_params *play, struct audio_params *rec)
212 {
213 	struct am7930_softc *sc = addr;
214 	struct audio_params *p;
215 	int mode;
216 
217 	for (mode = AUMODE_RECORD; mode != -1;
218 	    mode = mode == AUMODE_RECORD ? AUMODE_PLAY : -1) {
219 		if ((setmode & mode) == 0)
220 			continue;
221 
222 		p = mode == AUMODE_PLAY ? play : rec;
223 		if (p == NULL)
224 			continue;
225 
226 		switch (p->encoding) {
227 		case AUDIO_ENCODING_ULAW:
228 			p->sw_code = NULL;
229 			break;
230 		case AUDIO_ENCODING_SLINEAR:
231 		case AUDIO_ENCODING_SLINEAR_BE:
232 		case AUDIO_ENCODING_SLINEAR_LE:
233 			if (mode == AUMODE_PLAY)
234 				p->sw_code = slinear8_to_mulaw;
235 			else
236 				p->sw_code = mulaw_to_slinear8;
237 			break;
238 		case AUDIO_ENCODING_ULINEAR:
239 		case AUDIO_ENCODING_ULINEAR_BE:
240 		case AUDIO_ENCODING_ULINEAR_LE:
241 			if (mode == AUMODE_PLAY)
242 				p->sw_code = ulinear8_to_mulaw;
243 			else
244 				p->sw_code = mulaw_to_ulinear8;
245 			break;
246 		case AUDIO_ENCODING_ALAW:
247 			if (mode == AUMODE_PLAY)
248 				p->sw_code = alaw_to_mulaw;
249 			else
250 				p->sw_code = mulaw_to_alaw;
251 			break;
252 		default:
253 			return EINVAL;
254 		}
255 		p->precision = 8;
256 		p->bps = 1;
257 		p->msb = 1;
258 		p->channels = 1;
259 		/* no other rates supported by amd chip */
260 		p->sample_rate = 8000;
261 
262 		if (sc->sc_glue->factor > 1) {
263 			p->factor = sc->sc_glue->factor;
264 			/*
265 			 * Remember which converter routine had been
266 			 * selected, if any, since there is no way
267 			 * to stack filters yet.
268 			 *
269 			 * Note that we rely upon the converters working
270 			 * in place (i.e. with factor == 1), which is
271 			 * correct as long as we don't try to emulate
272 			 * 16-bit encodings.
273 			 */
274 			if (mode == AUMODE_PLAY) {
275 				sc->play_sw_code = p->sw_code;
276 				p->sw_code = sc->sc_glue->output_conv;
277 			} else {
278 				sc->rec_sw_code = p->sw_code;
279 				p->sw_code = sc->sc_glue->input_conv;
280 			}
281 		}
282 	}
283 
284 	return 0;
285 }
286 
287 int
288 am7930_query_encoding(void *addr, struct audio_encoding *fp)
289 {
290 	switch (fp->index) {
291 	case 0:
292 		strlcpy(fp->name, AudioEmulaw, sizeof fp->name);
293 		fp->encoding = AUDIO_ENCODING_ULAW;
294 		fp->precision = 8;
295 		fp->bps = 1;
296 		fp->msb = 1;
297 		fp->flags = 0;
298 		break;
299 	case 1:
300 		strlcpy(fp->name, AudioEslinear, sizeof fp->name);
301 		fp->encoding = AUDIO_ENCODING_SLINEAR;
302 		fp->precision = 8;
303 		fp->bps = 1;
304 		fp->msb = 1;
305 		fp->flags = AUDIO_ENCODINGFLAG_EMULATED;
306 		break;
307 	case 2:
308 		strlcpy(fp->name, AudioEulinear, sizeof fp->name);
309 		fp->encoding = AUDIO_ENCODING_ULINEAR;
310 		fp->precision = 8;
311 		fp->bps = 1;
312 		fp->msb = 1;
313 		fp->flags = AUDIO_ENCODINGFLAG_EMULATED;
314 		break;
315 	case 3:
316 		strlcpy(fp->name, AudioEalaw, sizeof fp->name);
317 		fp->encoding = AUDIO_ENCODING_ALAW;
318 		fp->precision = 8;
319 		fp->bps = 1;
320 		fp->msb = 1;
321 		fp->flags = AUDIO_ENCODINGFLAG_EMULATED;
322 		break;
323 	default:
324 		return EINVAL;
325 		/*NOTREACHED*/
326 	}
327 	return 0;
328 }
329 
330 int
331 am7930_round_blocksize(void *addr, int blk)
332 {
333 	return blk;
334 }
335 
336 int
337 am7930_commit_settings(void *addr)
338 {
339 	struct am7930_softc *sc = addr;
340 	uint16_t ger, gr, gx, stgr;
341 	uint8_t mmr2, mmr3;
342 	int s, level;
343 
344 	DPRINTF(("sa_commit.\n"));
345 	gx = gx_coeff[sc->sc_rlevel];
346 	stgr = gx_coeff[sc->sc_mlevel];
347 
348 	level = (sc->sc_plevel * (256 + NGER)) >> 8;
349 	if (level >= 256) {
350 		ger = ger_coeff[level - 256];
351 		gr = gx_coeff[255];
352 	} else {
353 		ger = ger_coeff[0];
354 		gr = gx_coeff[level];
355 	}
356 
357 	s = splaudio();
358 
359 	mmr2 = AM7930_IREAD(sc, AM7930_IREG_MAP_MMR2);
360 	if (sc->sc_out_port == AUDIOAMD_SPEAKER_VOL)
361 		mmr2 |= AM7930_MMR2_LS;
362 	else
363 		mmr2 &= ~AM7930_MMR2_LS;
364 	AM7930_IWRITE(sc, AM7930_IREG_MAP_MMR2, mmr2);
365 
366 	mmr3 = AM7930_IREAD(sc, AM7930_IREG_MAP_MMR3);
367 	if (sc->sc_mic_mute)
368 		mmr3 |= AM7930_MMR3_MUTE;
369 	else
370 		mmr3 &= ~AM7930_MMR3_MUTE;
371 	AM7930_IWRITE(sc, AM7930_IREG_MAP_MMR3, mmr3);
372 
373 	AM7930_IWRITE(sc, AM7930_IREG_MAP_MMR1,
374 	    AM7930_MMR1_GX | AM7930_MMR1_GER |
375 	    AM7930_MMR1_GR | AM7930_MMR1_STG);
376 
377 	AM7930_IWRITE16(sc, AM7930_IREG_MAP_GX, gx);
378 	AM7930_IWRITE16(sc, AM7930_IREG_MAP_STG, stgr);
379 	AM7930_IWRITE16(sc, AM7930_IREG_MAP_GR, gr);
380 	AM7930_IWRITE16(sc, AM7930_IREG_MAP_GER, ger);
381 
382 	splx(s);
383 
384 	return 0;
385 }
386 
387 int
388 am7930_halt_output(void *addr)
389 {
390 	struct am7930_softc *sc = addr;
391 
392 	/* XXX only halt, if input is also halted ?? */
393 	AM7930_IWRITE(sc, AM7930_IREG_INIT,
394 	    AM7930_INIT_PMS_ACTIVE | AM7930_INIT_INT_DISABLE);
395 	sc->sc_locked = 0;
396 	return 0;
397 }
398 
399 int
400 am7930_halt_input(void *addr)
401 {
402 	struct am7930_softc *sc = addr;
403 
404 	/* XXX only halt, if output is also halted ?? */
405 	AM7930_IWRITE(sc, AM7930_IREG_INIT,
406 	    AM7930_INIT_PMS_ACTIVE | AM7930_INIT_INT_DISABLE);
407 	sc->sc_locked = 0;
408 	return 0;
409 }
410 
411 /*
412  * XXX chip is full-duplex, but really attach-dependent.
413  * For now we know of no half-duplex attachments.
414  */
415 int
416 am7930_get_props(void *addr)
417 {
418 	return AUDIO_PROP_FULLDUPLEX;
419 }
420 
421 /*
422  * Attach-dependent channel set/query
423  */
424 int
425 am7930_set_port(void *addr, mixer_ctrl_t *cp)
426 {
427 	struct am7930_softc *sc = addr;
428 
429 	DPRINTF(("am7930_set_port: port=%d", cp->dev));
430 	if (cp->dev == AUDIOAMD_RECORD_SOURCE ||
431 	    cp->dev == AUDIOAMD_MONITOR_OUTPUT ||
432 	    cp->dev == AUDIOAMD_MIC_MUTE) {
433 		if (cp->type != AUDIO_MIXER_ENUM)
434 			return EINVAL;
435 	} else if (cp->type != AUDIO_MIXER_VALUE ||
436 	    cp->un.value.num_channels != 1) {
437 		return EINVAL;
438 	}
439 
440 	switch(cp->dev) {
441 	case AUDIOAMD_MIC_VOL:
442 		sc->sc_rlevel = cp->un.value.level[AUDIO_MIXER_LEVEL_MONO];
443 		break;
444 	case AUDIOAMD_SPEAKER_VOL:
445 	case AUDIOAMD_HEADPHONES_VOL:
446 		sc->sc_plevel = cp->un.value.level[AUDIO_MIXER_LEVEL_MONO];
447 		break;
448 	case AUDIOAMD_MONITOR_VOL:
449 		sc->sc_mlevel = cp->un.value.level[AUDIO_MIXER_LEVEL_MONO];
450 		break;
451 	case AUDIOAMD_RECORD_SOURCE:
452 		if (cp->un.ord != AUDIOAMD_MIC_VOL)
453 			return EINVAL;
454 		break;
455 	case AUDIOAMD_MIC_MUTE:
456 		sc->sc_mic_mute = cp->un.ord;
457 		break;
458 	case AUDIOAMD_MONITOR_OUTPUT:
459 		if (cp->un.ord != AUDIOAMD_SPEAKER_VOL &&
460 		    cp->un.ord != AUDIOAMD_HEADPHONES_VOL)
461 			return EINVAL;
462 		sc->sc_out_port = cp->un.ord;
463 		break;
464 	default:
465 		return EINVAL;
466 		/* NOTREACHED */
467 	}
468 	return 0;
469 }
470 
471 int
472 am7930_get_port(void *addr, mixer_ctrl_t *cp)
473 {
474 	struct am7930_softc *sc = addr;
475 
476 	DPRINTF(("am7930_get_port: port=%d\n", cp->dev));
477 	if (cp->dev == AUDIOAMD_RECORD_SOURCE ||
478 	    cp->dev == AUDIOAMD_MONITOR_OUTPUT ||
479 	    cp->dev == AUDIOAMD_MIC_MUTE) {
480 		if (cp->type != AUDIO_MIXER_ENUM)
481 			return EINVAL;
482 	} else if (cp->type != AUDIO_MIXER_VALUE ||
483 	    cp->un.value.num_channels != 1) {
484 		return EINVAL;
485 	}
486 
487 	switch(cp->dev) {
488 	case AUDIOAMD_MIC_VOL:
489 		cp->un.value.level[AUDIO_MIXER_LEVEL_MONO] = sc->sc_rlevel;
490 		break;
491 	case AUDIOAMD_SPEAKER_VOL:
492 	case AUDIOAMD_HEADPHONES_VOL:
493 		cp->un.value.level[AUDIO_MIXER_LEVEL_MONO] = sc->sc_plevel;
494 		break;
495 	case AUDIOAMD_MONITOR_VOL:
496 		cp->un.value.level[AUDIO_MIXER_LEVEL_MONO] = sc->sc_mlevel;
497 		break;
498 	case AUDIOAMD_RECORD_SOURCE:
499 		cp->un.ord = AUDIOAMD_MIC_VOL;
500 		break;
501 	case AUDIOAMD_MIC_MUTE:
502 		cp->un.ord = sc->sc_mic_mute;
503 		break;
504 	case AUDIOAMD_MONITOR_OUTPUT:
505 		cp->un.ord = sc->sc_out_port;
506 		break;
507 	default:
508 		return EINVAL;
509 		/* NOTREACHED */
510 	}
511 	return 0;
512 }
513 
514 
515 /*
516  * Define mixer control facilities.
517  */
518 int
519 am7930_query_devinfo(void *addr, mixer_devinfo_t *dip)
520 {
521 	DPRINTF(("am7930_query_devinfo()\n"));
522 
523 	switch(dip->index) {
524 	case AUDIOAMD_MIC_VOL:
525 		dip->type = AUDIO_MIXER_VALUE;
526 		dip->mixer_class = AUDIOAMD_INPUT_CLASS;
527 		dip->prev =  AUDIO_MIXER_LAST;
528 		dip->next = AUDIOAMD_MIC_MUTE;
529 		strlcpy(dip->label.name, AudioNmicrophone,
530 		    sizeof dip->label.name);
531 		dip->un.v.num_channels = 1;
532 		strlcpy(dip->un.v.units.name, AudioNvolume,
533 		    sizeof dip->un.v.units.name);
534 		break;
535 	case AUDIOAMD_SPEAKER_VOL:
536 		dip->type = AUDIO_MIXER_VALUE;
537 		dip->mixer_class = AUDIOAMD_OUTPUT_CLASS;
538 		dip->prev = dip->next = AUDIO_MIXER_LAST;
539 		strlcpy(dip->label.name, AudioNspeaker,
540 		    sizeof dip->label.name);
541 		dip->un.v.num_channels = 1;
542 		strlcpy(dip->un.v.units.name, AudioNvolume,
543 		    sizeof dip->un.v.units.name);
544 		break;
545 	case AUDIOAMD_HEADPHONES_VOL:
546 		dip->type = AUDIO_MIXER_VALUE;
547 		dip->mixer_class = AUDIOAMD_OUTPUT_CLASS;
548 		dip->prev = dip->next = AUDIO_MIXER_LAST;
549 		strlcpy(dip->label.name, AudioNheadphone,
550 		    sizeof dip->label.name);
551 		dip->un.v.num_channels = 1;
552 		strlcpy(dip->un.v.units.name, AudioNvolume,
553 		    sizeof dip->un.v.units.name);
554 		break;
555 	case AUDIOAMD_MONITOR_VOL:
556 		dip->type = AUDIO_MIXER_VALUE;
557 		dip->mixer_class = AUDIOAMD_MONITOR_CLASS;
558 		dip->prev = dip->next = AUDIO_MIXER_LAST;
559 		strlcpy(dip->label.name, AudioNmonitor,
560 		    sizeof dip->label.name);
561 		dip->un.v.num_channels = 1;
562 		strlcpy(dip->un.v.units.name, AudioNvolume,
563 		    sizeof dip->un.v.units.name);
564 		break;
565 	case AUDIOAMD_RECORD_SOURCE:
566 		dip->type = AUDIO_MIXER_ENUM;
567 		dip->mixer_class = AUDIOAMD_RECORD_CLASS;
568 		dip->prev = dip->next = AUDIO_MIXER_LAST;
569 		strlcpy(dip->label.name, AudioNsource,
570 		    sizeof dip->label.name);
571 		dip->un.e.num_mem = 1;
572 		strlcpy(dip->un.e.member[0].label.name, AudioNmicrophone,
573 		    sizeof dip->un.e.member[0].label.name);
574 		dip->un.e.member[0].ord = AUDIOAMD_MIC_VOL;
575 		break;
576 	case AUDIOAMD_MONITOR_OUTPUT:
577 		dip->type = AUDIO_MIXER_ENUM;
578 		dip->mixer_class = AUDIOAMD_MONITOR_CLASS;
579 		dip->prev = dip->next = AUDIO_MIXER_LAST;
580 		strlcpy(dip->label.name, AudioNoutput,
581 		    sizeof dip->label.name);
582 		dip->un.e.num_mem = 2;
583 		strlcpy(dip->un.e.member[0].label.name, AudioNspeaker,
584 		    sizeof dip->un.e.member[0].label.name);
585 		dip->un.e.member[0].ord = AUDIOAMD_SPEAKER_VOL;
586 		strlcpy(dip->un.e.member[1].label.name, AudioNheadphone,
587 		    sizeof dip->un.e.member[1].label.name);
588 		dip->un.e.member[1].ord = AUDIOAMD_HEADPHONES_VOL;
589 		break;
590 	case AUDIOAMD_MIC_MUTE:
591 		dip->type = AUDIO_MIXER_ENUM;
592 		dip->mixer_class = AUDIOAMD_INPUT_CLASS;
593 		dip->prev =  AUDIOAMD_MIC_VOL;
594 		dip->next = AUDIO_MIXER_LAST;
595 		strlcpy(dip->label.name, AudioNmute,
596 		    sizeof dip->label.name);
597 		dip->un.e.num_mem = 2;
598 		strlcpy(dip->un.e.member[0].label.name, AudioNoff,
599 		    sizeof dip->un.e.member[0].label.name);
600 		dip->un.e.member[0].ord = 0;
601 		strlcpy(dip->un.e.member[1].label.name, AudioNon,
602 		    sizeof dip->un.e.member[1].label.name);
603 		dip->un.e.member[1].ord = 1;
604 		break;
605 	case AUDIOAMD_INPUT_CLASS:
606 		dip->type = AUDIO_MIXER_CLASS;
607 		dip->mixer_class = AUDIOAMD_INPUT_CLASS;
608 		dip->prev = dip->next = AUDIO_MIXER_LAST;
609 		strlcpy(dip->label.name, AudioCinputs,
610 		    sizeof dip->label.name);
611 		break;
612 	case AUDIOAMD_OUTPUT_CLASS:
613 		dip->type = AUDIO_MIXER_CLASS;
614 		dip->mixer_class = AUDIOAMD_OUTPUT_CLASS;
615 		dip->prev = dip->next = AUDIO_MIXER_LAST;
616 		strlcpy(dip->label.name, AudioCoutputs,
617 		    sizeof dip->label.name);
618 		break;
619 	case AUDIOAMD_RECORD_CLASS:
620 		dip->type = AUDIO_MIXER_CLASS;
621 		dip->mixer_class = AUDIOAMD_RECORD_CLASS;
622 		dip->prev = dip->next = AUDIO_MIXER_LAST;
623 		strlcpy(dip->label.name, AudioCrecord,
624 		    sizeof dip->label.name);
625 		break;
626 	case AUDIOAMD_MONITOR_CLASS:
627 		dip->type = AUDIO_MIXER_CLASS;
628 		dip->mixer_class = AUDIOAMD_MONITOR_CLASS;
629 		dip->prev = dip->next = AUDIO_MIXER_LAST;
630 		strlcpy(dip->label.name, AudioCmonitor,
631 		    sizeof dip->label.name);
632 		break;
633 	default:
634 		return ENXIO;
635 		/*NOTREACHED*/
636 	}
637 
638 	DPRINTF(("AUDIO_MIXER_DEVINFO: name=%s\n", dip->label.name));
639 
640 	return 0;
641 }
642