patch-2.2.18 linux/drivers/sound/trident.c

Next file: linux/drivers/sound/uart401.c
Previous file: linux/drivers/sound/sound_core.c
Back to the patch index
Back to the overall index

diff -u --new-file --recursive --exclude-from /usr/src/exclude v2.2.17/drivers/sound/trident.c linux/drivers/sound/trident.c
@@ -30,6 +30,10 @@
  *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  *
  *  History
+ *  v0.14.5c Oct 28 2000 Alan Cox
+ *      Merged Ching-Ling Lee's ADC/DAC fix from the newer ALI work
+ *  v0.14.5b Sept 17 2000 Eric Brombaugh
+ *      Fix hang when trying ALi MIDI init on Trident
  *  v0.14.5 June 3 2000 Ollie Lho
  *  	Misc bug fix from the Net
  *	Backported from 2.4.0-test1 to 2.2.16 (Eric Brombaugh)
@@ -113,6 +117,10 @@
 #include <asm/hardirq.h>
 #include <linux/bitops.h>
 
+#if defined CONFIG_ALPHA_NAUTILUS || CONFIG_ALPHA_GENERIC
+#include <asm/hwrpb.h>
+#endif
+
 #include "dm.h"
 
 #include "trident.h"
@@ -1160,6 +1168,27 @@
 				__stop_adc(state);
 				dmabuf->error++;
 			}
