Lines Matching full:chip

98 ad1889_readw(struct snd_ad1889 *chip, unsigned reg)  in ad1889_readw()  argument
100 return readw(chip->iobase + reg); in ad1889_readw()
104 ad1889_writew(struct snd_ad1889 *chip, unsigned reg, u16 val) in ad1889_writew() argument
106 writew(val, chip->iobase + reg); in ad1889_writew()
110 ad1889_readl(struct snd_ad1889 *chip, unsigned reg) in ad1889_readl() argument
112 return readl(chip->iobase + reg); in ad1889_readl()
116 ad1889_writel(struct snd_ad1889 *chip, unsigned reg, u32 val) in ad1889_writel() argument
118 writel(val, chip->iobase + reg); in ad1889_writel()
122 ad1889_unmute(struct snd_ad1889 *chip) in ad1889_unmute() argument
125 st = ad1889_readw(chip, AD_DS_WADA) & in ad1889_unmute()
127 ad1889_writew(chip, AD_DS_WADA, st); in ad1889_unmute()
128 ad1889_readw(chip, AD_DS_WADA); in ad1889_unmute()
132 ad1889_mute(struct snd_ad1889 *chip) in ad1889_mute() argument
135 st = ad1889_readw(chip, AD_DS_WADA) | AD_DS_WADA_RWAM | AD_DS_WADA_LWAM; in ad1889_mute()
136 ad1889_writew(chip, AD_DS_WADA, st); in ad1889_mute()
137 ad1889_readw(chip, AD_DS_WADA); in ad1889_mute()
141 ad1889_load_adc_buffer_address(struct snd_ad1889 *chip, u32 address) in ad1889_load_adc_buffer_address() argument
143 ad1889_writel(chip, AD_DMA_ADCBA, address); in ad1889_load_adc_buffer_address()
144 ad1889_writel(chip, AD_DMA_ADCCA, address); in ad1889_load_adc_buffer_address()
148 ad1889_load_adc_buffer_count(struct snd_ad1889 *chip, u32 count) in ad1889_load_adc_buffer_count() argument
150 ad1889_writel(chip, AD_DMA_ADCBC, count); in ad1889_load_adc_buffer_count()
151 ad1889_writel(chip, AD_DMA_ADCCC, count); in ad1889_load_adc_buffer_count()
155 ad1889_load_adc_interrupt_count(struct snd_ad1889 *chip, u32 count) in ad1889_load_adc_interrupt_count() argument
157 ad1889_writel(chip, AD_DMA_ADCIB, count); in ad1889_load_adc_interrupt_count()
158 ad1889_writel(chip, AD_DMA_ADCIC, count); in ad1889_load_adc_interrupt_count()
162 ad1889_load_wave_buffer_address(struct snd_ad1889 *chip, u32 address) in ad1889_load_wave_buffer_address() argument
164 ad1889_writel(chip, AD_DMA_WAVBA, address); in ad1889_load_wave_buffer_address()
165 ad1889_writel(chip, AD_DMA_WAVCA, address); in ad1889_load_wave_buffer_address()
169 ad1889_load_wave_buffer_count(struct snd_ad1889 *chip, u32 count) in ad1889_load_wave_buffer_count() argument
171 ad1889_writel(chip, AD_DMA_WAVBC, count); in ad1889_load_wave_buffer_count()
172 ad1889_writel(chip, AD_DMA_WAVCC, count); in ad1889_load_wave_buffer_count()
176 ad1889_load_wave_interrupt_count(struct snd_ad1889 *chip, u32 count) in ad1889_load_wave_interrupt_count() argument
178 ad1889_writel(chip, AD_DMA_WAVIB, count); in ad1889_load_wave_interrupt_count()
179 ad1889_writel(chip, AD_DMA_WAVIC, count); in ad1889_load_wave_interrupt_count()
183 ad1889_channel_reset(struct snd_ad1889 *chip, unsigned int channel) in ad1889_channel_reset() argument
189 reg = ad1889_readw(chip, AD_DS_WSMC) & ~AD_DS_WSMC_WAEN; in ad1889_channel_reset()
190 ad1889_writew(chip, AD_DS_WSMC, reg); in ad1889_channel_reset()
191 chip->wave.reg = reg; in ad1889_channel_reset()
194 reg = ad1889_readw(chip, AD_DMA_WAV); in ad1889_channel_reset()
197 ad1889_writew(chip, AD_DMA_WAV, reg); in ad1889_channel_reset()
200 ad1889_load_wave_buffer_address(chip, 0x0); in ad1889_channel_reset()
201 ad1889_load_wave_buffer_count(chip, 0x0); in ad1889_channel_reset()
202 ad1889_load_wave_interrupt_count(chip, 0x0); in ad1889_channel_reset()
205 ad1889_readw(chip, AD_DMA_WAV); in ad1889_channel_reset()
210 reg = ad1889_readw(chip, AD_DS_RAMC) & ~AD_DS_RAMC_ADEN; in ad1889_channel_reset()
211 ad1889_writew(chip, AD_DS_RAMC, reg); in ad1889_channel_reset()
212 chip->ramc.reg = reg; in ad1889_channel_reset()
214 reg = ad1889_readw(chip, AD_DMA_ADC); in ad1889_channel_reset()
217 ad1889_writew(chip, AD_DMA_ADC, reg); in ad1889_channel_reset()
219 ad1889_load_adc_buffer_address(chip, 0x0); in ad1889_channel_reset()
220 ad1889_load_adc_buffer_count(chip, 0x0); in ad1889_channel_reset()
221 ad1889_load_adc_interrupt_count(chip, 0x0); in ad1889_channel_reset()
224 ad1889_readw(chip, AD_DMA_ADC); in ad1889_channel_reset()
231 struct snd_ad1889 *chip = ac97->private_data; in snd_ad1889_ac97_read() local
232 return ad1889_readw(chip, AD_AC97_BASE + reg); in snd_ad1889_ac97_read()
238 struct snd_ad1889 *chip = ac97->private_data; in snd_ad1889_ac97_write() local
239 ad1889_writew(chip, AD_AC97_BASE + reg, val); in snd_ad1889_ac97_write()
243 snd_ad1889_ac97_ready(struct snd_ad1889 *chip) in snd_ad1889_ac97_ready() argument
247 while (!(ad1889_readw(chip, AD_AC97_ACIC) & AD_AC97_ACIC_ACRDY) in snd_ad1889_ac97_ready()
251 dev_err(chip->card->dev, "[%s] Link is not ready.\n", in snd_ad1889_ac97_ready()
255 dev_dbg(chip->card->dev, "[%s] ready after %d ms\n", __func__, 400 - retry); in snd_ad1889_ac97_ready()
311 struct snd_ad1889 *chip = snd_pcm_substream_chip(ss); in snd_ad1889_playback_open() local
314 chip->psubs = ss; in snd_ad1889_playback_open()
323 struct snd_ad1889 *chip = snd_pcm_substream_chip(ss); in snd_ad1889_capture_open() local
326 chip->csubs = ss; in snd_ad1889_capture_open()
335 struct snd_ad1889 *chip = snd_pcm_substream_chip(ss); in snd_ad1889_playback_close() local
336 chip->psubs = NULL; in snd_ad1889_playback_close()
343 struct snd_ad1889 *chip = snd_pcm_substream_chip(ss); in snd_ad1889_capture_close() local
344 chip->csubs = NULL; in snd_ad1889_capture_close()
351 struct snd_ad1889 *chip = snd_pcm_substream_chip(ss); in snd_ad1889_playback_prepare() local
357 ad1889_channel_reset(chip, AD_CHAN_WAV); in snd_ad1889_playback_prepare()
359 reg = ad1889_readw(chip, AD_DS_WSMC); in snd_ad1889_playback_prepare()
371 spin_lock_irq(&chip->lock); in snd_ad1889_playback_prepare()
373 chip->wave.size = size; in snd_ad1889_playback_prepare()
374 chip->wave.reg = reg; in snd_ad1889_playback_prepare()
375 chip->wave.addr = rt->dma_addr; in snd_ad1889_playback_prepare()
377 ad1889_writew(chip, AD_DS_WSMC, chip->wave.reg); in snd_ad1889_playback_prepare()
380 ad1889_writew(chip, AD_DS_WAS, rt->rate); in snd_ad1889_playback_prepare()
383 ad1889_load_wave_buffer_address(chip, chip->wave.addr); in snd_ad1889_playback_prepare()
384 ad1889_load_wave_buffer_count(chip, size); in snd_ad1889_playback_prepare()
385 ad1889_load_wave_interrupt_count(chip, count); in snd_ad1889_playback_prepare()
388 ad1889_readw(chip, AD_DS_WSMC); in snd_ad1889_playback_prepare()
390 spin_unlock_irq(&chip->lock); in snd_ad1889_playback_prepare()
392 dev_dbg(chip->card->dev, in snd_ad1889_playback_prepare()
394 chip->wave.addr, count, size, reg, rt->rate); in snd_ad1889_playback_prepare()
401 struct snd_ad1889 *chip = snd_pcm_substream_chip(ss); in snd_ad1889_capture_prepare() local
407 ad1889_channel_reset(chip, AD_CHAN_ADC); in snd_ad1889_capture_prepare()
409 reg = ad1889_readw(chip, AD_DS_RAMC); in snd_ad1889_capture_prepare()
421 spin_lock_irq(&chip->lock); in snd_ad1889_capture_prepare()
423 chip->ramc.size = size; in snd_ad1889_capture_prepare()
424 chip->ramc.reg = reg; in snd_ad1889_capture_prepare()
425 chip->ramc.addr = rt->dma_addr; in snd_ad1889_capture_prepare()
427 ad1889_writew(chip, AD_DS_RAMC, chip->ramc.reg); in snd_ad1889_capture_prepare()
430 ad1889_load_adc_buffer_address(chip, chip->ramc.addr); in snd_ad1889_capture_prepare()
431 ad1889_load_adc_buffer_count(chip, size); in snd_ad1889_capture_prepare()
432 ad1889_load_adc_interrupt_count(chip, count); in snd_ad1889_capture_prepare()
435 ad1889_readw(chip, AD_DS_RAMC); in snd_ad1889_capture_prepare()
437 spin_unlock_irq(&chip->lock); in snd_ad1889_capture_prepare()
439 dev_dbg(chip->card->dev, in snd_ad1889_capture_prepare()
441 chip->ramc.addr, count, size, reg, rt->rate); in snd_ad1889_capture_prepare()
453 struct snd_ad1889 *chip = snd_pcm_substream_chip(ss); in snd_ad1889_playback_trigger() local
455 wsmc = ad1889_readw(chip, AD_DS_WSMC); in snd_ad1889_playback_trigger()
460 ad1889_writew(chip, AD_DMA_WAV, AD_DMA_LOOP | AD_DMA_IM_CNT); in snd_ad1889_playback_trigger()
463 ad1889_writel(chip, AD_DMA_CHSS, AD_DMA_CHSS_WAVS); in snd_ad1889_playback_trigger()
464 ad1889_unmute(chip); in snd_ad1889_playback_trigger()
467 ad1889_mute(chip); in snd_ad1889_playback_trigger()
475 chip->wave.reg = wsmc; in snd_ad1889_playback_trigger()
476 ad1889_writew(chip, AD_DS_WSMC, wsmc); in snd_ad1889_playback_trigger()
477 ad1889_readw(chip, AD_DS_WSMC); /* flush */ in snd_ad1889_playback_trigger()
479 /* reset the chip when STOP - will disable IRQs */ in snd_ad1889_playback_trigger()
481 ad1889_channel_reset(chip, AD_CHAN_WAV); in snd_ad1889_playback_trigger()
494 struct snd_ad1889 *chip = snd_pcm_substream_chip(ss); in snd_ad1889_capture_trigger() local
496 ramc = ad1889_readw(chip, AD_DS_RAMC); in snd_ad1889_capture_trigger()
501 ad1889_writew(chip, AD_DMA_ADC, AD_DMA_LOOP | AD_DMA_IM_CNT); in snd_ad1889_capture_trigger()
504 ad1889_writel(chip, AD_DMA_CHSS, AD_DMA_CHSS_ADCS); in snd_ad1889_capture_trigger()
513 chip->ramc.reg = ramc; in snd_ad1889_capture_trigger()
514 ad1889_writew(chip, AD_DS_RAMC, ramc); in snd_ad1889_capture_trigger()
515 ad1889_readw(chip, AD_DS_RAMC); /* flush */ in snd_ad1889_capture_trigger()
517 /* reset the chip when STOP - will disable IRQs */ in snd_ad1889_capture_trigger()
519 ad1889_channel_reset(chip, AD_CHAN_ADC); in snd_ad1889_capture_trigger()
529 struct snd_ad1889 *chip = snd_pcm_substream_chip(ss); in snd_ad1889_playback_pointer() local
531 if (unlikely(!(chip->wave.reg & AD_DS_WSMC_WAEN))) in snd_ad1889_playback_pointer()
534 ptr = ad1889_readl(chip, AD_DMA_WAVCA); in snd_ad1889_playback_pointer()
535 ptr -= chip->wave.addr; in snd_ad1889_playback_pointer()
537 if (snd_BUG_ON(ptr >= chip->wave.size)) in snd_ad1889_playback_pointer()
548 struct snd_ad1889 *chip = snd_pcm_substream_chip(ss); in snd_ad1889_capture_pointer() local
550 if (unlikely(!(chip->ramc.reg & AD_DS_RAMC_ADEN))) in snd_ad1889_capture_pointer()
553 ptr = ad1889_readl(chip, AD_DMA_ADCCA); in snd_ad1889_capture_pointer()
554 ptr -= chip->ramc.addr; in snd_ad1889_capture_pointer()
556 if (snd_BUG_ON(ptr >= chip->ramc.size)) in snd_ad1889_capture_pointer()
588 struct snd_ad1889 *chip = dev_id; in snd_ad1889_interrupt() local
590 st = ad1889_readl(chip, AD_DMA_DISR); in snd_ad1889_interrupt()
593 ad1889_writel(chip, AD_DMA_DISR, st); in snd_ad1889_interrupt()
601 dev_dbg(chip->card->dev, in snd_ad1889_interrupt()
604 if ((st & AD_DMA_DISR_WAVI) && chip->psubs) in snd_ad1889_interrupt()
605 snd_pcm_period_elapsed(chip->psubs); in snd_ad1889_interrupt()
606 if ((st & AD_DMA_DISR_ADCI) && chip->csubs) in snd_ad1889_interrupt()
607 snd_pcm_period_elapsed(chip->csubs); in snd_ad1889_interrupt()
613 snd_ad1889_pcm_init(struct snd_ad1889 *chip, int device) in snd_ad1889_pcm_init() argument
618 err = snd_pcm_new(chip->card, chip->card->driver, device, 1, 1, &pcm); in snd_ad1889_pcm_init()
627 pcm->private_data = chip; in snd_ad1889_pcm_init()
629 strcpy(pcm->name, chip->card->shortname); in snd_ad1889_pcm_init()
631 chip->pcm = pcm; in snd_ad1889_pcm_init()
632 chip->psubs = NULL; in snd_ad1889_pcm_init()
633 chip->csubs = NULL; in snd_ad1889_pcm_init()
636 snd_dma_pci_data(chip->pci), in snd_ad1889_pcm_init()
646 struct snd_ad1889 *chip = entry->private_data; in snd_ad1889_proc_read() local
650 reg = ad1889_readw(chip, AD_DS_WSMC); in snd_ad1889_proc_read()
678 reg = ad1889_readw(chip, AD_DS_RAMC); in snd_ad1889_proc_read()
709 reg = ad1889_readw(chip, AD_DS_WADA); in snd_ad1889_proc_read()
713 reg = ad1889_readw(chip, AD_DS_WADA); in snd_ad1889_proc_read()
718 reg = ad1889_readw(chip, AD_DS_WAS); in snd_ad1889_proc_read()
720 reg = ad1889_readw(chip, AD_DS_RES); in snd_ad1889_proc_read()
725 snd_ad1889_proc_init(struct snd_ad1889 *chip) in snd_ad1889_proc_init() argument
727 snd_card_ro_proc_new(chip->card, chip->card->driver, in snd_ad1889_proc_init()
728 chip, snd_ad1889_proc_read); in snd_ad1889_proc_init()
743 snd_ad1889_ac97_xinit(struct snd_ad1889 *chip) in snd_ad1889_ac97_xinit() argument
747 reg = ad1889_readw(chip, AD_AC97_ACIC); in snd_ad1889_ac97_xinit()
749 ad1889_writew(chip, AD_AC97_ACIC, reg); in snd_ad1889_ac97_xinit()
750 ad1889_readw(chip, AD_AC97_ACIC); /* flush posted write */ in snd_ad1889_ac97_xinit()
754 ad1889_writew(chip, AD_AC97_ACIC, reg); in snd_ad1889_ac97_xinit()
756 snd_ad1889_ac97_ready(chip); in snd_ad1889_ac97_xinit()
759 reg = ad1889_readw(chip, AD_AC97_ACIC); in snd_ad1889_ac97_xinit()
761 ad1889_writew(chip, AD_AC97_ACIC, reg); in snd_ad1889_ac97_xinit()
762 ad1889_readw(chip, AD_AC97_ACIC); /* flush posted write */ in snd_ad1889_ac97_xinit()
769 struct snd_ad1889 *chip = bus->private_data; in snd_ad1889_ac97_bus_free() local
770 chip->ac97_bus = NULL; in snd_ad1889_ac97_bus_free()
776 struct snd_ad1889 *chip = ac97->private_data; in snd_ad1889_ac97_free() local
777 chip->ac97 = NULL; in snd_ad1889_ac97_free()
781 snd_ad1889_ac97_init(struct snd_ad1889 *chip, const char *quirk_override) in snd_ad1889_ac97_init() argument
791 snd_ad1889_ac97_xinit(chip); in snd_ad1889_ac97_init()
793 err = snd_ac97_bus(chip->card, 0, &ops, chip, &chip->ac97_bus); in snd_ad1889_ac97_init()
797 chip->ac97_bus->private_free = snd_ad1889_ac97_bus_free; in snd_ad1889_ac97_init()
800 ac97.private_data = chip; in snd_ad1889_ac97_init()
802 ac97.pci = chip->pci; in snd_ad1889_ac97_init()
804 err = snd_ac97_mixer(chip->ac97_bus, &ac97, &chip->ac97); in snd_ad1889_ac97_init()
808 snd_ac97_tune_hardware(chip->ac97, ac97_quirks, quirk_override); in snd_ad1889_ac97_init()
814 snd_ad1889_free(struct snd_ad1889 *chip) in snd_ad1889_free() argument
816 if (chip->irq < 0) in snd_ad1889_free()
819 spin_lock_irq(&chip->lock); in snd_ad1889_free()
821 ad1889_mute(chip); in snd_ad1889_free()
824 ad1889_channel_reset(chip, AD_CHAN_WAV | AD_CHAN_ADC); in snd_ad1889_free()
827 ad1889_writel(chip, AD_DMA_DISR, AD_DMA_DISR_PTAI | AD_DMA_DISR_PMAI); in snd_ad1889_free()
828 ad1889_readl(chip, AD_DMA_DISR); /* flush, dammit! */ in snd_ad1889_free()
830 spin_unlock_irq(&chip->lock); in snd_ad1889_free()
832 if (chip->irq >= 0) in snd_ad1889_free()
833 free_irq(chip->irq, chip); in snd_ad1889_free()
836 iounmap(chip->iobase); in snd_ad1889_free()
837 pci_release_regions(chip->pci); in snd_ad1889_free()
838 pci_disable_device(chip->pci); in snd_ad1889_free()
839 kfree(chip); in snd_ad1889_free()
846 struct snd_ad1889 *chip = device->device_data; in snd_ad1889_dev_free() local
847 return snd_ad1889_free(chip); in snd_ad1889_dev_free()
851 snd_ad1889_init(struct snd_ad1889 *chip) in snd_ad1889_init() argument
853 ad1889_writew(chip, AD_DS_CCS, AD_DS_CCS_CLKEN); /* turn on clock */ in snd_ad1889_init()
854 ad1889_readw(chip, AD_DS_CCS); /* flush posted write */ in snd_ad1889_init()
859 ad1889_writel(chip, AD_DMA_DISR, AD_DMA_DISR_PMAE | AD_DMA_DISR_PTAE); in snd_ad1889_init()
871 struct snd_ad1889 *chip; in snd_ad1889_create() local
889 /* allocate chip specific data with zero-filled memory */ in snd_ad1889_create()
890 if ((chip = kzalloc(sizeof(*chip), GFP_KERNEL)) == NULL) { in snd_ad1889_create()
895 chip->card = card; in snd_ad1889_create()
896 card->private_data = chip; in snd_ad1889_create()
897 chip->pci = pci; in snd_ad1889_create()
898 chip->irq = -1; in snd_ad1889_create()
904 chip->bar = pci_resource_start(pci, 0); in snd_ad1889_create()
905 chip->iobase = pci_ioremap_bar(pci, 0); in snd_ad1889_create()
906 if (chip->iobase == NULL) { in snd_ad1889_create()
914 spin_lock_init(&chip->lock); /* only now can we call ad1889_free */ in snd_ad1889_create()
917 IRQF_SHARED, KBUILD_MODNAME, chip)) { in snd_ad1889_create()
919 snd_ad1889_free(chip); in snd_ad1889_create()
923 chip->irq = pci->irq; in snd_ad1889_create()
924 synchronize_irq(chip->irq); in snd_ad1889_create()
926 /* (2) initialization of the chip hardware */ in snd_ad1889_create()
927 if ((err = snd_ad1889_init(chip)) < 0) { in snd_ad1889_create()
928 snd_ad1889_free(chip); in snd_ad1889_create()
932 if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) { in snd_ad1889_create()
933 snd_ad1889_free(chip); in snd_ad1889_create()
937 *rchip = chip; in snd_ad1889_create()
942 kfree(chip); in snd_ad1889_create()
955 struct snd_ad1889 *chip; in snd_ad1889_probe() local
968 /* XXX REVISIT: we can probably allocate chip in this call */ in snd_ad1889_probe()
976 err = snd_ad1889_create(card, pci, &chip); in snd_ad1889_probe()
982 card->shortname, chip->bar, chip->irq); in snd_ad1889_probe()
986 err = snd_ad1889_ac97_init(chip, ac97_quirk[devno]); in snd_ad1889_probe()
990 err = snd_ad1889_pcm_init(chip, 0); in snd_ad1889_probe()
995 snd_ad1889_proc_init(chip); in snd_ad1889_probe()