Annotation of src/sys/dev/isa/aria.c, Revision 1.21.2.1
1.21.2.1! kent 1: /* $NetBSD: aria.c,v 1.21 2004/10/29 12:57:17 yamt Exp $ */
1.5 mycroft 2:
1.1 augustss 3: /*-
4: * Copyright (c) 1995, 1996, 1998 Roland C. Dowdeswell. All rights reserved.
5: *
6: * Redistribution and use in source and binary forms, with or without
7: * modification, are permitted provided that the following conditions
8: * are met:
9: * 1. Redistributions of source code must retain the above copyright
10: * notice, this list of conditions and the following disclaimer.
11: * 2. Redistributions in binary form must reproduce the above copyright
12: * notice, this list of conditions and the following disclaimer in the
13: * documentation and/or other materials provided with the distribution.
14: * 3. All advertising materials mentioning features or use of this software
15: * must display the following acknowledgement:
16: * This product includes software developed by Roland C. Dowdeswell.
17: * 4. The name of the authors may not be used to endorse or promote products
18: * derived from this software without specific prior written permission.
19: *
20: * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
21: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23: * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
24: * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25: * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29: * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30: */
31:
32: /*-
33: * TODO:
34: * o Test the driver on cards other than a single
35: * Prometheus Aria 16.
36: * o Look into where aria_prometheus_kludge() belongs.
1.18 wiz 37: * o Add some DMA code. It accomplishes its goal by
1.1 augustss 38: * direct IO at the moment.
39: * o Different programs should be able to open the device
40: * with O_RDONLY and O_WRONLY at the same time. But I
41: * do not see support for this in /sys/dev/audio.c, so
42: * I cannot effectively code it.
1.17 wiz 43: * o We should nicely deal with the cards that can do mu-law
44: * and A-law output.
1.1 augustss 45: * o Rework the mixer interface.
46: * o Deal with the lvls better. We need to do better mapping
47: * between logarithmic scales and the one byte that
48: * we are passed.
49: * o Deal better with cards that have no mixer.
50: */
1.11 lukem 51:
52: #include <sys/cdefs.h>
1.21.2.1! kent 53: __KERNEL_RCSID(0, "$NetBSD: aria.c,v 1.21 2004/10/29 12:57:17 yamt Exp $");
1.1 augustss 54:
55: #include <sys/param.h>
56: #include <sys/systm.h>
57: #include <sys/errno.h>
58: #include <sys/ioctl.h>
59: #include <sys/syslog.h>
60: #include <sys/device.h>
61: #include <sys/proc.h>
62: #include <sys/buf.h>
1.20 mycroft 63: #include <sys/fcntl.h>
1.1 augustss 64:
65: #include <machine/cpu.h>
66: #include <machine/bus.h>
67:
68: #include <sys/audioio.h>
69: #include <dev/audio_if.h>
70: #include <dev/auconv.h>
71:
72: #include <dev/mulaw.h>
73: #include <dev/isa/isavar.h>
74:
75: #include <dev/isa/ariareg.h>
76:
77: #ifdef AUDIO_DEBUG
78: #define DPRINTF(x) printf x
79: int ariadebug = 0;
80: #else
81: #define DPRINTF(x)
82: #endif
83:
84: struct aria_mixdev_info {
85: u_char num_channels;
86: u_char level[2];
87: u_char mute;
88: };
89:
90: struct aria_mixmaster {
91: u_char num_channels;
92: u_char level[2];
93: u_char treble[2];
94: u_char bass[2];
95: };
96:
97: struct aria_softc {
98: struct device sc_dev; /* base device */
99: void *sc_ih; /* interrupt vectoring */
100: bus_space_tag_t sc_iot; /* Tag on 'da bus. */
101: bus_space_handle_t sc_ioh; /* Handle of iospace */
1.2 thorpej 102: isa_chipset_tag_t sc_ic; /* ISA chipset info */
1.1 augustss 103:
104: u_short sc_open; /* reference count of open calls */
105: u_short sc_play; /* non-paused play chans 2**chan */
106: u_short sc_record; /* non-paused record chans 2**chan */
107: /* XXX -- keep this? */
108: u_short sc_gain[2]; /* left/right gain (play) */
109:
110: u_long sc_rate; /* Sample rate for input and output */
1.17 wiz 111: u_int sc_encoding; /* audio encoding -- mu-law/linear */
1.1 augustss 112: int sc_chans; /* # of channels */
113: int sc_precision; /* # bits per sample */
114:
115: u_long sc_interrupts; /* number of interrupts taken */
116: void (*sc_rintr)(void*); /* record transfer completion intr handler */
117: void (*sc_pintr)(void*); /* play transfer completion intr handler */
118: void *sc_rarg; /* arg for sc_rintr() */
119: void *sc_parg; /* arg for sc_pintr() */
120:
121: int sc_blocksize; /* literal dio block size */
122: void *sc_rdiobuffer; /* record: where the next samples should be */
123: void *sc_pdiobuffer; /* play: where the next samples are */
124:
125: u_short sc_hardware; /* bit field of hardware present */
126: #define ARIA_TELEPHONE 0x0001 /* has telephone input */
127: #define ARIA_MIXER 0x0002 /* has SC18075 digital mixer */
128: #define ARIA_MODEL 0x0004 /* is SC18025 (=0) or SC18026 (=1) */
129:
130: struct aria_mixdev_info aria_mix[6];
131: struct aria_mixmaster ariamix_master;
132: u_char aria_mix_source;
133:
134: int sc_sendcmd_err;
135: };
136:
137: int ariaprobe __P((struct device *, struct cfdata *, void *));
138: void ariaattach __P((struct device *, struct device *, void *));
139: void ariaclose __P((void *));
140: int ariaopen __P((void *, int));
141: int ariareset __P((bus_space_tag_t, bus_space_handle_t));
142: int aria_reset __P((struct aria_softc *));
143: int aria_getdev __P((void *, struct audio_device *));
144:
145: void aria_do_kludge __P((bus_space_tag_t, bus_space_handle_t,
146: bus_space_handle_t,
147: u_short, u_short, u_short, u_short));
148: void aria_prometheus_kludge __P((struct isa_attach_args *,
149: bus_space_handle_t));
150:
151: int aria_query_encoding __P((void *, struct audio_encoding *));
152: int aria_round_blocksize __P((void *, int));
153: int aria_speaker_ctl __P((void *, int));
154: int aria_commit_settings __P((void *));
1.21.2.1! kent 155: int aria_set_params __P((void *, int, int, audio_params_t *,
! 156: audio_params_t *, stream_filter_list_t *,
! 157: stream_filter_list_t *));
1.1 augustss 158: int aria_get_props __P((void *));
159:
160: int aria_start_output __P((void *, void *, int,
161: void (*) __P((void *)), void*));
162: int aria_start_input __P((void *, void *, int,
163: void (*) __P((void *)), void*));
164:
165: int aria_halt_input __P((void *));
166: int aria_halt_output __P((void *));
167:
168: int aria_sendcmd __P((struct aria_softc *, u_short, int, int, int));
169:
170: u_short aria_getdspmem __P((struct aria_softc *, u_short));
171: void aria_putdspmem __P((struct aria_softc *, u_short, u_short));
172:
173: int aria_intr __P((void *));
174: short ariaversion __P((struct aria_softc *));
175:
176: void aria_set_mixer __P((struct aria_softc *, int));
177:
178: void aria_mix_write __P((struct aria_softc *, int, int));
179: int aria_mix_read __P((struct aria_softc *, int));
180:
181: int aria_mixer_set_port __P((void *, mixer_ctrl_t *));
182: int aria_mixer_get_port __P((void *, mixer_ctrl_t *));
183: int aria_mixer_query_devinfo __P((void *, mixer_devinfo_t *));
184:
1.14 thorpej 185: CFATTACH_DECL(aria, sizeof(struct aria_softc),
1.15 thorpej 186: ariaprobe, ariaattach, NULL, NULL);
1.1 augustss 187:
188: /* XXX temporary test for 1.3 */
189: #ifndef AudioNaux
190: /* 1.3 */
191: struct cfdriver aria_cd = {
192: NULL, "aria", DV_DULL
193: };
194: #endif
195:
196: struct audio_device aria_device = {
197: "Aria 16(se)",
198: "x",
199: "aria"
200: };
201:
202: /*
203: * Define our interface to the higher level audio driver.
204: */
205:
1.21 yamt 206: const struct audio_hw_if aria_hw_if = {
1.1 augustss 207: ariaopen,
208: ariaclose,
209: NULL,
210: aria_query_encoding,
211: aria_set_params,
212: aria_round_blocksize,
213: aria_commit_settings,
214: NULL,
215: NULL,
216: aria_start_output,
217: aria_start_input,
218: aria_halt_input,
219: aria_halt_output,
220: NULL,
221: aria_getdev,
222: NULL,
223: aria_mixer_set_port,
224: aria_mixer_get_port,
225: aria_mixer_query_devinfo,
226: NULL,
227: NULL,
228: NULL,
229: NULL,
230: aria_get_props,
1.10 augustss 231: NULL,
232: NULL,
233: NULL,
1.1 augustss 234: };
235:
236: /*
237: * Probe / attach routines.
238: */
239:
240: /*
241: * Probe for the aria hardware.
242: */
243: int
244: ariaprobe(parent, cf, aux)
245: struct device *parent;
246: struct cfdata *cf;
247: void *aux;
248: {
249: bus_space_handle_t ioh;
250: struct isa_attach_args *ia = aux;
251:
1.12 thorpej 252: if (ia->ia_nio < 1)
253: return (0);
254: if (ia->ia_nirq < 1)
255: return (0);
256:
257: if (ISA_DIRECT_CONFIG(ia))
258: return (0);
259:
260: if (!ARIA_BASE_VALID(ia->ia_io[0].ir_addr)) {
261: printf("aria: configured iobase %d invalid\n",
262: ia->ia_io[0].ir_addr);
1.1 augustss 263: return 0;
264: }
265:
1.12 thorpej 266: if (!ARIA_IRQ_VALID(ia->ia_irq[0].ir_irq)) {
267: printf("aria: configured irq %d invalid\n",
268: ia->ia_irq[0].ir_irq);
1.1 augustss 269: return 0;
270: }
271:
1.12 thorpej 272: if (bus_space_map(ia->ia_iot, ia->ia_io[0].ir_addr, ARIADSP_NPORT,
273: 0, &ioh)) {
1.1 augustss 274: DPRINTF(("aria: aria probe failed\n"));
275: return 0;
276: }
277:
278: if (cf->cf_flags & 1)
279: aria_prometheus_kludge(ia, ioh);
280:
281: if (ariareset(ia->ia_iot, ioh) != 0) {
282: DPRINTF(("aria: aria probe failed\n"));
283: bus_space_unmap(ia->ia_iot, ioh, ARIADSP_NPORT);
284: return 0;
285: }
286:
1.12 thorpej 287: bus_space_unmap(ia->ia_iot, ioh, ARIADSP_NPORT);
288:
289: ia->ia_nio = 1;
290: ia->ia_io[0].ir_size = ARIADSP_NPORT;
291:
292: ia->ia_nirq = 1;
293:
294: ia->ia_niomem = 0;
295: ia->ia_ndrq = 0;
1.1 augustss 296:
297: DPRINTF(("aria: aria probe succeeded\n"));
298: return 1;
299: }
300:
301: /*
302: * I didn't call this a kludge for
303: * nothing. This is cribbed from
304: * ariainit, the author of that
305: * disassembled some code to discover
306: * how to set up the initial values of
307: * the card. Without this, the card
308: * is dead. (It will not respond to _any_
309: * input at all.)
310: *
311: * ariainit can be found (ftp) at:
312: * ftp://ftp.wi.leidenuniv.nl/pub/audio/aria/programming/contrib/ariainit.zip
313: * currently.
314: */
315:
316: void
317: aria_prometheus_kludge(ia, ioh1)
318: struct isa_attach_args *ia;
319: bus_space_handle_t ioh1;
320: {
321: bus_space_tag_t iot;
322: bus_space_handle_t ioh;
323: u_short end;
324:
325: DPRINTF(("aria: begin aria_prometheus_kludge\n"));
326:
327: /* Begin Config Sequence */
328:
329: iot = ia->ia_iot;
330: bus_space_map(iot, 0x200, 8, 0, &ioh);
331:
332: bus_space_write_1(iot, ioh, 4, 0x4c);
333: bus_space_write_1(iot, ioh, 5, 0x42);
334: bus_space_write_1(iot, ioh, 6, 0x00);
335: bus_space_write_2(iot, ioh, 0, 0x0f);
336: bus_space_write_1(iot, ioh, 1, 0x00);
337: bus_space_write_2(iot, ioh, 0, 0x02);
1.12 thorpej 338: bus_space_write_1(iot, ioh, 1, ia->ia_io[0].ir_addr>>2);
1.1 augustss 339:
340: /*
341: * These next three lines set up the iobase
342: * and the irq; and disable the drq.
343: */
344:
1.12 thorpej 345: aria_do_kludge(iot, ioh, ioh1, 0x111,
346: ((ia->ia_io[0].ir_addr-0x280)>>2)+0xA0, 0xbf, 0xa0);
347: aria_do_kludge(iot, ioh, ioh1, 0x011,
348: ia->ia_irq[0].ir_irq-6, 0xf8, 0x00);
1.1 augustss 349: aria_do_kludge(iot, ioh, ioh1, 0x011, 0x00, 0xef, 0x00);
350:
351: /* The rest of these lines just disable everything else */
352:
353: aria_do_kludge(iot, ioh, ioh1, 0x113, 0x00, 0x88, 0x00);
354: aria_do_kludge(iot, ioh, ioh1, 0x013, 0x00, 0xf8, 0x00);
355: aria_do_kludge(iot, ioh, ioh1, 0x013, 0x00, 0xef, 0x00);
356: aria_do_kludge(iot, ioh, ioh1, 0x117, 0x00, 0x88, 0x00);
357: aria_do_kludge(iot, ioh, ioh1, 0x017, 0x00, 0xff, 0x00);
358:
359: /* End Sequence */
360:
361: bus_space_write_1(iot, ioh, 0, 0x0f);
362: end = bus_space_read_1(iot, ioh1, 0);
363: bus_space_write_2(iot, ioh, 0, 0x0f);
364: bus_space_write_1(iot, ioh, 1, end|0x80);
365: bus_space_read_1(iot, ioh, 0);
366:
367: bus_space_unmap(iot, ioh, 8);
368: /*
369: * This delay is necessary for some reason,
370: * at least it would crash, and sometimes not
371: * probe properly if it did not exist.
372: */
373: delay(1000000);
374: }
375:
376: void
377: aria_do_kludge(iot, ioh, ioh1, func, bits, and, or)
378: bus_space_tag_t iot;
379: bus_space_handle_t ioh;
380: bus_space_handle_t ioh1;
381: u_short func;
382: u_short bits;
383: u_short and;
384: u_short or;
385: {
386: u_int i;
387: if (func & 0x100) {
388: func &= ~0x100;
389: if (bits) {
390: bus_space_write_2(iot, ioh, 0, func-1);
391: bus_space_write_1(iot, ioh, 1, bits);
392: }
393: } else
394: or |= bits;
395:
396: bus_space_write_1(iot, ioh, 0, func);
397: i = bus_space_read_1(iot, ioh1, 0);
398: bus_space_write_2(iot, ioh, 0, func);
399: bus_space_write_1(iot, ioh, 1, (i&and) | or);
400: }
401:
402: /*
403: * Attach hardware to driver, attach hardware driver to audio
404: * pseudo-device driver.
405: */
406: void
407: ariaattach(parent, self, aux)
408: struct device *parent, *self;
409: void *aux;
410: {
411: bus_space_handle_t ioh;
412: struct aria_softc *sc = (void *)self;
413: struct isa_attach_args *ia = aux;
414: u_short i;
415:
1.12 thorpej 416: if (bus_space_map(ia->ia_iot, ia->ia_io[0].ir_addr, ARIADSP_NPORT,
417: 0, &ioh))
1.1 augustss 418: panic("%s: can map io port range", self->dv_xname);
419:
420: sc->sc_iot = ia->ia_iot;
421: sc->sc_ioh = ioh;
1.2 thorpej 422: sc->sc_ic = ia->ia_ic;
1.1 augustss 423:
1.12 thorpej 424: sc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq[0].ir_irq,
425: IST_EDGE, IPL_AUDIO, aria_intr, sc);
1.1 augustss 426:
427: DPRINTF(("isa_intr_establish() returns (%x)\n", (unsigned) sc->sc_ih));
428:
429: i = aria_getdspmem(sc, ARIAA_HARDWARE_A);
430:
431: sc->sc_hardware = 0;
432: sc->sc_hardware |= ((i>>13)&0x01)==1 ? ARIA_TELEPHONE:0;
433: sc->sc_hardware |= (((i>>5)&0x07))==0x04 ? ARIA_MIXER:0;
434: sc->sc_hardware |= (aria_getdspmem(sc, ARIAA_MODEL_A)>=1)?ARIA_MODEL:0;
435:
436: sc->sc_open = 0;
437: sc->sc_play = 0;
438: sc->sc_record = 0;
439: sc->sc_rate = 7875;
440: sc->sc_chans = 1;
441: sc->sc_blocksize = 1024;
442: sc->sc_precision = 8;
443: sc->sc_rintr = 0;
444: sc->sc_rarg = 0;
445: sc->sc_pintr = 0;
446: sc->sc_parg = 0;
447: sc->sc_gain[0] = 127;
448: sc->sc_gain[1] = 127;
449:
450: for (i=0; i<6; i++) {
451: if (i == ARIAMIX_TEL_LVL)
452: sc->aria_mix[i].num_channels = 1;
453: else
454: sc->aria_mix[i].num_channels = 2;
455: sc->aria_mix[i].level[0] = 127;
456: sc->aria_mix[i].level[1] = 127;
457: }
458:
459: sc->ariamix_master.num_channels = 2;
460: sc->ariamix_master.level[0] = 222;
461: sc->ariamix_master.level[1] = 222;
462: sc->ariamix_master.bass[0] = 127;
463: sc->ariamix_master.bass[1] = 127;
464: sc->ariamix_master.treble[0] = 127;
465: sc->ariamix_master.treble[1] = 127;
466: sc->aria_mix_source = 0;
467:
468: aria_commit_settings(sc);
469:
470: printf(": dsp %s", (ARIA_MODEL&sc->sc_hardware)?"SC18026":"SC18025");
471: if (ARIA_TELEPHONE&sc->sc_hardware)
472: printf(", tel");
473: if (ARIA_MIXER&sc->sc_hardware)
474: printf(", SC18075 mixer");
475: printf("\n");
476:
1.19 itojun 477: snprintf(aria_device.version, sizeof(aria_device.version), "%s",
1.1 augustss 478: ARIA_MODEL & sc->sc_hardware ? "SC18026" : "SC18025");
479:
1.6 augustss 480: audio_attach_mi(&aria_hw_if, (void *)sc, &sc->sc_dev);
1.1 augustss 481: }
482:
483: /*
484: * Various routines to interface to higher level audio driver
485: */
486:
487: int
488: ariaopen(addr, flags)
489: void *addr;
490: int flags;
491: {
492: struct aria_softc *sc = addr;
493:
494: DPRINTF(("ariaopen() called\n"));
495:
496: if (!sc)
497: return ENXIO;
498:
499: if (flags&FREAD)
500: sc->sc_open |= ARIAR_OPEN_RECORD;
501: if (flags&FWRITE)
502: sc->sc_open |= ARIAR_OPEN_PLAY;
503:
504: return 0;
505: }
506:
507: int
508: aria_getdev(addr, retp)
509: void *addr;
510: struct audio_device *retp;
511: {
512: *retp = aria_device;
513: return 0;
514: }
515:
516: /*
517: * Various routines to interface to higher level audio driver
518: */
519:
520: int
521: aria_query_encoding(addr, fp)
522: void *addr;
523: struct audio_encoding *fp;
524: {
525: struct aria_softc *sc = addr;
526:
527: switch (fp->index) {
528: case 0:
529: strcpy(fp->name, AudioEmulaw);
530: fp->encoding = AUDIO_ENCODING_ULAW;
531: fp->precision = 8;
532: if ((ARIA_MODEL&sc->sc_hardware) == 0)
533: fp->flags = AUDIO_ENCODINGFLAG_EMULATED;
534: break;
535: case 1:
536: strcpy(fp->name, AudioEalaw);
537: fp->encoding = AUDIO_ENCODING_ALAW;
538: fp->precision = 8;
539: if ((ARIA_MODEL&sc->sc_hardware) == 0)
540: fp->flags = AUDIO_ENCODINGFLAG_EMULATED;
541: break;
542: case 2:
543: strcpy(fp->name, AudioEslinear);
544: fp->encoding = AUDIO_ENCODING_SLINEAR;
545: fp->precision = 8;
546: fp->flags = AUDIO_ENCODINGFLAG_EMULATED;
547: break;
548: case 3:
549: strcpy(fp->name, AudioEslinear_le);
550: fp->encoding = AUDIO_ENCODING_SLINEAR_LE;
551: fp->precision = 16;
552: fp->flags = 0;
553: break;
554: case 4:
555: strcpy(fp->name, AudioEslinear_be);
556: fp->encoding = AUDIO_ENCODING_SLINEAR_BE;
557: fp->precision = 16;
558: fp->flags = AUDIO_ENCODINGFLAG_EMULATED;
559: break;
560: case 5:
561: strcpy(fp->name, AudioEulinear);
562: fp->encoding = AUDIO_ENCODING_ULINEAR;
563: fp->precision = 8;
564: fp->flags = 0;
565: break;
566: case 6:
567: strcpy(fp->name, AudioEulinear_le);
568: fp->encoding = AUDIO_ENCODING_ULINEAR_LE;
569: fp->precision = 16;
570: fp->flags = AUDIO_ENCODINGFLAG_EMULATED;
571: break;
572: case 7:
573: strcpy(fp->name, AudioEulinear_be);
574: fp->encoding = AUDIO_ENCODING_ULINEAR_BE;
575: fp->precision = 16;
576: fp->flags = AUDIO_ENCODINGFLAG_EMULATED;
577: break;
578: default:
579: return(EINVAL);
580: /*NOTREACHED*/
581: }
582:
583: return (0);
584: }
585:
586: /*
587: * Store blocksize in bytes.
588: */
589:
590: int
591: aria_round_blocksize(addr, blk)
592: void *addr;
593: int blk;
594: {
595: int i;
596: #if 0 /* XXX -- this is being a tad bit of a problem... */
597: for (i=64; i<1024; i*=2)
598: if (blk <= i)
599: break;
600: #else
601: i = 1024;
602: #endif
603: return(i);
604: }
605:
606: int
607: aria_get_props(addr)
608: void *addr;
609: {
610: return AUDIO_PROP_FULLDUPLEX;
611: }
612:
613: int
1.21.2.1! kent 614: aria_set_params(addr, setmode, usemode, p, r, pfil, rfil)
1.1 augustss 615: void *addr;
616: int setmode, usemode;
1.21.2.1! kent 617: audio_params_t *p, *r;
! 618: stream_filter_list_t *pfil, *rfil;
1.1 augustss 619: {
1.21.2.1! kent 620: audio_params_t hw;
1.1 augustss 621: struct aria_softc *sc = addr;
622:
623: switch(p->encoding) {
624: case AUDIO_ENCODING_ULAW:
625: case AUDIO_ENCODING_ALAW:
626: case AUDIO_ENCODING_SLINEAR:
627: case AUDIO_ENCODING_SLINEAR_LE:
628: case AUDIO_ENCODING_SLINEAR_BE:
629: case AUDIO_ENCODING_ULINEAR:
630: case AUDIO_ENCODING_ULINEAR_LE:
631: case AUDIO_ENCODING_ULINEAR_BE:
632: break;
633: default:
634: return (EINVAL);
635: }
636:
637: if (p->sample_rate <= 9450)
638: p->sample_rate = 7875;
639: else if (p->sample_rate <= 13387)
640: p->sample_rate = 11025;
641: else if (p->sample_rate <= 18900)
642: p->sample_rate = 15750;
643: else if (p->sample_rate <= 26775)
644: p->sample_rate = 22050;
645: else if (p->sample_rate <= 37800)
646: p->sample_rate = 31500;
647: else
648: p->sample_rate = 44100;
649:
1.21.2.1! kent 650: hw = *p;
1.1 augustss 651: sc->sc_encoding = p->encoding;
652: sc->sc_precision = p->precision;
653: sc->sc_chans = p->channels;
654: sc->sc_rate = p->sample_rate;
655:
656: switch(p->encoding) {
657: case AUDIO_ENCODING_ULAW:
658: if ((ARIA_MODEL&sc->sc_hardware) == 0) {
1.21.2.1! kent 659: hw.encoding = AUDIO_ENCODING_ULINEAR_LE;
! 660: stream_filter_list_append(pfil, mulaw_to_linear8, &hw);
! 661: stream_filter_list_append(rfil, linear8_to_mulaw, &hw);
1.1 augustss 662: }
663: break;
664: case AUDIO_ENCODING_ALAW:
665: if ((ARIA_MODEL&sc->sc_hardware) == 0) {
1.21.2.1! kent 666: hw.encoding = AUDIO_ENCODING_ULINEAR_LE;
! 667: stream_filter_list_append(pfil, alaw_to_linear8, &hw);
! 668: stream_filter_list_append(rfil, linear8_to_alaw, &hw);
1.1 augustss 669: }
670: break;
671: case AUDIO_ENCODING_SLINEAR:
1.21.2.1! kent 672: hw.encoding = AUDIO_ENCODING_ULINEAR_LE;
! 673: stream_filter_list_append(pfil, change_sign8, &hw);
! 674: stream_filter_list_append(rfil, change_sign8, &hw);
1.1 augustss 675: break;
676: case AUDIO_ENCODING_ULINEAR_LE:
1.21.2.1! kent 677: hw.encoding = AUDIO_ENCODING_SLINEAR_LE;
! 678: stream_filter_list_append(pfil, change_sign16, &hw);
! 679: stream_filter_list_append(rfil, change_sign16, &hw);
1.1 augustss 680: break;
681: case AUDIO_ENCODING_SLINEAR_BE:
1.21.2.1! kent 682: hw.encoding = AUDIO_ENCODING_SLINEAR_LE;
! 683: stream_filter_list_append(pfil, swap_bytes, &hw);
! 684: stream_filter_list_append(rfil, swap_bytes, &hw);
1.1 augustss 685: break;
686: case AUDIO_ENCODING_ULINEAR_BE:
1.21.2.1! kent 687: hw.encoding = AUDIO_ENCODING_SLINEAR_LE;
! 688: stream_filter_list_append(pfil, swap_bytes_change_sign16, &hw);
! 689: stream_filter_list_append(rfil, swap_bytes_change_sign16, &hw);
1.1 augustss 690: break;
691: }
692:
693: return 0;
694: }
695:
696: /*
697: * This is where all of the twiddling goes on.
698: */
699:
700: int
701: aria_commit_settings(addr)
702: void *addr;
703: {
704: struct aria_softc *sc = addr;
705: bus_space_tag_t iot = sc->sc_iot;
706: bus_space_handle_t ioh = sc->sc_ioh;
707: static u_char tones[16] =
708: { 7, 6, 5, 4, 3, 2, 1, 0, 8, 9, 10, 11, 12, 13, 14, 15 };
709: u_short format;
710: u_short left, right;
711: u_short samp;
712: u_char i;
713:
714: DPRINTF(("aria_commit_settings\n"));
715:
716: switch (sc->sc_rate) {
717: case 7875: format = 0x00; samp = 0x60; break;
718: case 11025: format = 0x00; samp = 0x40; break;
719: case 15750: format = 0x10; samp = 0x60; break;
720: case 22050: format = 0x10; samp = 0x40; break;
721: case 31500: format = 0x10; samp = 0x20; break;
722: case 44100: format = 0x20; samp = 0x00; break;
723: default: format = 0x00; samp = 0x40; break;/* XXX can we get here? */
724: }
725:
726: if ((ARIA_MODEL&sc->sc_hardware) != 0) {
727: format |= (sc->sc_encoding==AUDIO_ENCODING_ULAW)?0x06:0x00;
728: format |= (sc->sc_encoding==AUDIO_ENCODING_ALAW)?0x08:0x00;
729: }
730:
731: format |= (sc->sc_precision==16)?0x02:0x00;
732: format |= (sc->sc_chans==2)?1:0;
733: samp |= bus_space_read_2(iot, ioh, ARIADSP_STATUS) & ~0x60;
734:
735: aria_sendcmd(sc, ARIADSPC_FORMAT, format, -1, -1);
736: bus_space_write_2(iot, ioh, ARIADSP_CONTROL, samp);
737:
738: if (sc->sc_hardware&ARIA_MIXER) {
739: for (i = 0; i < 6; i++)
740: aria_set_mixer(sc, i);
741:
742: if (sc->sc_chans==2) {
743: aria_sendcmd(sc, ARIADSPC_CHAN_VOL, ARIAR_PLAY_CHAN,
744: ((sc->sc_gain[0]+sc->sc_gain[1])/2)<<7,
745: -1);
746: aria_sendcmd(sc, ARIADSPC_CHAN_PAN, ARIAR_PLAY_CHAN,
747: (sc->sc_gain[0]-sc->sc_gain[1])/4+0x40,
748: -1);
749: } else {
750: aria_sendcmd(sc, ARIADSPC_CHAN_VOL, ARIAR_PLAY_CHAN,
751: sc->sc_gain[0]<<7, -1);
752: aria_sendcmd(sc, ARIADSPC_CHAN_PAN, ARIAR_PLAY_CHAN,
753: 0x40, -1);
754: }
755:
756: aria_sendcmd(sc, ARIADSPC_MASMONMODE,
757: sc->ariamix_master.num_channels != 2, -1, -1);
758:
759: aria_sendcmd(sc, ARIADSPC_MIXERVOL, 0x0004,
760: sc->ariamix_master.level[0] << 7,
761: sc->ariamix_master.level[1] << 7);
762:
763: /* Convert treble/bass from byte to soundcard style */
764:
765: left = (tones[(sc->ariamix_master.treble[0]>>4)&0x0f]<<8) |
766: tones[(sc->ariamix_master.bass[0]>>4)&0x0f];
767: right = (tones[(sc->ariamix_master.treble[1]>>4)&0x0f]<<8) |
768: tones[(sc->ariamix_master.bass[1]>>4)&0x0f];
769:
770: aria_sendcmd(sc, ARIADSPC_TONE, left, right, -1);
771: }
772:
773: aria_sendcmd(sc, ARIADSPC_BLOCKSIZE, sc->sc_blocksize/2, -1, -1);
774:
775: /*
776: * If we think that the card is recording or playing, start it up again here.
777: * Some of the previous commands turn the channels off.
778: */
779:
780: if (sc->sc_record&(1<<ARIAR_RECORD_CHAN))
781: aria_sendcmd(sc, ARIADSPC_START_REC, ARIAR_RECORD_CHAN, -1,-1);
782:
783: if (sc->sc_play&(1<<ARIAR_PLAY_CHAN))
784: aria_sendcmd(sc, ARIADSPC_START_PLAY, ARIAR_PLAY_CHAN, -1, -1);
785:
786: return(0);
787: }
788:
789: void
790: aria_set_mixer(sc, i)
791: struct aria_softc *sc;
792: int i;
793: {
794: u_char source;
795: switch(i) {
796: case ARIAMIX_MIC_LVL: source = 0x0001; break;
797: case ARIAMIX_CD_LVL: source = 0x0002; break;
798: case ARIAMIX_LINE_IN_LVL: source = 0x0008; break;
799: case ARIAMIX_TEL_LVL: source = 0x0020; break;
800: case ARIAMIX_AUX_LVL: source = 0x0010; break;
801: case ARIAMIX_DAC_LVL: source = 0x0004; break;
802: default: source = 0x0000; break;
803: }
804:
805: if (source != 0x0000 && source != 0x0004) {
806: if (sc->aria_mix[i].mute == 1)
807: aria_sendcmd(sc, ARIADSPC_INPMONMODE, source, 3, -1);
808: else
809: aria_sendcmd(sc, ARIADSPC_INPMONMODE, source,
810: sc->aria_mix[i].num_channels != 2, -1);
811:
812: aria_sendcmd(sc, ARIADSPC_INPMONMODE, 0x8000|source,
813: sc->aria_mix[i].num_channels != 2, -1);
814: aria_sendcmd(sc, ARIADSPC_MIXERVOL, source,
815: sc->aria_mix[i].level[0] << 7,
816: sc->aria_mix[i].level[1] << 7);
817: }
818:
819: if (sc->aria_mix_source == i) {
820: aria_sendcmd(sc, ARIADSPC_ADCSOURCE, source, -1, -1);
821:
822: if (sc->sc_open & ARIAR_OPEN_RECORD)
823: aria_sendcmd(sc, ARIADSPC_ADCCONTROL, 1, -1, -1);
824: else
825: aria_sendcmd(sc, ARIADSPC_ADCCONTROL, 0, -1, -1);
826: }
827: }
828:
829: void
830: ariaclose(addr)
831: void *addr;
832: {
833: struct aria_softc *sc = addr;
834:
835: DPRINTF(("aria_close sc=0x%x\n", (unsigned) sc));
836:
837: sc->sc_open = 0;
838:
839: if (aria_reset(sc) != 0) {
840: delay(500);
841: aria_reset(sc);
842: }
843: }
844:
845: /*
846: * Reset the hardware.
847: */
848:
849: int ariareset(iot, ioh)
850: bus_space_tag_t iot;
851: bus_space_handle_t ioh;
852: {
853: struct aria_softc tmp, *sc = &tmp;
854:
855: sc->sc_iot = iot;
856: sc->sc_ioh = ioh;
857: return aria_reset(sc);
858: }
859:
860: int
861: aria_reset(sc)
862: struct aria_softc *sc;
863: {
864: bus_space_tag_t iot = sc->sc_iot;
865: bus_space_handle_t ioh = sc->sc_ioh;
866: int fail=0;
867: int i;
868:
869: bus_space_write_2(iot, ioh, ARIADSP_CONTROL,
870: ARIAR_ARIA_SYNTH | ARIAR_SR22K|ARIAR_DSPINTWR);
871: aria_putdspmem(sc, 0x6102, 0);
872:
873: fail |= aria_sendcmd(sc, ARIADSPC_SYSINIT, 0x0000, 0x0000, 0x0000);
874:
875: for (i=0; i < ARIAR_NPOLL; i++)
876: if (aria_getdspmem(sc, ARIAA_TASK_A) == 1)
877: break;
878:
879: bus_space_write_2(iot, ioh, ARIADSP_CONTROL,
880: ARIAR_ARIA_SYNTH|ARIAR_SR22K | ARIAR_DSPINTWR |
881: ARIAR_PCINTWR);
882: fail |= aria_sendcmd(sc, ARIADSPC_MODE, ARIAV_MODE_NO_SYNTH,-1,-1);
883:
884: return (fail);
885: }
886:
887: /*
888: * Lower-level routines
889: */
890:
891: void
892: aria_putdspmem(sc, loc, val)
893: struct aria_softc *sc;
894: u_short loc;
895: u_short val;
896: {
897: bus_space_tag_t iot = sc->sc_iot;
898: bus_space_handle_t ioh = sc->sc_ioh;
899: bus_space_write_2(iot, ioh, ARIADSP_DMAADDRESS, loc);
900: bus_space_write_2(iot, ioh, ARIADSP_DMADATA, val);
901: }
902:
903: u_short
904: aria_getdspmem(sc, loc)
905: struct aria_softc *sc;
906: u_short loc;
907: {
908: bus_space_tag_t iot = sc->sc_iot;
909: bus_space_handle_t ioh = sc->sc_ioh;
910: bus_space_write_2(iot, ioh, ARIADSP_DMAADDRESS, loc);
911: return bus_space_read_2(iot, ioh, ARIADSP_DMADATA);
912: }
913:
914: /*
915: * aria_sendcmd()
916: * each full DSP command is unified into this
917: * function.
918: */
919:
920: #define ARIASEND(data, flag) \
921: for (i = ARIAR_NPOLL; \
922: (bus_space_read_2(iot, ioh, ARIADSP_STATUS) & ARIAR_BUSY) && i>0; \
923: i--) \
924: ; \
925: if (bus_space_read_2(iot, ioh, ARIADSP_STATUS) & ARIAR_BUSY) \
926: fail |= flag; \
927: bus_space_write_2(iot, ioh, ARIADSP_WRITE, (u_short)data)
928:
929: int
930: aria_sendcmd(sc, command, arg1, arg2, arg3)
931: struct aria_softc *sc;
932: u_short command;
933: int arg1;
934: int arg2;
935: int arg3;
936: {
937: bus_space_tag_t iot = sc->sc_iot;
938: bus_space_handle_t ioh = sc->sc_ioh;
939: int i, fail = 0;
940:
941: ARIASEND(command, 1);
942: if (arg1 != -1) {
943: ARIASEND(arg1, 2);
944: }
945: if (arg2 != -1) {
946: ARIASEND(arg2, 4);
947: }
948: if (arg3 != -1) {
949: ARIASEND(arg3, 8);
950: }
951: ARIASEND(ARIADSPC_TERM, 16);
952:
953: if (fail) {
954: sc->sc_sendcmd_err++;
955: #ifdef AUDIO_DEBUG
956: DPRINTF(("aria_sendcmd: failure=(%d) cmd=(0x%x) fail=(0x%x)\n",
957: sc->sc_sendcmd_err, command, fail));
958: #endif
959: return -1;
960: }
961:
962: return 0;
963: }
964: #undef ARIASEND
965:
966: int
967: aria_halt_input(addr)
968: void *addr;
969: {
970: struct aria_softc *sc = addr;
971:
972: DPRINTF(("aria_halt_input\n"));
973:
974: if (sc->sc_record & (1<<0)) {
975: aria_sendcmd(sc, ARIADSPC_STOP_REC, 0, -1, -1);
976: sc->sc_record &= ~(1<<0);
1.20 mycroft 977: sc->sc_rdiobuffer = 0;
1.1 augustss 978: }
979:
980: return(0);
981: }
982:
983: int
984: aria_halt_output(addr)
985: void *addr;
986: {
987: struct aria_softc *sc = addr;
988:
989: DPRINTF(("aria_halt_output\n"));
990:
991: if (sc->sc_play & (1<<1)) {
992: aria_sendcmd(sc, ARIADSPC_STOP_PLAY, 1, -1, -1);
993: sc->sc_play &= ~(1<<1);
1.20 mycroft 994: sc->sc_pdiobuffer = 0;
1.1 augustss 995: }
996:
997: return(0);
998: }
999:
1000: /*
1001: * Here we just set up the buffers. If we receive
1002: * an interrupt without these set, it is ignored.
1003: */
1004:
1005: int
1006: aria_start_input(addr, p, cc, intr, arg)
1007: void *addr;
1008: void *p;
1009: int cc;
1010: void (*intr) __P((void *));
1011: void *arg;
1012: {
1013: struct aria_softc *sc = addr;
1014:
1015: DPRINTF(("aria_start_input %d @ %x\n", cc, (unsigned) p));
1016:
1017: if (cc != sc->sc_blocksize) {
1018: DPRINTF(("aria_start_input reqsize %d not sc_blocksize %d\n",
1019: cc, sc->sc_blocksize));
1020: return EINVAL;
1021: }
1022:
1023: sc->sc_rarg = arg;
1024: sc->sc_rintr = intr;
1025: sc->sc_rdiobuffer = p;
1026:
1027: if (!(sc->sc_record&(1<<ARIAR_RECORD_CHAN))) {
1028: aria_sendcmd(sc, ARIADSPC_START_REC, ARIAR_RECORD_CHAN, -1,-1);
1029: sc->sc_record |= (1<<ARIAR_RECORD_CHAN);
1030: }
1031:
1032: return 0;
1033: }
1034:
1035: int
1036: aria_start_output(addr, p, cc, intr, arg)
1037: void *addr;
1038: void *p;
1039: int cc;
1040: void (*intr) __P((void *));
1041: void *arg;
1042: {
1043: struct aria_softc *sc = addr;
1044:
1045: DPRINTF(("aria_start_output %d @ %x\n", cc, (unsigned) p));
1046:
1047: if (cc != sc->sc_blocksize) {
1048: DPRINTF(("aria_start_output reqsize %d not sc_blocksize %d\n",
1049: cc, sc->sc_blocksize));
1050: return EINVAL;
1051: }
1052:
1053: sc->sc_parg = arg;
1054: sc->sc_pintr = intr;
1055: sc->sc_pdiobuffer = p;
1056:
1057: if (!(sc->sc_play&(1<<ARIAR_PLAY_CHAN))) {
1058: aria_sendcmd(sc, ARIADSPC_START_PLAY, ARIAR_PLAY_CHAN, -1, -1);
1059: sc->sc_play |= (1<<ARIAR_PLAY_CHAN);
1060: }
1061:
1062: return 0;
1063: }
1064:
1065: /*
1066: * Process an interrupt. This should be a
1067: * request (from the card) to write or read
1068: * samples.
1069: */
1070: int
1071: aria_intr(arg)
1072: void *arg;
1073: {
1074: struct aria_softc *sc = arg;
1075: bus_space_tag_t iot = sc->sc_iot;
1076: bus_space_handle_t ioh = sc->sc_ioh;
1077: u_short *pdata = sc->sc_pdiobuffer;
1078: u_short *rdata = sc->sc_rdiobuffer;
1079: u_short address;
1080:
1081: #if 0 /* XXX -- BAD BAD BAD (That this is #define'd out */
1082: DPRINTF(("Checking to see if this is our intr\n"));
1083:
1084: if ((inw(iobase) & 1) != 0x1)
1085: return 0; /* not for us */
1086: #endif
1087:
1088: sc->sc_interrupts++;
1089:
1090: DPRINTF(("aria_intr\n"));
1091:
1092: if ((sc->sc_open & ARIAR_OPEN_PLAY) && (pdata!=NULL)) {
1093: DPRINTF(("aria_intr play=(%x)\n", (unsigned) pdata));
1094: address = 0x8000 - 2*(sc->sc_blocksize);
1095: address+= aria_getdspmem(sc, ARIAA_PLAY_FIFO_A);
1096: bus_space_write_2(iot, ioh, ARIADSP_DMAADDRESS, address);
1097: bus_space_write_multi_2(iot, ioh, ARIADSP_DMADATA, pdata,
1098: sc->sc_blocksize / 2);
1099: if (sc->sc_pintr != NULL)
1100: (*sc->sc_pintr)(sc->sc_parg);
1101: }
1102:
1103: if ((sc->sc_open & ARIAR_OPEN_RECORD) && (rdata!=NULL)) {
1104: DPRINTF(("aria_intr record=(%x)\n", (unsigned) rdata));
1105: address = 0x8000 - (sc->sc_blocksize);
1106: address+= aria_getdspmem(sc, ARIAA_REC_FIFO_A);
1107: bus_space_write_2(iot, ioh, ARIADSP_DMAADDRESS, address);
1108: bus_space_read_multi_2(iot, ioh, ARIADSP_DMADATA, rdata,
1109: sc->sc_blocksize / 2);
1110: if (sc->sc_rintr != NULL)
1111: (*sc->sc_rintr)(sc->sc_rarg);
1112: }
1113:
1114: aria_sendcmd(sc, ARIADSPC_TRANSCOMPLETE, -1, -1, -1);
1115:
1116: return 1;
1117: }
1118:
1119: int
1120: aria_mixer_set_port(addr, cp)
1121: void *addr;
1122: mixer_ctrl_t *cp;
1123: {
1124: struct aria_softc *sc = addr;
1125: int error = EINVAL;
1126:
1127: DPRINTF(("aria_mixer_set_port\n"));
1128:
1129: /* This could be done better, no mixer still has some controls. */
1130: if (!(ARIA_MIXER & sc->sc_hardware))
1131: return ENXIO;
1132:
1133: if (cp->type == AUDIO_MIXER_VALUE) {
1134: mixer_level_t *mv = &cp->un.value;
1135: switch (cp->dev) {
1136: case ARIAMIX_MIC_LVL:
1137: if (mv->num_channels == 1 || mv->num_channels == 2) {
1138: sc->aria_mix[ARIAMIX_MIC_LVL].num_channels =
1139: mv->num_channels;
1140: sc->aria_mix[ARIAMIX_MIC_LVL].level[0] =
1141: mv->level[0];
1142: sc->aria_mix[ARIAMIX_MIC_LVL].level[1] =
1143: mv->level[1];
1144: error = 0;
1145: }
1146: break;
1147:
1148: case ARIAMIX_LINE_IN_LVL:
1149: if (mv->num_channels == 1 || mv->num_channels == 2) {
1150: sc->aria_mix[ARIAMIX_LINE_IN_LVL].num_channels=
1151: mv->num_channels;
1152: sc->aria_mix[ARIAMIX_LINE_IN_LVL].level[0] =
1153: mv->level[0];
1154: sc->aria_mix[ARIAMIX_LINE_IN_LVL].level[1] =
1155: mv->level[1];
1156: error = 0;
1157: }
1158: break;
1159:
1160: case ARIAMIX_CD_LVL:
1161: if (mv->num_channels == 1 || mv->num_channels == 2) {
1162: sc->aria_mix[ARIAMIX_CD_LVL].num_channels =
1163: mv->num_channels;
1164: sc->aria_mix[ARIAMIX_CD_LVL].level[0] =
1165: mv->level[0];
1166: sc->aria_mix[ARIAMIX_CD_LVL].level[1] =
1167: mv->level[1];
1168: error = 0;
1169: }
1170: break;
1171:
1172: case ARIAMIX_TEL_LVL:
1173: if (mv->num_channels == 1) {
1174: sc->aria_mix[ARIAMIX_TEL_LVL].num_channels =
1175: mv->num_channels;
1176: sc->aria_mix[ARIAMIX_TEL_LVL].level[0] =
1177: mv->level[0];
1178: error = 0;
1179: }
1180: break;
1181:
1182: case ARIAMIX_DAC_LVL:
1183: if (mv->num_channels == 1 || mv->num_channels == 2) {
1184: sc->aria_mix[ARIAMIX_DAC_LVL].num_channels =
1185: mv->num_channels;
1186: sc->aria_mix[ARIAMIX_DAC_LVL].level[0] =
1187: mv->level[0];
1188: sc->aria_mix[ARIAMIX_DAC_LVL].level[1] =
1189: mv->level[1];
1190: error = 0;
1191: }
1192: break;
1193:
1194: case ARIAMIX_AUX_LVL:
1195: if (mv->num_channels == 1 || mv->num_channels == 2) {
1196: sc->aria_mix[ARIAMIX_AUX_LVL].num_channels =
1197: mv->num_channels;
1198: sc->aria_mix[ARIAMIX_AUX_LVL].level[0] =
1199: mv->level[0];
1200: sc->aria_mix[ARIAMIX_AUX_LVL].level[1] =
1201: mv->level[1];
1202: error = 0;
1203: }
1204: break;
1205:
1206: case ARIAMIX_MASTER_LVL:
1207: if (mv->num_channels == 1 || mv->num_channels == 2) {
1208: sc->ariamix_master.num_channels =
1209: mv->num_channels;
1210: sc->ariamix_master.level[0] = mv->level[0];
1211: sc->ariamix_master.level[1] = mv->level[1];
1212: error = 0;
1213: }
1214: break;
1215:
1216: case ARIAMIX_MASTER_TREBLE:
1217: if (mv->num_channels == 2) {
1218: sc->ariamix_master.treble[0] =
1219: mv->level[0] == 0 ? 1 : mv->level[0];
1220: sc->ariamix_master.treble[1] =
1221: mv->level[1] == 0 ? 1 : mv->level[1];
1222: error = 0;
1223: }
1224: break;
1225: case ARIAMIX_MASTER_BASS:
1226: if (mv->num_channels == 2) {
1227: sc->ariamix_master.bass[0] =
1228: mv->level[0] == 0 ? 1 : mv->level[0];
1229: sc->ariamix_master.bass[1] =
1230: mv->level[1] == 0 ? 1 : mv->level[1];
1231: error = 0;
1232: }
1233: break;
1234: case ARIAMIX_OUT_LVL:
1235: if (mv->num_channels == 1 || mv->num_channels == 2) {
1236: sc->sc_gain[0] = mv->level[0];
1237: sc->sc_gain[1] = mv->level[1];
1238: error = 0;
1239: }
1240: break;
1241: default:
1242: }
1243: }
1244:
1245: if (cp->type == AUDIO_MIXER_ENUM)
1246: switch(cp->dev) {
1247: case ARIAMIX_RECORD_SOURCE:
1248: if (cp->un.ord>=0 && cp->un.ord<=6) {
1249: sc->aria_mix_source = cp->un.ord;
1250: error = 0;
1251: }
1252: break;
1253:
1254: case ARIAMIX_MIC_MUTE:
1255: if (cp->un.ord == 0 || cp->un.ord == 1) {
1256: sc->aria_mix[ARIAMIX_MIC_LVL].mute =cp->un.ord;
1257: error = 0;
1258: }
1259: break;
1260:
1261: case ARIAMIX_LINE_IN_MUTE:
1262: if (cp->un.ord == 0 || cp->un.ord == 1) {
1263: sc->aria_mix[ARIAMIX_LINE_IN_LVL].mute =
1264: cp->un.ord;
1265: error = 0;
1266: }
1267: break;
1268:
1269: case ARIAMIX_CD_MUTE:
1270: if (cp->un.ord == 0 || cp->un.ord == 1) {
1271: sc->aria_mix[ARIAMIX_CD_LVL].mute = cp->un.ord;
1272: error = 0;
1273: }
1274: break;
1275:
1276: case ARIAMIX_DAC_MUTE:
1277: if (cp->un.ord == 0 || cp->un.ord == 1) {
1278: sc->aria_mix[ARIAMIX_DAC_LVL].mute =cp->un.ord;
1279: error = 0;
1280: }
1281: break;
1282:
1283: case ARIAMIX_AUX_MUTE:
1284: if (cp->un.ord == 0 || cp->un.ord == 1) {
1285: sc->aria_mix[ARIAMIX_AUX_LVL].mute =cp->un.ord;
1286: error = 0;
1287: }
1288: break;
1289:
1290: case ARIAMIX_TEL_MUTE:
1291: if (cp->un.ord == 0 || cp->un.ord == 1) {
1292: sc->aria_mix[ARIAMIX_TEL_LVL].mute =cp->un.ord;
1293: error = 0;
1294: }
1295: break;
1296:
1297: default:
1298: /* NOTREACHED */
1299: return ENXIO;
1300: }
1301:
1302: return(error);
1303: }
1304:
1305: int
1306: aria_mixer_get_port(addr, cp)
1307: void *addr;
1308: mixer_ctrl_t *cp;
1309: {
1310: struct aria_softc *sc = addr;
1311: int error = EINVAL;
1312:
1313: DPRINTF(("aria_mixer_get_port\n"));
1314:
1315: /* This could be done better, no mixer still has some controls. */
1316: if (!(ARIA_MIXER&sc->sc_hardware))
1317: return ENXIO;
1318:
1319: switch (cp->dev) {
1320: case ARIAMIX_MIC_LVL:
1321: if (cp->type == AUDIO_MIXER_VALUE) {
1322: cp->un.value.num_channels =
1323: sc->aria_mix[ARIAMIX_MIC_LVL].num_channels;
1324: cp->un.value.level[0] =
1325: sc->aria_mix[ARIAMIX_MIC_LVL].level[0];
1326: cp->un.value.level[1] =
1327: sc->aria_mix[ARIAMIX_MIC_LVL].level[1];
1328: error = 0;
1329: }
1330: break;
1331:
1332: case ARIAMIX_LINE_IN_LVL:
1333: if (cp->type == AUDIO_MIXER_VALUE) {
1334: cp->un.value.num_channels =
1335: sc->aria_mix[ARIAMIX_LINE_IN_LVL].num_channels;
1336: cp->un.value.level[0] =
1337: sc->aria_mix[ARIAMIX_LINE_IN_LVL].level[0];
1338: cp->un.value.level[1] =
1339: sc->aria_mix[ARIAMIX_LINE_IN_LVL].level[1];
1340: error = 0;
1341: }
1342: break;
1343:
1344: case ARIAMIX_CD_LVL:
1345: if (cp->type == AUDIO_MIXER_VALUE) {
1346: cp->un.value.num_channels =
1347: sc->aria_mix[ARIAMIX_CD_LVL].num_channels;
1348: cp->un.value.level[0] =
1349: sc->aria_mix[ARIAMIX_CD_LVL].level[0];
1350: cp->un.value.level[1] =
1351: sc->aria_mix[ARIAMIX_CD_LVL].level[1];
1352: error = 0;
1353: }
1354: break;
1355:
1356: case ARIAMIX_TEL_LVL:
1357: if (cp->type == AUDIO_MIXER_VALUE) {
1358: cp->un.value.num_channels =
1359: sc->aria_mix[ARIAMIX_TEL_LVL].num_channels;
1360: cp->un.value.level[0] =
1361: sc->aria_mix[ARIAMIX_TEL_LVL].level[0];
1362: error = 0;
1363: }
1364: break;
1365: case ARIAMIX_DAC_LVL:
1366: if (cp->type == AUDIO_MIXER_VALUE) {
1367: cp->un.value.num_channels =
1368: sc->aria_mix[ARIAMIX_DAC_LVL].num_channels;
1369: cp->un.value.level[0] =
1370: sc->aria_mix[ARIAMIX_DAC_LVL].level[0];
1371: cp->un.value.level[1] =
1372: sc->aria_mix[ARIAMIX_DAC_LVL].level[1];
1373: error = 0;
1374: }
1375: break;
1376:
1377: case ARIAMIX_AUX_LVL:
1378: if (cp->type == AUDIO_MIXER_VALUE) {
1379: cp->un.value.num_channels =
1380: sc->aria_mix[ARIAMIX_AUX_LVL].num_channels;
1381: cp->un.value.level[0] =
1382: sc->aria_mix[ARIAMIX_AUX_LVL].level[0];
1383: cp->un.value.level[1] =
1384: sc->aria_mix[ARIAMIX_AUX_LVL].level[1];
1385: error = 0;
1386: }
1387: break;
1388:
1389: case ARIAMIX_MIC_MUTE:
1390: if (cp->type == AUDIO_MIXER_ENUM) {
1391: cp->un.ord = sc->aria_mix[ARIAMIX_MIC_LVL].mute;
1392: error = 0;
1393: }
1394: break;
1395:
1396: case ARIAMIX_LINE_IN_MUTE:
1397: if (cp->type == AUDIO_MIXER_ENUM) {
1398: cp->un.ord = sc->aria_mix[ARIAMIX_LINE_IN_LVL].mute;
1399: error = 0;
1400: }
1401: break;
1402:
1403: case ARIAMIX_CD_MUTE:
1404: if (cp->type == AUDIO_MIXER_ENUM) {
1405: cp->un.ord = sc->aria_mix[ARIAMIX_CD_LVL].mute;
1406: error = 0;
1407: }
1408: break;
1409:
1410: case ARIAMIX_DAC_MUTE:
1411: if (cp->type == AUDIO_MIXER_ENUM) {
1412: cp->un.ord = sc->aria_mix[ARIAMIX_DAC_LVL].mute;
1413: error = 0;
1414: }
1415: break;
1416:
1417: case ARIAMIX_AUX_MUTE:
1418: if (cp->type == AUDIO_MIXER_ENUM) {
1419: cp->un.ord = sc->aria_mix[ARIAMIX_AUX_LVL].mute;
1420: error = 0;
1421: }
1422: break;
1423:
1424: case ARIAMIX_TEL_MUTE:
1425: if (cp->type == AUDIO_MIXER_ENUM) {
1426: cp->un.ord = sc->aria_mix[ARIAMIX_TEL_LVL].mute;
1427: error = 0;
1428: }
1429: break;
1430:
1431: case ARIAMIX_MASTER_LVL:
1432: if (cp->type == AUDIO_MIXER_VALUE) {
1433: cp->un.value.num_channels =
1434: sc->ariamix_master.num_channels;
1435: cp->un.value.level[0] = sc->ariamix_master.level[0];
1436: cp->un.value.level[1] = sc->ariamix_master.level[1];
1437: error = 0;
1438: }
1439: break;
1440:
1441: case ARIAMIX_MASTER_TREBLE:
1442: if (cp->type == AUDIO_MIXER_VALUE) {
1443: cp->un.value.num_channels = 2;
1444: cp->un.value.level[0] = sc->ariamix_master.treble[0];
1445: cp->un.value.level[1] = sc->ariamix_master.treble[1];
1446: error = 0;
1447: }
1448: break;
1449:
1450: case ARIAMIX_MASTER_BASS:
1451: if (cp->type == AUDIO_MIXER_VALUE) {
1452: cp->un.value.num_channels = 2;
1453: cp->un.value.level[0] = sc->ariamix_master.bass[0];
1454: cp->un.value.level[1] = sc->ariamix_master.bass[1];
1455: error = 0;
1456: }
1457: break;
1458:
1459: case ARIAMIX_OUT_LVL:
1460: if (cp->type == AUDIO_MIXER_VALUE) {
1461: cp->un.value.num_channels = sc->sc_chans;
1462: cp->un.value.level[0] = sc->sc_gain[0];
1463: cp->un.value.level[1] = sc->sc_gain[1];
1464: error = 0;
1465: }
1466: break;
1467: case ARIAMIX_RECORD_SOURCE:
1468: if (cp->type == AUDIO_MIXER_ENUM) {
1469: cp->un.ord = sc->aria_mix_source;
1470: error = 0;
1471: }
1472: break;
1473:
1474: default:
1475: return ENXIO;
1476: /* NOT REACHED */
1477: }
1478:
1479: return(error);
1480: }
1481:
1482: int
1483: aria_mixer_query_devinfo(addr, dip)
1484: void *addr;
1485: mixer_devinfo_t *dip;
1486: {
1487:
1488: struct aria_softc *sc = addr;
1489:
1490: DPRINTF(("aria_mixer_query_devinfo\n"));
1491:
1492: /* This could be done better, no mixer still has some controls. */
1493: if (!(ARIA_MIXER & sc->sc_hardware))
1494: return ENXIO;
1495:
1496: dip->prev = dip->next = AUDIO_MIXER_LAST;
1497:
1498: switch(dip->index) {
1499: case ARIAMIX_MIC_LVL:
1500: dip->type = AUDIO_MIXER_VALUE;
1501: dip->mixer_class = ARIAMIX_INPUT_CLASS;
1502: dip->next = ARIAMIX_MIC_MUTE;
1503: strcpy(dip->label.name, AudioNmicrophone);
1504: dip->un.v.num_channels = 2;
1505: strcpy(dip->un.v.units.name, AudioNvolume);
1506: break;
1507:
1508: case ARIAMIX_LINE_IN_LVL:
1509: dip->type = AUDIO_MIXER_VALUE;
1510: dip->mixer_class = ARIAMIX_INPUT_CLASS;
1511: dip->next = ARIAMIX_LINE_IN_MUTE;
1512: strcpy(dip->label.name, AudioNline);
1513: dip->un.v.num_channels = 2;
1514: strcpy(dip->un.v.units.name, AudioNvolume);
1515: break;
1516:
1517: case ARIAMIX_CD_LVL:
1518: dip->type = AUDIO_MIXER_VALUE;
1519: dip->mixer_class = ARIAMIX_INPUT_CLASS;
1520: dip->next = ARIAMIX_CD_MUTE;
1521: strcpy(dip->label.name, AudioNcd);
1522: dip->un.v.num_channels = 2;
1523: strcpy(dip->un.v.units.name, AudioNvolume);
1524: break;
1525:
1526: case ARIAMIX_TEL_LVL:
1527: dip->type = AUDIO_MIXER_VALUE;
1528: dip->mixer_class = ARIAMIX_INPUT_CLASS;
1529: dip->next = ARIAMIX_TEL_MUTE;
1530: strcpy(dip->label.name, "telephone");
1531: dip->un.v.num_channels = 1;
1532: strcpy(dip->un.v.units.name, AudioNvolume);
1533: break;
1534:
1535: case ARIAMIX_DAC_LVL:
1536: dip->type = AUDIO_MIXER_VALUE;
1537: dip->mixer_class = ARIAMIX_INPUT_CLASS;
1538: dip->next = ARIAMIX_DAC_MUTE;
1539: strcpy(dip->label.name, AudioNdac);
1540: dip->un.v.num_channels = 1;
1541: strcpy(dip->un.v.units.name, AudioNvolume);
1542: break;
1543:
1544: case ARIAMIX_AUX_LVL:
1545: dip->type = AUDIO_MIXER_VALUE;
1546: dip->mixer_class = ARIAMIX_INPUT_CLASS;
1547: dip->next = ARIAMIX_AUX_MUTE;
1548: strcpy(dip->label.name, AudioNoutput);
1549: dip->un.v.num_channels = 1;
1550: strcpy(dip->un.v.units.name, AudioNvolume);
1551: break;
1552:
1553: case ARIAMIX_MIC_MUTE:
1554: dip->prev = ARIAMIX_MIC_LVL;
1555: goto mute;
1556:
1557: case ARIAMIX_LINE_IN_MUTE:
1558: dip->prev = ARIAMIX_LINE_IN_LVL;
1559: goto mute;
1560:
1561: case ARIAMIX_CD_MUTE:
1562: dip->prev = ARIAMIX_CD_LVL;
1563: goto mute;
1564:
1565: case ARIAMIX_DAC_MUTE:
1566: dip->prev = ARIAMIX_DAC_LVL;
1567: goto mute;
1568:
1569: case ARIAMIX_AUX_MUTE:
1570: dip->prev = ARIAMIX_AUX_LVL;
1571: goto mute;
1572:
1573: case ARIAMIX_TEL_MUTE:
1574: dip->prev = ARIAMIX_TEL_LVL;
1575: goto mute;
1576:
1577: mute:
1578: dip->mixer_class = ARIAMIX_INPUT_CLASS;
1579: dip->type = AUDIO_MIXER_ENUM;
1580: strcpy(dip->label.name, AudioNmute);
1581: dip->un.e.num_mem = 2;
1582: strcpy(dip->un.e.member[0].label.name, AudioNoff);
1583: dip->un.e.member[0].ord = 0;
1584: strcpy(dip->un.e.member[1].label.name, AudioNon);
1585: dip->un.e.member[1].ord = 1;
1586: break;
1587:
1588: case ARIAMIX_MASTER_LVL:
1589: dip->type = AUDIO_MIXER_VALUE;
1590: dip->mixer_class = ARIAMIX_OUTPUT_CLASS;
1591: dip->next = AUDIO_MIXER_LAST;
1592: strcpy(dip->label.name, AudioNvolume);
1593: dip->un.v.num_channels = 2;
1594: strcpy(dip->un.v.units.name, AudioNvolume);
1595: break;
1596:
1597: case ARIAMIX_MASTER_TREBLE:
1598: dip->type = AUDIO_MIXER_VALUE;
1599: dip->mixer_class = ARIAMIX_EQ_CLASS;
1600: strcpy(dip->label.name, AudioNtreble);
1601: dip->un.v.num_channels = 2;
1602: strcpy(dip->un.v.units.name, AudioNtreble);
1603: break;
1604:
1605: case ARIAMIX_MASTER_BASS:
1606: dip->type = AUDIO_MIXER_VALUE;
1607: dip->mixer_class = ARIAMIX_EQ_CLASS;
1608: strcpy(dip->label.name, AudioNbass);
1609: dip->un.v.num_channels = 2;
1610: strcpy(dip->un.v.units.name, AudioNbass);
1611: break;
1612:
1613: case ARIAMIX_OUT_LVL:
1614: dip->type = AUDIO_MIXER_VALUE;
1615: dip->mixer_class = ARIAMIX_OUTPUT_CLASS;
1616: strcpy(dip->label.name, AudioNoutput);
1617: dip->un.v.num_channels = 2;
1618: strcpy(dip->un.v.units.name, AudioNvolume);
1619: break;
1620:
1621: case ARIAMIX_RECORD_SOURCE:
1622: dip->mixer_class = ARIAMIX_RECORD_CLASS;
1623: dip->type = AUDIO_MIXER_ENUM;
1624: strcpy(dip->label.name, AudioNsource);
1625: dip->un.e.num_mem = 6;
1626: strcpy(dip->un.e.member[0].label.name, AudioNoutput);
1627: dip->un.e.member[0].ord = ARIAMIX_AUX_LVL;
1628: strcpy(dip->un.e.member[1].label.name, AudioNmicrophone);
1629: dip->un.e.member[1].ord = ARIAMIX_MIC_LVL;
1630: strcpy(dip->un.e.member[2].label.name, AudioNdac);
1631: dip->un.e.member[2].ord = ARIAMIX_DAC_LVL;
1632: strcpy(dip->un.e.member[3].label.name, AudioNline);
1633: dip->un.e.member[3].ord = ARIAMIX_LINE_IN_LVL;
1634: strcpy(dip->un.e.member[4].label.name, AudioNcd);
1635: dip->un.e.member[4].ord = ARIAMIX_CD_LVL;
1636: strcpy(dip->un.e.member[5].label.name, "telephone");
1637: dip->un.e.member[5].ord = ARIAMIX_TEL_LVL;
1638: break;
1639:
1640: case ARIAMIX_INPUT_CLASS:
1641: dip->type = AUDIO_MIXER_CLASS;
1642: dip->mixer_class = ARIAMIX_INPUT_CLASS;
1643: strcpy(dip->label.name, AudioCinputs);
1644: break;
1645:
1646: case ARIAMIX_OUTPUT_CLASS:
1647: dip->type = AUDIO_MIXER_CLASS;
1648: dip->mixer_class = ARIAMIX_OUTPUT_CLASS;
1649: strcpy(dip->label.name, AudioCoutputs);
1650: break;
1651:
1652: case ARIAMIX_RECORD_CLASS:
1653: dip->type = AUDIO_MIXER_CLASS;
1654: dip->mixer_class = ARIAMIX_RECORD_CLASS;
1655: strcpy(dip->label.name, AudioCrecord);
1656: break;
1657:
1658: case ARIAMIX_EQ_CLASS:
1659: dip->type = AUDIO_MIXER_CLASS;
1660: dip->mixer_class = ARIAMIX_EQ_CLASS;
1661: strcpy(dip->label.name, AudioCequalization);
1662: break;
1663:
1664: default:
1665: return ENXIO;
1666: /*NOTREACHED*/
1667: }
1668: return 0;
1669: }
CVSweb <webmaster@jp.NetBSD.org>