• Home
  • Raw
  • Download

Lines Matching +full:ec +full:- +full:codec

1 // SPDX-License-Identifier: GPL-2.0-or-later
11 * ---
23 #include <linux/dma-mapping.h>
57 dev_dbg(trident->card->dev, "Trident voice %i:\n", voice);
60 dev_dbg(trident->card->dev, "LBA: 0x%x\n", val);
62 dev_dbg(trident->card->dev, "GVSel: %i\n", val >> 31);
63 dev_dbg(trident->card->dev, "Pan: 0x%x\n", (val >> 24) & 0x7f);
64 dev_dbg(trident->card->dev, "Vol: 0x%x\n", (val >> 16) & 0xff);
65 dev_dbg(trident->card->dev, "CTRL: 0x%x\n", (val >> 12) & 0x0f);
66 dev_dbg(trident->card->dev, "EC: 0x%x\n", val & 0x0fff);
67 if (trident->device != TRIDENT_DEVICE_ID_NX) {
69 dev_dbg(trident->card->dev, "CSO: 0x%x\n", val >> 16);
70 dev_dbg(trident->card->dev, "Alpha: 0x%x\n", (val >> 4) & 0x0fff);
71 dev_dbg(trident->card->dev, "FMS: 0x%x\n", val & 0x0f);
73 dev_dbg(trident->card->dev, "ESO: 0x%x\n", val >> 16);
74 dev_dbg(trident->card->dev, "Delta: 0x%x\n", val & 0xffff);
79 dev_dbg(trident->card->dev, "CSO: 0x%x\n", val & 0x00ffffff);
82 dev_dbg(trident->card->dev, "Delta: 0x%x\n", tmp);
83 dev_dbg(trident->card->dev, "ESO: 0x%x\n", val & 0x00ffffff);
85 dev_dbg(trident->card->dev, "Alpha: 0x%x\n", val >> 20);
86 dev_dbg(trident->card->dev, "FMS: 0x%x\n", (val >> 16) & 0x0f);
88 dev_dbg(trident->card->dev, "FMC: 0x%x\n", (val >> 14) & 3);
89 dev_dbg(trident->card->dev, "RVol: 0x%x\n", (val >> 7) & 0x7f);
90 dev_dbg(trident->card->dev, "CVol: 0x%x\n", val & 0x7f);
94 /*---------------------------------------------------------------------------
98 CODEC (AC97).
100 Parameters: ac97 - ac97 codec structure
101 reg - CODEC register index, from AC97 Hal.
105 ---------------------------------------------------------------------------*/
111 struct snd_trident *trident = ac97->private_data; in snd_trident_codec_read()
113 spin_lock_irqsave(&trident->reg_lock, flags); in snd_trident_codec_read()
114 if (trident->device == TRIDENT_DEVICE_ID_DX) { in snd_trident_codec_read()
121 } while (--count); in snd_trident_codec_read()
122 } else if (trident->device == TRIDENT_DEVICE_ID_NX) { in snd_trident_codec_read()
124 treg = ac97->num == 0 ? NX_ACR2_AC97_R_PRIMARY : NX_ACR3_AC97_R_SECONDARY; in snd_trident_codec_read()
130 } while (--count); in snd_trident_codec_read()
131 } else if (trident->device == TRIDENT_DEVICE_ID_SI7018) { in snd_trident_codec_read()
133 if (ac97->num == 1) in snd_trident_codec_read()
140 } while (--count); in snd_trident_codec_read()
143 if (count == 0 && !trident->ac97_detect) { in snd_trident_codec_read()
144 dev_err(trident->card->dev, in snd_trident_codec_read()
145 "ac97 codec read TIMEOUT [0x%x/0x%x]!!!\n", in snd_trident_codec_read()
150 spin_unlock_irqrestore(&trident->reg_lock, flags); in snd_trident_codec_read()
154 /*---------------------------------------------------------------------------
159 CODEC (AC97).
161 Parameters: ac97 - ac97 codec structure
162 reg - CODEC register index, from AC97 Hal.
163 data - Lower 16 bits are the data to write to CODEC.
167 ---------------------------------------------------------------------------*/
174 struct snd_trident *trident = ac97->private_data; in snd_trident_codec_write()
178 spin_lock_irqsave(&trident->reg_lock, flags); in snd_trident_codec_write()
179 if (trident->device == TRIDENT_DEVICE_ID_DX) { in snd_trident_codec_write()
182 /* read AC-97 write register status */ in snd_trident_codec_write()
186 } while (--count); in snd_trident_codec_write()
189 } else if (trident->device == TRIDENT_DEVICE_ID_NX) { in snd_trident_codec_write()
192 /* read AC-97 write register status */ in snd_trident_codec_write()
196 } while (--count); in snd_trident_codec_write()
198 data |= (NX_AC97_BUSY_WRITE | (ac97->num << 8) | (reg & 0x000000ff)); in snd_trident_codec_write()
199 } else if (trident->device == TRIDENT_DEVICE_ID_SI7018) { in snd_trident_codec_write()
202 /* read AC-97 write register status */ in snd_trident_codec_write()
206 } while (--count); in snd_trident_codec_write()
209 if (ac97->num == 1) in snd_trident_codec_write()
217 spin_unlock_irqrestore(&trident->reg_lock, flags); in snd_trident_codec_write()
221 spin_unlock_irqrestore(&trident->reg_lock, flags); in snd_trident_codec_write()
224 /*---------------------------------------------------------------------------
232 Parameters: trident - pointer to target device class for 4DWave.
234 ---------------------------------------------------------------------------*/
243 if (trident->device == TRIDENT_DEVICE_ID_SI7018) in snd_trident_enable_eso()
248 /*---------------------------------------------------------------------------
257 trident - pointer to target device class for 4DWave.
261 ---------------------------------------------------------------------------*/
273 /*---------------------------------------------------------------------------
280 Parameters : voice - Voice number 0 thru n.
281 trident - pointer to target device class for 4DWave.
285 ---------------------------------------------------------------------------*/
297 /*---------------------------------------------------------------------------
304 Parameters : voice - Voice number 0 thru n.
305 trident - pointer to target device class for 4DWave.
309 ---------------------------------------------------------------------------*/
321 /*---------------------------------------------------------------------------
324 Description: Allocate hardware channel in Bank B (32-63).
326 Parameters : trident - pointer to target device class for 4DWave.
328 Return Value: hardware channel - 32-63 or -1 when no channel is available
330 ---------------------------------------------------------------------------*/
336 if (trident->ChanPCMcnt >= trident->ChanPCM) in snd_trident_allocate_pcm_channel()
337 return -1; in snd_trident_allocate_pcm_channel()
338 for (idx = 31; idx >= 0; idx--) { in snd_trident_allocate_pcm_channel()
339 if (!(trident->ChanMap[T4D_BANK_B] & (1 << idx))) { in snd_trident_allocate_pcm_channel()
340 trident->ChanMap[T4D_BANK_B] |= 1 << idx; in snd_trident_allocate_pcm_channel()
341 trident->ChanPCMcnt++; in snd_trident_allocate_pcm_channel()
345 return -1; in snd_trident_allocate_pcm_channel()
348 /*---------------------------------------------------------------------------
351 Description: Free hardware channel in Bank B (32-63)
353 Parameters : trident - pointer to target device class for 4DWave.
354 channel - hardware channel number 0-63
358 ---------------------------------------------------------------------------*/
365 if (trident->ChanMap[T4D_BANK_B] & (1 << channel)) { in snd_trident_free_pcm_channel()
366 trident->ChanMap[T4D_BANK_B] &= ~(1 << channel); in snd_trident_free_pcm_channel()
367 trident->ChanPCMcnt--; in snd_trident_free_pcm_channel()
371 /*---------------------------------------------------------------------------
374 Description: Allocate hardware channel in Bank A (0-31).
376 Parameters : trident - pointer to target device class for 4DWave.
378 Return Value: hardware channel - 0-31 or -1 when no channel is available
380 ---------------------------------------------------------------------------*/
386 for (idx = 31; idx >= 0; idx--) { in snd_trident_allocate_synth_channel()
387 if (!(trident->ChanMap[T4D_BANK_A] & (1 << idx))) { in snd_trident_allocate_synth_channel()
388 trident->ChanMap[T4D_BANK_A] |= 1 << idx; in snd_trident_allocate_synth_channel()
389 trident->synth.ChanSynthCount++; in snd_trident_allocate_synth_channel()
393 return -1; in snd_trident_allocate_synth_channel()
396 /*---------------------------------------------------------------------------
399 Description: Free hardware channel in Bank B (0-31).
401 Parameters : trident - pointer to target device class for 4DWave.
402 channel - hardware channel number 0-63
406 ---------------------------------------------------------------------------*/
413 if (trident->ChanMap[T4D_BANK_A] & (1 << channel)) { in snd_trident_free_synth_channel()
414 trident->ChanMap[T4D_BANK_A] &= ~(1 << channel); in snd_trident_free_synth_channel()
415 trident->synth.ChanSynthCount--; in snd_trident_free_synth_channel()
419 /*---------------------------------------------------------------------------
425 Parameters: trident - pointer to target device class for 4DWave.
426 voice - synthesizer voice structure
429 ---------------------------------------------------------------------------*/
437 regs[1] = voice->LBA; in snd_trident_write_voice_regs()
438 regs[4] = (voice->GVSel << 31) | in snd_trident_write_voice_regs()
439 ((voice->Pan & 0x0000007f) << 24) | in snd_trident_write_voice_regs()
440 ((voice->CTRL & 0x0000000f) << 12); in snd_trident_write_voice_regs()
441 FmcRvolCvol = ((voice->FMC & 3) << 14) | in snd_trident_write_voice_regs()
442 ((voice->RVol & 0x7f) << 7) | in snd_trident_write_voice_regs()
443 (voice->CVol & 0x7f); in snd_trident_write_voice_regs()
445 switch (trident->device) { in snd_trident_write_voice_regs()
447 regs[4] |= voice->number > 31 ? in snd_trident_write_voice_regs()
448 (voice->Vol & 0x000003ff) : in snd_trident_write_voice_regs()
449 ((voice->Vol & 0x00003fc) << (16-2)) | in snd_trident_write_voice_regs()
450 (voice->EC & 0x00000fff); in snd_trident_write_voice_regs()
451 regs[0] = (voice->CSO << 16) | ((voice->Alpha & 0x00000fff) << 4) | in snd_trident_write_voice_regs()
452 (voice->FMS & 0x0000000f); in snd_trident_write_voice_regs()
453 regs[2] = (voice->ESO << 16) | (voice->Delta & 0x0ffff); in snd_trident_write_voice_regs()
454 regs[3] = (voice->Attribute << 16) | FmcRvolCvol; in snd_trident_write_voice_regs()
457 regs[4] |= ((voice->Vol & 0x000003fc) << (16-2)) | in snd_trident_write_voice_regs()
458 (voice->EC & 0x00000fff); in snd_trident_write_voice_regs()
459 regs[0] = (voice->CSO << 16) | ((voice->Alpha & 0x00000fff) << 4) | in snd_trident_write_voice_regs()
460 (voice->FMS & 0x0000000f); in snd_trident_write_voice_regs()
461 regs[2] = (voice->ESO << 16) | (voice->Delta & 0x0ffff); in snd_trident_write_voice_regs()
465 regs[4] |= ((voice->Vol & 0x000003fc) << (16-2)) | in snd_trident_write_voice_regs()
466 (voice->EC & 0x00000fff); in snd_trident_write_voice_regs()
467 regs[0] = (voice->Delta << 24) | (voice->CSO & 0x00ffffff); in snd_trident_write_voice_regs()
468 regs[2] = ((voice->Delta << 16) & 0xff000000) | in snd_trident_write_voice_regs()
469 (voice->ESO & 0x00ffffff); in snd_trident_write_voice_regs()
470 regs[3] = (voice->Alpha << 20) | in snd_trident_write_voice_regs()
471 ((voice->FMS & 0x0000000f) << 16) | FmcRvolCvol; in snd_trident_write_voice_regs()
478 outb(voice->number, TRID_REG(trident, T4D_LFO_GC_CIR)); in snd_trident_write_voice_regs()
486 dev_dbg(trident->card->dev, "written %i channel:\n", voice->number); in snd_trident_write_voice_regs()
487 dev_dbg(trident->card->dev, " regs[0] = 0x%x/0x%x\n", in snd_trident_write_voice_regs()
489 dev_dbg(trident->card->dev, " regs[1] = 0x%x/0x%x\n", in snd_trident_write_voice_regs()
491 dev_dbg(trident->card->dev, " regs[2] = 0x%x/0x%x\n", in snd_trident_write_voice_regs()
493 dev_dbg(trident->card->dev, " regs[3] = 0x%x/0x%x\n", in snd_trident_write_voice_regs()
495 dev_dbg(trident->card->dev, " regs[4] = 0x%x/0x%x\n", in snd_trident_write_voice_regs()
502 /*---------------------------------------------------------------------------
508 Parameters: trident - pointer to target device class for 4DWave.
509 voice - synthesizer voice structure
510 CSO - new CSO value
512 ---------------------------------------------------------------------------*/
518 voice->CSO = CSO; in snd_trident_write_cso_reg()
519 outb(voice->number, TRID_REG(trident, T4D_LFO_GC_CIR)); in snd_trident_write_cso_reg()
520 if (trident->device != TRIDENT_DEVICE_ID_NX) { in snd_trident_write_cso_reg()
521 outw(voice->CSO, TRID_REG(trident, CH_DX_CSO_ALPHA_FMS) + 2); in snd_trident_write_cso_reg()
523 outl((voice->Delta << 24) | in snd_trident_write_cso_reg()
524 (voice->CSO & 0x00ffffff), TRID_REG(trident, CH_NX_DELTA_CSO)); in snd_trident_write_cso_reg()
528 /*---------------------------------------------------------------------------
534 Parameters: trident - pointer to target device class for 4DWave.
535 voice - synthesizer voice structure
536 ESO - new ESO value
538 ---------------------------------------------------------------------------*/
544 voice->ESO = ESO; in snd_trident_write_eso_reg()
545 outb(voice->number, TRID_REG(trident, T4D_LFO_GC_CIR)); in snd_trident_write_eso_reg()
546 if (trident->device != TRIDENT_DEVICE_ID_NX) { in snd_trident_write_eso_reg()
547 outw(voice->ESO, TRID_REG(trident, CH_DX_ESO_DELTA) + 2); in snd_trident_write_eso_reg()
549 outl(((voice->Delta << 16) & 0xff000000) | (voice->ESO & 0x00ffffff), in snd_trident_write_eso_reg()
554 /*---------------------------------------------------------------------------
560 Parameters: trident - pointer to target device class for 4DWave.
561 voice - synthesizer voice structure
562 Vol - new voice volume
564 ---------------------------------------------------------------------------*/
570 voice->Vol = Vol; in snd_trident_write_vol_reg()
571 outb(voice->number, TRID_REG(trident, T4D_LFO_GC_CIR)); in snd_trident_write_vol_reg()
572 switch (trident->device) { in snd_trident_write_vol_reg()
575 outb(voice->Vol >> 2, TRID_REG(trident, CH_GVSEL_PAN_VOL_CTRL_EC + 2)); in snd_trident_write_vol_reg()
578 /* dev_dbg(trident->card->dev, "voice->Vol = 0x%x\n", voice->Vol); */ in snd_trident_write_vol_reg()
579 outw((voice->CTRL << 12) | voice->Vol, in snd_trident_write_vol_reg()
585 /*---------------------------------------------------------------------------
591 Parameters: trident - pointer to target device class for 4DWave.
592 voice - synthesizer voice structure
593 Pan - new pan value
595 ---------------------------------------------------------------------------*/
601 voice->Pan = Pan; in snd_trident_write_pan_reg()
602 outb(voice->number, TRID_REG(trident, T4D_LFO_GC_CIR)); in snd_trident_write_pan_reg()
603 outb(((voice->GVSel & 0x01) << 7) | (voice->Pan & 0x7f), in snd_trident_write_pan_reg()
607 /*---------------------------------------------------------------------------
613 Parameters: trident - pointer to target device class for 4DWave.
614 voice - synthesizer voice structure
615 RVol - new reverb volume
617 ---------------------------------------------------------------------------*/
623 voice->RVol = RVol; in snd_trident_write_rvol_reg()
624 outb(voice->number, TRID_REG(trident, T4D_LFO_GC_CIR)); in snd_trident_write_rvol_reg()
625 outw(((voice->FMC & 0x0003) << 14) | ((voice->RVol & 0x007f) << 7) | in snd_trident_write_rvol_reg()
626 (voice->CVol & 0x007f), in snd_trident_write_rvol_reg()
627 TRID_REG(trident, trident->device == TRIDENT_DEVICE_ID_NX ? in snd_trident_write_rvol_reg()
631 /*---------------------------------------------------------------------------
637 Parameters: trident - pointer to target device class for 4DWave.
638 voice - synthesizer voice structure
639 CVol - new chorus volume
641 ---------------------------------------------------------------------------*/
647 voice->CVol = CVol; in snd_trident_write_cvol_reg()
648 outb(voice->number, TRID_REG(trident, T4D_LFO_GC_CIR)); in snd_trident_write_cvol_reg()
649 outw(((voice->FMC & 0x0003) << 14) | ((voice->RVol & 0x007f) << 7) | in snd_trident_write_cvol_reg()
650 (voice->CVol & 0x007f), in snd_trident_write_cvol_reg()
651 TRID_REG(trident, trident->device == TRIDENT_DEVICE_ID_NX ? in snd_trident_write_cvol_reg()
655 /*---------------------------------------------------------------------------
660 Parameters: trident - pointer to target device class for 4DWave.
661 rate - Real or Virtual channel number.
665 ---------------------------------------------------------------------------*/
685 /*---------------------------------------------------------------------------
690 Parameters: trident - pointer to target device class for 4DWave.
691 rate - Real or Virtual channel number.
695 ---------------------------------------------------------------------------*/
715 /*---------------------------------------------------------------------------
720 Parameters: trident - pointer to target device class for 4DWave.
721 rate - Real or Virtual channel number.
725 ---------------------------------------------------------------------------*/
733 res -= 32; in snd_trident_spurious_threshold()
737 /*---------------------------------------------------------------------------
742 Parameters: trident - pointer to target device class for 4DWave.
743 substream - PCM substream
747 ---------------------------------------------------------------------------*/
751 struct snd_pcm_runtime *runtime = substream->runtime; in snd_trident_control_mode()
754 CTRL default: 8-bit (unsigned) mono, loop mode enabled in snd_trident_control_mode()
757 if (snd_pcm_format_width(runtime->format) == 16) in snd_trident_control_mode()
758 CTRL |= 0x00000008; // 16-bit data in snd_trident_control_mode()
759 if (snd_pcm_format_signed(runtime->format)) in snd_trident_control_mode()
761 if (runtime->channels > 1) in snd_trident_control_mode()
770 /*---------------------------------------------------------------------------
775 Parameters: substream - PCM substream class
776 hw_params - hardware parameters
780 ---------------------------------------------------------------------------*/
786 struct snd_pcm_runtime *runtime = substream->runtime; in snd_trident_allocate_pcm_mem()
787 struct snd_trident_voice *voice = runtime->private_data; in snd_trident_allocate_pcm_mem()
789 if (trident->tlb.entries) { in snd_trident_allocate_pcm_mem()
790 if (runtime->buffer_changed) { in snd_trident_allocate_pcm_mem()
791 if (voice->memblk) in snd_trident_allocate_pcm_mem()
792 snd_trident_free_pages(trident, voice->memblk); in snd_trident_allocate_pcm_mem()
793 voice->memblk = snd_trident_alloc_pages(trident, substream); in snd_trident_allocate_pcm_mem()
794 if (voice->memblk == NULL) in snd_trident_allocate_pcm_mem()
795 return -ENOMEM; in snd_trident_allocate_pcm_mem()
801 /*---------------------------------------------------------------------------
806 Parameters: substream - PCM substream class
807 hw_params - hardware parameters
811 ---------------------------------------------------------------------------*/
817 struct snd_pcm_runtime *runtime = substream->runtime; in snd_trident_allocate_evoice()
818 struct snd_trident_voice *voice = runtime->private_data; in snd_trident_allocate_evoice()
819 struct snd_trident_voice *evoice = voice->extra; in snd_trident_allocate_evoice()
827 return -ENOMEM; in snd_trident_allocate_evoice()
828 voice->extra = evoice; in snd_trident_allocate_evoice()
829 evoice->substream = substream; in snd_trident_allocate_evoice()
834 voice->extra = evoice = NULL; in snd_trident_allocate_evoice()
841 /*---------------------------------------------------------------------------
846 Parameters: substream - PCM substream class
847 hw_params - hardware parameters
851 ---------------------------------------------------------------------------*/
864 /*---------------------------------------------------------------------------
869 Parameters: substream - PCM substream class
873 ---------------------------------------------------------------------------*/
878 struct snd_pcm_runtime *runtime = substream->runtime; in snd_trident_hw_free()
879 struct snd_trident_voice *voice = runtime->private_data; in snd_trident_hw_free()
880 struct snd_trident_voice *evoice = voice ? voice->extra : NULL; in snd_trident_hw_free()
882 if (trident->tlb.entries) { in snd_trident_hw_free()
883 if (voice && voice->memblk) { in snd_trident_hw_free()
884 snd_trident_free_pages(trident, voice->memblk); in snd_trident_hw_free()
885 voice->memblk = NULL; in snd_trident_hw_free()
890 voice->extra = NULL; in snd_trident_hw_free()
895 /*---------------------------------------------------------------------------
900 Parameters: substream - PCM substream class
904 ---------------------------------------------------------------------------*/
909 struct snd_pcm_runtime *runtime = substream->runtime; in snd_trident_playback_prepare()
910 struct snd_trident_voice *voice = runtime->private_data; in snd_trident_playback_prepare()
911 struct snd_trident_voice *evoice = voice->extra; in snd_trident_playback_prepare()
912 struct snd_trident_pcm_mixer *mix = &trident->pcm_mixer[substream->number]; in snd_trident_playback_prepare()
914 spin_lock_irq(&trident->reg_lock); in snd_trident_playback_prepare()
917 voice->Delta = snd_trident_convert_rate(runtime->rate); in snd_trident_playback_prepare()
918 voice->spurious_threshold = snd_trident_spurious_threshold(runtime->rate, runtime->period_size); in snd_trident_playback_prepare()
921 if (voice->memblk) in snd_trident_playback_prepare()
922 voice->LBA = voice->memblk->offset; in snd_trident_playback_prepare()
924 voice->LBA = runtime->dma_addr; in snd_trident_playback_prepare()
926 voice->CSO = 0; in snd_trident_playback_prepare()
927 voice->ESO = runtime->buffer_size - 1; /* in samples */ in snd_trident_playback_prepare()
928 voice->CTRL = snd_trident_control_mode(substream); in snd_trident_playback_prepare()
929 voice->FMC = 3; in snd_trident_playback_prepare()
930 voice->GVSel = 1; in snd_trident_playback_prepare()
931 voice->EC = 0; in snd_trident_playback_prepare()
932 voice->Alpha = 0; in snd_trident_playback_prepare()
933 voice->FMS = 0; in snd_trident_playback_prepare()
934 voice->Vol = mix->vol; in snd_trident_playback_prepare()
935 voice->RVol = mix->rvol; in snd_trident_playback_prepare()
936 voice->CVol = mix->cvol; in snd_trident_playback_prepare()
937 voice->Pan = mix->pan; in snd_trident_playback_prepare()
938 voice->Attribute = 0; in snd_trident_playback_prepare()
940 voice->Attribute = (1<<(30-16))|(2<<(26-16))| in snd_trident_playback_prepare()
941 (0<<(24-16))|(0x1f<<(19-16)); in snd_trident_playback_prepare()
943 voice->Attribute = 0; in snd_trident_playback_prepare()
949 evoice->Delta = voice->Delta; in snd_trident_playback_prepare()
950 evoice->spurious_threshold = voice->spurious_threshold; in snd_trident_playback_prepare()
951 evoice->LBA = voice->LBA; in snd_trident_playback_prepare()
952 evoice->CSO = 0; in snd_trident_playback_prepare()
953 evoice->ESO = (runtime->period_size * 2) + 4 - 1; /* in samples */ in snd_trident_playback_prepare()
954 evoice->CTRL = voice->CTRL; in snd_trident_playback_prepare()
955 evoice->FMC = 3; in snd_trident_playback_prepare()
956 evoice->GVSel = trident->device == TRIDENT_DEVICE_ID_SI7018 ? 0 : 1; in snd_trident_playback_prepare()
957 evoice->EC = 0; in snd_trident_playback_prepare()
958 evoice->Alpha = 0; in snd_trident_playback_prepare()
959 evoice->FMS = 0; in snd_trident_playback_prepare()
960 evoice->Vol = 0x3ff; /* mute */ in snd_trident_playback_prepare()
961 evoice->RVol = evoice->CVol = 0x7f; /* mute */ in snd_trident_playback_prepare()
962 evoice->Pan = 0x7f; /* mute */ in snd_trident_playback_prepare()
964 evoice->Attribute = (1<<(30-16))|(2<<(26-16))| in snd_trident_playback_prepare()
965 (0<<(24-16))|(0x1f<<(19-16)); in snd_trident_playback_prepare()
967 evoice->Attribute = 0; in snd_trident_playback_prepare()
970 evoice->isync2 = 1; in snd_trident_playback_prepare()
971 evoice->isync_mark = runtime->period_size; in snd_trident_playback_prepare()
972 evoice->ESO = (runtime->period_size * 2) - 1; in snd_trident_playback_prepare()
975 spin_unlock_irq(&trident->reg_lock); in snd_trident_playback_prepare()
980 /*---------------------------------------------------------------------------
985 Parameters: substream - PCM substream class
986 hw_params - hardware parameters
990 ---------------------------------------------------------------------------*/
998 /*---------------------------------------------------------------------------
1003 Parameters: substream - PCM substream class
1007 ---------------------------------------------------------------------------*/
1012 struct snd_pcm_runtime *runtime = substream->runtime; in snd_trident_capture_prepare()
1013 struct snd_trident_voice *voice = runtime->private_data; in snd_trident_capture_prepare()
1016 spin_lock_irq(&trident->reg_lock); in snd_trident_capture_prepare()
1025 voice->LBA = runtime->dma_addr; in snd_trident_capture_prepare()
1026 outl(voice->LBA, TRID_REG(trident, LEGACY_DMAR0)); in snd_trident_capture_prepare()
1027 if (voice->memblk) in snd_trident_capture_prepare()
1028 voice->LBA = voice->memblk->offset; in snd_trident_capture_prepare()
1031 ESO_bytes = snd_pcm_lib_buffer_bytes(substream) - 1; in snd_trident_capture_prepare()
1037 val = (((unsigned int) 48000L << 12) + (runtime->rate/2)) / runtime->rate; in snd_trident_capture_prepare()
1041 if (snd_pcm_format_width(runtime->format) == 16) { in snd_trident_capture_prepare()
1042 val = (unsigned short) ((ESO_bytes >> 1) - 1); in snd_trident_capture_prepare()
1044 val = (unsigned short) (ESO_bytes - 1); in snd_trident_capture_prepare()
1051 trident->bDMAStart = 0x19; // 0001 1001b in snd_trident_capture_prepare()
1053 if (snd_pcm_format_width(runtime->format) == 16) in snd_trident_capture_prepare()
1054 trident->bDMAStart |= 0x80; in snd_trident_capture_prepare()
1055 if (snd_pcm_format_signed(runtime->format)) in snd_trident_capture_prepare()
1056 trident->bDMAStart |= 0x20; in snd_trident_capture_prepare()
1057 if (runtime->channels > 1) in snd_trident_capture_prepare()
1058 trident->bDMAStart |= 0x40; in snd_trident_capture_prepare()
1062 voice->Delta = snd_trident_convert_rate(runtime->rate); in snd_trident_capture_prepare()
1063 voice->spurious_threshold = snd_trident_spurious_threshold(runtime->rate, runtime->period_size); in snd_trident_capture_prepare()
1064 voice->isync = 1; in snd_trident_capture_prepare()
1065 voice->isync_mark = runtime->period_size; in snd_trident_capture_prepare()
1066 voice->isync_max = runtime->buffer_size; in snd_trident_capture_prepare()
1069 voice->CSO = 0; in snd_trident_capture_prepare()
1070 voice->ESO = voice->isync_ESO = (runtime->period_size * 2) + 6 - 1; in snd_trident_capture_prepare()
1071 voice->CTRL = snd_trident_control_mode(substream); in snd_trident_capture_prepare()
1072 voice->FMC = 3; in snd_trident_capture_prepare()
1073 voice->RVol = 0x7f; in snd_trident_capture_prepare()
1074 voice->CVol = 0x7f; in snd_trident_capture_prepare()
1075 voice->GVSel = 1; in snd_trident_capture_prepare()
1076 voice->Pan = 0x7f; /* mute */ in snd_trident_capture_prepare()
1077 voice->Vol = 0x3ff; /* mute */ in snd_trident_capture_prepare()
1078 voice->EC = 0; in snd_trident_capture_prepare()
1079 voice->Alpha = 0; in snd_trident_capture_prepare()
1080 voice->FMS = 0; in snd_trident_capture_prepare()
1081 voice->Attribute = 0; in snd_trident_capture_prepare()
1085 spin_unlock_irq(&trident->reg_lock); in snd_trident_capture_prepare()
1089 /*---------------------------------------------------------------------------
1094 Parameters: substream - PCM substream class
1095 hw_params - hardware parameters
1099 ---------------------------------------------------------------------------*/
1107 /*---------------------------------------------------------------------------
1112 Parameters: substream - PCM substream class
1116 ---------------------------------------------------------------------------*/
1121 struct snd_pcm_runtime *runtime = substream->runtime; in snd_trident_si7018_capture_hw_free()
1122 struct snd_trident_voice *voice = runtime->private_data; in snd_trident_si7018_capture_hw_free()
1123 struct snd_trident_voice *evoice = voice ? voice->extra : NULL; in snd_trident_si7018_capture_hw_free()
1127 voice->extra = NULL; in snd_trident_si7018_capture_hw_free()
1132 /*---------------------------------------------------------------------------
1137 Parameters: substream - PCM substream class
1141 ---------------------------------------------------------------------------*/
1146 struct snd_pcm_runtime *runtime = substream->runtime; in snd_trident_si7018_capture_prepare()
1147 struct snd_trident_voice *voice = runtime->private_data; in snd_trident_si7018_capture_prepare()
1148 struct snd_trident_voice *evoice = voice->extra; in snd_trident_si7018_capture_prepare()
1150 spin_lock_irq(&trident->reg_lock); in snd_trident_si7018_capture_prepare()
1152 voice->LBA = runtime->dma_addr; in snd_trident_si7018_capture_prepare()
1153 voice->Delta = snd_trident_convert_adc_rate(runtime->rate); in snd_trident_si7018_capture_prepare()
1154 voice->spurious_threshold = snd_trident_spurious_threshold(runtime->rate, runtime->period_size); in snd_trident_si7018_capture_prepare()
1157 voice->CSO = 0; in snd_trident_si7018_capture_prepare()
1158 voice->ESO = runtime->buffer_size - 1; /* in samples */ in snd_trident_si7018_capture_prepare()
1159 voice->CTRL = snd_trident_control_mode(substream); in snd_trident_si7018_capture_prepare()
1160 voice->FMC = 0; in snd_trident_si7018_capture_prepare()
1161 voice->RVol = 0; in snd_trident_si7018_capture_prepare()
1162 voice->CVol = 0; in snd_trident_si7018_capture_prepare()
1163 voice->GVSel = 1; in snd_trident_si7018_capture_prepare()
1164 voice->Pan = T4D_DEFAULT_PCM_PAN; in snd_trident_si7018_capture_prepare()
1165 voice->Vol = 0; in snd_trident_si7018_capture_prepare()
1166 voice->EC = 0; in snd_trident_si7018_capture_prepare()
1167 voice->Alpha = 0; in snd_trident_si7018_capture_prepare()
1168 voice->FMS = 0; in snd_trident_si7018_capture_prepare()
1170 voice->Attribute = (2 << (30-16)) | in snd_trident_si7018_capture_prepare()
1171 (2 << (26-16)) | in snd_trident_si7018_capture_prepare()
1172 (2 << (24-16)) | in snd_trident_si7018_capture_prepare()
1173 (1 << (23-16)); in snd_trident_si7018_capture_prepare()
1178 evoice->Delta = snd_trident_convert_rate(runtime->rate); in snd_trident_si7018_capture_prepare()
1179 evoice->spurious_threshold = voice->spurious_threshold; in snd_trident_si7018_capture_prepare()
1180 evoice->LBA = voice->LBA; in snd_trident_si7018_capture_prepare()
1181 evoice->CSO = 0; in snd_trident_si7018_capture_prepare()
1182 evoice->ESO = (runtime->period_size * 2) + 20 - 1; /* in samples, 20 means correction */ in snd_trident_si7018_capture_prepare()
1183 evoice->CTRL = voice->CTRL; in snd_trident_si7018_capture_prepare()
1184 evoice->FMC = 3; in snd_trident_si7018_capture_prepare()
1185 evoice->GVSel = 0; in snd_trident_si7018_capture_prepare()
1186 evoice->EC = 0; in snd_trident_si7018_capture_prepare()
1187 evoice->Alpha = 0; in snd_trident_si7018_capture_prepare()
1188 evoice->FMS = 0; in snd_trident_si7018_capture_prepare()
1189 evoice->Vol = 0x3ff; /* mute */ in snd_trident_si7018_capture_prepare()
1190 evoice->RVol = evoice->CVol = 0x7f; /* mute */ in snd_trident_si7018_capture_prepare()
1191 evoice->Pan = 0x7f; /* mute */ in snd_trident_si7018_capture_prepare()
1192 evoice->Attribute = 0; in snd_trident_si7018_capture_prepare()
1194 evoice->isync2 = 1; in snd_trident_si7018_capture_prepare()
1195 evoice->isync_mark = runtime->period_size; in snd_trident_si7018_capture_prepare()
1196 evoice->ESO = (runtime->period_size * 2) - 1; in snd_trident_si7018_capture_prepare()
1199 spin_unlock_irq(&trident->reg_lock); in snd_trident_si7018_capture_prepare()
1203 /*---------------------------------------------------------------------------
1208 Parameters: substream - PCM substream class
1212 ---------------------------------------------------------------------------*/
1217 struct snd_pcm_runtime *runtime = substream->runtime; in snd_trident_foldback_prepare()
1218 struct snd_trident_voice *voice = runtime->private_data; in snd_trident_foldback_prepare()
1219 struct snd_trident_voice *evoice = voice->extra; in snd_trident_foldback_prepare()
1221 spin_lock_irq(&trident->reg_lock); in snd_trident_foldback_prepare()
1224 if (voice->memblk) in snd_trident_foldback_prepare()
1225 voice->LBA = voice->memblk->offset; in snd_trident_foldback_prepare()
1227 voice->LBA = runtime->dma_addr; in snd_trident_foldback_prepare()
1230 voice->ESO = runtime->buffer_size - 1; /* in samples */ in snd_trident_foldback_prepare()
1233 voice->Delta = 0x1000; in snd_trident_foldback_prepare()
1234 voice->spurious_threshold = snd_trident_spurious_threshold(48000, runtime->period_size); in snd_trident_foldback_prepare()
1236 voice->CSO = 0; in snd_trident_foldback_prepare()
1237 voice->CTRL = snd_trident_control_mode(substream); in snd_trident_foldback_prepare()
1238 voice->FMC = 3; in snd_trident_foldback_prepare()
1239 voice->RVol = 0x7f; in snd_trident_foldback_prepare()
1240 voice->CVol = 0x7f; in snd_trident_foldback_prepare()
1241 voice->GVSel = 1; in snd_trident_foldback_prepare()
1242 voice->Pan = 0x7f; /* mute */ in snd_trident_foldback_prepare()
1243 voice->Vol = 0x3ff; /* mute */ in snd_trident_foldback_prepare()
1244 voice->EC = 0; in snd_trident_foldback_prepare()
1245 voice->Alpha = 0; in snd_trident_foldback_prepare()
1246 voice->FMS = 0; in snd_trident_foldback_prepare()
1247 voice->Attribute = 0; in snd_trident_foldback_prepare()
1250 outb(((voice->number & 0x3f) | 0x80), TRID_REG(trident, T4D_RCI + voice->foldback_chan)); in snd_trident_foldback_prepare()
1255 evoice->Delta = voice->Delta; in snd_trident_foldback_prepare()
1256 evoice->spurious_threshold = voice->spurious_threshold; in snd_trident_foldback_prepare()
1257 evoice->LBA = voice->LBA; in snd_trident_foldback_prepare()
1258 evoice->CSO = 0; in snd_trident_foldback_prepare()
1259 evoice->ESO = (runtime->period_size * 2) + 4 - 1; /* in samples */ in snd_trident_foldback_prepare()
1260 evoice->CTRL = voice->CTRL; in snd_trident_foldback_prepare()
1261 evoice->FMC = 3; in snd_trident_foldback_prepare()
1262 evoice->GVSel = trident->device == TRIDENT_DEVICE_ID_SI7018 ? 0 : 1; in snd_trident_foldback_prepare()
1263 evoice->EC = 0; in snd_trident_foldback_prepare()
1264 evoice->Alpha = 0; in snd_trident_foldback_prepare()
1265 evoice->FMS = 0; in snd_trident_foldback_prepare()
1266 evoice->Vol = 0x3ff; /* mute */ in snd_trident_foldback_prepare()
1267 evoice->RVol = evoice->CVol = 0x7f; /* mute */ in snd_trident_foldback_prepare()
1268 evoice->Pan = 0x7f; /* mute */ in snd_trident_foldback_prepare()
1269 evoice->Attribute = 0; in snd_trident_foldback_prepare()
1271 evoice->isync2 = 1; in snd_trident_foldback_prepare()
1272 evoice->isync_mark = runtime->period_size; in snd_trident_foldback_prepare()
1273 evoice->ESO = (runtime->period_size * 2) - 1; in snd_trident_foldback_prepare()
1276 spin_unlock_irq(&trident->reg_lock); in snd_trident_foldback_prepare()
1280 /*---------------------------------------------------------------------------
1285 Parameters: substream - PCM substream class
1286 hw_params - hardware parameters
1290 ---------------------------------------------------------------------------*/
1303 if (trident->device == TRIDENT_DEVICE_ID_SI7018) { in snd_trident_spdif_hw_params()
1310 spin_lock_irq(&trident->reg_lock); in snd_trident_spdif_hw_params()
1311 old_bits = trident->spdif_pcm_bits; in snd_trident_spdif_hw_params()
1313 trident->spdif_pcm_bits &= ~IEC958_AES0_PRO_FS; in snd_trident_spdif_hw_params()
1315 trident->spdif_pcm_bits &= ~(IEC958_AES3_CON_FS << 24); in snd_trident_spdif_hw_params()
1317 trident->spdif_pcm_ctrl = 0x3c; // 48000 Hz in snd_trident_spdif_hw_params()
1318 trident->spdif_pcm_bits |= in snd_trident_spdif_hw_params()
1319 trident->spdif_bits & IEC958_AES0_PROFESSIONAL ? in snd_trident_spdif_hw_params()
1324 trident->spdif_pcm_ctrl = 0x3e; // 44100 Hz in snd_trident_spdif_hw_params()
1325 trident->spdif_pcm_bits |= in snd_trident_spdif_hw_params()
1326 trident->spdif_bits & IEC958_AES0_PROFESSIONAL ? in snd_trident_spdif_hw_params()
1331 trident->spdif_pcm_ctrl = 0x3d; // 32000 Hz in snd_trident_spdif_hw_params()
1332 trident->spdif_pcm_bits |= in snd_trident_spdif_hw_params()
1333 trident->spdif_bits & IEC958_AES0_PROFESSIONAL ? in snd_trident_spdif_hw_params()
1337 change = old_bits != trident->spdif_pcm_bits; in snd_trident_spdif_hw_params()
1338 spin_unlock_irq(&trident->reg_lock); in snd_trident_spdif_hw_params()
1341 snd_ctl_notify(trident->card, SNDRV_CTL_EVENT_MASK_VALUE, &trident->spdif_pcm_ctl->id); in snd_trident_spdif_hw_params()
1346 /*---------------------------------------------------------------------------
1351 Parameters: substream - PCM substream class
1355 ---------------------------------------------------------------------------*/
1360 struct snd_pcm_runtime *runtime = substream->runtime; in snd_trident_spdif_prepare()
1361 struct snd_trident_voice *voice = runtime->private_data; in snd_trident_spdif_prepare()
1362 struct snd_trident_voice *evoice = voice->extra; in snd_trident_spdif_prepare()
1363 struct snd_trident_pcm_mixer *mix = &trident->pcm_mixer[substream->number]; in snd_trident_spdif_prepare()
1367 spin_lock_irq(&trident->reg_lock); in snd_trident_spdif_prepare()
1369 if (trident->device != TRIDENT_DEVICE_ID_SI7018) { in snd_trident_spdif_prepare()
1372 voice->Delta = snd_trident_convert_rate(runtime->rate); in snd_trident_spdif_prepare()
1373 voice->spurious_threshold = snd_trident_spurious_threshold(runtime->rate, runtime->period_size); in snd_trident_spdif_prepare()
1376 LBAO = runtime->dma_addr; in snd_trident_spdif_prepare()
1377 if (voice->memblk) in snd_trident_spdif_prepare()
1378 voice->LBA = voice->memblk->offset; in snd_trident_spdif_prepare()
1380 voice->LBA = LBAO; in snd_trident_spdif_prepare()
1382 voice->isync = 1; in snd_trident_spdif_prepare()
1383 voice->isync3 = 1; in snd_trident_spdif_prepare()
1384 voice->isync_mark = runtime->period_size; in snd_trident_spdif_prepare()
1385 voice->isync_max = runtime->buffer_size; in snd_trident_spdif_prepare()
1388 RESO = runtime->buffer_size - 1; in snd_trident_spdif_prepare()
1389 voice->ESO = voice->isync_ESO = (runtime->period_size * 2) + 6 - 1; in snd_trident_spdif_prepare()
1392 voice->CTRL = snd_trident_control_mode(substream); in snd_trident_spdif_prepare()
1394 voice->FMC = 3; in snd_trident_spdif_prepare()
1395 voice->RVol = 0x7f; in snd_trident_spdif_prepare()
1396 voice->CVol = 0x7f; in snd_trident_spdif_prepare()
1397 voice->GVSel = 1; in snd_trident_spdif_prepare()
1398 voice->Pan = 0x7f; in snd_trident_spdif_prepare()
1399 voice->Vol = 0x3ff; in snd_trident_spdif_prepare()
1400 voice->EC = 0; in snd_trident_spdif_prepare()
1401 voice->CSO = 0; in snd_trident_spdif_prepare()
1402 voice->Alpha = 0; in snd_trident_spdif_prepare()
1403 voice->FMS = 0; in snd_trident_spdif_prepare()
1404 voice->Attribute = 0; in snd_trident_spdif_prepare()
1412 outw((voice->CSO & 0xffff), TRID_REG(trident, NX_SPCTRL_SPCSO)); in snd_trident_spdif_prepare()
1413 outb((voice->CSO >> 16), TRID_REG(trident, NX_SPCTRL_SPCSO + 2)); in snd_trident_spdif_prepare()
1416 outb(trident->spdif_pcm_ctrl, TRID_REG(trident, NX_SPCTRL_SPCSO + 3)); in snd_trident_spdif_prepare()
1417 outl(trident->spdif_pcm_bits, TRID_REG(trident, NX_SPCSTATUS)); in snd_trident_spdif_prepare()
1422 voice->Delta = 0x800; in snd_trident_spdif_prepare()
1423 voice->spurious_threshold = snd_trident_spurious_threshold(48000, runtime->period_size); in snd_trident_spdif_prepare()
1426 if (voice->memblk) in snd_trident_spdif_prepare()
1427 voice->LBA = voice->memblk->offset; in snd_trident_spdif_prepare()
1429 voice->LBA = runtime->dma_addr; in snd_trident_spdif_prepare()
1431 voice->CSO = 0; in snd_trident_spdif_prepare()
1432 voice->ESO = runtime->buffer_size - 1; /* in samples */ in snd_trident_spdif_prepare()
1433 voice->CTRL = snd_trident_control_mode(substream); in snd_trident_spdif_prepare()
1434 voice->FMC = 3; in snd_trident_spdif_prepare()
1435 voice->GVSel = 1; in snd_trident_spdif_prepare()
1436 voice->EC = 0; in snd_trident_spdif_prepare()
1437 voice->Alpha = 0; in snd_trident_spdif_prepare()
1438 voice->FMS = 0; in snd_trident_spdif_prepare()
1439 voice->Vol = mix->vol; in snd_trident_spdif_prepare()
1440 voice->RVol = mix->rvol; in snd_trident_spdif_prepare()
1441 voice->CVol = mix->cvol; in snd_trident_spdif_prepare()
1442 voice->Pan = mix->pan; in snd_trident_spdif_prepare()
1443 voice->Attribute = (1<<(30-16))|(7<<(26-16))| in snd_trident_spdif_prepare()
1444 (0<<(24-16))|(0<<(19-16)); in snd_trident_spdif_prepare()
1449 evoice->Delta = voice->Delta; in snd_trident_spdif_prepare()
1450 evoice->spurious_threshold = voice->spurious_threshold; in snd_trident_spdif_prepare()
1451 evoice->LBA = voice->LBA; in snd_trident_spdif_prepare()
1452 evoice->CSO = 0; in snd_trident_spdif_prepare()
1453 evoice->ESO = (runtime->period_size * 2) + 4 - 1; /* in samples */ in snd_trident_spdif_prepare()
1454 evoice->CTRL = voice->CTRL; in snd_trident_spdif_prepare()
1455 evoice->FMC = 3; in snd_trident_spdif_prepare()
1456 evoice->GVSel = trident->device == TRIDENT_DEVICE_ID_SI7018 ? 0 : 1; in snd_trident_spdif_prepare()
1457 evoice->EC = 0; in snd_trident_spdif_prepare()
1458 evoice->Alpha = 0; in snd_trident_spdif_prepare()
1459 evoice->FMS = 0; in snd_trident_spdif_prepare()
1460 evoice->Vol = 0x3ff; /* mute */ in snd_trident_spdif_prepare()
1461 evoice->RVol = evoice->CVol = 0x7f; /* mute */ in snd_trident_spdif_prepare()
1462 evoice->Pan = 0x7f; /* mute */ in snd_trident_spdif_prepare()
1463 evoice->Attribute = 0; in snd_trident_spdif_prepare()
1465 evoice->isync2 = 1; in snd_trident_spdif_prepare()
1466 evoice->isync_mark = runtime->period_size; in snd_trident_spdif_prepare()
1467 evoice->ESO = (runtime->period_size * 2) - 1; in snd_trident_spdif_prepare()
1470 outl(trident->spdif_pcm_bits, TRID_REG(trident, SI_SPDIF_CS)); in snd_trident_spdif_prepare()
1479 spin_unlock_irq(&trident->reg_lock); in snd_trident_spdif_prepare()
1484 /*---------------------------------------------------------------------------
1489 Parameters: substream - PCM substream class
1490 cmd - trigger command (STOP, GO)
1494 ---------------------------------------------------------------------------*/
1518 return -EINVAL; in snd_trident_trigger()
1521 spin_lock(&trident->reg_lock); in snd_trident_trigger()
1525 voice = s->runtime->private_data; in snd_trident_trigger()
1526 evoice = voice->extra; in snd_trident_trigger()
1527 what |= 1 << (voice->number & 0x1f); in snd_trident_trigger()
1529 whati |= 1 << (voice->number & 0x1f); in snd_trident_trigger()
1531 what |= 1 << (evoice->number & 0x1f); in snd_trident_trigger()
1532 whati |= 1 << (evoice->number & 0x1f); in snd_trident_trigger()
1534 evoice->stimer = val; in snd_trident_trigger()
1537 voice->running = 1; in snd_trident_trigger()
1538 voice->stimer = val; in snd_trident_trigger()
1540 voice->running = 0; in snd_trident_trigger()
1543 if (voice->capture) in snd_trident_trigger()
1545 if (voice->spdif) in snd_trident_trigger()
1550 if (trident->device != TRIDENT_DEVICE_ID_SI7018) { in snd_trident_trigger()
1551 outl(trident->spdif_pcm_bits, TRID_REG(trident, NX_SPCSTATUS)); in snd_trident_trigger()
1552 val = trident->spdif_pcm_ctrl; in snd_trident_trigger()
1557 outl(trident->spdif_pcm_bits, TRID_REG(trident, SI_SPDIF_CS)); in snd_trident_trigger()
1574 if (capture_flag && trident->device != TRIDENT_DEVICE_ID_SI7018) in snd_trident_trigger()
1575 outb(trident->bDMAStart, TRID_REG(trident, T4D_SBCTRL_SBE2R_SBDD)); in snd_trident_trigger()
1577 if (capture_flag && trident->device != TRIDENT_DEVICE_ID_SI7018) in snd_trident_trigger()
1580 spin_unlock(&trident->reg_lock); in snd_trident_trigger()
1584 /*---------------------------------------------------------------------------
1589 Parameters: substream - PCM substream class
1593 ---------------------------------------------------------------------------*/
1598 struct snd_pcm_runtime *runtime = substream->runtime; in snd_trident_playback_pointer()
1599 struct snd_trident_voice *voice = runtime->private_data; in snd_trident_playback_pointer()
1602 if (!voice->running) in snd_trident_playback_pointer()
1605 spin_lock(&trident->reg_lock); in snd_trident_playback_pointer()
1607 outb(voice->number, TRID_REG(trident, T4D_LFO_GC_CIR)); in snd_trident_playback_pointer()
1609 if (trident->device != TRIDENT_DEVICE_ID_NX) { in snd_trident_playback_pointer()
1615 spin_unlock(&trident->reg_lock); in snd_trident_playback_pointer()
1617 if (cso >= runtime->buffer_size) in snd_trident_playback_pointer()
1623 /*---------------------------------------------------------------------------
1628 Parameters: pcm1 - PCM device class
1632 ---------------------------------------------------------------------------*/
1637 struct snd_pcm_runtime *runtime = substream->runtime; in snd_trident_capture_pointer()
1638 struct snd_trident_voice *voice = runtime->private_data; in snd_trident_capture_pointer()
1641 if (!voice->running) in snd_trident_capture_pointer()
1645 if (runtime->channels > 1) in snd_trident_capture_pointer()
1648 result = runtime->buffer_size - result; in snd_trident_capture_pointer()
1653 /*---------------------------------------------------------------------------
1658 Parameters: substream - PCM substream class
1662 ---------------------------------------------------------------------------*/
1667 struct snd_pcm_runtime *runtime = substream->runtime; in snd_trident_spdif_pointer()
1668 struct snd_trident_voice *voice = runtime->private_data; in snd_trident_spdif_pointer()
1671 if (!voice->running) in snd_trident_spdif_pointer()
1800 struct snd_trident_voice *voice = runtime->private_data; in snd_trident_pcm_free_substream()
1804 trident = voice->trident; in snd_trident_pcm_free_substream()
1812 struct snd_pcm_runtime *runtime = substream->runtime; in snd_trident_playback_open()
1817 return -EAGAIN; in snd_trident_playback_open()
1819 voice->substream = substream; in snd_trident_playback_open()
1820 runtime->private_data = voice; in snd_trident_playback_open()
1821 runtime->private_free = snd_trident_pcm_free_substream; in snd_trident_playback_open()
1822 runtime->hw = snd_trident_playback; in snd_trident_playback_open()
1828 /*---------------------------------------------------------------------------
1834 Parameters: substream - PCM substream class
1836 ---------------------------------------------------------------------------*/
1840 struct snd_pcm_runtime *runtime = substream->runtime; in snd_trident_playback_close()
1841 struct snd_trident_voice *voice = runtime->private_data; in snd_trident_playback_close()
1847 /*---------------------------------------------------------------------------
1852 Parameters: substream - PCM substream class
1854 Returns: status - success or failure flag
1856 ---------------------------------------------------------------------------*/
1862 struct snd_pcm_runtime *runtime = substream->runtime; in snd_trident_spdif_open()
1866 return -EAGAIN; in snd_trident_spdif_open()
1867 voice->spdif = 1; in snd_trident_spdif_open()
1868 voice->substream = substream; in snd_trident_spdif_open()
1869 spin_lock_irq(&trident->reg_lock); in snd_trident_spdif_open()
1870 trident->spdif_pcm_bits = trident->spdif_bits; in snd_trident_spdif_open()
1871 spin_unlock_irq(&trident->reg_lock); in snd_trident_spdif_open()
1873 runtime->private_data = voice; in snd_trident_spdif_open()
1874 runtime->private_free = snd_trident_pcm_free_substream; in snd_trident_spdif_open()
1875 if (trident->device == TRIDENT_DEVICE_ID_SI7018) { in snd_trident_spdif_open()
1876 runtime->hw = snd_trident_spdif; in snd_trident_spdif_open()
1878 runtime->hw = snd_trident_spdif_7018; in snd_trident_spdif_open()
1881 trident->spdif_pcm_ctl->vd[0].access &= ~SNDRV_CTL_ELEM_ACCESS_INACTIVE; in snd_trident_spdif_open()
1882 snd_ctl_notify(trident->card, SNDRV_CTL_EVENT_MASK_VALUE | in snd_trident_spdif_open()
1883 SNDRV_CTL_EVENT_MASK_INFO, &trident->spdif_pcm_ctl->id); in snd_trident_spdif_open()
1890 /*---------------------------------------------------------------------------
1895 Parameters: substream - PCM substream class
1897 ---------------------------------------------------------------------------*/
1904 spin_lock_irq(&trident->reg_lock); in snd_trident_spdif_close()
1906 if (trident->device != TRIDENT_DEVICE_ID_SI7018) { in snd_trident_spdif_close()
1907 outb(trident->spdif_ctrl, TRID_REG(trident, NX_SPCTRL_SPCSO + 3)); in snd_trident_spdif_close()
1908 outl(trident->spdif_bits, TRID_REG(trident, NX_SPCSTATUS)); in snd_trident_spdif_close()
1910 outl(trident->spdif_bits, TRID_REG(trident, SI_SPDIF_CS)); in snd_trident_spdif_close()
1912 if (trident->spdif_ctrl) { in snd_trident_spdif_close()
1919 spin_unlock_irq(&trident->reg_lock); in snd_trident_spdif_close()
1920 trident->spdif_pcm_ctl->vd[0].access |= SNDRV_CTL_ELEM_ACCESS_INACTIVE; in snd_trident_spdif_close()
1921 snd_ctl_notify(trident->card, SNDRV_CTL_EVENT_MASK_VALUE | in snd_trident_spdif_close()
1922 SNDRV_CTL_EVENT_MASK_INFO, &trident->spdif_pcm_ctl->id); in snd_trident_spdif_close()
1926 /*---------------------------------------------------------------------------
1931 Parameters: substream - PCM substream class
1933 Returns: status - success or failure flag
1935 ---------------------------------------------------------------------------*/
1941 struct snd_pcm_runtime *runtime = substream->runtime; in snd_trident_capture_open()
1945 return -EAGAIN; in snd_trident_capture_open()
1946 voice->capture = 1; in snd_trident_capture_open()
1947 voice->substream = substream; in snd_trident_capture_open()
1948 runtime->private_data = voice; in snd_trident_capture_open()
1949 runtime->private_free = snd_trident_pcm_free_substream; in snd_trident_capture_open()
1950 runtime->hw = snd_trident_capture; in snd_trident_capture_open()
1956 /*---------------------------------------------------------------------------
1962 Parameters: substream - PCM substream class
1964 ---------------------------------------------------------------------------*/
1970 /*---------------------------------------------------------------------------
1975 Parameters: substream - PCM substream class
1977 Returns: status - success or failure flag
1979 ---------------------------------------------------------------------------*/
1985 struct snd_pcm_runtime *runtime = substream->runtime; in snd_trident_foldback_open()
1989 return -EAGAIN; in snd_trident_foldback_open()
1990 voice->foldback_chan = substream->number; in snd_trident_foldback_open()
1991 voice->substream = substream; in snd_trident_foldback_open()
1992 runtime->private_data = voice; in snd_trident_foldback_open()
1993 runtime->private_free = snd_trident_pcm_free_substream; in snd_trident_foldback_open()
1994 runtime->hw = snd_trident_foldback; in snd_trident_foldback_open()
1999 /*---------------------------------------------------------------------------
2005 Parameters: substream - PCM substream class
2007 ---------------------------------------------------------------------------*/
2012 struct snd_pcm_runtime *runtime = substream->runtime; in snd_trident_foldback_close()
2013 voice = runtime->private_data; in snd_trident_foldback_close()
2016 spin_lock_irq(&trident->reg_lock); in snd_trident_foldback_close()
2017 outb(0x00, TRID_REG(trident, T4D_RCI + voice->foldback_chan)); in snd_trident_foldback_close()
2018 spin_unlock_irq(&trident->reg_lock); in snd_trident_foldback_close()
2022 /*---------------------------------------------------------------------------
2024 ---------------------------------------------------------------------------*/
2106 /*---------------------------------------------------------------------------
2111 Parameters: trident - pointer to target device class for 4DWave.
2115 ---------------------------------------------------------------------------*/
2122 if ((err = snd_pcm_new(trident->card, "trident_dx_nx", device, trident->ChanPCM, 1, &pcm)) < 0) in snd_trident_pcm()
2125 pcm->private_data = trident; in snd_trident_pcm()
2127 if (trident->tlb.entries) { in snd_trident_pcm()
2133 trident->device != TRIDENT_DEVICE_ID_SI7018 ? in snd_trident_pcm()
2137 pcm->info_flags = 0; in snd_trident_pcm()
2138 pcm->dev_subclass = SNDRV_PCM_SUBCLASS_GENERIC_MIX; in snd_trident_pcm()
2139 strcpy(pcm->name, "Trident 4DWave"); in snd_trident_pcm()
2140 trident->pcm = pcm; in snd_trident_pcm()
2142 if (trident->tlb.entries) { in snd_trident_pcm()
2144 …for (substream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; substream; substream = substre… in snd_trident_pcm()
2146 &trident->pci->dev, in snd_trident_pcm()
2148 snd_pcm_set_managed_buffer(pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream, in snd_trident_pcm()
2150 &trident->pci->dev, in snd_trident_pcm()
2154 &trident->pci->dev, in snd_trident_pcm()
2161 /*---------------------------------------------------------------------------
2166 Parameters: trident - pointer to target device class for 4DWave.
2170 ---------------------------------------------------------------------------*/
2179 if (trident->device == TRIDENT_DEVICE_ID_NX) in snd_trident_foldback_pcm()
2181 if ((err = snd_pcm_new(trident->card, "trident_dx_nx", device, 0, num_chan, &foldback)) < 0) in snd_trident_foldback_pcm()
2184 foldback->private_data = trident; in snd_trident_foldback_pcm()
2185 if (trident->tlb.entries) in snd_trident_foldback_pcm()
2189 foldback->info_flags = 0; in snd_trident_foldback_pcm()
2190 strcpy(foldback->name, "Trident 4DWave"); in snd_trident_foldback_pcm()
2191 substream = foldback->streams[SNDRV_PCM_STREAM_CAPTURE].substream; in snd_trident_foldback_pcm()
2192 strcpy(substream->name, "Front Mixer"); in snd_trident_foldback_pcm()
2193 substream = substream->next; in snd_trident_foldback_pcm()
2194 strcpy(substream->name, "Reverb Mixer"); in snd_trident_foldback_pcm()
2195 substream = substream->next; in snd_trident_foldback_pcm()
2196 strcpy(substream->name, "Chorus Mixer"); in snd_trident_foldback_pcm()
2198 substream = substream->next; in snd_trident_foldback_pcm()
2199 strcpy(substream->name, "Second AC'97 ADC"); in snd_trident_foldback_pcm()
2201 trident->foldback = foldback; in snd_trident_foldback_pcm()
2203 if (trident->tlb.entries) in snd_trident_foldback_pcm()
2205 &trident->pci->dev, in snd_trident_foldback_pcm()
2209 &trident->pci->dev, in snd_trident_foldback_pcm()
2215 /*---------------------------------------------------------------------------
2218 Description: This routine registers the 4DWave-NX device for SPDIF support.
2220 Parameters: trident - pointer to target device class for 4DWave-NX.
2224 ---------------------------------------------------------------------------*/
2231 if ((err = snd_pcm_new(trident->card, "trident_dx_nx IEC958", device, 1, 0, &spdif)) < 0) in snd_trident_spdif_pcm()
2234 spdif->private_data = trident; in snd_trident_spdif_pcm()
2235 if (trident->device != TRIDENT_DEVICE_ID_SI7018) { in snd_trident_spdif_pcm()
2240 spdif->info_flags = 0; in snd_trident_spdif_pcm()
2241 strcpy(spdif->name, "Trident 4DWave IEC958"); in snd_trident_spdif_pcm()
2242 trident->spdif = spdif; in snd_trident_spdif_pcm()
2245 &trident->pci->dev, 64*1024, 128*1024); in snd_trident_spdif_pcm()
2255 /*---------------------------------------------------------------------------
2259 ---------------------------------------------------------------------------*/
2269 spin_lock_irq(&trident->reg_lock); in snd_trident_spdif_control_get()
2270 val = trident->spdif_ctrl; in snd_trident_spdif_control_get()
2271 ucontrol->value.integer.value[0] = val == kcontrol->private_value; in snd_trident_spdif_control_get()
2272 spin_unlock_irq(&trident->reg_lock); in snd_trident_spdif_control_get()
2283 val = ucontrol->value.integer.value[0] ? (unsigned char) kcontrol->private_value : 0x00; in snd_trident_spdif_control_put()
2284 spin_lock_irq(&trident->reg_lock); in snd_trident_spdif_control_put()
2285 /* S/PDIF C Channel bits 0-31 : 48khz, SCMS disabled */ in snd_trident_spdif_control_put()
2286 change = trident->spdif_ctrl != val; in snd_trident_spdif_control_put()
2287 trident->spdif_ctrl = val; in snd_trident_spdif_control_put()
2288 if (trident->device != TRIDENT_DEVICE_ID_SI7018) { in snd_trident_spdif_control_put()
2290 outl(trident->spdif_bits, TRID_REG(trident, NX_SPCSTATUS)); in snd_trident_spdif_control_put()
2291 outb(trident->spdif_ctrl, TRID_REG(trident, NX_SPCTRL_SPCSO + 3)); in snd_trident_spdif_control_put()
2294 if (trident->spdif == NULL) { in snd_trident_spdif_control_put()
2296 outl(trident->spdif_bits, TRID_REG(trident, SI_SPDIF_CS)); in snd_trident_spdif_control_put()
2303 spin_unlock_irq(&trident->reg_lock); in snd_trident_spdif_control_put()
2317 /*---------------------------------------------------------------------------
2321 ---------------------------------------------------------------------------*/
2326 uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958; in snd_trident_spdif_default_info()
2327 uinfo->count = 1; in snd_trident_spdif_default_info()
2336 spin_lock_irq(&trident->reg_lock); in snd_trident_spdif_default_get()
2337 ucontrol->value.iec958.status[0] = (trident->spdif_bits >> 0) & 0xff; in snd_trident_spdif_default_get()
2338 ucontrol->value.iec958.status[1] = (trident->spdif_bits >> 8) & 0xff; in snd_trident_spdif_default_get()
2339 ucontrol->value.iec958.status[2] = (trident->spdif_bits >> 16) & 0xff; in snd_trident_spdif_default_get()
2340 ucontrol->value.iec958.status[3] = (trident->spdif_bits >> 24) & 0xff; in snd_trident_spdif_default_get()
2341 spin_unlock_irq(&trident->reg_lock); in snd_trident_spdif_default_get()
2352 val = (ucontrol->value.iec958.status[0] << 0) | in snd_trident_spdif_default_put()
2353 (ucontrol->value.iec958.status[1] << 8) | in snd_trident_spdif_default_put()
2354 (ucontrol->value.iec958.status[2] << 16) | in snd_trident_spdif_default_put()
2355 (ucontrol->value.iec958.status[3] << 24); in snd_trident_spdif_default_put()
2356 spin_lock_irq(&trident->reg_lock); in snd_trident_spdif_default_put()
2357 change = trident->spdif_bits != val; in snd_trident_spdif_default_put()
2358 trident->spdif_bits = val; in snd_trident_spdif_default_put()
2359 if (trident->device != TRIDENT_DEVICE_ID_SI7018) { in snd_trident_spdif_default_put()
2361 outl(trident->spdif_bits, TRID_REG(trident, NX_SPCSTATUS)); in snd_trident_spdif_default_put()
2363 if (trident->spdif == NULL) in snd_trident_spdif_default_put()
2364 outl(trident->spdif_bits, TRID_REG(trident, SI_SPDIF_CS)); in snd_trident_spdif_default_put()
2366 spin_unlock_irq(&trident->reg_lock); in snd_trident_spdif_default_put()
2379 /*---------------------------------------------------------------------------
2383 ---------------------------------------------------------------------------*/
2388 uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958; in snd_trident_spdif_mask_info()
2389 uinfo->count = 1; in snd_trident_spdif_mask_info()
2396 ucontrol->value.iec958.status[0] = 0xff; in snd_trident_spdif_mask_get()
2397 ucontrol->value.iec958.status[1] = 0xff; in snd_trident_spdif_mask_get()
2398 ucontrol->value.iec958.status[2] = 0xff; in snd_trident_spdif_mask_get()
2399 ucontrol->value.iec958.status[3] = 0xff; in snd_trident_spdif_mask_get()
2412 /*---------------------------------------------------------------------------
2416 ---------------------------------------------------------------------------*/
2421 uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958; in snd_trident_spdif_stream_info()
2422 uinfo->count = 1; in snd_trident_spdif_stream_info()
2431 spin_lock_irq(&trident->reg_lock); in snd_trident_spdif_stream_get()
2432 ucontrol->value.iec958.status[0] = (trident->spdif_pcm_bits >> 0) & 0xff; in snd_trident_spdif_stream_get()
2433 ucontrol->value.iec958.status[1] = (trident->spdif_pcm_bits >> 8) & 0xff; in snd_trident_spdif_stream_get()
2434 ucontrol->value.iec958.status[2] = (trident->spdif_pcm_bits >> 16) & 0xff; in snd_trident_spdif_stream_get()
2435 ucontrol->value.iec958.status[3] = (trident->spdif_pcm_bits >> 24) & 0xff; in snd_trident_spdif_stream_get()
2436 spin_unlock_irq(&trident->reg_lock); in snd_trident_spdif_stream_get()
2447 val = (ucontrol->value.iec958.status[0] << 0) | in snd_trident_spdif_stream_put()
2448 (ucontrol->value.iec958.status[1] << 8) | in snd_trident_spdif_stream_put()
2449 (ucontrol->value.iec958.status[2] << 16) | in snd_trident_spdif_stream_put()
2450 (ucontrol->value.iec958.status[3] << 24); in snd_trident_spdif_stream_put()
2451 spin_lock_irq(&trident->reg_lock); in snd_trident_spdif_stream_put()
2452 change = trident->spdif_pcm_bits != val; in snd_trident_spdif_stream_put()
2453 trident->spdif_pcm_bits = val; in snd_trident_spdif_stream_put()
2454 if (trident->spdif != NULL) { in snd_trident_spdif_stream_put()
2455 if (trident->device != TRIDENT_DEVICE_ID_SI7018) { in snd_trident_spdif_stream_put()
2456 outl(trident->spdif_pcm_bits, TRID_REG(trident, NX_SPCSTATUS)); in snd_trident_spdif_stream_put()
2458 outl(trident->spdif_bits, TRID_REG(trident, SI_SPDIF_CS)); in snd_trident_spdif_stream_put()
2461 spin_unlock_irq(&trident->reg_lock); in snd_trident_spdif_stream_put()
2475 /*---------------------------------------------------------------------------
2479 ---------------------------------------------------------------------------*/
2489 spin_lock_irq(&trident->reg_lock); in snd_trident_ac97_control_get()
2490 val = trident->ac97_ctrl = inl(TRID_REG(trident, NX_ACR0_AC97_COM_STAT)); in snd_trident_ac97_control_get()
2491 ucontrol->value.integer.value[0] = (val & (1 << kcontrol->private_value)) ? 1 : 0; in snd_trident_ac97_control_get()
2492 spin_unlock_irq(&trident->reg_lock); in snd_trident_ac97_control_get()
2503 spin_lock_irq(&trident->reg_lock); in snd_trident_ac97_control_put()
2504 val = trident->ac97_ctrl = inl(TRID_REG(trident, NX_ACR0_AC97_COM_STAT)); in snd_trident_ac97_control_put()
2505 val &= ~(1 << kcontrol->private_value); in snd_trident_ac97_control_put()
2506 if (ucontrol->value.integer.value[0]) in snd_trident_ac97_control_put()
2507 val |= 1 << kcontrol->private_value; in snd_trident_ac97_control_put()
2508 change = val != trident->ac97_ctrl; in snd_trident_ac97_control_put()
2509 trident->ac97_ctrl = val; in snd_trident_ac97_control_put()
2510 outl(trident->ac97_ctrl = val, TRID_REG(trident, NX_ACR0_AC97_COM_STAT)); in snd_trident_ac97_control_put()
2511 spin_unlock_irq(&trident->reg_lock); in snd_trident_ac97_control_put()
2525 /*---------------------------------------------------------------------------
2529 ---------------------------------------------------------------------------*/
2534 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in snd_trident_vol_control_info()
2535 uinfo->count = 2; in snd_trident_vol_control_info()
2536 uinfo->value.integer.min = 0; in snd_trident_vol_control_info()
2537 uinfo->value.integer.max = 255; in snd_trident_vol_control_info()
2547 val = trident->musicvol_wavevol; in snd_trident_vol_control_get()
2548 ucontrol->value.integer.value[0] = 255 - ((val >> kcontrol->private_value) & 0xff); in snd_trident_vol_control_get()
2549 ucontrol->value.integer.value[1] = 255 - ((val >> (kcontrol->private_value + 8)) & 0xff); in snd_trident_vol_control_get()
2553 static const DECLARE_TLV_DB_SCALE(db_scale_gvol, -6375, 25, 0);
2562 spin_lock_irq(&trident->reg_lock); in snd_trident_vol_control_put()
2563 val = trident->musicvol_wavevol; in snd_trident_vol_control_put()
2564 val &= ~(0xffff << kcontrol->private_value); in snd_trident_vol_control_put()
2565 val |= ((255 - (ucontrol->value.integer.value[0] & 0xff)) | in snd_trident_vol_control_put()
2566 ((255 - (ucontrol->value.integer.value[1] & 0xff)) << 8)) << kcontrol->private_value; in snd_trident_vol_control_put()
2567 change = val != trident->musicvol_wavevol; in snd_trident_vol_control_put()
2568 outl(trident->musicvol_wavevol = val, TRID_REG(trident, T4D_MUSICVOL_WAVEVOL)); in snd_trident_vol_control_put()
2569 spin_unlock_irq(&trident->reg_lock); in snd_trident_vol_control_put()
2595 /*---------------------------------------------------------------------------
2599 ---------------------------------------------------------------------------*/
2606 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in snd_trident_pcm_vol_control_info()
2607 uinfo->count = 1; in snd_trident_pcm_vol_control_info()
2608 uinfo->value.integer.min = 0; in snd_trident_pcm_vol_control_info()
2609 uinfo->value.integer.max = 255; in snd_trident_pcm_vol_control_info()
2610 if (trident->device == TRIDENT_DEVICE_ID_SI7018) in snd_trident_pcm_vol_control_info()
2611 uinfo->value.integer.max = 1023; in snd_trident_pcm_vol_control_info()
2619 …struct snd_trident_pcm_mixer *mix = &trident->pcm_mixer[snd_ctl_get_ioffnum(kcontrol, &ucontrol->i… in snd_trident_pcm_vol_control_get()
2621 if (trident->device == TRIDENT_DEVICE_ID_SI7018) { in snd_trident_pcm_vol_control_get()
2622 ucontrol->value.integer.value[0] = 1023 - mix->vol; in snd_trident_pcm_vol_control_get()
2624 ucontrol->value.integer.value[0] = 255 - (mix->vol>>2); in snd_trident_pcm_vol_control_get()
2633 …struct snd_trident_pcm_mixer *mix = &trident->pcm_mixer[snd_ctl_get_ioffnum(kcontrol, &ucontrol->i… in snd_trident_pcm_vol_control_put()
2637 if (trident->device == TRIDENT_DEVICE_ID_SI7018) { in snd_trident_pcm_vol_control_put()
2638 val = 1023 - (ucontrol->value.integer.value[0] & 1023); in snd_trident_pcm_vol_control_put()
2640 val = (255 - (ucontrol->value.integer.value[0] & 255)) << 2; in snd_trident_pcm_vol_control_put()
2642 spin_lock_irq(&trident->reg_lock); in snd_trident_pcm_vol_control_put()
2643 change = val != mix->vol; in snd_trident_pcm_vol_control_put()
2644 mix->vol = val; in snd_trident_pcm_vol_control_put()
2645 if (mix->voice != NULL) in snd_trident_pcm_vol_control_put()
2646 snd_trident_write_vol_reg(trident, mix->voice, val); in snd_trident_pcm_vol_control_put()
2647 spin_unlock_irq(&trident->reg_lock); in snd_trident_pcm_vol_control_put()
2663 /*---------------------------------------------------------------------------
2667 ---------------------------------------------------------------------------*/
2672 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in snd_trident_pcm_pan_control_info()
2673 uinfo->count = 1; in snd_trident_pcm_pan_control_info()
2674 uinfo->value.integer.min = 0; in snd_trident_pcm_pan_control_info()
2675 uinfo->value.integer.max = 127; in snd_trident_pcm_pan_control_info()
2683 …struct snd_trident_pcm_mixer *mix = &trident->pcm_mixer[snd_ctl_get_ioffnum(kcontrol, &ucontrol->i… in snd_trident_pcm_pan_control_get()
2685 ucontrol->value.integer.value[0] = mix->pan; in snd_trident_pcm_pan_control_get()
2686 if (ucontrol->value.integer.value[0] & 0x40) { in snd_trident_pcm_pan_control_get()
2687 ucontrol->value.integer.value[0] = (0x3f - (ucontrol->value.integer.value[0] & 0x3f)); in snd_trident_pcm_pan_control_get()
2689 ucontrol->value.integer.value[0] |= 0x40; in snd_trident_pcm_pan_control_get()
2698 …struct snd_trident_pcm_mixer *mix = &trident->pcm_mixer[snd_ctl_get_ioffnum(kcontrol, &ucontrol->i… in snd_trident_pcm_pan_control_put()
2702 if (ucontrol->value.integer.value[0] & 0x40) in snd_trident_pcm_pan_control_put()
2703 val = ucontrol->value.integer.value[0] & 0x3f; in snd_trident_pcm_pan_control_put()
2705 val = (0x3f - (ucontrol->value.integer.value[0] & 0x3f)) | 0x40; in snd_trident_pcm_pan_control_put()
2706 spin_lock_irq(&trident->reg_lock); in snd_trident_pcm_pan_control_put()
2707 change = val != mix->pan; in snd_trident_pcm_pan_control_put()
2708 mix->pan = val; in snd_trident_pcm_pan_control_put()
2709 if (mix->voice != NULL) in snd_trident_pcm_pan_control_put()
2710 snd_trident_write_pan_reg(trident, mix->voice, val); in snd_trident_pcm_pan_control_put()
2711 spin_unlock_irq(&trident->reg_lock); in snd_trident_pcm_pan_control_put()
2726 /*---------------------------------------------------------------------------
2730 ---------------------------------------------------------------------------*/
2735 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in snd_trident_pcm_rvol_control_info()
2736 uinfo->count = 1; in snd_trident_pcm_rvol_control_info()
2737 uinfo->value.integer.min = 0; in snd_trident_pcm_rvol_control_info()
2738 uinfo->value.integer.max = 127; in snd_trident_pcm_rvol_control_info()
2746 …struct snd_trident_pcm_mixer *mix = &trident->pcm_mixer[snd_ctl_get_ioffnum(kcontrol, &ucontrol->i… in snd_trident_pcm_rvol_control_get()
2748 ucontrol->value.integer.value[0] = 127 - mix->rvol; in snd_trident_pcm_rvol_control_get()
2756 …struct snd_trident_pcm_mixer *mix = &trident->pcm_mixer[snd_ctl_get_ioffnum(kcontrol, &ucontrol->i… in snd_trident_pcm_rvol_control_put()
2760 val = 0x7f - (ucontrol->value.integer.value[0] & 0x7f); in snd_trident_pcm_rvol_control_put()
2761 spin_lock_irq(&trident->reg_lock); in snd_trident_pcm_rvol_control_put()
2762 change = val != mix->rvol; in snd_trident_pcm_rvol_control_put()
2763 mix->rvol = val; in snd_trident_pcm_rvol_control_put()
2764 if (mix->voice != NULL) in snd_trident_pcm_rvol_control_put()
2765 snd_trident_write_rvol_reg(trident, mix->voice, val); in snd_trident_pcm_rvol_control_put()
2766 spin_unlock_irq(&trident->reg_lock); in snd_trident_pcm_rvol_control_put()
2770 static const DECLARE_TLV_DB_SCALE(db_scale_crvol, -3175, 25, 1);
2784 /*---------------------------------------------------------------------------
2788 ---------------------------------------------------------------------------*/
2793 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in snd_trident_pcm_cvol_control_info()
2794 uinfo->count = 1; in snd_trident_pcm_cvol_control_info()
2795 uinfo->value.integer.min = 0; in snd_trident_pcm_cvol_control_info()
2796 uinfo->value.integer.max = 127; in snd_trident_pcm_cvol_control_info()
2804 …struct snd_trident_pcm_mixer *mix = &trident->pcm_mixer[snd_ctl_get_ioffnum(kcontrol, &ucontrol->i… in snd_trident_pcm_cvol_control_get()
2806 ucontrol->value.integer.value[0] = 127 - mix->cvol; in snd_trident_pcm_cvol_control_get()
2814 …struct snd_trident_pcm_mixer *mix = &trident->pcm_mixer[snd_ctl_get_ioffnum(kcontrol, &ucontrol->i… in snd_trident_pcm_cvol_control_put()
2818 val = 0x7f - (ucontrol->value.integer.value[0] & 0x7f); in snd_trident_pcm_cvol_control_put()
2819 spin_lock_irq(&trident->reg_lock); in snd_trident_pcm_cvol_control_put()
2820 change = val != mix->cvol; in snd_trident_pcm_cvol_control_put()
2821 mix->cvol = val; in snd_trident_pcm_cvol_control_put()
2822 if (mix->voice != NULL) in snd_trident_pcm_cvol_control_put()
2823 snd_trident_write_cvol_reg(trident, mix->voice, val); in snd_trident_pcm_cvol_control_put()
2824 spin_unlock_irq(&trident->reg_lock); in snd_trident_pcm_cvol_control_put()
2849 kctl->vd[num].access &= ~SNDRV_CTL_ELEM_ACCESS_INACTIVE; in snd_trident_notify_pcm_change1()
2851 kctl->vd[num].access |= SNDRV_CTL_ELEM_ACCESS_INACTIVE; in snd_trident_notify_pcm_change1()
2861 snd_trident_notify_pcm_change1(trident->card, trident->ctl_vol, num, activate); in snd_trident_notify_pcm_change()
2862 snd_trident_notify_pcm_change1(trident->card, trident->ctl_pan, num, activate); in snd_trident_notify_pcm_change()
2863 snd_trident_notify_pcm_change1(trident->card, trident->ctl_rvol, num, activate); in snd_trident_notify_pcm_change()
2864 snd_trident_notify_pcm_change1(trident->card, trident->ctl_cvol, num, activate); in snd_trident_notify_pcm_change()
2874 return -EINVAL; in snd_trident_pcm_mixer_build()
2875 tmix = &trident->pcm_mixer[substream->number]; in snd_trident_pcm_mixer_build()
2876 tmix->voice = voice; in snd_trident_pcm_mixer_build()
2877 tmix->vol = T4D_DEFAULT_PCM_VOL; in snd_trident_pcm_mixer_build()
2878 tmix->pan = T4D_DEFAULT_PCM_PAN; in snd_trident_pcm_mixer_build()
2879 tmix->rvol = T4D_DEFAULT_PCM_RVOL; in snd_trident_pcm_mixer_build()
2880 tmix->cvol = T4D_DEFAULT_PCM_CVOL; in snd_trident_pcm_mixer_build()
2881 snd_trident_notify_pcm_change(trident, tmix, substream->number, 1); in snd_trident_pcm_mixer_build()
2890 return -EINVAL; in snd_trident_pcm_mixer_free()
2891 tmix = &trident->pcm_mixer[substream->number]; in snd_trident_pcm_mixer_free()
2892 tmix->voice = NULL; in snd_trident_pcm_mixer_free()
2893 snd_trident_notify_pcm_change(trident, tmix, substream->number, 0); in snd_trident_pcm_mixer_free()
2897 /*---------------------------------------------------------------------------
2902 Parameters: trident - pointer to target device class for 4DWave.
2906 ---------------------------------------------------------------------------*/
2911 struct snd_card *card = trident->card; in snd_trident_mixer()
2922 return -ENOMEM; in snd_trident_mixer()
2924 if ((err = snd_ac97_bus(trident->card, 0, &ops, NULL, &trident->ac97_bus)) < 0) in snd_trident_mixer()
2929 trident->ac97_detect = 1; in snd_trident_mixer()
2932 if ((err = snd_ac97_mixer(trident->ac97_bus, &_ac97, &trident->ac97)) < 0) { in snd_trident_mixer()
2933 if (trident->device == TRIDENT_DEVICE_ID_SI7018) { in snd_trident_mixer()
2936 if (retries-- > 0) in snd_trident_mixer()
2938 err = -EIO; in snd_trident_mixer()
2943 /* secondary codec? */ in snd_trident_mixer()
2944 if (trident->device == TRIDENT_DEVICE_ID_SI7018 && in snd_trident_mixer()
2947 err = snd_ac97_mixer(trident->ac97_bus, &_ac97, &trident->ac97_sec); in snd_trident_mixer()
2949 dev_err(trident->card->dev, in snd_trident_mixer()
2950 "SI7018: the secondary codec - invalid access\n"); in snd_trident_mixer()
2951 #if 0 // only for my testing purpose --jk in snd_trident_mixer()
2954 err = snd_ac97_modem(trident->card, &_ac97, &mc97); in snd_trident_mixer()
2956 dev_err(trident->card->dev, in snd_trident_mixer()
2962 trident->ac97_detect = 0; in snd_trident_mixer()
2964 if (trident->device != TRIDENT_DEVICE_ID_SI7018) { in snd_trident_mixer()
2967 kctl->put(kctl, uctl); in snd_trident_mixer()
2970 kctl->put(kctl, uctl); in snd_trident_mixer()
2971 outl(trident->musicvol_wavevol = 0x00000000, TRID_REG(trident, T4D_MUSICVOL_WAVEVOL)); in snd_trident_mixer()
2973 outl(trident->musicvol_wavevol = 0xffff0000, TRID_REG(trident, T4D_MUSICVOL_WAVEVOL)); in snd_trident_mixer()
2979 tmix = &trident->pcm_mixer[idx]; in snd_trident_mixer()
2980 tmix->voice = NULL; in snd_trident_mixer()
2982 if ((trident->ctl_vol = snd_ctl_new1(&snd_trident_pcm_vol_control, trident)) == NULL) in snd_trident_mixer()
2984 if ((err = snd_ctl_add(card, trident->ctl_vol))) in snd_trident_mixer()
2987 if ((trident->ctl_pan = snd_ctl_new1(&snd_trident_pcm_pan_control, trident)) == NULL) in snd_trident_mixer()
2989 if ((err = snd_ctl_add(card, trident->ctl_pan))) in snd_trident_mixer()
2992 if ((trident->ctl_rvol = snd_ctl_new1(&snd_trident_pcm_rvol_control, trident)) == NULL) in snd_trident_mixer()
2994 if ((err = snd_ctl_add(card, trident->ctl_rvol))) in snd_trident_mixer()
2997 if ((trident->ctl_cvol = snd_ctl_new1(&snd_trident_pcm_cvol_control, trident)) == NULL) in snd_trident_mixer()
2999 if ((err = snd_ctl_add(card, trident->ctl_cvol))) in snd_trident_mixer()
3002 if (trident->device == TRIDENT_DEVICE_ID_NX) { in snd_trident_mixer()
3005 kctl->put(kctl, uctl); in snd_trident_mixer()
3007 if (trident->device == TRIDENT_DEVICE_ID_NX || trident->device == TRIDENT_DEVICE_ID_SI7018) { in snd_trident_mixer()
3011 err = -ENOMEM; in snd_trident_mixer()
3014 if (trident->ac97->ext_id & AC97_EI_SPDIF) in snd_trident_mixer()
3015 kctl->id.index++; in snd_trident_mixer()
3016 if (trident->ac97_sec && (trident->ac97_sec->ext_id & AC97_EI_SPDIF)) in snd_trident_mixer()
3017 kctl->id.index++; in snd_trident_mixer()
3018 idx = kctl->id.index; in snd_trident_mixer()
3021 kctl->put(kctl, uctl); in snd_trident_mixer()
3025 err = -ENOMEM; in snd_trident_mixer()
3028 kctl->id.index = idx; in snd_trident_mixer()
3029 kctl->id.device = pcm_spdif_device; in snd_trident_mixer()
3035 err = -ENOMEM; in snd_trident_mixer()
3038 kctl->id.index = idx; in snd_trident_mixer()
3039 kctl->id.device = pcm_spdif_device; in snd_trident_mixer()
3045 err = -ENOMEM; in snd_trident_mixer()
3048 kctl->id.index = idx; in snd_trident_mixer()
3049 kctl->id.device = pcm_spdif_device; in snd_trident_mixer()
3052 trident->spdif_pcm_ctl = kctl; in snd_trident_mixer()
3059 err = -ENOMEM; in snd_trident_mixer()
3103 if (axes[i] == 0xffff) axes[i] = -1; in snd_trident_gameport_cooked_read()
3125 return -1; in snd_trident_gameport_open()
3133 chip->gameport = gp = gameport_allocate_port(); in snd_trident_create_gameport()
3135 dev_err(chip->card->dev, in snd_trident_create_gameport()
3137 return -ENOMEM; in snd_trident_create_gameport()
3141 gameport_set_phys(gp, "pci%s/gameport0", pci_name(chip->pci)); in snd_trident_create_gameport()
3142 gameport_set_dev_parent(gp, &chip->pci->dev); in snd_trident_create_gameport()
3145 gp->fuzz = 64; in snd_trident_create_gameport()
3146 gp->read = snd_trident_gameport_read; in snd_trident_create_gameport()
3147 gp->trigger = snd_trident_gameport_trigger; in snd_trident_create_gameport()
3148 gp->cooked_read = snd_trident_gameport_cooked_read; in snd_trident_create_gameport()
3149 gp->open = snd_trident_gameport_open; in snd_trident_create_gameport()
3158 if (chip->gameport) { in snd_trident_free_gameport()
3159 gameport_unregister_port(chip->gameport); in snd_trident_free_gameport()
3160 chip->gameport = NULL; in snd_trident_free_gameport()
3164 int snd_trident_create_gameport(struct snd_trident *chip) { return -ENOSYS; } in snd_trident_create_gameport()
3186 r = trident->in_suspend ? 0 : 2; /* count of retries */ in snd_trident_sis_reset()
3188 pci_write_config_byte(trident->pci, 0x46, 0x04); /* SOFTWARE RESET */ in snd_trident_sis_reset()
3190 pci_write_config_byte(trident->pci, 0x46, 0x00); in snd_trident_sis_reset()
3202 /* wait, until the codec is ready */ in snd_trident_sis_reset()
3209 dev_err(trident->card->dev, "AC'97 codec ready error [0x%x]\n", in snd_trident_sis_reset()
3211 if (r-- > 0) { in snd_trident_sis_reset()
3219 /* wait for the second codec */ in snd_trident_sis_reset()
3237 struct snd_trident *trident = entry->private_data; in snd_trident_proc_read()
3240 switch (trident->device) { in snd_trident_proc_read()
3254 snd_iprintf(buffer, "Spurious IRQs : %d\n", trident->spurious_irq_count); in snd_trident_proc_read()
3255 snd_iprintf(buffer, "Spurious IRQ dlta: %d\n", trident->spurious_irq_max_delta); in snd_trident_proc_read()
3256 if (trident->device == TRIDENT_DEVICE_ID_NX || trident->device == TRIDENT_DEVICE_ID_SI7018) in snd_trident_proc_read()
3257 snd_iprintf(buffer, "IEC958 Mixer Out : %s\n", trident->spdif_ctrl == 0x28 ? "on" : "off"); in snd_trident_proc_read()
3258 if (trident->device == TRIDENT_DEVICE_ID_NX) { in snd_trident_proc_read()
3259 snd_iprintf(buffer, "Rear Speakers : %s\n", trident->ac97_ctrl & 0x00000010 ? "on" : "off"); in snd_trident_proc_read()
3260 if (trident->tlb.entries) { in snd_trident_proc_read()
3262 snd_iprintf(buffer, "Memory Maximum : %d\n", trident->tlb.memhdr->size); in snd_trident_proc_read()
3263 snd_iprintf(buffer, "Memory Used : %d\n", trident->tlb.memhdr->used); in snd_trident_proc_read()
3264 snd_iprintf(buffer, "Memory Free : %d\n", snd_util_mem_avail(trident->tlb.memhdr)); in snd_trident_proc_read()
3273 if (trident->device == TRIDENT_DEVICE_ID_SI7018) in snd_trident_proc_init()
3275 snd_card_ro_proc_new(trident->card, s, trident, snd_trident_proc_read); in snd_trident_proc_init()
3280 struct snd_trident *trident = device->device_data; in snd_trident_dev_free()
3284 /*---------------------------------------------------------------------------
3290 Parameters: trident - pointer to target device class for 4DWave.
3294 ---------------------------------------------------------------------------*/
3303 if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, &trident->pci->dev, in snd_trident_tlb_alloc()
3304 2 * SNDRV_TRIDENT_MAX_PAGES * 4, &trident->tlb.buffer) < 0) { in snd_trident_tlb_alloc()
3305 dev_err(trident->card->dev, "unable to allocate TLB buffer\n"); in snd_trident_tlb_alloc()
3306 return -ENOMEM; in snd_trident_tlb_alloc()
3308 …trident->tlb.entries = (__le32 *)ALIGN((unsigned long)trident->tlb.buffer.area, SNDRV_TRIDENT_MAX_… in snd_trident_tlb_alloc()
3309 trident->tlb.entries_dmaaddr = ALIGN(trident->tlb.buffer.addr, SNDRV_TRIDENT_MAX_PAGES * 4); in snd_trident_tlb_alloc()
3311 trident->tlb.shadow_entries = in snd_trident_tlb_alloc()
3314 if (!trident->tlb.shadow_entries) in snd_trident_tlb_alloc()
3315 return -ENOMEM; in snd_trident_tlb_alloc()
3318 if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, &trident->pci->dev, in snd_trident_tlb_alloc()
3319 SNDRV_TRIDENT_PAGE_SIZE, &trident->tlb.silent_page) < 0) { in snd_trident_tlb_alloc()
3320 dev_err(trident->card->dev, "unable to allocate silent page\n"); in snd_trident_tlb_alloc()
3321 return -ENOMEM; in snd_trident_tlb_alloc()
3323 memset(trident->tlb.silent_page.area, 0, SNDRV_TRIDENT_PAGE_SIZE); in snd_trident_tlb_alloc()
3325 …trident->tlb.entries[i] = cpu_to_le32(trident->tlb.silent_page.addr & ~(SNDRV_TRIDENT_PAGE_SIZE-1)… in snd_trident_tlb_alloc()
3326 trident->tlb.shadow_entries[i] = (unsigned long)trident->tlb.silent_page.area; in snd_trident_tlb_alloc()
3330 trident->tlb.memhdr = snd_util_memhdr_new(SNDRV_TRIDENT_PAGE_SIZE * SNDRV_TRIDENT_MAX_PAGES); in snd_trident_tlb_alloc()
3331 if (trident->tlb.memhdr == NULL) in snd_trident_tlb_alloc()
3332 return -ENOMEM; in snd_trident_tlb_alloc()
3334 trident->tlb.memhdr->block_extra_size = sizeof(struct snd_trident_memblk_arg); in snd_trident_tlb_alloc()
3352 struct pci_dev *pci = trident->pci; in snd_trident_4d_dx_init()
3364 /* warm reset of the AC'97 codec */ in snd_trident_4d_dx_init()
3369 trident->ac97_ctrl = 0x0000004a; in snd_trident_4d_dx_init()
3370 outl(trident->ac97_ctrl, TRID_REG(trident, DX_ACR2_AC97_COM_STAT)); in snd_trident_4d_dx_init()
3371 /* wait, until the codec is ready */ in snd_trident_4d_dx_init()
3378 dev_err(trident->card->dev, "AC'97 codec ready error\n"); in snd_trident_4d_dx_init()
3379 return -EIO; in snd_trident_4d_dx_init()
3392 struct pci_dev *pci = trident->pci; in snd_trident_4d_nx_init()
3405 /* warm reset of the AC'97 codec */ in snd_trident_4d_nx_init()
3409 /* wait, until the codec is ready */ in snd_trident_4d_nx_init()
3416 dev_err(trident->card->dev, "AC'97 codec ready error [0x%x]\n", in snd_trident_4d_nx_init()
3418 return -EIO; in snd_trident_4d_nx_init()
3422 trident->ac97_ctrl = 0x00000002; in snd_trident_4d_nx_init()
3423 outl(trident->ac97_ctrl, TRID_REG(trident, NX_ACR0_AC97_COM_STAT)); in snd_trident_4d_nx_init()
3429 if (trident->tlb.entries != NULL) { in snd_trident_4d_nx_init()
3432 i = trident->tlb.entries_dmaaddr; in snd_trident_4d_nx_init()
3439 outl(trident->spdif_bits, TRID_REG(trident, NX_SPCSTATUS)); in snd_trident_4d_nx_init()
3440 outb(trident->spdif_ctrl, TRID_REG(trident, NX_SPCTRL_SPCSO + 3)); in snd_trident_4d_nx_init()
3458 outl(trident->spdif_bits, TRID_REG(trident, SI_SPDIF_CS)); in snd_trident_sis_init()
3463 /*---------------------------------------------------------------------------
3469 Parameters: card - which card to create
3470 pci - interface to PCI bus resource info
3471 dma1ptr - playback dma buffer
3472 dma2ptr - capture dma buffer
3473 irqptr - interrupt resource info
3477 ---------------------------------------------------------------------------*/
3500 if (dma_set_mask(&pci->dev, DMA_BIT_MASK(30)) < 0 || in snd_trident_create()
3501 dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(30)) < 0) { in snd_trident_create()
3502 dev_err(card->dev, in snd_trident_create()
3505 return -ENXIO; in snd_trident_create()
3511 return -ENOMEM; in snd_trident_create()
3513 trident->device = (pci->vendor << 16) | pci->device; in snd_trident_create()
3514 trident->card = card; in snd_trident_create()
3515 trident->pci = pci; in snd_trident_create()
3516 spin_lock_init(&trident->reg_lock); in snd_trident_create()
3517 spin_lock_init(&trident->event_lock); in snd_trident_create()
3518 spin_lock_init(&trident->voice_alloc); in snd_trident_create()
3523 trident->ChanPCM = pcm_streams; in snd_trident_create()
3526 trident->synth.max_size = max_wavetable_size * 1024; in snd_trident_create()
3527 trident->irq = -1; in snd_trident_create()
3529 trident->midi_port = TRID_REG(trident, T4D_MPU401_BASE); in snd_trident_create()
3537 trident->port = pci_resource_start(pci, 0); in snd_trident_create()
3539 if (request_irq(pci->irq, snd_trident_interrupt, IRQF_SHARED, in snd_trident_create()
3541 dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq); in snd_trident_create()
3543 return -EBUSY; in snd_trident_create()
3545 trident->irq = pci->irq; in snd_trident_create()
3546 card->sync_irq = trident->irq; in snd_trident_create()
3548 /* allocate 16k-aligned TLB for NX cards */ in snd_trident_create()
3549 trident->tlb.entries = NULL; in snd_trident_create()
3550 trident->tlb.buffer.area = NULL; in snd_trident_create()
3551 if (trident->device == TRIDENT_DEVICE_ID_NX) { in snd_trident_create()
3558 trident->spdif_bits = trident->spdif_pcm_bits = SNDRV_PCM_DEFAULT_CON_SPDIF; in snd_trident_create()
3561 switch (trident->device) { in snd_trident_create()
3590 voice = &trident->synth.voices[i]; in snd_trident_create()
3591 voice->number = i; in snd_trident_create()
3592 voice->trident = trident; in snd_trident_create()
3596 tmix = &trident->pcm_mixer[i]; in snd_trident_create()
3597 tmix->vol = T4D_DEFAULT_PCM_VOL; in snd_trident_create()
3598 tmix->pan = T4D_DEFAULT_PCM_PAN; in snd_trident_create()
3599 tmix->rvol = T4D_DEFAULT_PCM_RVOL; in snd_trident_create()
3600 tmix->cvol = T4D_DEFAULT_PCM_CVOL; in snd_trident_create()
3610 /*---------------------------------------------------------------------------
3616 Parameters: trident - device specific private data for 4DWave card
3620 ---------------------------------------------------------------------------*/
3627 if (trident->device == TRIDENT_DEVICE_ID_NX) in snd_trident_free()
3629 else if (trident->device == TRIDENT_DEVICE_ID_SI7018) { in snd_trident_free()
3632 if (trident->irq >= 0) in snd_trident_free()
3633 free_irq(trident->irq, trident); in snd_trident_free()
3634 if (trident->tlb.buffer.area) { in snd_trident_free()
3636 snd_util_memhdr_free(trident->tlb.memhdr); in snd_trident_free()
3637 if (trident->tlb.silent_page.area) in snd_trident_free()
3638 snd_dma_free_pages(&trident->tlb.silent_page); in snd_trident_free()
3639 vfree(trident->tlb.shadow_entries); in snd_trident_free()
3640 snd_dma_free_pages(&trident->tlb.buffer); in snd_trident_free()
3642 pci_release_regions(trident->pci); in snd_trident_free()
3643 pci_disable_device(trident->pci); in snd_trident_free()
3648 /*---------------------------------------------------------------------------
3653 Parameters: trident - device specific private data for 4DWave card
3664 ---------------------------------------------------------------------------*/
3678 spin_lock(&trident->reg_lock); in snd_trident_interrupt()
3688 for (channel = 63; channel >= 32; channel--) { in snd_trident_interrupt()
3692 voice = &trident->synth.voices[channel]; in snd_trident_interrupt()
3693 if (!voice->pcm || voice->substream == NULL) { in snd_trident_interrupt()
3697 delta = (int)stimer - (int)voice->stimer; in snd_trident_interrupt()
3699 delta = -delta; in snd_trident_interrupt()
3700 if ((unsigned int)delta < voice->spurious_threshold) { in snd_trident_interrupt()
3702 trident->spurious_irq_count++; in snd_trident_interrupt()
3703 if (trident->spurious_irq_max_delta < (unsigned int)delta) in snd_trident_interrupt()
3704 trident->spurious_irq_max_delta = delta; in snd_trident_interrupt()
3707 voice->stimer = stimer; in snd_trident_interrupt()
3708 if (voice->isync) { in snd_trident_interrupt()
3709 if (!voice->isync3) { in snd_trident_interrupt()
3711 if (trident->bDMAStart & 0x40) in snd_trident_interrupt()
3714 tmp = voice->isync_max - tmp; in snd_trident_interrupt()
3718 if (tmp < voice->isync_mark) { in snd_trident_interrupt()
3720 tmp = voice->isync_ESO - 7; in snd_trident_interrupt()
3722 tmp = voice->isync_ESO + 2; in snd_trident_interrupt()
3724 snd_trident_stop_voice(trident, voice->number); in snd_trident_interrupt()
3726 snd_trident_start_voice(trident, voice->number); in snd_trident_interrupt()
3728 } else if (voice->isync2) { in snd_trident_interrupt()
3729 voice->isync2 = 0; in snd_trident_interrupt()
3731 snd_trident_stop_voice(trident, voice->number); in snd_trident_interrupt()
3732 snd_trident_write_cso_reg(trident, voice, voice->isync_mark); in snd_trident_interrupt()
3733 snd_trident_write_eso_reg(trident, voice, voice->ESO); in snd_trident_interrupt()
3734 snd_trident_start_voice(trident, voice->number); in snd_trident_interrupt()
3737 if (voice->extra) { in snd_trident_interrupt()
3739 snd_trident_stop_voice(trident, voice->extra->number); in snd_trident_interrupt()
3740 snd_trident_write_cso_reg(trident, voice->extra, 0); in snd_trident_interrupt()
3741 snd_trident_start_voice(trident, voice->extra->number); in snd_trident_interrupt()
3744 spin_unlock(&trident->reg_lock); in snd_trident_interrupt()
3745 snd_pcm_period_elapsed(voice->substream); in snd_trident_interrupt()
3746 spin_lock(&trident->reg_lock); in snd_trident_interrupt()
3750 spin_unlock(&trident->reg_lock); in snd_trident_interrupt()
3753 if (trident->rmidi) { in snd_trident_interrupt()
3754 snd_mpu401_uart_interrupt(irq, trident->rmidi->private_data); in snd_trident_interrupt()
3769 spin_lock_irqsave(&trident->voice_alloc, flags); in snd_trident_alloc_voice()
3773 spin_unlock_irqrestore(&trident->voice_alloc, flags); in snd_trident_alloc_voice()
3776 pvoice = &trident->synth.voices[idx]; in snd_trident_alloc_voice()
3777 pvoice->use = 1; in snd_trident_alloc_voice()
3778 pvoice->pcm = 1; in snd_trident_alloc_voice()
3779 pvoice->capture = 0; in snd_trident_alloc_voice()
3780 pvoice->spdif = 0; in snd_trident_alloc_voice()
3781 pvoice->memblk = NULL; in snd_trident_alloc_voice()
3782 pvoice->substream = NULL; in snd_trident_alloc_voice()
3783 spin_unlock_irqrestore(&trident->voice_alloc, flags); in snd_trident_alloc_voice()
3789 spin_unlock_irqrestore(&trident->voice_alloc, flags); in snd_trident_alloc_voice()
3792 pvoice = &trident->synth.voices[idx]; in snd_trident_alloc_voice()
3793 pvoice->use = 1; in snd_trident_alloc_voice()
3794 pvoice->synth = 1; in snd_trident_alloc_voice()
3795 pvoice->client = client; in snd_trident_alloc_voice()
3796 pvoice->port = port; in snd_trident_alloc_voice()
3797 pvoice->memblk = NULL; in snd_trident_alloc_voice()
3798 spin_unlock_irqrestore(&trident->voice_alloc, flags); in snd_trident_alloc_voice()
3803 spin_unlock_irqrestore(&trident->voice_alloc, flags); in snd_trident_alloc_voice()
3814 if (voice == NULL || !voice->use) in snd_trident_free_voice()
3816 snd_trident_clear_voices(trident, voice->number, voice->number); in snd_trident_free_voice()
3817 spin_lock_irqsave(&trident->voice_alloc, flags); in snd_trident_free_voice()
3818 private_free = voice->private_free; in snd_trident_free_voice()
3819 voice->private_free = NULL; in snd_trident_free_voice()
3820 voice->private_data = NULL; in snd_trident_free_voice()
3821 if (voice->pcm) in snd_trident_free_voice()
3822 snd_trident_free_pcm_channel(trident, voice->number); in snd_trident_free_voice()
3823 if (voice->synth) in snd_trident_free_voice()
3824 snd_trident_free_synth_channel(trident, voice->number); in snd_trident_free_voice()
3825 voice->use = voice->pcm = voice->synth = voice->midi = 0; in snd_trident_free_voice()
3826 voice->capture = voice->spdif = 0; in snd_trident_free_voice()
3827 voice->sample_ops = NULL; in snd_trident_free_voice()
3828 voice->substream = NULL; in snd_trident_free_voice()
3829 voice->extra = NULL; in snd_trident_free_voice()
3830 spin_unlock_irqrestore(&trident->voice_alloc, flags); in snd_trident_free_voice()
3861 struct snd_trident *trident = card->private_data; in snd_trident_suspend()
3863 trident->in_suspend = 1; in snd_trident_suspend()
3865 snd_ac97_suspend(trident->ac97); in snd_trident_suspend()
3866 snd_ac97_suspend(trident->ac97_sec); in snd_trident_suspend()
3873 struct snd_trident *trident = card->private_data; in snd_trident_resume()
3875 switch (trident->device) { in snd_trident_resume()
3887 snd_ac97_resume(trident->ac97); in snd_trident_resume()
3888 snd_ac97_resume(trident->ac97_sec); in snd_trident_resume()
3891 outl(trident->musicvol_wavevol, TRID_REG(trident, T4D_MUSICVOL_WAVEVOL)); in snd_trident_resume()
3896 trident->in_suspend = 0; in snd_trident_resume()