1 /* $NetBSD: interwave.c,v 1.33 2008/04/28 20:23:50 martin Exp $ */
4 * Copyright (c) 1997, 1999 The NetBSD Foundation, Inc.
7 * Author: Kari Mettinen
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
18 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
19 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
22 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 * POSSIBILITY OF SUCH DAMAGE.
31 #include <sys/cdefs.h>
32 __KERNEL_RCSID(0, "$NetBSD: interwave.c,v 1.33 2008/04/28 20:23:50 martin Exp $");
34 #include <sys/param.h>
35 #include <sys/systm.h>
36 #include <sys/errno.h>
37 #include <sys/ioctl.h>
38 #include <sys/syslog.h>
39 #include <sys/device.h>
42 #include <sys/fcntl.h>
43 #include <sys/malloc.h>
44 #include <sys/kernel.h>
48 #include <machine/pio.h>
49 #include <sys/audioio.h>
50 #include <dev/audio_if.h>
51 #include <dev/mulaw.h>
53 #include <dev/isa/isavar.h>
54 #include <dev/isa/isadmavar.h>
56 #include <dev/ic/interwavereg.h>
57 #include <dev/ic/interwavevar.h>
60 static void iwreset(struct iw_softc
*, int);
62 static int iw_set_speed(struct iw_softc
*, u_long
, char);
63 static u_long
iw_set_format(struct iw_softc
*, u_long
, int);
64 static void iw_mixer_line_level(struct iw_softc
*, int, int, int);
65 static void iw_trigger_dma(struct iw_softc
*, u_char
);
66 static void iw_stop_dma(struct iw_softc
*, u_char
, u_char
);
67 static void iw_dma_count(struct iw_softc
*, u_short
, int);
68 static int iwintr(void *);
69 static void iw_meminit(struct iw_softc
*);
70 static void iw_mempoke(struct iw_softc
*, u_long
, u_char
);
71 static u_char
iw_mempeek(struct iw_softc
*, u_long
);
74 static void iw_set_voice_place(struct iw_softc
*, u_char
, u_long
);
75 static void iw_voice_pan(struct iw_softc
*, u_char
, u_short
, u_short
);
76 static void iw_voice_freq(struct iw_softc
*, u_char
, u_long
);
77 static void iw_set_loopmode(struct iw_softc
*, u_char
, u_char
, u_char
);
78 static void iw_set_voice_pos(struct iw_softc
*, u_short
, u_long
, u_long
);
79 static void iw_start_voice(struct iw_softc
*, u_char
);
80 static void iw_play_voice(struct iw_softc
*, u_long
, u_long
, u_short
);
81 static void iw_stop_voice(struct iw_softc
*, u_char
);
82 static void iw_move_voice_end(struct iw_softc
*, u_short
, u_long
);
83 static void iw_initvoices(struct iw_softc
*);
86 struct audio_device iw_device
= {
94 #define DPRINTF(p) if (iw_debug) printf p
101 static int outputs
= 0;
102 static int iw_ints
= 0;
103 static int inputs
= 0;
104 static int iw_inints
= 0;
117 IW_READ_DIRECT_1(6, sc
->p2xr_h
, intrs
); /* UISR */
122 * The proper order to do this seems to be to read CSR3 to get the
123 * int cause and fifo over underrrun status, then deal with the ints
124 * (new DMA set up), and to clear ints by writing the respective bit
128 /* read what ints happened */
130 IW_READ_CODEC_1(CSR3I
, intrs
);
134 IW_WRITE_DIRECT_1(2, sc
->codec_index_h
, 0x00);
136 /* and process them */
142 if (sc
->sc_recintr
!= 0)
143 sc
->sc_recintr(sc
->sc_recarg
);
150 if (sc
->sc_playintr
!= 0)
151 sc
->sc_playintr(sc
->sc_playarg
);
159 iwattach(struct iw_softc
*sc
)
163 DPRINTF(("iwattach sc %p\n", sc
));
166 sc
->cdatap
= 1; /* relative offsets in region */
168 sc
->cxdr
= 3; /* CPDR or CRDR */
170 sc
->gmxr
= 0; /* sc->p3xr */
171 sc
->gmxdr
= 1; /* GMTDR or GMRDR */
178 sc
->rec_precision
= sc
->play_precision
= 8;
179 sc
->rec_channels
= sc
->play_channels
= 1;
180 sc
->rec_encoding
= sc
->play_encoding
= AUDIO_ENCODING_ULAW
;
184 sc
->sc_fullduplex
= 1;
186 sc
->sc_dma_flags
= 0;
189 * We can only use a few selected irqs, see if we got one from pnp
190 * code that suits us.
193 if (sc
->sc_irq
> 0) {
194 sc
->sc_ih
= isa_intr_establish(sc
->sc_p2xr_ic
,
195 sc
->sc_irq
, IST_EDGE
, IPL_AUDIO
, iwintr
, sc
);
199 printf("\niwattach: couldn't get a suitable irq\n");
204 iw_set_format(sc
, AUDIO_ENCODING_ULAW
, 0);
205 iw_set_format(sc
, AUDIO_ENCODING_ULAW
, 1);
206 printf("%s: interwave version %s\n",
207 device_xname(&sc
->sc_dev
), iw_device
.version
);
208 audio_attach_mi(sc
->iw_hw_if
, sc
, &sc
->sc_dev
);
212 iwopen(struct iw_softc
*sc
, int flags
)
215 DPRINTF(("iwopen: sc %p\n", sc
));
233 DPRINTF(("iwclose sc %p\n", addr
));
235 DPRINTF(("iwclose: outputs %d ints %d inputs %d in_ints %d\n",
236 outputs
, iw_ints
, inputs
, iw_inints
));
240 #define RAM_STEP 64*1024
243 iw_mempoke(struct iw_softc
*sc
, u_long addy
, u_char val
)
246 IW_WRITE_GENERAL_2(LMALI
, (u_short
) addy
);
247 IW_WRITE_GENERAL_1(LMAHI
, (u_char
) (addy
>> 16));
249 /* Write byte to LMBDR */
250 IW_WRITE_DIRECT_1(sc
->p3xr
+ 7, sc
->p3xr_h
, val
);
254 iw_mempeek(struct iw_softc
*sc
, u_long addy
)
258 IW_WRITE_GENERAL_2(LMALI
, (u_short
) addy
);
259 IW_WRITE_GENERAL_1(LMAHI
, (u_char
) (addy
>> 16));
261 IW_READ_DIRECT_1(sc
->p3xr
+ 7, sc
->p3xr_h
, ret
);
262 return ret
; /* return byte from LMBDR */
266 iw_meminit(struct iw_softc
*sc
)
268 u_long bank
[4] = {0L, 0L, 0L, 0L};
269 u_long addr
, base
, cnt
;
270 u_char i
, ram
/* ,memval=0 */ ;
281 IW_WRITE_GENERAL_1(LDMACI
, 0x00);
283 IW_READ_GENERAL_2(LMCFI
, lmcfi
); /* 0x52 */
285 IW_WRITE_GENERAL_2(LMCFI
, lmcfi
); /* max addr span */
286 IW_WRITE_GENERAL_1(LMCI
, 0x00);
290 IW_WRITE_GENERAL_2(LMRFAI
, ((4 * 1024 * 1024) >> 8));
291 IW_WRITE_GENERAL_2(LMPFAI
, ((4 * 1024 * 1024 + 16 * 1024) >> 8));
293 IW_WRITE_GENERAL_2(LMFSI
, 0x000);
295 IW_WRITE_GENERAL_2(LDICI
, 0x0000);
297 while (addr
< (16 * 1024 * 1024)) {
298 iw_mempoke(sc
, addr
, 0x00);
302 printf("%s:", device_xname(&sc
->sc_dev
));
304 for (i
= 0; i
< 4; i
++) {
305 iw_mempoke(sc
, base
, 0xAA); /* mark start of bank */
306 iw_mempoke(sc
, base
+ 1L, 0x55);
307 if (iw_mempeek(sc
, base
) == 0xAA &&
308 iw_mempeek(sc
, base
+ 1L) == 0x55)
311 while (cnt
< (4 * 1024 * 1024)) {
315 if (iw_mempeek(sc
, addr
) == 0xAA)
319 if (lpbanks
!= NULL
) {
323 bank
[i
] = bank
[i
] >> 10;
324 printf("%s bank[%d]: %ldK", i
? "," : "", i
, bank
[i
]);
325 base
+= 4 * 1024 * 1024;
333 * this is not really useful since GUS PnP supports memory
334 * configurations that aren't really supported by Interwave...beware
335 * of holes! Also, we don't use the memory for anything in this
336 * version of the driver.
338 * we've configured for 4M-4M-4M-4M
343 iwreset(struct iw_softc
*sc
, int warm
)
345 u_char reg
, cmode
, val
, mixer_image
;
349 reg
= 0; /* XXX gcc -Wall */
351 cmode
= 0x6c; /* enhanced codec mode (full duplex) */
355 IW_WRITE_GENERAL_1(URSTI
, 0x00);
357 IW_WRITE_GENERAL_1(URSTI
, 0x07);
358 IW_WRITE_GENERAL_1(ICMPTI
, 0x1f); /* disable DSP and uici and
360 IW_WRITE_GENERAL_1(IDECI
, 0x7f); /* enable ints to ISA and
362 IW_READ_GENERAL_1(IVERI
, reg
);
363 IW_WRITE_GENERAL_1(IVERI
, reg
| 0x01); /* hidden reg lock disable */
364 IW_WRITE_GENERAL_1(UASBCI
, 0x00);
366 /* synth enhanced mode (default), 0 active voices, disable ints */
368 IW_WRITE_GENERAL_1(SGMI_WR
, 0x01); /* enhanced mode, LFOs
370 for (val
= 0; val
< 32; val
++) {
371 /* set each synth sound volume to 0 */
372 IW_WRITE_DIRECT_1(sc
->p3xr
+ 2, sc
->p3xr_h
, val
);
373 IW_WRITE_GENERAL_1(SVSI_WR
, 0x00);
374 IW_WRITE_GENERAL_2(SASLI_WR
, 0x0000);
375 IW_WRITE_GENERAL_2(SASHI_WR
, 0x0000);
376 IW_WRITE_GENERAL_2(SAELI_WR
, 0x0000);
377 IW_WRITE_GENERAL_2(SAEHI_WR
, 0x0000);
378 IW_WRITE_GENERAL_2(SFCI_WR
, 0x0000);
379 IW_WRITE_GENERAL_1(SACI_WR
, 0x02);
380 IW_WRITE_GENERAL_1(SVSI_WR
, 0x00);
381 IW_WRITE_GENERAL_1(SVEI_WR
, 0x00);
382 IW_WRITE_GENERAL_2(SVLI_WR
, 0x0000);
383 IW_WRITE_GENERAL_1(SVCI_WR
, 0x02);
384 IW_WRITE_GENERAL_1(SMSI_WR
, 0x02);
387 IW_WRITE_GENERAL_1(SAVI_WR
, 0x00);
389 /* codec mode/init */
391 /* first change mode to 1 */
393 IW_WRITE_CODEC_1(CMODEI
, 0x00);
397 IW_WRITE_CODEC_1(CMODEI
, cmode
);
399 IW_READ_CODEC_1(CMODEI
, reg
);
401 DPRINTF(("cmode %x\n", reg
));
403 sc
->revision
= ((reg
& 0x80) >> 3) | (reg
& 0x0f);
405 IW_WRITE_DIRECT_1(sc
->codec_index
+ 2, sc
->p2xr_h
, 0x00);
407 IW_WRITE_CODEC_1(CFIG1I
| IW_MCE
, 0x00); /* DMA 2 chan access */
408 IW_WRITE_CODEC_1(CEXTI
, 0x00); /* disable ints for now */
411 IW_WRITE_CODEC_1(CLPCTI
, 0x00); /* reset playback sample counters */
412 IW_WRITE_CODEC_1(CUPCTI
, 0x00); /* always upper byte last */
413 IW_WRITE_CODEC_1(CFIG2I
, 0x80); /* full voltage range, enable record
414 * and playback sample counters, and
415 * don't center output in case or
417 IW_WRITE_CODEC_1(CFIG3I
, 0xc0); /* enable record/playback irq (still
418 * turned off from CEXTI), max DMA
420 IW_WRITE_CODEC_1(CSR3I
, 0x00); /* clear status 3 reg */
423 IW_WRITE_CODEC_1(CLRCTI
, 0x00); /* reset record sample counters */
424 IW_WRITE_CODEC_1(CURCTI
, 0x00); /* always upper byte last */
427 IW_READ_GENERAL_1(IVERI
, reg
);
431 snprintf(iw_device
.version
, sizeof(iw_device
.version
), "%d.%d",
432 sc
->vers
, sc
->revision
);
434 IW_WRITE_GENERAL_1(IDECI
, 0x7f); /* irqs and codec decode
441 iw_mixer_line_level(sc
, IW_LINE_OUT
, 255, 255);
442 iw_mixer_line_level(sc
, IW_LINE_IN
, 0, 0);
443 iw_mixer_line_level(sc
, IW_AUX1
, 0, 0);
444 iw_mixer_line_level(sc
, IW_AUX2
, 200, 200); /* CD */
446 iw_mixer_line_level(sc
, IW_DAC
, 200, 200);
448 iw_mixer_line_level(sc
, IW_MIC_IN
, 0, 0);
449 iw_mixer_line_level(sc
, IW_REC
, 0, 0);
450 iw_mixer_line_level(sc
, IW_LOOPBACK
, 0, 0);
451 iw_mixer_line_level(sc
, IW_MONO_IN
, 0, 0);
457 IW_WRITE_CODEC_1(CEXTI
, 0x02); /* codec int enable */
461 IW_WRITE_GENERAL_1(LDMACI
, 0x00);
463 /* enable mixer paths */
465 IW_WRITE_DIRECT_1(sc
->p2xr
, sc
->p2xr_h
, mixer_image
);
467 * enable output, line in. disable mic in bit 0 = 0 -> line in on
468 * (from codec?) bit 1 = 0 -> output on bit 2 = 1 -> mic in on bit 3
469 * = 1 -> irq&drq pin enable bit 4 = 1 -> channel interrupts to chan
470 * 1 bit 5 = 1 -> enable midi loop back bit 6 = 0 -> irq latches
471 * URCR[2:0] bit 6 = 1 -> DMA latches URCR[2:0]
475 IW_READ_DIRECT_1(sc
->p2xr
, sc
->p2xr_h
, mixer_image
);
478 DPRINTF(("mix image %x \n", mixer_image
));
482 struct iw_codec_freq
{
488 iw_set_speed(struct iw_softc
*sc
, u_long freq
, char in
)
490 u_char var
, cfig3
, reg
;
492 static struct iw_codec_freq iw_cf
[17] = {
493 #define FREQ_1 24576000
494 #define FREQ_2 16934400
497 {5510, 0x00 | XTAL2
}, {6620, 0x0E | XTAL2
},
498 {8000, 0x00 | XTAL1
}, {9600, 0x0E | XTAL1
},
499 {11025, 0x02 | XTAL2
}, {16000, 0x02 | XTAL1
},
500 {18900, 0x04 | XTAL2
}, {22050, 0x06 | XTAL2
},
501 {27420, 0x04 | XTAL1
}, {32000, 0x06 | XTAL1
},
502 {33075, 0x0C | XTAL2
}, {37800, 0x08 | XTAL2
},
503 {38400, 0x0A | XTAL1
}, {44100, 0x0A | XTAL2
},
504 {44800, 0x08 | XTAL1
}, {48000, 0x0C | XTAL1
},
505 {48000, 0x0C | XTAL1
} /* really a dummy for indexing later */
510 cfig3
= 0; /* XXX gcc -Wall */
513 * if the frequency is between 3493 Hz and 32 kHz we can use a more
514 * accurate frequency than the ones listed above base on the formula
515 * FREQ/((16*(48+x))) where FREQ is either FREQ_1 (24576000Hz) or
516 * FREQ_2 (16934400Hz) and x is the value to be written to either
517 * CPVFI or CRVFI. To enable this option, bit 2 in CFIG3 needs to be
522 * Note that if you have a 'bad' XTAL_1 (higher than 18.5 MHz), 44.8 kHz
523 * and 38.4 kHz modes will provide wrong frequencies to output.
534 IW_READ_CODEC_1(CFIG3I
, cfig3
);
536 cfig3
|= 0xc0; /* not full fifo treshhold */
538 DPRINTF(("cfig3i = %x -> ", cfig3
));
541 IW_WRITE_CODEC_1(CFIG3I
, cfig3
);
542 IW_READ_CODEC_1(CFIG3I
, cfig3
);
544 DPRINTF(("%x\n", cfig3
));
546 for (var
= 0; var
< 16; var
++) /* select closest frequency */
547 if (freq
<= iw_cf
[var
].freq
)
550 if (abs(freq
- iw_cf
[var
].freq
) > abs(iw_cf
[var
+ 1].freq
- freq
))
554 IW_WRITE_CODEC_1(CRDFI
| IW_MCE
, sc
->recfmtbits
| iw_cf
[var
].bits
);
556 IW_WRITE_CODEC_1(CPDFI
| IW_MCE
, sc
->playfmtbits
| iw_cf
[var
].bits
);
557 freq
= iw_cf
[var
].freq
;
558 DPRINTF(("setting %s frequency to %d bits %x \n",
559 in
? "in" : "out", (int) freq
, iw_cf
[var
].bits
));
561 IW_READ_CODEC_1(CPDFI
, reg
);
563 DPRINTF((" CPDFI %x ", reg
));
565 IW_READ_CODEC_1(CRDFI
, reg
);
567 DPRINTF((" CRDFI %x ", reg
));
574 iw_query_encoding(void *addr
, audio_encoding_t
*fp
)
577 * LINEAR, ALAW, ULAW, ADPCM in HW, we'll use linear unsigned
578 * hardware mode for all 8-bit modes due to buggy (?) codec.
582 * except in wavetable synth. there we have only mu-law and 8 and 16
588 strcpy(fp
->name
, AudioEulinear
);
589 fp
->encoding
= AUDIO_ENCODING_ULINEAR_LE
;
594 strcpy(fp
->name
, AudioEmulaw
);
595 fp
->encoding
= AUDIO_ENCODING_ULAW
;
597 fp
->flags
= AUDIO_ENCODINGFLAG_EMULATED
;
600 strcpy(fp
->name
, AudioEalaw
);
601 fp
->encoding
= AUDIO_ENCODING_ALAW
;
603 fp
->flags
= AUDIO_ENCODINGFLAG_EMULATED
;
606 strcpy(fp
->name
, AudioEadpcm
);
607 fp
->encoding
= AUDIO_ENCODING_ADPCM
;
608 fp
->precision
= 8; /* really 4 bit */
612 strcpy(fp
->name
, AudioEslinear_le
);
613 fp
->encoding
= AUDIO_ENCODING_SLINEAR_LE
;
618 strcpy(fp
->name
, AudioEslinear_be
);
619 fp
->encoding
= AUDIO_ENCODING_SLINEAR_BE
;
631 iw_set_format(struct iw_softc
*sc
, u_long precision
, int in
)
634 int encoding
, channels
;
636 encoding
= in
? sc
->rec_encoding
: sc
->play_encoding
;
637 channels
= in
? sc
->rec_channels
: sc
->play_channels
;
639 DPRINTF(("iw_set_format\n"));
642 case AUDIO_ENCODING_ULAW
:
646 case AUDIO_ENCODING_ALAW
:
650 case AUDIO_ENCODING_SLINEAR_LE
:
652 data
= 0x40; /* little endian. 0xc0 is big endian */
657 case AUDIO_ENCODING_SLINEAR_BE
:
664 case AUDIO_ENCODING_ADPCM
:
673 data
|= 0x10; /* stereo */
677 sc
->recfmtbits
= data
;
678 /* This will zero the normal codec frequency,
679 * iw_set_speed should always be called afterwards.
681 IW_WRITE_CODEC_1(CRDFI
| IW_MCE
, data
);
684 sc
->playfmtbits
= data
;
685 IW_WRITE_CODEC_1(CPDFI
| IW_MCE
, data
);
688 DPRINTF(("formatbits %s %x", in
? "in" : "out", data
));
694 iw_set_params(void *addr
, int setmode
, int usemode
, audio_params_t
*p
,
695 audio_params_t
*q
, stream_filter_list_t
*pfil
, stream_filter_list_t
*rfil
)
697 audio_params_t phw
, rhw
;
699 stream_filter_factory_t
*swcode
;
701 DPRINTF(("iw_setparams: code %u, prec %u, rate %u, chan %u\n",
702 p
->encoding
, p
->precision
, p
->sample_rate
, p
->channels
));
707 switch (p
->encoding
) {
708 case AUDIO_ENCODING_ULAW
:
709 if (p
->precision
!= 8)
711 phw
.encoding
= AUDIO_ENCODING_ULINEAR_LE
;
712 rhw
.encoding
= AUDIO_ENCODING_ULINEAR_LE
;
713 swcode
= setmode
& AUMODE_PLAY
? mulaw_to_linear8
: linear8_to_mulaw
;
715 case AUDIO_ENCODING_ALAW
:
716 if (p
->precision
!= 8)
718 phw
.encoding
= AUDIO_ENCODING_ULINEAR_LE
;
719 rhw
.encoding
= AUDIO_ENCODING_ULINEAR_LE
;
720 swcode
= setmode
& AUMODE_PLAY
? alaw_to_linear8
: linear8_to_alaw
;
722 case AUDIO_ENCODING_ADPCM
:
723 if (p
->precision
!= 8)
728 case AUDIO_ENCODING_SLINEAR_LE
:
729 case AUDIO_ENCODING_SLINEAR_BE
:
730 if (p
->precision
!= 8 && p
->precision
!= 16)
740 if (setmode
& AUMODE_PLAY
) {
741 sc
->play_channels
= p
->channels
;
742 sc
->play_encoding
= p
->encoding
;
743 sc
->play_precision
= p
->precision
;
744 iw_set_format(sc
, p
->precision
, 0);
745 q
->sample_rate
= p
->sample_rate
= sc
->sc_orate
=
746 iw_set_speed(sc
, p
->sample_rate
, 0);
747 if (swcode
!= NULL
) {
748 phw
.sample_rate
= p
->sample_rate
;
749 pfil
->append(pfil
, swcode
, &phw
);
753 q
->channels
= sc
->rec_channels
= p
->channels
;
754 q
->encoding
= sc
->rec_encoding
= p
->encoding
;
755 q
->precision
= sc
->rec_precision
= p
->precision
;
757 sc
->rec_channels
= q
->channels
;
758 sc
->rec_encoding
= q
->encoding
;
759 sc
->rec_precision
= q
->precision
;
761 iw_set_format(sc
, p
->precision
, 1);
762 q
->sample_rate
= sc
->sc_irate
=
763 iw_set_speed(sc
, q
->sample_rate
, 1);
764 if (swcode
!= NULL
) {
765 rhw
.sample_rate
= q
->sample_rate
;
766 rfil
->append(rfil
, swcode
, &rhw
);
774 iw_round_blocksize(void *addr
, int blk
, int mode
,
775 const audio_params_t
*param
)
778 /* Round to a multiple of the biggest sample size. */
783 iw_mixer_line_level(struct iw_softc
*sc
, int line
, int levl
, int levr
)
785 u_char gainl
, gainr
, attenl
, attenr
;
789 gainl
= sc
->sc_recsrcbits
| (levl
>> 4);
790 gainr
= sc
->sc_recsrcbits
| (levr
>> 4);
791 DPRINTF(("recording with %x", gainl
));
792 IW_WRITE_CODEC_1(CLICI
, gainl
);
793 IW_WRITE_CODEC_1(CRICI
, gainr
);
794 sc
->sc_rec
.voll
= levl
& 0xf0;
795 sc
->sc_rec
.volr
= levr
& 0xf0;
800 gainl
= (255 - levl
) >> 3;
801 gainr
= (255 - levr
) >> 3;
803 /* mute if 0 level */
809 IW_WRITE_CODEC_1(IW_LEFT_AUX1_PORT
, gainl
);
810 IW_WRITE_CODEC_1(IW_RIGHT_AUX1_PORT
, gainr
);
811 sc
->sc_aux1
.voll
= levl
& 0xf8;
812 sc
->sc_aux1
.volr
= levr
& 0xf8;
818 gainl
= (255 - levl
) >> 3;
819 gainr
= (255 - levr
) >> 3;
821 /* mute if 0 level */
827 IW_WRITE_CODEC_1(IW_LEFT_AUX2_PORT
, gainl
);
828 IW_WRITE_CODEC_1(IW_RIGHT_AUX2_PORT
, gainr
);
829 sc
->sc_aux2
.voll
= levl
& 0xf8;
830 sc
->sc_aux2
.volr
= levr
& 0xf8;
833 attenl
= ((255 - levl
) >> 2) | ((levl
&& !sc
->sc_dac
.off
) ? 0 : 0x80);
834 attenr
= ((255 - levr
) >> 2) | ((levr
&& !sc
->sc_dac
.off
) ? 0 : 0x80);
835 IW_WRITE_CODEC_1(CLDACI
, attenl
);
836 IW_WRITE_CODEC_1(CRDACI
, attenr
);
837 sc
->sc_dac
.voll
= levl
& 0xfc;
838 sc
->sc_dac
.volr
= levr
& 0xfc;
841 attenl
= ((255 - levl
) & 0xfc) | (levl
? 0x01 : 0);
842 IW_WRITE_CODEC_1(CLCI
, attenl
);
843 sc
->sc_loopback
.voll
= levl
& 0xfc;
846 gainl
= (levl
>> 3) | (levl
? 0 : 0x80);
847 gainr
= (levr
>> 3) | (levr
? 0 : 0x80);
848 IW_WRITE_CODEC_1(CLLICI
, gainl
);
849 IW_WRITE_CODEC_1(CRLICI
, gainr
);
850 sc
->sc_linein
.voll
= levl
& 0xf8;
851 sc
->sc_linein
.volr
= levr
& 0xf8;
854 gainl
= ((255 - levl
) >> 3) | (levl
? 0 : 0x80);
855 gainr
= ((255 - levr
) >> 3) | (levr
? 0 : 0x80);
856 IW_WRITE_CODEC_1(CLMICI
, gainl
);
857 IW_WRITE_CODEC_1(CRMICI
, gainr
);
858 sc
->sc_mic
.voll
= levl
& 0xf8;
859 sc
->sc_mic
.volr
= levr
& 0xf8;
862 attenl
= ((255 - levl
) >> 3) | (levl
? 0 : 0x80);
863 attenr
= ((255 - levr
) >> 3) | (levr
? 0 : 0x80);
864 IW_WRITE_CODEC_1(CLOAI
, attenl
);
865 IW_WRITE_CODEC_1(CROAI
, attenr
);
866 sc
->sc_lineout
.voll
= levl
& 0xf8;
867 sc
->sc_lineout
.volr
= levr
& 0xf8;
870 attenl
= ((255 - levl
) >> 4) | (levl
? 0 : 0xc0); /* in/out mute */
871 IW_WRITE_CODEC_1(CMONOI
, attenl
);
872 sc
->sc_monoin
.voll
= levl
& 0xf0;
878 iw_commit_settings(void *addr
)
885 iw_trigger_dma(struct iw_softc
*sc
, u_char io
)
892 IW_READ_CODEC_1(CSR3I
, reg
);
893 IW_WRITE_CODEC_1(CSR3I
, reg
& ~(io
== IW_DMA_PLAYBACK
? 0x10 : 0x20));
895 IW_READ_CODEC_1(CFIG1I
, reg
);
897 IW_WRITE_CODEC_1(CFIG1I
, reg
| io
);
899 /* let the counter run */
900 IW_READ_CODEC_1(CFIG2I
, reg
);
901 IW_WRITE_CODEC_1(CFIG2I
, reg
& ~(io
<< 4));
907 iw_stop_dma(struct iw_softc
*sc
, u_char io
, u_char hard
)
911 /* just stop the counter, no need to flush the fifo */
912 IW_READ_CODEC_1(CFIG2I
, reg
);
913 IW_WRITE_CODEC_1(CFIG2I
, (reg
| (io
<< 4)));
916 /* unless we're closing the device */
917 IW_READ_CODEC_1(CFIG1I
, reg
);
918 IW_WRITE_CODEC_1(CFIG1I
, reg
& ~io
);
923 iw_dma_count(struct iw_softc
*sc
, u_short count
, int io
)
926 if (io
== IW_DMA_PLAYBACK
) {
927 IW_WRITE_CODEC_1(CLPCTI
, (u_char
) (count
& 0x00ff));
928 IW_WRITE_CODEC_1(CUPCTI
, (u_char
) ((count
>> 8) & 0x00ff));
930 IW_WRITE_CODEC_1(CLRCTI
, (u_char
) (count
& 0x00ff));
931 IW_WRITE_CODEC_1(CURCTI
, (u_char
) ((count
>> 8) & 0x00ff));
936 iw_init_output(void *addr
, void *sbuf
, int cc
)
938 struct iw_softc
*sc
= (struct iw_softc
*) addr
;
940 DPRINTF(("iw_init_output\n"));
942 isa_dmastart(sc
->sc_ic
, sc
->sc_playdrq
, sbuf
,
943 cc
, NULL
, DMAMODE_WRITE
| DMAMODE_LOOP
, BUS_DMA_NOWAIT
);
948 iw_init_input(void *addr
, void *sbuf
, int cc
)
952 DPRINTF(("iw_init_input\n"));
953 sc
= (struct iw_softc
*) addr
;
954 isa_dmastart(sc
->sc_ic
, sc
->sc_recdrq
, sbuf
,
955 cc
, NULL
, DMAMODE_READ
| DMAMODE_LOOP
, BUS_DMA_NOWAIT
);
961 iw_start_output(void *addr
, void *p
, int cc
, void (*intr
)(void *), void *arg
)
967 printf("iw_start_output: no callback!\n");
972 sc
->sc_playintr
= intr
;
973 sc
->sc_playarg
= arg
;
974 sc
->sc_dma_flags
|= DMAMODE_WRITE
;
975 sc
->sc_playdma_bp
= p
;
977 isa_dmastart(sc
->sc_ic
, sc
->sc_playdrq
, sc
->sc_playdma_bp
,
978 cc
, NULL
, DMAMODE_WRITE
, BUS_DMA_NOWAIT
);
981 if (sc
->play_encoding
== AUDIO_ENCODING_ADPCM
)
983 if (sc
->play_precision
== 16)
986 if (sc
->play_channels
== 2 && sc
->play_encoding
!= AUDIO_ENCODING_ADPCM
)
991 /* iw_dma_access(sc,1); */
992 if (cc
!= sc
->sc_playdma_cnt
) {
993 iw_dma_count(sc
, (u_short
) cc
, IW_DMA_PLAYBACK
);
994 sc
->sc_playdma_cnt
= cc
;
996 iw_trigger_dma(sc
, IW_DMA_PLAYBACK
);
1000 if (outputs
!= iw_ints
)
1001 printf("iw_start_output: out %d, int %d\n", outputs
, iw_ints
);
1010 iw_start_input(void *addr
, void *p
, int cc
, void (*intr
)(void *), void *arg
)
1012 struct iw_softc
*sc
;
1016 printf("iw_start_input: no callback!\n");
1021 sc
->sc_recintr
= intr
;
1022 sc
->sc_recarg
= arg
;
1023 sc
->sc_dma_flags
|= DMAMODE_READ
;
1024 sc
->sc_recdma_bp
= p
;
1026 isa_dmastart(sc
->sc_ic
, sc
->sc_recdrq
, sc
->sc_recdma_bp
,
1027 cc
, NULL
, DMAMODE_READ
, BUS_DMA_NOWAIT
);
1030 if (sc
->rec_encoding
== AUDIO_ENCODING_ADPCM
)
1032 if (sc
->rec_precision
== 16)
1035 if (sc
->rec_channels
== 2 && sc
->rec_encoding
!= AUDIO_ENCODING_ADPCM
)
1040 /* iw_dma_access(sc,0); */
1041 if (sc
->sc_recdma_cnt
!= cc
) {
1042 iw_dma_count(sc
, (u_short
) cc
, IW_DMA_RECORD
);
1043 sc
->sc_recdma_cnt
= cc
;
1044 /* iw_dma_ctrl(sc, IW_DMA_RECORD); */
1045 iw_trigger_dma(sc
, IW_DMA_RECORD
);
1049 if ((inputs
!= iw_inints
))
1050 printf("iw_start_input: in %d, inints %d\n", inputs
, iw_inints
);
1059 iw_halt_output(void *addr
)
1061 struct iw_softc
*sc
;
1064 iw_stop_dma(sc
, IW_DMA_PLAYBACK
, 0);
1070 iw_halt_input(void *addr
)
1072 struct iw_softc
*sc
;
1075 iw_stop_dma(sc
, IW_DMA_RECORD
, 0);
1080 iw_speaker_ctl(void *addr
, int newstate
)
1082 struct iw_softc
*sc
;
1086 if (newstate
== SPKR_ON
) {
1088 IW_READ_CODEC_1(CLDACI
, reg
);
1089 IW_WRITE_CODEC_1(CLDACI
, reg
& 0x7f);
1090 IW_READ_CODEC_1(CRDACI
, reg
);
1091 IW_WRITE_CODEC_1(CRDACI
, reg
& 0x7f);
1095 IW_READ_CODEC_1(CLDACI
, reg
);
1096 IW_WRITE_CODEC_1(CLDACI
, reg
| 0x80);
1097 IW_READ_CODEC_1(CRDACI
, reg
);
1098 IW_WRITE_CODEC_1(CRDACI
, reg
| 0x80);
1104 iw_getdev(void *addr
, struct audio_device
*retp
)
1112 iw_setfd(void *addr
, int flag
)
1118 /* Mixer (in/out ports) */
1120 iw_set_port(void *addr
, mixer_ctrl_t
*cp
)
1122 struct iw_softc
*sc
;
1132 if (cp
->type
== AUDIO_MIXER_VALUE
) {
1134 if (cp
->un
.value
.num_channels
== 1) {
1135 vall
= valr
= cp
->un
.value
.level
[0];
1137 vall
= cp
->un
.value
.level
[0];
1138 valr
= cp
->un
.value
.level
[1];
1140 sc
->sc_mic
.voll
= vall
;
1141 sc
->sc_mic
.volr
= valr
;
1142 iw_mixer_line_level(sc
, IW_MIC_IN
, vall
, valr
);
1146 if (cp
->type
== AUDIO_MIXER_VALUE
) {
1148 if (cp
->un
.value
.num_channels
== 1) {
1149 vall
= valr
= cp
->un
.value
.level
[0];
1151 vall
= cp
->un
.value
.level
[0];
1152 valr
= cp
->un
.value
.level
[1];
1154 sc
->sc_aux1
.voll
= vall
;
1155 sc
->sc_aux1
.volr
= valr
;
1156 iw_mixer_line_level(sc
, IW_AUX1
, vall
, valr
);
1160 if (cp
->type
== AUDIO_MIXER_VALUE
) {
1162 if (cp
->un
.value
.num_channels
== 1) {
1163 vall
= valr
= cp
->un
.value
.level
[0];
1165 vall
= cp
->un
.value
.level
[0];
1166 valr
= cp
->un
.value
.level
[1];
1168 sc
->sc_aux2
.voll
= vall
;
1169 sc
->sc_aux2
.volr
= valr
;
1170 iw_mixer_line_level(sc
, IW_AUX2
, vall
, valr
);
1173 case IW_LINE_IN_LVL
:
1174 if (cp
->type
== AUDIO_MIXER_VALUE
) {
1176 if (cp
->un
.value
.num_channels
== 1) {
1177 vall
= valr
= cp
->un
.value
.level
[0];
1179 vall
= cp
->un
.value
.level
[0];
1180 valr
= cp
->un
.value
.level
[1];
1182 sc
->sc_linein
.voll
= vall
;
1183 sc
->sc_linein
.volr
= valr
;
1184 iw_mixer_line_level(sc
, IW_LINE_IN
, vall
, valr
);
1187 case IW_LINE_OUT_LVL
:
1188 if (cp
->type
== AUDIO_MIXER_VALUE
) {
1190 if (cp
->un
.value
.num_channels
== 1) {
1191 vall
= valr
= cp
->un
.value
.level
[0];
1193 vall
= cp
->un
.value
.level
[0];
1194 valr
= cp
->un
.value
.level
[1];
1196 sc
->sc_lineout
.voll
= vall
;
1197 sc
->sc_lineout
.volr
= valr
;
1198 iw_mixer_line_level(sc
, IW_LINE_OUT
, vall
, valr
);
1202 if (cp
->type
== AUDIO_MIXER_VALUE
) {
1204 if (cp
->un
.value
.num_channels
== 1) {
1205 vall
= valr
= cp
->un
.value
.level
[0];
1207 vall
= cp
->un
.value
.level
[0];
1208 valr
= cp
->un
.value
.level
[1];
1210 sc
->sc_rec
.voll
= vall
;
1211 sc
->sc_rec
.volr
= valr
;
1212 iw_mixer_line_level(sc
, IW_REC
, vall
, valr
);
1217 if (cp
->type
== AUDIO_MIXER_VALUE
) {
1219 if (cp
->un
.value
.num_channels
== 1) {
1220 vall
= valr
= cp
->un
.value
.level
[0];
1222 vall
= cp
->un
.value
.level
[0];
1223 valr
= cp
->un
.value
.level
[1];
1225 sc
->sc_dac
.voll
= vall
;
1226 sc
->sc_dac
.volr
= valr
;
1227 iw_mixer_line_level(sc
, IW_DAC
, vall
, valr
);
1231 case IW_LOOPBACK_LVL
:
1232 if (cp
->type
== AUDIO_MIXER_VALUE
) {
1234 if (cp
->un
.value
.num_channels
!= 1) {
1237 valr
= vall
= cp
->un
.value
.level
[0];
1239 sc
->sc_loopback
.voll
= vall
;
1240 sc
->sc_loopback
.volr
= valr
;
1241 iw_mixer_line_level(sc
, IW_LOOPBACK
, vall
, valr
);
1245 case IW_MONO_IN_LVL
:
1246 if (cp
->type
== AUDIO_MIXER_VALUE
) {
1248 if (cp
->un
.value
.num_channels
!= 1) {
1251 valr
= vall
= cp
->un
.value
.level
[0];
1253 sc
->sc_monoin
.voll
= vall
;
1254 sc
->sc_monoin
.volr
= valr
;
1255 iw_mixer_line_level(sc
, IW_MONO_IN
, vall
, valr
);
1258 case IW_RECORD_SOURCE
:
1260 sc
->sc_recsrcbits
= cp
->un
.ord
<< 6;
1261 DPRINTF(("record source %d bits %x\n", cp
->un
.ord
, sc
->sc_recsrcbits
));
1262 iw_mixer_line_level(sc
, IW_REC
, sc
->sc_rec
.voll
, sc
->sc_rec
.volr
);
1271 iw_get_port(void *addr
, mixer_ctrl_t
*cp
)
1273 struct iw_softc
*sc
;
1280 if (cp
->type
== AUDIO_MIXER_VALUE
) {
1281 cp
->un
.value
.num_channels
= 2;
1282 cp
->un
.value
.level
[0] = sc
->sc_mic
.voll
;
1283 cp
->un
.value
.level
[1] = sc
->sc_mic
.volr
;
1288 if (cp
->type
== AUDIO_MIXER_VALUE
) {
1289 cp
->un
.value
.num_channels
= 2;
1290 cp
->un
.value
.level
[0] = sc
->sc_aux1
.voll
;
1291 cp
->un
.value
.level
[1] = sc
->sc_aux1
.volr
;
1296 if (cp
->type
== AUDIO_MIXER_VALUE
) {
1297 cp
->un
.value
.num_channels
= 2;
1298 cp
->un
.value
.level
[0] = sc
->sc_aux2
.voll
;
1299 cp
->un
.value
.level
[1] = sc
->sc_aux2
.volr
;
1303 case IW_LINE_OUT_LVL
:
1304 if (cp
->type
== AUDIO_MIXER_VALUE
) {
1305 cp
->un
.value
.num_channels
= 2;
1306 cp
->un
.value
.level
[0] = sc
->sc_lineout
.voll
;
1307 cp
->un
.value
.level
[1] = sc
->sc_lineout
.volr
;
1311 case IW_LINE_IN_LVL
:
1312 if (cp
->type
== AUDIO_MIXER_VALUE
) {
1313 cp
->un
.value
.num_channels
= 2;
1314 cp
->un
.value
.level
[0] = sc
->sc_linein
.voll
;
1315 cp
->un
.value
.level
[1] = sc
->sc_linein
.volr
;
1319 if (cp
->type
== AUDIO_MIXER_VALUE
) {
1320 cp
->un
.value
.num_channels
= 2;
1321 cp
->un
.value
.level
[0] = sc
->sc_rec
.voll
;
1322 cp
->un
.value
.level
[1] = sc
->sc_rec
.volr
;
1328 if (cp
->type
== AUDIO_MIXER_VALUE
) {
1329 cp
->un
.value
.num_channels
= 2;
1330 cp
->un
.value
.level
[0] = sc
->sc_dac
.voll
;
1331 cp
->un
.value
.level
[1] = sc
->sc_dac
.volr
;
1336 case IW_LOOPBACK_LVL
:
1337 if (cp
->type
== AUDIO_MIXER_VALUE
) {
1338 cp
->un
.value
.num_channels
= 1;
1339 cp
->un
.value
.level
[0] = sc
->sc_loopback
.voll
;
1344 case IW_MONO_IN_LVL
:
1345 if (cp
->type
== AUDIO_MIXER_VALUE
) {
1346 cp
->un
.value
.num_channels
= 1;
1347 cp
->un
.value
.level
[0] = sc
->sc_monoin
.voll
;
1351 case IW_RECORD_SOURCE
:
1352 cp
->un
.ord
= sc
->sc_recsrcbits
>> 6;
1363 iw_query_devinfo(void *addr
, mixer_devinfo_t
*dip
)
1366 switch (dip
->index
) {
1367 case IW_MIC_IN_LVL
: /* Microphone */
1368 dip
->type
= AUDIO_MIXER_VALUE
;
1369 dip
->mixer_class
= IW_INPUT_CLASS
;
1370 dip
->prev
= AUDIO_MIXER_LAST
;
1371 dip
->next
= AUDIO_MIXER_LAST
;
1372 strcpy(dip
->label
.name
, AudioNmicrophone
);
1373 dip
->un
.v
.num_channels
= 2;
1374 strcpy(dip
->un
.v
.units
.name
, AudioNvolume
);
1377 dip
->type
= AUDIO_MIXER_VALUE
;
1378 dip
->mixer_class
= IW_INPUT_CLASS
;
1379 dip
->prev
= AUDIO_MIXER_LAST
;
1380 dip
->next
= AUDIO_MIXER_LAST
;
1381 strcpy(dip
->label
.name
, AudioNline
);
1382 dip
->un
.v
.num_channels
= 2;
1383 strcpy(dip
->un
.v
.units
.name
, AudioNvolume
);
1386 dip
->type
= AUDIO_MIXER_VALUE
;
1387 dip
->mixer_class
= IW_INPUT_CLASS
;
1388 dip
->prev
= AUDIO_MIXER_LAST
;
1389 dip
->next
= AUDIO_MIXER_LAST
;
1390 strcpy(dip
->label
.name
, AudioNcd
);
1391 dip
->un
.v
.num_channels
= 2;
1392 strcpy(dip
->un
.v
.units
.name
, AudioNvolume
);
1394 case IW_LINE_OUT_LVL
:
1395 dip
->type
= AUDIO_MIXER_VALUE
;
1396 dip
->mixer_class
= IW_OUTPUT_CLASS
;
1397 dip
->prev
= AUDIO_MIXER_LAST
;
1398 dip
->next
= AUDIO_MIXER_LAST
;
1399 strcpy(dip
->label
.name
, AudioNline
);
1400 dip
->un
.v
.num_channels
= 2;
1401 strcpy(dip
->un
.v
.units
.name
, AudioNvolume
);
1404 dip
->type
= AUDIO_MIXER_VALUE
;
1405 dip
->mixer_class
= IW_OUTPUT_CLASS
;
1406 dip
->prev
= AUDIO_MIXER_LAST
;
1407 dip
->next
= AUDIO_MIXER_LAST
;
1408 strcpy(dip
->label
.name
, AudioNdac
);
1409 dip
->un
.v
.num_channels
= 2;
1410 strcpy(dip
->un
.v
.units
.name
, AudioNvolume
);
1412 case IW_LINE_IN_LVL
:
1413 dip
->type
= AUDIO_MIXER_VALUE
;
1414 dip
->mixer_class
= IW_INPUT_CLASS
;
1415 dip
->prev
= AUDIO_MIXER_LAST
;
1416 dip
->next
= AUDIO_MIXER_LAST
;
1417 strcpy(dip
->label
.name
, AudioNinput
);
1418 dip
->un
.v
.num_channels
= 2;
1419 strcpy(dip
->un
.v
.units
.name
, AudioNvolume
);
1421 case IW_MONO_IN_LVL
:
1422 dip
->type
= AUDIO_MIXER_VALUE
;
1423 dip
->mixer_class
= IW_INPUT_CLASS
;
1424 dip
->prev
= AUDIO_MIXER_LAST
;
1425 dip
->next
= AUDIO_MIXER_LAST
;
1426 strcpy(dip
->label
.name
, AudioNmono
);
1427 dip
->un
.v
.num_channels
= 1;
1428 strcpy(dip
->un
.v
.units
.name
, AudioNvolume
);
1431 case IW_REC_LVL
: /* record level */
1432 dip
->type
= AUDIO_MIXER_VALUE
;
1433 dip
->mixer_class
= IW_RECORD_CLASS
;
1434 dip
->prev
= AUDIO_MIXER_LAST
;
1435 dip
->next
= AUDIO_MIXER_LAST
;
1436 strcpy(dip
->label
.name
, AudioNrecord
);
1437 dip
->un
.v
.num_channels
= 2;
1438 strcpy(dip
->un
.v
.units
.name
, AudioNvolume
);
1441 case IW_LOOPBACK_LVL
:
1442 dip
->type
= AUDIO_MIXER_VALUE
;
1443 dip
->mixer_class
= IW_RECORD_CLASS
;
1444 dip
->prev
= AUDIO_MIXER_LAST
;
1445 dip
->next
= AUDIO_MIXER_LAST
;
1446 strcpy(dip
->label
.name
, "filter");
1447 dip
->un
.v
.num_channels
= 1;
1448 strcpy(dip
->un
.v
.units
.name
, AudioNvolume
);
1451 case IW_RECORD_SOURCE
:
1452 dip
->mixer_class
= IW_RECORD_CLASS
;
1453 dip
->type
= AUDIO_MIXER_ENUM
;
1454 dip
->prev
= AUDIO_MIXER_LAST
;
1455 dip
->next
= AUDIO_MIXER_LAST
;
1456 strcpy(dip
->label
.name
, AudioNsource
);
1457 dip
->un
.e
.num_mem
= 4;
1458 strcpy(dip
->un
.e
.member
[0].label
.name
, AudioNline
);
1459 dip
->un
.e
.member
[0].ord
= IW_LINE_IN_SRC
;
1460 strcpy(dip
->un
.e
.member
[1].label
.name
, "aux1");
1461 dip
->un
.e
.member
[1].ord
= IW_AUX1_SRC
;
1462 strcpy(dip
->un
.e
.member
[2].label
.name
, AudioNmicrophone
);
1463 dip
->un
.e
.member
[2].ord
= IW_MIC_IN_SRC
;
1464 strcpy(dip
->un
.e
.member
[3].label
.name
, AudioNmixerout
);
1465 dip
->un
.e
.member
[3].ord
= IW_MIX_OUT_SRC
;
1467 case IW_INPUT_CLASS
:
1468 dip
->type
= AUDIO_MIXER_CLASS
;
1469 dip
->mixer_class
= IW_INPUT_CLASS
;
1470 dip
->next
= dip
->prev
= AUDIO_MIXER_LAST
;
1471 strcpy(dip
->label
.name
, AudioCinputs
);
1473 case IW_OUTPUT_CLASS
:
1474 dip
->type
= AUDIO_MIXER_CLASS
;
1475 dip
->mixer_class
= IW_OUTPUT_CLASS
;
1476 dip
->next
= dip
->prev
= AUDIO_MIXER_LAST
;
1477 strcpy(dip
->label
.name
, AudioCoutputs
);
1479 case IW_RECORD_CLASS
: /* record source class */
1480 dip
->type
= AUDIO_MIXER_CLASS
;
1481 dip
->mixer_class
= IW_RECORD_CLASS
;
1482 dip
->next
= dip
->prev
= AUDIO_MIXER_LAST
;
1483 strcpy(dip
->label
.name
, AudioCrecord
);
1493 iw_malloc(void *addr
, int direction
, size_t size
,
1494 struct malloc_type
*pool
, int flags
)
1496 struct iw_softc
*sc
;
1500 if (direction
== AUMODE_PLAY
)
1501 drq
= sc
->sc_playdrq
;
1503 drq
= sc
->sc_recdrq
;
1504 return isa_malloc(sc
->sc_ic
, drq
, size
, pool
, flags
);
1508 iw_free(void *addr
, void *ptr
, struct malloc_type
*pool
)
1510 isa_free(ptr
, pool
);
1514 iw_round_buffersize(void *addr
, int direction
, size_t size
)
1516 struct iw_softc
*sc
;
1520 if (direction
== AUMODE_PLAY
)
1521 maxsize
= sc
->sc_play_maxsize
;
1523 maxsize
= sc
->sc_rec_maxsize
;
1531 iw_mappage(void *addr
, void *mem
, off_t off
, int prot
)
1534 return isa_mappage(mem
, off
, prot
);
1538 iw_get_props(void *addr
)
1540 struct iw_softc
*sc
;
1543 return AUDIO_PROP_MMAP
|
1544 (sc
->sc_fullduplex
? AUDIO_PROP_FULLDUPLEX
: 0);