Lines Matching +full:we +full:- +full:extra +full:- +full:delay

1 // SPDX-License-Identifier: GPL-2.0-or-later
4 * Lee Revell <rlrevell@joe-job.com>
5 * James Courtier-Dutton <James@superbug.co.uk>
13 #include <linux/delay.h>
25 epcm = voice->epcm; in snd_emu10k1_pcm_interrupt()
28 if (epcm->substream == NULL) in snd_emu10k1_pcm_interrupt()
31 dev_dbg(emu->card->dev, in snd_emu10k1_pcm_interrupt()
33 epcm->substream->runtime->hw->pointer(emu, epcm->substream), in snd_emu10k1_pcm_interrupt()
34 snd_pcm_lib_period_bytes(epcm->substream), in snd_emu10k1_pcm_interrupt()
35 snd_pcm_lib_buffer_bytes(epcm->substream)); in snd_emu10k1_pcm_interrupt()
37 snd_pcm_period_elapsed(epcm->substream); in snd_emu10k1_pcm_interrupt()
45 if (emu->pcm_capture_substream->runtime->mode == SNDRV_PCM_MODE_FRAME) in snd_emu10k1_pcm_ac97adc_interrupt()
49 snd_pcm_period_elapsed(emu->pcm_capture_substream); in snd_emu10k1_pcm_ac97adc_interrupt()
57 if (emu->pcm_capture_mic_substream->runtime->mode == SNDRV_PCM_MODE_FRAME) in snd_emu10k1_pcm_ac97mic_interrupt()
61 snd_pcm_period_elapsed(emu->pcm_capture_mic_substream); in snd_emu10k1_pcm_ac97mic_interrupt()
69 if (emu->pcm_capture_efx_substream->runtime->mode == SNDRV_PCM_MODE_FRAME) in snd_emu10k1_pcm_efx_interrupt()
73 snd_pcm_period_elapsed(emu->pcm_capture_efx_substream); in snd_emu10k1_pcm_efx_interrupt()
78 for (unsigned i = 0; i < ARRAY_SIZE(epcm->voices); i++) { in snd_emu10k1_pcm_free_voices()
79 if (epcm->voices[i]) { in snd_emu10k1_pcm_free_voices()
80 snd_emu10k1_voice_free(epcm->emu, epcm->voices[i]); in snd_emu10k1_pcm_free_voices()
81 epcm->voices[i] = NULL; in snd_emu10k1_pcm_free_voices()
93 err = snd_emu10k1_voice_alloc(epcm->emu, in snd_emu10k1_pcm_channel_alloc()
95 epcm, &epcm->voices[0]); in snd_emu10k1_pcm_channel_alloc()
99 if (epcm->extra == NULL) { in snd_emu10k1_pcm_channel_alloc()
100 // The hardware supports only (half-)loop interrupts, so to support an in snd_emu10k1_pcm_channel_alloc()
101 // arbitrary number of periods per buffer, we use an extra voice with a in snd_emu10k1_pcm_channel_alloc()
102 // period-sized loop as the interrupt source. Additionally, the interrupt in snd_emu10k1_pcm_channel_alloc()
104 err = snd_emu10k1_voice_alloc(epcm->emu, in snd_emu10k1_pcm_channel_alloc()
106 epcm, &epcm->extra); in snd_emu10k1_pcm_channel_alloc()
109 dev_dbg(emu->card->dev, "pcm_channel_alloc: " in snd_emu10k1_pcm_channel_alloc()
110 "failed extra: voices=%d, frame=%d\n", in snd_emu10k1_pcm_channel_alloc()
116 epcm->extra->interrupt = snd_emu10k1_pcm_interrupt; in snd_emu10k1_pcm_channel_alloc()
122 // Primes 2-7 and 2^n multiples thereof, up to 16.
188 if (emu->card_capabilities->emu_model && in snd_emu10k1_constrain_capture_rates()
189 emu->emu1010.word_clock == 44100) { in snd_emu10k1_constrain_capture_rates()
190 runtime->hw.rates = SNDRV_PCM_RATE_11025 | \ in snd_emu10k1_constrain_capture_rates()
193 runtime->hw.rate_min = 11025; in snd_emu10k1_constrain_capture_rates()
194 runtime->hw.rate_max = 44100; in snd_emu10k1_constrain_capture_rates()
195 } else if (emu->audigy) { in snd_emu10k1_constrain_capture_rates()
196 runtime->hw.rates = SNDRV_PCM_RATE_8000_48000 | in snd_emu10k1_constrain_capture_rates()
207 rate = emu->emu1010.word_clock; in snd_emu1010_constrain_efx_rate()
208 runtime->hw.rate_min = runtime->hw.rate_max = rate; in snd_emu1010_constrain_efx_rate()
209 runtime->hw.rates = snd_pcm_rate_to_rate_bit(rate); in snd_emu1010_constrain_efx_rate()
271 voice = evoice->number; in snd_emu10k1_pcm_init_voice()
273 silent_page = ((unsigned int)emu->silent_page.addr << emu->address_mode) | in snd_emu10k1_pcm_init_voice()
274 (emu->address_mode ? MAP_PTI_MASK1 : MAP_PTI_MASK0); in snd_emu10k1_pcm_init_voice()
283 CCCA, emu10k1_select_interprom(evoice->epcm->pitch_target) | in snd_emu10k1_pcm_init_voice()
285 // Clear filter delay memory in snd_emu10k1_pcm_init_voice()
296 if (emu->audigy) { in snd_emu10k1_pcm_init_voice()
312 emu->voices[voice].dirty = 1; in snd_emu10k1_pcm_init_voice()
322 spin_lock_irq(&emu->reg_lock); in snd_emu10k1_pcm_init_voices()
325 &mix->send_routing[stereo][0], in snd_emu10k1_pcm_init_voices()
326 &mix->send_volume[stereo][0]); in snd_emu10k1_pcm_init_voices()
330 &mix->send_routing[2][0], in snd_emu10k1_pcm_init_voices()
331 &mix->send_volume[2][0]); in snd_emu10k1_pcm_init_voices()
332 spin_unlock_irq(&emu->reg_lock); in snd_emu10k1_pcm_init_voices()
353 struct snd_pcm_runtime *runtime = substream->runtime; in snd_emu10k1_playback_hw_params()
354 struct snd_emu10k1_pcm *epcm = runtime->private_data; in snd_emu10k1_playback_hw_params()
359 if (epcm->type == PLAYBACK_EMUVOICE) { in snd_emu10k1_playback_hw_params()
373 if (emu->iommu_workaround) in snd_emu10k1_playback_hw_params()
378 if (emu->iommu_workaround && runtime->dma_bytes >= EMUPAGESIZE) in snd_emu10k1_playback_hw_params()
379 runtime->dma_bytes -= EMUPAGESIZE; in snd_emu10k1_playback_hw_params()
382 if (epcm->memblk != NULL) in snd_emu10k1_playback_hw_params()
383 snd_emu10k1_free_pages(emu, epcm->memblk); in snd_emu10k1_playback_hw_params()
384 epcm->memblk = snd_emu10k1_alloc_pages(emu, substream); in snd_emu10k1_playback_hw_params()
385 epcm->start_addr = 0; in snd_emu10k1_playback_hw_params()
386 if (! epcm->memblk) in snd_emu10k1_playback_hw_params()
387 return -ENOMEM; in snd_emu10k1_playback_hw_params()
388 mapped = ((struct snd_emu10k1_memblk *)epcm->memblk)->mapped_page; in snd_emu10k1_playback_hw_params()
390 return -ENOMEM; in snd_emu10k1_playback_hw_params()
391 epcm->start_addr = mapped << PAGE_SHIFT; in snd_emu10k1_playback_hw_params()
399 struct snd_pcm_runtime *runtime = substream->runtime; in snd_emu10k1_playback_hw_free()
402 if (runtime->private_data == NULL) in snd_emu10k1_playback_hw_free()
404 epcm = runtime->private_data; in snd_emu10k1_playback_hw_free()
405 if (epcm->extra) { in snd_emu10k1_playback_hw_free()
406 snd_emu10k1_voice_free(epcm->emu, epcm->extra); in snd_emu10k1_playback_hw_free()
407 epcm->extra = NULL; in snd_emu10k1_playback_hw_free()
410 if (epcm->memblk) { in snd_emu10k1_playback_hw_free()
411 snd_emu10k1_free_pages(emu, epcm->memblk); in snd_emu10k1_playback_hw_free()
412 epcm->memblk = NULL; in snd_emu10k1_playback_hw_free()
413 epcm->start_addr = 0; in snd_emu10k1_playback_hw_free()
422 struct snd_pcm_runtime *runtime = substream->runtime; in snd_emu10k1_playback_prepare()
423 struct snd_emu10k1_pcm *epcm = runtime->private_data; in snd_emu10k1_playback_prepare()
424 bool w_16 = snd_pcm_format_width(runtime->format) == 16; in snd_emu10k1_playback_prepare()
425 bool stereo = runtime->channels == 2; in snd_emu10k1_playback_prepare()
429 rate = runtime->rate; in snd_emu10k1_playback_prepare()
430 if (emu->card_capabilities->emu_model && in snd_emu10k1_playback_prepare()
431 emu->emu1010.word_clock == 44100) in snd_emu10k1_playback_prepare()
433 epcm->pitch_target = emu10k1_calc_pitch_target(rate); in snd_emu10k1_playback_prepare()
435 start_addr = epcm->start_addr >> w_16; in snd_emu10k1_playback_prepare()
436 end_addr = start_addr + runtime->period_size; in snd_emu10k1_playback_prepare()
437 snd_emu10k1_pcm_init_extra_voice(emu, epcm->extra, w_16, in snd_emu10k1_playback_prepare()
440 epcm->ccca_start_addr = start_addr; in snd_emu10k1_playback_prepare()
441 end_addr = start_addr + runtime->buffer_size; in snd_emu10k1_playback_prepare()
442 snd_emu10k1_pcm_init_voices(emu, epcm->voices[0], w_16, stereo, in snd_emu10k1_playback_prepare()
444 &emu->pcm_mixer[substream->number]); in snd_emu10k1_playback_prepare()
452 struct snd_pcm_runtime *runtime = substream->runtime; in snd_emu10k1_efx_playback_prepare()
453 struct snd_emu10k1_pcm *epcm = runtime->private_data; in snd_emu10k1_efx_playback_prepare()
458 epcm->pitch_target = PITCH_48000; in snd_emu10k1_efx_playback_prepare()
460 start_addr = epcm->start_addr >> 1; // 16-bit voices in snd_emu10k1_efx_playback_prepare()
462 extra_size = runtime->period_size; in snd_emu10k1_efx_playback_prepare()
463 channel_size = runtime->buffer_size; in snd_emu10k1_efx_playback_prepare()
465 snd_emu10k1_pcm_init_extra_voice(emu, epcm->extra, true, in snd_emu10k1_efx_playback_prepare()
468 epcm->ccca_start_addr = start_addr; in snd_emu10k1_efx_playback_prepare()
469 for (i = 0; i < runtime->channels; i++) { in snd_emu10k1_efx_playback_prepare()
470 snd_emu10k1_pcm_init_voices(emu, epcm->voices[i], true, false, in snd_emu10k1_efx_playback_prepare()
472 &emu->efx_pcm_mixer[i]); in snd_emu10k1_efx_playback_prepare()
501 struct snd_pcm_runtime *runtime = substream->runtime; in snd_emu10k1_capture_prepare()
502 struct snd_emu10k1_pcm *epcm = runtime->private_data; in snd_emu10k1_capture_prepare()
506 snd_emu10k1_ptr_write(emu, epcm->capture_bs_reg, 0, 0); in snd_emu10k1_capture_prepare()
507 switch (epcm->type) { in snd_emu10k1_capture_prepare()
512 if (emu->card_capabilities->emu_model) { in snd_emu10k1_capture_prepare()
513 // The upper 32 16-bit capture voices, two for each of the 16 32-bit channels. in snd_emu10k1_capture_prepare()
515 epcm->capture_cr_val = 0; in snd_emu10k1_capture_prepare()
516 epcm->capture_cr_val2 = 0xffffffff >> (32 - runtime->channels * 2); in snd_emu10k1_capture_prepare()
518 if (emu->audigy) { in snd_emu10k1_capture_prepare()
529 snd_emu10k1_ptr_write(emu, epcm->capture_ba_reg, 0, runtime->dma_addr); in snd_emu10k1_capture_prepare()
530 epcm->capture_bufsize = snd_pcm_lib_buffer_bytes(substream); in snd_emu10k1_capture_prepare()
531 epcm->capture_bs_val = 0; in snd_emu10k1_capture_prepare()
533 if (capture_buffer_sizes[idx] == epcm->capture_bufsize) { in snd_emu10k1_capture_prepare()
534 epcm->capture_bs_val = idx + 1; in snd_emu10k1_capture_prepare()
538 if (epcm->capture_bs_val == 0) { in snd_emu10k1_capture_prepare()
540 epcm->capture_bs_val++; in snd_emu10k1_capture_prepare()
542 if (epcm->type == CAPTURE_AC97ADC) { in snd_emu10k1_capture_prepare()
543 unsigned rate = runtime->rate; in snd_emu10k1_capture_prepare()
544 if (!(runtime->hw.rates & SNDRV_PCM_RATE_48000)) in snd_emu10k1_capture_prepare()
547 epcm->capture_cr_val = emu->audigy ? A_ADCCR_LCHANENABLE : ADCCR_LCHANENABLE; in snd_emu10k1_capture_prepare()
548 if (runtime->channels > 1) in snd_emu10k1_capture_prepare()
549 epcm->capture_cr_val |= emu->audigy ? A_ADCCR_RCHANENABLE : ADCCR_RCHANENABLE; in snd_emu10k1_capture_prepare()
550 epcm->capture_cr_val |= emu->audigy ? in snd_emu10k1_capture_prepare()
563 // We assume that the cache is resting at this point (i.e., in snd_emu10k1_playback_fill_cache()
567 // except for 16-bit stereo. And the interpolator will actually in snd_emu10k1_playback_fill_cache()
568 // access them at all only when we're pitch-shifting. in snd_emu10k1_playback_fill_cache()
573 ccr = (64 - 3) << REG_SHIFT(CCR_CACHEINVALIDSIZE); in snd_emu10k1_playback_fill_cache()
586 struct snd_pcm_substream *substream = epcm->substream; in snd_emu10k1_playback_prepare_voices()
587 struct snd_pcm_runtime *runtime = substream->runtime; in snd_emu10k1_playback_prepare_voices()
588 unsigned eloop_start = epcm->start_addr >> w_16; in snd_emu10k1_playback_prepare_voices()
590 unsigned eloop_size = runtime->period_size; in snd_emu10k1_playback_prepare_voices()
591 unsigned loop_size = runtime->buffer_size; in snd_emu10k1_playback_prepare_voices()
595 // we need to compensate for two circumstances: in snd_emu10k1_playback_prepare_voices()
596 // - The actual position is delayed by the cache size (64 frames) in snd_emu10k1_playback_prepare_voices()
597 // - The interpolator is centered around the 4th frame in snd_emu10k1_playback_prepare_voices()
598 loop_start += (epcm->resume_pos + 64 - 3) % loop_size; in snd_emu10k1_playback_prepare_voices()
600 unsigned voice = epcm->voices[i]->number; in snd_emu10k1_playback_prepare_voices()
610 // In principle, this wouldn't need to be the cache's entire size - in in snd_emu10k1_playback_prepare_voices()
615 // align them with the interrupts. This makes a non-delayed interrupt in snd_emu10k1_playback_prepare_voices()
617 // for (CA - CIS) >= period_boundary for every channel in the stream. in snd_emu10k1_playback_prepare_voices()
619 // This is why all other (open) drivers for these chips use timer-based in snd_emu10k1_playback_prepare_voices()
622 eloop_start += (epcm->resume_pos + eloop_size - 3) % eloop_size; in snd_emu10k1_playback_prepare_voices()
623 snd_emu10k1_ptr_write(emu, CCCA_CURRADDR, epcm->extra->number, eloop_start); in snd_emu10k1_playback_prepare_voices()
633 snd_emu10k1_ptr_write_multiple(emu, evoice->number, in snd_emu10k1_playback_commit_volume()
648 vattn = mix->attn[tmp] << 16; in snd_emu10k1_playback_unmute_voice()
693 voice = evoice->number; in snd_emu10k1_playback_trigger_voice()
694 snd_emu10k1_playback_commit_pitch(emu, voice, evoice->epcm->pitch_target << 16); in snd_emu10k1_playback_trigger_voice()
702 voice = evoice->number; in snd_emu10k1_playback_stop_voice()
709 epcm->running = 1; in snd_emu10k1_playback_set_running()
710 snd_emu10k1_voice_intr_enable(emu, epcm->extra->number); in snd_emu10k1_playback_set_running()
716 snd_emu10k1_voice_intr_disable(emu, epcm->extra->number); in snd_emu10k1_playback_set_stopped()
717 epcm->running = 0; in snd_emu10k1_playback_set_stopped()
724 struct snd_pcm_runtime *runtime = substream->runtime; in snd_emu10k1_playback_trigger()
725 struct snd_emu10k1_pcm *epcm = runtime->private_data; in snd_emu10k1_playback_trigger()
727 bool w_16 = snd_pcm_format_width(runtime->format) == 16; in snd_emu10k1_playback_trigger()
728 bool stereo = runtime->channels == 2; in snd_emu10k1_playback_trigger()
732 dev_dbg(emu->card->dev, in snd_emu10k1_playback_trigger()
733 "trigger - emu10k1 = 0x%x, cmd = %i, pointer = %i\n", in snd_emu10k1_playback_trigger()
734 (int)emu, cmd, substream->ops->pointer(substream)) in snd_emu10k1_playback_trigger()
736 spin_lock(&emu->reg_lock); in snd_emu10k1_playback_trigger()
743 mix = &emu->pcm_mixer[substream->number]; in snd_emu10k1_playback_trigger()
744 snd_emu10k1_playback_unmute_voices(emu, epcm->voices[0], stereo, mix); in snd_emu10k1_playback_trigger()
746 snd_emu10k1_playback_trigger_voice(emu, epcm->voices[0]); in snd_emu10k1_playback_trigger()
747 snd_emu10k1_playback_trigger_voice(emu, epcm->extra); in snd_emu10k1_playback_trigger()
752 snd_emu10k1_playback_stop_voice(emu, epcm->voices[0]); in snd_emu10k1_playback_trigger()
753 snd_emu10k1_playback_stop_voice(emu, epcm->extra); in snd_emu10k1_playback_trigger()
755 snd_emu10k1_playback_mute_voices(emu, epcm->voices[0], stereo); in snd_emu10k1_playback_trigger()
758 result = -EINVAL; in snd_emu10k1_playback_trigger()
761 spin_unlock(&emu->reg_lock); in snd_emu10k1_playback_trigger()
769 struct snd_pcm_runtime *runtime = substream->runtime; in snd_emu10k1_capture_trigger()
770 struct snd_emu10k1_pcm *epcm = runtime->private_data; in snd_emu10k1_capture_trigger()
773 spin_lock(&emu->reg_lock); in snd_emu10k1_capture_trigger()
778 outl(epcm->capture_ipr, emu->port + IPR); in snd_emu10k1_capture_trigger()
779 snd_emu10k1_intr_enable(emu, epcm->capture_inte); in snd_emu10k1_capture_trigger()
781 dev_dbg(emu->card->dev, "adccr = 0x%x, adcbs = 0x%x\n", in snd_emu10k1_capture_trigger()
782 epcm->adccr, epcm->adcbs); in snd_emu10k1_capture_trigger()
784 switch (epcm->type) { in snd_emu10k1_capture_trigger()
786 snd_emu10k1_ptr_write(emu, ADCCR, 0, epcm->capture_cr_val); in snd_emu10k1_capture_trigger()
789 if (emu->audigy) { in snd_emu10k1_capture_trigger()
791 A_FXWC1, epcm->capture_cr_val, in snd_emu10k1_capture_trigger()
792 A_FXWC2, epcm->capture_cr_val2, in snd_emu10k1_capture_trigger()
794 dev_dbg(emu->card->dev, in snd_emu10k1_capture_trigger()
796 epcm->capture_cr_val, in snd_emu10k1_capture_trigger()
797 epcm->capture_cr_val2); in snd_emu10k1_capture_trigger()
799 snd_emu10k1_ptr_write(emu, FXWC, 0, epcm->capture_cr_val); in snd_emu10k1_capture_trigger()
804 snd_emu10k1_ptr_write(emu, epcm->capture_bs_reg, 0, epcm->capture_bs_val); in snd_emu10k1_capture_trigger()
805 epcm->running = 1; in snd_emu10k1_capture_trigger()
806 epcm->first_ptr = 1; in snd_emu10k1_capture_trigger()
810 epcm->running = 0; in snd_emu10k1_capture_trigger()
811 snd_emu10k1_intr_disable(emu, epcm->capture_inte); in snd_emu10k1_capture_trigger()
812 outl(epcm->capture_ipr, emu->port + IPR); in snd_emu10k1_capture_trigger()
813 snd_emu10k1_ptr_write(emu, epcm->capture_bs_reg, 0, 0); in snd_emu10k1_capture_trigger()
814 switch (epcm->type) { in snd_emu10k1_capture_trigger()
819 if (emu->audigy) { in snd_emu10k1_capture_trigger()
832 result = -EINVAL; in snd_emu10k1_capture_trigger()
834 spin_unlock(&emu->reg_lock); in snd_emu10k1_capture_trigger()
841 struct snd_pcm_runtime *runtime = substream->runtime; in snd_emu10k1_playback_pointer()
842 struct snd_emu10k1_pcm *epcm = runtime->private_data; in snd_emu10k1_playback_pointer()
845 if (!epcm->running) in snd_emu10k1_playback_pointer()
848 ptr = snd_emu10k1_ptr_read(emu, CCCA, epcm->voices[0]->number) & 0x00ffffff; in snd_emu10k1_playback_pointer()
849 ptr -= epcm->ccca_start_addr; in snd_emu10k1_playback_pointer()
851 // This is the size of the whole cache minus the interpolator read-ahead, in snd_emu10k1_playback_pointer()
854 // The cache is constantly kept mostly filled, so in principle we could in snd_emu10k1_playback_pointer()
856 // already read the buffer, and set runtime->delay accordingly. However, in snd_emu10k1_playback_pointer()
858 // to obtain), so only a fixed worst-case value would be practical. in snd_emu10k1_playback_pointer()
860 ptr -= 64 - 3; in snd_emu10k1_playback_pointer()
862 ptr += runtime->buffer_size; in snd_emu10k1_playback_pointer()
865 dev_dbg(emu->card->dev, in snd_emu10k1_playback_pointer()
867 (long)ptr, (long)runtime->buffer_size, in snd_emu10k1_playback_pointer()
868 (long)runtime->period_size); in snd_emu10k1_playback_pointer()
879 int voice = epcm->voices[i]->number; in snd_emu10k1_efx_playback_voice_mask()
890 int voice = epcm->voices[i]->number; in snd_emu10k1_efx_playback_freeze_voices()
901 snd_emu10k1_playback_unmute_voice(emu, epcm->voices[i], false, true, in snd_emu10k1_efx_playback_unmute_voices()
902 &emu->efx_pcm_mixer[i]); in snd_emu10k1_efx_playback_unmute_voices()
910 snd_emu10k1_playback_stop_voice(emu, epcm->voices[i]); in snd_emu10k1_efx_playback_stop_voices()
914 snd_emu10k1_playback_mute_voice(emu, epcm->voices[i]); in snd_emu10k1_efx_playback_stop_voices()
921 struct snd_pcm_runtime *runtime = substream->runtime; in snd_emu10k1_efx_playback_trigger()
922 struct snd_emu10k1_pcm *epcm = runtime->private_data; in snd_emu10k1_efx_playback_trigger()
926 spin_lock(&emu->reg_lock); in snd_emu10k1_efx_playback_trigger()
932 epcm, runtime->channels); in snd_emu10k1_efx_playback_trigger()
934 // Note that the freeze is not interruptible, so we make no in snd_emu10k1_efx_playback_trigger()
938 emu, epcm, runtime->channels); in snd_emu10k1_efx_playback_trigger()
940 emu, epcm, true, false, runtime->channels); in snd_emu10k1_efx_playback_trigger()
944 // if something goes wrong. However, we cannot unmute atomically, in snd_emu10k1_efx_playback_trigger()
945 // which means that we'd get some mild artifacts in the regular case. in snd_emu10k1_efx_playback_trigger()
946 snd_emu10k1_efx_playback_unmute_voices(emu, epcm, runtime->channels); in snd_emu10k1_efx_playback_trigger()
951 // The extra voice is allowed to lag a bit in snd_emu10k1_efx_playback_trigger()
952 snd_emu10k1_playback_trigger_voice(emu, epcm->extra); in snd_emu10k1_efx_playback_trigger()
957 emu, epcm, runtime->channels); in snd_emu10k1_efx_playback_trigger()
959 if (result != -EAGAIN) in snd_emu10k1_efx_playback_trigger()
968 snd_emu10k1_playback_stop_voice(emu, epcm->extra); in snd_emu10k1_efx_playback_trigger()
970 emu, epcm, runtime->channels); in snd_emu10k1_efx_playback_trigger()
972 epcm->resume_pos = snd_emu10k1_playback_pointer(substream); in snd_emu10k1_efx_playback_trigger()
975 result = -EINVAL; in snd_emu10k1_efx_playback_trigger()
979 spin_unlock(&emu->reg_lock); in snd_emu10k1_efx_playback_trigger()
987 struct snd_pcm_runtime *runtime = substream->runtime; in snd_emu10k1_capture_pointer()
988 struct snd_emu10k1_pcm *epcm = runtime->private_data; in snd_emu10k1_capture_pointer()
991 if (!epcm->running) in snd_emu10k1_capture_pointer()
993 if (epcm->first_ptr) { in snd_emu10k1_capture_pointer()
995 epcm->first_ptr = 0; in snd_emu10k1_capture_pointer()
997 ptr = snd_emu10k1_ptr_read(emu, epcm->capture_idx_reg, 0) & 0x0000ffff; in snd_emu10k1_capture_pointer()
1079 kctl->vd[idx].access &= ~SNDRV_CTL_ELEM_ACCESS_INACTIVE; in snd_emu10k1_pcm_mixer_notify1()
1081 kctl->vd[idx].access |= SNDRV_CTL_ELEM_ACCESS_INACTIVE; in snd_emu10k1_pcm_mixer_notify1()
1082 snd_ctl_notify(emu->card, SNDRV_CTL_EVENT_MASK_VALUE | in snd_emu10k1_pcm_mixer_notify1()
1089 snd_emu10k1_pcm_mixer_notify1(emu, emu->ctl_send_routing, idx, activate); in snd_emu10k1_pcm_mixer_notify()
1090 snd_emu10k1_pcm_mixer_notify1(emu, emu->ctl_send_volume, idx, activate); in snd_emu10k1_pcm_mixer_notify()
1091 snd_emu10k1_pcm_mixer_notify1(emu, emu->ctl_attn, idx, activate); in snd_emu10k1_pcm_mixer_notify()
1096 snd_emu10k1_pcm_mixer_notify1(emu, emu->ctl_efx_send_routing, idx, activate); in snd_emu10k1_pcm_efx_mixer_notify()
1097 snd_emu10k1_pcm_mixer_notify1(emu, emu->ctl_efx_send_volume, idx, activate); in snd_emu10k1_pcm_efx_mixer_notify()
1098 snd_emu10k1_pcm_mixer_notify1(emu, emu->ctl_efx_attn, idx, activate); in snd_emu10k1_pcm_efx_mixer_notify()
1103 kfree(runtime->private_data); in snd_emu10k1_pcm_free_substream()
1113 mix = &emu->efx_pcm_mixer[i]; in snd_emu10k1_efx_playback_close()
1114 mix->epcm = NULL; in snd_emu10k1_efx_playback_close()
1125 // mismatch between the extra voice and the regular voices. in snd_emu10k1_playback_set_constraints()
1141 struct snd_pcm_runtime *runtime = substream->runtime; in snd_emu10k1_efx_playback_open()
1146 return -ENOMEM; in snd_emu10k1_efx_playback_open()
1147 epcm->emu = emu; in snd_emu10k1_efx_playback_open()
1148 epcm->type = PLAYBACK_EFX; in snd_emu10k1_efx_playback_open()
1149 epcm->substream = substream; in snd_emu10k1_efx_playback_open()
1151 runtime->private_data = epcm; in snd_emu10k1_efx_playback_open()
1152 runtime->private_free = snd_emu10k1_pcm_free_substream; in snd_emu10k1_efx_playback_open()
1153 runtime->hw = snd_emu10k1_efx_playback; in snd_emu10k1_efx_playback_open()
1154 if (emu->card_capabilities->emu_model) in snd_emu10k1_efx_playback_open()
1163 mix = &emu->efx_pcm_mixer[i]; in snd_emu10k1_efx_playback_open()
1165 mix->send_routing[0][j] = i + j; in snd_emu10k1_efx_playback_open()
1166 memset(&mix->send_volume, 0, sizeof(mix->send_volume)); in snd_emu10k1_efx_playback_open()
1167 mix->send_volume[0][0] = 255; in snd_emu10k1_efx_playback_open()
1168 mix->attn[0] = 0x8000; in snd_emu10k1_efx_playback_open()
1169 mix->epcm = epcm; in snd_emu10k1_efx_playback_open()
1180 struct snd_pcm_runtime *runtime = substream->runtime; in snd_emu10k1_playback_open()
1185 return -ENOMEM; in snd_emu10k1_playback_open()
1186 epcm->emu = emu; in snd_emu10k1_playback_open()
1187 epcm->type = PLAYBACK_EMUVOICE; in snd_emu10k1_playback_open()
1188 epcm->substream = substream; in snd_emu10k1_playback_open()
1189 runtime->private_data = epcm; in snd_emu10k1_playback_open()
1190 runtime->private_free = snd_emu10k1_pcm_free_substream; in snd_emu10k1_playback_open()
1191 runtime->hw = snd_emu10k1_playback; in snd_emu10k1_playback_open()
1197 if (emu->card_capabilities->emu_model) in snd_emu10k1_playback_open()
1198 sample_rate = emu->emu1010.word_clock; in snd_emu10k1_playback_open()
1206 mix = &emu->pcm_mixer[substream->number]; in snd_emu10k1_playback_open()
1208 mix->send_routing[0][i] = mix->send_routing[1][i] = mix->send_routing[2][i] = i; in snd_emu10k1_playback_open()
1209 memset(&mix->send_volume, 0, sizeof(mix->send_volume)); in snd_emu10k1_playback_open()
1210 mix->send_volume[0][0] = mix->send_volume[0][1] = in snd_emu10k1_playback_open()
1211 mix->send_volume[1][0] = mix->send_volume[2][1] = 255; in snd_emu10k1_playback_open()
1212 mix->attn[0] = mix->attn[1] = mix->attn[2] = 0x8000; in snd_emu10k1_playback_open()
1213 mix->epcm = epcm; in snd_emu10k1_playback_open()
1214 snd_emu10k1_pcm_mixer_notify(emu, substream->number, 1); in snd_emu10k1_playback_open()
1221 struct snd_emu10k1_pcm_mixer *mix = &emu->pcm_mixer[substream->number]; in snd_emu10k1_playback_close()
1223 mix->epcm = NULL; in snd_emu10k1_playback_close()
1224 snd_emu10k1_pcm_mixer_notify(emu, substream->number, 0); in snd_emu10k1_playback_close()
1231 struct snd_pcm_runtime *runtime = substream->runtime; in snd_emu10k1_capture_open()
1236 return -ENOMEM; in snd_emu10k1_capture_open()
1237 epcm->emu = emu; in snd_emu10k1_capture_open()
1238 epcm->type = CAPTURE_AC97ADC; in snd_emu10k1_capture_open()
1239 epcm->substream = substream; in snd_emu10k1_capture_open()
1240 epcm->capture_ipr = IPR_ADCBUFFULL|IPR_ADCBUFHALFFULL; in snd_emu10k1_capture_open()
1241 epcm->capture_inte = INTE_ADCBUFENABLE; in snd_emu10k1_capture_open()
1242 epcm->capture_ba_reg = ADCBA; in snd_emu10k1_capture_open()
1243 epcm->capture_bs_reg = ADCBS; in snd_emu10k1_capture_open()
1244 epcm->capture_idx_reg = emu->audigy ? A_ADCIDX : ADCIDX; in snd_emu10k1_capture_open()
1245 runtime->private_data = epcm; in snd_emu10k1_capture_open()
1246 runtime->private_free = snd_emu10k1_pcm_free_substream; in snd_emu10k1_capture_open()
1247 runtime->hw = snd_emu10k1_capture; in snd_emu10k1_capture_open()
1251 emu->capture_interrupt = snd_emu10k1_pcm_ac97adc_interrupt; in snd_emu10k1_capture_open()
1252 emu->pcm_capture_substream = substream; in snd_emu10k1_capture_open()
1260 emu->capture_interrupt = NULL; in snd_emu10k1_capture_close()
1261 emu->pcm_capture_substream = NULL; in snd_emu10k1_capture_close()
1269 struct snd_pcm_runtime *runtime = substream->runtime; in snd_emu10k1_capture_mic_open()
1273 return -ENOMEM; in snd_emu10k1_capture_mic_open()
1274 epcm->emu = emu; in snd_emu10k1_capture_mic_open()
1275 epcm->type = CAPTURE_AC97MIC; in snd_emu10k1_capture_mic_open()
1276 epcm->substream = substream; in snd_emu10k1_capture_mic_open()
1277 epcm->capture_ipr = IPR_MICBUFFULL|IPR_MICBUFHALFFULL; in snd_emu10k1_capture_mic_open()
1278 epcm->capture_inte = INTE_MICBUFENABLE; in snd_emu10k1_capture_mic_open()
1279 epcm->capture_ba_reg = MICBA; in snd_emu10k1_capture_mic_open()
1280 epcm->capture_bs_reg = MICBS; in snd_emu10k1_capture_mic_open()
1281 epcm->capture_idx_reg = emu->audigy ? A_MICIDX : MICIDX; in snd_emu10k1_capture_mic_open()
1282 substream->runtime->private_data = epcm; in snd_emu10k1_capture_mic_open()
1283 substream->runtime->private_free = snd_emu10k1_pcm_free_substream; in snd_emu10k1_capture_mic_open()
1284 runtime->hw = snd_emu10k1_capture; in snd_emu10k1_capture_mic_open()
1285 runtime->hw.rates = SNDRV_PCM_RATE_8000; in snd_emu10k1_capture_mic_open()
1286 runtime->hw.rate_min = runtime->hw.rate_max = 8000; in snd_emu10k1_capture_mic_open()
1289 emu->capture_mic_interrupt = snd_emu10k1_pcm_ac97mic_interrupt; in snd_emu10k1_capture_mic_open()
1290 emu->pcm_capture_mic_substream = substream; in snd_emu10k1_capture_mic_open()
1298 emu->capture_mic_interrupt = NULL; in snd_emu10k1_capture_mic_close()
1299 emu->pcm_capture_mic_substream = NULL; in snd_emu10k1_capture_mic_close()
1307 struct snd_pcm_runtime *runtime = substream->runtime; in snd_emu10k1_capture_efx_open()
1308 int nefx = emu->audigy ? 64 : 32; in snd_emu10k1_capture_efx_open()
1313 return -ENOMEM; in snd_emu10k1_capture_efx_open()
1314 epcm->emu = emu; in snd_emu10k1_capture_efx_open()
1315 epcm->type = CAPTURE_EFX; in snd_emu10k1_capture_efx_open()
1316 epcm->substream = substream; in snd_emu10k1_capture_efx_open()
1317 epcm->capture_ipr = IPR_EFXBUFFULL|IPR_EFXBUFHALFFULL; in snd_emu10k1_capture_efx_open()
1318 epcm->capture_inte = INTE_EFXBUFENABLE; in snd_emu10k1_capture_efx_open()
1319 epcm->capture_ba_reg = FXBA; in snd_emu10k1_capture_efx_open()
1320 epcm->capture_bs_reg = FXBS; in snd_emu10k1_capture_efx_open()
1321 epcm->capture_idx_reg = FXIDX; in snd_emu10k1_capture_efx_open()
1322 substream->runtime->private_data = epcm; in snd_emu10k1_capture_efx_open()
1323 substream->runtime->private_free = snd_emu10k1_pcm_free_substream; in snd_emu10k1_capture_efx_open()
1324 runtime->hw = snd_emu10k1_capture_efx; in snd_emu10k1_capture_efx_open()
1325 if (emu->card_capabilities->emu_model) { in snd_emu10k1_capture_efx_open()
1336 * but we don't exceed 16 channels anyway. in snd_emu10k1_capture_efx_open()
1340 runtime->hw.channels_min = runtime->hw.channels_max = 4; in snd_emu10k1_capture_efx_open()
1344 runtime->hw.channels_min = runtime->hw.channels_max = 2; in snd_emu10k1_capture_efx_open()
1346 runtime->hw.formats = SNDRV_PCM_FMTBIT_S32_LE; in snd_emu10k1_capture_efx_open()
1348 spin_lock_irq(&emu->reg_lock); in snd_emu10k1_capture_efx_open()
1349 runtime->hw.channels_min = runtime->hw.channels_max = 0; in snd_emu10k1_capture_efx_open()
1351 if (emu->efx_voices_mask[idx/32] & (1 << (idx%32))) { in snd_emu10k1_capture_efx_open()
1352 runtime->hw.channels_min++; in snd_emu10k1_capture_efx_open()
1353 runtime->hw.channels_max++; in snd_emu10k1_capture_efx_open()
1356 epcm->capture_cr_val = emu->efx_voices_mask[0]; in snd_emu10k1_capture_efx_open()
1357 epcm->capture_cr_val2 = emu->efx_voices_mask[1]; in snd_emu10k1_capture_efx_open()
1358 spin_unlock_irq(&emu->reg_lock); in snd_emu10k1_capture_efx_open()
1368 emu->capture_efx_interrupt = snd_emu10k1_pcm_efx_interrupt; in snd_emu10k1_capture_efx_open()
1369 emu->pcm_capture_efx_substream = substream; in snd_emu10k1_capture_efx_open()
1377 emu->capture_efx_interrupt = NULL; in snd_emu10k1_capture_efx_close()
1378 emu->pcm_capture_efx_substream = NULL; in snd_emu10k1_capture_efx_close()
1417 err = snd_pcm_new(emu->card, "emu10k1", device, 32, 1, &pcm); in snd_emu10k1_pcm()
1421 pcm->private_data = emu; in snd_emu10k1_pcm()
1426 pcm->info_flags = 0; in snd_emu10k1_pcm()
1427 pcm->dev_subclass = SNDRV_PCM_SUBCLASS_GENERIC_MIX; in snd_emu10k1_pcm()
1428 strcpy(pcm->name, "ADC Capture/Standard PCM Playback"); in snd_emu10k1_pcm()
1429 emu->pcm = pcm; in snd_emu10k1_pcm()
1432 …for (substream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; substream; substream = substre… in snd_emu10k1_pcm()
1434 &emu->pci->dev, in snd_emu10k1_pcm()
1437 …for (substream = pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream; substream; substream = substrea… in snd_emu10k1_pcm()
1439 &emu->pci->dev, 64*1024, 64*1024); in snd_emu10k1_pcm()
1450 err = snd_pcm_new(emu->card, "emu10k1", device, 1, 0, &pcm); in snd_emu10k1_pcm_multi()
1454 pcm->private_data = emu; in snd_emu10k1_pcm_multi()
1458 pcm->info_flags = 0; in snd_emu10k1_pcm_multi()
1459 pcm->dev_subclass = SNDRV_PCM_SUBCLASS_GENERIC_MIX; in snd_emu10k1_pcm_multi()
1460 strcpy(pcm->name, "Multichannel Playback"); in snd_emu10k1_pcm_multi()
1461 emu->pcm_multi = pcm; in snd_emu10k1_pcm_multi()
1463 …for (substream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; substream; substream = substre… in snd_emu10k1_pcm_multi()
1465 &emu->pci->dev, in snd_emu10k1_pcm_multi()
1485 err = snd_pcm_new(emu->card, "emu10k1 mic", device, 0, 1, &pcm); in snd_emu10k1_pcm_mic()
1489 pcm->private_data = emu; in snd_emu10k1_pcm_mic()
1493 pcm->info_flags = 0; in snd_emu10k1_pcm_mic()
1494 strcpy(pcm->name, "Mic Capture"); in snd_emu10k1_pcm_mic()
1495 emu->pcm_mic = pcm; in snd_emu10k1_pcm_mic()
1497 snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, &emu->pci->dev, in snd_emu10k1_pcm_mic()
1506 int nefx = emu->audigy ? 64 : 32; in snd_emu10k1_pcm_efx_voices_mask_info()
1507 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; in snd_emu10k1_pcm_efx_voices_mask_info()
1508 uinfo->count = nefx; in snd_emu10k1_pcm_efx_voices_mask_info()
1509 uinfo->value.integer.min = 0; in snd_emu10k1_pcm_efx_voices_mask_info()
1510 uinfo->value.integer.max = 1; in snd_emu10k1_pcm_efx_voices_mask_info()
1517 int nefx = emu->audigy ? 64 : 32; in snd_emu10k1_pcm_efx_voices_mask_get()
1521 ucontrol->value.integer.value[idx] = (emu->efx_voices_mask[idx / 32] & (1 << (idx % 32))) ? 1 : 0; in snd_emu10k1_pcm_efx_voices_mask_get()
1529 int nefx = emu->audigy ? 64 : 32; in snd_emu10k1_pcm_efx_voices_mask_put()
1534 if (ucontrol->value.integer.value[idx]) { in snd_emu10k1_pcm_efx_voices_mask_put()
1540 return -EINVAL; in snd_emu10k1_pcm_efx_voices_mask_put()
1542 spin_lock_irq(&emu->reg_lock); in snd_emu10k1_pcm_efx_voices_mask_put()
1543 change = (nval[0] != emu->efx_voices_mask[0]) || in snd_emu10k1_pcm_efx_voices_mask_put()
1544 (nval[1] != emu->efx_voices_mask[1]); in snd_emu10k1_pcm_efx_voices_mask_put()
1545 emu->efx_voices_mask[0] = nval[0]; in snd_emu10k1_pcm_efx_voices_mask_put()
1546 emu->efx_voices_mask[1] = nval[1]; in snd_emu10k1_pcm_efx_voices_mask_put()
1547 spin_unlock_irq(&emu->reg_lock); in snd_emu10k1_pcm_efx_voices_mask_put()
1571 #define INITIAL_TRAM_POS(size) ((((size) / 2) - INITIAL_TRAM_SHIFT) - 1)
1586 dev_dbg(emu->card->dev, in snd_emu10k1_fx8010_playback_tram_poke1()
1592 while (count--) { in snd_emu10k1_fx8010_playback_tram_poke1()
1593 *dst_left-- = *src++; in snd_emu10k1_fx8010_playback_tram_poke1()
1594 *dst_right-- = *src++; in snd_emu10k1_fx8010_playback_tram_poke1()
1597 while (count--) { in snd_emu10k1_fx8010_playback_tram_poke1()
1598 *dst_right-- = *src++; in snd_emu10k1_fx8010_playback_tram_poke1()
1599 *dst_left-- = *src++; in snd_emu10k1_fx8010_playback_tram_poke1()
1608 struct snd_emu10k1_fx8010_pcm *pcm = &emu->fx8010.pcm[substream->number]; in fx8010_pb_trans_copy()
1609 unsigned int tram_size = pcm->buffer_size; in fx8010_pb_trans_copy()
1610 unsigned short *src = (unsigned short *)(substream->runtime->dma_area + rec->sw_data); in fx8010_pb_trans_copy()
1612 unsigned int tram_pos = pcm->tram_pos; in fx8010_pb_trans_copy()
1613 unsigned int tram_shift = pcm->tram_shift; in fx8010_pb_trans_copy()
1617 snd_emu10k1_fx8010_playback_tram_poke1((unsigned short *)emu->fx8010.etram_pages.area + tram_pos, in fx8010_pb_trans_copy()
1618 (unsigned short *)emu->fx8010.etram_pages.area + tram_pos + tram_size / 2, in fx8010_pb_trans_copy()
1621 frames -= count; in fx8010_pb_trans_copy()
1622 tram_pos = (tram_size / 2) - 1; in fx8010_pb_trans_copy()
1625 snd_emu10k1_fx8010_playback_tram_poke1((unsigned short *)emu->fx8010.etram_pages.area + tram_pos, in fx8010_pb_trans_copy()
1626 (unsigned short *)emu->fx8010.etram_pages.area + tram_pos + tram_size / 2, in fx8010_pb_trans_copy()
1628 tram_pos -= frames; in fx8010_pb_trans_copy()
1629 pcm->tram_pos = tram_pos; in fx8010_pb_trans_copy()
1630 pcm->tram_shift = tram_shift; in fx8010_pb_trans_copy()
1636 struct snd_emu10k1_fx8010_pcm *pcm = &emu->fx8010.pcm[substream->number]; in snd_emu10k1_fx8010_playback_transfer()
1638 return snd_pcm_indirect_playback_transfer(substream, &pcm->pcm_rec, in snd_emu10k1_fx8010_playback_transfer()
1645 struct snd_emu10k1_fx8010_pcm *pcm = &emu->fx8010.pcm[substream->number]; in snd_emu10k1_fx8010_playback_hw_free()
1648 for (i = 0; i < pcm->channels; i++) in snd_emu10k1_fx8010_playback_hw_free()
1649 snd_emu10k1_ptr_write(emu, TANKMEMADDRREGBASE + 0x80 + pcm->etram[i], 0, 0); in snd_emu10k1_fx8010_playback_hw_free()
1656 struct snd_pcm_runtime *runtime = substream->runtime; in snd_emu10k1_fx8010_playback_prepare()
1657 struct snd_emu10k1_fx8010_pcm *pcm = &emu->fx8010.pcm[substream->number]; in snd_emu10k1_fx8010_playback_prepare()
1661 dev_dbg(emu->card->dev, "prepare: etram_pages = 0x%p, dma_area = 0x%x, " in snd_emu10k1_fx8010_playback_prepare()
1663 emu->fx8010.etram_pages, runtime->dma_area, in snd_emu10k1_fx8010_playback_prepare()
1664 runtime->buffer_size, runtime->buffer_size << 2); in snd_emu10k1_fx8010_playback_prepare()
1666 memset(&pcm->pcm_rec, 0, sizeof(pcm->pcm_rec)); in snd_emu10k1_fx8010_playback_prepare()
1667 pcm->pcm_rec.hw_buffer_size = pcm->buffer_size * 2; /* byte size */ in snd_emu10k1_fx8010_playback_prepare()
1668 pcm->pcm_rec.sw_buffer_size = snd_pcm_lib_buffer_bytes(substream); in snd_emu10k1_fx8010_playback_prepare()
1669 pcm->tram_pos = INITIAL_TRAM_POS(pcm->buffer_size); in snd_emu10k1_fx8010_playback_prepare()
1670 pcm->tram_shift = 0; in snd_emu10k1_fx8010_playback_prepare()
1672 emu->gpr_base + pcm->gpr_running, 0, /* reset */ in snd_emu10k1_fx8010_playback_prepare()
1673 emu->gpr_base + pcm->gpr_trigger, 0, /* reset */ in snd_emu10k1_fx8010_playback_prepare()
1674 emu->gpr_base + pcm->gpr_size, runtime->buffer_size, in snd_emu10k1_fx8010_playback_prepare()
1675 emu->gpr_base + pcm->gpr_ptr, 0, /* reset ptr number */ in snd_emu10k1_fx8010_playback_prepare()
1676 emu->gpr_base + pcm->gpr_count, runtime->period_size, in snd_emu10k1_fx8010_playback_prepare()
1677 emu->gpr_base + pcm->gpr_tmpcount, runtime->period_size, in snd_emu10k1_fx8010_playback_prepare()
1679 for (i = 0; i < pcm->channels; i++) in snd_emu10k1_fx8010_playback_prepare()
1680 …ANKMEMADDRREGBASE + 0x80 + pcm->etram[i], 0, (TANKMEMADDRREG_READ|TANKMEMADDRREG_ALIGN) + i * (run… in snd_emu10k1_fx8010_playback_prepare()
1687 struct snd_emu10k1_fx8010_pcm *pcm = &emu->fx8010.pcm[substream->number]; in snd_emu10k1_fx8010_playback_trigger()
1690 spin_lock(&emu->reg_lock); in snd_emu10k1_fx8010_playback_trigger()
1708 …register_irq_handler(emu, snd_emu10k1_fx8010_playback_irq, pcm->gpr_running, substream, &pcm->irq); in snd_emu10k1_fx8010_playback_trigger()
1712 snd_emu10k1_ptr_write(emu, emu->gpr_base + pcm->gpr_trigger, 0, 1); in snd_emu10k1_fx8010_playback_trigger()
1717 snd_emu10k1_fx8010_unregister_irq_handler(emu, &pcm->irq); in snd_emu10k1_fx8010_playback_trigger()
1718 snd_emu10k1_ptr_write(emu, emu->gpr_base + pcm->gpr_trigger, 0, 0); in snd_emu10k1_fx8010_playback_trigger()
1719 pcm->tram_pos = INITIAL_TRAM_POS(pcm->buffer_size); in snd_emu10k1_fx8010_playback_trigger()
1720 pcm->tram_shift = 0; in snd_emu10k1_fx8010_playback_trigger()
1723 result = -EINVAL; in snd_emu10k1_fx8010_playback_trigger()
1727 spin_unlock(&emu->reg_lock); in snd_emu10k1_fx8010_playback_trigger()
1734 struct snd_emu10k1_fx8010_pcm *pcm = &emu->fx8010.pcm[substream->number]; in snd_emu10k1_fx8010_playback_pointer()
1737 if (!snd_emu10k1_ptr_read(emu, emu->gpr_base + pcm->gpr_trigger, 0)) in snd_emu10k1_fx8010_playback_pointer()
1739 ptr = snd_emu10k1_ptr_read(emu, emu->gpr_base + pcm->gpr_ptr, 0) << 2; in snd_emu10k1_fx8010_playback_pointer()
1740 return snd_pcm_indirect_playback_pointer(substream, &pcm->pcm_rec, ptr); in snd_emu10k1_fx8010_playback_pointer()
1766 struct snd_pcm_runtime *runtime = substream->runtime; in snd_emu10k1_fx8010_playback_open()
1767 struct snd_emu10k1_fx8010_pcm *pcm = &emu->fx8010.pcm[substream->number]; in snd_emu10k1_fx8010_playback_open()
1769 runtime->hw = snd_emu10k1_fx8010_playback; in snd_emu10k1_fx8010_playback_open()
1770 runtime->hw.channels_min = runtime->hw.channels_max = pcm->channels; in snd_emu10k1_fx8010_playback_open()
1771 runtime->hw.period_bytes_max = (pcm->buffer_size * 2) / 2; in snd_emu10k1_fx8010_playback_open()
1772 spin_lock_irq(&emu->reg_lock); in snd_emu10k1_fx8010_playback_open()
1773 if (pcm->valid == 0) { in snd_emu10k1_fx8010_playback_open()
1774 spin_unlock_irq(&emu->reg_lock); in snd_emu10k1_fx8010_playback_open()
1775 return -ENODEV; in snd_emu10k1_fx8010_playback_open()
1777 pcm->opened = 1; in snd_emu10k1_fx8010_playback_open()
1778 spin_unlock_irq(&emu->reg_lock); in snd_emu10k1_fx8010_playback_open()
1785 struct snd_emu10k1_fx8010_pcm *pcm = &emu->fx8010.pcm[substream->number]; in snd_emu10k1_fx8010_playback_close()
1787 spin_lock_irq(&emu->reg_lock); in snd_emu10k1_fx8010_playback_close()
1788 pcm->opened = 0; in snd_emu10k1_fx8010_playback_close()
1789 spin_unlock_irq(&emu->reg_lock); in snd_emu10k1_fx8010_playback_close()
1809 err = snd_pcm_new(emu->card, "emu10k1 efx", device, emu->audigy ? 0 : 8, 1, &pcm); in snd_emu10k1_pcm_efx()
1813 pcm->private_data = emu; in snd_emu10k1_pcm_efx()
1815 if (!emu->audigy) in snd_emu10k1_pcm_efx()
1819 pcm->info_flags = 0; in snd_emu10k1_pcm_efx()
1820 if (emu->audigy) in snd_emu10k1_pcm_efx()
1821 strcpy(pcm->name, "Multichannel Capture"); in snd_emu10k1_pcm_efx()
1823 strcpy(pcm->name, "Multichannel Capture/PT Playback"); in snd_emu10k1_pcm_efx()
1824 emu->pcm_efx = pcm; in snd_emu10k1_pcm_efx()
1826 if (!emu->card_capabilities->emu_model) { in snd_emu10k1_pcm_efx()
1828 // The mask determines which of these and the EXTOUTs the multi- in snd_emu10k1_pcm_efx()
1830 if (emu->audigy) { in snd_emu10k1_pcm_efx()
1831 emu->efx_voices_mask[0] = 0; in snd_emu10k1_pcm_efx()
1832 emu->efx_voices_mask[1] = 0xffff; in snd_emu10k1_pcm_efx()
1834 emu->efx_voices_mask[0] = 0xffff0000; in snd_emu10k1_pcm_efx()
1835 emu->efx_voices_mask[1] = 0; in snd_emu10k1_pcm_efx()
1839 return -ENOMEM; in snd_emu10k1_pcm_efx()
1840 kctl->id.device = device; in snd_emu10k1_pcm_efx()
1841 err = snd_ctl_add(emu->card, kctl); in snd_emu10k1_pcm_efx()
1845 // On E-MU cards, the DSP code copies the P16VINs/EMU32INs to in snd_emu10k1_pcm_efx()
1850 snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, &emu->pci->dev, in snd_emu10k1_pcm_efx()