• Home
  • Raw
  • Download

Lines Matching refs:ensoniq

143 #define ES_REG(ensoniq, x) ((ensoniq)->port + ES_REG_##x)  argument
384 struct ensoniq { struct
518 static unsigned int snd_es1371_wait_src_ready(struct ensoniq * ensoniq) in snd_es1371_wait_src_ready() argument
523 r = inl(ES_REG(ensoniq, 1371_SMPRATE)); in snd_es1371_wait_src_ready()
528 dev_err(ensoniq->card->dev, "wait src ready timeout 0x%lx [0x%x]\n", in snd_es1371_wait_src_ready()
529 ES_REG(ensoniq, 1371_SMPRATE), r); in snd_es1371_wait_src_ready()
533 static unsigned int snd_es1371_src_read(struct ensoniq * ensoniq, unsigned short reg) in snd_es1371_src_read() argument
538 temp = orig = snd_es1371_wait_src_ready(ensoniq); in snd_es1371_src_read()
544 outl(r, ES_REG(ensoniq, 1371_SMPRATE)); in snd_es1371_src_read()
547 temp = snd_es1371_wait_src_ready(ensoniq); in snd_es1371_src_read()
552 temp = inl(ES_REG(ensoniq, 1371_SMPRATE)); in snd_es1371_src_read()
562 outl(r, ES_REG(ensoniq, 1371_SMPRATE)); in snd_es1371_src_read()
567 static void snd_es1371_src_write(struct ensoniq * ensoniq, in snd_es1371_src_write() argument
572 r = snd_es1371_wait_src_ready(ensoniq) & in snd_es1371_src_write()
576 outl(r | ES_1371_SRC_RAM_WE, ES_REG(ensoniq, 1371_SMPRATE)); in snd_es1371_src_write()
586 struct ensoniq *ensoniq = ak4531->private_data; in snd_es1370_codec_write() local
590 dev_dbg(ensoniq->card->dev, in snd_es1370_codec_write()
592 reg, val, ES_1370_CODEC_WRITE(reg, val), ES_REG(ensoniq, 1370_CODEC)); in snd_es1370_codec_write()
595 if (!(inl(ES_REG(ensoniq, STATUS)) & ES_1370_CSTAT)) { in snd_es1370_codec_write()
596 outw(ES_1370_CODEC_WRITE(reg, val), ES_REG(ensoniq, 1370_CODEC)); in snd_es1370_codec_write()
601 dev_err(ensoniq->card->dev, "codec write timeout, status = 0x%x\n", in snd_es1370_codec_write()
602 inl(ES_REG(ensoniq, STATUS))); in snd_es1370_codec_write()
609 static inline bool is_ev1938(struct ensoniq *ensoniq) in is_ev1938() argument
611 return ensoniq->pci->device == 0x8938; in is_ev1938()
617 struct ensoniq *ensoniq = ac97->private_data; in snd_es1371_codec_write() local
620 flag = is_ev1938(ensoniq) ? EV_1938_CODEC_MAGIC : 0; in snd_es1371_codec_write()
621 mutex_lock(&ensoniq->src_mutex); in snd_es1371_codec_write()
623 if (!(inl(ES_REG(ensoniq, 1371_CODEC)) & ES_1371_CODEC_WIP)) { in snd_es1371_codec_write()
625 x = snd_es1371_wait_src_ready(ensoniq); in snd_es1371_codec_write()
628 ES_REG(ensoniq, 1371_SMPRATE)); in snd_es1371_codec_write()
632 if ((inl(ES_REG(ensoniq, 1371_SMPRATE)) & 0x00870000) == in snd_es1371_codec_write()
638 if ((inl(ES_REG(ensoniq, 1371_SMPRATE)) & 0x00870000) == in snd_es1371_codec_write()
643 ES_REG(ensoniq, 1371_CODEC)); in snd_es1371_codec_write()
645 snd_es1371_wait_src_ready(ensoniq); in snd_es1371_codec_write()
646 outl(x, ES_REG(ensoniq, 1371_SMPRATE)); in snd_es1371_codec_write()
647 mutex_unlock(&ensoniq->src_mutex); in snd_es1371_codec_write()
651 mutex_unlock(&ensoniq->src_mutex); in snd_es1371_codec_write()
652 dev_err(ensoniq->card->dev, "codec write timeout at 0x%lx [0x%x]\n", in snd_es1371_codec_write()
653 ES_REG(ensoniq, 1371_CODEC), inl(ES_REG(ensoniq, 1371_CODEC))); in snd_es1371_codec_write()
659 struct ensoniq *ensoniq = ac97->private_data; in snd_es1371_codec_read() local
662 flag = is_ev1938(ensoniq) ? EV_1938_CODEC_MAGIC : 0; in snd_es1371_codec_read()
664 mutex_lock(&ensoniq->src_mutex); in snd_es1371_codec_read()
666 if (!(inl(ES_REG(ensoniq, 1371_CODEC)) & ES_1371_CODEC_WIP)) { in snd_es1371_codec_read()
668 x = snd_es1371_wait_src_ready(ensoniq); in snd_es1371_codec_read()
671 ES_REG(ensoniq, 1371_SMPRATE)); in snd_es1371_codec_read()
675 if ((inl(ES_REG(ensoniq, 1371_SMPRATE)) & 0x00870000) == in snd_es1371_codec_read()
681 if ((inl(ES_REG(ensoniq, 1371_SMPRATE)) & 0x00870000) == in snd_es1371_codec_read()
686 ES_REG(ensoniq, 1371_CODEC)); in snd_es1371_codec_read()
688 snd_es1371_wait_src_ready(ensoniq); in snd_es1371_codec_read()
689 outl(x, ES_REG(ensoniq, 1371_SMPRATE)); in snd_es1371_codec_read()
692 if (!(inl(ES_REG(ensoniq, 1371_CODEC)) & ES_1371_CODEC_WIP)) in snd_es1371_codec_read()
697 if ((x = inl(ES_REG(ensoniq, 1371_CODEC))) & ES_1371_CODEC_RDY) { in snd_es1371_codec_read()
698 if (is_ev1938(ensoniq)) { in snd_es1371_codec_read()
700 inl(ES_REG(ensoniq, CONTROL)); in snd_es1371_codec_read()
701 x = inl(ES_REG(ensoniq, 1371_CODEC)); in snd_es1371_codec_read()
703 mutex_unlock(&ensoniq->src_mutex); in snd_es1371_codec_read()
707 mutex_unlock(&ensoniq->src_mutex); in snd_es1371_codec_read()
709 dev_err(ensoniq->card->dev, in snd_es1371_codec_read()
711 ES_REG(ensoniq, 1371_CODEC), reg, in snd_es1371_codec_read()
712 inl(ES_REG(ensoniq, 1371_CODEC))); in snd_es1371_codec_read()
718 mutex_unlock(&ensoniq->src_mutex); in snd_es1371_codec_read()
719 dev_err(ensoniq->card->dev, "codec read timeout at 0x%lx [0x%x]\n", in snd_es1371_codec_read()
720 ES_REG(ensoniq, 1371_CODEC), inl(ES_REG(ensoniq, 1371_CODEC))); in snd_es1371_codec_read()
733 static void snd_es1371_adc_rate(struct ensoniq * ensoniq, unsigned int rate) in snd_es1371_adc_rate() argument
737 mutex_lock(&ensoniq->src_mutex); in snd_es1371_adc_rate()
747 snd_es1371_src_write(ensoniq, ES_SMPREG_ADC + ES_SMPREG_TRUNC_N, in snd_es1371_adc_rate()
752 snd_es1371_src_write(ensoniq, ES_SMPREG_ADC + ES_SMPREG_TRUNC_N, in snd_es1371_adc_rate()
755 snd_es1371_src_write(ensoniq, ES_SMPREG_ADC + ES_SMPREG_INT_REGS, in snd_es1371_adc_rate()
756 (snd_es1371_src_read(ensoniq, ES_SMPREG_ADC + in snd_es1371_adc_rate()
759 snd_es1371_src_write(ensoniq, ES_SMPREG_ADC + ES_SMPREG_VFREQ_FRAC, freq & 0x7fff); in snd_es1371_adc_rate()
760 snd_es1371_src_write(ensoniq, ES_SMPREG_VOL_ADC, n << 8); in snd_es1371_adc_rate()
761 snd_es1371_src_write(ensoniq, ES_SMPREG_VOL_ADC + 1, n << 8); in snd_es1371_adc_rate()
762 mutex_unlock(&ensoniq->src_mutex); in snd_es1371_adc_rate()
765 static void snd_es1371_dac1_rate(struct ensoniq * ensoniq, unsigned int rate) in snd_es1371_dac1_rate() argument
769 mutex_lock(&ensoniq->src_mutex); in snd_es1371_dac1_rate()
771 r = (snd_es1371_wait_src_ready(ensoniq) & (ES_1371_SRC_DISABLE | in snd_es1371_dac1_rate()
774 outl(r, ES_REG(ensoniq, 1371_SMPRATE)); in snd_es1371_dac1_rate()
775 snd_es1371_src_write(ensoniq, ES_SMPREG_DAC1 + ES_SMPREG_INT_REGS, in snd_es1371_dac1_rate()
776 (snd_es1371_src_read(ensoniq, ES_SMPREG_DAC1 + in snd_es1371_dac1_rate()
779 snd_es1371_src_write(ensoniq, ES_SMPREG_DAC1 + ES_SMPREG_VFREQ_FRAC, freq & 0x7fff); in snd_es1371_dac1_rate()
780 r = (snd_es1371_wait_src_ready(ensoniq) & (ES_1371_SRC_DISABLE | in snd_es1371_dac1_rate()
782 outl(r, ES_REG(ensoniq, 1371_SMPRATE)); in snd_es1371_dac1_rate()
783 mutex_unlock(&ensoniq->src_mutex); in snd_es1371_dac1_rate()
786 static void snd_es1371_dac2_rate(struct ensoniq * ensoniq, unsigned int rate) in snd_es1371_dac2_rate() argument
790 mutex_lock(&ensoniq->src_mutex); in snd_es1371_dac2_rate()
792 r = (snd_es1371_wait_src_ready(ensoniq) & (ES_1371_SRC_DISABLE | in snd_es1371_dac2_rate()
795 outl(r, ES_REG(ensoniq, 1371_SMPRATE)); in snd_es1371_dac2_rate()
796 snd_es1371_src_write(ensoniq, ES_SMPREG_DAC2 + ES_SMPREG_INT_REGS, in snd_es1371_dac2_rate()
797 (snd_es1371_src_read(ensoniq, ES_SMPREG_DAC2 + in snd_es1371_dac2_rate()
800 snd_es1371_src_write(ensoniq, ES_SMPREG_DAC2 + ES_SMPREG_VFREQ_FRAC, in snd_es1371_dac2_rate()
802 r = (snd_es1371_wait_src_ready(ensoniq) & (ES_1371_SRC_DISABLE | in snd_es1371_dac2_rate()
804 outl(r, ES_REG(ensoniq, 1371_SMPRATE)); in snd_es1371_dac2_rate()
805 mutex_unlock(&ensoniq->src_mutex); in snd_es1371_dac2_rate()
812 struct ensoniq *ensoniq = snd_pcm_substream_chip(substream); in snd_ensoniq_trigger() local
820 if (s == ensoniq->playback1_substream) { in snd_ensoniq_trigger()
823 } else if (s == ensoniq->playback2_substream) { in snd_ensoniq_trigger()
826 } else if (s == ensoniq->capture_substream) in snd_ensoniq_trigger()
829 spin_lock(&ensoniq->reg_lock); in snd_ensoniq_trigger()
831 ensoniq->sctrl |= what; in snd_ensoniq_trigger()
833 ensoniq->sctrl &= ~what; in snd_ensoniq_trigger()
834 outl(ensoniq->sctrl, ES_REG(ensoniq, SERIAL)); in snd_ensoniq_trigger()
835 spin_unlock(&ensoniq->reg_lock); in snd_ensoniq_trigger()
844 if (s == ensoniq->playback1_substream) { in snd_ensoniq_trigger()
847 } else if (s == ensoniq->playback2_substream) { in snd_ensoniq_trigger()
850 } else if (s == ensoniq->capture_substream) { in snd_ensoniq_trigger()
855 spin_lock(&ensoniq->reg_lock); in snd_ensoniq_trigger()
857 ensoniq->ctrl |= what; in snd_ensoniq_trigger()
859 ensoniq->ctrl &= ~what; in snd_ensoniq_trigger()
860 outl(ensoniq->ctrl, ES_REG(ensoniq, CONTROL)); in snd_ensoniq_trigger()
861 spin_unlock(&ensoniq->reg_lock); in snd_ensoniq_trigger()
887 struct ensoniq *ensoniq = snd_pcm_substream_chip(substream); in snd_ensoniq_playback1_prepare() local
891 ensoniq->p1_dma_size = snd_pcm_lib_buffer_bytes(substream); in snd_ensoniq_playback1_prepare()
892 ensoniq->p1_period_size = snd_pcm_lib_period_bytes(substream); in snd_ensoniq_playback1_prepare()
897 spin_lock_irq(&ensoniq->reg_lock); in snd_ensoniq_playback1_prepare()
898 ensoniq->ctrl &= ~ES_DAC1_EN; in snd_ensoniq_playback1_prepare()
902 ensoniq->ctrl |= ES_1373_BYPASS_P1; in snd_ensoniq_playback1_prepare()
904 ensoniq->ctrl &= ~ES_1373_BYPASS_P1; in snd_ensoniq_playback1_prepare()
906 outl(ensoniq->ctrl, ES_REG(ensoniq, CONTROL)); in snd_ensoniq_playback1_prepare()
907 outl(ES_MEM_PAGEO(ES_PAGE_DAC), ES_REG(ensoniq, MEM_PAGE)); in snd_ensoniq_playback1_prepare()
908 outl(runtime->dma_addr, ES_REG(ensoniq, DAC1_FRAME)); in snd_ensoniq_playback1_prepare()
909 outl((ensoniq->p1_dma_size >> 2) - 1, ES_REG(ensoniq, DAC1_SIZE)); in snd_ensoniq_playback1_prepare()
910 ensoniq->sctrl &= ~(ES_P1_LOOP_SEL | ES_P1_PAUSE | ES_P1_SCT_RLD | ES_P1_MODEM); in snd_ensoniq_playback1_prepare()
911 ensoniq->sctrl |= ES_P1_INT_EN | ES_P1_MODEO(mode); in snd_ensoniq_playback1_prepare()
912 outl(ensoniq->sctrl, ES_REG(ensoniq, SERIAL)); in snd_ensoniq_playback1_prepare()
913 outl((ensoniq->p1_period_size >> snd_ensoniq_sample_shift[mode]) - 1, in snd_ensoniq_playback1_prepare()
914 ES_REG(ensoniq, DAC1_COUNT)); in snd_ensoniq_playback1_prepare()
916 ensoniq->ctrl &= ~ES_1370_WTSRSELM; in snd_ensoniq_playback1_prepare()
918 case 5512: ensoniq->ctrl |= ES_1370_WTSRSEL(0); break; in snd_ensoniq_playback1_prepare()
919 case 11025: ensoniq->ctrl |= ES_1370_WTSRSEL(1); break; in snd_ensoniq_playback1_prepare()
920 case 22050: ensoniq->ctrl |= ES_1370_WTSRSEL(2); break; in snd_ensoniq_playback1_prepare()
921 case 44100: ensoniq->ctrl |= ES_1370_WTSRSEL(3); break; in snd_ensoniq_playback1_prepare()
925 outl(ensoniq->ctrl, ES_REG(ensoniq, CONTROL)); in snd_ensoniq_playback1_prepare()
926 spin_unlock_irq(&ensoniq->reg_lock); in snd_ensoniq_playback1_prepare()
928 snd_es1371_dac1_rate(ensoniq, runtime->rate); in snd_ensoniq_playback1_prepare()
935 struct ensoniq *ensoniq = snd_pcm_substream_chip(substream); in snd_ensoniq_playback2_prepare() local
939 ensoniq->p2_dma_size = snd_pcm_lib_buffer_bytes(substream); in snd_ensoniq_playback2_prepare()
940 ensoniq->p2_period_size = snd_pcm_lib_period_bytes(substream); in snd_ensoniq_playback2_prepare()
945 spin_lock_irq(&ensoniq->reg_lock); in snd_ensoniq_playback2_prepare()
946 ensoniq->ctrl &= ~ES_DAC2_EN; in snd_ensoniq_playback2_prepare()
947 outl(ensoniq->ctrl, ES_REG(ensoniq, CONTROL)); in snd_ensoniq_playback2_prepare()
948 outl(ES_MEM_PAGEO(ES_PAGE_DAC), ES_REG(ensoniq, MEM_PAGE)); in snd_ensoniq_playback2_prepare()
949 outl(runtime->dma_addr, ES_REG(ensoniq, DAC2_FRAME)); in snd_ensoniq_playback2_prepare()
950 outl((ensoniq->p2_dma_size >> 2) - 1, ES_REG(ensoniq, DAC2_SIZE)); in snd_ensoniq_playback2_prepare()
951 ensoniq->sctrl &= ~(ES_P2_LOOP_SEL | ES_P2_PAUSE | ES_P2_DAC_SEN | in snd_ensoniq_playback2_prepare()
953 ensoniq->sctrl |= ES_P2_INT_EN | ES_P2_MODEO(mode) | in snd_ensoniq_playback2_prepare()
955 outl(ensoniq->sctrl, ES_REG(ensoniq, SERIAL)); in snd_ensoniq_playback2_prepare()
956 outl((ensoniq->p2_period_size >> snd_ensoniq_sample_shift[mode]) - 1, in snd_ensoniq_playback2_prepare()
957 ES_REG(ensoniq, DAC2_COUNT)); in snd_ensoniq_playback2_prepare()
959 if (!(ensoniq->u.es1370.pclkdiv_lock & ES_MODE_CAPTURE)) { in snd_ensoniq_playback2_prepare()
960 ensoniq->ctrl &= ~ES_1370_PCLKDIVM; in snd_ensoniq_playback2_prepare()
961 ensoniq->ctrl |= ES_1370_PCLKDIVO(ES_1370_SRTODIV(runtime->rate)); in snd_ensoniq_playback2_prepare()
962 ensoniq->u.es1370.pclkdiv_lock |= ES_MODE_PLAY2; in snd_ensoniq_playback2_prepare()
965 outl(ensoniq->ctrl, ES_REG(ensoniq, CONTROL)); in snd_ensoniq_playback2_prepare()
966 spin_unlock_irq(&ensoniq->reg_lock); in snd_ensoniq_playback2_prepare()
968 snd_es1371_dac2_rate(ensoniq, runtime->rate); in snd_ensoniq_playback2_prepare()
975 struct ensoniq *ensoniq = snd_pcm_substream_chip(substream); in snd_ensoniq_capture_prepare() local
979 ensoniq->c_dma_size = snd_pcm_lib_buffer_bytes(substream); in snd_ensoniq_capture_prepare()
980 ensoniq->c_period_size = snd_pcm_lib_period_bytes(substream); in snd_ensoniq_capture_prepare()
985 spin_lock_irq(&ensoniq->reg_lock); in snd_ensoniq_capture_prepare()
986 ensoniq->ctrl &= ~ES_ADC_EN; in snd_ensoniq_capture_prepare()
987 outl(ensoniq->ctrl, ES_REG(ensoniq, CONTROL)); in snd_ensoniq_capture_prepare()
988 outl(ES_MEM_PAGEO(ES_PAGE_ADC), ES_REG(ensoniq, MEM_PAGE)); in snd_ensoniq_capture_prepare()
989 outl(runtime->dma_addr, ES_REG(ensoniq, ADC_FRAME)); in snd_ensoniq_capture_prepare()
990 outl((ensoniq->c_dma_size >> 2) - 1, ES_REG(ensoniq, ADC_SIZE)); in snd_ensoniq_capture_prepare()
991 ensoniq->sctrl &= ~(ES_R1_LOOP_SEL | ES_R1_MODEM); in snd_ensoniq_capture_prepare()
992 ensoniq->sctrl |= ES_R1_INT_EN | ES_R1_MODEO(mode); in snd_ensoniq_capture_prepare()
993 outl(ensoniq->sctrl, ES_REG(ensoniq, SERIAL)); in snd_ensoniq_capture_prepare()
994 outl((ensoniq->c_period_size >> snd_ensoniq_sample_shift[mode]) - 1, in snd_ensoniq_capture_prepare()
995 ES_REG(ensoniq, ADC_COUNT)); in snd_ensoniq_capture_prepare()
997 if (!(ensoniq->u.es1370.pclkdiv_lock & ES_MODE_PLAY2)) { in snd_ensoniq_capture_prepare()
998 ensoniq->ctrl &= ~ES_1370_PCLKDIVM; in snd_ensoniq_capture_prepare()
999 ensoniq->ctrl |= ES_1370_PCLKDIVO(ES_1370_SRTODIV(runtime->rate)); in snd_ensoniq_capture_prepare()
1000 ensoniq->u.es1370.pclkdiv_lock |= ES_MODE_CAPTURE; in snd_ensoniq_capture_prepare()
1003 outl(ensoniq->ctrl, ES_REG(ensoniq, CONTROL)); in snd_ensoniq_capture_prepare()
1004 spin_unlock_irq(&ensoniq->reg_lock); in snd_ensoniq_capture_prepare()
1006 snd_es1371_adc_rate(ensoniq, runtime->rate); in snd_ensoniq_capture_prepare()
1013 struct ensoniq *ensoniq = snd_pcm_substream_chip(substream); in snd_ensoniq_playback1_pointer() local
1016 spin_lock(&ensoniq->reg_lock); in snd_ensoniq_playback1_pointer()
1017 if (inl(ES_REG(ensoniq, CONTROL)) & ES_DAC1_EN) { in snd_ensoniq_playback1_pointer()
1018 outl(ES_MEM_PAGEO(ES_PAGE_DAC), ES_REG(ensoniq, MEM_PAGE)); in snd_ensoniq_playback1_pointer()
1019 ptr = ES_REG_FCURR_COUNTI(inl(ES_REG(ensoniq, DAC1_SIZE))); in snd_ensoniq_playback1_pointer()
1024 spin_unlock(&ensoniq->reg_lock); in snd_ensoniq_playback1_pointer()
1030 struct ensoniq *ensoniq = snd_pcm_substream_chip(substream); in snd_ensoniq_playback2_pointer() local
1033 spin_lock(&ensoniq->reg_lock); in snd_ensoniq_playback2_pointer()
1034 if (inl(ES_REG(ensoniq, CONTROL)) & ES_DAC2_EN) { in snd_ensoniq_playback2_pointer()
1035 outl(ES_MEM_PAGEO(ES_PAGE_DAC), ES_REG(ensoniq, MEM_PAGE)); in snd_ensoniq_playback2_pointer()
1036 ptr = ES_REG_FCURR_COUNTI(inl(ES_REG(ensoniq, DAC2_SIZE))); in snd_ensoniq_playback2_pointer()
1041 spin_unlock(&ensoniq->reg_lock); in snd_ensoniq_playback2_pointer()
1047 struct ensoniq *ensoniq = snd_pcm_substream_chip(substream); in snd_ensoniq_capture_pointer() local
1050 spin_lock(&ensoniq->reg_lock); in snd_ensoniq_capture_pointer()
1051 if (inl(ES_REG(ensoniq, CONTROL)) & ES_ADC_EN) { in snd_ensoniq_capture_pointer()
1052 outl(ES_MEM_PAGEO(ES_PAGE_ADC), ES_REG(ensoniq, MEM_PAGE)); in snd_ensoniq_capture_pointer()
1053 ptr = ES_REG_FCURR_COUNTI(inl(ES_REG(ensoniq, ADC_SIZE))); in snd_ensoniq_capture_pointer()
1058 spin_unlock(&ensoniq->reg_lock); in snd_ensoniq_capture_pointer()
1130 struct ensoniq *ensoniq = snd_pcm_substream_chip(substream); in snd_ensoniq_playback1_open() local
1133 ensoniq->mode |= ES_MODE_PLAY1; in snd_ensoniq_playback1_open()
1134 ensoniq->playback1_substream = substream; in snd_ensoniq_playback1_open()
1137 spin_lock_irq(&ensoniq->reg_lock); in snd_ensoniq_playback1_open()
1138 if (ensoniq->spdif && ensoniq->playback2_substream == NULL) in snd_ensoniq_playback1_open()
1139 ensoniq->spdif_stream = ensoniq->spdif_default; in snd_ensoniq_playback1_open()
1140 spin_unlock_irq(&ensoniq->reg_lock); in snd_ensoniq_playback1_open()
1153 struct ensoniq *ensoniq = snd_pcm_substream_chip(substream); in snd_ensoniq_playback2_open() local
1156 ensoniq->mode |= ES_MODE_PLAY2; in snd_ensoniq_playback2_open()
1157 ensoniq->playback2_substream = substream; in snd_ensoniq_playback2_open()
1160 spin_lock_irq(&ensoniq->reg_lock); in snd_ensoniq_playback2_open()
1161 if (ensoniq->spdif && ensoniq->playback1_substream == NULL) in snd_ensoniq_playback2_open()
1162 ensoniq->spdif_stream = ensoniq->spdif_default; in snd_ensoniq_playback2_open()
1163 spin_unlock_irq(&ensoniq->reg_lock); in snd_ensoniq_playback2_open()
1176 struct ensoniq *ensoniq = snd_pcm_substream_chip(substream); in snd_ensoniq_capture_open() local
1179 ensoniq->mode |= ES_MODE_CAPTURE; in snd_ensoniq_capture_open()
1180 ensoniq->capture_substream = substream; in snd_ensoniq_capture_open()
1195 struct ensoniq *ensoniq = snd_pcm_substream_chip(substream); in snd_ensoniq_playback1_close() local
1197 ensoniq->playback1_substream = NULL; in snd_ensoniq_playback1_close()
1198 ensoniq->mode &= ~ES_MODE_PLAY1; in snd_ensoniq_playback1_close()
1204 struct ensoniq *ensoniq = snd_pcm_substream_chip(substream); in snd_ensoniq_playback2_close() local
1206 ensoniq->playback2_substream = NULL; in snd_ensoniq_playback2_close()
1207 spin_lock_irq(&ensoniq->reg_lock); in snd_ensoniq_playback2_close()
1209 ensoniq->u.es1370.pclkdiv_lock &= ~ES_MODE_PLAY2; in snd_ensoniq_playback2_close()
1211 ensoniq->mode &= ~ES_MODE_PLAY2; in snd_ensoniq_playback2_close()
1212 spin_unlock_irq(&ensoniq->reg_lock); in snd_ensoniq_playback2_close()
1218 struct ensoniq *ensoniq = snd_pcm_substream_chip(substream); in snd_ensoniq_capture_close() local
1220 ensoniq->capture_substream = NULL; in snd_ensoniq_capture_close()
1221 spin_lock_irq(&ensoniq->reg_lock); in snd_ensoniq_capture_close()
1223 ensoniq->u.es1370.pclkdiv_lock &= ~ES_MODE_CAPTURE; in snd_ensoniq_capture_close()
1225 ensoniq->mode &= ~ES_MODE_CAPTURE; in snd_ensoniq_capture_close()
1226 spin_unlock_irq(&ensoniq->reg_lock); in snd_ensoniq_capture_close()
1271 static int snd_ensoniq_pcm(struct ensoniq *ensoniq, int device) in snd_ensoniq_pcm() argument
1276 err = snd_pcm_new(ensoniq->card, CHIP_NAME "/1", device, 1, 1, &pcm); in snd_ensoniq_pcm()
1287 pcm->private_data = ensoniq; in snd_ensoniq_pcm()
1290 ensoniq->pcm1 = pcm; in snd_ensoniq_pcm()
1293 snd_dma_pci_data(ensoniq->pci), 64*1024, 128*1024); in snd_ensoniq_pcm()
1305 static int snd_ensoniq_pcm2(struct ensoniq *ensoniq, int device) in snd_ensoniq_pcm2() argument
1310 err = snd_pcm_new(ensoniq->card, CHIP_NAME "/2", device, 1, 0, &pcm); in snd_ensoniq_pcm2()
1319 pcm->private_data = ensoniq; in snd_ensoniq_pcm2()
1322 ensoniq->pcm2 = pcm; in snd_ensoniq_pcm2()
1325 snd_dma_pci_data(ensoniq->pci), 64*1024, 128*1024); in snd_ensoniq_pcm2()
1356 struct ensoniq *ensoniq = snd_kcontrol_chip(kcontrol); in snd_ens1373_spdif_default_get() local
1357 spin_lock_irq(&ensoniq->reg_lock); in snd_ens1373_spdif_default_get()
1358 ucontrol->value.iec958.status[0] = (ensoniq->spdif_default >> 0) & 0xff; in snd_ens1373_spdif_default_get()
1359 ucontrol->value.iec958.status[1] = (ensoniq->spdif_default >> 8) & 0xff; in snd_ens1373_spdif_default_get()
1360 ucontrol->value.iec958.status[2] = (ensoniq->spdif_default >> 16) & 0xff; in snd_ens1373_spdif_default_get()
1361 ucontrol->value.iec958.status[3] = (ensoniq->spdif_default >> 24) & 0xff; in snd_ens1373_spdif_default_get()
1362 spin_unlock_irq(&ensoniq->reg_lock); in snd_ens1373_spdif_default_get()
1369 struct ensoniq *ensoniq = snd_kcontrol_chip(kcontrol); in snd_ens1373_spdif_default_put() local
1377 spin_lock_irq(&ensoniq->reg_lock); in snd_ens1373_spdif_default_put()
1378 change = ensoniq->spdif_default != val; in snd_ens1373_spdif_default_put()
1379 ensoniq->spdif_default = val; in snd_ens1373_spdif_default_put()
1380 if (change && ensoniq->playback1_substream == NULL && in snd_ens1373_spdif_default_put()
1381 ensoniq->playback2_substream == NULL) in snd_ens1373_spdif_default_put()
1382 outl(val, ES_REG(ensoniq, CHANNEL_STATUS)); in snd_ens1373_spdif_default_put()
1383 spin_unlock_irq(&ensoniq->reg_lock); in snd_ens1373_spdif_default_put()
1400 struct ensoniq *ensoniq = snd_kcontrol_chip(kcontrol); in snd_ens1373_spdif_stream_get() local
1401 spin_lock_irq(&ensoniq->reg_lock); in snd_ens1373_spdif_stream_get()
1402 ucontrol->value.iec958.status[0] = (ensoniq->spdif_stream >> 0) & 0xff; in snd_ens1373_spdif_stream_get()
1403 ucontrol->value.iec958.status[1] = (ensoniq->spdif_stream >> 8) & 0xff; in snd_ens1373_spdif_stream_get()
1404 ucontrol->value.iec958.status[2] = (ensoniq->spdif_stream >> 16) & 0xff; in snd_ens1373_spdif_stream_get()
1405 ucontrol->value.iec958.status[3] = (ensoniq->spdif_stream >> 24) & 0xff; in snd_ens1373_spdif_stream_get()
1406 spin_unlock_irq(&ensoniq->reg_lock); in snd_ens1373_spdif_stream_get()
1413 struct ensoniq *ensoniq = snd_kcontrol_chip(kcontrol); in snd_ens1373_spdif_stream_put() local
1421 spin_lock_irq(&ensoniq->reg_lock); in snd_ens1373_spdif_stream_put()
1422 change = ensoniq->spdif_stream != val; in snd_ens1373_spdif_stream_put()
1423 ensoniq->spdif_stream = val; in snd_ens1373_spdif_stream_put()
1424 if (change && (ensoniq->playback1_substream != NULL || in snd_ens1373_spdif_stream_put()
1425 ensoniq->playback2_substream != NULL)) in snd_ens1373_spdif_stream_put()
1426 outl(val, ES_REG(ensoniq, CHANNEL_STATUS)); in snd_ens1373_spdif_stream_put()
1427 spin_unlock_irq(&ensoniq->reg_lock); in snd_ens1373_spdif_stream_put()
1440 struct ensoniq *ensoniq = snd_kcontrol_chip(kcontrol); in snd_es1371_spdif_get() local
1442 spin_lock_irq(&ensoniq->reg_lock); in snd_es1371_spdif_get()
1443 ucontrol->value.integer.value[0] = ensoniq->ctrl & ES_1373_SPDIF_THRU ? 1 : 0; in snd_es1371_spdif_get()
1444 spin_unlock_irq(&ensoniq->reg_lock); in snd_es1371_spdif_get()
1451 struct ensoniq *ensoniq = snd_kcontrol_chip(kcontrol); in snd_es1371_spdif_put() local
1457 spin_lock_irq(&ensoniq->reg_lock); in snd_es1371_spdif_put()
1458 change = (ensoniq->ctrl & ES_1373_SPDIF_THRU) != nval1; in snd_es1371_spdif_put()
1459 ensoniq->ctrl &= ~ES_1373_SPDIF_THRU; in snd_es1371_spdif_put()
1460 ensoniq->ctrl |= nval1; in snd_es1371_spdif_put()
1461 ensoniq->cssr &= ~ES_1373_SPDIF_EN; in snd_es1371_spdif_put()
1462 ensoniq->cssr |= nval2; in snd_es1371_spdif_put()
1463 outl(ensoniq->ctrl, ES_REG(ensoniq, CONTROL)); in snd_es1371_spdif_put()
1464 outl(ensoniq->cssr, ES_REG(ensoniq, STATUS)); in snd_es1371_spdif_put()
1465 spin_unlock_irq(&ensoniq->reg_lock); in snd_es1371_spdif_put()
1502 struct ensoniq *ensoniq = snd_kcontrol_chip(kcontrol); in snd_es1373_rear_get() local
1505 spin_lock_irq(&ensoniq->reg_lock); in snd_es1373_rear_get()
1506 if ((ensoniq->cssr & (ES_1373_REAR_BIT27|ES_1373_REAR_BIT26| in snd_es1373_rear_get()
1510 spin_unlock_irq(&ensoniq->reg_lock); in snd_es1373_rear_get()
1517 struct ensoniq *ensoniq = snd_kcontrol_chip(kcontrol); in snd_es1373_rear_put() local
1523 spin_lock_irq(&ensoniq->reg_lock); in snd_es1373_rear_put()
1524 change = (ensoniq->cssr & (ES_1373_REAR_BIT27| in snd_es1373_rear_put()
1526 ensoniq->cssr &= ~(ES_1373_REAR_BIT27|ES_1373_REAR_BIT26|ES_1373_REAR_BIT24); in snd_es1373_rear_put()
1527 ensoniq->cssr |= nval1; in snd_es1373_rear_put()
1528 outl(ensoniq->cssr, ES_REG(ensoniq, STATUS)); in snd_es1373_rear_put()
1529 spin_unlock_irq(&ensoniq->reg_lock); in snd_es1373_rear_put()
1547 struct ensoniq *ensoniq = snd_kcontrol_chip(kcontrol); in snd_es1373_line_get() local
1550 spin_lock_irq(&ensoniq->reg_lock); in snd_es1373_line_get()
1551 if ((ensoniq->ctrl & ES_1371_GPIO_OUTM) >= 4) in snd_es1373_line_get()
1554 spin_unlock_irq(&ensoniq->reg_lock); in snd_es1373_line_get()
1561 struct ensoniq *ensoniq = snd_kcontrol_chip(kcontrol); in snd_es1373_line_put() local
1565 spin_lock_irq(&ensoniq->reg_lock); in snd_es1373_line_put()
1566 ctrl = ensoniq->ctrl; in snd_es1373_line_put()
1568 ensoniq->ctrl |= ES_1371_GPIO_OUT(4); /* switch line-in -> rear out */ in snd_es1373_line_put()
1570 ensoniq->ctrl &= ~ES_1371_GPIO_OUT(4); in snd_es1373_line_put()
1571 changed = (ctrl != ensoniq->ctrl); in snd_es1373_line_put()
1573 outl(ensoniq->ctrl, ES_REG(ensoniq, CONTROL)); in snd_es1373_line_put()
1574 spin_unlock_irq(&ensoniq->reg_lock); in snd_es1373_line_put()
1589 struct ensoniq *ensoniq = ac97->private_data; in snd_ensoniq_mixer_free_ac97() local
1590 ensoniq->u.es1371.ac97 = NULL; in snd_ensoniq_mixer_free_ac97()
1599 static int es1371_quirk_lookup(struct ensoniq *ensoniq, in es1371_quirk_lookup() argument
1603 if (ensoniq->pci->vendor == list->vid && in es1371_quirk_lookup()
1604 ensoniq->pci->device == list->did && in es1371_quirk_lookup()
1605 ensoniq->rev == list->rev) in es1371_quirk_lookup()
1627 static int snd_ensoniq_1371_mixer(struct ensoniq *ensoniq, in snd_ensoniq_1371_mixer() argument
1630 struct snd_card *card = ensoniq->card; in snd_ensoniq_1371_mixer()
1644 ac97.private_data = ensoniq; in snd_ensoniq_1371_mixer()
1646 ac97.pci = ensoniq->pci; in snd_ensoniq_1371_mixer()
1648 if ((err = snd_ac97_mixer(pbus, &ac97, &ensoniq->u.es1371.ac97)) < 0) in snd_ensoniq_1371_mixer()
1651 (!has_spdif && es1371_quirk_lookup(ensoniq, es1371_spdif_present))) { in snd_ensoniq_1371_mixer()
1655 ensoniq->spdif_default = ensoniq->spdif_stream = in snd_ensoniq_1371_mixer()
1657 outl(ensoniq->spdif_default, ES_REG(ensoniq, CHANNEL_STATUS)); in snd_ensoniq_1371_mixer()
1659 if (ensoniq->u.es1371.ac97->ext_id & AC97_EI_SPDIF) in snd_ensoniq_1371_mixer()
1663 kctl = snd_ctl_new1(&snd_es1371_mixer_spdif[i], ensoniq); in snd_ensoniq_1371_mixer()
1672 if (ensoniq->u.es1371.ac97->ext_id & AC97_EI_SDAC) { in snd_ensoniq_1371_mixer()
1674 ensoniq->cssr &= ~(ES_1373_REAR_BIT27|ES_1373_REAR_BIT24); in snd_ensoniq_1371_mixer()
1675 ensoniq->cssr |= ES_1373_REAR_BIT26; in snd_ensoniq_1371_mixer()
1676 err = snd_ctl_add(card, snd_ctl_new1(&snd_ens1373_rear, ensoniq)); in snd_ensoniq_1371_mixer()
1681 snd_pci_quirk_lookup(ensoniq->pci, ens1373_line_quirk)) { in snd_ensoniq_1371_mixer()
1683 ensoniq)); in snd_ensoniq_1371_mixer()
1705 struct ensoniq *ensoniq = snd_kcontrol_chip(kcontrol); in snd_ensoniq_control_get() local
1708 spin_lock_irq(&ensoniq->reg_lock); in snd_ensoniq_control_get()
1709 ucontrol->value.integer.value[0] = ensoniq->ctrl & mask ? 1 : 0; in snd_ensoniq_control_get()
1710 spin_unlock_irq(&ensoniq->reg_lock); in snd_ensoniq_control_get()
1717 struct ensoniq *ensoniq = snd_kcontrol_chip(kcontrol); in snd_ensoniq_control_put() local
1723 spin_lock_irq(&ensoniq->reg_lock); in snd_ensoniq_control_put()
1724 change = (ensoniq->ctrl & mask) != nval; in snd_ensoniq_control_put()
1725 ensoniq->ctrl &= ~mask; in snd_ensoniq_control_put()
1726 ensoniq->ctrl |= nval; in snd_ensoniq_control_put()
1727 outl(ensoniq->ctrl, ES_REG(ensoniq, CONTROL)); in snd_ensoniq_control_put()
1728 spin_unlock_irq(&ensoniq->reg_lock); in snd_ensoniq_control_put()
1745 struct ensoniq *ensoniq = ak4531->private_data; in snd_ensoniq_mixer_free_ak4531() local
1746 ensoniq->u.es1370.ak4531 = NULL; in snd_ensoniq_mixer_free_ak4531()
1749 static int snd_ensoniq_1370_mixer(struct ensoniq *ensoniq) in snd_ensoniq_1370_mixer() argument
1751 struct snd_card *card = ensoniq->card; in snd_ensoniq_1370_mixer()
1757 outw(ES_1370_CODEC_WRITE(AK4531_RESET, 0x02), ES_REG(ensoniq, 1370_CODEC)); in snd_ensoniq_1370_mixer()
1758 inw(ES_REG(ensoniq, 1370_CODEC)); in snd_ensoniq_1370_mixer()
1760 outw(ES_1370_CODEC_WRITE(AK4531_RESET, 0x03), ES_REG(ensoniq, 1370_CODEC)); in snd_ensoniq_1370_mixer()
1761 inw(ES_REG(ensoniq, 1370_CODEC)); in snd_ensoniq_1370_mixer()
1766 ak4531.private_data = ensoniq; in snd_ensoniq_1370_mixer()
1768 if ((err = snd_ak4531_mixer(card, &ak4531, &ensoniq->u.es1370.ak4531)) < 0) in snd_ensoniq_1370_mixer()
1771 err = snd_ctl_add(card, snd_ctl_new1(&snd_es1370_controls[idx], ensoniq)); in snd_ensoniq_1370_mixer()
1783 static int snd_ensoniq_get_joystick_port(struct ensoniq *ensoniq, int dev) in snd_ensoniq_get_joystick_port() argument
1795 dev_err(ensoniq->card->dev, in snd_ensoniq_get_joystick_port()
1801 static int snd_ensoniq_get_joystick_port(struct ensoniq *ensoniq, int dev) in snd_ensoniq_get_joystick_port() argument
1807 static int snd_ensoniq_create_gameport(struct ensoniq *ensoniq, int dev) in snd_ensoniq_create_gameport() argument
1812 io_port = snd_ensoniq_get_joystick_port(ensoniq, dev); in snd_ensoniq_create_gameport()
1823 dev_warn(ensoniq->card->dev, in snd_ensoniq_create_gameport()
1831 dev_warn(ensoniq->card->dev, in snd_ensoniq_create_gameport()
1839 ensoniq->gameport = gp = gameport_allocate_port(); in snd_ensoniq_create_gameport()
1841 dev_err(ensoniq->card->dev, in snd_ensoniq_create_gameport()
1848 gameport_set_phys(gp, "pci%s/gameport0", pci_name(ensoniq->pci)); in snd_ensoniq_create_gameport()
1849 gameport_set_dev_parent(gp, &ensoniq->pci->dev); in snd_ensoniq_create_gameport()
1852 ensoniq->ctrl |= ES_JYSTK_EN; in snd_ensoniq_create_gameport()
1854 ensoniq->ctrl &= ~ES_1371_JOY_ASELM; in snd_ensoniq_create_gameport()
1855 ensoniq->ctrl |= ES_1371_JOY_ASEL((io_port - 0x200) / 8); in snd_ensoniq_create_gameport()
1857 outl(ensoniq->ctrl, ES_REG(ensoniq, CONTROL)); in snd_ensoniq_create_gameport()
1859 gameport_register_port(ensoniq->gameport); in snd_ensoniq_create_gameport()
1864 static void snd_ensoniq_free_gameport(struct ensoniq *ensoniq) in snd_ensoniq_free_gameport() argument
1866 if (ensoniq->gameport) { in snd_ensoniq_free_gameport()
1867 int port = ensoniq->gameport->io; in snd_ensoniq_free_gameport()
1869 gameport_unregister_port(ensoniq->gameport); in snd_ensoniq_free_gameport()
1870 ensoniq->gameport = NULL; in snd_ensoniq_free_gameport()
1871 ensoniq->ctrl &= ~ES_JYSTK_EN; in snd_ensoniq_free_gameport()
1872 outl(ensoniq->ctrl, ES_REG(ensoniq, CONTROL)); in snd_ensoniq_free_gameport()
1877 static inline int snd_ensoniq_create_gameport(struct ensoniq *ensoniq, long port) { return -ENOSYS;… in snd_ensoniq_create_gameport() argument
1878 static inline void snd_ensoniq_free_gameport(struct ensoniq *ensoniq) { } in snd_ensoniq_free_gameport() argument
1888 struct ensoniq *ensoniq = entry->private_data; in snd_ensoniq_proc_read() local
1892 ensoniq->ctrl & ES_JYSTK_EN ? "on" : "off"); in snd_ensoniq_proc_read()
1895 ensoniq->ctrl & ES_1370_XCTL1 ? "on" : "off"); in snd_ensoniq_proc_read()
1897 ensoniq->ctrl & ES_1370_XCTL0 ? "on" : "off"); in snd_ensoniq_proc_read()
1900 (ES_1371_JOY_ASELI(ensoniq->ctrl) * 8) + 0x200); in snd_ensoniq_proc_read()
1904 static void snd_ensoniq_proc_init(struct ensoniq *ensoniq) in snd_ensoniq_proc_init() argument
1908 if (! snd_card_proc_new(ensoniq->card, "audiopci", &entry)) in snd_ensoniq_proc_init()
1909 snd_info_set_text_ops(entry, ensoniq, snd_ensoniq_proc_read); in snd_ensoniq_proc_init()
1916 static int snd_ensoniq_free(struct ensoniq *ensoniq) in snd_ensoniq_free() argument
1918 snd_ensoniq_free_gameport(ensoniq); in snd_ensoniq_free()
1919 if (ensoniq->irq < 0) in snd_ensoniq_free()
1922 outl(ES_1370_SERR_DISABLE, ES_REG(ensoniq, CONTROL)); /* switch everything off */ in snd_ensoniq_free()
1923 outl(0, ES_REG(ensoniq, SERIAL)); /* clear serial interface */ in snd_ensoniq_free()
1925 outl(0, ES_REG(ensoniq, CONTROL)); /* switch everything off */ in snd_ensoniq_free()
1926 outl(0, ES_REG(ensoniq, SERIAL)); /* clear serial interface */ in snd_ensoniq_free()
1928 if (ensoniq->irq >= 0) in snd_ensoniq_free()
1929 synchronize_irq(ensoniq->irq); in snd_ensoniq_free()
1930 pci_set_power_state(ensoniq->pci, PCI_D3hot); in snd_ensoniq_free()
1933 if (ensoniq->dma_bug.area) in snd_ensoniq_free()
1934 snd_dma_free_pages(&ensoniq->dma_bug); in snd_ensoniq_free()
1936 if (ensoniq->irq >= 0) in snd_ensoniq_free()
1937 free_irq(ensoniq->irq, ensoniq); in snd_ensoniq_free()
1938 pci_release_regions(ensoniq->pci); in snd_ensoniq_free()
1939 pci_disable_device(ensoniq->pci); in snd_ensoniq_free()
1940 kfree(ensoniq); in snd_ensoniq_free()
1946 struct ensoniq *ensoniq = device->device_data; in snd_ensoniq_dev_free() local
1947 return snd_ensoniq_free(ensoniq); in snd_ensoniq_dev_free()
1969 static void snd_ensoniq_chip_init(struct ensoniq *ensoniq) in snd_ensoniq_chip_init() argument
1978 outl(ensoniq->ctrl, ES_REG(ensoniq, CONTROL)); in snd_ensoniq_chip_init()
1979 outl(ensoniq->sctrl, ES_REG(ensoniq, SERIAL)); in snd_ensoniq_chip_init()
1980 outl(ES_MEM_PAGEO(ES_PAGE_ADC), ES_REG(ensoniq, MEM_PAGE)); in snd_ensoniq_chip_init()
1981 outl(ensoniq->dma_bug.addr, ES_REG(ensoniq, PHANTOM_FRAME)); in snd_ensoniq_chip_init()
1982 outl(0, ES_REG(ensoniq, PHANTOM_COUNT)); in snd_ensoniq_chip_init()
1984 outl(ensoniq->ctrl, ES_REG(ensoniq, CONTROL)); in snd_ensoniq_chip_init()
1985 outl(ensoniq->sctrl, ES_REG(ensoniq, SERIAL)); in snd_ensoniq_chip_init()
1986 outl(0, ES_REG(ensoniq, 1371_LEGACY)); in snd_ensoniq_chip_init()
1987 if (es1371_quirk_lookup(ensoniq, es1371_ac97_reset_hack)) { in snd_ensoniq_chip_init()
1988 outl(ensoniq->cssr, ES_REG(ensoniq, STATUS)); in snd_ensoniq_chip_init()
1994 outl(ensoniq->ctrl | ES_1371_SYNC_RES, ES_REG(ensoniq, CONTROL)); in snd_ensoniq_chip_init()
1995 inl(ES_REG(ensoniq, CONTROL)); in snd_ensoniq_chip_init()
1997 outl(ensoniq->ctrl, ES_REG(ensoniq, CONTROL)); in snd_ensoniq_chip_init()
1999 snd_es1371_wait_src_ready(ensoniq); in snd_ensoniq_chip_init()
2000 outl(ES_1371_SRC_DISABLE, ES_REG(ensoniq, 1371_SMPRATE)); in snd_ensoniq_chip_init()
2002 snd_es1371_src_write(ensoniq, idx, 0); in snd_ensoniq_chip_init()
2003 snd_es1371_src_write(ensoniq, ES_SMPREG_DAC1 + ES_SMPREG_TRUNC_N, 16 << 4); in snd_ensoniq_chip_init()
2004 snd_es1371_src_write(ensoniq, ES_SMPREG_DAC1 + ES_SMPREG_INT_REGS, 16 << 10); in snd_ensoniq_chip_init()
2005 snd_es1371_src_write(ensoniq, ES_SMPREG_DAC2 + ES_SMPREG_TRUNC_N, 16 << 4); in snd_ensoniq_chip_init()
2006 snd_es1371_src_write(ensoniq, ES_SMPREG_DAC2 + ES_SMPREG_INT_REGS, 16 << 10); in snd_ensoniq_chip_init()
2007 snd_es1371_src_write(ensoniq, ES_SMPREG_VOL_ADC, 1 << 12); in snd_ensoniq_chip_init()
2008 snd_es1371_src_write(ensoniq, ES_SMPREG_VOL_ADC + 1, 1 << 12); in snd_ensoniq_chip_init()
2009 snd_es1371_src_write(ensoniq, ES_SMPREG_VOL_DAC1, 1 << 12); in snd_ensoniq_chip_init()
2010 snd_es1371_src_write(ensoniq, ES_SMPREG_VOL_DAC1 + 1, 1 << 12); in snd_ensoniq_chip_init()
2011 snd_es1371_src_write(ensoniq, ES_SMPREG_VOL_DAC2, 1 << 12); in snd_ensoniq_chip_init()
2012 snd_es1371_src_write(ensoniq, ES_SMPREG_VOL_DAC2 + 1, 1 << 12); in snd_ensoniq_chip_init()
2013 snd_es1371_adc_rate(ensoniq, 22050); in snd_ensoniq_chip_init()
2014 snd_es1371_dac1_rate(ensoniq, 22050); in snd_ensoniq_chip_init()
2015 snd_es1371_dac2_rate(ensoniq, 22050); in snd_ensoniq_chip_init()
2022 snd_es1371_wait_src_ready(ensoniq); in snd_ensoniq_chip_init()
2023 outl(0, ES_REG(ensoniq, 1371_SMPRATE)); in snd_ensoniq_chip_init()
2025 outl(ES_1371_CODEC_WRITE(0, 0), ES_REG(ensoniq, 1371_CODEC)); in snd_ensoniq_chip_init()
2027 outb(ensoniq->uartc = 0x00, ES_REG(ensoniq, UART_CONTROL)); in snd_ensoniq_chip_init()
2028 outb(0x00, ES_REG(ensoniq, UART_RES)); in snd_ensoniq_chip_init()
2029 outl(ensoniq->cssr, ES_REG(ensoniq, STATUS)); in snd_ensoniq_chip_init()
2030 synchronize_irq(ensoniq->irq); in snd_ensoniq_chip_init()
2037 struct ensoniq *ensoniq = card->private_data; in snd_ensoniq_suspend() local
2041 snd_pcm_suspend_all(ensoniq->pcm1); in snd_ensoniq_suspend()
2042 snd_pcm_suspend_all(ensoniq->pcm2); in snd_ensoniq_suspend()
2045 snd_ac97_suspend(ensoniq->u.es1371.ac97); in snd_ensoniq_suspend()
2048 outw(ES_1370_CODEC_WRITE(AK4531_RESET, 0x02), ES_REG(ensoniq, 1370_CODEC)); in snd_ensoniq_suspend()
2049 inw(ES_REG(ensoniq, 1370_CODEC)); in snd_ensoniq_suspend()
2051 outw(ES_1370_CODEC_WRITE(AK4531_RESET, 0x03), ES_REG(ensoniq, 1370_CODEC)); in snd_ensoniq_suspend()
2052 inw(ES_REG(ensoniq, 1370_CODEC)); in snd_ensoniq_suspend()
2054 snd_ak4531_suspend(ensoniq->u.es1370.ak4531); in snd_ensoniq_suspend()
2062 struct ensoniq *ensoniq = card->private_data; in snd_ensoniq_resume() local
2064 snd_ensoniq_chip_init(ensoniq); in snd_ensoniq_resume()
2067 snd_ac97_resume(ensoniq->u.es1371.ac97); in snd_ensoniq_resume()
2069 snd_ak4531_resume(ensoniq->u.es1370.ak4531); in snd_ensoniq_resume()
2083 struct ensoniq **rensoniq) in snd_ensoniq_create()
2085 struct ensoniq *ensoniq; in snd_ensoniq_create() local
2094 ensoniq = kzalloc(sizeof(*ensoniq), GFP_KERNEL); in snd_ensoniq_create()
2095 if (ensoniq == NULL) { in snd_ensoniq_create()
2099 spin_lock_init(&ensoniq->reg_lock); in snd_ensoniq_create()
2100 mutex_init(&ensoniq->src_mutex); in snd_ensoniq_create()
2101 ensoniq->card = card; in snd_ensoniq_create()
2102 ensoniq->pci = pci; in snd_ensoniq_create()
2103 ensoniq->irq = -1; in snd_ensoniq_create()
2105 kfree(ensoniq); in snd_ensoniq_create()
2109 ensoniq->port = pci_resource_start(pci, 0); in snd_ensoniq_create()
2111 KBUILD_MODNAME, ensoniq)) { in snd_ensoniq_create()
2113 snd_ensoniq_free(ensoniq); in snd_ensoniq_create()
2116 ensoniq->irq = pci->irq; in snd_ensoniq_create()
2119 16, &ensoniq->dma_bug) < 0) { in snd_ensoniq_create()
2121 snd_ensoniq_free(ensoniq); in snd_ensoniq_create()
2126 ensoniq->rev = pci->revision; in snd_ensoniq_create()
2129 ensoniq->ctrl = ES_1370_CDC_EN | ES_1370_SERR_DISABLE | in snd_ensoniq_create()
2132 ensoniq->ctrl = ES_1370_CDC_EN | ES_1370_PCLKDIVO(ES_1370_SRTODIV(8000)); in snd_ensoniq_create()
2134 ensoniq->sctrl = 0; in snd_ensoniq_create()
2136 ensoniq->ctrl = 0; in snd_ensoniq_create()
2137 ensoniq->sctrl = 0; in snd_ensoniq_create()
2138 ensoniq->cssr = 0; in snd_ensoniq_create()
2140 ensoniq->ctrl |= ES_1371_GPIO_OUT(1); /* turn amplifier on */ in snd_ensoniq_create()
2142 if (es1371_quirk_lookup(ensoniq, es1371_ac97_reset_hack)) in snd_ensoniq_create()
2143 ensoniq->cssr |= ES_1371_ST_AC97_RST; in snd_ensoniq_create()
2146 snd_ensoniq_chip_init(ensoniq); in snd_ensoniq_create()
2148 if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, ensoniq, &ops)) < 0) { in snd_ensoniq_create()
2149 snd_ensoniq_free(ensoniq); in snd_ensoniq_create()
2153 snd_ensoniq_proc_init(ensoniq); in snd_ensoniq_create()
2155 *rensoniq = ensoniq; in snd_ensoniq_create()
2163 static void snd_ensoniq_midi_interrupt(struct ensoniq * ensoniq) in snd_ensoniq_midi_interrupt() argument
2165 struct snd_rawmidi *rmidi = ensoniq->rmidi; in snd_ensoniq_midi_interrupt()
2171 spin_lock(&ensoniq->reg_lock); in snd_ensoniq_midi_interrupt()
2172 mask = ensoniq->uartm & ES_MODE_INPUT ? ES_RXRDY : 0; in snd_ensoniq_midi_interrupt()
2174 status = inb(ES_REG(ensoniq, UART_STATUS)); in snd_ensoniq_midi_interrupt()
2177 byte = inb(ES_REG(ensoniq, UART_DATA)); in snd_ensoniq_midi_interrupt()
2178 snd_rawmidi_receive(ensoniq->midi_input, &byte, 1); in snd_ensoniq_midi_interrupt()
2180 spin_unlock(&ensoniq->reg_lock); in snd_ensoniq_midi_interrupt()
2183 spin_lock(&ensoniq->reg_lock); in snd_ensoniq_midi_interrupt()
2184 mask = ensoniq->uartm & ES_MODE_OUTPUT ? ES_TXRDY : 0; in snd_ensoniq_midi_interrupt()
2186 status = inb(ES_REG(ensoniq, UART_STATUS)); in snd_ensoniq_midi_interrupt()
2189 if (snd_rawmidi_transmit(ensoniq->midi_output, &byte, 1) != 1) { in snd_ensoniq_midi_interrupt()
2190 ensoniq->uartc &= ~ES_TXINTENM; in snd_ensoniq_midi_interrupt()
2191 outb(ensoniq->uartc, ES_REG(ensoniq, UART_CONTROL)); in snd_ensoniq_midi_interrupt()
2194 outb(byte, ES_REG(ensoniq, UART_DATA)); in snd_ensoniq_midi_interrupt()
2197 spin_unlock(&ensoniq->reg_lock); in snd_ensoniq_midi_interrupt()
2202 struct ensoniq *ensoniq = substream->rmidi->private_data; in snd_ensoniq_midi_input_open() local
2204 spin_lock_irq(&ensoniq->reg_lock); in snd_ensoniq_midi_input_open()
2205 ensoniq->uartm |= ES_MODE_INPUT; in snd_ensoniq_midi_input_open()
2206 ensoniq->midi_input = substream; in snd_ensoniq_midi_input_open()
2207 if (!(ensoniq->uartm & ES_MODE_OUTPUT)) { in snd_ensoniq_midi_input_open()
2208 outb(ES_CNTRL(3), ES_REG(ensoniq, UART_CONTROL)); in snd_ensoniq_midi_input_open()
2209 outb(ensoniq->uartc = 0, ES_REG(ensoniq, UART_CONTROL)); in snd_ensoniq_midi_input_open()
2210 outl(ensoniq->ctrl |= ES_UART_EN, ES_REG(ensoniq, CONTROL)); in snd_ensoniq_midi_input_open()
2212 spin_unlock_irq(&ensoniq->reg_lock); in snd_ensoniq_midi_input_open()
2218 struct ensoniq *ensoniq = substream->rmidi->private_data; in snd_ensoniq_midi_input_close() local
2220 spin_lock_irq(&ensoniq->reg_lock); in snd_ensoniq_midi_input_close()
2221 if (!(ensoniq->uartm & ES_MODE_OUTPUT)) { in snd_ensoniq_midi_input_close()
2222 outb(ensoniq->uartc = 0, ES_REG(ensoniq, UART_CONTROL)); in snd_ensoniq_midi_input_close()
2223 outl(ensoniq->ctrl &= ~ES_UART_EN, ES_REG(ensoniq, CONTROL)); in snd_ensoniq_midi_input_close()
2225 outb(ensoniq->uartc &= ~ES_RXINTEN, ES_REG(ensoniq, UART_CONTROL)); in snd_ensoniq_midi_input_close()
2227 ensoniq->midi_input = NULL; in snd_ensoniq_midi_input_close()
2228 ensoniq->uartm &= ~ES_MODE_INPUT; in snd_ensoniq_midi_input_close()
2229 spin_unlock_irq(&ensoniq->reg_lock); in snd_ensoniq_midi_input_close()
2235 struct ensoniq *ensoniq = substream->rmidi->private_data; in snd_ensoniq_midi_output_open() local
2237 spin_lock_irq(&ensoniq->reg_lock); in snd_ensoniq_midi_output_open()
2238 ensoniq->uartm |= ES_MODE_OUTPUT; in snd_ensoniq_midi_output_open()
2239 ensoniq->midi_output = substream; in snd_ensoniq_midi_output_open()
2240 if (!(ensoniq->uartm & ES_MODE_INPUT)) { in snd_ensoniq_midi_output_open()
2241 outb(ES_CNTRL(3), ES_REG(ensoniq, UART_CONTROL)); in snd_ensoniq_midi_output_open()
2242 outb(ensoniq->uartc = 0, ES_REG(ensoniq, UART_CONTROL)); in snd_ensoniq_midi_output_open()
2243 outl(ensoniq->ctrl |= ES_UART_EN, ES_REG(ensoniq, CONTROL)); in snd_ensoniq_midi_output_open()
2245 spin_unlock_irq(&ensoniq->reg_lock); in snd_ensoniq_midi_output_open()
2251 struct ensoniq *ensoniq = substream->rmidi->private_data; in snd_ensoniq_midi_output_close() local
2253 spin_lock_irq(&ensoniq->reg_lock); in snd_ensoniq_midi_output_close()
2254 if (!(ensoniq->uartm & ES_MODE_INPUT)) { in snd_ensoniq_midi_output_close()
2255 outb(ensoniq->uartc = 0, ES_REG(ensoniq, UART_CONTROL)); in snd_ensoniq_midi_output_close()
2256 outl(ensoniq->ctrl &= ~ES_UART_EN, ES_REG(ensoniq, CONTROL)); in snd_ensoniq_midi_output_close()
2258 outb(ensoniq->uartc &= ~ES_TXINTENM, ES_REG(ensoniq, UART_CONTROL)); in snd_ensoniq_midi_output_close()
2260 ensoniq->midi_output = NULL; in snd_ensoniq_midi_output_close()
2261 ensoniq->uartm &= ~ES_MODE_OUTPUT; in snd_ensoniq_midi_output_close()
2262 spin_unlock_irq(&ensoniq->reg_lock); in snd_ensoniq_midi_output_close()
2269 struct ensoniq *ensoniq = substream->rmidi->private_data; in snd_ensoniq_midi_input_trigger() local
2272 spin_lock_irqsave(&ensoniq->reg_lock, flags); in snd_ensoniq_midi_input_trigger()
2274 if ((ensoniq->uartc & ES_RXINTEN) == 0) { in snd_ensoniq_midi_input_trigger()
2277 inb(ES_REG(ensoniq, UART_DATA)); in snd_ensoniq_midi_input_trigger()
2278 ensoniq->uartc |= ES_RXINTEN; in snd_ensoniq_midi_input_trigger()
2279 outb(ensoniq->uartc, ES_REG(ensoniq, UART_CONTROL)); in snd_ensoniq_midi_input_trigger()
2282 if (ensoniq->uartc & ES_RXINTEN) { in snd_ensoniq_midi_input_trigger()
2283 ensoniq->uartc &= ~ES_RXINTEN; in snd_ensoniq_midi_input_trigger()
2284 outb(ensoniq->uartc, ES_REG(ensoniq, UART_CONTROL)); in snd_ensoniq_midi_input_trigger()
2287 spin_unlock_irqrestore(&ensoniq->reg_lock, flags); in snd_ensoniq_midi_input_trigger()
2293 struct ensoniq *ensoniq = substream->rmidi->private_data; in snd_ensoniq_midi_output_trigger() local
2296 spin_lock_irqsave(&ensoniq->reg_lock, flags); in snd_ensoniq_midi_output_trigger()
2298 if (ES_TXINTENI(ensoniq->uartc) == 0) { in snd_ensoniq_midi_output_trigger()
2299 ensoniq->uartc |= ES_TXINTENO(1); in snd_ensoniq_midi_output_trigger()
2301 while (ES_TXINTENI(ensoniq->uartc) == 1 && in snd_ensoniq_midi_output_trigger()
2302 (inb(ES_REG(ensoniq, UART_STATUS)) & ES_TXRDY)) { in snd_ensoniq_midi_output_trigger()
2304 ensoniq->uartc &= ~ES_TXINTENM; in snd_ensoniq_midi_output_trigger()
2306 outb(byte, ES_REG(ensoniq, UART_DATA)); in snd_ensoniq_midi_output_trigger()
2309 outb(ensoniq->uartc, ES_REG(ensoniq, UART_CONTROL)); in snd_ensoniq_midi_output_trigger()
2312 if (ES_TXINTENI(ensoniq->uartc) == 1) { in snd_ensoniq_midi_output_trigger()
2313 ensoniq->uartc &= ~ES_TXINTENM; in snd_ensoniq_midi_output_trigger()
2314 outb(ensoniq->uartc, ES_REG(ensoniq, UART_CONTROL)); in snd_ensoniq_midi_output_trigger()
2317 spin_unlock_irqrestore(&ensoniq->reg_lock, flags); in snd_ensoniq_midi_output_trigger()
2334 static int snd_ensoniq_midi(struct ensoniq *ensoniq, int device) in snd_ensoniq_midi() argument
2339 if ((err = snd_rawmidi_new(ensoniq->card, "ES1370/1", device, 1, 1, &rmidi)) < 0) in snd_ensoniq_midi()
2346 rmidi->private_data = ensoniq; in snd_ensoniq_midi()
2347 ensoniq->rmidi = rmidi; in snd_ensoniq_midi()
2357 struct ensoniq *ensoniq = dev_id; in snd_audiopci_interrupt() local
2360 if (ensoniq == NULL) in snd_audiopci_interrupt()
2363 status = inl(ES_REG(ensoniq, STATUS)); in snd_audiopci_interrupt()
2367 spin_lock(&ensoniq->reg_lock); in snd_audiopci_interrupt()
2368 sctrl = ensoniq->sctrl; in snd_audiopci_interrupt()
2375 outl(sctrl, ES_REG(ensoniq, SERIAL)); in snd_audiopci_interrupt()
2376 outl(ensoniq->sctrl, ES_REG(ensoniq, SERIAL)); in snd_audiopci_interrupt()
2377 spin_unlock(&ensoniq->reg_lock); in snd_audiopci_interrupt()
2380 snd_ensoniq_midi_interrupt(ensoniq); in snd_audiopci_interrupt()
2381 if ((status & ES_DAC2) && ensoniq->playback2_substream) in snd_audiopci_interrupt()
2382 snd_pcm_period_elapsed(ensoniq->playback2_substream); in snd_audiopci_interrupt()
2383 if ((status & ES_ADC) && ensoniq->capture_substream) in snd_audiopci_interrupt()
2384 snd_pcm_period_elapsed(ensoniq->capture_substream); in snd_audiopci_interrupt()
2385 if ((status & ES_DAC1) && ensoniq->playback1_substream) in snd_audiopci_interrupt()
2386 snd_pcm_period_elapsed(ensoniq->playback1_substream); in snd_audiopci_interrupt()
2395 struct ensoniq *ensoniq; in snd_audiopci_probe() local
2410 if ((err = snd_ensoniq_create(card, pci, &ensoniq)) < 0) { in snd_audiopci_probe()
2414 card->private_data = ensoniq; in snd_audiopci_probe()
2418 if ((err = snd_ensoniq_1370_mixer(ensoniq)) < 0) { in snd_audiopci_probe()
2424 if ((err = snd_ensoniq_1371_mixer(ensoniq, spdif[dev], lineio[dev])) < 0) { in snd_audiopci_probe()
2429 if ((err = snd_ensoniq_pcm(ensoniq, 0)) < 0) { in snd_audiopci_probe()
2433 if ((err = snd_ensoniq_pcm2(ensoniq, 1)) < 0) { in snd_audiopci_probe()
2437 if ((err = snd_ensoniq_midi(ensoniq, 0)) < 0) { in snd_audiopci_probe()
2442 snd_ensoniq_create_gameport(ensoniq, dev); in snd_audiopci_probe()
2450 ensoniq->port, in snd_audiopci_probe()
2451 ensoniq->irq); in snd_audiopci_probe()