diff -ur /home/nemesis/src/linux/aureal/alsa/alsa-driver-0.9.4/pci/au88x0/au88x0_core.c pci/au88x0/au88x0_core.c --- /home/nemesis/src/linux/aureal/alsa/alsa-driver-0.9.4/pci/au88x0/au88x0_core.c 2003-06-14 21:25:13.000000000 -0500 +++ pci/au88x0/au88x0_core.c 2003-06-15 06:32:19.000000000 -0500 @@ -1880,7 +1880,7 @@ /* Codec */ -#define POLL_COUNT 15 +#define POLL_COUNT 1000 void vortex_codec_init(vortex_t *vortex) { int i; @@ -1922,25 +1922,25 @@ unsigned long flags; unsigned int t; - //verify that the codec is ready for writing +// printk("DEBUG: write codec: %d <- %d\n",addr,data); + + // Verify transactions are clear for (t = 0; t < POLL_COUNT; t++){ if((hwread(card->mmio,VORTEX_CODEC_CTRL) & 0x100)) break; udelay(100); } spin_lock_irqsave(&card->lock, flags); - //Write register + // Write register hwwrite(card->mmio, VORTEX_CODEC_IO, ((addr << VORTEX_CODEC_ADDSHIFT) & VORTEX_CODEC_ADDMASK) | ((data << VORTEX_CODEC_DATSHIFT) & VORTEX_CODEC_DATMASK) | VORTEX_CODEC_WRITE); - //FIXME: maybe check to see if the write succeeded?? spin_unlock_irqrestore(&card->lock, flags); - for (t = 0; t < POLL_COUNT; t++){ - if((hwread(card->mmio,VORTEX_CODEC_CTRL) & 0x100)) - break; - udelay(100); - } + + // Flush PCI posted write + vortex_codec_read(codec, addr); + vortex_codec_read(codec, addr); } @@ -1951,31 +1951,45 @@ unsigned long flags; unsigned t; u16 x; + static unsigned char i; spin_lock_irqsave(&card->lock, flags); - //poll for codec write + // Wait for transactions to clear for (t = 0; t < POLL_COUNT; t++){ - if(!(hwread(card->mmio,VORTEX_CODEC_CTRL) & 0x100)) - break; - udelay(100); + if((hwread(card->mmio,VORTEX_CODEC_CTRL) & 0x100)) + goto ok1; + udelay(100); } + printk("Vortex AC'97 read failure -- stage 1"); + return 0xffff; + +ok1: reader = ((addr << VORTEX_CODEC_ADDSHIFT) & VORTEX_CODEC_ADDMASK); hwwrite(card->mmio, VORTEX_CODEC_IO, reader); - //FIXME: this could be cleaner, and have a proper fail path for (t = 0; t < POLL_COUNT; t++){ if(((hwread(card->mmio,VORTEX_CODEC_IO) & VORTEX_CODEC_ADDMASK)) == (addr << VORTEX_CODEC_ADDSHIFT)) - break; + goto ok2; udelay(100); } - //FIXME: get rid of this + printk("Vortex AC'97 read failure -- stage 2"); + return 0xffff; +ok2: x = hwread(card->mmio,VORTEX_CODEC_IO) & VORTEX_CODEC_DATMASK; +// printk("DEBUG: read codec #%d: %d -> %d\n",i,addr,x); + i++; spin_unlock_irqrestore(&card->lock, flags); return x; } +void vortex_codec_wait(void) { + + /* FIXME */ + +} + /* Initialization */ int vortex_core_init(vortex_t *vortex) { diff -ur /home/nemesis/src/linux/aureal/alsa/alsa-driver-0.9.4/pci/au88x0/au88x0.h pci/au88x0/au88x0.h --- /home/nemesis/src/linux/aureal/alsa/alsa-driver-0.9.4/pci/au88x0/au88x0.h 2003-06-14 21:25:13.000000000 -0500 +++ pci/au88x0/au88x0.h 2003-06-15 05:09:58.000000000 -0500 @@ -147,6 +147,7 @@ /* global stuff. */ void vortex_codec_init(vortex_t *vortex); void vortex_codec_write(ac97_t *codec, unsigned short addr,unsigned short data); +void vortex_codec_wait(void); unsigned short vortex_codec_read(ac97_t *codec, unsigned short addr); int vortex_core_init(vortex_t *card); diff -ur /home/nemesis/src/linux/aureal/alsa/alsa-driver-0.9.4/pci/au88x0/au88x0_mixer.c pci/au88x0/au88x0_mixer.c --- /home/nemesis/src/linux/aureal/alsa/alsa-driver-0.9.4/pci/au88x0/au88x0_mixer.c 2003-06-14 21:25:13.000000000 -0500 +++ pci/au88x0/au88x0_mixer.c 2003-06-15 04:59:55.000000000 -0500 @@ -13,20 +13,12 @@ int __devinit snd_vortex_mixer(vortex_t *vortex) { ac97_t ac97; - int result; memset(&ac97, 0, sizeof(ac97)); // Intialize AC97 codec stuff. ac97.write = vortex_codec_write; ac97.read = vortex_codec_read; + ac97.wait = vortex_codec_wait; ac97.private_data = vortex; - result = snd_ac97_mixer(vortex->card, &ac97, &vortex->codec); - if (vortex->codec) { - /* Disable -6dB input and output attenuation. */ - vortex_codec_write(vortex->codec, 0x6c, 0x0); - /* Enable external amplifier. This is for STAC9708/11 codecs. - STAC9701/03 dont need this*/ - vortex_codec_write(vortex->codec, 0x26, 0x8000); - } - return result; + return snd_ac97_mixer(vortex->card, &ac97, &vortex->codec); }