FreeBSD kernel sound device code
cmi.c
Go to the documentation of this file.
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3 *
4 * Copyright (c) 2000 Orion Hodson <O.Hodson@cs.ucl.ac.uk>
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHERIN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THEPOSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28
29/*
30 * This driver exists largely as a result of other people's efforts.
31 * Much of register handling is based on NetBSD CMI8x38 audio driver
32 * by Takuya Shiozaki <AoiMoe@imou.to>. Chen-Li Tien
33 * <cltien@cmedia.com.tw> clarified points regarding the DMA related
34 * registers and the 8738 mixer devices. His Linux driver was also a
35 * useful reference point.
36 *
37 * TODO: MIDI
38 *
39 * SPDIF contributed by Gerhard Gonter <gonter@whisky.wu-wien.ac.at>.
40 *
41 * This card/code does not always manage to sample at 44100 - actual
42 * rate drifts slightly between recordings (usually 0-3%). No
43 * differences visible in register dumps between times that work and
44 * those that don't.
45 */
46
47#ifdef HAVE_KERNEL_OPTION_HEADERS
48#include "opt_snd.h"
49#endif
50
51#include <dev/sound/pcm/sound.h>
53#include <dev/sound/isa/sb.h>
54
55#include <dev/pci/pcireg.h>
56#include <dev/pci/pcivar.h>
57
58#include <sys/sysctl.h>
60
61#include "mixer_if.h"
62#include "mpufoi_if.h"
63
64SND_DECLARE_FILE("$FreeBSD$");
65
66/* Supported chip ID's */
67#define CMI8338A_PCI_ID 0x010013f6
68#define CMI8338B_PCI_ID 0x010113f6
69#define CMI8738_PCI_ID 0x011113f6
70#define CMI8738B_PCI_ID 0x011213f6
71#define CMI120_USB_ID 0x01030d8c
72
73/* Buffer size max is 64k for permitted DMA boundaries */
74#define CMI_DEFAULT_BUFSZ 16384
75
76/* Interrupts per length of buffer */
77#define CMI_INTR_PER_BUFFER 2
78
79/* Clarify meaning of named defines in cmireg.h */
80#define CMPCI_REG_DMA0_MAX_SAMPLES CMPCI_REG_DMA0_BYTES
81#define CMPCI_REG_DMA0_INTR_SAMPLES CMPCI_REG_DMA0_SAMPLES
82#define CMPCI_REG_DMA1_MAX_SAMPLES CMPCI_REG_DMA1_BYTES
83#define CMPCI_REG_DMA1_INTR_SAMPLES CMPCI_REG_DMA1_SAMPLES
84
85/* Our indication of custom mixer control */
86#define CMPCI_NON_SB16_CONTROL 0xff
87
88/* Debugging macro's */
89#undef DEB
90#ifndef DEB
91#define DEB(x) /* x */
92#endif /* DEB */
93
94#ifndef DEBMIX
95#define DEBMIX(x) /* x */
96#endif /* DEBMIX */
97
98/* ------------------------------------------------------------------------- */
99/* Structures */
100
101struct sc_info;
102
103struct sc_chinfo {
104 struct sc_info *parent;
105 struct pcm_channel *channel;
106 struct snd_dbuf *buffer;
107 u_int32_t fmt, spd, phys_buf, bps;
108 u_int32_t dma_active:1, dma_was_active:1;
109 int dir;
110};
111
112struct sc_info {
113 device_t dev;
114
115 bus_space_tag_t st;
116 bus_space_handle_t sh;
117 bus_dma_tag_t parent_dmat;
118 struct resource *reg, *irq;
119 int regid, irqid;
120 void *ih;
121 struct mtx *lock;
122
124 unsigned int bufsz;
125 struct sc_chinfo pch, rch;
126
127 struct mpu401 *mpu;
129 struct resource *mpu_reg;
131 bus_space_tag_t mpu_bt;
132 bus_space_handle_t mpu_bh;
133};
134
135/* Channel caps */
136
137static u_int32_t cmi_fmt[] = {
138 SND_FORMAT(AFMT_U8, 1, 0),
139 SND_FORMAT(AFMT_U8, 2, 0),
140 SND_FORMAT(AFMT_S16_LE, 1, 0),
141 SND_FORMAT(AFMT_S16_LE, 2, 0),
142 0
143};
144
145static struct pcmchan_caps cmi_caps = {5512, 48000, cmi_fmt, 0};
146
147/* ------------------------------------------------------------------------- */
148/* Register Utilities */
149
150static u_int32_t
151cmi_rd(struct sc_info *sc, int regno, int size)
152{
153 switch (size) {
154 case 1:
155 return bus_space_read_1(sc->st, sc->sh, regno);
156 case 2:
157 return bus_space_read_2(sc->st, sc->sh, regno);
158 case 4:
159 return bus_space_read_4(sc->st, sc->sh, regno);
160 default:
161 DEB(printf("cmi_rd: failed 0x%04x %d\n", regno, size));
162 return 0xFFFFFFFF;
163 }
164}
165
166static void
167cmi_wr(struct sc_info *sc, int regno, u_int32_t data, int size)
168{
169 switch (size) {
170 case 1:
171 bus_space_write_1(sc->st, sc->sh, regno, data);
172 break;
173 case 2:
174 bus_space_write_2(sc->st, sc->sh, regno, data);
175 break;
176 case 4:
177 bus_space_write_4(sc->st, sc->sh, regno, data);
178 break;
179 }
180}
181
182static void
184 int reg, int shift, u_int32_t mask, u_int32_t val)
185{
186 u_int32_t r;
187
188 r = cmi_rd(sc, reg, 4);
189 r &= ~(mask << shift);
190 r |= val << shift;
191 cmi_wr(sc, reg, r, 4);
192}
193
194static void
195cmi_clr4(struct sc_info *sc, int reg, u_int32_t mask)
196{
197 u_int32_t r;
198
199 r = cmi_rd(sc, reg, 4);
200 r &= ~mask;
201 cmi_wr(sc, reg, r, 4);
202}
203
204static void
205cmi_set4(struct sc_info *sc, int reg, u_int32_t mask)
206{
207 u_int32_t r;
208
209 r = cmi_rd(sc, reg, 4);
210 r |= mask;
211 cmi_wr(sc, reg, r, 4);
212}
213
214/* ------------------------------------------------------------------------- */
215/* Rate Mapping */
216
217static int cmi_rates[] = {5512, 8000, 11025, 16000,
218 22050, 32000, 44100, 48000};
219#define NUM_CMI_RATES (sizeof(cmi_rates)/sizeof(cmi_rates[0]))
220
221/* cmpci_rate_to_regvalue returns sampling freq selector for FCR1
222 * register - reg order is 5k,11k,22k,44k,8k,16k,32k,48k */
223
224static u_int32_t
226{
227 int i, r;
228
229 for(i = 0; i < NUM_CMI_RATES - 1; i++) {
230 if (rate < ((cmi_rates[i] + cmi_rates[i + 1]) / 2)) {
231 break;
232 }
233 }
234
235 DEB(printf("cmpci_rate_to_regvalue: %d -> %d\n", rate, cmi_rates[i]));
236
237 r = ((i >> 1) | (i << 2)) & 0x07;
238 return r;
239}
240
241static int
243{
244 int i;
245
246 i = ((r << 1) | (r >> 2)) & 0x07;
247 DEB(printf("cmpci_regvalue_to_rate: %d -> %d\n", r, i));
248 return cmi_rates[i];
249}
250
251/* ------------------------------------------------------------------------- */
252/* ADC/DAC control - there are 2 dma channels on 8738, either can be
253 * playback or capture. We use ch0 for playback and ch1 for capture. */
254
255static void
256cmi_dma_prog(struct sc_info *sc, struct sc_chinfo *ch, u_int32_t base)
257{
258 u_int32_t s, i, sz;
259
261
262 cmi_wr(sc, base, ch->phys_buf, 4);
263 sz = (u_int32_t)sndbuf_getsize(ch->buffer);
264
265 s = sz / ch->bps - 1;
266 cmi_wr(sc, base + 4, s, 2);
267
268 i = sz / (ch->bps * CMI_INTR_PER_BUFFER) - 1;
269 cmi_wr(sc, base + 6, i, 2);
270}
271
272static void
273cmi_ch0_start(struct sc_info *sc, struct sc_chinfo *ch)
274{
276
280
281 ch->dma_active = 1;
282}
283
284static u_int32_t
285cmi_ch0_stop(struct sc_info *sc, struct sc_chinfo *ch)
286{
287 u_int32_t r = ch->dma_active;
288
293 ch->dma_active = 0;
294 return r;
295}
296
297static void
298cmi_ch1_start(struct sc_info *sc, struct sc_chinfo *ch)
299{
302 /* Enable Interrupts */
305 DEB(printf("cmi_ch1_start: dma prog\n"));
306 ch->dma_active = 1;
307}
308
309static u_int32_t
310cmi_ch1_stop(struct sc_info *sc, struct sc_chinfo *ch)
311{
312 u_int32_t r = ch->dma_active;
313
318 ch->dma_active = 0;
319 return r;
320}
321
322static void
323cmi_spdif_speed(struct sc_info *sc, int speed) {
324 u_int32_t fcr1, lcr, mcr;
325
326 if (speed >= 44100) {
329 mcr = (speed == 48000) ?
331 } else {
332 fcr1 = mcr = lcr = 0;
333 }
334
341}
342
343/* ------------------------------------------------------------------------- */
344/* Channel Interface implementation */
345
346static void *
347cmichan_init(kobj_t obj, void *devinfo,
348 struct snd_dbuf *b, struct pcm_channel *c, int dir)
349{
350 struct sc_info *sc = devinfo;
351 struct sc_chinfo *ch = (dir == PCMDIR_PLAY) ? &sc->pch : &sc->rch;
352
353 ch->parent = sc;
354 ch->channel = c;
355 ch->bps = 1;
356 ch->fmt = SND_FORMAT(AFMT_U8, 1, 0);
358 ch->buffer = b;
359 ch->dma_active = 0;
360 if (sndbuf_alloc(ch->buffer, sc->parent_dmat, 0, sc->bufsz) != 0) {
361 DEB(printf("cmichan_init failed\n"));
362 return NULL;
363 }
364
365 ch->dir = dir;
366 snd_mtxlock(sc->lock);
367 if (ch->dir == PCMDIR_PLAY) {
369 } else {
371 }
372 snd_mtxunlock(sc->lock);
373
374 return ch;
375}
376
377static int
378cmichan_setformat(kobj_t obj, void *data, u_int32_t format)
379{
380 struct sc_chinfo *ch = data;
381 struct sc_info *sc = ch->parent;
382 u_int32_t f;
383
384 if (format & AFMT_S16_LE) {
386 ch->bps = 2;
387 } else {
389 ch->bps = 1;
390 }
391
392 if (AFMT_CHANNEL(format) > 1) {
394 ch->bps *= 2;
395 } else {
397 }
398
399 snd_mtxlock(sc->lock);
400 if (ch->dir == PCMDIR_PLAY) {
405 f);
406 } else {
411 f);
412 }
413 snd_mtxunlock(sc->lock);
414 ch->fmt = format;
415
416 return 0;
417}
418
419static u_int32_t
420cmichan_setspeed(kobj_t obj, void *data, u_int32_t speed)
421{
422 struct sc_chinfo *ch = data;
423 struct sc_info *sc = ch->parent;
424 u_int32_t r, rsp;
425
427 snd_mtxlock(sc->lock);
428 if (ch->dir == PCMDIR_PLAY) {
429 if (speed < 44100) {
430 /* disable if req before rate change */
432 }
437 r);
438 if (speed >= 44100 && ch->parent->spdif_enabled) {
439 /* enable if req after rate change */
441 }
442 rsp = cmi_rd(ch->parent, CMPCI_REG_FUNC_1, 4);
445 } else {
450 r);
451 rsp = cmi_rd(ch->parent, CMPCI_REG_FUNC_1, 4);
454 }
455 snd_mtxunlock(sc->lock);
457
458 DEB(printf("cmichan_setspeed (%s) %d -> %d (%d)\n",
459 (ch->dir == PCMDIR_PLAY) ? "play" : "rec",
461
462 return ch->spd;
463}
464
465static u_int32_t
466cmichan_setblocksize(kobj_t obj, void *data, u_int32_t blocksize)
467{
468 struct sc_chinfo *ch = data;
469 struct sc_info *sc = ch->parent;
470
471 /* user has requested interrupts every blocksize bytes */
472 if (blocksize > sc->bufsz / CMI_INTR_PER_BUFFER) {
474 }
476
477 return blocksize;
478}
479
480static int
481cmichan_trigger(kobj_t obj, void *data, int go)
482{
483 struct sc_chinfo *ch = data;
484 struct sc_info *sc = ch->parent;
485
486 if (!PCMTRIG_COMMON(go))
487 return 0;
488
489 snd_mtxlock(sc->lock);
490 if (ch->dir == PCMDIR_PLAY) {
491 switch(go) {
492 case PCMTRIG_START:
493 cmi_ch0_start(sc, ch);
494 break;
495 case PCMTRIG_STOP:
496 case PCMTRIG_ABORT:
497 cmi_ch0_stop(sc, ch);
498 break;
499 }
500 } else {
501 switch(go) {
502 case PCMTRIG_START:
503 cmi_ch1_start(sc, ch);
504 break;
505 case PCMTRIG_STOP:
506 case PCMTRIG_ABORT:
507 cmi_ch1_stop(sc, ch);
508 break;
509 }
510 }
511 snd_mtxunlock(sc->lock);
512 return 0;
513}
514
515static u_int32_t
516cmichan_getptr(kobj_t obj, void *data)
517{
518 struct sc_chinfo *ch = data;
519 struct sc_info *sc = ch->parent;
520 u_int32_t physptr, bufptr, sz;
521
522 snd_mtxlock(sc->lock);
523 if (ch->dir == PCMDIR_PLAY) {
524 physptr = cmi_rd(sc, CMPCI_REG_DMA0_BASE, 4);
525 } else {
526 physptr = cmi_rd(sc, CMPCI_REG_DMA1_BASE, 4);
527 }
528 snd_mtxunlock(sc->lock);
529
530 sz = sndbuf_getsize(ch->buffer);
531 bufptr = (physptr - ch->phys_buf + sz - ch->bps) % sz;
532
533 return bufptr;
534}
535
536static void
538{
539 struct sc_info *sc = data;
540 u_int32_t intrstat;
541 u_int32_t toclear;
542
543 snd_mtxlock(sc->lock);
544 intrstat = cmi_rd(sc, CMPCI_REG_INTR_STATUS, 4);
545 if ((intrstat & CMPCI_REG_ANY_INTR) != 0) {
546 toclear = 0;
547 if (intrstat & CMPCI_REG_CH0_INTR) {
548 toclear |= CMPCI_REG_CH0_INTR_ENABLE;
549 //cmi_clr4(sc, CMPCI_REG_INTR_CTRL, CMPCI_REG_CH0_INTR_ENABLE);
550 }
551
552 if (intrstat & CMPCI_REG_CH1_INTR) {
553 toclear |= CMPCI_REG_CH1_INTR_ENABLE;
554 //cmi_clr4(sc, CMPCI_REG_INTR_CTRL, CMPCI_REG_CH1_INTR_ENABLE);
555 }
556
557 if (toclear) {
558 cmi_clr4(sc, CMPCI_REG_INTR_CTRL, toclear);
559 snd_mtxunlock(sc->lock);
560
561 /* Signal interrupts to channel */
562 if (intrstat & CMPCI_REG_CH0_INTR) {
563 chn_intr(sc->pch.channel);
564 }
565
566 if (intrstat & CMPCI_REG_CH1_INTR) {
567 chn_intr(sc->rch.channel);
568 }
569
570 snd_mtxlock(sc->lock);
571 cmi_set4(sc, CMPCI_REG_INTR_CTRL, toclear);
572 }
573 }
574 if(sc->mpu_intr) {
575 (sc->mpu_intr)(sc->mpu);
576 }
577 snd_mtxunlock(sc->lock);
578 return;
579}
580
581static struct pcmchan_caps *
582cmichan_getcaps(kobj_t obj, void *data)
583{
584 return &cmi_caps;
585}
586
587static kobj_method_t cmichan_methods[] = {
588 KOBJMETHOD(channel_init, cmichan_init),
589 KOBJMETHOD(channel_setformat, cmichan_setformat),
590 KOBJMETHOD(channel_setspeed, cmichan_setspeed),
591 KOBJMETHOD(channel_setblocksize, cmichan_setblocksize),
592 KOBJMETHOD(channel_trigger, cmichan_trigger),
593 KOBJMETHOD(channel_getptr, cmichan_getptr),
594 KOBJMETHOD(channel_getcaps, cmichan_getcaps),
596};
598
599/* ------------------------------------------------------------------------- */
600/* Mixer - sb16 with kinks */
601
602static void
603cmimix_wr(struct sc_info *sc, u_int8_t port, u_int8_t val)
604{
605 cmi_wr(sc, CMPCI_REG_SBADDR, port, 1);
606 cmi_wr(sc, CMPCI_REG_SBDATA, val, 1);
607}
608
609static u_int8_t
610cmimix_rd(struct sc_info *sc, u_int8_t port)
611{
612 cmi_wr(sc, CMPCI_REG_SBADDR, port, 1);
613 return (u_int8_t)cmi_rd(sc, CMPCI_REG_SBDATA, 1);
614}
615
616struct sb16props {
617 u_int8_t rreg; /* right reg chan register */
618 u_int8_t stereo:1; /* (no explanation needed, honest) */
619 u_int8_t rec:1; /* recording source */
620 u_int8_t bits:3; /* num bits to represent maximum gain rep */
621 u_int8_t oselect; /* output select mask */
622 u_int8_t iselect; /* right input select mask */
623} static const cmt[SOUND_MIXER_NRDEVICES] = {
624 [SOUND_MIXER_SYNTH] = {CMPCI_SB16_MIXER_FM_R, 1, 1, 5,
626 [SOUND_MIXER_CD] = {CMPCI_SB16_MIXER_CDDA_R, 1, 1, 5,
628 [SOUND_MIXER_LINE] = {CMPCI_SB16_MIXER_LINE_R, 1, 1, 5,
630 [SOUND_MIXER_MIC] = {CMPCI_SB16_MIXER_MIC, 0, 1, 5,
632 [SOUND_MIXER_SPEAKER] = {CMPCI_SB16_MIXER_SPEAKER, 0, 0, 2, 0, 0},
633 [SOUND_MIXER_PCM] = {CMPCI_SB16_MIXER_VOICE_R, 1, 0, 5, 0, 0},
634 [SOUND_MIXER_VOLUME] = {CMPCI_SB16_MIXER_MASTER_R, 1, 0, 5, 0, 0},
635 /* These controls are not implemented in CMI8738, but maybe at a
636 future date. They are not documented in C-Media documentation,
637 though appear in other drivers for future h/w (ALSA, Linux, NetBSD).
638 */
639 [SOUND_MIXER_IGAIN] = {CMPCI_SB16_MIXER_INGAIN_R, 1, 0, 2, 0, 0},
640 [SOUND_MIXER_OGAIN] = {CMPCI_SB16_MIXER_OUTGAIN_R, 1, 0, 2, 0, 0},
641 [SOUND_MIXER_BASS] = {CMPCI_SB16_MIXER_BASS_R, 1, 0, 4, 0, 0},
642 [SOUND_MIXER_TREBLE] = {CMPCI_SB16_MIXER_TREBLE_R, 1, 0, 4, 0, 0},
643 /* The mic pre-amp is implemented with non-SB16 compatible
644 registers. */
645 [SOUND_MIXER_MONITOR] = {CMPCI_NON_SB16_CONTROL, 0, 1, 4, 0},
647
648#define MIXER_GAIN_REG_RTOL(r) (r - 1)
649
650static int
652{
653 struct sc_info *sc = mix_getdevinfo(m);
654 u_int32_t i,v;
655
656 for(i = v = 0; i < SOUND_MIXER_NRDEVICES; i++) {
657 if (cmt[i].bits) v |= 1 << i;
658 }
659 mix_setdevs(m, v);
660
661 for(i = v = 0; i < SOUND_MIXER_NRDEVICES; i++) {
662 if (cmt[i].rec) v |= 1 << i;
663 }
664 mix_setrecdevs(m, v);
665
671 return 0;
672}
673
674static int
675cmimix_set(struct snd_mixer *m, unsigned dev, unsigned left, unsigned right)
676{
677 struct sc_info *sc = mix_getdevinfo(m);
678 u_int32_t r, l, max;
679 u_int8_t v;
680
681 max = (1 << cmt[dev].bits) - 1;
682
683 if (cmt[dev].rreg == CMPCI_NON_SB16_CONTROL) {
684 /* For time being this can only be one thing (mic in
685 * mic/aux reg) */
686 v = cmi_rd(sc, CMPCI_REG_AUX_MIC, 1) & 0xf0;
687 l = left * max / 100;
688 /* 3 bit gain with LSB MICGAIN off(1),on(1) -> 4 bit value */
689 v |= ((l << 1) | (~l >> 3)) & 0x0f;
690 cmi_wr(sc, CMPCI_REG_AUX_MIC, v, 1);
691 return 0;
692 }
693
694 l = (left * max / 100) << (8 - cmt[dev].bits);
695 if (cmt[dev].stereo) {
696 r = (right * max / 100) << (8 - cmt[dev].bits);
697 cmimix_wr(sc, MIXER_GAIN_REG_RTOL(cmt[dev].rreg), l);
698 cmimix_wr(sc, cmt[dev].rreg, r);
699 DEBMIX(printf("Mixer stereo write dev %d reg 0x%02x "\
700 "value 0x%02x:0x%02x\n",
701 dev, MIXER_GAIN_REG_RTOL(cmt[dev].rreg), l, r));
702 } else {
703 r = l;
704 cmimix_wr(sc, cmt[dev].rreg, l);
705 DEBMIX(printf("Mixer mono write dev %d reg 0x%02x " \
706 "value 0x%02x:0x%02x\n",
707 dev, cmt[dev].rreg, l, l));
708 }
709
710 /* Zero gain does not mute channel from output, but this does... */
712 if (l == 0 && r == 0) {
713 v &= ~cmt[dev].oselect;
714 } else {
715 v |= cmt[dev].oselect;
716 }
718
719 return 0;
720}
721
722static u_int32_t
723cmimix_setrecsrc(struct snd_mixer *m, u_int32_t src)
724{
725 struct sc_info *sc = mix_getdevinfo(m);
726 u_int32_t i, ml, sl;
727
728 ml = sl = 0;
729 for(i = 0; i < SOUND_MIXER_NRDEVICES; i++) {
730 if ((1<<i) & src) {
731 if (cmt[i].stereo) {
732 sl |= cmt[i].iselect;
733 } else {
734 ml |= cmt[i].iselect;
735 }
736 }
737 }
739 DEBMIX(printf("cmimix_setrecsrc: reg 0x%02x val 0x%02x\n",
743 DEBMIX(printf("cmimix_setrecsrc: reg 0x%02x val 0x%02x\n",
745
746 return src;
747}
748
749/* Optional SPDIF support. */
750
751static int
753{
754 /* XXX: an user should be able to set this with a control tool,
755 if not done before 7.0-RELEASE, this needs to be converted
756 to a device specific sysctl "dev.pcm.X.yyy" via
757 device_get_sysctl_*() as discussed on multimedia@ in msg-id
758 <861wujij2q.fsf@xps.des.no> */
759 SYSCTL_ADD_INT(device_get_sysctl_ctx(sc->dev),
760 SYSCTL_CHILDREN(device_get_sysctl_tree(sc->dev)),
761 OID_AUTO, "spdif_enabled", CTLFLAG_RW,
762 &sc->spdif_enabled, 0,
763 "enable SPDIF output at 44.1 kHz and above");
764
765 return 0;
766}
767
768/* ------------------------------------------------------------------------- */
769static kobj_method_t cmi_mixer_methods[] = {
770 KOBJMETHOD(mixer_init, cmimix_init),
771 KOBJMETHOD(mixer_set, cmimix_set),
774};
775MIXER_DECLARE(cmi_mixer);
776
777/*
778 * mpu401 functions
779 */
780
781static unsigned char
782cmi_mread(struct mpu401 *arg, void *sc, int reg)
783{
784 unsigned int d;
785
786 d = bus_space_read_1(0,0, 0x330 + reg);
787 /* printf("cmi_mread: reg %x %x\n",reg, d);
788 */
789 return d;
790}
791
792static void
793cmi_mwrite(struct mpu401 *arg, void *sc, int reg, unsigned char b)
794{
795
796 bus_space_write_1(0,0,0x330 + reg , b);
797}
798
799static int
800cmi_muninit(struct mpu401 *arg, void *cookie)
801{
802 struct sc_info *sc = cookie;
803
804 snd_mtxlock(sc->lock);
805 sc->mpu_intr = NULL;
806 sc->mpu = NULL;
807 snd_mtxunlock(sc->lock);
808
809 return 0;
810}
811
812static kobj_method_t cmi_mpu_methods[] = {
813 KOBJMETHOD(mpufoi_read, cmi_mread),
814 KOBJMETHOD(mpufoi_write, cmi_mwrite),
815 KOBJMETHOD(mpufoi_uninit, cmi_muninit),
817};
818
819static DEFINE_CLASS(cmi_mpu, cmi_mpu_methods, 0);
820
821static void
823/*
824 const struct {
825 int port,bits;
826 } *p, ports[] = {
827 {0x330,0},
828 {0x320,1},
829 {0x310,2},
830 {0x300,3},
831 {0,0} } ;
832 Notes, CMPCI_REG_VMPUSEL sets the io port for the mpu. Does
833 anyone know how to bus_space tag?
834*/
841 sc->mpu = mpu401_init(&cmi_mpu_class, sc, cmi_intr, &sc->mpu_intr);
842}
843
844/* ------------------------------------------------------------------------- */
845/* Power and reset */
846
847static void
848cmi_power(struct sc_info *sc, int state)
849{
850 switch (state) {
851 case 0: /* full power */
853 break;
854 default:
855 /* power off */
857 break;
858 }
859}
860
861static int
862cmi_init(struct sc_info *sc)
863{
864 /* Effect reset */
866 DELAY(100);
868
869 /* Disable interrupts and channels */
874
875 /* Configure DMA channels, ch0 = play, ch1 = capture */
878
879 /* Attempt to enable 4 Channel output */
881
882 /* Disable SPDIF1 - not compatible with config */
885
886 return 0;
887}
888
889static void
891{
892 /* Disable interrupts and channels */
900
901 if( sc->mpu )
902 sc->mpu_intr = NULL;
903}
904
905/* ------------------------------------------------------------------------- */
906/* Bus and device registration */
907static int
908cmi_probe(device_t dev)
909{
910 switch(pci_get_devid(dev)) {
911 case CMI8338A_PCI_ID:
912 device_set_desc(dev, "CMedia CMI8338A");
913 return BUS_PROBE_DEFAULT;
914 case CMI8338B_PCI_ID:
915 device_set_desc(dev, "CMedia CMI8338B");
916 return BUS_PROBE_DEFAULT;
917 case CMI8738_PCI_ID:
918 device_set_desc(dev, "CMedia CMI8738");
919 return BUS_PROBE_DEFAULT;
920 case CMI8738B_PCI_ID:
921 device_set_desc(dev, "CMedia CMI8738B");
922 return BUS_PROBE_DEFAULT;
923 case CMI120_USB_ID:
924 device_set_desc(dev, "CMedia CMI120");
925 return BUS_PROBE_DEFAULT;
926 default:
927 return ENXIO;
928 }
929}
930
931static int
933{
934 struct sc_info *sc;
935 char status[SND_STATUSLEN];
936
937 sc = malloc(sizeof(*sc), M_DEVBUF, M_WAITOK | M_ZERO);
938 sc->lock = snd_mtxcreate(device_get_nameunit(dev), "snd_cmi softc");
939 pci_enable_busmaster(dev);
940
941 sc->dev = dev;
942 sc->regid = PCIR_BAR(0);
943 sc->reg = bus_alloc_resource_any(dev, SYS_RES_IOPORT, &sc->regid,
944 RF_ACTIVE);
945 if (!sc->reg) {
946 device_printf(dev, "cmi_attach: Cannot allocate bus resource\n");
947 goto bad;
948 }
949 sc->st = rman_get_bustag(sc->reg);
950 sc->sh = rman_get_bushandle(sc->reg);
951
952 if (0)
953 cmi_midiattach(sc);
954
955 sc->irqid = 0;
956 sc->irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &sc->irqid,
957 RF_ACTIVE | RF_SHAREABLE);
958 if (!sc->irq ||
959 snd_setup_intr(dev, sc->irq, INTR_MPSAFE, cmi_intr, sc, &sc->ih)) {
960 device_printf(dev, "cmi_attach: Unable to map interrupt\n");
961 goto bad;
962 }
963
964 sc->bufsz = pcm_getbuffersize(dev, 4096, CMI_DEFAULT_BUFSZ, 65536);
965
966 if (bus_dma_tag_create(/*parent*/bus_get_dma_tag(dev), /*alignment*/2,
967 /*boundary*/0,
968 /*lowaddr*/BUS_SPACE_MAXADDR_32BIT,
969 /*highaddr*/BUS_SPACE_MAXADDR,
970 /*filter*/NULL, /*filterarg*/NULL,
971 /*maxsize*/sc->bufsz, /*nsegments*/1,
972 /*maxsegz*/0x3ffff, /*flags*/0,
973 /*lockfunc*/NULL,
974 /*lockfunc*/NULL,
975 &sc->parent_dmat) != 0) {
976 device_printf(dev, "cmi_attach: Unable to create dma tag\n");
977 goto bad;
978 }
979
980 cmi_power(sc, 0);
981 if (cmi_init(sc))
982 goto bad;
983
984 if (mixer_init(dev, &cmi_mixer_class, sc))
985 goto bad;
986
987 if (pcm_register(dev, sc, 1, 1))
988 goto bad;
989
990 cmi_initsys(sc);
991
992 pcm_addchan(dev, PCMDIR_PLAY, &cmichan_class, sc);
993 pcm_addchan(dev, PCMDIR_REC, &cmichan_class, sc);
994
995 snprintf(status, SND_STATUSLEN, "at io 0x%jx irq %jd %s",
996 rman_get_start(sc->reg), rman_get_start(sc->irq),PCM_KLDSTRING(snd_cmi));
998
999 DEB(printf("cmi_attach: succeeded\n"));
1000 return 0;
1001
1002 bad:
1003 if (sc->parent_dmat)
1004 bus_dma_tag_destroy(sc->parent_dmat);
1005 if (sc->ih)
1006 bus_teardown_intr(dev, sc->irq, sc->ih);
1007 if (sc->irq)
1008 bus_release_resource(dev, SYS_RES_IRQ, sc->irqid, sc->irq);
1009 if (sc->reg)
1010 bus_release_resource(dev, SYS_RES_IOPORT, sc->regid, sc->reg);
1011 if (sc->lock)
1012 snd_mtxfree(sc->lock);
1013 if (sc)
1014 free(sc, M_DEVBUF);
1015
1016 return ENXIO;
1017}
1018
1019static int
1021{
1022 struct sc_info *sc;
1023 int r;
1024
1025 r = pcm_unregister(dev);
1026 if (r) return r;
1027
1028 sc = pcm_getdevinfo(dev);
1029 cmi_uninit(sc);
1030 cmi_power(sc, 3);
1031
1032 bus_dma_tag_destroy(sc->parent_dmat);
1033 bus_teardown_intr(dev, sc->irq, sc->ih);
1034 bus_release_resource(dev, SYS_RES_IRQ, sc->irqid, sc->irq);
1035 if(sc->mpu)
1036 mpu401_uninit(sc->mpu);
1037 bus_release_resource(dev, SYS_RES_IOPORT, sc->regid, sc->reg);
1038 if (sc->mpu_reg)
1039 bus_release_resource(dev, SYS_RES_IOPORT, sc->mpu_regid, sc->mpu_reg);
1040
1041 snd_mtxfree(sc->lock);
1042 free(sc, M_DEVBUF);
1043
1044 return 0;
1045}
1046
1047static int
1049{
1050 struct sc_info *sc = pcm_getdevinfo(dev);
1051
1052 snd_mtxlock(sc->lock);
1053 sc->pch.dma_was_active = cmi_ch0_stop(sc, &sc->pch);
1054 sc->rch.dma_was_active = cmi_ch1_stop(sc, &sc->rch);
1055 cmi_power(sc, 3);
1056 snd_mtxunlock(sc->lock);
1057 return 0;
1058}
1059
1060static int
1062{
1063 struct sc_info *sc = pcm_getdevinfo(dev);
1064
1065 snd_mtxlock(sc->lock);
1066 cmi_power(sc, 0);
1067 if (cmi_init(sc) != 0) {
1068 device_printf(dev, "unable to reinitialize the card\n");
1069 snd_mtxunlock(sc->lock);
1070 return ENXIO;
1071 }
1072
1073 if (mixer_reinit(dev) == -1) {
1074 device_printf(dev, "unable to reinitialize the mixer\n");
1075 snd_mtxunlock(sc->lock);
1076 return ENXIO;
1077 }
1078
1079 if (sc->pch.dma_was_active) {
1080 cmichan_setspeed(NULL, &sc->pch, sc->pch.spd);
1081 cmichan_setformat(NULL, &sc->pch, sc->pch.fmt);
1082 cmi_ch0_start(sc, &sc->pch);
1083 }
1084
1085 if (sc->rch.dma_was_active) {
1086 cmichan_setspeed(NULL, &sc->rch, sc->rch.spd);
1087 cmichan_setformat(NULL, &sc->rch, sc->rch.fmt);
1088 cmi_ch1_start(sc, &sc->rch);
1089 }
1090 snd_mtxunlock(sc->lock);
1091 return 0;
1092}
1093
1094static device_method_t cmi_methods[] = {
1095 DEVMETHOD(device_probe, cmi_probe),
1096 DEVMETHOD(device_attach, cmi_attach),
1097 DEVMETHOD(device_detach, cmi_detach),
1098 DEVMETHOD(device_resume, cmi_resume),
1099 DEVMETHOD(device_suspend, cmi_suspend),
1100 { 0, 0 }
1101};
1102
1103static driver_t cmi_driver = {
1104 "pcm",
1107};
1108
1111MODULE_DEPEND(snd_cmi, midi, 1,1,1);
1112MODULE_VERSION(snd_cmi, 1);
u_int32_t data
Definition: ac97_if.m:60
int regno
Definition: ac97_if.m:53
void * devinfo
Definition: ac97_if.m:47
uint32_t format
Definition: audio_dai_if.m:39
uint32_t speed
Definition: audio_dai_if.m:86
uint32_t rate
Definition: audio_dai_if.m:58
int go
Definition: audio_dai_if.m:64
int sndbuf_alloc(struct snd_dbuf *b, bus_dma_tag_t dmatag, int dmaflags, unsigned int size)
Definition: buffer.c:93
bus_addr_t sndbuf_getbufaddr(struct snd_dbuf *buf)
Definition: buffer.c:66
unsigned int sndbuf_getsize(struct snd_dbuf *b)
Definition: buffer.c:435
int sndbuf_resize(struct snd_dbuf *b, unsigned int blkcnt, unsigned int blksz)
Definition: buffer.c:164
void chn_intr(struct pcm_channel *c)
Definition: channel.c:660
#define PCMDIR_PLAY
Definition: channel.h:339
#define PCMTRIG_START
Definition: channel.h:344
#define PCMTRIG_STOP
Definition: channel.h:347
#define PCMDIR_REC
Definition: channel.h:341
#define PCMTRIG_COMMON(x)
Definition: channel.h:350
#define PCMTRIG_ABORT
Definition: channel.h:348
struct pcm_channel * c
Definition: channel_if.m:106
METHOD int free
Definition: channel_if.m:110
u_int32_t blocksize
Definition: channel_if.m:140
struct pcmchan_matrix * m
Definition: channel_if.m:232
struct snd_dbuf * b
Definition: channel_if.m:105
static void cmi_set4(struct sc_info *sc, int reg, u_int32_t mask)
Definition: cmi.c:205
static int cmi_probe(device_t dev)
Definition: cmi.c:908
static int cmimix_init(struct snd_mixer *m)
Definition: cmi.c:651
static u_int32_t cmichan_setspeed(kobj_t obj, void *data, u_int32_t speed)
Definition: cmi.c:420
static void cmi_wr(struct sc_info *sc, int regno, u_int32_t data, int size)
Definition: cmi.c:167
static u_int32_t cmi_ch1_stop(struct sc_info *sc, struct sc_chinfo *ch)
Definition: cmi.c:310
static void cmi_ch1_start(struct sc_info *sc, struct sc_chinfo *ch)
Definition: cmi.c:298
static unsigned char cmi_mread(struct mpu401 *arg, void *sc, int reg)
Definition: cmi.c:782
#define CMI8738B_PCI_ID
Definition: cmi.c:70
static void cmi_clr4(struct sc_info *sc, int reg, u_int32_t mask)
Definition: cmi.c:195
static void cmi_ch0_start(struct sc_info *sc, struct sc_chinfo *ch)
Definition: cmi.c:273
static kobj_method_t cmi_mixer_methods[]
Definition: cmi.c:769
static int cmi_init(struct sc_info *sc)
Definition: cmi.c:862
CHANNEL_DECLARE(cmichan)
static u_int8_t cmimix_rd(struct sc_info *sc, u_int8_t port)
Definition: cmi.c:610
static DEFINE_CLASS(cmi_mpu, cmi_mpu_methods, 0)
static kobj_method_t cmi_mpu_methods[]
Definition: cmi.c:812
static u_int32_t cmichan_setblocksize(kobj_t obj, void *data, u_int32_t blocksize)
Definition: cmi.c:466
static u_int32_t cmi_rd(struct sc_info *sc, int regno, int size)
Definition: cmi.c:151
#define CMI120_USB_ID
Definition: cmi.c:71
static int cmichan_trigger(kobj_t obj, void *data, int go)
Definition: cmi.c:481
#define CMI8338B_PCI_ID
Definition: cmi.c:68
static u_int32_t cmimix_setrecsrc(struct snd_mixer *m, u_int32_t src)
Definition: cmi.c:723
static u_int32_t cmichan_getptr(kobj_t obj, void *data)
Definition: cmi.c:516
static void * cmichan_init(kobj_t obj, void *devinfo, struct snd_dbuf *b, struct pcm_channel *c, int dir)
Definition: cmi.c:347
static int cmi_suspend(device_t dev)
Definition: cmi.c:1048
#define MIXER_GAIN_REG_RTOL(r)
Definition: cmi.c:648
static int cmi_resume(device_t dev)
Definition: cmi.c:1061
SND_DECLARE_FILE("$FreeBSD$")
static int cmpci_regvalue_to_rate(u_int32_t r)
Definition: cmi.c:242
static device_method_t cmi_methods[]
Definition: cmi.c:1094
#define CMI8338A_PCI_ID
Definition: cmi.c:67
static int cmimix_set(struct snd_mixer *m, unsigned dev, unsigned left, unsigned right)
Definition: cmi.c:675
static void cmi_partial_wr4(struct sc_info *sc, int reg, int shift, u_int32_t mask, u_int32_t val)
Definition: cmi.c:183
#define CMPCI_NON_SB16_CONTROL
Definition: cmi.c:86
DRIVER_MODULE(snd_cmi, pci, cmi_driver, pcm_devclass, 0, 0)
static driver_t cmi_driver
Definition: cmi.c:1103
MODULE_VERSION(snd_cmi, 1)
static int cmi_initsys(struct sc_info *sc)
Definition: cmi.c:752
#define CMI_INTR_PER_BUFFER
Definition: cmi.c:77
static int cmi_muninit(struct mpu401 *arg, void *cookie)
Definition: cmi.c:800
static void cmimix_wr(struct sc_info *sc, u_int8_t port, u_int8_t val)
Definition: cmi.c:603
static void cmi_spdif_speed(struct sc_info *sc, int speed)
Definition: cmi.c:323
static void cmi_uninit(struct sc_info *sc)
Definition: cmi.c:890
static struct pcmchan_caps * cmichan_getcaps(kobj_t obj, void *data)
Definition: cmi.c:582
static u_int32_t cmi_fmt[]
Definition: cmi.c:137
static void cmi_intr(void *data)
Definition: cmi.c:537
static void cmi_mwrite(struct mpu401 *arg, void *sc, int reg, unsigned char b)
Definition: cmi.c:793
struct sb16props cmt[SOUND_MIXER_NRDEVICES]
#define CMI8738_PCI_ID
Definition: cmi.c:69
static int cmi_attach(device_t dev)
Definition: cmi.c:932
static void cmi_midiattach(struct sc_info *sc)
Definition: cmi.c:822
static kobj_method_t cmichan_methods[]
Definition: cmi.c:587
static struct pcmchan_caps cmi_caps
Definition: cmi.c:145
#define DEBMIX(x)
Definition: cmi.c:95
static void cmi_dma_prog(struct sc_info *sc, struct sc_chinfo *ch, u_int32_t base)
Definition: cmi.c:256
#define NUM_CMI_RATES
Definition: cmi.c:219
static int cmi_rates[]
Definition: cmi.c:217
static int cmichan_setformat(kobj_t obj, void *data, u_int32_t format)
Definition: cmi.c:378
static u_int32_t cmi_ch0_stop(struct sc_info *sc, struct sc_chinfo *ch)
Definition: cmi.c:285
static u_int32_t cmpci_rate_to_regvalue(int rate)
Definition: cmi.c:225
static int cmi_detach(device_t dev)
Definition: cmi.c:1020
static void cmi_power(struct sc_info *sc, int state)
Definition: cmi.c:848
#define CMI_DEFAULT_BUFSZ
Definition: cmi.c:74
MODULE_DEPEND(snd_cmi, sound, SOUND_MINVER, SOUND_PREFVER, SOUND_MAXVER)
MIXER_DECLARE(cmi_mixer)
#define DEB(x)
Definition: cmi.c:91
#define CMPCI_REG_AUX_MIC
Definition: cmireg.h:184
#define CMPCI_REG_CH0_FORMAT_SHIFT
Definition: cmireg.h:75
#define CMPCI_SB16_SW_MIC
Definition: cmireg.h:141
#define CMPCI_REG_INTR_STATUS
Definition: cmireg.h:89
#define CMPCI_SB16_SW_LINE
Definition: cmireg.h:147
#define CMPCI_REG_CH1_FORMAT_SHIFT
Definition: cmireg.h:77
#define CMPCI_REG_VMPUSEL_MASK
Definition: cmireg.h:114
#define CMPCI_SB16_MIXER_TREBLE_R
Definition: cmireg.h:165
#define CMPCI_REG_XSPDIF_ENABLE
Definition: cmireg.h:108
#define CMPCI_SB16_MIXER_CDDA_R
Definition: cmireg.h:135
#define CMPCI_REG_DAC_FS_SHIFT
Definition: cmireg.h:69
#define CMPCI_REG_DMA1_BASE
Definition: cmireg.h:195
#define CMPCI_SB16_MIXER_MASTER_R
Definition: cmireg.h:129
#define CMPCI_SB16_MIXER_OUTMIX
Definition: cmireg.h:140
#define CMPCI_REG_MISC
Definition: cmireg.h:116
#define CMPCI_REG_ADC_FS_MASK
Definition: cmireg.h:72
#define CMPCI_SB16_MIXER_BASS_R
Definition: cmireg.h:167
#define CMPCI_REG_TDMA_INTR_ENABLE
Definition: cmireg.h:87
#define CMPCI_SB16_SW_FM
Definition: cmireg.h:150
#define CMPCI_REG_FUNC_0
Definition: cmireg.h:49
#define CMPCI_REG_ADC_FS_SHIFT
Definition: cmireg.h:71
#define CMPCI_REG_CH0_INTR_ENABLE
Definition: cmireg.h:85
#define CMPCI_SB16_MIXER_OUTGAIN_R
Definition: cmireg.h:162
#define CMPCI_REG_UART_ENABLE
Definition: cmireg.h:61
#define CMPCI_REG_CH1_ENABLE
Definition: cmireg.h:55
#define CMPCI_SB16_MIXER_VOICE_R
Definition: cmireg.h:131
#define CMPCI_SB16_MIXER_LINE_R
Definition: cmireg.h:137
#define CMPCI_REG_ANY_INTR
Definition: cmireg.h:103
#define CMPCI_REG_FORMAT_8BIT
Definition: cmireg.h:81
#define CMPCI_REG_CH0_INTR
Definition: cmireg.h:90
#define CMPCI_REG_BUS_AND_DSP_RESET
Definition: cmireg.h:118
#define CMPCI_SB16_MIXER_RESET
Definition: cmireg.h:127
#define CMPCI_SB16_MIXER_INGAIN_R
Definition: cmireg.h:160
#define CMPCI_REG_CH0_FORMAT_MASK
Definition: cmireg.h:76
#define CMPCI_REG_N4SPK3D
Definition: cmireg.h:119
#define CMPCI_REG_SBDATA
Definition: cmireg.h:125
#define CMPCI_SB16_MIXER_FM_R
Definition: cmireg.h:133
#define CMPCI_REG_CH1_FORMAT_MASK
Definition: cmireg.h:78
#define CMPCI_REG_CH0_RESET
Definition: cmireg.h:56
#define CMPCI_REG_CH1_INTR
Definition: cmireg.h:91
#define CMPCI_SB16_MIXER_FM_SRC_R
Definition: cmireg.h:153
#define CMPCI_REG_INTR_CTRL
Definition: cmireg.h:84
#define CMPCI_REG_CH1_RESET
Definition: cmireg.h:57
#define CMPCI_REG_SPDIF0_ENABLE
Definition: cmireg.h:67
#define CMPCI_REG_POWER_DOWN
Definition: cmireg.h:117
#define CMPCI_REG_SPDIF_48K
Definition: cmireg.h:123
#define CMPCI_REG_CH0_ENABLE
Definition: cmireg.h:54
#define CMPCI_REG_FORMAT_16BIT
Definition: cmireg.h:82
#define CMPCI_SB16_MIXER_ADCMIX_L
Definition: cmireg.h:151
#define CMPCI_REG_DMA0_BASE
Definition: cmireg.h:192
#define CMPCI_REG_DAC_FS_MASK
Definition: cmireg.h:70
#define CMPCI_REG_SPDIF_LOOP
Definition: cmireg.h:66
#define CMPCI_REG_FORMAT_STEREO
Definition: cmireg.h:80
#define CMPCI_REG_CHANNEL_FORMAT
Definition: cmireg.h:74
#define CMPCI_SB16_MIXER_ADCMIX_R
Definition: cmireg.h:152
#define CMPCI_REG_FUNC_1
Definition: cmireg.h:59
#define CMPCI_SB16_MIXER_SRC_R_TO_L(v)
Definition: cmireg.h:157
#define CMPCI_REG_CH1_DIR
Definition: cmireg.h:51
#define CMPCI_SB16_MIXER_MIC_SRC
Definition: cmireg.h:156
#define CMPCI_REG_W_SPDIF_48L
Definition: cmireg.h:120
#define CMPCI_REG_CH0_DIR
Definition: cmireg.h:50
#define CMPCI_REG_LEGACY_CTRL
Definition: cmireg.h:105
#define CMPCI_SB16_MIXER_SPEAKER
Definition: cmireg.h:139
#define CMPCI_REG_VMPUSEL_SHIFT
Definition: cmireg.h:113
#define CMPCI_SB16_MIXER_MIC
Definition: cmireg.h:138
#define CMPCI_SB16_SW_CD
Definition: cmireg.h:144
#define CMPCI_REG_FORMAT_MONO
Definition: cmireg.h:79
#define CMPCI_REG_CH1_INTR_ENABLE
Definition: cmireg.h:86
#define CMPCI_SB16_MIXER_CD_SRC_R
Definition: cmireg.h:155
#define CMPCI_REG_SBADDR
Definition: cmireg.h:126
#define CMPCI_SB16_MIXER_LINE_SRC_R
Definition: cmireg.h:154
#define CMPCI_REG_SPDIF1_ENABLE
Definition: cmireg.h:68
int max
Definition: dsp.c:392
unsigned stereo
Definition: es137x.c:262
unsigned right
Definition: es137x.c:261
unsigned left
Definition: es137x.c:260
uint16_t base
Definition: hdaa.c:124
uint8_t mask
Definition: hdac.c:212
uint8_t reg
Definition: hdac.c:211
int dir
Definition: hdac_if.m:45
uint8_t size
uint8_t r
#define KOBJMETHOD_END
Definition: midi.c:76
static int mixer_setrecsrc(struct snd_mixer *mixer, u_int32_t src)
Definition: mixer.c:373
int mixer_init(device_t dev, kobj_class_t cls, void *devinfo)
Definition: mixer.c:725
static int mixer_set(struct snd_mixer *m, u_int dev, u_int32_t muted, u_int lev)
Definition: mixer.c:247
void mix_setdevs(struct snd_mixer *m, u_int32_t v)
Definition: mixer.c:489
int mixer_reinit(device_t dev)
Definition: mixer.c:860
void * mix_getdevinfo(struct snd_mixer *m)
Definition: mixer.c:645
void mix_setrecdevs(struct snd_mixer *m, u_int32_t v)
Record mask of available recording devices.
Definition: mixer.c:529
unsigned dev
Definition: mixer_if.m:59
u_int32_t src
Definition: mixer_if.m:66
int mpu401_uninit(struct mpu401 *m)
Definition: mpu401.c:208
struct mpu401 * mpu401_init(kobj_class_t cls, void *cookie, driver_intr_t softintr, mpu401_intr_t **cb)
Definition: mpu401.c:177
int mpu401_intr_t(struct mpu401 *_obj)
Definition: mpu401.h:36
bool * status
int state
u_int32_t val
#define PCIR_BAR(x)
void * snd_mtxcreate(const char *desc, const char *type)
Definition: sound.c:88
void * pcm_getdevinfo(device_t dev)
Definition: sound.c:832
int pcm_setstatus(device_t dev, char *str)
Definition: sound.c:766
devclass_t pcm_devclass
Definition: sound.c:49
void snd_mtxfree(void *m)
Definition: sound.c:98
int pcm_addchan(device_t dev, int dir, kobj_class_t cls, void *devinfo)
Definition: sound.c:692
int pcm_unregister(device_t dev)
Definition: sound.c:1170
int pcm_register(device_t dev, void *devinfo, int numplay, int numrec)
Definition: sound.c:1080
int snd_setup_intr(device_t dev, struct resource *res, int flags, driver_intr_t hand, void *param, void **cookiep)
Definition: sound.c:117
unsigned int pcm_getbuffersize(device_t dev, unsigned int minbufsz, unsigned int deflt, unsigned int maxbufsz)
Definition: sound.c:840
#define PCM_KLDSTRING(a)
Definition: sound.h:619
#define SND_FORMAT(f, c, e)
Definition: sound.h:238
#define SOUND_PREFVER
Definition: sound.h:103
#define SOUND_MAXVER
Definition: sound.h:104
#define DSP_DEFAULT_SPEED
Definition: sound.h:295
#define snd_mtxlock(m)
Definition: sound.h:347
#define AFMT_CHANNEL(v)
Definition: sound.h:227
#define snd_mtxunlock(m)
Definition: sound.h:348
#define SOUND_MINVER
Definition: sound.h:102
#define PCM_SOFTC_SIZE
Definition: sound.h:96
#define SND_STATUSLEN
Definition: sound.h:98
Definition: mpu401.c:76
u_int8_t rec
Definition: cmi.c:619
u_int8_t rreg
Definition: als4000.c:534
u_int8_t bits
Definition: als4000.c:535
u_int8_t oselect
Definition: als4000.c:536
u_int8_t stereo
Definition: cmi.c:618
u_int8_t iselect
Definition: als4000.c:537
u_int32_t dma_was_active
Definition: als4000.c:71
u_int32_t fmt
Definition: cmi.c:107
u_int32_t spd
Definition: cmi.c:107
struct pcm_channel * channel
Definition: als4000.c:68
u_int32_t bps
Definition: als4000.c:70
struct sc_info * parent
Definition: als4000.c:67
u_int32_t dma_active
Definition: als4000.c:71
u_int32_t phys_buf
Definition: als4000.c:70
int dir
Definition: als4000.c:73
struct snd_dbuf * buffer
Definition: als4000.c:69
bus_space_tag_t st
Definition: als4000.c:78
mpu401_intr_t * mpu_intr
Definition: cmi.c:128
struct mtx * lock
Definition: als4000.c:84
unsigned int bufsz
Definition: als4000.c:86
int mpu_regid
Definition: cmi.c:130
struct resource * irq
Definition: als4000.c:81
bus_space_tag_t mpu_bt
Definition: cmi.c:131
device_t dev
Definition: als4000.c:77
int spdif_enabled
Definition: cmi.c:123
int irqid
Definition: als4000.c:82
struct resource * reg
Definition: als4000.c:81
struct sc_chinfo pch rch
Definition: als4000.c:87
void * ih
Definition: als4000.c:83
bus_space_handle_t mpu_bh
Definition: cmi.c:132
int regid
Definition: als4000.c:82
bus_dma_tag_t parent_dmat
Definition: als4000.c:80
struct sc_chinfo pch
Definition: cs4281.c:99
struct mpu401 * mpu
Definition: cmi.c:127
struct resource * mpu_reg
Definition: cmi.c:129
struct sc_chinfo ch[3]
Definition: ich.c:192
bus_space_handle_t sh
Definition: als4000.c:79