Lines Matching full:chip
32 static void snd_ymfpci_irq_wait(struct snd_ymfpci *chip);
34 static inline void snd_ymfpci_writeb(struct snd_ymfpci *chip, u32 offset, u8 val) in snd_ymfpci_writeb() argument
36 writeb(val, chip->reg_area_virt + offset); in snd_ymfpci_writeb()
39 static inline u16 snd_ymfpci_readw(struct snd_ymfpci *chip, u32 offset) in snd_ymfpci_readw() argument
41 return readw(chip->reg_area_virt + offset); in snd_ymfpci_readw()
44 static inline void snd_ymfpci_writew(struct snd_ymfpci *chip, u32 offset, u16 val) in snd_ymfpci_writew() argument
46 writew(val, chip->reg_area_virt + offset); in snd_ymfpci_writew()
49 static inline u32 snd_ymfpci_readl(struct snd_ymfpci *chip, u32 offset) in snd_ymfpci_readl() argument
51 return readl(chip->reg_area_virt + offset); in snd_ymfpci_readl()
54 static inline void snd_ymfpci_writel(struct snd_ymfpci *chip, u32 offset, u32 val) in snd_ymfpci_writel() argument
56 writel(val, chip->reg_area_virt + offset); in snd_ymfpci_writel()
59 static int snd_ymfpci_codec_ready(struct snd_ymfpci *chip, int secondary) in snd_ymfpci_codec_ready() argument
66 if ((snd_ymfpci_readw(chip, reg) & 0x8000) == 0) in snd_ymfpci_codec_ready()
70 dev_err(chip->card->dev, in snd_ymfpci_codec_ready()
72 secondary, snd_ymfpci_readw(chip, reg)); in snd_ymfpci_codec_ready()
78 struct snd_ymfpci *chip = ac97->private_data; in snd_ymfpci_codec_write() local
81 snd_ymfpci_codec_ready(chip, 0); in snd_ymfpci_codec_write()
83 snd_ymfpci_writel(chip, YDSXGR_AC97CMDDATA, cmd); in snd_ymfpci_codec_write()
88 struct snd_ymfpci *chip = ac97->private_data; in snd_ymfpci_codec_read() local
90 if (snd_ymfpci_codec_ready(chip, 0)) in snd_ymfpci_codec_read()
92 snd_ymfpci_writew(chip, YDSXGR_AC97CMDADR, YDSXG_AC97READCMD | reg); in snd_ymfpci_codec_read()
93 if (snd_ymfpci_codec_ready(chip, 0)) in snd_ymfpci_codec_read()
95 if (chip->device_id == PCI_DEVICE_ID_YAMAHA_744 && chip->rev < 2) { in snd_ymfpci_codec_read()
98 snd_ymfpci_readw(chip, YDSXGR_PRISTATUSDATA); in snd_ymfpci_codec_read()
100 return snd_ymfpci_readw(chip, YDSXGR_PRISTATUSDATA); in snd_ymfpci_codec_read()
160 static void snd_ymfpci_hw_start(struct snd_ymfpci *chip) in snd_ymfpci_hw_start() argument
164 spin_lock_irqsave(&chip->reg_lock, flags); in snd_ymfpci_hw_start()
165 if (chip->start_count++ > 0) in snd_ymfpci_hw_start()
167 snd_ymfpci_writel(chip, YDSXGR_MODE, in snd_ymfpci_hw_start()
168 snd_ymfpci_readl(chip, YDSXGR_MODE) | 3); in snd_ymfpci_hw_start()
169 chip->active_bank = snd_ymfpci_readl(chip, YDSXGR_CTRLSELECT) & 1; in snd_ymfpci_hw_start()
171 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_ymfpci_hw_start()
174 static void snd_ymfpci_hw_stop(struct snd_ymfpci *chip) in snd_ymfpci_hw_stop() argument
179 spin_lock_irqsave(&chip->reg_lock, flags); in snd_ymfpci_hw_stop()
180 if (--chip->start_count > 0) in snd_ymfpci_hw_stop()
182 snd_ymfpci_writel(chip, YDSXGR_MODE, in snd_ymfpci_hw_stop()
183 snd_ymfpci_readl(chip, YDSXGR_MODE) & ~3); in snd_ymfpci_hw_stop()
185 if ((snd_ymfpci_readl(chip, YDSXGR_STATUS) & 2) == 0) in snd_ymfpci_hw_stop()
188 if (atomic_read(&chip->interrupt_sleep_count)) { in snd_ymfpci_hw_stop()
189 atomic_set(&chip->interrupt_sleep_count, 0); in snd_ymfpci_hw_stop()
190 wake_up(&chip->interrupt_sleep); in snd_ymfpci_hw_stop()
193 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_ymfpci_hw_stop()
200 static int voice_alloc(struct snd_ymfpci *chip, in voice_alloc() argument
209 voice = &chip->voices[idx]; in voice_alloc()
210 voice2 = pair ? &chip->voices[idx+1] : NULL; in voice_alloc()
229 snd_ymfpci_hw_start(chip); in voice_alloc()
231 snd_ymfpci_hw_start(chip); in voice_alloc()
238 static int snd_ymfpci_voice_alloc(struct snd_ymfpci *chip, in snd_ymfpci_voice_alloc() argument
250 spin_lock_irqsave(&chip->voice_lock, flags); in snd_ymfpci_voice_alloc()
252 result = voice_alloc(chip, type, pair, rvoice); in snd_ymfpci_voice_alloc()
258 spin_unlock_irqrestore(&chip->voice_lock, flags); in snd_ymfpci_voice_alloc()
262 static int snd_ymfpci_voice_free(struct snd_ymfpci *chip, struct snd_ymfpci_voice *pvoice) in snd_ymfpci_voice_free() argument
268 snd_ymfpci_hw_stop(chip); in snd_ymfpci_voice_free()
269 spin_lock_irqsave(&chip->voice_lock, flags); in snd_ymfpci_voice_free()
270 if (pvoice->number == chip->src441_used) { in snd_ymfpci_voice_free()
271 chip->src441_used = -1; in snd_ymfpci_voice_free()
277 spin_unlock_irqrestore(&chip->voice_lock, flags); in snd_ymfpci_voice_free()
285 static void snd_ymfpci_pcm_interrupt(struct snd_ymfpci *chip, struct snd_ymfpci_voice *voice) in snd_ymfpci_pcm_interrupt() argument
295 spin_lock(&chip->reg_lock); in snd_ymfpci_pcm_interrupt()
297 pos = le32_to_cpu(voice->bank[chip->active_bank].start); in snd_ymfpci_pcm_interrupt()
306 dev_dbg(chip->card->dev, in snd_ymfpci_pcm_interrupt()
308 chip->active_bank, in snd_ymfpci_pcm_interrupt()
309 voice->bank[chip->active_bank].start); in snd_ymfpci_pcm_interrupt()
312 spin_unlock(&chip->reg_lock); in snd_ymfpci_pcm_interrupt()
314 spin_lock(&chip->reg_lock); in snd_ymfpci_pcm_interrupt()
319 unsigned int next_bank = 1 - chip->active_bank; in snd_ymfpci_pcm_interrupt()
324 volume = cpu_to_le32(chip->pcm_mixer[subs].left << 15); in snd_ymfpci_pcm_interrupt()
330 volume = cpu_to_le32(chip->pcm_mixer[subs].right << 15); in snd_ymfpci_pcm_interrupt()
337 spin_unlock(&chip->reg_lock); in snd_ymfpci_pcm_interrupt()
344 struct snd_ymfpci *chip = ypcm->chip; in snd_ymfpci_pcm_capture_interrupt() local
347 spin_lock(&chip->reg_lock); in snd_ymfpci_pcm_capture_interrupt()
349 …pos = le32_to_cpu(chip->bank_capture[ypcm->capture_bank_number][chip->active_bank]->start) >> ypcm… in snd_ymfpci_pcm_capture_interrupt()
359 dev_dbg(chip->card->dev, in snd_ymfpci_pcm_capture_interrupt()
361 chip->active_bank, in snd_ymfpci_pcm_capture_interrupt()
362 voice->bank[chip->active_bank].start); in snd_ymfpci_pcm_capture_interrupt()
364 spin_unlock(&chip->reg_lock); in snd_ymfpci_pcm_capture_interrupt()
366 spin_lock(&chip->reg_lock); in snd_ymfpci_pcm_capture_interrupt()
369 spin_unlock(&chip->reg_lock); in snd_ymfpci_pcm_capture_interrupt()
375 struct snd_ymfpci *chip = snd_pcm_substream_chip(substream); in snd_ymfpci_playback_trigger() local
380 spin_lock(&chip->reg_lock); in snd_ymfpci_playback_trigger()
389 chip->ctrl_playback[ypcm->voices[0]->number + 1] = cpu_to_le32(ypcm->voices[0]->bank_addr); in snd_ymfpci_playback_trigger()
391 chip->ctrl_playback[ypcm->voices[1]->number + 1] = cpu_to_le32(ypcm->voices[1]->bank_addr); in snd_ymfpci_playback_trigger()
395 if (substream->pcm == chip->pcm && !ypcm->use_441_slot) { in snd_ymfpci_playback_trigger()
396 kctl = chip->pcm_mixer[substream->number].ctl; in snd_ymfpci_playback_trigger()
402 chip->ctrl_playback[ypcm->voices[0]->number + 1] = 0; in snd_ymfpci_playback_trigger()
404 chip->ctrl_playback[ypcm->voices[1]->number + 1] = 0; in snd_ymfpci_playback_trigger()
412 spin_unlock(&chip->reg_lock); in snd_ymfpci_playback_trigger()
414 snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_INFO, &kctl->id); in snd_ymfpci_playback_trigger()
420 struct snd_ymfpci *chip = snd_pcm_substream_chip(substream); in snd_ymfpci_capture_trigger() local
425 spin_lock(&chip->reg_lock); in snd_ymfpci_capture_trigger()
430 tmp = snd_ymfpci_readl(chip, YDSXGR_MAPOFREC) | (1 << ypcm->capture_bank_number); in snd_ymfpci_capture_trigger()
431 snd_ymfpci_writel(chip, YDSXGR_MAPOFREC, tmp); in snd_ymfpci_capture_trigger()
437 tmp = snd_ymfpci_readl(chip, YDSXGR_MAPOFREC) & ~(1 << ypcm->capture_bank_number); in snd_ymfpci_capture_trigger()
438 snd_ymfpci_writel(chip, YDSXGR_MAPOFREC, tmp); in snd_ymfpci_capture_trigger()
445 spin_unlock(&chip->reg_lock); in snd_ymfpci_capture_trigger()
454 snd_ymfpci_voice_free(ypcm->chip, ypcm->voices[1]); in snd_ymfpci_pcm_voice_alloc()
463 snd_ymfpci_voice_free(ypcm->chip, ypcm->voices[0]); in snd_ymfpci_pcm_voice_alloc()
467 err = snd_ymfpci_voice_alloc(ypcm->chip, YMFPCI_PCM, voices > 1, &ypcm->voices[0]); in snd_ymfpci_pcm_voice_alloc()
473 ypcm->voices[1] = &ypcm->chip->voices[ypcm->voices[0]->number + 1]; in snd_ymfpci_pcm_voice_alloc()
504 vol_left = cpu_to_le32(ypcm->chip->pcm_mixer in snd_ymfpci_pcm_init_voice()
506 vol_right = cpu_to_le32(ypcm->chip->pcm_mixer in snd_ymfpci_pcm_init_voice()
512 spin_lock_irqsave(&ypcm->chip->voice_lock, flags); in snd_ymfpci_pcm_init_voice()
516 else if (ypcm->chip->device_id == PCI_DEVICE_ID_YAMAHA_754 && in snd_ymfpci_pcm_init_voice()
518 voiceidx == 0 && (ypcm->chip->src441_used == -1 || in snd_ymfpci_pcm_init_voice()
519 ypcm->chip->src441_used == voice->number)) { in snd_ymfpci_pcm_init_voice()
520 ypcm->chip->src441_used = voice->number; in snd_ymfpci_pcm_init_voice()
524 if (ypcm->chip->src441_used == voice->number && in snd_ymfpci_pcm_init_voice()
526 ypcm->chip->src441_used = -1; in snd_ymfpci_pcm_init_voice()
531 spin_unlock_irqrestore(&ypcm->chip->voice_lock, flags); in snd_ymfpci_pcm_init_voice()
584 static int snd_ymfpci_ac3_init(struct snd_ymfpci *chip) in snd_ymfpci_ac3_init() argument
586 if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, &chip->pci->dev, in snd_ymfpci_ac3_init()
587 4096, &chip->ac3_tmp_base) < 0) in snd_ymfpci_ac3_init()
590 chip->bank_effect[3][0]->base = in snd_ymfpci_ac3_init()
591 chip->bank_effect[3][1]->base = cpu_to_le32(chip->ac3_tmp_base.addr); in snd_ymfpci_ac3_init()
592 chip->bank_effect[3][0]->loop_end = in snd_ymfpci_ac3_init()
593 chip->bank_effect[3][1]->loop_end = cpu_to_le32(1024); in snd_ymfpci_ac3_init()
594 chip->bank_effect[4][0]->base = in snd_ymfpci_ac3_init()
595 chip->bank_effect[4][1]->base = cpu_to_le32(chip->ac3_tmp_base.addr + 2048); in snd_ymfpci_ac3_init()
596 chip->bank_effect[4][0]->loop_end = in snd_ymfpci_ac3_init()
597 chip->bank_effect[4][1]->loop_end = cpu_to_le32(1024); in snd_ymfpci_ac3_init()
599 spin_lock_irq(&chip->reg_lock); in snd_ymfpci_ac3_init()
600 snd_ymfpci_writel(chip, YDSXGR_MAPOFEFFECT, in snd_ymfpci_ac3_init()
601 snd_ymfpci_readl(chip, YDSXGR_MAPOFEFFECT) | 3 << 3); in snd_ymfpci_ac3_init()
602 spin_unlock_irq(&chip->reg_lock); in snd_ymfpci_ac3_init()
606 static int snd_ymfpci_ac3_done(struct snd_ymfpci *chip) in snd_ymfpci_ac3_done() argument
608 spin_lock_irq(&chip->reg_lock); in snd_ymfpci_ac3_done()
609 snd_ymfpci_writel(chip, YDSXGR_MAPOFEFFECT, in snd_ymfpci_ac3_done()
610 snd_ymfpci_readl(chip, YDSXGR_MAPOFEFFECT) & ~(3 << 3)); in snd_ymfpci_ac3_done()
611 spin_unlock_irq(&chip->reg_lock); in snd_ymfpci_ac3_done()
612 // snd_ymfpci_irq_wait(chip); in snd_ymfpci_ac3_done()
613 if (chip->ac3_tmp_base.area) { in snd_ymfpci_ac3_done()
614 snd_dma_free_pages(&chip->ac3_tmp_base); in snd_ymfpci_ac3_done()
615 chip->ac3_tmp_base.area = NULL; in snd_ymfpci_ac3_done()
635 struct snd_ymfpci *chip = snd_pcm_substream_chip(substream); in snd_ymfpci_playback_hw_free() local
644 snd_ymfpci_irq_wait(chip); in snd_ymfpci_playback_hw_free()
646 snd_ymfpci_voice_free(chip, ypcm->voices[1]); in snd_ymfpci_playback_hw_free()
650 snd_ymfpci_voice_free(chip, ypcm->voices[0]); in snd_ymfpci_playback_hw_free()
658 struct snd_ymfpci *chip = snd_pcm_substream_chip(substream); in snd_ymfpci_playback_prepare() local
670 substream->pcm == chip->pcm); in snd_ymfpci_playback_prepare()
672 if (substream->pcm == chip->pcm && !ypcm->use_441_slot) { in snd_ymfpci_playback_prepare()
673 kctl = chip->pcm_mixer[substream->number].ctl; in snd_ymfpci_playback_prepare()
675 snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_INFO, &kctl->id); in snd_ymfpci_playback_prepare()
682 struct snd_ymfpci *chip = snd_pcm_substream_chip(substream); in snd_ymfpci_capture_hw_free() local
685 snd_ymfpci_irq_wait(chip); in snd_ymfpci_capture_hw_free()
691 struct snd_ymfpci *chip = snd_pcm_substream_chip(substream); in snd_ymfpci_capture_prepare() local
715 snd_ymfpci_writel(chip, YDSXGR_RECFORMAT, format); in snd_ymfpci_capture_prepare()
716 snd_ymfpci_writel(chip, YDSXGR_RECSLOTSR, rate); in snd_ymfpci_capture_prepare()
719 snd_ymfpci_writel(chip, YDSXGR_ADCFORMAT, format); in snd_ymfpci_capture_prepare()
720 snd_ymfpci_writel(chip, YDSXGR_ADCSLOTSR, rate); in snd_ymfpci_capture_prepare()
724 bank = chip->bank_capture[ypcm->capture_bank_number][nbank]; in snd_ymfpci_capture_prepare()
735 struct snd_ymfpci *chip = snd_pcm_substream_chip(substream); in snd_ymfpci_playback_pointer() local
742 return le32_to_cpu(voice->bank[chip->active_bank].start); in snd_ymfpci_playback_pointer()
747 struct snd_ymfpci *chip = snd_pcm_substream_chip(substream); in snd_ymfpci_capture_pointer() local
753 …return le32_to_cpu(chip->bank_capture[ypcm->capture_bank_number][chip->active_bank]->start) >> ypc… in snd_ymfpci_capture_pointer()
756 static void snd_ymfpci_irq_wait(struct snd_ymfpci *chip) in snd_ymfpci_irq_wait() argument
762 if ((snd_ymfpci_readl(chip, YDSXGR_MODE) & 3) == 0) in snd_ymfpci_irq_wait()
765 add_wait_queue(&chip->interrupt_sleep, &wait); in snd_ymfpci_irq_wait()
766 atomic_inc(&chip->interrupt_sleep_count); in snd_ymfpci_irq_wait()
768 remove_wait_queue(&chip->interrupt_sleep, &wait); in snd_ymfpci_irq_wait()
774 struct snd_ymfpci *chip = dev_id; in snd_ymfpci_interrupt() local
778 status = snd_ymfpci_readl(chip, YDSXGR_STATUS); in snd_ymfpci_interrupt()
780 chip->active_bank = snd_ymfpci_readl(chip, YDSXGR_CTRLSELECT) & 1; in snd_ymfpci_interrupt()
781 spin_lock(&chip->voice_lock); in snd_ymfpci_interrupt()
783 voice = &chip->voices[nvoice]; in snd_ymfpci_interrupt()
785 voice->interrupt(chip, voice); in snd_ymfpci_interrupt()
788 if (chip->capture_substream[nvoice]) in snd_ymfpci_interrupt()
789 snd_ymfpci_pcm_capture_interrupt(chip->capture_substream[nvoice]); in snd_ymfpci_interrupt()
793 if (chip->effect_substream[nvoice]) in snd_ymfpci_interrupt()
794 snd_ymfpci_pcm_effect_interrupt(chip->effect_substream[nvoice]); in snd_ymfpci_interrupt()
797 spin_unlock(&chip->voice_lock); in snd_ymfpci_interrupt()
798 spin_lock(&chip->reg_lock); in snd_ymfpci_interrupt()
799 snd_ymfpci_writel(chip, YDSXGR_STATUS, 0x80000000); in snd_ymfpci_interrupt()
800 mode = snd_ymfpci_readl(chip, YDSXGR_MODE) | 2; in snd_ymfpci_interrupt()
801 snd_ymfpci_writel(chip, YDSXGR_MODE, mode); in snd_ymfpci_interrupt()
802 spin_unlock(&chip->reg_lock); in snd_ymfpci_interrupt()
804 if (atomic_read(&chip->interrupt_sleep_count)) { in snd_ymfpci_interrupt()
805 atomic_set(&chip->interrupt_sleep_count, 0); in snd_ymfpci_interrupt()
806 wake_up(&chip->interrupt_sleep); in snd_ymfpci_interrupt()
810 status = snd_ymfpci_readw(chip, YDSXGR_INTFLAG); in snd_ymfpci_interrupt()
812 if (chip->timer) in snd_ymfpci_interrupt()
813 snd_timer_interrupt(chip->timer, chip->timer_ticks); in snd_ymfpci_interrupt()
815 snd_ymfpci_writew(chip, YDSXGR_INTFLAG, status); in snd_ymfpci_interrupt()
817 if (chip->rawmidi) in snd_ymfpci_interrupt()
818 snd_mpu401_uart_interrupt(irq, chip->rawmidi->private_data); in snd_ymfpci_interrupt()
873 struct snd_ymfpci *chip = snd_pcm_substream_chip(substream); in snd_ymfpci_playback_open_1() local
892 ypcm->chip = chip; in snd_ymfpci_playback_open_1()
901 static void ymfpci_open_extension(struct snd_ymfpci *chip) in ymfpci_open_extension() argument
903 if (! chip->rear_opened) { in ymfpci_open_extension()
904 if (! chip->spdif_opened) /* set AC3 */ in ymfpci_open_extension()
905 snd_ymfpci_writel(chip, YDSXGR_MODE, in ymfpci_open_extension()
906 snd_ymfpci_readl(chip, YDSXGR_MODE) | (1 << 30)); in ymfpci_open_extension()
908 snd_ymfpci_writew(chip, YDSXGR_SECCONFIG, in ymfpci_open_extension()
909 (snd_ymfpci_readw(chip, YDSXGR_SECCONFIG) & ~0x0330) | 0x0010); in ymfpci_open_extension()
914 static void ymfpci_close_extension(struct snd_ymfpci *chip) in ymfpci_close_extension() argument
916 if (! chip->rear_opened) { in ymfpci_close_extension()
917 if (! chip->spdif_opened) in ymfpci_close_extension()
918 snd_ymfpci_writel(chip, YDSXGR_MODE, in ymfpci_close_extension()
919 snd_ymfpci_readl(chip, YDSXGR_MODE) & ~(1 << 30)); in ymfpci_close_extension()
920 snd_ymfpci_writew(chip, YDSXGR_SECCONFIG, in ymfpci_close_extension()
921 (snd_ymfpci_readw(chip, YDSXGR_SECCONFIG) & ~0x0330) & ~0x0010); in ymfpci_close_extension()
927 struct snd_ymfpci *chip = snd_pcm_substream_chip(substream); in snd_ymfpci_playback_open() local
937 ypcm->output_rear = chip->mode_dup4ch ? 1 : 0; in snd_ymfpci_playback_open()
939 spin_lock_irq(&chip->reg_lock); in snd_ymfpci_playback_open()
941 ymfpci_open_extension(chip); in snd_ymfpci_playback_open()
942 chip->rear_opened++; in snd_ymfpci_playback_open()
944 spin_unlock_irq(&chip->reg_lock); in snd_ymfpci_playback_open()
950 struct snd_ymfpci *chip = snd_pcm_substream_chip(substream); in snd_ymfpci_playback_spdif_open() local
962 spin_lock_irq(&chip->reg_lock); in snd_ymfpci_playback_spdif_open()
963 snd_ymfpci_writew(chip, YDSXGR_SPDIFOUTCTRL, in snd_ymfpci_playback_spdif_open()
964 snd_ymfpci_readw(chip, YDSXGR_SPDIFOUTCTRL) | 2); in snd_ymfpci_playback_spdif_open()
965 ymfpci_open_extension(chip); in snd_ymfpci_playback_spdif_open()
966 chip->spdif_pcm_bits = chip->spdif_bits; in snd_ymfpci_playback_spdif_open()
967 snd_ymfpci_writew(chip, YDSXGR_SPDIFOUTSTATUS, chip->spdif_pcm_bits); in snd_ymfpci_playback_spdif_open()
968 chip->spdif_opened++; in snd_ymfpci_playback_spdif_open()
969 spin_unlock_irq(&chip->reg_lock); in snd_ymfpci_playback_spdif_open()
971 chip->spdif_pcm_ctl->vd[0].access &= ~SNDRV_CTL_ELEM_ACCESS_INACTIVE; in snd_ymfpci_playback_spdif_open()
972 snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE | in snd_ymfpci_playback_spdif_open()
973 SNDRV_CTL_EVENT_MASK_INFO, &chip->spdif_pcm_ctl->id); in snd_ymfpci_playback_spdif_open()
979 struct snd_ymfpci *chip = snd_pcm_substream_chip(substream); in snd_ymfpci_playback_4ch_open() local
991 spin_lock_irq(&chip->reg_lock); in snd_ymfpci_playback_4ch_open()
992 ymfpci_open_extension(chip); in snd_ymfpci_playback_4ch_open()
993 chip->rear_opened++; in snd_ymfpci_playback_4ch_open()
994 spin_unlock_irq(&chip->reg_lock); in snd_ymfpci_playback_4ch_open()
1001 struct snd_ymfpci *chip = snd_pcm_substream_chip(substream); in snd_ymfpci_capture_open() local
1020 ypcm->chip = chip; in snd_ymfpci_capture_open()
1024 chip->capture_substream[capture_bank_number] = substream; in snd_ymfpci_capture_open()
1027 snd_ymfpci_hw_start(chip); in snd_ymfpci_capture_open()
1048 struct snd_ymfpci *chip = snd_pcm_substream_chip(substream); in snd_ymfpci_playback_close() local
1051 spin_lock_irq(&chip->reg_lock); in snd_ymfpci_playback_close()
1052 if (ypcm->output_rear && chip->rear_opened > 0) { in snd_ymfpci_playback_close()
1053 chip->rear_opened--; in snd_ymfpci_playback_close()
1054 ymfpci_close_extension(chip); in snd_ymfpci_playback_close()
1056 spin_unlock_irq(&chip->reg_lock); in snd_ymfpci_playback_close()
1062 struct snd_ymfpci *chip = snd_pcm_substream_chip(substream); in snd_ymfpci_playback_spdif_close() local
1064 spin_lock_irq(&chip->reg_lock); in snd_ymfpci_playback_spdif_close()
1065 chip->spdif_opened = 0; in snd_ymfpci_playback_spdif_close()
1066 ymfpci_close_extension(chip); in snd_ymfpci_playback_spdif_close()
1067 snd_ymfpci_writew(chip, YDSXGR_SPDIFOUTCTRL, in snd_ymfpci_playback_spdif_close()
1068 snd_ymfpci_readw(chip, YDSXGR_SPDIFOUTCTRL) & ~2); in snd_ymfpci_playback_spdif_close()
1069 snd_ymfpci_writew(chip, YDSXGR_SPDIFOUTSTATUS, chip->spdif_bits); in snd_ymfpci_playback_spdif_close()
1070 spin_unlock_irq(&chip->reg_lock); in snd_ymfpci_playback_spdif_close()
1071 chip->spdif_pcm_ctl->vd[0].access |= SNDRV_CTL_ELEM_ACCESS_INACTIVE; in snd_ymfpci_playback_spdif_close()
1072 snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE | in snd_ymfpci_playback_spdif_close()
1073 SNDRV_CTL_EVENT_MASK_INFO, &chip->spdif_pcm_ctl->id); in snd_ymfpci_playback_spdif_close()
1079 struct snd_ymfpci *chip = snd_pcm_substream_chip(substream); in snd_ymfpci_playback_4ch_close() local
1081 spin_lock_irq(&chip->reg_lock); in snd_ymfpci_playback_4ch_close()
1082 if (chip->rear_opened > 0) { in snd_ymfpci_playback_4ch_close()
1083 chip->rear_opened--; in snd_ymfpci_playback_4ch_close()
1084 ymfpci_close_extension(chip); in snd_ymfpci_playback_4ch_close()
1086 spin_unlock_irq(&chip->reg_lock); in snd_ymfpci_playback_4ch_close()
1092 struct snd_ymfpci *chip = snd_pcm_substream_chip(substream); in snd_ymfpci_capture_close() local
1097 chip->capture_substream[ypcm->capture_bank_number] = NULL; in snd_ymfpci_capture_close()
1098 snd_ymfpci_hw_stop(chip); in snd_ymfpci_capture_close()
1122 int snd_ymfpci_pcm(struct snd_ymfpci *chip, int device) in snd_ymfpci_pcm() argument
1127 err = snd_pcm_new(chip->card, "YMFPCI", device, 32, 1, &pcm); in snd_ymfpci_pcm()
1130 pcm->private_data = chip; in snd_ymfpci_pcm()
1138 chip->pcm = pcm; in snd_ymfpci_pcm()
1141 &chip->pci->dev, 64*1024, 256*1024); in snd_ymfpci_pcm()
1156 int snd_ymfpci_pcm2(struct snd_ymfpci *chip, int device) in snd_ymfpci_pcm2() argument
1161 err = snd_pcm_new(chip->card, "YMFPCI - PCM2", device, 0, 1, &pcm); in snd_ymfpci_pcm2()
1164 pcm->private_data = chip; in snd_ymfpci_pcm2()
1171 chip->device_id == PCI_DEVICE_ID_YAMAHA_754 ? "Direct Recording" : "AC'97"); in snd_ymfpci_pcm2()
1172 chip->pcm2 = pcm; in snd_ymfpci_pcm2()
1175 &chip->pci->dev, 64*1024, 256*1024); in snd_ymfpci_pcm2()
1190 int snd_ymfpci_pcm_spdif(struct snd_ymfpci *chip, int device) in snd_ymfpci_pcm_spdif() argument
1195 err = snd_pcm_new(chip->card, "YMFPCI - IEC958", device, 1, 0, &pcm); in snd_ymfpci_pcm_spdif()
1198 pcm->private_data = chip; in snd_ymfpci_pcm_spdif()
1205 chip->pcm_spdif = pcm; in snd_ymfpci_pcm_spdif()
1208 &chip->pci->dev, 64*1024, 256*1024); in snd_ymfpci_pcm_spdif()
1231 int snd_ymfpci_pcm_4ch(struct snd_ymfpci *chip, int device) in snd_ymfpci_pcm_4ch() argument
1236 err = snd_pcm_new(chip->card, "YMFPCI - Rear", device, 1, 0, &pcm); in snd_ymfpci_pcm_4ch()
1239 pcm->private_data = chip; in snd_ymfpci_pcm_4ch()
1246 chip->pcm_4ch = pcm; in snd_ymfpci_pcm_4ch()
1249 &chip->pci->dev, 64*1024, 256*1024); in snd_ymfpci_pcm_4ch()
1265 struct snd_ymfpci *chip = snd_kcontrol_chip(kcontrol); in snd_ymfpci_spdif_default_get() local
1267 spin_lock_irq(&chip->reg_lock); in snd_ymfpci_spdif_default_get()
1268 ucontrol->value.iec958.status[0] = (chip->spdif_bits >> 0) & 0xff; in snd_ymfpci_spdif_default_get()
1269 ucontrol->value.iec958.status[1] = (chip->spdif_bits >> 8) & 0xff; in snd_ymfpci_spdif_default_get()
1271 spin_unlock_irq(&chip->reg_lock); in snd_ymfpci_spdif_default_get()
1278 struct snd_ymfpci *chip = snd_kcontrol_chip(kcontrol); in snd_ymfpci_spdif_default_put() local
1284 spin_lock_irq(&chip->reg_lock); in snd_ymfpci_spdif_default_put()
1285 change = chip->spdif_bits != val; in snd_ymfpci_spdif_default_put()
1286 chip->spdif_bits = val; in snd_ymfpci_spdif_default_put()
1287 if ((snd_ymfpci_readw(chip, YDSXGR_SPDIFOUTCTRL) & 1) && chip->pcm_spdif == NULL) in snd_ymfpci_spdif_default_put()
1288 snd_ymfpci_writew(chip, YDSXGR_SPDIFOUTSTATUS, chip->spdif_bits); in snd_ymfpci_spdif_default_put()
1289 spin_unlock_irq(&chip->reg_lock); in snd_ymfpci_spdif_default_put()
1312 struct snd_ymfpci *chip = snd_kcontrol_chip(kcontrol); in snd_ymfpci_spdif_mask_get() local
1314 spin_lock_irq(&chip->reg_lock); in snd_ymfpci_spdif_mask_get()
1317 spin_unlock_irq(&chip->reg_lock); in snd_ymfpci_spdif_mask_get()
1340 struct snd_ymfpci *chip = snd_kcontrol_chip(kcontrol); in snd_ymfpci_spdif_stream_get() local
1342 spin_lock_irq(&chip->reg_lock); in snd_ymfpci_spdif_stream_get()
1343 ucontrol->value.iec958.status[0] = (chip->spdif_pcm_bits >> 0) & 0xff; in snd_ymfpci_spdif_stream_get()
1344 ucontrol->value.iec958.status[1] = (chip->spdif_pcm_bits >> 8) & 0xff; in snd_ymfpci_spdif_stream_get()
1346 spin_unlock_irq(&chip->reg_lock); in snd_ymfpci_spdif_stream_get()
1353 struct snd_ymfpci *chip = snd_kcontrol_chip(kcontrol); in snd_ymfpci_spdif_stream_put() local
1359 spin_lock_irq(&chip->reg_lock); in snd_ymfpci_spdif_stream_put()
1360 change = chip->spdif_pcm_bits != val; in snd_ymfpci_spdif_stream_put()
1361 chip->spdif_pcm_bits = val; in snd_ymfpci_spdif_stream_put()
1362 if ((snd_ymfpci_readw(chip, YDSXGR_SPDIFOUTCTRL) & 2)) in snd_ymfpci_spdif_stream_put()
1363 snd_ymfpci_writew(chip, YDSXGR_SPDIFOUTSTATUS, chip->spdif_pcm_bits); in snd_ymfpci_spdif_stream_put()
1364 spin_unlock_irq(&chip->reg_lock); in snd_ymfpci_spdif_stream_put()
1387 struct snd_ymfpci *chip = snd_kcontrol_chip(kcontrol); in snd_ymfpci_drec_source_get() local
1390 spin_lock_irq(&chip->reg_lock); in snd_ymfpci_drec_source_get()
1391 reg = snd_ymfpci_readw(chip, YDSXGR_GLOBALCTRL); in snd_ymfpci_drec_source_get()
1392 spin_unlock_irq(&chip->reg_lock); in snd_ymfpci_drec_source_get()
1402 struct snd_ymfpci *chip = snd_kcontrol_chip(kcontrol); in snd_ymfpci_drec_source_put() local
1405 spin_lock_irq(&chip->reg_lock); in snd_ymfpci_drec_source_put()
1406 old_reg = snd_ymfpci_readw(chip, YDSXGR_GLOBALCTRL); in snd_ymfpci_drec_source_put()
1411 snd_ymfpci_writew(chip, YDSXGR_GLOBALCTRL, reg); in snd_ymfpci_drec_source_put()
1412 spin_unlock_irq(&chip->reg_lock); in snd_ymfpci_drec_source_put()
1440 struct snd_ymfpci *chip = snd_kcontrol_chip(kcontrol); in snd_ymfpci_get_single() local
1451 (snd_ymfpci_readl(chip, reg) >> shift) & mask; in snd_ymfpci_get_single()
1458 struct snd_ymfpci *chip = snd_kcontrol_chip(kcontrol); in snd_ymfpci_put_single() local
1472 spin_lock_irq(&chip->reg_lock); in snd_ymfpci_put_single()
1473 oval = snd_ymfpci_readl(chip, reg); in snd_ymfpci_put_single()
1476 snd_ymfpci_writel(chip, reg, val); in snd_ymfpci_put_single()
1477 spin_unlock_irq(&chip->reg_lock); in snd_ymfpci_put_single()
1506 struct snd_ymfpci *chip = snd_kcontrol_chip(kcontrol); in snd_ymfpci_get_double() local
1513 spin_lock_irq(&chip->reg_lock); in snd_ymfpci_get_double()
1514 val = snd_ymfpci_readl(chip, reg); in snd_ymfpci_get_double()
1515 spin_unlock_irq(&chip->reg_lock); in snd_ymfpci_get_double()
1523 struct snd_ymfpci *chip = snd_kcontrol_chip(kcontrol); in snd_ymfpci_put_double() local
1535 spin_lock_irq(&chip->reg_lock); in snd_ymfpci_put_double()
1536 oval = snd_ymfpci_readl(chip, reg); in snd_ymfpci_put_double()
1539 snd_ymfpci_writel(chip, reg, val1); in snd_ymfpci_put_double()
1540 spin_unlock_irq(&chip->reg_lock); in snd_ymfpci_put_double()
1547 struct snd_ymfpci *chip = snd_kcontrol_chip(kcontrol); in snd_ymfpci_put_nativedacvol() local
1555 spin_lock_irq(&chip->reg_lock); in snd_ymfpci_put_nativedacvol()
1556 oval = snd_ymfpci_readl(chip, reg); in snd_ymfpci_put_nativedacvol()
1558 snd_ymfpci_writel(chip, reg, value); in snd_ymfpci_put_nativedacvol()
1559 snd_ymfpci_writel(chip, reg2, value); in snd_ymfpci_put_nativedacvol()
1560 spin_unlock_irq(&chip->reg_lock); in snd_ymfpci_put_nativedacvol()
1571 struct snd_ymfpci *chip = snd_kcontrol_chip(kcontrol); in snd_ymfpci_get_dup4ch() local
1572 ucontrol->value.integer.value[0] = chip->mode_dup4ch; in snd_ymfpci_get_dup4ch()
1578 struct snd_ymfpci *chip = snd_kcontrol_chip(kcontrol); in snd_ymfpci_put_dup4ch() local
1580 change = (ucontrol->value.integer.value[0] != chip->mode_dup4ch); in snd_ymfpci_put_dup4ch()
1582 chip->mode_dup4ch = !!ucontrol->value.integer.value[0]; in snd_ymfpci_put_dup4ch()
1629 static int snd_ymfpci_get_gpio_out(struct snd_ymfpci *chip, int pin) in snd_ymfpci_get_gpio_out() argument
1634 spin_lock_irqsave(&chip->reg_lock, flags); in snd_ymfpci_get_gpio_out()
1635 reg = snd_ymfpci_readw(chip, YDSXGR_GPIOFUNCENABLE); in snd_ymfpci_get_gpio_out()
1638 snd_ymfpci_writew(chip, YDSXGR_GPIOFUNCENABLE, reg); in snd_ymfpci_get_gpio_out()
1640 mode = snd_ymfpci_readw(chip, YDSXGR_GPIOTYPECONFIG); in snd_ymfpci_get_gpio_out()
1642 snd_ymfpci_writew(chip, YDSXGR_GPIOTYPECONFIG, mode); in snd_ymfpci_get_gpio_out()
1643 snd_ymfpci_writew(chip, YDSXGR_GPIOFUNCENABLE, reg | (1 << (pin + 8))); in snd_ymfpci_get_gpio_out()
1644 mode = snd_ymfpci_readw(chip, YDSXGR_GPIOINSTATUS); in snd_ymfpci_get_gpio_out()
1645 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_ymfpci_get_gpio_out()
1649 static int snd_ymfpci_set_gpio_out(struct snd_ymfpci *chip, int pin, int enable) in snd_ymfpci_set_gpio_out() argument
1654 spin_lock_irqsave(&chip->reg_lock, flags); in snd_ymfpci_set_gpio_out()
1655 reg = snd_ymfpci_readw(chip, YDSXGR_GPIOFUNCENABLE); in snd_ymfpci_set_gpio_out()
1658 snd_ymfpci_writew(chip, YDSXGR_GPIOFUNCENABLE, reg); in snd_ymfpci_set_gpio_out()
1659 snd_ymfpci_writew(chip, YDSXGR_GPIOOUTCTRL, enable << pin); in snd_ymfpci_set_gpio_out()
1660 snd_ymfpci_writew(chip, YDSXGR_GPIOFUNCENABLE, reg | (1 << (pin + 8))); in snd_ymfpci_set_gpio_out()
1661 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_ymfpci_set_gpio_out()
1670 struct snd_ymfpci *chip = snd_kcontrol_chip(kcontrol); in snd_ymfpci_gpio_sw_get() local
1672 ucontrol->value.integer.value[0] = snd_ymfpci_get_gpio_out(chip, pin); in snd_ymfpci_gpio_sw_get()
1678 struct snd_ymfpci *chip = snd_kcontrol_chip(kcontrol); in snd_ymfpci_gpio_sw_put() local
1681 if (snd_ymfpci_get_gpio_out(chip, pin) != ucontrol->value.integer.value[0]) { in snd_ymfpci_gpio_sw_put()
1682 snd_ymfpci_set_gpio_out(chip, pin, !!ucontrol->value.integer.value[0]); in snd_ymfpci_gpio_sw_put()
1683 ucontrol->value.integer.value[0] = snd_ymfpci_get_gpio_out(chip, pin); in snd_ymfpci_gpio_sw_put()
1715 struct snd_ymfpci *chip = snd_kcontrol_chip(kcontrol); in snd_ymfpci_pcm_vol_get() local
1718 ucontrol->value.integer.value[0] = chip->pcm_mixer[subs].left; in snd_ymfpci_pcm_vol_get()
1719 ucontrol->value.integer.value[1] = chip->pcm_mixer[subs].right; in snd_ymfpci_pcm_vol_get()
1726 struct snd_ymfpci *chip = snd_kcontrol_chip(kcontrol); in snd_ymfpci_pcm_vol_put() local
1731 if (ucontrol->value.integer.value[0] != chip->pcm_mixer[subs].left || in snd_ymfpci_pcm_vol_put()
1732 ucontrol->value.integer.value[1] != chip->pcm_mixer[subs].right) { in snd_ymfpci_pcm_vol_put()
1733 chip->pcm_mixer[subs].left = ucontrol->value.integer.value[0]; in snd_ymfpci_pcm_vol_put()
1734 chip->pcm_mixer[subs].right = ucontrol->value.integer.value[1]; in snd_ymfpci_pcm_vol_put()
1735 if (chip->pcm_mixer[subs].left > 0x8000) in snd_ymfpci_pcm_vol_put()
1736 chip->pcm_mixer[subs].left = 0x8000; in snd_ymfpci_pcm_vol_put()
1737 if (chip->pcm_mixer[subs].right > 0x8000) in snd_ymfpci_pcm_vol_put()
1738 chip->pcm_mixer[subs].right = 0x8000; in snd_ymfpci_pcm_vol_put()
1741 spin_lock_irqsave(&chip->voice_lock, flags); in snd_ymfpci_pcm_vol_put()
1747 spin_unlock_irqrestore(&chip->voice_lock, flags); in snd_ymfpci_pcm_vol_put()
1770 struct snd_ymfpci *chip = bus->private_data; in snd_ymfpci_mixer_free_ac97_bus() local
1771 chip->ac97_bus = NULL; in snd_ymfpci_mixer_free_ac97_bus()
1776 struct snd_ymfpci *chip = ac97->private_data; in snd_ymfpci_mixer_free_ac97() local
1777 chip->ac97 = NULL; in snd_ymfpci_mixer_free_ac97()
1780 int snd_ymfpci_mixer(struct snd_ymfpci *chip, int rear_switch) in snd_ymfpci_mixer() argument
1792 err = snd_ac97_bus(chip->card, 0, &ops, chip, &chip->ac97_bus); in snd_ymfpci_mixer()
1795 chip->ac97_bus->private_free = snd_ymfpci_mixer_free_ac97_bus; in snd_ymfpci_mixer()
1796 chip->ac97_bus->no_vra = 1; /* YMFPCI doesn't need VRA */ in snd_ymfpci_mixer()
1799 ac97.private_data = chip; in snd_ymfpci_mixer()
1801 err = snd_ac97_mixer(chip->ac97_bus, &ac97, &chip->ac97); in snd_ymfpci_mixer()
1806 snd_ac97_update_bits(chip->ac97, AC97_EXTENDED_STATUS, in snd_ymfpci_mixer()
1810 err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_ymfpci_controls[idx], chip)); in snd_ymfpci_mixer()
1814 if (chip->ac97->ext_id & AC97_EI_SDAC) { in snd_ymfpci_mixer()
1815 kctl = snd_ctl_new1(&snd_ymfpci_dup4ch, chip); in snd_ymfpci_mixer()
1816 err = snd_ctl_add(chip->card, kctl); in snd_ymfpci_mixer()
1822 if (snd_BUG_ON(!chip->pcm_spdif)) in snd_ymfpci_mixer()
1824 kctl = snd_ctl_new1(&snd_ymfpci_spdif_default, chip); in snd_ymfpci_mixer()
1825 kctl->id.device = chip->pcm_spdif->device; in snd_ymfpci_mixer()
1826 err = snd_ctl_add(chip->card, kctl); in snd_ymfpci_mixer()
1829 kctl = snd_ctl_new1(&snd_ymfpci_spdif_mask, chip); in snd_ymfpci_mixer()
1830 kctl->id.device = chip->pcm_spdif->device; in snd_ymfpci_mixer()
1831 err = snd_ctl_add(chip->card, kctl); in snd_ymfpci_mixer()
1834 kctl = snd_ctl_new1(&snd_ymfpci_spdif_stream, chip); in snd_ymfpci_mixer()
1835 kctl->id.device = chip->pcm_spdif->device; in snd_ymfpci_mixer()
1836 err = snd_ctl_add(chip->card, kctl); in snd_ymfpci_mixer()
1839 chip->spdif_pcm_ctl = kctl; in snd_ymfpci_mixer()
1842 if (chip->device_id == PCI_DEVICE_ID_YAMAHA_754) { in snd_ymfpci_mixer()
1843 kctl = snd_ctl_new1(&snd_ymfpci_drec_source, chip); in snd_ymfpci_mixer()
1844 err = snd_ctl_add(chip->card, kctl); in snd_ymfpci_mixer()
1853 err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_ymfpci_rear_shared, chip)); in snd_ymfpci_mixer()
1859 substream = chip->pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; in snd_ymfpci_mixer()
1861 kctl = snd_ctl_new1(&snd_ymfpci_pcm_volume, chip); in snd_ymfpci_mixer()
1864 kctl->id.device = chip->pcm->device; in snd_ymfpci_mixer()
1867 err = snd_ctl_add(chip->card, kctl); in snd_ymfpci_mixer()
1870 chip->pcm_mixer[idx].left = 0x8000; in snd_ymfpci_mixer()
1871 chip->pcm_mixer[idx].right = 0x8000; in snd_ymfpci_mixer()
1872 chip->pcm_mixer[idx].ctl = kctl; in snd_ymfpci_mixer()
1886 struct snd_ymfpci *chip; in snd_ymfpci_timer_start() local
1890 chip = snd_timer_chip(timer); in snd_ymfpci_timer_start()
1891 spin_lock_irqsave(&chip->reg_lock, flags); in snd_ymfpci_timer_start()
1893 chip->timer_ticks = timer->sticks; in snd_ymfpci_timer_start()
1900 chip->timer_ticks = 2; in snd_ymfpci_timer_start()
1903 snd_ymfpci_writew(chip, YDSXGR_TIMERCOUNT, count); in snd_ymfpci_timer_start()
1904 snd_ymfpci_writeb(chip, YDSXGR_TIMERCTRL, 0x03); in snd_ymfpci_timer_start()
1905 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_ymfpci_timer_start()
1911 struct snd_ymfpci *chip; in snd_ymfpci_timer_stop() local
1914 chip = snd_timer_chip(timer); in snd_ymfpci_timer_stop()
1915 spin_lock_irqsave(&chip->reg_lock, flags); in snd_ymfpci_timer_stop()
1916 snd_ymfpci_writeb(chip, YDSXGR_TIMERCTRL, 0x00); in snd_ymfpci_timer_stop()
1917 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_ymfpci_timer_stop()
1938 int snd_ymfpci_timer(struct snd_ymfpci *chip, int device) in snd_ymfpci_timer() argument
1946 tid.card = chip->card->number; in snd_ymfpci_timer()
1949 err = snd_timer_new(chip->card, "YMFPCI", &tid, &timer); in snd_ymfpci_timer()
1952 timer->private_data = chip; in snd_ymfpci_timer()
1955 chip->timer = timer; in snd_ymfpci_timer()
1967 struct snd_ymfpci *chip = entry->private_data; in snd_ymfpci_proc_read() local
1972 snd_iprintf(buffer, "%04x: %04x\n", i, snd_ymfpci_readl(chip, i)); in snd_ymfpci_proc_read()
1975 static int snd_ymfpci_proc_init(struct snd_card *card, struct snd_ymfpci *chip) in snd_ymfpci_proc_init() argument
1977 return snd_card_ro_proc_new(card, "ymfpci", chip, snd_ymfpci_proc_read); in snd_ymfpci_proc_init()
2002 static void snd_ymfpci_enable_dsp(struct snd_ymfpci *chip) in snd_ymfpci_enable_dsp() argument
2004 snd_ymfpci_writel(chip, YDSXGR_CONFIG, 0x00000001); in snd_ymfpci_enable_dsp()
2007 static void snd_ymfpci_disable_dsp(struct snd_ymfpci *chip) in snd_ymfpci_disable_dsp() argument
2012 val = snd_ymfpci_readl(chip, YDSXGR_CONFIG); in snd_ymfpci_disable_dsp()
2014 snd_ymfpci_writel(chip, YDSXGR_CONFIG, 0x00000000); in snd_ymfpci_disable_dsp()
2016 val = snd_ymfpci_readl(chip, YDSXGR_STATUS); in snd_ymfpci_disable_dsp()
2022 static int snd_ymfpci_request_firmware(struct snd_ymfpci *chip) in snd_ymfpci_request_firmware() argument
2027 err = request_firmware(&chip->dsp_microcode, "yamaha/ds1_dsp.fw", in snd_ymfpci_request_firmware()
2028 &chip->pci->dev); in snd_ymfpci_request_firmware()
2030 if (chip->dsp_microcode->size != YDSXG_DSPLENGTH) { in snd_ymfpci_request_firmware()
2031 dev_err(chip->card->dev, in snd_ymfpci_request_firmware()
2038 is_1e = chip->device_id == PCI_DEVICE_ID_YAMAHA_724F || in snd_ymfpci_request_firmware()
2039 chip->device_id == PCI_DEVICE_ID_YAMAHA_740C || in snd_ymfpci_request_firmware()
2040 chip->device_id == PCI_DEVICE_ID_YAMAHA_744 || in snd_ymfpci_request_firmware()
2041 chip->device_id == PCI_DEVICE_ID_YAMAHA_754; in snd_ymfpci_request_firmware()
2043 err = request_firmware(&chip->controller_microcode, name, in snd_ymfpci_request_firmware()
2044 &chip->pci->dev); in snd_ymfpci_request_firmware()
2046 if (chip->controller_microcode->size != YDSXG_CTRLLENGTH) { in snd_ymfpci_request_firmware()
2047 dev_err(chip->card->dev, in snd_ymfpci_request_firmware()
2061 static void snd_ymfpci_download_image(struct snd_ymfpci *chip) in snd_ymfpci_download_image() argument
2067 snd_ymfpci_writel(chip, YDSXGR_NATIVEDACOUTVOL, 0x00000000); in snd_ymfpci_download_image()
2068 snd_ymfpci_disable_dsp(chip); in snd_ymfpci_download_image()
2069 snd_ymfpci_writel(chip, YDSXGR_MODE, 0x00010000); in snd_ymfpci_download_image()
2070 snd_ymfpci_writel(chip, YDSXGR_MODE, 0x00000000); in snd_ymfpci_download_image()
2071 snd_ymfpci_writel(chip, YDSXGR_MAPOFREC, 0x00000000); in snd_ymfpci_download_image()
2072 snd_ymfpci_writel(chip, YDSXGR_MAPOFEFFECT, 0x00000000); in snd_ymfpci_download_image()
2073 snd_ymfpci_writel(chip, YDSXGR_PLAYCTRLBASE, 0x00000000); in snd_ymfpci_download_image()
2074 snd_ymfpci_writel(chip, YDSXGR_RECCTRLBASE, 0x00000000); in snd_ymfpci_download_image()
2075 snd_ymfpci_writel(chip, YDSXGR_EFFCTRLBASE, 0x00000000); in snd_ymfpci_download_image()
2076 ctrl = snd_ymfpci_readw(chip, YDSXGR_GLOBALCTRL); in snd_ymfpci_download_image()
2077 snd_ymfpci_writew(chip, YDSXGR_GLOBALCTRL, ctrl & ~0x0007); in snd_ymfpci_download_image()
2080 inst = (const __le32 *)chip->dsp_microcode->data; in snd_ymfpci_download_image()
2082 snd_ymfpci_writel(chip, YDSXGR_DSPINSTRAM + (i << 2), in snd_ymfpci_download_image()
2086 inst = (const __le32 *)chip->controller_microcode->data; in snd_ymfpci_download_image()
2088 snd_ymfpci_writel(chip, YDSXGR_CTRLINSTRAM + (i << 2), in snd_ymfpci_download_image()
2091 snd_ymfpci_enable_dsp(chip); in snd_ymfpci_download_image()
2094 static int snd_ymfpci_memalloc(struct snd_ymfpci *chip) in snd_ymfpci_memalloc() argument
2102 chip->bank_size_playback = snd_ymfpci_readl(chip, YDSXGR_PLAYCTRLSIZE) << 2; in snd_ymfpci_memalloc()
2103 chip->bank_size_capture = snd_ymfpci_readl(chip, YDSXGR_RECCTRLSIZE) << 2; in snd_ymfpci_memalloc()
2104 chip->bank_size_effect = snd_ymfpci_readl(chip, YDSXGR_EFFCTRLSIZE) << 2; in snd_ymfpci_memalloc()
2105 chip->work_size = YDSXG_DEFAULT_WORK_SIZE; in snd_ymfpci_memalloc()
2108 ALIGN(chip->bank_size_playback * 2 * YDSXG_PLAYBACK_VOICES, 0x100) + in snd_ymfpci_memalloc()
2109 ALIGN(chip->bank_size_capture * 2 * YDSXG_CAPTURE_VOICES, 0x100) + in snd_ymfpci_memalloc()
2110 ALIGN(chip->bank_size_effect * 2 * YDSXG_EFFECT_VOICES, 0x100) + in snd_ymfpci_memalloc()
2111 chip->work_size; in snd_ymfpci_memalloc()
2114 chip->work_ptr = snd_devm_alloc_pages(&chip->pci->dev, in snd_ymfpci_memalloc()
2116 if (!chip->work_ptr) in snd_ymfpci_memalloc()
2118 ptr = chip->work_ptr->area; in snd_ymfpci_memalloc()
2119 ptr_addr = chip->work_ptr->addr; in snd_ymfpci_memalloc()
2122 chip->bank_base_playback = ptr; in snd_ymfpci_memalloc()
2123 chip->bank_base_playback_addr = ptr_addr; in snd_ymfpci_memalloc()
2124 chip->ctrl_playback = (__le32 *)ptr; in snd_ymfpci_memalloc()
2125 chip->ctrl_playback[0] = cpu_to_le32(YDSXG_PLAYBACK_VOICES); in snd_ymfpci_memalloc()
2129 chip->voices[voice].number = voice; in snd_ymfpci_memalloc()
2130 chip->voices[voice].bank = (struct snd_ymfpci_playback_bank *)ptr; in snd_ymfpci_memalloc()
2131 chip->voices[voice].bank_addr = ptr_addr; in snd_ymfpci_memalloc()
2133 chip->bank_playback[voice][bank] = (struct snd_ymfpci_playback_bank *)ptr; in snd_ymfpci_memalloc()
2134 ptr += chip->bank_size_playback; in snd_ymfpci_memalloc()
2135 ptr_addr += chip->bank_size_playback; in snd_ymfpci_memalloc()
2140 chip->bank_base_capture = ptr; in snd_ymfpci_memalloc()
2141 chip->bank_base_capture_addr = ptr_addr; in snd_ymfpci_memalloc()
2144 chip->bank_capture[voice][bank] = (struct snd_ymfpci_capture_bank *)ptr; in snd_ymfpci_memalloc()
2145 ptr += chip->bank_size_capture; in snd_ymfpci_memalloc()
2146 ptr_addr += chip->bank_size_capture; in snd_ymfpci_memalloc()
2150 chip->bank_base_effect = ptr; in snd_ymfpci_memalloc()
2151 chip->bank_base_effect_addr = ptr_addr; in snd_ymfpci_memalloc()
2154 chip->bank_effect[voice][bank] = (struct snd_ymfpci_effect_bank *)ptr; in snd_ymfpci_memalloc()
2155 ptr += chip->bank_size_effect; in snd_ymfpci_memalloc()
2156 ptr_addr += chip->bank_size_effect; in snd_ymfpci_memalloc()
2160 chip->work_base = ptr; in snd_ymfpci_memalloc()
2161 chip->work_base_addr = ptr_addr; in snd_ymfpci_memalloc()
2163 snd_BUG_ON(ptr + PAGE_ALIGN(chip->work_size) != in snd_ymfpci_memalloc()
2164 chip->work_ptr->area + chip->work_ptr->bytes); in snd_ymfpci_memalloc()
2166 snd_ymfpci_writel(chip, YDSXGR_PLAYCTRLBASE, chip->bank_base_playback_addr); in snd_ymfpci_memalloc()
2167 snd_ymfpci_writel(chip, YDSXGR_RECCTRLBASE, chip->bank_base_capture_addr); in snd_ymfpci_memalloc()
2168 snd_ymfpci_writel(chip, YDSXGR_EFFCTRLBASE, chip->bank_base_effect_addr); in snd_ymfpci_memalloc()
2169 snd_ymfpci_writel(chip, YDSXGR_WORKBASE, chip->work_base_addr); in snd_ymfpci_memalloc()
2170 snd_ymfpci_writel(chip, YDSXGR_WORKSIZE, chip->work_size >> 2); in snd_ymfpci_memalloc()
2173 chip->spdif_bits = chip->spdif_pcm_bits = SNDRV_PCM_DEFAULT_CON_SPDIF & 0xffff; in snd_ymfpci_memalloc()
2174 snd_ymfpci_writew(chip, YDSXGR_SPDIFOUTCTRL, 0); in snd_ymfpci_memalloc()
2175 snd_ymfpci_writew(chip, YDSXGR_SPDIFOUTSTATUS, chip->spdif_bits); in snd_ymfpci_memalloc()
2178 snd_ymfpci_writew(chip, YDSXGR_SPDIFINCTRL, 0); in snd_ymfpci_memalloc()
2182 snd_ymfpci_writel(chip, reg, 0); in snd_ymfpci_memalloc()
2183 snd_ymfpci_writel(chip, YDSXGR_NATIVEDACOUTVOL, 0x3fff3fff); in snd_ymfpci_memalloc()
2184 snd_ymfpci_writel(chip, YDSXGR_BUF441OUTVOL, 0x3fff3fff); in snd_ymfpci_memalloc()
2185 snd_ymfpci_writel(chip, YDSXGR_ZVOUTVOL, 0x3fff3fff); in snd_ymfpci_memalloc()
2186 snd_ymfpci_writel(chip, YDSXGR_SPDIFOUTVOL, 0x3fff3fff); in snd_ymfpci_memalloc()
2187 snd_ymfpci_writel(chip, YDSXGR_NATIVEADCINVOL, 0x3fff3fff); in snd_ymfpci_memalloc()
2188 snd_ymfpci_writel(chip, YDSXGR_NATIVEDACINVOL, 0x3fff3fff); in snd_ymfpci_memalloc()
2189 snd_ymfpci_writel(chip, YDSXGR_PRIADCLOOPVOL, 0x3fff3fff); in snd_ymfpci_memalloc()
2190 snd_ymfpci_writel(chip, YDSXGR_LEGACYOUTVOL, 0x3fff3fff); in snd_ymfpci_memalloc()
2197 struct snd_ymfpci *chip = card->private_data; in snd_ymfpci_free() local
2200 snd_ymfpci_writel(chip, YDSXGR_NATIVEDACOUTVOL, 0); in snd_ymfpci_free()
2201 snd_ymfpci_writel(chip, YDSXGR_BUF441OUTVOL, 0); in snd_ymfpci_free()
2202 snd_ymfpci_writel(chip, YDSXGR_LEGACYOUTVOL, 0); in snd_ymfpci_free()
2203 snd_ymfpci_writel(chip, YDSXGR_STATUS, ~0); in snd_ymfpci_free()
2204 snd_ymfpci_disable_dsp(chip); in snd_ymfpci_free()
2205 snd_ymfpci_writel(chip, YDSXGR_PLAYCTRLBASE, 0); in snd_ymfpci_free()
2206 snd_ymfpci_writel(chip, YDSXGR_RECCTRLBASE, 0); in snd_ymfpci_free()
2207 snd_ymfpci_writel(chip, YDSXGR_EFFCTRLBASE, 0); in snd_ymfpci_free()
2208 snd_ymfpci_writel(chip, YDSXGR_WORKBASE, 0); in snd_ymfpci_free()
2209 snd_ymfpci_writel(chip, YDSXGR_WORKSIZE, 0); in snd_ymfpci_free()
2210 ctrl = snd_ymfpci_readw(chip, YDSXGR_GLOBALCTRL); in snd_ymfpci_free()
2211 snd_ymfpci_writew(chip, YDSXGR_GLOBALCTRL, ctrl & ~0x0007); in snd_ymfpci_free()
2213 snd_ymfpci_ac3_done(chip); in snd_ymfpci_free()
2215 snd_ymfpci_free_gameport(chip); in snd_ymfpci_free()
2217 pci_write_config_word(chip->pci, PCIR_DSXG_LEGACY, chip->old_legacy_ctrl); in snd_ymfpci_free()
2219 release_firmware(chip->dsp_microcode); in snd_ymfpci_free()
2220 release_firmware(chip->controller_microcode); in snd_ymfpci_free()
2226 struct snd_ymfpci *chip = card->private_data; in snd_ymfpci_suspend() local
2229 if (chip->pci->device >= 0x0010) /* YMF 744/754 */ in snd_ymfpci_suspend()
2233 snd_ac97_suspend(chip->ac97); in snd_ymfpci_suspend()
2236 chip->saved_regs[i] = snd_ymfpci_readl(chip, saved_regs_index[i]); in snd_ymfpci_suspend()
2238 chip->saved_ydsxgr_mode = snd_ymfpci_readl(chip, YDSXGR_MODE); in snd_ymfpci_suspend()
2241 pci_read_config_word(chip->pci, pci_saved_regs_index[i], in snd_ymfpci_suspend()
2242 chip->saved_dsxg_pci_regs + i); in snd_ymfpci_suspend()
2244 snd_ymfpci_writel(chip, YDSXGR_NATIVEDACOUTVOL, 0); in snd_ymfpci_suspend()
2245 snd_ymfpci_writel(chip, YDSXGR_BUF441OUTVOL, 0); in snd_ymfpci_suspend()
2246 snd_ymfpci_disable_dsp(chip); in snd_ymfpci_suspend()
2254 struct snd_ymfpci *chip = card->private_data; in snd_ymfpci_resume() local
2257 if (chip->pci->device >= 0x0010) /* YMF 744/754 */ in snd_ymfpci_resume()
2261 snd_ymfpci_codec_ready(chip, 0); in snd_ymfpci_resume()
2262 snd_ymfpci_download_image(chip); in snd_ymfpci_resume()
2266 snd_ymfpci_writel(chip, saved_regs_index[i], chip->saved_regs[i]); in snd_ymfpci_resume()
2268 snd_ac97_resume(chip->ac97); in snd_ymfpci_resume()
2271 pci_write_config_word(chip->pci, pci_saved_regs_index[i], in snd_ymfpci_resume()
2272 chip->saved_dsxg_pci_regs[i]); in snd_ymfpci_resume()
2275 if (chip->start_count > 0) { in snd_ymfpci_resume()
2276 spin_lock_irq(&chip->reg_lock); in snd_ymfpci_resume()
2277 snd_ymfpci_writel(chip, YDSXGR_MODE, chip->saved_ydsxgr_mode); in snd_ymfpci_resume()
2278 chip->active_bank = snd_ymfpci_readl(chip, YDSXGR_CTRLSELECT); in snd_ymfpci_resume()
2279 spin_unlock_irq(&chip->reg_lock); in snd_ymfpci_resume()
2291 struct snd_ymfpci *chip = card->private_data; in snd_ymfpci_create() local
2299 chip->old_legacy_ctrl = old_legacy_ctrl; in snd_ymfpci_create()
2300 spin_lock_init(&chip->reg_lock); in snd_ymfpci_create()
2301 spin_lock_init(&chip->voice_lock); in snd_ymfpci_create()
2302 init_waitqueue_head(&chip->interrupt_sleep); in snd_ymfpci_create()
2303 atomic_set(&chip->interrupt_sleep_count, 0); in snd_ymfpci_create()
2304 chip->card = card; in snd_ymfpci_create()
2305 chip->pci = pci; in snd_ymfpci_create()
2306 chip->irq = -1; in snd_ymfpci_create()
2307 chip->device_id = pci->device; in snd_ymfpci_create()
2308 chip->rev = pci->revision; in snd_ymfpci_create()
2314 chip->reg_area_phys = pci_resource_start(pci, 0); in snd_ymfpci_create()
2315 chip->reg_area_virt = devm_ioremap(&pci->dev, chip->reg_area_phys, 0x8000); in snd_ymfpci_create()
2316 if (!chip->reg_area_virt) { in snd_ymfpci_create()
2317 dev_err(chip->card->dev, in snd_ymfpci_create()
2319 chip->reg_area_phys, chip->reg_area_phys + 0x8000 - 1); in snd_ymfpci_create()
2323 chip->src441_used = -1; in snd_ymfpci_create()
2326 KBUILD_MODNAME, chip)) { in snd_ymfpci_create()
2327 dev_err(chip->card->dev, "unable to grab IRQ %d\n", pci->irq); in snd_ymfpci_create()
2330 chip->irq = pci->irq; in snd_ymfpci_create()
2331 card->sync_irq = chip->irq; in snd_ymfpci_create()
2335 if (snd_ymfpci_codec_ready(chip, 0) < 0) in snd_ymfpci_create()
2338 err = snd_ymfpci_request_firmware(chip); in snd_ymfpci_create()
2340 dev_err(chip->card->dev, "firmware request failed: %d\n", err); in snd_ymfpci_create()
2343 snd_ymfpci_download_image(chip); in snd_ymfpci_create()
2347 if (snd_ymfpci_memalloc(chip) < 0) in snd_ymfpci_create()
2350 err = snd_ymfpci_ac3_init(chip); in snd_ymfpci_create()
2354 snd_ymfpci_proc_init(card, chip); in snd_ymfpci_create()