+			if (dmabuf->count < (signed)dmabuf->dmasize/2)
+				wake_up(&dmabuf->wait);
+		}
+	}
+
+	/* error handling and process wake up for DAC */
+	if (dmabuf->enable == DAC_RUNNING) {
+		if (dmabuf->mapped) {
+			dmabuf->count += diff;
+			if (dmabuf->count >= (signed)dmabuf->fragsize)
+				wake_up(&dmabuf->wait);
+		} else {
+			dmabuf->count -= diff;
+
+			if (dmabuf->count < 0 || dmabuf->count > dmabuf->dmasize) {
+				/* buffer underrun or buffer overrun, we have no way to recover
+				   it here, just stop the machine and let the process force hwptr
+				   and swptr to sync */
+				__stop_dac(state);
+				dmabuf->error++;
+			}
 			else if (!dmabuf->endcleared) {
 				swptr = dmabuf->swptr;
 				silence = (dmabuf->fmt & TRIDENT_FMT_16BIT ? 0 : 0x80);
@@ -1177,7 +1206,6 @@
 						//clear the invalid data
 						memset (dmabuf->rawbuf + swptr,
 							silence, clear_cnt);
-
 						dmabuf->endcleared = 1;
 					}
 				} else if (dmabuf->count < (signed) dmabuf->fragsize) {
@@ -1190,30 +1218,6 @@
 			}
 			/* trident_update_ptr is called by interrupt handler or by process via
 			   ioctl/poll, we only wake up the waiting process when we have more
-			   than 1/2 buffer of data to process (always true for interrupt handler) */
-			if (dmabuf->count > (signed)dmabuf->dmasize/2)
-				wake_up(&dmabuf->wait);
-		}
-	}
-
-	/* error handling and process wake up for DAC */
-	if (dmabuf->enable == DAC_RUNNING) {
-		if (dmabuf->mapped) {
-			dmabuf->count += diff;
-			if (dmabuf->count >= (signed)dmabuf->fragsize)
-				wake_up(&dmabuf->wait);
-		} else {
-			dmabuf->count -= diff;
-
-			if (dmabuf->count < 0 || dmabuf->count > dmabuf->dmasize) {
-				/* buffer underrun or buffer overrun, we have no way to recover
-				   it here, just stop the machine and let the process force hwptr
-				   and swptr to sync */
-				__stop_dac(state);
-				dmabuf->error++;
-			}
-			/* trident_update_ptr is called by interrupt handler or by process via
-			   ioctl/poll, we only wake up the waiting process when we have more
 			   than 1/2 buffer free (always true for interrupt handler) */
 			if (dmabuf->count < (signed)dmabuf->dmasize/2)
 				wake_up(&dmabuf->wait);
@@ -2863,40 +2867,57 @@
 		return -ENODEV;
 	}
 	
-	if ((card->dev_midi = register_sound_midi(&trident_midi_fops, -1))<0)
-		printk(KERN_WARNING "trident: Unable to register midi.\n");
-	else
-	{
-		struct midi_stuff *midi = &card->midi;
-		init_waitqueue(&midi->iwait);
-		init_waitqueue(&midi->owait);
-		midi->ird = midi->iwr = midi->icnt = 0;
-		midi->ord = midi->owr = midi->ocnt = 0;
-		outb(0xbc, card->iobase+ALI_MPUR2);
+	if(card->pci_id == PCI_DEVICE_ID_ALI_5451) {
+		/* ALi 5451 has special MIDI regs and FM emulation */
+		if ((card->dev_midi = register_sound_midi(&trident_midi_fops, -1))<0)
+			printk(KERN_WARNING "trident: Unable to register midi.\n");
+		else
+		{
+			struct midi_stuff *midi = &card->midi;
+			init_waitqueue(&midi->iwait);
+			init_waitqueue(&midi->owait);
+			midi->ird = midi->iwr = midi->icnt = 0;
+			midi->ord = midi->owr = midi->ocnt = 0;
+			outb(0xbc, card->iobase+ALI_MPUR2);
 		
-		/* reset command */
-		while (inb(card->iobase + ALI_MPUR1) & 0x40);
-		outb(0xff, card->iobase + ALI_MPUR1);
-		while (inb(card->iobase + ALI_MPUR1) & 0x80);
-		while ((inb(card->iobase + ALI_MPUR0) != 0xfe) && (inb(card->iobase+ALI_MPUR1) != 0x10)) 
+			/* reset command */
+			while (inb(card->iobase + ALI_MPUR1) & 0x40);
+			outb(0xff, card->iobase + ALI_MPUR1);
 			while (inb(card->iobase + ALI_MPUR1) & 0x80);
+			while ((inb(card->iobase + ALI_MPUR0) != 0xfe) && (inb(card->iobase+ALI_MPUR1) != 0x10)) 
+				while (inb(card->iobase + ALI_MPUR1) & 0x80);
 			
-		midi->ird = midi->iwr = midi->icnt = 0;
-	}
-		
-	if ((card->dev_dmfm = register_sound_special(&trident_dmfm_fops, 15))<0)
-		printk(KERN_WARNING "trident: Unable to register FM.\n");
+			midi->ird = midi->iwr = midi->icnt = 0;
+		}
 	
+		if ((card->dev_dmfm = register_sound_special(&trident_dmfm_fops, 15))<0)
+			printk(KERN_WARNING "trident: Unable to register FM.\n");
+	} else {
+		/* don't try to enable MIDI and FM on other chips */
+		card->dev_midi = -1;
+		card->dev_dmfm = -1;
+	}
+
 	outl(0x00, TRID_REG(card, T4D_MUSICVOL_WAVEVOL));
 
 	if (card->pci_id == PCI_DEVICE_ID_ALI_5451) {
-		/* edited by HMSEO for GT sound */
-#ifdef CONFIG_ALPHA_NAUTILUS
-		ac97_data = trident_ac97_get (card->ac97_codec[0], AC97_POWER_CONTROL);
-		trident_ac97_set (card->ac97_codec[0], AC97_POWER_CONTROL,
-				  ac97_data | ALI_EAPD_POWER_DOWN);
-#endif
-		/* edited by HMSEO for GT sound*/
+               /* edited by HMSEO for GT sound
+               09-20-00 changed by Rich Payne (rdp@alphalinux.org) to take into account
+		generic kernels running on Nautilus */
+
+#if defined CONFIG_ALPHA_NAUTILUS || CONFIG_ALPHA_GENERIC
+		u16 ac97_data;
+		extern struct hwrpb_struct *hwrpb;
+
+		if ((hwrpb->sys_type) == 201) {
+			printk(KERN_INFO "trident: Running on Alpha system type Nautilus\n");
+                	ac97_data = trident_ac97_get (card->ac97_codec[0], AC97_POWER_CONTROL);
+                	trident_ac97_set (card->ac97_codec[0], AC97_POWER_CONTROL,
+                                  ac97_data | ALI_EAPD_POWER_DOWN);
+       		}
+#endif                
+	/* edited by HMSEO for GT sound*/
+
 	}
 
 	/* Enable Address Engine Interrupts */

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)