36 #include <linux/pci.h>
38 #include <linux/slab.h>
40 #include <linux/compiler.h>
42 #include <linux/module.h>
54 #define AD1889_DRVVER "Version: 1.7"
77 #define DEVNAME "ad1889"
78 #define PFX DEVNAME ": "
81 #define ad1889_debug(fmt, arg...) snd_printd(KERN_DEBUG fmt, ## arg)
216 ad1889_load_wave_buffer_address(chip, 0x0);
217 ad1889_load_wave_buffer_count(chip, 0x0);
218 ad1889_load_wave_interrupt_count(chip, 0x0);
235 ad1889_load_adc_buffer_address(chip, 0x0);
236 ad1889_load_adc_buffer_count(chip, 0x0);
237 ad1889_load_adc_interrupt_count(chip, 0x0);
245 snd_ad1889_ac97_read(
struct snd_ac97 *ac97,
unsigned short reg)
252 snd_ad1889_ac97_write(
struct snd_ac97 *
ac97,
unsigned short reg,
unsigned short val)
259 snd_ad1889_ac97_ready(
struct snd_ad1889 *chip)
271 ad1889_debug(
"[%s] ready after %d ms\n", __func__, 400 - retry);
331 rt->
hw = snd_ad1889_playback_hw;
343 rt->
hw = snd_ad1889_capture_hw;
369 unsigned int size = snd_pcm_lib_buffer_bytes(ss);
370 unsigned int count = snd_pcm_lib_period_bytes(ss);
373 ad1889_channel_reset(chip, AD_CHAN_WAV);
387 spin_lock_irq(&chip->
lock);
399 ad1889_load_wave_buffer_address(chip, chip->
wave.addr);
400 ad1889_load_wave_buffer_count(chip, size);
401 ad1889_load_wave_interrupt_count(chip, count);
406 spin_unlock_irq(&chip->
lock);
408 ad1889_debug(
"prepare playback: addr = 0x%x, count = %u, "
409 "size = %u, reg = 0x%x, rate = %u\n", chip->
wave.addr,
410 count, size, reg, rt->
rate);
419 unsigned int size = snd_pcm_lib_buffer_bytes(ss);
420 unsigned int count = snd_pcm_lib_period_bytes(ss);
437 spin_lock_irq(&chip->
lock);
446 ad1889_load_adc_buffer_address(chip, chip->
ramc.addr);
447 ad1889_load_adc_buffer_count(chip, size);
448 ad1889_load_adc_interrupt_count(chip, count);
453 spin_unlock_irq(&chip->
lock);
455 ad1889_debug(
"prepare capture: addr = 0x%x, count = %u, "
456 "size = %u, reg = 0x%x, rate = %u\n", chip->
ramc.addr,
457 count, size, reg, rt->
rate);
491 chip->
wave.reg = wsmc;
497 ad1889_channel_reset(chip, AD_CHAN_WAV);
551 ptr -= chip->
wave.addr;
556 return bytes_to_frames(ss->
runtime, ptr);
570 ptr -= chip->
ramc.addr;
575 return bytes_to_frames(ss->
runtime, ptr);
578 static struct snd_pcm_ops snd_ad1889_playback_ops = {
579 .open = snd_ad1889_playback_open,
580 .close = snd_ad1889_playback_close,
582 .hw_params = snd_ad1889_hw_params,
583 .hw_free = snd_ad1889_hw_free,
584 .prepare = snd_ad1889_playback_prepare,
585 .trigger = snd_ad1889_playback_trigger,
586 .pointer = snd_ad1889_playback_pointer,
589 static struct snd_pcm_ops snd_ad1889_capture_ops = {
590 .open = snd_ad1889_capture_open,
591 .close = snd_ad1889_capture_close,
593 .hw_params = snd_ad1889_hw_params,
594 .hw_free = snd_ad1889_hw_free,
595 .prepare = snd_ad1889_capture_prepare,
596 .trigger = snd_ad1889_capture_trigger,
597 .pointer = snd_ad1889_capture_pointer,
601 snd_ad1889_interrupt(
int irq,
void *
dev_id)
617 ad1889_debug(
"Unexpected master or target abort interrupt!\n");
641 &snd_ad1889_playback_ops);
643 &snd_ad1889_capture_ops);
677 snd_iprintf(buffer,
"Wave output: %s\n",
679 snd_iprintf(buffer,
"Wave Channels: %s\n",
681 snd_iprintf(buffer,
"Wave Quality: %d-bit linear\n",
689 snd_iprintf(buffer,
"Wave FIFO: %d %s words\n\n", tmp,
693 snd_iprintf(buffer,
"Synthesis output: %s\n",
701 snd_iprintf(buffer,
"Synthesis FIFO: %d %s words\n\n", tmp,
705 snd_iprintf(buffer,
"ADC input: %s\n",
707 snd_iprintf(buffer,
"ADC Channels: %s\n",
709 snd_iprintf(buffer,
"ADC Quality: %d-bit linear\n",
717 snd_iprintf(buffer,
"ADC FIFO: %d %s words\n\n", tmp,
720 snd_iprintf(buffer,
"Resampler input: %s\n",
728 snd_iprintf(buffer,
"Resampler FIFO: %d %s words\n\n", tmp,
736 snd_iprintf(buffer,
"Left: %s, -%d dB\n",
740 snd_iprintf(buffer,
"Right: %s, -%d dB\n",
745 snd_iprintf(buffer,
"Wave samplerate: %u Hz\n", reg);
747 snd_iprintf(buffer,
"Resampler samplerate: %u Hz\n", reg);
755 if (!snd_card_proc_new(chip->
card, chip->
card->driver, &entry))
756 snd_info_set_text_ops(entry, chip, snd_ad1889_proc_read);
771 snd_ad1889_ac97_xinit(
struct snd_ad1889 *chip)
784 snd_ad1889_ac97_ready(chip);
809 snd_ad1889_ac97_init(
struct snd_ad1889 *chip,
const char *quirk_override)
814 .write = snd_ad1889_ac97_write,
815 .read = snd_ad1889_ac97_read,
819 snd_ad1889_ac97_xinit(chip);
825 chip->
ac97_bus->private_free = snd_ad1889_ac97_bus_free;
827 memset(&ac97, 0,
sizeof(ac97));
829 ac97.private_free = snd_ad1889_ac97_free;
847 spin_lock_irq(&chip->
lock);
852 ad1889_channel_reset(chip, AD_CHAN_WAV |
AD_CHAN_ADC);
858 spin_unlock_irq(&chip->
lock);
875 snd_ad1889_dev_free(
struct snd_device *device)
878 return snd_ad1889_free(chip);
904 .dev_free = snd_ad1889_dev_free,
914 pci_set_consistent_dma_mask(pci,
DMA_BIT_MASK(32)) < 0) {
950 snd_ad1889_free(chip);
958 if ((err = snd_ad1889_init(chip)) < 0) {
959 snd_ad1889_free(chip);
964 snd_ad1889_free(chip);
982 snd_ad1889_probe(
struct pci_dev *pci,
1008 err = snd_ad1889_create(card, pci, &chip);
1018 err = snd_ad1889_ac97_init(chip,
ac97_quirk[devno]);
1022 err = snd_ad1889_pcm_init(chip, 0,
NULL);
1027 snd_ad1889_proc_init(chip);
1035 pci_set_drvdata(pci, card);
1046 snd_ad1889_remove(
struct pci_dev *pci)
1049 pci_set_drvdata(pci,
NULL);
1058 static struct pci_driver ad1889_pci_driver = {
1059 .name = KBUILD_MODNAME,
1060 .id_table = snd_ad1889_ids,
1061 .probe = snd_ad1889_probe,