Lines Matching +full:p +full:- +full:384

1 // SPDX-License-Identifier: GPL-2.0-or-later
4 * Lee Revell <rlrevell@joe-job.com>
5 * James Courtier-Dutton <James@superbug.co.uk>
25 epcm = voice->epcm;
28 if (epcm->substream == NULL)
31 dev_dbg(emu->card->dev,
33 epcm->substream->runtime->hw->pointer(emu, epcm->substream),
34 snd_pcm_lib_period_bytes(epcm->substream),
35 snd_pcm_lib_buffer_bytes(epcm->substream));
37 snd_pcm_period_elapsed(epcm->substream);
45 if (emu->pcm_capture_substream->runtime->mode == SNDRV_PCM_MODE_FRAME)
49 snd_pcm_period_elapsed(emu->pcm_capture_substream);
57 if (emu->pcm_capture_mic_substream->runtime->mode == SNDRV_PCM_MODE_FRAME)
61 snd_pcm_period_elapsed(emu->pcm_capture_mic_substream);
69 if (emu->pcm_capture_efx_substream->runtime->mode == SNDRV_PCM_MODE_FRAME)
73 snd_pcm_period_elapsed(emu->pcm_capture_efx_substream);
78 for (unsigned i = 0; i < ARRAY_SIZE(epcm->voices); i++) {
79 if (epcm->voices[i]) {
80 snd_emu10k1_voice_free(epcm->emu, epcm->voices[i]);
81 epcm->voices[i] = NULL;
93 err = snd_emu10k1_voice_alloc(epcm->emu,
95 epcm, &epcm->voices[0]);
99 if (epcm->extra == NULL) {
100 // The hardware supports only (half-)loop interrupts, so to support an
102 // period-sized loop as the interrupt source. Additionally, the interrupt
104 err = snd_emu10k1_voice_alloc(epcm->emu,
106 epcm, &epcm->extra);
109 dev_dbg(emu->card->dev, "pcm_channel_alloc: "
116 epcm->extra->interrupt = snd_emu10k1_pcm_interrupt;
122 // Primes 2-7 and 2^n multiples thereof, up to 16.
134 384, 448, 512, 640,
135 384*2, 448*2, 512*2, 640*2,
136 384*4, 448*4, 512*4, 640*4,
137 384*8, 448*8, 512*8, 640*8,
138 384*16, 448*16, 512*16, 640*16,
139 384*32, 448*32, 512*32, 640*32,
140 384*64, 448*64, 512*64, 640*64,
141 384*128,448*128,512*128
188 if (emu->card_capabilities->emu_model &&
189 emu->emu1010.word_clock == 44100) {
190 runtime->hw.rates = SNDRV_PCM_RATE_11025 | \
193 runtime->hw.rate_min = 11025;
194 runtime->hw.rate_max = 44100;
195 } else if (emu->audigy) {
196 runtime->hw.rates = SNDRV_PCM_RATE_8000_48000 |
207 rate = emu->emu1010.word_clock;
208 runtime->hw.rate_min = runtime->hw.rate_max = rate;
209 runtime->hw.rates = snd_pcm_rate_to_rate_bit(rate);
271 voice = evoice->number;
273 silent_page = ((unsigned int)emu->silent_page.addr << emu->address_mode) |
274 (emu->address_mode ? MAP_PTI_MASK1 : MAP_PTI_MASK0);
283 CCCA, emu10k1_select_interprom(evoice->epcm->pitch_target) |
296 if (emu->audigy) {
312 emu->voices[voice].dirty = 1;
322 guard(spinlock_irq)(&emu->reg_lock);
325 &mix->send_routing[stereo][0],
326 &mix->send_volume[stereo][0]);
330 &mix->send_routing[2][0],
331 &mix->send_volume[2][0]);
352 struct snd_pcm_runtime *runtime = substream->runtime;
353 struct snd_emu10k1_pcm *epcm = runtime->private_data;
358 if (epcm->type == PLAYBACK_EMUVOICE) {
372 if (emu->iommu_workaround)
377 if (emu->iommu_workaround && runtime->dma_bytes >= EMUPAGESIZE)
378 runtime->dma_bytes -= EMUPAGESIZE;
381 if (epcm->memblk != NULL)
382 snd_emu10k1_free_pages(emu, epcm->memblk);
383 epcm->memblk = snd_emu10k1_alloc_pages(emu, substream);
384 epcm->start_addr = 0;
385 if (! epcm->memblk)
386 return -ENOMEM;
387 mapped = ((struct snd_emu10k1_memblk *)epcm->memblk)->mapped_page;
389 return -ENOMEM;
390 epcm->start_addr = mapped << PAGE_SHIFT;
398 struct snd_pcm_runtime *runtime = substream->runtime;
401 if (runtime->private_data == NULL)
403 epcm = runtime->private_data;
404 if (epcm->extra) {
405 snd_emu10k1_voice_free(epcm->emu, epcm->extra);
406 epcm->extra = NULL;
409 if (epcm->memblk) {
410 snd_emu10k1_free_pages(emu, epcm->memblk);
411 epcm->memblk = NULL;
412 epcm->start_addr = 0;
421 struct snd_pcm_runtime *runtime = substream->runtime;
422 struct snd_emu10k1_pcm *epcm = runtime->private_data;
423 bool w_16 = snd_pcm_format_width(runtime->format) == 16;
424 bool stereo = runtime->channels == 2;
428 rate = runtime->rate;
429 if (emu->card_capabilities->emu_model &&
430 emu->emu1010.word_clock == 44100)
432 epcm->pitch_target = emu10k1_calc_pitch_target(rate);
434 start_addr = epcm->start_addr >> w_16;
435 end_addr = start_addr + runtime->period_size;
436 snd_emu10k1_pcm_init_extra_voice(emu, epcm->extra, w_16,
439 epcm->ccca_start_addr = start_addr;
440 end_addr = start_addr + runtime->buffer_size;
441 snd_emu10k1_pcm_init_voices(emu, epcm->voices[0], w_16, stereo,
443 &emu->pcm_mixer[substream->number]);
451 struct snd_pcm_runtime *runtime = substream->runtime;
452 struct snd_emu10k1_pcm *epcm = runtime->private_data;
457 epcm->pitch_target = PITCH_48000;
459 start_addr = epcm->start_addr >> 1; // 16-bit voices
461 extra_size = runtime->period_size;
462 channel_size = runtime->buffer_size;
464 snd_emu10k1_pcm_init_extra_voice(emu, epcm->extra, true,
467 epcm->ccca_start_addr = start_addr;
468 for (i = 0; i < runtime->channels; i++) {
469 snd_emu10k1_pcm_init_voices(emu, epcm->voices[i], true, false,
471 &emu->efx_pcm_mixer[i]);
500 struct snd_pcm_runtime *runtime = substream->runtime;
501 struct snd_emu10k1_pcm *epcm = runtime->private_data;
505 snd_emu10k1_ptr_write(emu, epcm->capture_bs_reg, 0, 0);
506 switch (epcm->type) {
511 if (emu->card_capabilities->emu_model) {
512 // The upper 32 16-bit capture voices, two for each of the 16 32-bit channels.
514 epcm->capture_cr_val = 0;
515 epcm->capture_cr_val2 = 0xffffffff >> (32 - runtime->channels * 2);
517 if (emu->audigy) {
528 snd_emu10k1_ptr_write(emu, epcm->capture_ba_reg, 0, runtime->dma_addr);
529 epcm->capture_bufsize = snd_pcm_lib_buffer_bytes(substream);
530 epcm->capture_bs_val = 0;
532 if (capture_buffer_sizes[idx] == epcm->capture_bufsize) {
533 epcm->capture_bs_val = idx + 1;
537 if (epcm->capture_bs_val == 0) {
539 epcm->capture_bs_val++;
541 if (epcm->type == CAPTURE_AC97ADC) {
542 unsigned rate = runtime->rate;
543 if (!(runtime->hw.rates & SNDRV_PCM_RATE_48000))
546 epcm->capture_cr_val = emu->audigy ? A_ADCCR_LCHANENABLE : ADCCR_LCHANENABLE;
547 if (runtime->channels > 1)
548 epcm->capture_cr_val |= emu->audigy ? A_ADCCR_RCHANENABLE : ADCCR_RCHANENABLE;
549 epcm->capture_cr_val |= emu->audigy ?
566 // except for 16-bit stereo. And the interpolator will actually
567 // access them at all only when we're pitch-shifting.
572 ccr = (64 - 3) << REG_SHIFT(CCR_CACHEINVALIDSIZE);
585 struct snd_pcm_substream *substream = epcm->substream;
586 struct snd_pcm_runtime *runtime = substream->runtime;
587 unsigned eloop_start = epcm->start_addr >> w_16;
589 unsigned eloop_size = runtime->period_size;
590 unsigned loop_size = runtime->buffer_size;
595 // - The actual position is delayed by the cache size (64 frames)
596 // - The interpolator is centered around the 4th frame
597 loop_start += (epcm->resume_pos + 64 - 3) % loop_size;
599 unsigned voice = epcm->voices[i]->number;
609 // In principle, this wouldn't need to be the cache's entire size - in
614 // align them with the interrupts. This makes a non-delayed interrupt
616 // for (CA - CIS) >= period_boundary for every channel in the stream.
618 // This is why all other (open) drivers for these chips use timer-based
621 eloop_start += (epcm->resume_pos + eloop_size - 3) % eloop_size;
622 snd_emu10k1_ptr_write(emu, CCCA_CURRADDR, epcm->extra->number, eloop_start);
632 snd_emu10k1_ptr_write_multiple(emu, evoice->number,
647 vattn = mix->attn[tmp] << 16;
692 voice = evoice->number;
693 snd_emu10k1_playback_commit_pitch(emu, voice, evoice->epcm->pitch_target << 16);
701 voice = evoice->number;
708 epcm->running = 1;
709 snd_emu10k1_voice_intr_enable(emu, epcm->extra->number);
715 snd_emu10k1_voice_intr_disable(emu, epcm->extra->number);
716 epcm->running = 0;
723 struct snd_pcm_runtime *runtime = substream->runtime;
724 struct snd_emu10k1_pcm *epcm = runtime->private_data;
726 bool w_16 = snd_pcm_format_width(runtime->format) == 16;
727 bool stereo = runtime->channels == 2;
730 dev_dbg(emu->card->dev,
731 "trigger - emu10k1 = 0x%x, cmd = %i, pointer = %i\n",
732 (int)emu, cmd, substream->ops->pointer(substream))
734 guard(spinlock)(&emu->reg_lock);
741 mix = &emu->pcm_mixer[substream->number];
742 snd_emu10k1_playback_unmute_voices(emu, epcm->voices[0], stereo, mix);
744 snd_emu10k1_playback_trigger_voice(emu, epcm->voices[0]);
745 snd_emu10k1_playback_trigger_voice(emu, epcm->extra);
750 snd_emu10k1_playback_stop_voice(emu, epcm->voices[0]);
751 snd_emu10k1_playback_stop_voice(emu, epcm->extra);
753 snd_emu10k1_playback_mute_voices(emu, epcm->voices[0], stereo);
756 return -EINVAL;
765 struct snd_pcm_runtime *runtime = substream->runtime;
766 struct snd_emu10k1_pcm *epcm = runtime->private_data;
768 guard(spinlock)(&emu->reg_lock);
773 outl(epcm->capture_ipr, emu->port + IPR);
774 snd_emu10k1_intr_enable(emu, epcm->capture_inte);
776 dev_dbg(emu->card->dev, "adccr = 0x%x, adcbs = 0x%x\n",
777 epcm->adccr, epcm->adcbs);
779 switch (epcm->type) {
781 snd_emu10k1_ptr_write(emu, ADCCR, 0, epcm->capture_cr_val);
784 if (emu->audigy) {
786 A_FXWC1, epcm->capture_cr_val,
787 A_FXWC2, epcm->capture_cr_val2,
789 dev_dbg(emu->card->dev,
791 epcm->capture_cr_val,
792 epcm->capture_cr_val2);
794 snd_emu10k1_ptr_write(emu, FXWC, 0, epcm->capture_cr_val);
799 snd_emu10k1_ptr_write(emu, epcm->capture_bs_reg, 0, epcm->capture_bs_val);
800 epcm->running = 1;
801 epcm->first_ptr = 1;
805 epcm->running = 0;
806 snd_emu10k1_intr_disable(emu, epcm->capture_inte);
807 outl(epcm->capture_ipr, emu->port + IPR);
808 snd_emu10k1_ptr_write(emu, epcm->capture_bs_reg, 0, 0);
809 switch (epcm->type) {
814 if (emu->audigy) {
827 return -EINVAL;
835 struct snd_pcm_runtime *runtime = substream->runtime;
836 struct snd_emu10k1_pcm *epcm = runtime->private_data;
839 if (!epcm->running)
842 ptr = snd_emu10k1_ptr_read(emu, CCCA, epcm->voices[0]->number) & 0x00ffffff;
843 ptr -= epcm->ccca_start_addr;
845 // This is the size of the whole cache minus the interpolator read-ahead,
850 // already read the buffer, and set runtime->delay accordingly. However,
852 // to obtain), so only a fixed worst-case value would be practical.
854 ptr -= 64 - 3;
856 ptr += runtime->buffer_size;
859 dev_dbg(emu->card->dev,
861 (long)ptr, (long)runtime->buffer_size,
862 (long)runtime->period_size);
873 int voice = epcm->voices[i]->number;
884 int voice = epcm->voices[i]->number;
895 snd_emu10k1_playback_unmute_voice(emu, epcm->voices[i], false, true,
896 &emu->efx_pcm_mixer[i]);
904 snd_emu10k1_playback_stop_voice(emu, epcm->voices[i]);
908 snd_emu10k1_playback_mute_voice(emu, epcm->voices[i]);
915 struct snd_pcm_runtime *runtime = substream->runtime;
916 struct snd_emu10k1_pcm *epcm = runtime->private_data;
920 guard(spinlock)(&emu->reg_lock);
926 epcm, runtime->channels);
932 emu, epcm, runtime->channels);
934 emu, epcm, true, false, runtime->channels);
940 snd_emu10k1_efx_playback_unmute_voices(emu, epcm, runtime->channels);
946 snd_emu10k1_playback_trigger_voice(emu, epcm->extra);
951 emu, epcm, runtime->channels);
953 if (result != -EAGAIN)
962 snd_emu10k1_playback_stop_voice(emu, epcm->extra);
964 emu, epcm, runtime->channels);
966 epcm->resume_pos = snd_emu10k1_playback_pointer(substream);
969 return -EINVAL;
978 struct snd_pcm_runtime *runtime = substream->runtime;
979 struct snd_emu10k1_pcm *epcm = runtime->private_data;
982 if (!epcm->running)
984 if (epcm->first_ptr) {
986 epcm->first_ptr = 0;
988 ptr = snd_emu10k1_ptr_read(emu, epcm->capture_idx_reg, 0) & 0x0000ffff;
1032 .period_bytes_min = 384,
1052 .period_bytes_min = 384,
1070 kctl->vd[idx].access &= ~SNDRV_CTL_ELEM_ACCESS_INACTIVE;
1072 kctl->vd[idx].access |= SNDRV_CTL_ELEM_ACCESS_INACTIVE;
1073 snd_ctl_notify(emu->card, SNDRV_CTL_EVENT_MASK_VALUE |
1080 snd_emu10k1_pcm_mixer_notify1(emu, emu->ctl_send_routing, idx, activate);
1081 snd_emu10k1_pcm_mixer_notify1(emu, emu->ctl_send_volume, idx, activate);
1082 snd_emu10k1_pcm_mixer_notify1(emu, emu->ctl_attn, idx, activate);
1087 snd_emu10k1_pcm_mixer_notify1(emu, emu->ctl_efx_send_routing, idx, activate);
1088 snd_emu10k1_pcm_mixer_notify1(emu, emu->ctl_efx_send_volume, idx, activate);
1089 snd_emu10k1_pcm_mixer_notify1(emu, emu->ctl_efx_attn, idx, activate);
1094 kfree(runtime->private_data);
1104 mix = &emu->efx_pcm_mixer[i];
1105 mix->epcm = NULL;
1132 struct snd_pcm_runtime *runtime = substream->runtime;
1137 return -ENOMEM;
1138 epcm->emu = emu;
1139 epcm->type = PLAYBACK_EFX;
1140 epcm->substream = substream;
1142 runtime->private_data = epcm;
1143 runtime->private_free = snd_emu10k1_pcm_free_substream;
1144 runtime->hw = snd_emu10k1_efx_playback;
1145 if (emu->card_capabilities->emu_model)
1154 mix = &emu->efx_pcm_mixer[i];
1156 mix->send_routing[0][j] = i + j;
1157 memset(&mix->send_volume, 0, sizeof(mix->send_volume));
1158 mix->send_volume[0][0] = 255;
1159 mix->attn[0] = 0x8000;
1160 mix->epcm = epcm;
1171 struct snd_pcm_runtime *runtime = substream->runtime;
1176 return -ENOMEM;
1177 epcm->emu = emu;
1178 epcm->type = PLAYBACK_EMUVOICE;
1179 epcm->substream = substream;
1180 runtime->private_data = epcm;
1181 runtime->private_free = snd_emu10k1_pcm_free_substream;
1182 runtime->hw = snd_emu10k1_playback;
1188 if (emu->card_capabilities->emu_model)
1189 sample_rate = emu->emu1010.word_clock;
1197 mix = &emu->pcm_mixer[substream->number];
1199 mix->send_routing[0][i] = mix->send_routing[1][i] = mix->send_routing[2][i] = i;
1200 memset(&mix->send_volume, 0, sizeof(mix->send_volume));
1201 mix->send_volume[0][0] = mix->send_volume[0][1] =
1202 mix->send_volume[1][0] = mix->send_volume[2][1] = 255;
1203 mix->attn[0] = mix->attn[1] = mix->attn[2] = 0x8000;
1204 mix->epcm = epcm;
1205 snd_emu10k1_pcm_mixer_notify(emu, substream->number, 1);
1212 struct snd_emu10k1_pcm_mixer *mix = &emu->pcm_mixer[substream->number];
1214 mix->epcm = NULL;
1215 snd_emu10k1_pcm_mixer_notify(emu, substream->number, 0);
1222 struct snd_pcm_runtime *runtime = substream->runtime;
1227 return -ENOMEM;
1228 epcm->emu = emu;
1229 epcm->type = CAPTURE_AC97ADC;
1230 epcm->substream = substream;
1231 epcm->capture_ipr = IPR_ADCBUFFULL|IPR_ADCBUFHALFFULL;
1232 epcm->capture_inte = INTE_ADCBUFENABLE;
1233 epcm->capture_ba_reg = ADCBA;
1234 epcm->capture_bs_reg = ADCBS;
1235 epcm->capture_idx_reg = emu->audigy ? A_ADCIDX : ADCIDX;
1236 runtime->private_data = epcm;
1237 runtime->private_free = snd_emu10k1_pcm_free_substream;
1238 runtime->hw = snd_emu10k1_capture;
1242 emu->capture_interrupt = snd_emu10k1_pcm_ac97adc_interrupt;
1243 emu->pcm_capture_substream = substream;
1251 emu->capture_interrupt = NULL;
1252 emu->pcm_capture_substream = NULL;
1260 struct snd_pcm_runtime *runtime = substream->runtime;
1264 return -ENOMEM;
1265 epcm->emu = emu;
1266 epcm->type = CAPTURE_AC97MIC;
1267 epcm->substream = substream;
1268 epcm->capture_ipr = IPR_MICBUFFULL|IPR_MICBUFHALFFULL;
1269 epcm->capture_inte = INTE_MICBUFENABLE;
1270 epcm->capture_ba_reg = MICBA;
1271 epcm->capture_bs_reg = MICBS;
1272 epcm->capture_idx_reg = emu->audigy ? A_MICIDX : MICIDX;
1273 substream->runtime->private_data = epcm;
1274 substream->runtime->private_free = snd_emu10k1_pcm_free_substream;
1275 runtime->hw = snd_emu10k1_capture;
1276 runtime->hw.rates = SNDRV_PCM_RATE_8000;
1277 runtime->hw.rate_min = runtime->hw.rate_max = 8000;
1280 emu->capture_mic_interrupt = snd_emu10k1_pcm_ac97mic_interrupt;
1281 emu->pcm_capture_mic_substream = substream;
1289 emu->capture_mic_interrupt = NULL;
1290 emu->pcm_capture_mic_substream = NULL;
1298 struct snd_pcm_runtime *runtime = substream->runtime;
1299 int nefx = emu->audigy ? 64 : 32;
1304 return -ENOMEM;
1305 epcm->emu = emu;
1306 epcm->type = CAPTURE_EFX;
1307 epcm->substream = substream;
1308 epcm->capture_ipr = IPR_EFXBUFFULL|IPR_EFXBUFHALFFULL;
1309 epcm->capture_inte = INTE_EFXBUFENABLE;
1310 epcm->capture_ba_reg = FXBA;
1311 epcm->capture_bs_reg = FXBS;
1312 epcm->capture_idx_reg = FXIDX;
1313 substream->runtime->private_data = epcm;
1314 substream->runtime->private_free = snd_emu10k1_pcm_free_substream;
1315 runtime->hw = snd_emu10k1_capture_efx;
1316 if (emu->card_capabilities->emu_model) {
1331 runtime->hw.channels_min = runtime->hw.channels_max = 4;
1335 runtime->hw.channels_min = runtime->hw.channels_max = 2;
1337 runtime->hw.formats = SNDRV_PCM_FMTBIT_S32_LE;
1339 guard(spinlock_irq)(&emu->reg_lock);
1340 runtime->hw.channels_min = runtime->hw.channels_max = 0;
1342 if (emu->efx_voices_mask[idx/32] & (1 << (idx%32))) {
1343 runtime->hw.channels_min++;
1344 runtime->hw.channels_max++;
1347 epcm->capture_cr_val = emu->efx_voices_mask[0];
1348 epcm->capture_cr_val2 = emu->efx_voices_mask[1];
1358 emu->capture_efx_interrupt = snd_emu10k1_pcm_efx_interrupt;
1359 emu->pcm_capture_efx_substream = substream;
1367 emu->capture_efx_interrupt = NULL;
1368 emu->pcm_capture_efx_substream = NULL;
1407 err = snd_pcm_new(emu->card, "emu10k1", device, 32, 1, &pcm);
1411 pcm->private_data = emu;
1416 pcm->info_flags = 0;
1417 pcm->dev_subclass = SNDRV_PCM_SUBCLASS_GENERIC_MIX;
1418 strscpy(pcm->name, "ADC Capture/Standard PCM Playback");
1419 emu->pcm = pcm;
1422 for (substream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; substream; substream = substream->next)
1424 &emu->pci->dev,
1427 for (substream = pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream; substream; substream = substream->next)
1429 &emu->pci->dev, 64*1024, 64*1024);
1440 err = snd_pcm_new(emu->card, "emu10k1", device, 1, 0, &pcm);
1444 pcm->private_data = emu;
1448 pcm->info_flags = 0;
1449 pcm->dev_subclass = SNDRV_PCM_SUBCLASS_GENERIC_MIX;
1450 strscpy(pcm->name, "Multichannel Playback");
1451 emu->pcm_multi = pcm;
1453 for (substream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; substream; substream = substream->next)
1455 &emu->pci->dev,
1475 err = snd_pcm_new(emu->card, "emu10k1 mic", device, 0, 1, &pcm);
1479 pcm->private_data = emu;
1483 pcm->info_flags = 0;
1484 strscpy(pcm->name, "Mic Capture");
1485 emu->pcm_mic = pcm;
1487 snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, &emu->pci->dev,
1496 int nefx = emu->audigy ? 64 : 32;
1497 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
1498 uinfo->count = nefx;
1499 uinfo->value.integer.min = 0;
1500 uinfo->value.integer.max = 1;
1507 int nefx = emu->audigy ? 64 : 32;
1511 ucontrol->value.integer.value[idx] = (emu->efx_voices_mask[idx / 32] & (1 << (idx % 32))) ? 1 : 0;
1519 int nefx = emu->audigy ? 64 : 32;
1524 if (ucontrol->value.integer.value[idx]) {
1530 return -EINVAL;
1532 guard(spinlock_irq)(&emu->reg_lock);
1533 change = (nval[0] != emu->efx_voices_mask[0]) ||
1534 (nval[1] != emu->efx_voices_mask[1]);
1535 emu->efx_voices_mask[0] = nval[0];
1536 emu->efx_voices_mask[1] = nval[1];
1560 #define INITIAL_TRAM_POS(size) ((((size) / 2) - INITIAL_TRAM_SHIFT) - 1)
1575 dev_dbg(emu->card->dev,
1576 "tram_poke1: dst_left = 0x%p, dst_right = 0x%p, "
1577 "src = 0x%p, count = 0x%x\n",
1581 while (count--) {
1582 *dst_left-- = *src++;
1583 *dst_right-- = *src++;
1586 while (count--) {
1587 *dst_right-- = *src++;
1588 *dst_left-- = *src++;
1597 struct snd_emu10k1_fx8010_pcm *pcm = &emu->fx8010.pcm[substream->number];
1598 unsigned int tram_size = pcm->buffer_size;
1599 unsigned short *src = (unsigned short *)(substream->runtime->dma_area + rec->sw_data);
1601 unsigned int tram_pos = pcm->tram_pos;
1602 unsigned int tram_shift = pcm->tram_shift;
1606 snd_emu10k1_fx8010_playback_tram_poke1((unsigned short *)emu->fx8010.etram_pages.area + tram_pos,
1607 (unsigned short *)emu->fx8010.etram_pages.area + tram_pos + tram_size / 2,
1610 frames -= count;
1611 tram_pos = (tram_size / 2) - 1;
1614 snd_emu10k1_fx8010_playback_tram_poke1((unsigned short *)emu->fx8010.etram_pages.area + tram_pos,
1615 (unsigned short *)emu->fx8010.etram_pages.area + tram_pos + tram_size / 2,
1617 tram_pos -= frames;
1618 pcm->tram_pos = tram_pos;
1619 pcm->tram_shift = tram_shift;
1625 struct snd_emu10k1_fx8010_pcm *pcm = &emu->fx8010.pcm[substream->number];
1627 return snd_pcm_indirect_playback_transfer(substream, &pcm->pcm_rec,
1634 struct snd_emu10k1_fx8010_pcm *pcm = &emu->fx8010.pcm[substream->number];
1637 for (i = 0; i < pcm->channels; i++)
1638 snd_emu10k1_ptr_write(emu, TANKMEMADDRREGBASE + 0x80 + pcm->etram[i], 0, 0);
1645 struct snd_pcm_runtime *runtime = substream->runtime;
1646 struct snd_emu10k1_fx8010_pcm *pcm = &emu->fx8010.pcm[substream->number];
1650 dev_dbg(emu->card->dev, "prepare: etram_pages = 0x%p, dma_area = 0x%x, "
1652 emu->fx8010.etram_pages, runtime->dma_area,
1653 runtime->buffer_size, runtime->buffer_size << 2);
1655 memset(&pcm->pcm_rec, 0, sizeof(pcm->pcm_rec));
1656 pcm->pcm_rec.hw_buffer_size = pcm->buffer_size * 2; /* byte size */
1657 pcm->pcm_rec.sw_buffer_size = snd_pcm_lib_buffer_bytes(substream);
1658 pcm->tram_pos = INITIAL_TRAM_POS(pcm->buffer_size);
1659 pcm->tram_shift = 0;
1661 emu->gpr_base + pcm->gpr_running, 0, /* reset */
1662 emu->gpr_base + pcm->gpr_trigger, 0, /* reset */
1663 emu->gpr_base + pcm->gpr_size, runtime->buffer_size,
1664 emu->gpr_base + pcm->gpr_ptr, 0, /* reset ptr number */
1665 emu->gpr_base + pcm->gpr_count, runtime->period_size,
1666 emu->gpr_base + pcm->gpr_tmpcount, runtime->period_size,
1668 for (i = 0; i < pcm->channels; i++)
1669 snd_emu10k1_ptr_write(emu, TANKMEMADDRREGBASE + 0x80 + pcm->etram[i], 0, (TANKMEMADDRREG_READ|TANKMEMADDRREG_ALIGN) + i * (runtime->buffer_size / pcm->channels));
1676 struct snd_emu10k1_fx8010_pcm *pcm = &emu->fx8010.pcm[substream->number];
1679 guard(spinlock)(&emu->reg_lock);
1697 result = snd_emu10k1_fx8010_register_irq_handler(emu, snd_emu10k1_fx8010_playback_irq, pcm->gpr_running, substream, &pcm->irq);
1701 snd_emu10k1_ptr_write(emu, emu->gpr_base + pcm->gpr_trigger, 0, 1);
1706 snd_emu10k1_fx8010_unregister_irq_handler(emu, &pcm->irq);
1707 snd_emu10k1_ptr_write(emu, emu->gpr_base + pcm->gpr_trigger, 0, 0);
1708 pcm->tram_pos = INITIAL_TRAM_POS(pcm->buffer_size);
1709 pcm->tram_shift = 0;
1712 return -EINVAL;
1720 struct snd_emu10k1_fx8010_pcm *pcm = &emu->fx8010.pcm[substream->number];
1723 if (!snd_emu10k1_ptr_read(emu, emu->gpr_base + pcm->gpr_trigger, 0))
1725 ptr = snd_emu10k1_ptr_read(emu, emu->gpr_base + pcm->gpr_ptr, 0) << 2;
1726 return snd_pcm_indirect_playback_pointer(substream, &pcm->pcm_rec, ptr);
1752 struct snd_pcm_runtime *runtime = substream->runtime;
1753 struct snd_emu10k1_fx8010_pcm *pcm = &emu->fx8010.pcm[substream->number];
1755 runtime->hw = snd_emu10k1_fx8010_playback;
1756 runtime->hw.channels_min = runtime->hw.channels_max = pcm->channels;
1757 runtime->hw.period_bytes_max = (pcm->buffer_size * 2) / 2;
1758 guard(spinlock_irq)(&emu->reg_lock);
1759 if (pcm->valid == 0)
1760 return -ENODEV;
1761 pcm->opened = 1;
1768 struct snd_emu10k1_fx8010_pcm *pcm = &emu->fx8010.pcm[substream->number];
1770 guard(spinlock_irq)(&emu->reg_lock);
1771 pcm->opened = 0;
1791 err = snd_pcm_new(emu->card, "emu10k1 efx", device, emu->audigy ? 0 : 8, 1, &pcm);
1795 pcm->private_data = emu;
1797 if (!emu->audigy)
1801 pcm->info_flags = 0;
1802 if (emu->audigy)
1803 strscpy(pcm->name, "Multichannel Capture");
1805 strscpy(pcm->name, "Multichannel Capture/PT Playback");
1806 emu->pcm_efx = pcm;
1808 if (!emu->card_capabilities->emu_model) {
1810 // The mask determines which of these and the EXTOUTs the multi-
1812 if (emu->audigy) {
1813 emu->efx_voices_mask[0] = 0;
1814 emu->efx_voices_mask[1] = 0xffff;
1816 emu->efx_voices_mask[0] = 0xffff0000;
1817 emu->efx_voices_mask[1] = 0;
1821 return -ENOMEM;
1822 kctl->id.device = device;
1823 err = snd_ctl_add(emu->card, kctl);
1827 // On E-MU cards, the DSP code copies the P16VINs/EMU32INs to
1832 snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, &emu->pci->dev,