Lines Matching +full:pcm +full:- +full:interface +full:- +full:rate

1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
5 * Copyright (c) 2003-2007 Yuriy Tsibizov <yuriy.tsibizov@gfk.ru>
46 #include <dev/sound/pcm/sound.h>
47 #include <dev/sound/pcm/ac97.h>
63 struct emu_pcm_info *pcm; member
81 struct emu_pcm_info *pcm; member
166 static uint32_t emu_pcm_intr(void *pcm, uint32_t stat);
177 [SOUND_MIXER_LINE2] = {1, 1, 4}, /* in4 Line-In2 */
178 [SOUND_MIXER_DIGITAL3] = {1, 1, 5}, /* in5 on-card SPDIF */
187 [SOUND_MIXER_VOLUME] = {1, 0, (-1)},
188 [SOUND_MIXER_PCM] = {1, 0, (-1)},
194 [SOUND_MIXER_LINE2] = {1, 1, 4}, /* in4 Line-In2 */
195 [SOUND_MIXER_DIGITAL3] = {1, 1, 5}, /* in5 on-card SPDIF */
212 if (sc->route == RT_FRONT) { in emu_dspmixer_init()
214 if ((sc->ac97_mixerclass != NULL) && (sc->codec != NULL)) { in emu_dspmixer_init()
215 sc->sm = mixer_create(sc->dev, sc->ac97_mixerclass, sc->codec, "ac97"); in emu_dspmixer_init()
216 if (sc->sm != NULL) { in emu_dspmixer_init()
217 p = mix_getdevs(sc->sm); in emu_dspmixer_init()
218 r = mix_getrecdevs(sc->sm); in emu_dspmixer_init()
222 sc->ac97_playdevs = p; in emu_dspmixer_init()
223 sc->ac97_recdevs = r; in emu_dspmixer_init()
230 if (sc->route == RT_FRONT) { in emu_dspmixer_init()
231 if (sc->is_emu10k1) { in emu_dspmixer_init()
262 if (sc->sm != NULL) { in emu_dspmixer_uninit()
263 err = mixer_delete(sc->sm); in emu_dspmixer_uninit()
266 sc->sm = NULL; in emu_dspmixer_uninit()
280 switch (sc->route) { in emu_dspmixer_set()
282 if (sc->sm != NULL) in emu_dspmixer_set()
283 mix_set(sc->sm, dev, left, right); in emu_dspmixer_set()
284 if (sc->mch_disabled) { in emu_dspmixer_set()
285 /* In emu10k1 case PCM volume does not affect in emu_dspmixer_set()
289 if (sc->is_emu10k1) { in emu_dspmixer_set()
290 sc->emu10k1_volcache[0][0] = left; in emu_dspmixer_set()
291 left = left * sc->emu10k1_volcache[1][0] / 100; in emu_dspmixer_set()
292 sc->emu10k1_volcache[0][1] = right; in emu_dspmixer_set()
293 right = right * sc->emu10k1_volcache[1][1] / 100; in emu_dspmixer_set()
296 emumix_set_volume(sc->card, M_MASTER_REAR_L, left); in emu_dspmixer_set()
297 emumix_set_volume(sc->card, M_MASTER_REAR_R, right); in emu_dspmixer_set()
298 if (!sc->is_emu10k1) { in emu_dspmixer_set()
299 emumix_set_volume(sc->card, M_MASTER_CENTER, (left+right)/2); in emu_dspmixer_set()
300 emumix_set_volume(sc->card, M_MASTER_SUBWOOFER, (left+right)/2); in emu_dspmixer_set()
306 emumix_set_volume(sc->card, M_MASTER_REAR_L, left); in emu_dspmixer_set()
307 emumix_set_volume(sc->card, M_MASTER_REAR_R, right); in emu_dspmixer_set()
310 emumix_set_volume(sc->card, M_MASTER_CENTER, (left+right)/2); in emu_dspmixer_set()
313 emumix_set_volume(sc->card, M_MASTER_SUBWOOFER, (left+right)/2); in emu_dspmixer_set()
318 switch (sc->route) { in emu_dspmixer_set()
320 if (sc->sm != NULL) in emu_dspmixer_set()
321 mix_set(sc->sm, dev, left, right); in emu_dspmixer_set()
322 if (sc->mch_disabled) { in emu_dspmixer_set()
324 if (sc->is_emu10k1) { in emu_dspmixer_set()
325 sc->emu10k1_volcache[1][0] = left; in emu_dspmixer_set()
326 left = left * sc->emu10k1_volcache[0][0] / 100; in emu_dspmixer_set()
327 sc->emu10k1_volcache[1][1] = right; in emu_dspmixer_set()
328 right = right * sc->emu10k1_volcache[0][1] / 100; in emu_dspmixer_set()
330 emumix_set_volume(sc->card, M_MASTER_REAR_L, left); in emu_dspmixer_set()
331 emumix_set_volume(sc->card, M_MASTER_REAR_R, right); in emu_dspmixer_set()
333 if (!sc->is_emu10k1) { in emu_dspmixer_set()
334 emumix_set_volume(sc->card, M_MASTER_CENTER, (left+right)/2); in emu_dspmixer_set()
335 emumix_set_volume(sc->card, M_MASTER_SUBWOOFER, (left+right)/2); in emu_dspmixer_set()
341 emumix_set_volume(sc->card, M_FX2_REAR_L, left); in emu_dspmixer_set()
342 emumix_set_volume(sc->card, M_FX3_REAR_R, right); in emu_dspmixer_set()
345 emumix_set_volume(sc->card, M_FX4_CENTER, (left+right)/2); in emu_dspmixer_set()
348 emumix_set_volume(sc->card, M_FX5_SUBWOOFER, (left+right)/2); in emu_dspmixer_set()
353 emumix_set_volume(sc->card, M_IN1_FRONT_L, left); in emu_dspmixer_set()
354 emumix_set_volume(sc->card, M_IN1_FRONT_R, right); in emu_dspmixer_set()
357 if (sc->is_emu10k1) { in emu_dspmixer_set()
359 emumix_set_volume(sc->card, M_IN3_FRONT_L, left); in emu_dspmixer_set()
360 emumix_set_volume(sc->card, M_IN3_FRONT_R, right); in emu_dspmixer_set()
363 emumix_set_volume(sc->card, M_IN2_FRONT_L, left); in emu_dspmixer_set()
364 emumix_set_volume(sc->card, M_IN2_FRONT_R, right); in emu_dspmixer_set()
367 case SOUND_MIXER_LINE2: /* Line-In2, in4 */ in emu_dspmixer_set()
368 emumix_set_volume(sc->card, M_IN4_FRONT_L, left); in emu_dspmixer_set()
369 emumix_set_volume(sc->card, M_IN4_FRONT_R, right); in emu_dspmixer_set()
371 case SOUND_MIXER_DIGITAL3: /* on-card SPDIF, in5 */ in emu_dspmixer_set()
372 emumix_set_volume(sc->card, M_IN5_FRONT_L, left); in emu_dspmixer_set()
373 emumix_set_volume(sc->card, M_IN5_FRONT_R, right); in emu_dspmixer_set()
376 emumix_set_volume(sc->card, M_IN6_FRONT_L, left); in emu_dspmixer_set()
377 emumix_set_volume(sc->card, M_IN6_FRONT_R, right); in emu_dspmixer_set()
380 if (sc->sm != NULL) { in emu_dspmixer_set()
382 emumix_set_volume(sc->card, M_IN0_FRONT_L, 100); in emu_dspmixer_set()
383 emumix_set_volume(sc->card, M_IN0_FRONT_R, 100); in emu_dspmixer_set()
384 mix_set(sc->sm, dev, left, right); in emu_dspmixer_set()
386 device_printf(sc->dev, "mixer error: unknown device %d\n", dev); in emu_dspmixer_set()
404 if (sc->sm != NULL) in emu_dspmixer_setrecsrc()
405 if ((src & sc->ac97_recdevs) !=0) in emu_dspmixer_setrecsrc()
406 if (mix_setrecsrc(sc->sm, src & sc->ac97_recdevs) == 0) { in emu_dspmixer_setrecsrc()
407 recmask |= (src & sc->ac97_recdevs); in emu_dspmixer_setrecsrc()
412 if (sc->is_emu10k1) { in emu_dspmixer_setrecsrc()
431 emumix_set_volume(sc->card, M_IN0_REC_L, input[0] == 1 ? 100 : 0); in emu_dspmixer_setrecsrc()
432 emumix_set_volume(sc->card, M_IN0_REC_R, input[0] == 1 ? 100 : 0); in emu_dspmixer_setrecsrc()
434 emumix_set_volume(sc->card, M_IN1_REC_L, input[1] == 1 ? 100 : 0); in emu_dspmixer_setrecsrc()
435 emumix_set_volume(sc->card, M_IN1_REC_R, input[1] == 1 ? 100 : 0); in emu_dspmixer_setrecsrc()
437 if (!sc->is_emu10k1) { in emu_dspmixer_setrecsrc()
438 emumix_set_volume(sc->card, M_IN2_REC_L, input[2] == 1 ? 100 : 0); in emu_dspmixer_setrecsrc()
439 emumix_set_volume(sc->card, M_IN2_REC_R, input[2] == 1 ? 100 : 0); in emu_dspmixer_setrecsrc()
442 if (sc->is_emu10k1) { in emu_dspmixer_setrecsrc()
443 emumix_set_volume(sc->card, M_IN3_REC_L, input[3] == 1 ? 100 : 0); in emu_dspmixer_setrecsrc()
444 emumix_set_volume(sc->card, M_IN3_REC_R, input[3] == 1 ? 100 : 0); in emu_dspmixer_setrecsrc()
447 emumix_set_volume(sc->card, M_IN4_REC_L, input[4] == 1 ? 100 : 0); in emu_dspmixer_setrecsrc()
448 emumix_set_volume(sc->card, M_IN4_REC_R, input[4] == 1 ? 100 : 0); in emu_dspmixer_setrecsrc()
450 emumix_set_volume(sc->card, M_IN5_REC_L, input[5] == 1 ? 100 : 0); in emu_dspmixer_setrecsrc()
451 emumix_set_volume(sc->card, M_IN5_REC_R, input[5] == 1 ? 100 : 0); in emu_dspmixer_setrecsrc()
453 emumix_set_volume(sc->card, M_IN6_REC_L, input[6] == 1 ? 100 : 0); in emu_dspmixer_setrecsrc()
454 emumix_set_volume(sc->card, M_IN6_REC_R, input[6] == 1 ? 100 : 0); in emu_dspmixer_setrecsrc()
458 emumix_set_volume(sc->card, M_FX0_REC_L, emumix_get_volume(sc->card, M_FX0_FRONT_L)); in emu_dspmixer_setrecsrc()
459 emumix_set_volume(sc->card, M_FX1_REC_R, emumix_get_volume(sc->card, M_FX1_FRONT_R)); in emu_dspmixer_setrecsrc()
461 emumix_set_volume(sc->card, M_FX0_REC_L, 0); in emu_dspmixer_setrecsrc()
462 emumix_set_volume(sc->card, M_FX1_REC_R, 0); in emu_dspmixer_setrecsrc()
509 * to change some DSP controls via AC97 mixer interface. This includes:
510 * - master volume controls MASTER_FRONT_[R|L]
511 * - pcm volume controls FX[0|1]_FRONT_[R|L]
512 * - rec volume controls MASTER_REC_[R|L]
520 #define BIT4_TO100(x) (100-(x)*100/(0x0f))
521 #define BIT6_TO100(x) (100-(x)*100/(0x3f))
522 #define BIT4_TO255(x) (255-(x)*255/(0x0f))
523 #define BIT6_TO255(x) (255-(x)*255/(0x3f))
524 #define V100_TOBIT6(x) (0x3f*(100-x)/100)
525 #define V100_TOBIT4(x) (0x0f*(100-x)/100)
540 emulated = sc->ac97_state[AC97_MIX_MASTER]; in emu_ac97_read_emulation()
544 emulated = sc->ac97_state[AC97_MIX_PCM]; in emu_ac97_read_emulation()
552 emulated = sc->ac97_state[AC97_MIX_RGAIN]; in emu_ac97_read_emulation()
557 emu_wr(sc->card, EMU_AC97ADDR, regno, 1); in emu_ac97_read_emulation()
558 tmp = emu_rd(sc->card, EMU_AC97DATA, 2); in emu_ac97_read_emulation()
577 emu_left = BIT6_TO100(left); /* We show us as 6-bit AC97 mixer */ in emu_ac97_write_emulation()
587 emumix_set_volume(sc->card, M_MASTER_FRONT_L, emu_left); in emu_ac97_write_emulation()
588 emumix_set_volume(sc->card, M_MASTER_FRONT_R, emu_right); in emu_ac97_write_emulation()
589 sc->ac97_state[AC97_MIX_MASTER] = data & (0x8000 | 0x3f3f); in emu_ac97_write_emulation()
592 case AC97_MIX_PCM: /* PCM OUT VOL */ in emu_ac97_write_emulation()
593 emumix_set_volume(sc->card, M_FX0_FRONT_L, emu_left); in emu_ac97_write_emulation()
594 emumix_set_volume(sc->card, M_FX1_FRONT_R, emu_right); in emu_ac97_write_emulation()
595 sc->ac97_state[AC97_MIX_PCM] = data & (0x8000 | 0x3f3f); in emu_ac97_write_emulation()
596 data = 0x8000; /* Mute AC97 PCM out */ in emu_ac97_write_emulation()
600 * PCM recording source is set to "stereo mix" (labeled "vol" in emu_ac97_write_emulation()
601 * in mixer). There is no 'playback' from AC97 codec - in emu_ac97_write_emulation()
608 emu_left = BIT4_TO100(left); /* rgain is 4-bit */ in emu_ac97_write_emulation()
610 emumix_set_volume(sc->card, M_MASTER_REC_L, 100-emu_left); in emu_ac97_write_emulation()
611 emumix_set_volume(sc->card, M_MASTER_REC_R, 100-emu_right); in emu_ac97_write_emulation()
618 sc->ac97_state[AC97_MIX_RGAIN] = data & (0x8000 | 0x0f0f); in emu_ac97_write_emulation()
623 emu_wr(sc->card, EMU_AC97ADDR, regno, 1); in emu_ac97_write_emulation()
624 emu_wr(sc->card, EMU_AC97DATA, data, 2); in emu_ac97_write_emulation()
659 KASSERT(sc->card != NULL, ("emu_rdcd: no soundcard")); in emu_rdcd()
660 emu_wr(sc->card, EMU_AC97ADDR, regno, 1); in emu_rdcd()
661 rd = emu_rd(sc->card, EMU_AC97DATA, 2); in emu_rdcd()
670 KASSERT(sc->card != NULL, ("emu_wrcd: no soundcard")); in emu_wrcd()
671 emu_wr(sc->card, EMU_AC97ADDR, regno, 1); in emu_wrcd()
672 emu_wr(sc->card, EMU_AC97DATA, data, 2); in emu_wrcd()
713 KASSERT(sc->card != NULL, ("empchan_init: no soundcard")); in emupchan_init()
715 if (sc->pnum >= MAX_CHANNELS) in emupchan_init()
717 ch = &(sc->pch[sc->pnum++]); in emupchan_init()
718 ch->buffer = b; in emupchan_init()
719 ch->pcm = sc; in emupchan_init()
720 ch->channel = c; in emupchan_init()
721 ch->blksz = sc->bufsz; in emupchan_init()
722 ch->fmt = SND_FORMAT(AFMT_U8, 1, 0); in emupchan_init()
723 ch->spd = 8000; in emupchan_init()
724 ch->master = emu_valloc(sc->card); in emupchan_init()
729 ch->slave = emu_valloc(sc->card); in emupchan_init()
730 ch->timer = emu_timer_create(sc->card); in emupchan_init()
731 r = (emu_vinit(sc->card, ch->master, ch->slave, EMU_PLAY_BUFSZ, ch->buffer)) ? NULL : ch; in emupchan_init()
739 struct emu_pcm_info *sc = ch->pcm; in emupchan_free()
741 emu_timer_clear(sc->card, ch->timer); in emupchan_free()
742 if (ch->slave != NULL) in emupchan_free()
743 emu_vfree(sc->card, ch->slave); in emupchan_free()
744 emu_vfree(sc->card, ch->master); in emupchan_free()
753 ch->fmt = format; in emupchan_setformat()
762 ch->spd = speed; in emupchan_setspeed()
763 return (ch->spd); in emupchan_setspeed()
770 struct emu_pcm_info *sc = ch->pcm; in emupchan_setblocksize()
772 if (blocksize > ch->pcm->bufsz) in emupchan_setblocksize()
773 blocksize = ch->pcm->bufsz; in emupchan_setblocksize()
774 snd_mtxlock(sc->lock); in emupchan_setblocksize()
775 ch->blksz = blocksize; in emupchan_setblocksize()
776 emu_timer_set(sc->card, ch->timer, ch->blksz / sndbuf_getalign(ch->buffer)); in emupchan_setblocksize()
777 snd_mtxunlock(sc->lock); in emupchan_setblocksize()
778 return (ch->blksz); in emupchan_setblocksize()
785 struct emu_pcm_info *sc = ch->pcm; in emupchan_trigger()
790 snd_mtxlock(sc->lock); /* XXX can we trigger on parallel threads ? */ in emupchan_trigger()
792 emu_vsetup(ch->master, ch->fmt, ch->spd); in emupchan_trigger()
793 if (AFMT_CHANNEL(ch->fmt) > 1) in emupchan_trigger()
794 emu_vroute(sc->card, &(sc->rt), ch->master); in emupchan_trigger()
796 emu_vroute(sc->card, &(sc->rt_mono), ch->master); in emupchan_trigger()
797 emu_vwrite(sc->card, ch->master); in emupchan_trigger()
798 emu_timer_set(sc->card, ch->timer, ch->blksz / sndbuf_getalign(ch->buffer)); in emupchan_trigger()
799 emu_timer_enable(sc->card, ch->timer, 1); in emupchan_trigger()
801 /* PCM interrupt handler will handle PCMTRIG_STOP event */ in emupchan_trigger()
802 ch->run = (go == PCMTRIG_START) ? 1 : 0; in emupchan_trigger()
803 emu_vtrigger(sc->card, ch->master, ch->run); in emupchan_trigger()
804 snd_mtxunlock(sc->lock); in emupchan_trigger()
812 struct emu_pcm_info *sc = ch->pcm; in emupchan_getptr()
815 r = emu_vpos(sc->card, ch->master); in emupchan_getptr()
824 struct emu_pcm_info *sc = ch->pcm; in emupchan_getcaps()
826 switch (sc->route) { in emupchan_getcaps()
863 ch = &sc->rch_adc; in emurchan_init()
864 ch->buffer = b; in emurchan_init()
865 ch->pcm = sc; in emurchan_init()
866 ch->channel = c; in emurchan_init()
867 ch->blksz = sc->bufsz / 2; /* We rise interrupt for half-full buffer */ in emurchan_init()
868 ch->fmt = SND_FORMAT(AFMT_U8, 1, 0); in emurchan_init()
869 ch->spd = 8000; in emurchan_init()
870 ch->idxreg = sc->is_emu10k1 ? EMU_ADCIDX : EMU_A_ADCIDX; in emurchan_init()
871 ch->basereg = EMU_ADCBA; in emurchan_init()
872 ch->sizereg = EMU_ADCBS; in emurchan_init()
873 ch->setupreg = EMU_ADCCR; in emurchan_init()
874 ch->irqmask = EMU_INTE_ADCBUFENABLE; in emurchan_init()
875 ch->iprmask = EMU_IPR_ADCBUFFULL | EMU_IPR_ADCBUFHALFFULL; in emurchan_init()
877 if (sndbuf_alloc(ch->buffer, emu_gettag(sc->card), 0, sc->bufsz) != 0) in emurchan_init()
880 ch->timer = emu_timer_create(sc->card); in emurchan_init()
881 emu_wrptr(sc->card, 0, ch->basereg, sndbuf_getbufaddr(ch->buffer)); in emurchan_init()
882 emu_wrptr(sc->card, 0, ch->sizereg, 0); /* off */ in emurchan_init()
891 struct emu_pcm_info *sc = ch->pcm; in emurchan_free()
893 emu_timer_clear(sc->card, ch->timer); in emurchan_free()
902 ch->fmt = format; in emurchan_setformat()
911 if (ch->pcm->is_emu10k1) { in emurchan_setspeed()
916 ch->spd = speed; in emurchan_setspeed()
917 return (ch->spd); in emurchan_setspeed()
924 struct emu_pcm_info *sc = ch->pcm; in emurchan_setblocksize()
926 ch->blksz = blocksize; in emurchan_setblocksize()
932 if (ch->blksz < (ch->pcm->bufsz / 2)) { in emurchan_setblocksize()
933 emu_timer_set(sc->card, ch->timer, ch->blksz / sndbuf_getalign(ch->buffer)); in emurchan_setblocksize()
934 emu_timer_enable(sc->card, ch->timer, 1); in emurchan_setblocksize()
936 emu_timer_enable(sc->card, ch->timer, 0); in emurchan_setblocksize()
938 return (ch->blksz); in emurchan_setblocksize()
945 struct emu_pcm_info *sc = ch->pcm; in emurchan_trigger()
951 switch (sc->bufsz) { in emurchan_trigger()
971 snd_mtxlock(sc->lock); in emurchan_trigger()
974 ch->run = 1; in emurchan_trigger()
975 emu_wrptr(sc->card, 0, ch->sizereg, sz); in emurchan_trigger()
976 val = sc->is_emu10k1 ? EMU_ADCCR_LCHANENABLE : EMU_A_ADCCR_LCHANENABLE; in emurchan_trigger()
977 if (AFMT_CHANNEL(ch->fmt) > 1) in emurchan_trigger()
978 val |= sc->is_emu10k1 ? EMU_ADCCR_RCHANENABLE : EMU_A_ADCCR_RCHANENABLE; in emurchan_trigger()
979 val |= sc->is_emu10k1 ? emu_k1_recval(ch->spd) : emu_k2_recval(ch->spd); in emurchan_trigger()
980 emu_wrptr(sc->card, 0, ch->setupreg, 0); in emurchan_trigger()
981 emu_wrptr(sc->card, 0, ch->setupreg, val); in emurchan_trigger()
982 ch->ihandle = emu_intr_register(sc->card, ch->irqmask, ch->iprmask, &emu_pcm_intr, sc); in emurchan_trigger()
987 ch->run = 0; in emurchan_trigger()
988 emu_wrptr(sc->card, 0, ch->sizereg, 0); in emurchan_trigger()
989 if (ch->setupreg) in emurchan_trigger()
990 emu_wrptr(sc->card, 0, ch->setupreg, 0); in emurchan_trigger()
991 (void)emu_intr_unregister(sc->card, ch->ihandle); in emurchan_trigger()
1000 snd_mtxunlock(sc->lock); in emurchan_trigger()
1009 struct emu_pcm_info *sc = ch->pcm; in emurchan_getptr()
1012 r = emu_rdptr(sc->card, 0, ch->idxreg) & 0x0000ffff; in emurchan_getptr()
1046 ch = &(sc->rch_efx); in emufxrchan_init()
1047 ch->fmt = SND_FORMAT(AFMT_S16_LE, 1, 0); in emufxrchan_init()
1048 ch->spd = sc->is_emu10k1 ? 48000*32 : 48000 * 64; in emufxrchan_init()
1049 ch->idxreg = EMU_FXIDX; in emufxrchan_init()
1050 ch->basereg = EMU_FXBA; in emufxrchan_init()
1051 ch->sizereg = EMU_FXBS; in emufxrchan_init()
1052 ch->irqmask = EMU_INTE_EFXBUFENABLE; in emufxrchan_init()
1053 ch->iprmask = EMU_IPR_EFXBUFFULL | EMU_IPR_EFXBUFHALFFULL; in emufxrchan_init()
1054 ch->buffer = b; in emufxrchan_init()
1055 ch->pcm = sc; in emufxrchan_init()
1056 ch->channel = c; in emufxrchan_init()
1057 ch->blksz = sc->bufsz / 2; in emufxrchan_init()
1059 if (sndbuf_alloc(ch->buffer, emu_gettag(sc->card), 0, sc->bufsz) != 0) in emufxrchan_init()
1062 emu_wrptr(sc->card, 0, ch->basereg, sndbuf_getbufaddr(ch->buffer)); in emufxrchan_init()
1063 emu_wrptr(sc->card, 0, ch->sizereg, 0); /* off */ in emufxrchan_init()
1080 /* FIXED RATE CHANNEL */ in emufxrchan_setspeed()
1081 return (ch->spd); in emufxrchan_setspeed()
1089 ch->blksz = blocksize; in emufxrchan_setblocksize()
1096 if (ch->blksz < (ch->pcm->bufsz / 2)) in emufxrchan_setblocksize()
1097 ch->blksz = ch->pcm->bufsz / 2; in emufxrchan_setblocksize()
1098 return (ch->blksz); in emufxrchan_setblocksize()
1105 struct emu_pcm_info *sc = ch->pcm; in emufxrchan_trigger()
1111 switch (sc->bufsz) { in emufxrchan_trigger()
1131 snd_mtxlock(sc->lock); in emufxrchan_trigger()
1134 ch->run = 1; in emufxrchan_trigger()
1135 emu_wrptr(sc->card, 0, ch->sizereg, sz); in emufxrchan_trigger()
1136 ch->ihandle = emu_intr_register(sc->card, ch->irqmask, ch->iprmask, &emu_pcm_intr, sc); in emufxrchan_trigger()
1143 if (sc->is_emu10k1) { in emufxrchan_trigger()
1144 emu_wrptr(sc->card, 0, EMU_FXWC, 0xffffffff); in emufxrchan_trigger()
1146 emu_wrptr(sc->card, 0, EMU_A_FXWC1, 0xffffffff); in emufxrchan_trigger()
1147 emu_wrptr(sc->card, 0, EMU_A_FXWC2, 0xffffffff); in emufxrchan_trigger()
1153 ch->run = 0; in emufxrchan_trigger()
1154 if (sc->is_emu10k1) { in emufxrchan_trigger()
1155 emu_wrptr(sc->card, 0, EMU_FXWC, 0x0); in emufxrchan_trigger()
1157 emu_wrptr(sc->card, 0, EMU_A_FXWC1, 0x0); in emufxrchan_trigger()
1158 emu_wrptr(sc->card, 0, EMU_A_FXWC2, 0x0); in emufxrchan_trigger()
1160 emu_wrptr(sc->card, 0, ch->sizereg, 0); in emufxrchan_trigger()
1161 (void)emu_intr_unregister(sc->card, ch->ihandle); in emufxrchan_trigger()
1170 snd_mtxunlock(sc->lock); in emufxrchan_trigger()
1179 struct emu_pcm_info *sc = ch->pcm; in emufxrchan_getptr()
1182 r = emu_rdptr(sc->card, 0, ch->idxreg) & 0x0000ffff; in emufxrchan_getptr()
1191 struct emu_pcm_info *sc = ch->pcm; in emufxrchan_getcaps()
1193 if (sc->is_emu10k1) in emufxrchan_getcaps()
1203 struct emu_pcm_info *sc = ch->pcm; in emufxrchan_getrates()
1205 if (sc->is_emu10k1) in emufxrchan_getrates()
1227 emu_pcm_intr(void *pcm, uint32_t stat) in emu_pcm_intr() argument
1229 struct emu_pcm_info *sc = (struct emu_pcm_info *)pcm; in emu_pcm_intr()
1235 snd_mtxlock(sc->lock); in emu_pcm_intr()
1240 if (sc->pch[i].channel) { in emu_pcm_intr()
1241 if (sc->pch[i].run == 1) { in emu_pcm_intr()
1242 snd_mtxunlock(sc->lock); in emu_pcm_intr()
1243 chn_intr(sc->pch[i].channel); in emu_pcm_intr()
1244 snd_mtxlock(sc->lock); in emu_pcm_intr()
1246 emu_timer_enable(sc->card, sc->pch[i].timer, 0); in emu_pcm_intr()
1248 /* ADC may install timer to get low-latency interrupts */ in emu_pcm_intr()
1249 if ((sc->rch_adc.channel) && (sc->rch_adc.run)) { in emu_pcm_intr()
1250 snd_mtxunlock(sc->lock); in emu_pcm_intr()
1251 chn_intr(sc->rch_adc.channel); in emu_pcm_intr()
1252 snd_mtxlock(sc->lock); in emu_pcm_intr()
1262 if (sc->rch_adc.channel) { in emu_pcm_intr()
1263 snd_mtxunlock(sc->lock); in emu_pcm_intr()
1264 chn_intr(sc->rch_adc.channel); in emu_pcm_intr()
1265 snd_mtxlock(sc->lock); in emu_pcm_intr()
1271 if (sc->rch_efx.channel) { in emu_pcm_intr()
1272 snd_mtxunlock(sc->lock); in emu_pcm_intr()
1273 chn_intr(sc->rch_efx.channel); in emu_pcm_intr()
1274 snd_mtxlock(sc->lock); in emu_pcm_intr()
1277 snd_mtxunlock(sc->lock); in emu_pcm_intr()
1285 sc->bufsz = pcm_getbuffersize(sc->dev, EMUPAGESIZE, EMU_REC_BUFSZ, EMU_MAX_BUFSZ); in emu_pcm_init()
1329 device_set_descf(dev, "EMU10Kx DSP %s PCM interface", rt); in emu_pcm_probe()
1343 sc->card = (struct emu_sc_info *)(device_get_softc(device_get_parent(dev))); in emu_pcm_attach()
1344 if (sc->card == NULL) { in emu_pcm_attach()
1350 sc->lock = snd_mtxcreate(device_get_nameunit(dev), "snd_emu10kx pcm softc"); in emu_pcm_attach()
1351 sc->dev = dev; in emu_pcm_attach()
1354 sc->is_emu10k1 = ivar ? 1 : 0; in emu_pcm_attach()
1357 sc->mch_disabled = ivar ? 1 : 0; in emu_pcm_attach()
1359 sc->codec = NULL; in emu_pcm_attach()
1362 sc->rt.routing_left[i] = i; in emu_pcm_attach()
1363 sc->rt.amounts_left[i] = 0x00; in emu_pcm_attach()
1364 sc->rt.routing_right[i] = i; in emu_pcm_attach()
1365 sc->rt.amounts_right[i] = 0x00; in emu_pcm_attach()
1369 sc->rt_mono.routing_left[i] = i; in emu_pcm_attach()
1370 sc->rt_mono.amounts_left[i] = 0x00; in emu_pcm_attach()
1371 sc->rt_mono.routing_right[i] = i; in emu_pcm_attach()
1372 sc->rt_mono.amounts_right[i] = 0x00; in emu_pcm_attach()
1375 sc->emu10k1_volcache[0][0] = 75; in emu_pcm_attach()
1376 sc->emu10k1_volcache[1][0] = 75; in emu_pcm_attach()
1377 sc->emu10k1_volcache[0][1] = 75; in emu_pcm_attach()
1378 sc->emu10k1_volcache[1][1] = 75; in emu_pcm_attach()
1380 sc->route = route; in emu_pcm_attach()
1383 sc->rt.amounts_left[0] = 0xff; in emu_pcm_attach()
1384 sc->rt.amounts_right[1] = 0xff; in emu_pcm_attach()
1385 sc->rt_mono.amounts_left[0] = 0xff; in emu_pcm_attach()
1386 sc->rt_mono.amounts_left[1] = 0xff; in emu_pcm_attach()
1387 if (sc->is_emu10k1) in emu_pcm_attach()
1388 sc->codec = AC97_CREATE(dev, sc, emu_ac97); in emu_pcm_attach()
1390 sc->codec = AC97_CREATE(dev, sc, emu_eac97); in emu_pcm_attach()
1391 sc->ac97_mixerclass = NULL; in emu_pcm_attach()
1392 if (sc->codec != NULL) in emu_pcm_attach()
1393 sc->ac97_mixerclass = ac97_getmixerclass(); in emu_pcm_attach()
1400 sc->rt.amounts_left[2] = 0xff; in emu_pcm_attach()
1401 sc->rt.amounts_right[3] = 0xff; in emu_pcm_attach()
1402 sc->rt_mono.amounts_left[2] = 0xff; in emu_pcm_attach()
1403 sc->rt_mono.amounts_left[3] = 0xff; in emu_pcm_attach()
1410 sc->rt.amounts_left[4] = 0xff; in emu_pcm_attach()
1411 sc->rt_mono.amounts_left[4] = 0xff; in emu_pcm_attach()
1418 sc->rt.amounts_left[5] = 0xff; in emu_pcm_attach()
1419 sc->rt_mono.amounts_left[5] = 0xff; in emu_pcm_attach()
1426 sc->rt.amounts_left[6] = 0xff; in emu_pcm_attach()
1427 sc->rt.amounts_right[7] = 0xff; in emu_pcm_attach()
1428 sc->rt_mono.amounts_left[6] = 0xff; in emu_pcm_attach()
1429 sc->rt_mono.amounts_left[7] = 0xff; in emu_pcm_attach()
1448 sc->ihandle = emu_intr_register(sc->card, inte, ipr, &emu_pcm_intr, sc); in emu_pcm_attach()
1450 if (emu_pcm_init(sc) == -1) { in emu_pcm_attach()
1451 device_printf(dev, "unable to initialize PCM part of the card\n"); in emu_pcm_attach()
1457 * in pcm device. Mark pcm device as MPSAFE manually. in emu_pcm_attach()
1463 sc->pnum = 0; in emu_pcm_attach()
1482 if (sc->codec) in emu_pcm_attach()
1483 ac97_destroy(sc->codec); in emu_pcm_attach()
1484 if (sc->lock) in emu_pcm_attach()
1485 snd_mtxfree(sc->lock); in emu_pcm_attach()
1504 if (sc->lock) in emu_pcm_detach()
1505 snd_mtxfree(sc->lock); in emu_pcm_detach()
1520 "pcm",