Lines Matching full:chip
32 static void snd_ymfpci_irq_wait(struct snd_ymfpci *chip);
34 static inline u8 snd_ymfpci_readb(struct snd_ymfpci *chip, u32 offset) in snd_ymfpci_readb() argument
36 return readb(chip->reg_area_virt + offset); in snd_ymfpci_readb()
39 static inline void snd_ymfpci_writeb(struct snd_ymfpci *chip, u32 offset, u8 val) in snd_ymfpci_writeb() argument
41 writeb(val, chip->reg_area_virt + offset); in snd_ymfpci_writeb()
44 static inline u16 snd_ymfpci_readw(struct snd_ymfpci *chip, u32 offset) in snd_ymfpci_readw() argument
46 return readw(chip->reg_area_virt + offset); in snd_ymfpci_readw()
49 static inline void snd_ymfpci_writew(struct snd_ymfpci *chip, u32 offset, u16 val) in snd_ymfpci_writew() argument
51 writew(val, chip->reg_area_virt + offset); in snd_ymfpci_writew()
54 static inline u32 snd_ymfpci_readl(struct snd_ymfpci *chip, u32 offset) in snd_ymfpci_readl() argument
56 return readl(chip->reg_area_virt + offset); in snd_ymfpci_readl()
59 static inline void snd_ymfpci_writel(struct snd_ymfpci *chip, u32 offset, u32 val) in snd_ymfpci_writel() argument
61 writel(val, chip->reg_area_virt + offset); in snd_ymfpci_writel()
64 static int snd_ymfpci_codec_ready(struct snd_ymfpci *chip, int secondary) in snd_ymfpci_codec_ready() argument
71 if ((snd_ymfpci_readw(chip, reg) & 0x8000) == 0) in snd_ymfpci_codec_ready()
75 dev_err(chip->card->dev, in snd_ymfpci_codec_ready()
77 secondary, snd_ymfpci_readw(chip, reg)); in snd_ymfpci_codec_ready()
83 struct snd_ymfpci *chip = ac97->private_data; in snd_ymfpci_codec_write() local
86 snd_ymfpci_codec_ready(chip, 0); in snd_ymfpci_codec_write()
88 snd_ymfpci_writel(chip, YDSXGR_AC97CMDDATA, cmd); in snd_ymfpci_codec_write()
93 struct snd_ymfpci *chip = ac97->private_data; in snd_ymfpci_codec_read() local
95 if (snd_ymfpci_codec_ready(chip, 0)) in snd_ymfpci_codec_read()
97 snd_ymfpci_writew(chip, YDSXGR_AC97CMDADR, YDSXG_AC97READCMD | reg); in snd_ymfpci_codec_read()
98 if (snd_ymfpci_codec_ready(chip, 0)) in snd_ymfpci_codec_read()
100 if (chip->device_id == PCI_DEVICE_ID_YAMAHA_744 && chip->rev < 2) { in snd_ymfpci_codec_read()
103 snd_ymfpci_readw(chip, YDSXGR_PRISTATUSDATA); in snd_ymfpci_codec_read()
105 return snd_ymfpci_readw(chip, YDSXGR_PRISTATUSDATA); in snd_ymfpci_codec_read()
165 static void snd_ymfpci_hw_start(struct snd_ymfpci *chip) in snd_ymfpci_hw_start() argument
169 spin_lock_irqsave(&chip->reg_lock, flags); in snd_ymfpci_hw_start()
170 if (chip->start_count++ > 0) in snd_ymfpci_hw_start()
172 snd_ymfpci_writel(chip, YDSXGR_MODE, in snd_ymfpci_hw_start()
173 snd_ymfpci_readl(chip, YDSXGR_MODE) | 3); in snd_ymfpci_hw_start()
174 chip->active_bank = snd_ymfpci_readl(chip, YDSXGR_CTRLSELECT) & 1; in snd_ymfpci_hw_start()
176 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_ymfpci_hw_start()
179 static void snd_ymfpci_hw_stop(struct snd_ymfpci *chip) in snd_ymfpci_hw_stop() argument
184 spin_lock_irqsave(&chip->reg_lock, flags); in snd_ymfpci_hw_stop()
185 if (--chip->start_count > 0) in snd_ymfpci_hw_stop()
187 snd_ymfpci_writel(chip, YDSXGR_MODE, in snd_ymfpci_hw_stop()
188 snd_ymfpci_readl(chip, YDSXGR_MODE) & ~3); in snd_ymfpci_hw_stop()
190 if ((snd_ymfpci_readl(chip, YDSXGR_STATUS) & 2) == 0) in snd_ymfpci_hw_stop()
193 if (atomic_read(&chip->interrupt_sleep_count)) { in snd_ymfpci_hw_stop()
194 atomic_set(&chip->interrupt_sleep_count, 0); in snd_ymfpci_hw_stop()
195 wake_up(&chip->interrupt_sleep); in snd_ymfpci_hw_stop()
198 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_ymfpci_hw_stop()
205 static int voice_alloc(struct snd_ymfpci *chip, in voice_alloc() argument
214 voice = &chip->voices[idx]; in voice_alloc()
215 voice2 = pair ? &chip->voices[idx+1] : NULL; in voice_alloc()
234 snd_ymfpci_hw_start(chip); in voice_alloc()
236 snd_ymfpci_hw_start(chip); in voice_alloc()
243 static int snd_ymfpci_voice_alloc(struct snd_ymfpci *chip, in snd_ymfpci_voice_alloc() argument
255 spin_lock_irqsave(&chip->voice_lock, flags); in snd_ymfpci_voice_alloc()
257 result = voice_alloc(chip, type, pair, rvoice); in snd_ymfpci_voice_alloc()
263 spin_unlock_irqrestore(&chip->voice_lock, flags); in snd_ymfpci_voice_alloc()
267 static int snd_ymfpci_voice_free(struct snd_ymfpci *chip, struct snd_ymfpci_voice *pvoice) in snd_ymfpci_voice_free() argument
273 snd_ymfpci_hw_stop(chip); in snd_ymfpci_voice_free()
274 spin_lock_irqsave(&chip->voice_lock, flags); in snd_ymfpci_voice_free()
275 if (pvoice->number == chip->src441_used) { in snd_ymfpci_voice_free()
276 chip->src441_used = -1; in snd_ymfpci_voice_free()
282 spin_unlock_irqrestore(&chip->voice_lock, flags); in snd_ymfpci_voice_free()
290 static void snd_ymfpci_pcm_interrupt(struct snd_ymfpci *chip, struct snd_ymfpci_voice *voice) in snd_ymfpci_pcm_interrupt() argument
299 spin_lock(&chip->reg_lock); in snd_ymfpci_pcm_interrupt()
301 pos = le32_to_cpu(voice->bank[chip->active_bank].start); in snd_ymfpci_pcm_interrupt()
310 dev_dbg(chip->card->dev, in snd_ymfpci_pcm_interrupt()
312 chip->active_bank, in snd_ymfpci_pcm_interrupt()
313 voice->bank[chip->active_bank].start); in snd_ymfpci_pcm_interrupt()
316 spin_unlock(&chip->reg_lock); in snd_ymfpci_pcm_interrupt()
318 spin_lock(&chip->reg_lock); in snd_ymfpci_pcm_interrupt()
323 unsigned int next_bank = 1 - chip->active_bank; in snd_ymfpci_pcm_interrupt()
328 volume = cpu_to_le32(chip->pcm_mixer[subs].left << 15); in snd_ymfpci_pcm_interrupt()
334 volume = cpu_to_le32(chip->pcm_mixer[subs].right << 15); in snd_ymfpci_pcm_interrupt()
341 spin_unlock(&chip->reg_lock); in snd_ymfpci_pcm_interrupt()
348 struct snd_ymfpci *chip = ypcm->chip; in snd_ymfpci_pcm_capture_interrupt() local
351 spin_lock(&chip->reg_lock); in snd_ymfpci_pcm_capture_interrupt()
353 …pos = le32_to_cpu(chip->bank_capture[ypcm->capture_bank_number][chip->active_bank]->start) >> ypcm… in snd_ymfpci_pcm_capture_interrupt()
363 dev_dbg(chip->card->dev, in snd_ymfpci_pcm_capture_interrupt()
365 chip->active_bank, in snd_ymfpci_pcm_capture_interrupt()
366 voice->bank[chip->active_bank].start); in snd_ymfpci_pcm_capture_interrupt()
368 spin_unlock(&chip->reg_lock); in snd_ymfpci_pcm_capture_interrupt()
370 spin_lock(&chip->reg_lock); in snd_ymfpci_pcm_capture_interrupt()
373 spin_unlock(&chip->reg_lock); in snd_ymfpci_pcm_capture_interrupt()
379 struct snd_ymfpci *chip = snd_pcm_substream_chip(substream); in snd_ymfpci_playback_trigger() local
384 spin_lock(&chip->reg_lock); in snd_ymfpci_playback_trigger()
393 chip->ctrl_playback[ypcm->voices[0]->number + 1] = cpu_to_le32(ypcm->voices[0]->bank_addr); in snd_ymfpci_playback_trigger()
395 chip->ctrl_playback[ypcm->voices[1]->number + 1] = cpu_to_le32(ypcm->voices[1]->bank_addr); in snd_ymfpci_playback_trigger()
399 if (substream->pcm == chip->pcm && !ypcm->use_441_slot) { in snd_ymfpci_playback_trigger()
400 kctl = chip->pcm_mixer[substream->number].ctl; in snd_ymfpci_playback_trigger()
406 chip->ctrl_playback[ypcm->voices[0]->number + 1] = 0; in snd_ymfpci_playback_trigger()
408 chip->ctrl_playback[ypcm->voices[1]->number + 1] = 0; in snd_ymfpci_playback_trigger()
416 spin_unlock(&chip->reg_lock); in snd_ymfpci_playback_trigger()
418 snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_INFO, &kctl->id); in snd_ymfpci_playback_trigger()
424 struct snd_ymfpci *chip = snd_pcm_substream_chip(substream); in snd_ymfpci_capture_trigger() local
429 spin_lock(&chip->reg_lock); in snd_ymfpci_capture_trigger()
434 tmp = snd_ymfpci_readl(chip, YDSXGR_MAPOFREC) | (1 << ypcm->capture_bank_number); in snd_ymfpci_capture_trigger()
435 snd_ymfpci_writel(chip, YDSXGR_MAPOFREC, tmp); in snd_ymfpci_capture_trigger()
441 tmp = snd_ymfpci_readl(chip, YDSXGR_MAPOFREC) & ~(1 << ypcm->capture_bank_number); in snd_ymfpci_capture_trigger()
442 snd_ymfpci_writel(chip, YDSXGR_MAPOFREC, tmp); in snd_ymfpci_capture_trigger()
449 spin_unlock(&chip->reg_lock); in snd_ymfpci_capture_trigger()
458 snd_ymfpci_voice_free(ypcm->chip, ypcm->voices[1]); in snd_ymfpci_pcm_voice_alloc()
467 snd_ymfpci_voice_free(ypcm->chip, ypcm->voices[0]); in snd_ymfpci_pcm_voice_alloc()
471 err = snd_ymfpci_voice_alloc(ypcm->chip, YMFPCI_PCM, voices > 1, &ypcm->voices[0]); in snd_ymfpci_pcm_voice_alloc()
477 ypcm->voices[1] = &ypcm->chip->voices[ypcm->voices[0]->number + 1]; in snd_ymfpci_pcm_voice_alloc()
508 vol_left = cpu_to_le32(ypcm->chip->pcm_mixer in snd_ymfpci_pcm_init_voice()
510 vol_right = cpu_to_le32(ypcm->chip->pcm_mixer in snd_ymfpci_pcm_init_voice()
516 spin_lock_irqsave(&ypcm->chip->voice_lock, flags); in snd_ymfpci_pcm_init_voice()
520 else if (ypcm->chip->device_id == PCI_DEVICE_ID_YAMAHA_754 && in snd_ymfpci_pcm_init_voice()
522 voiceidx == 0 && (ypcm->chip->src441_used == -1 || in snd_ymfpci_pcm_init_voice()
523 ypcm->chip->src441_used == voice->number)) { in snd_ymfpci_pcm_init_voice()
524 ypcm->chip->src441_used = voice->number; in snd_ymfpci_pcm_init_voice()
528 if (ypcm->chip->src441_used == voice->number && in snd_ymfpci_pcm_init_voice()
530 ypcm->chip->src441_used = -1; in snd_ymfpci_pcm_init_voice()
535 spin_unlock_irqrestore(&ypcm->chip->voice_lock, flags); in snd_ymfpci_pcm_init_voice()
588 static int snd_ymfpci_ac3_init(struct snd_ymfpci *chip) in snd_ymfpci_ac3_init() argument
590 if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(chip->pci), in snd_ymfpci_ac3_init()
591 4096, &chip->ac3_tmp_base) < 0) in snd_ymfpci_ac3_init()
594 chip->bank_effect[3][0]->base = in snd_ymfpci_ac3_init()
595 chip->bank_effect[3][1]->base = cpu_to_le32(chip->ac3_tmp_base.addr); in snd_ymfpci_ac3_init()
596 chip->bank_effect[3][0]->loop_end = in snd_ymfpci_ac3_init()
597 chip->bank_effect[3][1]->loop_end = cpu_to_le32(1024); in snd_ymfpci_ac3_init()
598 chip->bank_effect[4][0]->base = in snd_ymfpci_ac3_init()
599 chip->bank_effect[4][1]->base = cpu_to_le32(chip->ac3_tmp_base.addr + 2048); in snd_ymfpci_ac3_init()
600 chip->bank_effect[4][0]->loop_end = in snd_ymfpci_ac3_init()
601 chip->bank_effect[4][1]->loop_end = cpu_to_le32(1024); in snd_ymfpci_ac3_init()
603 spin_lock_irq(&chip->reg_lock); in snd_ymfpci_ac3_init()
604 snd_ymfpci_writel(chip, YDSXGR_MAPOFEFFECT, in snd_ymfpci_ac3_init()
605 snd_ymfpci_readl(chip, YDSXGR_MAPOFEFFECT) | 3 << 3); in snd_ymfpci_ac3_init()
606 spin_unlock_irq(&chip->reg_lock); in snd_ymfpci_ac3_init()
610 static int snd_ymfpci_ac3_done(struct snd_ymfpci *chip) in snd_ymfpci_ac3_done() argument
612 spin_lock_irq(&chip->reg_lock); in snd_ymfpci_ac3_done()
613 snd_ymfpci_writel(chip, YDSXGR_MAPOFEFFECT, in snd_ymfpci_ac3_done()
614 snd_ymfpci_readl(chip, YDSXGR_MAPOFEFFECT) & ~(3 << 3)); in snd_ymfpci_ac3_done()
615 spin_unlock_irq(&chip->reg_lock); in snd_ymfpci_ac3_done()
616 // snd_ymfpci_irq_wait(chip); in snd_ymfpci_ac3_done()
617 if (chip->ac3_tmp_base.area) { in snd_ymfpci_ac3_done()
618 snd_dma_free_pages(&chip->ac3_tmp_base); in snd_ymfpci_ac3_done()
619 chip->ac3_tmp_base.area = NULL; in snd_ymfpci_ac3_done()
640 struct snd_ymfpci *chip = snd_pcm_substream_chip(substream); in snd_ymfpci_playback_hw_free() local
649 snd_ymfpci_irq_wait(chip); in snd_ymfpci_playback_hw_free()
652 snd_ymfpci_voice_free(chip, ypcm->voices[1]); in snd_ymfpci_playback_hw_free()
656 snd_ymfpci_voice_free(chip, ypcm->voices[0]); in snd_ymfpci_playback_hw_free()
664 struct snd_ymfpci *chip = snd_pcm_substream_chip(substream); in snd_ymfpci_playback_prepare() local
676 substream->pcm == chip->pcm); in snd_ymfpci_playback_prepare()
678 if (substream->pcm == chip->pcm && !ypcm->use_441_slot) { in snd_ymfpci_playback_prepare()
679 kctl = chip->pcm_mixer[substream->number].ctl; in snd_ymfpci_playback_prepare()
681 snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_INFO, &kctl->id); in snd_ymfpci_playback_prepare()
694 struct snd_ymfpci *chip = snd_pcm_substream_chip(substream); in snd_ymfpci_capture_hw_free() local
697 snd_ymfpci_irq_wait(chip); in snd_ymfpci_capture_hw_free()
703 struct snd_ymfpci *chip = snd_pcm_substream_chip(substream); in snd_ymfpci_capture_prepare() local
727 snd_ymfpci_writel(chip, YDSXGR_RECFORMAT, format); in snd_ymfpci_capture_prepare()
728 snd_ymfpci_writel(chip, YDSXGR_RECSLOTSR, rate); in snd_ymfpci_capture_prepare()
731 snd_ymfpci_writel(chip, YDSXGR_ADCFORMAT, format); in snd_ymfpci_capture_prepare()
732 snd_ymfpci_writel(chip, YDSXGR_ADCSLOTSR, rate); in snd_ymfpci_capture_prepare()
736 bank = chip->bank_capture[ypcm->capture_bank_number][nbank]; in snd_ymfpci_capture_prepare()
747 struct snd_ymfpci *chip = snd_pcm_substream_chip(substream); in snd_ymfpci_playback_pointer() local
754 return le32_to_cpu(voice->bank[chip->active_bank].start); in snd_ymfpci_playback_pointer()
759 struct snd_ymfpci *chip = snd_pcm_substream_chip(substream); in snd_ymfpci_capture_pointer() local
765 …return le32_to_cpu(chip->bank_capture[ypcm->capture_bank_number][chip->active_bank]->start) >> ypc… in snd_ymfpci_capture_pointer()
768 static void snd_ymfpci_irq_wait(struct snd_ymfpci *chip) in snd_ymfpci_irq_wait() argument
774 if ((snd_ymfpci_readl(chip, YDSXGR_MODE) & 3) == 0) in snd_ymfpci_irq_wait()
777 add_wait_queue(&chip->interrupt_sleep, &wait); in snd_ymfpci_irq_wait()
778 atomic_inc(&chip->interrupt_sleep_count); in snd_ymfpci_irq_wait()
780 remove_wait_queue(&chip->interrupt_sleep, &wait); in snd_ymfpci_irq_wait()
786 struct snd_ymfpci *chip = dev_id; in snd_ymfpci_interrupt() local
790 status = snd_ymfpci_readl(chip, YDSXGR_STATUS); in snd_ymfpci_interrupt()
792 chip->active_bank = snd_ymfpci_readl(chip, YDSXGR_CTRLSELECT) & 1; in snd_ymfpci_interrupt()
793 spin_lock(&chip->voice_lock); in snd_ymfpci_interrupt()
795 voice = &chip->voices[nvoice]; in snd_ymfpci_interrupt()
797 voice->interrupt(chip, voice); in snd_ymfpci_interrupt()
800 if (chip->capture_substream[nvoice]) in snd_ymfpci_interrupt()
801 snd_ymfpci_pcm_capture_interrupt(chip->capture_substream[nvoice]); in snd_ymfpci_interrupt()
805 if (chip->effect_substream[nvoice]) in snd_ymfpci_interrupt()
806 snd_ymfpci_pcm_effect_interrupt(chip->effect_substream[nvoice]); in snd_ymfpci_interrupt()
809 spin_unlock(&chip->voice_lock); in snd_ymfpci_interrupt()
810 spin_lock(&chip->reg_lock); in snd_ymfpci_interrupt()
811 snd_ymfpci_writel(chip, YDSXGR_STATUS, 0x80000000); in snd_ymfpci_interrupt()
812 mode = snd_ymfpci_readl(chip, YDSXGR_MODE) | 2; in snd_ymfpci_interrupt()
813 snd_ymfpci_writel(chip, YDSXGR_MODE, mode); in snd_ymfpci_interrupt()
814 spin_unlock(&chip->reg_lock); in snd_ymfpci_interrupt()
816 if (atomic_read(&chip->interrupt_sleep_count)) { in snd_ymfpci_interrupt()
817 atomic_set(&chip->interrupt_sleep_count, 0); in snd_ymfpci_interrupt()
818 wake_up(&chip->interrupt_sleep); in snd_ymfpci_interrupt()
822 status = snd_ymfpci_readw(chip, YDSXGR_INTFLAG); in snd_ymfpci_interrupt()
824 if (chip->timer) in snd_ymfpci_interrupt()
825 snd_timer_interrupt(chip->timer, chip->timer_ticks); in snd_ymfpci_interrupt()
827 snd_ymfpci_writew(chip, YDSXGR_INTFLAG, status); in snd_ymfpci_interrupt()
829 if (chip->rawmidi) in snd_ymfpci_interrupt()
830 snd_mpu401_uart_interrupt(irq, chip->rawmidi->private_data); in snd_ymfpci_interrupt()
885 struct snd_ymfpci *chip = snd_pcm_substream_chip(substream); in snd_ymfpci_playback_open_1() local
904 ypcm->chip = chip; in snd_ymfpci_playback_open_1()
913 static void ymfpci_open_extension(struct snd_ymfpci *chip) in ymfpci_open_extension() argument
915 if (! chip->rear_opened) { in ymfpci_open_extension()
916 if (! chip->spdif_opened) /* set AC3 */ in ymfpci_open_extension()
917 snd_ymfpci_writel(chip, YDSXGR_MODE, in ymfpci_open_extension()
918 snd_ymfpci_readl(chip, YDSXGR_MODE) | (1 << 30)); in ymfpci_open_extension()
920 snd_ymfpci_writew(chip, YDSXGR_SECCONFIG, in ymfpci_open_extension()
921 (snd_ymfpci_readw(chip, YDSXGR_SECCONFIG) & ~0x0330) | 0x0010); in ymfpci_open_extension()
926 static void ymfpci_close_extension(struct snd_ymfpci *chip) in ymfpci_close_extension() argument
928 if (! chip->rear_opened) { in ymfpci_close_extension()
929 if (! chip->spdif_opened) in ymfpci_close_extension()
930 snd_ymfpci_writel(chip, YDSXGR_MODE, in ymfpci_close_extension()
931 snd_ymfpci_readl(chip, YDSXGR_MODE) & ~(1 << 30)); in ymfpci_close_extension()
932 snd_ymfpci_writew(chip, YDSXGR_SECCONFIG, in ymfpci_close_extension()
933 (snd_ymfpci_readw(chip, YDSXGR_SECCONFIG) & ~0x0330) & ~0x0010); in ymfpci_close_extension()
939 struct snd_ymfpci *chip = snd_pcm_substream_chip(substream); in snd_ymfpci_playback_open() local
948 ypcm->output_rear = chip->mode_dup4ch ? 1 : 0; in snd_ymfpci_playback_open()
950 spin_lock_irq(&chip->reg_lock); in snd_ymfpci_playback_open()
952 ymfpci_open_extension(chip); in snd_ymfpci_playback_open()
953 chip->rear_opened++; in snd_ymfpci_playback_open()
955 spin_unlock_irq(&chip->reg_lock); in snd_ymfpci_playback_open()
961 struct snd_ymfpci *chip = snd_pcm_substream_chip(substream); in snd_ymfpci_playback_spdif_open() local
972 spin_lock_irq(&chip->reg_lock); in snd_ymfpci_playback_spdif_open()
973 snd_ymfpci_writew(chip, YDSXGR_SPDIFOUTCTRL, in snd_ymfpci_playback_spdif_open()
974 snd_ymfpci_readw(chip, YDSXGR_SPDIFOUTCTRL) | 2); in snd_ymfpci_playback_spdif_open()
975 ymfpci_open_extension(chip); in snd_ymfpci_playback_spdif_open()
976 chip->spdif_pcm_bits = chip->spdif_bits; in snd_ymfpci_playback_spdif_open()
977 snd_ymfpci_writew(chip, YDSXGR_SPDIFOUTSTATUS, chip->spdif_pcm_bits); in snd_ymfpci_playback_spdif_open()
978 chip->spdif_opened++; in snd_ymfpci_playback_spdif_open()
979 spin_unlock_irq(&chip->reg_lock); in snd_ymfpci_playback_spdif_open()
981 chip->spdif_pcm_ctl->vd[0].access &= ~SNDRV_CTL_ELEM_ACCESS_INACTIVE; in snd_ymfpci_playback_spdif_open()
982 snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE | in snd_ymfpci_playback_spdif_open()
983 SNDRV_CTL_EVENT_MASK_INFO, &chip->spdif_pcm_ctl->id); in snd_ymfpci_playback_spdif_open()
989 struct snd_ymfpci *chip = snd_pcm_substream_chip(substream); in snd_ymfpci_playback_4ch_open() local
1000 spin_lock_irq(&chip->reg_lock); in snd_ymfpci_playback_4ch_open()
1001 ymfpci_open_extension(chip); in snd_ymfpci_playback_4ch_open()
1002 chip->rear_opened++; in snd_ymfpci_playback_4ch_open()
1003 spin_unlock_irq(&chip->reg_lock); in snd_ymfpci_playback_4ch_open()
1010 struct snd_ymfpci *chip = snd_pcm_substream_chip(substream); in snd_ymfpci_capture_open() local
1029 ypcm->chip = chip; in snd_ymfpci_capture_open()
1033 chip->capture_substream[capture_bank_number] = substream; in snd_ymfpci_capture_open()
1036 snd_ymfpci_hw_start(chip); in snd_ymfpci_capture_open()
1057 struct snd_ymfpci *chip = snd_pcm_substream_chip(substream); in snd_ymfpci_playback_close() local
1060 spin_lock_irq(&chip->reg_lock); in snd_ymfpci_playback_close()
1061 if (ypcm->output_rear && chip->rear_opened > 0) { in snd_ymfpci_playback_close()
1062 chip->rear_opened--; in snd_ymfpci_playback_close()
1063 ymfpci_close_extension(chip); in snd_ymfpci_playback_close()
1065 spin_unlock_irq(&chip->reg_lock); in snd_ymfpci_playback_close()
1071 struct snd_ymfpci *chip = snd_pcm_substream_chip(substream); in snd_ymfpci_playback_spdif_close() local
1073 spin_lock_irq(&chip->reg_lock); in snd_ymfpci_playback_spdif_close()
1074 chip->spdif_opened = 0; in snd_ymfpci_playback_spdif_close()
1075 ymfpci_close_extension(chip); in snd_ymfpci_playback_spdif_close()
1076 snd_ymfpci_writew(chip, YDSXGR_SPDIFOUTCTRL, in snd_ymfpci_playback_spdif_close()
1077 snd_ymfpci_readw(chip, YDSXGR_SPDIFOUTCTRL) & ~2); in snd_ymfpci_playback_spdif_close()
1078 snd_ymfpci_writew(chip, YDSXGR_SPDIFOUTSTATUS, chip->spdif_bits); in snd_ymfpci_playback_spdif_close()
1079 spin_unlock_irq(&chip->reg_lock); in snd_ymfpci_playback_spdif_close()
1080 chip->spdif_pcm_ctl->vd[0].access |= SNDRV_CTL_ELEM_ACCESS_INACTIVE; in snd_ymfpci_playback_spdif_close()
1081 snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE | in snd_ymfpci_playback_spdif_close()
1082 SNDRV_CTL_EVENT_MASK_INFO, &chip->spdif_pcm_ctl->id); in snd_ymfpci_playback_spdif_close()
1088 struct snd_ymfpci *chip = snd_pcm_substream_chip(substream); in snd_ymfpci_playback_4ch_close() local
1090 spin_lock_irq(&chip->reg_lock); in snd_ymfpci_playback_4ch_close()
1091 if (chip->rear_opened > 0) { in snd_ymfpci_playback_4ch_close()
1092 chip->rear_opened--; in snd_ymfpci_playback_4ch_close()
1093 ymfpci_close_extension(chip); in snd_ymfpci_playback_4ch_close()
1095 spin_unlock_irq(&chip->reg_lock); in snd_ymfpci_playback_4ch_close()
1101 struct snd_ymfpci *chip = snd_pcm_substream_chip(substream); in snd_ymfpci_capture_close() local
1106 chip->capture_substream[ypcm->capture_bank_number] = NULL; in snd_ymfpci_capture_close()
1107 snd_ymfpci_hw_stop(chip); in snd_ymfpci_capture_close()
1134 int snd_ymfpci_pcm(struct snd_ymfpci *chip, int device) in snd_ymfpci_pcm() argument
1139 if ((err = snd_pcm_new(chip->card, "YMFPCI", device, 32, 1, &pcm)) < 0) in snd_ymfpci_pcm()
1141 pcm->private_data = chip; in snd_ymfpci_pcm()
1149 chip->pcm = pcm; in snd_ymfpci_pcm()
1152 snd_dma_pci_data(chip->pci), 64*1024, 256*1024); in snd_ymfpci_pcm()
1169 int snd_ymfpci_pcm2(struct snd_ymfpci *chip, int device) in snd_ymfpci_pcm2() argument
1174 if ((err = snd_pcm_new(chip->card, "YMFPCI - PCM2", device, 0, 1, &pcm)) < 0) in snd_ymfpci_pcm2()
1176 pcm->private_data = chip; in snd_ymfpci_pcm2()
1183 chip->device_id == PCI_DEVICE_ID_YAMAHA_754 ? "Direct Recording" : "AC'97"); in snd_ymfpci_pcm2()
1184 chip->pcm2 = pcm; in snd_ymfpci_pcm2()
1187 snd_dma_pci_data(chip->pci), 64*1024, 256*1024); in snd_ymfpci_pcm2()
1203 int snd_ymfpci_pcm_spdif(struct snd_ymfpci *chip, int device) in snd_ymfpci_pcm_spdif() argument
1208 if ((err = snd_pcm_new(chip->card, "YMFPCI - IEC958", device, 1, 0, &pcm)) < 0) in snd_ymfpci_pcm_spdif()
1210 pcm->private_data = chip; in snd_ymfpci_pcm_spdif()
1217 chip->pcm_spdif = pcm; in snd_ymfpci_pcm_spdif()
1220 snd_dma_pci_data(chip->pci), 64*1024, 256*1024); in snd_ymfpci_pcm_spdif()
1244 int snd_ymfpci_pcm_4ch(struct snd_ymfpci *chip, int device) in snd_ymfpci_pcm_4ch() argument
1249 if ((err = snd_pcm_new(chip->card, "YMFPCI - Rear", device, 1, 0, &pcm)) < 0) in snd_ymfpci_pcm_4ch()
1251 pcm->private_data = chip; in snd_ymfpci_pcm_4ch()
1258 chip->pcm_4ch = pcm; in snd_ymfpci_pcm_4ch()
1261 snd_dma_pci_data(chip->pci), 64*1024, 256*1024); in snd_ymfpci_pcm_4ch()
1277 struct snd_ymfpci *chip = snd_kcontrol_chip(kcontrol); in snd_ymfpci_spdif_default_get() local
1279 spin_lock_irq(&chip->reg_lock); in snd_ymfpci_spdif_default_get()
1280 ucontrol->value.iec958.status[0] = (chip->spdif_bits >> 0) & 0xff; in snd_ymfpci_spdif_default_get()
1281 ucontrol->value.iec958.status[1] = (chip->spdif_bits >> 8) & 0xff; in snd_ymfpci_spdif_default_get()
1283 spin_unlock_irq(&chip->reg_lock); in snd_ymfpci_spdif_default_get()
1290 struct snd_ymfpci *chip = snd_kcontrol_chip(kcontrol); in snd_ymfpci_spdif_default_put() local
1296 spin_lock_irq(&chip->reg_lock); in snd_ymfpci_spdif_default_put()
1297 change = chip->spdif_bits != val; in snd_ymfpci_spdif_default_put()
1298 chip->spdif_bits = val; in snd_ymfpci_spdif_default_put()
1299 if ((snd_ymfpci_readw(chip, YDSXGR_SPDIFOUTCTRL) & 1) && chip->pcm_spdif == NULL) in snd_ymfpci_spdif_default_put()
1300 snd_ymfpci_writew(chip, YDSXGR_SPDIFOUTSTATUS, chip->spdif_bits); in snd_ymfpci_spdif_default_put()
1301 spin_unlock_irq(&chip->reg_lock); in snd_ymfpci_spdif_default_put()
1324 struct snd_ymfpci *chip = snd_kcontrol_chip(kcontrol); in snd_ymfpci_spdif_mask_get() local
1326 spin_lock_irq(&chip->reg_lock); in snd_ymfpci_spdif_mask_get()
1329 spin_unlock_irq(&chip->reg_lock); in snd_ymfpci_spdif_mask_get()
1352 struct snd_ymfpci *chip = snd_kcontrol_chip(kcontrol); in snd_ymfpci_spdif_stream_get() local
1354 spin_lock_irq(&chip->reg_lock); in snd_ymfpci_spdif_stream_get()
1355 ucontrol->value.iec958.status[0] = (chip->spdif_pcm_bits >> 0) & 0xff; in snd_ymfpci_spdif_stream_get()
1356 ucontrol->value.iec958.status[1] = (chip->spdif_pcm_bits >> 8) & 0xff; in snd_ymfpci_spdif_stream_get()
1358 spin_unlock_irq(&chip->reg_lock); in snd_ymfpci_spdif_stream_get()
1365 struct snd_ymfpci *chip = snd_kcontrol_chip(kcontrol); in snd_ymfpci_spdif_stream_put() local
1371 spin_lock_irq(&chip->reg_lock); in snd_ymfpci_spdif_stream_put()
1372 change = chip->spdif_pcm_bits != val; in snd_ymfpci_spdif_stream_put()
1373 chip->spdif_pcm_bits = val; in snd_ymfpci_spdif_stream_put()
1374 if ((snd_ymfpci_readw(chip, YDSXGR_SPDIFOUTCTRL) & 2)) in snd_ymfpci_spdif_stream_put()
1375 snd_ymfpci_writew(chip, YDSXGR_SPDIFOUTSTATUS, chip->spdif_pcm_bits); in snd_ymfpci_spdif_stream_put()
1376 spin_unlock_irq(&chip->reg_lock); in snd_ymfpci_spdif_stream_put()
1399 struct snd_ymfpci *chip = snd_kcontrol_chip(kcontrol); in snd_ymfpci_drec_source_get() local
1402 spin_lock_irq(&chip->reg_lock); in snd_ymfpci_drec_source_get()
1403 reg = snd_ymfpci_readw(chip, YDSXGR_GLOBALCTRL); in snd_ymfpci_drec_source_get()
1404 spin_unlock_irq(&chip->reg_lock); in snd_ymfpci_drec_source_get()
1414 struct snd_ymfpci *chip = snd_kcontrol_chip(kcontrol); in snd_ymfpci_drec_source_put() local
1417 spin_lock_irq(&chip->reg_lock); in snd_ymfpci_drec_source_put()
1418 old_reg = snd_ymfpci_readw(chip, YDSXGR_GLOBALCTRL); in snd_ymfpci_drec_source_put()
1423 snd_ymfpci_writew(chip, YDSXGR_GLOBALCTRL, reg); in snd_ymfpci_drec_source_put()
1424 spin_unlock_irq(&chip->reg_lock); in snd_ymfpci_drec_source_put()
1452 struct snd_ymfpci *chip = snd_kcontrol_chip(kcontrol); in snd_ymfpci_get_single() local
1463 (snd_ymfpci_readl(chip, reg) >> shift) & mask; in snd_ymfpci_get_single()
1470 struct snd_ymfpci *chip = snd_kcontrol_chip(kcontrol); in snd_ymfpci_put_single() local
1484 spin_lock_irq(&chip->reg_lock); in snd_ymfpci_put_single()
1485 oval = snd_ymfpci_readl(chip, reg); in snd_ymfpci_put_single()
1488 snd_ymfpci_writel(chip, reg, val); in snd_ymfpci_put_single()
1489 spin_unlock_irq(&chip->reg_lock); in snd_ymfpci_put_single()
1518 struct snd_ymfpci *chip = snd_kcontrol_chip(kcontrol); in snd_ymfpci_get_double() local
1525 spin_lock_irq(&chip->reg_lock); in snd_ymfpci_get_double()
1526 val = snd_ymfpci_readl(chip, reg); in snd_ymfpci_get_double()
1527 spin_unlock_irq(&chip->reg_lock); in snd_ymfpci_get_double()
1535 struct snd_ymfpci *chip = snd_kcontrol_chip(kcontrol); in snd_ymfpci_put_double() local
1547 spin_lock_irq(&chip->reg_lock); in snd_ymfpci_put_double()
1548 oval = snd_ymfpci_readl(chip, reg); in snd_ymfpci_put_double()
1551 snd_ymfpci_writel(chip, reg, val1); in snd_ymfpci_put_double()
1552 spin_unlock_irq(&chip->reg_lock); in snd_ymfpci_put_double()
1559 struct snd_ymfpci *chip = snd_kcontrol_chip(kcontrol); in snd_ymfpci_put_nativedacvol() local
1567 spin_lock_irq(&chip->reg_lock); in snd_ymfpci_put_nativedacvol()
1568 oval = snd_ymfpci_readl(chip, reg); in snd_ymfpci_put_nativedacvol()
1570 snd_ymfpci_writel(chip, reg, value); in snd_ymfpci_put_nativedacvol()
1571 snd_ymfpci_writel(chip, reg2, value); in snd_ymfpci_put_nativedacvol()
1572 spin_unlock_irq(&chip->reg_lock); in snd_ymfpci_put_nativedacvol()
1583 struct snd_ymfpci *chip = snd_kcontrol_chip(kcontrol); in snd_ymfpci_get_dup4ch() local
1584 ucontrol->value.integer.value[0] = chip->mode_dup4ch; in snd_ymfpci_get_dup4ch()
1590 struct snd_ymfpci *chip = snd_kcontrol_chip(kcontrol); in snd_ymfpci_put_dup4ch() local
1592 change = (ucontrol->value.integer.value[0] != chip->mode_dup4ch); in snd_ymfpci_put_dup4ch()
1594 chip->mode_dup4ch = !!ucontrol->value.integer.value[0]; in snd_ymfpci_put_dup4ch()
1641 static int snd_ymfpci_get_gpio_out(struct snd_ymfpci *chip, int pin) in snd_ymfpci_get_gpio_out() argument
1646 spin_lock_irqsave(&chip->reg_lock, flags); in snd_ymfpci_get_gpio_out()
1647 reg = snd_ymfpci_readw(chip, YDSXGR_GPIOFUNCENABLE); in snd_ymfpci_get_gpio_out()
1650 snd_ymfpci_writew(chip, YDSXGR_GPIOFUNCENABLE, reg); in snd_ymfpci_get_gpio_out()
1652 mode = snd_ymfpci_readw(chip, YDSXGR_GPIOTYPECONFIG); in snd_ymfpci_get_gpio_out()
1654 snd_ymfpci_writew(chip, YDSXGR_GPIOTYPECONFIG, mode); in snd_ymfpci_get_gpio_out()
1655 snd_ymfpci_writew(chip, YDSXGR_GPIOFUNCENABLE, reg | (1 << (pin + 8))); in snd_ymfpci_get_gpio_out()
1656 mode = snd_ymfpci_readw(chip, YDSXGR_GPIOINSTATUS); in snd_ymfpci_get_gpio_out()
1657 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_ymfpci_get_gpio_out()
1661 static int snd_ymfpci_set_gpio_out(struct snd_ymfpci *chip, int pin, int enable) in snd_ymfpci_set_gpio_out() argument
1666 spin_lock_irqsave(&chip->reg_lock, flags); in snd_ymfpci_set_gpio_out()
1667 reg = snd_ymfpci_readw(chip, YDSXGR_GPIOFUNCENABLE); in snd_ymfpci_set_gpio_out()
1670 snd_ymfpci_writew(chip, YDSXGR_GPIOFUNCENABLE, reg); in snd_ymfpci_set_gpio_out()
1671 snd_ymfpci_writew(chip, YDSXGR_GPIOOUTCTRL, enable << pin); in snd_ymfpci_set_gpio_out()
1672 snd_ymfpci_writew(chip, YDSXGR_GPIOFUNCENABLE, reg | (1 << (pin + 8))); in snd_ymfpci_set_gpio_out()
1673 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_ymfpci_set_gpio_out()
1682 struct snd_ymfpci *chip = snd_kcontrol_chip(kcontrol); in snd_ymfpci_gpio_sw_get() local
1684 ucontrol->value.integer.value[0] = snd_ymfpci_get_gpio_out(chip, pin); in snd_ymfpci_gpio_sw_get()
1690 struct snd_ymfpci *chip = snd_kcontrol_chip(kcontrol); in snd_ymfpci_gpio_sw_put() local
1693 if (snd_ymfpci_get_gpio_out(chip, pin) != ucontrol->value.integer.value[0]) { in snd_ymfpci_gpio_sw_put()
1694 snd_ymfpci_set_gpio_out(chip, pin, !!ucontrol->value.integer.value[0]); in snd_ymfpci_gpio_sw_put()
1695 ucontrol->value.integer.value[0] = snd_ymfpci_get_gpio_out(chip, pin); in snd_ymfpci_gpio_sw_put()
1727 struct snd_ymfpci *chip = snd_kcontrol_chip(kcontrol); in snd_ymfpci_pcm_vol_get() local
1730 ucontrol->value.integer.value[0] = chip->pcm_mixer[subs].left; in snd_ymfpci_pcm_vol_get()
1731 ucontrol->value.integer.value[1] = chip->pcm_mixer[subs].right; in snd_ymfpci_pcm_vol_get()
1738 struct snd_ymfpci *chip = snd_kcontrol_chip(kcontrol); in snd_ymfpci_pcm_vol_put() local
1743 if (ucontrol->value.integer.value[0] != chip->pcm_mixer[subs].left || in snd_ymfpci_pcm_vol_put()
1744 ucontrol->value.integer.value[1] != chip->pcm_mixer[subs].right) { in snd_ymfpci_pcm_vol_put()
1745 chip->pcm_mixer[subs].left = ucontrol->value.integer.value[0]; in snd_ymfpci_pcm_vol_put()
1746 chip->pcm_mixer[subs].right = ucontrol->value.integer.value[1]; in snd_ymfpci_pcm_vol_put()
1747 if (chip->pcm_mixer[subs].left > 0x8000) in snd_ymfpci_pcm_vol_put()
1748 chip->pcm_mixer[subs].left = 0x8000; in snd_ymfpci_pcm_vol_put()
1749 if (chip->pcm_mixer[subs].right > 0x8000) in snd_ymfpci_pcm_vol_put()
1750 chip->pcm_mixer[subs].right = 0x8000; in snd_ymfpci_pcm_vol_put()
1753 spin_lock_irqsave(&chip->voice_lock, flags); in snd_ymfpci_pcm_vol_put()
1759 spin_unlock_irqrestore(&chip->voice_lock, flags); in snd_ymfpci_pcm_vol_put()
1782 struct snd_ymfpci *chip = bus->private_data; in snd_ymfpci_mixer_free_ac97_bus() local
1783 chip->ac97_bus = NULL; in snd_ymfpci_mixer_free_ac97_bus()
1788 struct snd_ymfpci *chip = ac97->private_data; in snd_ymfpci_mixer_free_ac97() local
1789 chip->ac97 = NULL; in snd_ymfpci_mixer_free_ac97()
1792 int snd_ymfpci_mixer(struct snd_ymfpci *chip, int rear_switch) in snd_ymfpci_mixer() argument
1804 if ((err = snd_ac97_bus(chip->card, 0, &ops, chip, &chip->ac97_bus)) < 0) in snd_ymfpci_mixer()
1806 chip->ac97_bus->private_free = snd_ymfpci_mixer_free_ac97_bus; in snd_ymfpci_mixer()
1807 chip->ac97_bus->no_vra = 1; /* YMFPCI doesn't need VRA */ in snd_ymfpci_mixer()
1810 ac97.private_data = chip; in snd_ymfpci_mixer()
1812 if ((err = snd_ac97_mixer(chip->ac97_bus, &ac97, &chip->ac97)) < 0) in snd_ymfpci_mixer()
1816 snd_ac97_update_bits(chip->ac97, AC97_EXTENDED_STATUS, in snd_ymfpci_mixer()
1820 if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_ymfpci_controls[idx], chip))) < 0) in snd_ymfpci_mixer()
1823 if (chip->ac97->ext_id & AC97_EI_SDAC) { in snd_ymfpci_mixer()
1824 kctl = snd_ctl_new1(&snd_ymfpci_dup4ch, chip); in snd_ymfpci_mixer()
1825 err = snd_ctl_add(chip->card, kctl); in snd_ymfpci_mixer()
1831 if (snd_BUG_ON(!chip->pcm_spdif)) in snd_ymfpci_mixer()
1833 if ((err = snd_ctl_add(chip->card, kctl = snd_ctl_new1(&snd_ymfpci_spdif_default, chip))) < 0) in snd_ymfpci_mixer()
1835 kctl->id.device = chip->pcm_spdif->device; in snd_ymfpci_mixer()
1836 if ((err = snd_ctl_add(chip->card, kctl = snd_ctl_new1(&snd_ymfpci_spdif_mask, chip))) < 0) in snd_ymfpci_mixer()
1838 kctl->id.device = chip->pcm_spdif->device; in snd_ymfpci_mixer()
1839 if ((err = snd_ctl_add(chip->card, kctl = snd_ctl_new1(&snd_ymfpci_spdif_stream, chip))) < 0) in snd_ymfpci_mixer()
1841 kctl->id.device = chip->pcm_spdif->device; in snd_ymfpci_mixer()
1842 chip->spdif_pcm_ctl = kctl; in snd_ymfpci_mixer()
1845 if (chip->device_id == PCI_DEVICE_ID_YAMAHA_754 && in snd_ymfpci_mixer()
1846 (err = snd_ctl_add(chip->card, kctl = snd_ctl_new1(&snd_ymfpci_drec_source, chip))) < 0) in snd_ymfpci_mixer()
1853 if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_ymfpci_rear_shared, chip))) < 0) in snd_ymfpci_mixer()
1858 substream = chip->pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; in snd_ymfpci_mixer()
1860 kctl = snd_ctl_new1(&snd_ymfpci_pcm_volume, chip); in snd_ymfpci_mixer()
1863 kctl->id.device = chip->pcm->device; in snd_ymfpci_mixer()
1866 if ((err = snd_ctl_add(chip->card, kctl)) < 0) in snd_ymfpci_mixer()
1868 chip->pcm_mixer[idx].left = 0x8000; in snd_ymfpci_mixer()
1869 chip->pcm_mixer[idx].right = 0x8000; in snd_ymfpci_mixer()
1870 chip->pcm_mixer[idx].ctl = kctl; in snd_ymfpci_mixer()
1884 struct snd_ymfpci *chip; in snd_ymfpci_timer_start() local
1888 chip = snd_timer_chip(timer); in snd_ymfpci_timer_start()
1889 spin_lock_irqsave(&chip->reg_lock, flags); in snd_ymfpci_timer_start()
1891 chip->timer_ticks = timer->sticks; in snd_ymfpci_timer_start()
1898 chip->timer_ticks = 2; in snd_ymfpci_timer_start()
1901 snd_ymfpci_writew(chip, YDSXGR_TIMERCOUNT, count); in snd_ymfpci_timer_start()
1902 snd_ymfpci_writeb(chip, YDSXGR_TIMERCTRL, 0x03); in snd_ymfpci_timer_start()
1903 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_ymfpci_timer_start()
1909 struct snd_ymfpci *chip; in snd_ymfpci_timer_stop() local
1912 chip = snd_timer_chip(timer); in snd_ymfpci_timer_stop()
1913 spin_lock_irqsave(&chip->reg_lock, flags); in snd_ymfpci_timer_stop()
1914 snd_ymfpci_writeb(chip, YDSXGR_TIMERCTRL, 0x00); in snd_ymfpci_timer_stop()
1915 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_ymfpci_timer_stop()
1936 int snd_ymfpci_timer(struct snd_ymfpci *chip, int device) in snd_ymfpci_timer() argument
1944 tid.card = chip->card->number; in snd_ymfpci_timer()
1947 if ((err = snd_timer_new(chip->card, "YMFPCI", &tid, &timer)) >= 0) { in snd_ymfpci_timer()
1949 timer->private_data = chip; in snd_ymfpci_timer()
1952 chip->timer = timer; in snd_ymfpci_timer()
1964 struct snd_ymfpci *chip = entry->private_data; in snd_ymfpci_proc_read() local
1969 snd_iprintf(buffer, "%04x: %04x\n", i, snd_ymfpci_readl(chip, i)); in snd_ymfpci_proc_read()
1972 static int snd_ymfpci_proc_init(struct snd_card *card, struct snd_ymfpci *chip) in snd_ymfpci_proc_init() argument
1974 return snd_card_ro_proc_new(card, "ymfpci", chip, snd_ymfpci_proc_read); in snd_ymfpci_proc_init()
1999 static void snd_ymfpci_enable_dsp(struct snd_ymfpci *chip) in snd_ymfpci_enable_dsp() argument
2001 snd_ymfpci_writel(chip, YDSXGR_CONFIG, 0x00000001); in snd_ymfpci_enable_dsp()
2004 static void snd_ymfpci_disable_dsp(struct snd_ymfpci *chip) in snd_ymfpci_disable_dsp() argument
2009 val = snd_ymfpci_readl(chip, YDSXGR_CONFIG); in snd_ymfpci_disable_dsp()
2011 snd_ymfpci_writel(chip, YDSXGR_CONFIG, 0x00000000); in snd_ymfpci_disable_dsp()
2013 val = snd_ymfpci_readl(chip, YDSXGR_STATUS); in snd_ymfpci_disable_dsp()
2019 static int snd_ymfpci_request_firmware(struct snd_ymfpci *chip) in snd_ymfpci_request_firmware() argument
2024 err = request_firmware(&chip->dsp_microcode, "yamaha/ds1_dsp.fw", in snd_ymfpci_request_firmware()
2025 &chip->pci->dev); in snd_ymfpci_request_firmware()
2027 if (chip->dsp_microcode->size != YDSXG_DSPLENGTH) { in snd_ymfpci_request_firmware()
2028 dev_err(chip->card->dev, in snd_ymfpci_request_firmware()
2035 is_1e = chip->device_id == PCI_DEVICE_ID_YAMAHA_724F || in snd_ymfpci_request_firmware()
2036 chip->device_id == PCI_DEVICE_ID_YAMAHA_740C || in snd_ymfpci_request_firmware()
2037 chip->device_id == PCI_DEVICE_ID_YAMAHA_744 || in snd_ymfpci_request_firmware()
2038 chip->device_id == PCI_DEVICE_ID_YAMAHA_754; in snd_ymfpci_request_firmware()
2040 err = request_firmware(&chip->controller_microcode, name, in snd_ymfpci_request_firmware()
2041 &chip->pci->dev); in snd_ymfpci_request_firmware()
2043 if (chip->controller_microcode->size != YDSXG_CTRLLENGTH) { in snd_ymfpci_request_firmware()
2044 dev_err(chip->card->dev, in snd_ymfpci_request_firmware()
2058 static void snd_ymfpci_download_image(struct snd_ymfpci *chip) in snd_ymfpci_download_image() argument
2064 snd_ymfpci_writel(chip, YDSXGR_NATIVEDACOUTVOL, 0x00000000); in snd_ymfpci_download_image()
2065 snd_ymfpci_disable_dsp(chip); in snd_ymfpci_download_image()
2066 snd_ymfpci_writel(chip, YDSXGR_MODE, 0x00010000); in snd_ymfpci_download_image()
2067 snd_ymfpci_writel(chip, YDSXGR_MODE, 0x00000000); in snd_ymfpci_download_image()
2068 snd_ymfpci_writel(chip, YDSXGR_MAPOFREC, 0x00000000); in snd_ymfpci_download_image()
2069 snd_ymfpci_writel(chip, YDSXGR_MAPOFEFFECT, 0x00000000); in snd_ymfpci_download_image()
2070 snd_ymfpci_writel(chip, YDSXGR_PLAYCTRLBASE, 0x00000000); in snd_ymfpci_download_image()
2071 snd_ymfpci_writel(chip, YDSXGR_RECCTRLBASE, 0x00000000); in snd_ymfpci_download_image()
2072 snd_ymfpci_writel(chip, YDSXGR_EFFCTRLBASE, 0x00000000); in snd_ymfpci_download_image()
2073 ctrl = snd_ymfpci_readw(chip, YDSXGR_GLOBALCTRL); in snd_ymfpci_download_image()
2074 snd_ymfpci_writew(chip, YDSXGR_GLOBALCTRL, ctrl & ~0x0007); in snd_ymfpci_download_image()
2077 inst = (const __le32 *)chip->dsp_microcode->data; in snd_ymfpci_download_image()
2079 snd_ymfpci_writel(chip, YDSXGR_DSPINSTRAM + (i << 2), in snd_ymfpci_download_image()
2083 inst = (const __le32 *)chip->controller_microcode->data; in snd_ymfpci_download_image()
2085 snd_ymfpci_writel(chip, YDSXGR_CTRLINSTRAM + (i << 2), in snd_ymfpci_download_image()
2088 snd_ymfpci_enable_dsp(chip); in snd_ymfpci_download_image()
2091 static int snd_ymfpci_memalloc(struct snd_ymfpci *chip) in snd_ymfpci_memalloc() argument
2099 chip->bank_size_playback = snd_ymfpci_readl(chip, YDSXGR_PLAYCTRLSIZE) << 2; in snd_ymfpci_memalloc()
2100 chip->bank_size_capture = snd_ymfpci_readl(chip, YDSXGR_RECCTRLSIZE) << 2; in snd_ymfpci_memalloc()
2101 chip->bank_size_effect = snd_ymfpci_readl(chip, YDSXGR_EFFCTRLSIZE) << 2; in snd_ymfpci_memalloc()
2102 chip->work_size = YDSXG_DEFAULT_WORK_SIZE; in snd_ymfpci_memalloc()
2105 ALIGN(chip->bank_size_playback * 2 * YDSXG_PLAYBACK_VOICES, 0x100) + in snd_ymfpci_memalloc()
2106 ALIGN(chip->bank_size_capture * 2 * YDSXG_CAPTURE_VOICES, 0x100) + in snd_ymfpci_memalloc()
2107 ALIGN(chip->bank_size_effect * 2 * YDSXG_EFFECT_VOICES, 0x100) + in snd_ymfpci_memalloc()
2108 chip->work_size; in snd_ymfpci_memalloc()
2111 if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(chip->pci), in snd_ymfpci_memalloc()
2112 size, &chip->work_ptr) < 0) in snd_ymfpci_memalloc()
2114 ptr = chip->work_ptr.area; in snd_ymfpci_memalloc()
2115 ptr_addr = chip->work_ptr.addr; in snd_ymfpci_memalloc()
2118 chip->bank_base_playback = ptr; in snd_ymfpci_memalloc()
2119 chip->bank_base_playback_addr = ptr_addr; in snd_ymfpci_memalloc()
2120 chip->ctrl_playback = (__le32 *)ptr; in snd_ymfpci_memalloc()
2121 chip->ctrl_playback[0] = cpu_to_le32(YDSXG_PLAYBACK_VOICES); in snd_ymfpci_memalloc()
2125 chip->voices[voice].number = voice; in snd_ymfpci_memalloc()
2126 chip->voices[voice].bank = (struct snd_ymfpci_playback_bank *)ptr; in snd_ymfpci_memalloc()
2127 chip->voices[voice].bank_addr = ptr_addr; in snd_ymfpci_memalloc()
2129 chip->bank_playback[voice][bank] = (struct snd_ymfpci_playback_bank *)ptr; in snd_ymfpci_memalloc()
2130 ptr += chip->bank_size_playback; in snd_ymfpci_memalloc()
2131 ptr_addr += chip->bank_size_playback; in snd_ymfpci_memalloc()
2136 chip->bank_base_capture = ptr; in snd_ymfpci_memalloc()
2137 chip->bank_base_capture_addr = ptr_addr; in snd_ymfpci_memalloc()
2140 chip->bank_capture[voice][bank] = (struct snd_ymfpci_capture_bank *)ptr; in snd_ymfpci_memalloc()
2141 ptr += chip->bank_size_capture; in snd_ymfpci_memalloc()
2142 ptr_addr += chip->bank_size_capture; in snd_ymfpci_memalloc()
2146 chip->bank_base_effect = ptr; in snd_ymfpci_memalloc()
2147 chip->bank_base_effect_addr = ptr_addr; in snd_ymfpci_memalloc()
2150 chip->bank_effect[voice][bank] = (struct snd_ymfpci_effect_bank *)ptr; in snd_ymfpci_memalloc()
2151 ptr += chip->bank_size_effect; in snd_ymfpci_memalloc()
2152 ptr_addr += chip->bank_size_effect; in snd_ymfpci_memalloc()
2156 chip->work_base = ptr; in snd_ymfpci_memalloc()
2157 chip->work_base_addr = ptr_addr; in snd_ymfpci_memalloc()
2159 snd_BUG_ON(ptr + chip->work_size != in snd_ymfpci_memalloc()
2160 chip->work_ptr.area + chip->work_ptr.bytes); in snd_ymfpci_memalloc()
2162 snd_ymfpci_writel(chip, YDSXGR_PLAYCTRLBASE, chip->bank_base_playback_addr); in snd_ymfpci_memalloc()
2163 snd_ymfpci_writel(chip, YDSXGR_RECCTRLBASE, chip->bank_base_capture_addr); in snd_ymfpci_memalloc()
2164 snd_ymfpci_writel(chip, YDSXGR_EFFCTRLBASE, chip->bank_base_effect_addr); in snd_ymfpci_memalloc()
2165 snd_ymfpci_writel(chip, YDSXGR_WORKBASE, chip->work_base_addr); in snd_ymfpci_memalloc()
2166 snd_ymfpci_writel(chip, YDSXGR_WORKSIZE, chip->work_size >> 2); in snd_ymfpci_memalloc()
2169 chip->spdif_bits = chip->spdif_pcm_bits = SNDRV_PCM_DEFAULT_CON_SPDIF & 0xffff; in snd_ymfpci_memalloc()
2170 snd_ymfpci_writew(chip, YDSXGR_SPDIFOUTCTRL, 0); in snd_ymfpci_memalloc()
2171 snd_ymfpci_writew(chip, YDSXGR_SPDIFOUTSTATUS, chip->spdif_bits); in snd_ymfpci_memalloc()
2174 snd_ymfpci_writew(chip, YDSXGR_SPDIFINCTRL, 0); in snd_ymfpci_memalloc()
2178 snd_ymfpci_writel(chip, reg, 0); in snd_ymfpci_memalloc()
2179 snd_ymfpci_writel(chip, YDSXGR_NATIVEDACOUTVOL, 0x3fff3fff); in snd_ymfpci_memalloc()
2180 snd_ymfpci_writel(chip, YDSXGR_BUF441OUTVOL, 0x3fff3fff); in snd_ymfpci_memalloc()
2181 snd_ymfpci_writel(chip, YDSXGR_ZVOUTVOL, 0x3fff3fff); in snd_ymfpci_memalloc()
2182 snd_ymfpci_writel(chip, YDSXGR_SPDIFOUTVOL, 0x3fff3fff); in snd_ymfpci_memalloc()
2183 snd_ymfpci_writel(chip, YDSXGR_NATIVEADCINVOL, 0x3fff3fff); in snd_ymfpci_memalloc()
2184 snd_ymfpci_writel(chip, YDSXGR_NATIVEDACINVOL, 0x3fff3fff); in snd_ymfpci_memalloc()
2185 snd_ymfpci_writel(chip, YDSXGR_PRIADCLOOPVOL, 0x3fff3fff); in snd_ymfpci_memalloc()
2186 snd_ymfpci_writel(chip, YDSXGR_LEGACYOUTVOL, 0x3fff3fff); in snd_ymfpci_memalloc()
2191 static int snd_ymfpci_free(struct snd_ymfpci *chip) in snd_ymfpci_free() argument
2195 if (snd_BUG_ON(!chip)) in snd_ymfpci_free()
2198 if (chip->res_reg_area) { /* don't touch busy hardware */ in snd_ymfpci_free()
2199 snd_ymfpci_writel(chip, YDSXGR_NATIVEDACOUTVOL, 0); in snd_ymfpci_free()
2200 snd_ymfpci_writel(chip, YDSXGR_BUF441OUTVOL, 0); in snd_ymfpci_free()
2201 snd_ymfpci_writel(chip, YDSXGR_LEGACYOUTVOL, 0); in snd_ymfpci_free()
2202 snd_ymfpci_writel(chip, YDSXGR_STATUS, ~0); in snd_ymfpci_free()
2203 snd_ymfpci_disable_dsp(chip); in snd_ymfpci_free()
2204 snd_ymfpci_writel(chip, YDSXGR_PLAYCTRLBASE, 0); in snd_ymfpci_free()
2205 snd_ymfpci_writel(chip, YDSXGR_RECCTRLBASE, 0); in snd_ymfpci_free()
2206 snd_ymfpci_writel(chip, YDSXGR_EFFCTRLBASE, 0); in snd_ymfpci_free()
2207 snd_ymfpci_writel(chip, YDSXGR_WORKBASE, 0); in snd_ymfpci_free()
2208 snd_ymfpci_writel(chip, YDSXGR_WORKSIZE, 0); in snd_ymfpci_free()
2209 ctrl = snd_ymfpci_readw(chip, YDSXGR_GLOBALCTRL); in snd_ymfpci_free()
2210 snd_ymfpci_writew(chip, YDSXGR_GLOBALCTRL, ctrl & ~0x0007); in snd_ymfpci_free()
2213 snd_ymfpci_ac3_done(chip); in snd_ymfpci_free()
2218 * the chip again unless reboot. ACPI bug? in snd_ymfpci_free()
2220 pci_set_power_state(chip->pci, PCI_D3hot); in snd_ymfpci_free()
2224 kfree(chip->saved_regs); in snd_ymfpci_free()
2226 if (chip->irq >= 0) in snd_ymfpci_free()
2227 free_irq(chip->irq, chip); in snd_ymfpci_free()
2228 release_and_free_resource(chip->mpu_res); in snd_ymfpci_free()
2229 release_and_free_resource(chip->fm_res); in snd_ymfpci_free()
2230 snd_ymfpci_free_gameport(chip); in snd_ymfpci_free()
2231 iounmap(chip->reg_area_virt); in snd_ymfpci_free()
2232 if (chip->work_ptr.area) in snd_ymfpci_free()
2233 snd_dma_free_pages(&chip->work_ptr); in snd_ymfpci_free()
2235 release_and_free_resource(chip->res_reg_area); in snd_ymfpci_free()
2237 pci_write_config_word(chip->pci, 0x40, chip->old_legacy_ctrl); in snd_ymfpci_free()
2239 pci_disable_device(chip->pci); in snd_ymfpci_free()
2240 release_firmware(chip->dsp_microcode); in snd_ymfpci_free()
2241 release_firmware(chip->controller_microcode); in snd_ymfpci_free()
2242 kfree(chip); in snd_ymfpci_free()
2248 struct snd_ymfpci *chip = device->device_data; in snd_ymfpci_dev_free() local
2249 return snd_ymfpci_free(chip); in snd_ymfpci_dev_free()
2285 struct snd_ymfpci *chip = card->private_data; in snd_ymfpci_suspend() local
2289 snd_ac97_suspend(chip->ac97); in snd_ymfpci_suspend()
2291 chip->saved_regs[i] = snd_ymfpci_readl(chip, saved_regs_index[i]); in snd_ymfpci_suspend()
2292 chip->saved_ydsxgr_mode = snd_ymfpci_readl(chip, YDSXGR_MODE); in snd_ymfpci_suspend()
2293 pci_read_config_word(chip->pci, PCIR_DSXG_LEGACY, in snd_ymfpci_suspend()
2294 &chip->saved_dsxg_legacy); in snd_ymfpci_suspend()
2295 pci_read_config_word(chip->pci, PCIR_DSXG_ELEGACY, in snd_ymfpci_suspend()
2296 &chip->saved_dsxg_elegacy); in snd_ymfpci_suspend()
2297 snd_ymfpci_writel(chip, YDSXGR_NATIVEDACOUTVOL, 0); in snd_ymfpci_suspend()
2298 snd_ymfpci_writel(chip, YDSXGR_BUF441OUTVOL, 0); in snd_ymfpci_suspend()
2299 snd_ymfpci_disable_dsp(chip); in snd_ymfpci_suspend()
2307 struct snd_ymfpci *chip = card->private_data; in snd_ymfpci_resume() local
2311 snd_ymfpci_codec_ready(chip, 0); in snd_ymfpci_resume()
2312 snd_ymfpci_download_image(chip); in snd_ymfpci_resume()
2316 snd_ymfpci_writel(chip, saved_regs_index[i], chip->saved_regs[i]); in snd_ymfpci_resume()
2318 snd_ac97_resume(chip->ac97); in snd_ymfpci_resume()
2320 pci_write_config_word(chip->pci, PCIR_DSXG_LEGACY, in snd_ymfpci_resume()
2321 chip->saved_dsxg_legacy); in snd_ymfpci_resume()
2322 pci_write_config_word(chip->pci, PCIR_DSXG_ELEGACY, in snd_ymfpci_resume()
2323 chip->saved_dsxg_elegacy); in snd_ymfpci_resume()
2326 if (chip->start_count > 0) { in snd_ymfpci_resume()
2327 spin_lock_irq(&chip->reg_lock); in snd_ymfpci_resume()
2328 snd_ymfpci_writel(chip, YDSXGR_MODE, chip->saved_ydsxgr_mode); in snd_ymfpci_resume()
2329 chip->active_bank = snd_ymfpci_readl(chip, YDSXGR_CTRLSELECT); in snd_ymfpci_resume()
2330 spin_unlock_irq(&chip->reg_lock); in snd_ymfpci_resume()
2344 struct snd_ymfpci *chip; in snd_ymfpci_create() local
2356 chip = kzalloc(sizeof(*chip), GFP_KERNEL); in snd_ymfpci_create()
2357 if (chip == NULL) { in snd_ymfpci_create()
2361 chip->old_legacy_ctrl = old_legacy_ctrl; in snd_ymfpci_create()
2362 spin_lock_init(&chip->reg_lock); in snd_ymfpci_create()
2363 spin_lock_init(&chip->voice_lock); in snd_ymfpci_create()
2364 init_waitqueue_head(&chip->interrupt_sleep); in snd_ymfpci_create()
2365 atomic_set(&chip->interrupt_sleep_count, 0); in snd_ymfpci_create()
2366 chip->card = card; in snd_ymfpci_create()
2367 chip->pci = pci; in snd_ymfpci_create()
2368 chip->irq = -1; in snd_ymfpci_create()
2369 chip->device_id = pci->device; in snd_ymfpci_create()
2370 chip->rev = pci->revision; in snd_ymfpci_create()
2371 chip->reg_area_phys = pci_resource_start(pci, 0); in snd_ymfpci_create()
2372 chip->reg_area_virt = ioremap_nocache(chip->reg_area_phys, 0x8000); in snd_ymfpci_create()
2374 chip->src441_used = -1; in snd_ymfpci_create()
2376 if ((chip->res_reg_area = request_mem_region(chip->reg_area_phys, 0x8000, "YMFPCI")) == NULL) { in snd_ymfpci_create()
2377 dev_err(chip->card->dev, in snd_ymfpci_create()
2379 chip->reg_area_phys, chip->reg_area_phys + 0x8000 - 1); in snd_ymfpci_create()
2384 KBUILD_MODNAME, chip)) { in snd_ymfpci_create()
2385 dev_err(chip->card->dev, "unable to grab IRQ %d\n", pci->irq); in snd_ymfpci_create()
2389 chip->irq = pci->irq; in snd_ymfpci_create()
2392 if (snd_ymfpci_codec_ready(chip, 0) < 0) { in snd_ymfpci_create()
2397 err = snd_ymfpci_request_firmware(chip); in snd_ymfpci_create()
2399 dev_err(chip->card->dev, "firmware request failed: %d\n", err); in snd_ymfpci_create()
2402 snd_ymfpci_download_image(chip); in snd_ymfpci_create()
2406 if (snd_ymfpci_memalloc(chip) < 0) { in snd_ymfpci_create()
2411 err = snd_ymfpci_ac3_init(chip); in snd_ymfpci_create()
2416 chip->saved_regs = kmalloc_array(YDSXGR_NUM_SAVED_REGS, sizeof(u32), in snd_ymfpci_create()
2418 if (chip->saved_regs == NULL) { in snd_ymfpci_create()
2424 err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops); in snd_ymfpci_create()
2428 snd_ymfpci_proc_init(card, chip); in snd_ymfpci_create()
2430 *rchip = chip; in snd_ymfpci_create()
2434 snd_ymfpci_free(chip); in snd_ymfpci_create()