xref: /openbsd/sys/dev/ic/am7930.c (revision cc5bdd41)
1 /*	$OpenBSD: am7930.c,v 1.8 2022/10/26 20:19:07 kn 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 
49 #include <dev/ic/am7930reg.h>
50 #include <dev/ic/am7930var.h>
51 
52 #ifdef AUDIO_DEBUG
53 int	am7930debug = 0;
54 #define	DPRINTF(x)	if (am7930debug) printf x
55 #else
56 #define	DPRINTF(x)
57 #endif
58 
59 
60 /* The following tables stolen from former (4.4Lite's) sys/sparc/bsd_audio.c */
61 
62 /*
63  * gx, gr & stg gains.  this table must contain 256 elements with
64  * the 0th being "infinity" (the magic value 9008).  The remaining
65  * elements match sun's gain curve (but with higher resolution):
66  * -18 to 0dB in .16dB steps then 0 to 12dB in .08dB steps.
67  */
68 static const uint16_t gx_coeff[256] = {
69 	0x9008, 0x8e7c, 0x8e51, 0x8e45, 0x8d42, 0x8d3b, 0x8c36, 0x8c33,
70 	0x8b32, 0x8b2a, 0x8b2b, 0x8b2c, 0x8b25, 0x8b23, 0x8b22, 0x8b22,
71 	0x9122, 0x8b1a, 0x8aa3, 0x8aa3, 0x8b1c, 0x8aa6, 0x912d, 0x912b,
72 	0x8aab, 0x8b12, 0x8aaa, 0x8ab2, 0x9132, 0x8ab4, 0x913c, 0x8abb,
73 	0x9142, 0x9144, 0x9151, 0x8ad5, 0x8aeb, 0x8a79, 0x8a5a, 0x8a4a,
74 	0x8b03, 0x91c2, 0x91bb, 0x8a3f, 0x8a33, 0x91b2, 0x9212, 0x9213,
75 	0x8a2c, 0x921d, 0x8a23, 0x921a, 0x9222, 0x9223, 0x922d, 0x9231,
76 	0x9234, 0x9242, 0x925b, 0x92dd, 0x92c1, 0x92b3, 0x92ab, 0x92a4,
77 	0x92a2, 0x932b, 0x9341, 0x93d3, 0x93b2, 0x93a2, 0x943c, 0x94b2,
78 	0x953a, 0x9653, 0x9782, 0x9e21, 0x9d23, 0x9cd2, 0x9c23, 0x9baa,
79 	0x9bde, 0x9b33, 0x9b22, 0x9b1d, 0x9ab2, 0xa142, 0xa1e5, 0x9a3b,
80 	0xa213, 0xa1a2, 0xa231, 0xa2eb, 0xa313, 0xa334, 0xa421, 0xa54b,
81 	0xada4, 0xac23, 0xab3b, 0xaaab, 0xaa5c, 0xb1a3, 0xb2ca, 0xb3bd,
82 	0xbe24, 0xbb2b, 0xba33, 0xc32b, 0xcb5a, 0xd2a2, 0xe31d, 0x0808,
83 	0x72ba, 0x62c2, 0x5c32, 0x52db, 0x513e, 0x4cce, 0x43b2, 0x4243,
84 	0x41b4, 0x3b12, 0x3bc3, 0x3df2, 0x34bd, 0x3334, 0x32c2, 0x3224,
85 	0x31aa, 0x2a7b, 0x2aaa, 0x2b23, 0x2bba, 0x2c42, 0x2e23, 0x25bb,
86 	0x242b, 0x240f, 0x231a, 0x22bb, 0x2241, 0x2223, 0x221f, 0x1a33,
87 	0x1a4a, 0x1acd, 0x2132, 0x1b1b, 0x1b2c, 0x1b62, 0x1c12, 0x1c32,
88 	0x1d1b, 0x1e71, 0x16b1, 0x1522, 0x1434, 0x1412, 0x1352, 0x1323,
89 	0x1315, 0x12bc, 0x127a, 0x1235, 0x1226, 0x11a2, 0x1216, 0x0a2a,
90 	0x11bc, 0x11d1, 0x1163, 0x0ac2, 0x0ab2, 0x0aab, 0x0b1b, 0x0b23,
91 	0x0b33, 0x0c0f, 0x0bb3, 0x0c1b, 0x0c3e, 0x0cb1, 0x0d4c, 0x0ec1,
92 	0x079a, 0x0614, 0x0521, 0x047c, 0x0422, 0x03b1, 0x03e3, 0x0333,
93 	0x0322, 0x031c, 0x02aa, 0x02ba, 0x02f2, 0x0242, 0x0232, 0x0227,
94 	0x0222, 0x021b, 0x01ad, 0x0212, 0x01b2, 0x01bb, 0x01cb, 0x01f6,
95 	0x0152, 0x013a, 0x0133, 0x0131, 0x012c, 0x0123, 0x0122, 0x00a2,
96 	0x011b, 0x011e, 0x0114, 0x00b1, 0x00aa, 0x00b3, 0x00bd, 0x00ba,
97 	0x00c5, 0x00d3, 0x00f3, 0x0062, 0x0051, 0x0042, 0x003b, 0x0033,
98 	0x0032, 0x002a, 0x002c, 0x0025, 0x0023, 0x0022, 0x001a, 0x0021,
99 	0x001b, 0x001b, 0x001d, 0x0015, 0x0013, 0x0013, 0x0012, 0x0012,
100 	0x000a, 0x000a, 0x0011, 0x0011, 0x000b, 0x000b, 0x000c, 0x000e,
101 };
102 
103 /*
104  * second stage play gain.
105  */
106 static const uint16_t ger_coeff[] = {
107 	0x431f, /* 5. dB */
108 	0x331f, /* 5.5 dB */
109 	0x40dd, /* 6. dB */
110 	0x11dd, /* 6.5 dB */
111 	0x440f, /* 7. dB */
112 	0x411f, /* 7.5 dB */
113 	0x311f, /* 8. dB */
114 	0x5520, /* 8.5 dB */
115 	0x10dd, /* 9. dB */
116 	0x4211, /* 9.5 dB */
117 	0x410f, /* 10. dB */
118 	0x111f, /* 10.5 dB */
119 	0x600b, /* 11. dB */
120 	0x00dd, /* 11.5 dB */
121 	0x4210, /* 12. dB */
122 	0x110f, /* 13. dB */
123 	0x7200, /* 14. dB */
124 	0x2110, /* 15. dB */
125 	0x2200, /* 15.9 dB */
126 	0x000b, /* 16.9 dB */
127 	0x000f  /* 18. dB */
128 #define NGER (sizeof(ger_coeff) / sizeof(ger_coeff[0]))
129 };
130 
131 
132 /*
133  * Reset chip and set boot-time softc defaults.
134  */
135 void
am7930_init(struct am7930_softc * sc,int flag)136 am7930_init(struct am7930_softc *sc, int flag)
137 {
138 	DPRINTF(("am7930_init()\n"));
139 
140 	/* set boot defaults */
141 	sc->sc_rlevel = 128;
142 	sc->sc_plevel = 128;
143 	sc->sc_mlevel = 0;
144 	sc->sc_out_port = AUDIOAMD_SPEAKER_VOL;
145 	sc->sc_mic_mute = 0;
146 
147 	/* disable sample interrupts */
148 	AM7930_IWRITE(sc, AM7930_IREG_MUX_MCR4, 0);
149 
150 	/* initialise voice and data, and disable interrupts */
151 	AM7930_IWRITE(sc, AM7930_IREG_INIT,
152 	    AM7930_INIT_PMS_ACTIVE | AM7930_INIT_INT_DISABLE);
153 
154 	if (flag == AUDIOAMD_DMA_MODE) {
155 		/* configure PP for serial (SBP) mode */
156 		AM7930_IWRITE(sc, AM7930_IREG_PP_PPCR1, AM7930_PPCR1_SBP);
157 
158 		/*
159 		 * Initialise the MUX unit - route the MAP to the PP
160 		 */
161 		AM7930_IWRITE(sc, AM7930_IREG_MUX_MCR1,
162 		    (AM7930_MCRCHAN_BA << 4) | AM7930_MCRCHAN_BD);
163 		AM7930_IWRITE(sc, AM7930_IREG_MUX_MCR2, AM7930_MCRCHAN_NC);
164 		AM7930_IWRITE(sc, AM7930_IREG_MUX_MCR3, AM7930_MCRCHAN_NC);
165 	} else {
166 		/*
167 		 * Initialize the MUX unit.  We use MCR3 to route the MAP
168 		 * through channel Bb.  MCR1 and MCR2 are unused.
169 		 * Setting the INT enable bit in MCR4 will generate an
170 		 * interrupt on each converted audio sample.
171 		 */
172 		AM7930_IWRITE(sc, AM7930_IREG_MUX_MCR1, 0);
173 		AM7930_IWRITE(sc, AM7930_IREG_MUX_MCR2, 0);
174 		AM7930_IWRITE(sc, AM7930_IREG_MUX_MCR3,
175 		    (AM7930_MCRCHAN_BB << 4) | AM7930_MCRCHAN_BA);
176 		AM7930_IWRITE(sc, AM7930_IREG_MUX_MCR4,
177 		    AM7930_MCR4_INT_ENABLE);
178 	}
179 }
180 
181 /*
182  * XXX chip is full-duplex, but really attach-dependent.
183  * For now we know of no half-duplex attachments.
184  */
185 int
am7930_open(void * addr,int flags)186 am7930_open(void *addr, int flags)
187 {
188 	struct am7930_softc *sc = addr;
189 
190 	DPRINTF(("sa_open: unit %p\n", sc));
191 	if (sc->sc_open)
192 		return EBUSY;
193 	sc->sc_open = 1;
194 	sc->sc_locked = 0;
195 
196 	sc->sc_glue->onopen(sc);
197 	DPRINTF(("saopen: ok -> sc=%p\n",sc));
198 	return 0;
199 }
200 
201 void
am7930_close(void * addr)202 am7930_close(void *addr)
203 {
204 	struct am7930_softc *sc = addr;
205 
206 	DPRINTF(("sa_close: sc=%p\n", sc));
207 	sc->sc_glue->onclose(sc);
208 	sc->sc_open = 0;
209 	DPRINTF(("sa_close: closed.\n"));
210 }
211 
212 int
am7930_set_params(void * addr,int setmode,int usemode,struct audio_params * play,struct audio_params * rec)213 am7930_set_params(void *addr, int setmode, int usemode,
214     struct audio_params *play, struct audio_params *rec)
215 {
216 	struct am7930_softc *sc = addr;
217 	struct audio_params *p;
218 	int mode;
219 
220 	for (mode = AUMODE_RECORD; mode != -1;
221 	    mode = mode == AUMODE_RECORD ? AUMODE_PLAY : -1) {
222 		if ((setmode & mode) == 0)
223 			continue;
224 
225 		p = mode == AUMODE_PLAY ? play : rec;
226 		if (p == NULL)
227 			continue;
228 
229 		p->encoding = AUDIO_ENCODING_ULAW;
230 		p->precision = sc->sc_glue->precision;
231 		p->bps = AUDIO_BPS(p->precision);
232 		p->msb = 0;
233 		p->channels = 1;
234 		/* no other rates supported by amd chip */
235 		p->sample_rate = 8000;
236 	}
237 
238 	return 0;
239 }
240 
241 int
am7930_round_blocksize(void * addr,int blk)242 am7930_round_blocksize(void *addr, int blk)
243 {
244 	return blk;
245 }
246 
247 int
am7930_commit_settings(void * addr)248 am7930_commit_settings(void *addr)
249 {
250 	struct am7930_softc *sc = addr;
251 	uint16_t ger, gr, gx, stgr;
252 	uint8_t mmr2, mmr3;
253 	int level;
254 
255 	DPRINTF(("sa_commit.\n"));
256 	gx = gx_coeff[sc->sc_rlevel];
257 	stgr = gx_coeff[sc->sc_mlevel];
258 
259 	level = (sc->sc_plevel * (256 + NGER)) >> 8;
260 	if (level >= 256) {
261 		ger = ger_coeff[level - 256];
262 		gr = gx_coeff[255];
263 	} else {
264 		ger = ger_coeff[0];
265 		gr = gx_coeff[level];
266 	}
267 
268 	/* XXX: this is called before DMA is setup, useful ? */
269 	mtx_enter(&audio_lock);
270 
271 	mmr2 = AM7930_IREAD(sc, AM7930_IREG_MAP_MMR2);
272 	if (sc->sc_out_port == AUDIOAMD_SPEAKER_VOL)
273 		mmr2 |= AM7930_MMR2_LS;
274 	else
275 		mmr2 &= ~AM7930_MMR2_LS;
276 	AM7930_IWRITE(sc, AM7930_IREG_MAP_MMR2, mmr2);
277 
278 	mmr3 = AM7930_IREAD(sc, AM7930_IREG_MAP_MMR3);
279 	if (sc->sc_mic_mute)
280 		mmr3 |= AM7930_MMR3_MUTE;
281 	else
282 		mmr3 &= ~AM7930_MMR3_MUTE;
283 	AM7930_IWRITE(sc, AM7930_IREG_MAP_MMR3, mmr3);
284 
285 	AM7930_IWRITE(sc, AM7930_IREG_MAP_MMR1,
286 	    AM7930_MMR1_GX | AM7930_MMR1_GER |
287 	    AM7930_MMR1_GR | AM7930_MMR1_STG);
288 
289 	AM7930_IWRITE16(sc, AM7930_IREG_MAP_GX, gx);
290 	AM7930_IWRITE16(sc, AM7930_IREG_MAP_STG, stgr);
291 	AM7930_IWRITE16(sc, AM7930_IREG_MAP_GR, gr);
292 	AM7930_IWRITE16(sc, AM7930_IREG_MAP_GER, ger);
293 
294 	mtx_leave(&audio_lock);
295 
296 	return 0;
297 }
298 
299 int
am7930_halt_output(void * addr)300 am7930_halt_output(void *addr)
301 {
302 	struct am7930_softc *sc = addr;
303 
304 	/* XXX only halt, if input is also halted ?? */
305 	AM7930_IWRITE(sc, AM7930_IREG_INIT,
306 	    AM7930_INIT_PMS_ACTIVE | AM7930_INIT_INT_DISABLE);
307 	sc->sc_locked = 0;
308 	return 0;
309 }
310 
311 int
am7930_halt_input(void * addr)312 am7930_halt_input(void *addr)
313 {
314 	struct am7930_softc *sc = addr;
315 
316 	/* XXX only halt, if output is also halted ?? */
317 	AM7930_IWRITE(sc, AM7930_IREG_INIT,
318 	    AM7930_INIT_PMS_ACTIVE | AM7930_INIT_INT_DISABLE);
319 	sc->sc_locked = 0;
320 	return 0;
321 }
322 
323 /*
324  * Attach-dependent channel set/query
325  */
326 int
am7930_set_port(void * addr,mixer_ctrl_t * cp)327 am7930_set_port(void *addr, mixer_ctrl_t *cp)
328 {
329 	struct am7930_softc *sc = addr;
330 
331 	DPRINTF(("am7930_set_port: port=%d", cp->dev));
332 	if (cp->dev == AUDIOAMD_RECORD_SOURCE ||
333 	    cp->dev == AUDIOAMD_MONITOR_OUTPUT ||
334 	    cp->dev == AUDIOAMD_MIC_MUTE) {
335 		if (cp->type != AUDIO_MIXER_ENUM)
336 			return EINVAL;
337 	} else if (cp->type != AUDIO_MIXER_VALUE ||
338 	    cp->un.value.num_channels != 1) {
339 		return EINVAL;
340 	}
341 
342 	switch(cp->dev) {
343 	case AUDIOAMD_MIC_VOL:
344 		sc->sc_rlevel = cp->un.value.level[AUDIO_MIXER_LEVEL_MONO];
345 		break;
346 	case AUDIOAMD_SPEAKER_VOL:
347 	case AUDIOAMD_HEADPHONES_VOL:
348 		sc->sc_plevel = cp->un.value.level[AUDIO_MIXER_LEVEL_MONO];
349 		break;
350 	case AUDIOAMD_MONITOR_VOL:
351 		sc->sc_mlevel = cp->un.value.level[AUDIO_MIXER_LEVEL_MONO];
352 		break;
353 	case AUDIOAMD_RECORD_SOURCE:
354 		if (cp->un.ord != AUDIOAMD_MIC_VOL)
355 			return EINVAL;
356 		break;
357 	case AUDIOAMD_MIC_MUTE:
358 		sc->sc_mic_mute = cp->un.ord;
359 		break;
360 	case AUDIOAMD_MONITOR_OUTPUT:
361 		if (cp->un.ord != AUDIOAMD_SPEAKER_VOL &&
362 		    cp->un.ord != AUDIOAMD_HEADPHONES_VOL)
363 			return EINVAL;
364 		sc->sc_out_port = cp->un.ord;
365 		break;
366 	default:
367 		return EINVAL;
368 		/* NOTREACHED */
369 	}
370 	return 0;
371 }
372 
373 int
am7930_get_port(void * addr,mixer_ctrl_t * cp)374 am7930_get_port(void *addr, mixer_ctrl_t *cp)
375 {
376 	struct am7930_softc *sc = addr;
377 
378 	DPRINTF(("am7930_get_port: port=%d\n", cp->dev));
379 	if (cp->dev == AUDIOAMD_RECORD_SOURCE ||
380 	    cp->dev == AUDIOAMD_MONITOR_OUTPUT ||
381 	    cp->dev == AUDIOAMD_MIC_MUTE) {
382 		if (cp->type != AUDIO_MIXER_ENUM)
383 			return EINVAL;
384 	} else if (cp->type != AUDIO_MIXER_VALUE ||
385 	    cp->un.value.num_channels != 1) {
386 		return EINVAL;
387 	}
388 
389 	switch(cp->dev) {
390 	case AUDIOAMD_MIC_VOL:
391 		cp->un.value.level[AUDIO_MIXER_LEVEL_MONO] = sc->sc_rlevel;
392 		break;
393 	case AUDIOAMD_SPEAKER_VOL:
394 	case AUDIOAMD_HEADPHONES_VOL:
395 		cp->un.value.level[AUDIO_MIXER_LEVEL_MONO] = sc->sc_plevel;
396 		break;
397 	case AUDIOAMD_MONITOR_VOL:
398 		cp->un.value.level[AUDIO_MIXER_LEVEL_MONO] = sc->sc_mlevel;
399 		break;
400 	case AUDIOAMD_RECORD_SOURCE:
401 		cp->un.ord = AUDIOAMD_MIC_VOL;
402 		break;
403 	case AUDIOAMD_MIC_MUTE:
404 		cp->un.ord = sc->sc_mic_mute;
405 		break;
406 	case AUDIOAMD_MONITOR_OUTPUT:
407 		cp->un.ord = sc->sc_out_port;
408 		break;
409 	default:
410 		return EINVAL;
411 		/* NOTREACHED */
412 	}
413 	return 0;
414 }
415 
416 
417 /*
418  * Define mixer control facilities.
419  */
420 int
am7930_query_devinfo(void * addr,mixer_devinfo_t * dip)421 am7930_query_devinfo(void *addr, mixer_devinfo_t *dip)
422 {
423 	DPRINTF(("am7930_query_devinfo()\n"));
424 
425 	switch(dip->index) {
426 	case AUDIOAMD_MIC_VOL:
427 		dip->type = AUDIO_MIXER_VALUE;
428 		dip->mixer_class = AUDIOAMD_INPUT_CLASS;
429 		dip->prev =  AUDIO_MIXER_LAST;
430 		dip->next = AUDIOAMD_MIC_MUTE;
431 		strlcpy(dip->label.name, AudioNmicrophone,
432 		    sizeof dip->label.name);
433 		dip->un.v.num_channels = 1;
434 		strlcpy(dip->un.v.units.name, AudioNvolume,
435 		    sizeof dip->un.v.units.name);
436 		break;
437 	case AUDIOAMD_SPEAKER_VOL:
438 		dip->type = AUDIO_MIXER_VALUE;
439 		dip->mixer_class = AUDIOAMD_OUTPUT_CLASS;
440 		dip->prev = dip->next = AUDIO_MIXER_LAST;
441 		strlcpy(dip->label.name, AudioNspeaker,
442 		    sizeof dip->label.name);
443 		dip->un.v.num_channels = 1;
444 		strlcpy(dip->un.v.units.name, AudioNvolume,
445 		    sizeof dip->un.v.units.name);
446 		break;
447 	case AUDIOAMD_HEADPHONES_VOL:
448 		dip->type = AUDIO_MIXER_VALUE;
449 		dip->mixer_class = AUDIOAMD_OUTPUT_CLASS;
450 		dip->prev = dip->next = AUDIO_MIXER_LAST;
451 		strlcpy(dip->label.name, AudioNheadphone,
452 		    sizeof dip->label.name);
453 		dip->un.v.num_channels = 1;
454 		strlcpy(dip->un.v.units.name, AudioNvolume,
455 		    sizeof dip->un.v.units.name);
456 		break;
457 	case AUDIOAMD_MONITOR_VOL:
458 		dip->type = AUDIO_MIXER_VALUE;
459 		dip->mixer_class = AUDIOAMD_MONITOR_CLASS;
460 		dip->prev = dip->next = AUDIO_MIXER_LAST;
461 		strlcpy(dip->label.name, AudioNmonitor,
462 		    sizeof dip->label.name);
463 		dip->un.v.num_channels = 1;
464 		strlcpy(dip->un.v.units.name, AudioNvolume,
465 		    sizeof dip->un.v.units.name);
466 		break;
467 	case AUDIOAMD_RECORD_SOURCE:
468 		dip->type = AUDIO_MIXER_ENUM;
469 		dip->mixer_class = AUDIOAMD_RECORD_CLASS;
470 		dip->prev = dip->next = AUDIO_MIXER_LAST;
471 		strlcpy(dip->label.name, AudioNsource,
472 		    sizeof dip->label.name);
473 		dip->un.e.num_mem = 1;
474 		strlcpy(dip->un.e.member[0].label.name, AudioNmicrophone,
475 		    sizeof dip->un.e.member[0].label.name);
476 		dip->un.e.member[0].ord = AUDIOAMD_MIC_VOL;
477 		break;
478 	case AUDIOAMD_MONITOR_OUTPUT:
479 		dip->type = AUDIO_MIXER_ENUM;
480 		dip->mixer_class = AUDIOAMD_MONITOR_CLASS;
481 		dip->prev = dip->next = AUDIO_MIXER_LAST;
482 		strlcpy(dip->label.name, AudioNoutput,
483 		    sizeof dip->label.name);
484 		dip->un.e.num_mem = 2;
485 		strlcpy(dip->un.e.member[0].label.name, AudioNspeaker,
486 		    sizeof dip->un.e.member[0].label.name);
487 		dip->un.e.member[0].ord = AUDIOAMD_SPEAKER_VOL;
488 		strlcpy(dip->un.e.member[1].label.name, AudioNheadphone,
489 		    sizeof dip->un.e.member[1].label.name);
490 		dip->un.e.member[1].ord = AUDIOAMD_HEADPHONES_VOL;
491 		break;
492 	case AUDIOAMD_MIC_MUTE:
493 		dip->type = AUDIO_MIXER_ENUM;
494 		dip->mixer_class = AUDIOAMD_INPUT_CLASS;
495 		dip->prev =  AUDIOAMD_MIC_VOL;
496 		dip->next = AUDIO_MIXER_LAST;
497 		strlcpy(dip->label.name, AudioNmute,
498 		    sizeof dip->label.name);
499 		dip->un.e.num_mem = 2;
500 		strlcpy(dip->un.e.member[0].label.name, AudioNoff,
501 		    sizeof dip->un.e.member[0].label.name);
502 		dip->un.e.member[0].ord = 0;
503 		strlcpy(dip->un.e.member[1].label.name, AudioNon,
504 		    sizeof dip->un.e.member[1].label.name);
505 		dip->un.e.member[1].ord = 1;
506 		break;
507 	case AUDIOAMD_INPUT_CLASS:
508 		dip->type = AUDIO_MIXER_CLASS;
509 		dip->mixer_class = AUDIOAMD_INPUT_CLASS;
510 		dip->prev = dip->next = AUDIO_MIXER_LAST;
511 		strlcpy(dip->label.name, AudioCinputs,
512 		    sizeof dip->label.name);
513 		break;
514 	case AUDIOAMD_OUTPUT_CLASS:
515 		dip->type = AUDIO_MIXER_CLASS;
516 		dip->mixer_class = AUDIOAMD_OUTPUT_CLASS;
517 		dip->prev = dip->next = AUDIO_MIXER_LAST;
518 		strlcpy(dip->label.name, AudioCoutputs,
519 		    sizeof dip->label.name);
520 		break;
521 	case AUDIOAMD_RECORD_CLASS:
522 		dip->type = AUDIO_MIXER_CLASS;
523 		dip->mixer_class = AUDIOAMD_RECORD_CLASS;
524 		dip->prev = dip->next = AUDIO_MIXER_LAST;
525 		strlcpy(dip->label.name, AudioCrecord,
526 		    sizeof dip->label.name);
527 		break;
528 	case AUDIOAMD_MONITOR_CLASS:
529 		dip->type = AUDIO_MIXER_CLASS;
530 		dip->mixer_class = AUDIOAMD_MONITOR_CLASS;
531 		dip->prev = dip->next = AUDIO_MIXER_LAST;
532 		strlcpy(dip->label.name, AudioCmonitor,
533 		    sizeof dip->label.name);
534 		break;
535 	default:
536 		return ENXIO;
537 		/*NOTREACHED*/
538 	}
539 
540 	DPRINTF(("AUDIO_MIXER_DEVINFO: name=%s\n", dip->label.name));
541 
542 	return 0;
543 }
544