patch-2.1.81 linux/drivers/sound/gus_wave.c

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

diff -u --recursive --new-file v2.1.80/linux/drivers/sound/gus_wave.c linux/drivers/sound/gus_wave.c
@@ -32,42 +32,42 @@
 #define NOT_SAMPLE	0xffff
 
 struct voice_info
-  {
-	  unsigned long   orig_freq;
-	  unsigned long   current_freq;
-	  unsigned long   mode;
-	  int             fixed_pitch;
-	  int             bender;
-	  int             bender_range;
-	  int             panning;
-	  int             midi_volume;
-	  unsigned int    initial_volume;
-	  unsigned int    current_volume;
-	  int             loop_irq_mode, loop_irq_parm;
+{
+	unsigned long   orig_freq;
+	unsigned long   current_freq;
+	unsigned long   mode;
+	int             fixed_pitch;
+	int             bender;
+	int             bender_range;
+	int             panning;
+	int             midi_volume;
+	unsigned int    initial_volume;
+	unsigned int    current_volume;
+	int             loop_irq_mode, loop_irq_parm;
 #define LMODE_FINISH		1
 #define LMODE_PCM		2
 #define LMODE_PCM_STOP		3
-	  int             volume_irq_mode, volume_irq_parm;
+	int             volume_irq_mode, volume_irq_parm;
 #define VMODE_HALT		1
 #define VMODE_ENVELOPE		2
 #define VMODE_START_NOTE	3
 
-	  int             env_phase;
-	  unsigned char   env_rate[6];
-	  unsigned char   env_offset[6];
-
-	  /*
-	   * Volume computation parameters for gus_adagio_vol()
-	   */
-	  int             main_vol, expression_vol, patch_vol;
-
-	  /* Variables for "Ultraclick" removal */
-	  int             dev_pending, note_pending, volume_pending,
-	                  sample_pending;
-	  char            kill_pending;
-	  long            offset_pending;
+	int             env_phase;
+	unsigned char   env_rate[6];
+	unsigned char   env_offset[6];
+
+	/*
+	 * Volume computation parameters for gus_adagio_vol()
+	 */
+	int		main_vol, expression_vol, patch_vol;
+
+	/* Variables for "Ultraclick" removal */
+	int             dev_pending, note_pending, volume_pending,
+	                sample_pending;
+	char            kill_pending;
+	long            offset_pending;
 
-  };
+};
 
 static struct voice_alloc_info *voice_alloc;
 
@@ -101,6 +101,7 @@
  * Current version of this driver doesn't allow synth and PCM functions
  * at the same time. The active_device specifies the active driver
  */
+
 static int      active_device = 0;
 
 #define GUS_DEV_WAVE		1	/* Wave table synth */
@@ -114,12 +115,14 @@
 static char     bounce_buf[8 * 1024];	/* Must match value set to max_fragment */
 
 static struct wait_queue *dram_sleeper = NULL;
-static volatile struct snd_wait dram_sleep_flag =
-{0};
+static volatile struct snd_wait dram_sleep_flag = {
+	0
+};
 
 /*
  * Variables and buffers for PCM output
  */
+
 #define MAX_PCM_BUFFERS		(128*MAX_REALTIME_FACTOR)	/* Don't change */
 
 static int      pcm_bsize, pcm_nblk, pcm_banksize;
@@ -172,8 +175,10 @@
 static int      patch_table[MAX_PATCH];
 static int      patch_map[32];
 
-static struct synth_info gus_info =
-{"Gravis UltraSound", 0, SYNTH_TYPE_SAMPLE, SAMPLE_TYPE_GUS, 0, 16, 0, MAX_PATCH};
+static struct synth_info gus_info = {
+	"Gravis UltraSound", 0, SYNTH_TYPE_SAMPLE, SAMPLE_TYPE_GUS, 
+	0, 16, 0, MAX_PATCH
+};
 
 static void     gus_poke(long addr, unsigned char data);
 static void     compute_and_set_volume(int voice, int volume, int ramp_time);
@@ -187,10 +192,9 @@
 #define	INSTANT_RAMP		-1	/* Instant change. No ramping */
 #define FAST_RAMP		0	/* Fastest possible ramp */
 
-static void
-reset_sample_memory(void)
+static void reset_sample_memory(void)
 {
-	int             i;
+	int i;
 
 	for (i = 0; i <= MAX_SAMPLE; i++)
 		sample_ptrs[i] = -1;
@@ -209,17 +213,15 @@
 		patch_table[i] = NOT_SAMPLE;
 }
 
-void
-gus_delay(void)
+void gus_delay(void)
 {
-	int             i;
+	int i;
 
 	for (i = 0; i < 7; i++)
 		inb(u_DRAMIO);
 }
 
-static void
-gus_poke(long addr, unsigned char data)
+static void gus_poke(long addr, unsigned char data)
 {				/* Writes a byte to the DRAM */
 	unsigned long   flags;
 
@@ -235,8 +237,7 @@
 	restore_flags(flags);
 }
 
-static unsigned char
-gus_peek(long addr)
+static unsigned char gus_peek(long addr)
 {				/* Reads a byte from the DRAM */
 	unsigned long   flags;
 	unsigned char   tmp;
@@ -255,8 +256,7 @@
 	return tmp;
 }
 
-void
-gus_write8(int reg, unsigned int data)
+void gus_write8(int reg, unsigned int data)
 {				/* Writes to an indirect register (8 bit) */
 	unsigned long   flags;
 
@@ -269,9 +269,9 @@
 	restore_flags(flags);
 }
 
-static unsigned char
-gus_read8(int reg)
-{				/* Reads from an indirect register (8 bit). Offset 0x80. */
+static unsigned char gus_read8(int reg)
+{				
+	/* Reads from an indirect register (8 bit). Offset 0x80. */
 	unsigned long   flags;
 	unsigned char   val;
 
@@ -284,9 +284,9 @@
 	return val;
 }
 
-static unsigned char
-gus_look8(int reg)
-{				/* Reads from an indirect register (8 bit). No additional offset. */
+static unsigned char gus_look8(int reg)
+{
+	/* Reads from an indirect register (8 bit). No additional offset. */
 	unsigned long   flags;
 	unsigned char   val;
 
@@ -299,9 +299,9 @@
 	return val;
 }
 
-static void
-gus_write16(int reg, unsigned int data)
-{				/* Writes to an indirect register (16 bit) */
+static void gus_write16(int reg, unsigned int data)
+{
+	/* Writes to an indirect register (16 bit) */
 	unsigned long   flags;
 
 	save_flags(flags);
@@ -315,9 +315,9 @@
 	restore_flags(flags);
 }
 
-static unsigned short
-gus_read16(int reg)
-{				/* Reads from an indirect register (16 bit). Offset 0x80. */
+static unsigned short gus_read16(int reg)
+{
+	/* Reads from an indirect register (16 bit). Offset 0x80. */
 	unsigned long   flags;
 	unsigned char   hi, lo;
 
@@ -334,9 +334,9 @@
 	return ((hi << 8) & 0xff00) | lo;
 }
 
-static unsigned short
-gus_look16(int reg)
-{				/* Reads from an indirect register (16 bit). No additional offset. */
+static unsigned short gus_look16(int reg)
+{		
+	/* Reads from an indirect register (16 bit). No additional offset. */
 	unsigned long   flags;
 	unsigned char   hi, lo;
 
@@ -353,32 +353,33 @@
 	return ((hi << 8) & 0xff00) | lo;
 }
 
-static void
-gus_write_addr(int reg, unsigned long address, int frac, int is16bit)
-{				/* Writes an 24 bit memory address */
+static void gus_write_addr(int reg, unsigned long address, int frac, int is16bit)
+{
+	/* Writes an 24 bit memory address */
 	unsigned long   hold_address;
 	unsigned long   flags;
 
 	save_flags(flags);
 	cli();
 	if (is16bit)
-	  {
-		  if (iw_mode)
-		    {
-			    /* Interwave spesific address translations */
-			    address >>= 1;
-		  } else
-		    {
-			    /*
-			     * Special processing required for 16 bit patches
-			     */
-
-			    hold_address = address;
-			    address = address >> 1;
-			    address &= 0x0001ffffL;
-			    address |= (hold_address & 0x000c0000L);
-		    }
-	  }
+	{
+		if (iw_mode)
+		{
+			/* Interwave spesific address translations */
+			address >>= 1;
+		}
+		else
+		{
+			/*
+			 * Special processing required for 16 bit patches
+			 */
+
+			hold_address = address;
+			address = address >> 1;
+			address &= 0x0001ffffL;
+			address |= (hold_address & 0x000c0000L);
+		}
+	}
 	gus_write16(reg, (unsigned short) ((address >> 7) & 0xffff));
 	gus_write16(reg + 1, (unsigned short) ((address << 9) & 0xffff)
 		    + (frac << 5));
@@ -390,17 +391,14 @@
 	restore_flags(flags);
 }
 
-static void
-gus_select_voice(int voice)
+static void gus_select_voice(int voice)
 {
 	if (voice < 0 || voice > 31)
 		return;
-
 	outb((voice), u_Voice);
 }
 
-static void
-gus_select_max_voices(int nvoices)
+static void gus_select_max_voices(int nvoices)
 {
 	if (iw_mode)
 		nvoices = 32;
@@ -410,26 +408,22 @@
 		nvoices = 32;
 
 	voice_alloc->max_voice = nr_voices = nvoices;
-
 	gus_write8(0x0e, (nvoices - 1) | 0xc0);
 }
 
-static void
-gus_voice_on(unsigned int mode)
+static void gus_voice_on(unsigned int mode)
 {
 	gus_write8(0x00, (unsigned char) (mode & 0xfc));
 	gus_delay();
 	gus_write8(0x00, (unsigned char) (mode & 0xfc));
 }
 
-static void
-gus_voice_off(void)
+static void gus_voice_off(void)
 {
 	gus_write8(0x00, gus_read8(0x00) | 0x03);
 }
 
-static void
-gus_voice_mode(unsigned int m)
+static void gus_voice_mode(unsigned int m)
 {
 	unsigned char   mode = (unsigned char) (m & 0xff);
 
@@ -439,8 +433,7 @@
 	gus_write8(0x00, (gus_read8(0x00) & 0x03) | (mode & 0xfc));
 }
 
-static void
-gus_voice_freq(unsigned long freq)
+static void gus_voice_freq(unsigned long freq)
 {
 	unsigned long   divisor = freq_div_table[nr_voices - 14];
 	unsigned short  fc;
@@ -455,34 +448,29 @@
 	gus_write16(0x01, fc);
 }
 
-static void
-gus_voice_volume(unsigned int vol)
+static void gus_voice_volume(unsigned int vol)
 {
 	gus_write8(0x0d, 0x03);	/* Stop ramp before setting volume */
 	gus_write16(0x09, (unsigned short) (vol << 4));
 }
 
-static void
-gus_voice_balance(unsigned int balance)
+static void gus_voice_balance(unsigned int balance)
 {
 	gus_write8(0x0c, (unsigned char) (balance & 0xff));
 }
 
-static void
-gus_ramp_range(unsigned int low, unsigned int high)
+static void gus_ramp_range(unsigned int low, unsigned int high)
 {
 	gus_write8(0x07, (unsigned char) ((low >> 4) & 0xff));
 	gus_write8(0x08, (unsigned char) ((high >> 4) & 0xff));
 }
 
-static void
-gus_ramp_rate(unsigned int scale, unsigned int rate)
+static void gus_ramp_rate(unsigned int scale, unsigned int rate)
 {
 	gus_write8(0x06, (unsigned char) (((scale & 0x03) << 6) | (rate & 0x3f)));
 }
 
-static void
-gus_rampon(unsigned int m)
+static void gus_rampon(unsigned int m)
 {
 	unsigned char   mode = (unsigned char) (m & 0xff);
 
@@ -491,10 +479,9 @@
 	gus_write8(0x0d, mode & 0xfc);
 }
 
-static void
-gus_ramp_mode(unsigned int m)
+static void gus_ramp_mode(unsigned int m)
 {
-	unsigned char   mode = (unsigned char) (m & 0xff);
+	unsigned char mode = (unsigned char) (m & 0xff);
 
 	gus_write8(0x0d, (gus_read8(0x0d) & 0x03) |
 		   (mode & 0xfc));	/* Leave the last 2 bits alone */
@@ -502,16 +489,14 @@
 	gus_write8(0x0d, (gus_read8(0x0d) & 0x03) | (mode & 0xfc));
 }
 
-static void
-gus_rampoff(void)
+static void gus_rampoff(void)
 {
 	gus_write8(0x0d, 0x03);
 }
 
-static void
-gus_set_voice_pos(int voice, long position)
+static void gus_set_voice_pos(int voice, long position)
 {
-	int             sample_no;
+	int sample_no;
 
 	if ((sample_no = sample_map[voice]) != -1)
 		if (position < samples[sample_no].len)
@@ -522,8 +507,7 @@
 				 samples[sample_no].mode & WAVE_16_BITS);
 }
 
-static void
-gus_voice_init(int voice)
+static void gus_voice_init(int voice)
 {
 	unsigned long   flags;
 
@@ -541,8 +525,7 @@
 
 }
 
-static void
-gus_voice_init2(int voice)
+static void gus_voice_init2(int voice)
 {
 	voices[voice].panning = 0;
 	voices[voice].mode = 0;
@@ -564,30 +547,30 @@
 	voices[voice].fixed_pitch = 0;
 }
 
-static void
-step_envelope(int voice)
+static void step_envelope(int voice)
 {
 	unsigned        vol, prev_vol, phase;
 	unsigned char   rate;
 	long int        flags;
 
 	if (voices[voice].mode & WAVE_SUSTAIN_ON && voices[voice].env_phase == 2)
-	  {
-		  save_flags(flags);
-		  cli();
-		  gus_select_voice(voice);
-		  gus_rampoff();
-		  restore_flags(flags);
-		  return;
-		  /*
-		   * Sustain phase begins. Continue envelope after receiving note off.
-		   */
-	  }
+	{
+		save_flags(flags);
+		cli();
+		gus_select_voice(voice);
+		gus_rampoff();
+		restore_flags(flags);
+		return;
+		/*
+		 * Sustain phase begins. Continue envelope after receiving note off.
+		 */
+	}
 	if (voices[voice].env_phase >= 5)
-	  {			/* Envelope finished. Shoot the voice down */
-		  gus_voice_init(voice);
-		  return;
-	  }
+	{
+		/* Envelope finished. Shoot the voice down */
+		gus_voice_init(voice);
+		return;
+	}
 	prev_vol = voices[voice].current_volume;
 	phase = ++voices[voice].env_phase;
 	compute_volume(voice, voices[voice].midi_volume);
@@ -606,30 +589,30 @@
 	voices[voice].volume_irq_mode = VMODE_ENVELOPE;
 
 	if (((vol - prev_vol) / 64) == 0)	/* No significant volume change */
-	  {
-		  restore_flags(flags);
-		  step_envelope(voice);		/* Continue the envelope on the next step */
-		  return;
-	  }
+	{
+		restore_flags(flags);
+		step_envelope(voice);		/* Continue the envelope on the next step */
+		return;
+	}
 	if (vol > prev_vol)
-	  {
-		  if (vol >= (4096 - 64))
-			  vol = 4096 - 65;
-		  gus_ramp_range(0, vol);
-		  gus_rampon(0x20);	/* Increasing volume, with IRQ */
-	} else
-	  {
-		  if (vol <= 64)
-			  vol = 65;
-		  gus_ramp_range(vol, 4030);
-		  gus_rampon(0x60);	/* Decreasing volume, with IRQ */
-	  }
+	{
+		if (vol >= (4096 - 64))
+			vol = 4096 - 65;
+		gus_ramp_range(0, vol);
+		gus_rampon(0x20);	/* Increasing volume, with IRQ */
+	}
+	else
+	{
+		if (vol <= 64)
+			vol = 65;
+		gus_ramp_range(vol, 4030);
+		gus_rampon(0x60);	/* Decreasing volume, with IRQ */
+	}
 	voices[voice].current_volume = vol;
 	restore_flags(flags);
 }
 
-static void
-init_envelope(int voice)
+static void init_envelope(int voice)
 {
 	voices[voice].env_phase = -1;
 	voices[voice].current_volume = 64;
@@ -637,17 +620,15 @@
 	step_envelope(voice);
 }
 
-static void
-start_release(int voice, long int flags)
+static void start_release(int voice, long int flags)
 {
 	if (gus_read8(0x00) & 0x03)
 		return;		/* Voice already stopped */
 
 	voices[voice].env_phase = 2;	/* Will be incremented by step_envelope */
 
-	voices[voice].current_volume =
-	    voices[voice].initial_volume =
-	    gus_read16(0x09) >> 4;	/* Get current volume */
+	voices[voice].current_volume = voices[voice].initial_volume =
+						gus_read16(0x09) >> 4;	/* Get current volume */
 
 	voices[voice].mode &= ~WAVE_SUSTAIN_ON;
 	gus_rampoff();
@@ -655,42 +636,41 @@
 	step_envelope(voice);
 }
 
-static void
-gus_voice_fade(int voice)
+static void gus_voice_fade(int voice)
 {
-	int             instr_no = sample_map[voice], is16bits;
-	long int        flags;
+	int instr_no = sample_map[voice], is16bits;
+	long int flags;
 
 	save_flags(flags);
 	cli();
 	gus_select_voice(voice);
 
 	if (instr_no < 0 || instr_no > MAX_SAMPLE)
-	  {
-		  gus_write8(0x00, 0x03);	/* Hard stop */
-		  voice_alloc->map[voice] = 0;
-		  restore_flags(flags);
-		  return;
-	  }
+	{
+		gus_write8(0x00, 0x03);	/* Hard stop */
+		voice_alloc->map[voice] = 0;
+		restore_flags(flags);
+		return;
+	}
 	is16bits = (samples[instr_no].mode & WAVE_16_BITS) ? 1 : 0;	/* 8 or 16 bits */
 
 	if (voices[voice].mode & WAVE_ENVELOPES)
-	  {
-		  start_release(voice, flags);
-		  restore_flags(flags);
-		  return;
-	  }
+	{
+		start_release(voice, flags);
+		restore_flags(flags);
+		return;
+	}
 	/*
 	 * Ramp the volume down but not too quickly.
 	 */
 	if ((int) (gus_read16(0x09) >> 4) < 100)	/* Get current volume */
-	  {
-		  gus_voice_off();
-		  gus_rampoff();
-		  gus_voice_init(voice);
-		  restore_flags(flags);
-		  return;
-	  }
+	{
+		gus_voice_off();
+		gus_rampoff();
+		gus_voice_init(voice);
+		restore_flags(flags);
+		return;
+	}
 	gus_ramp_range(65, 4030);
 	gus_ramp_rate(2, 4);
 	gus_rampon(0x40 | 0x20);	/* Down, once, with IRQ */
@@ -698,10 +678,9 @@
 	restore_flags(flags);
 }
 
-static void
-gus_reset(void)
+static void gus_reset(void)
 {
-	int             i;
+	int i;
 
 	gus_select_max_voices(24);
 	volume_base = 3071;
@@ -709,23 +688,24 @@
 	volume_method = VOL_METHOD_ADAGIO;
 
 	for (i = 0; i < 32; i++)
-	  {
-		  gus_voice_init(i);	/* Turn voice off */
-		  gus_voice_init2(i);
-	  }
+	{
+		gus_voice_init(i);	/* Turn voice off */
+		gus_voice_init2(i);
+	}
 }
 
-static void
-gus_initialize(void)
+static void gus_initialize(void)
 {
-	unsigned long   flags;
-	unsigned char   dma_image, irq_image, tmp;
+	unsigned long flags;
+	unsigned char dma_image, irq_image, tmp;
 
-	static unsigned char gus_irq_map[16] =
-	{0, 0, 0, 3, 0, 2, 0, 4, 0, 1, 0, 5, 6, 0, 0, 7};
-
-	static unsigned char gus_dma_map[8] =
-	{0, 1, 0, 2, 0, 3, 4, 5};
+	static unsigned char gus_irq_map[16] = 	{
+		0, 0, 0, 3, 0, 2, 0, 4, 0, 1, 0, 5, 6, 0, 0, 7
+	};
+
+	static unsigned char gus_dma_map[8] = {
+		0, 1, 0, 2, 0, 3, 4, 5
+	};
 
 	save_flags(flags);
 	cli();
@@ -787,37 +767,39 @@
 	irq_image = 0;
 	tmp = gus_irq_map[gus_irq];
 	if (!gus_pnp_flag && !tmp)
-		printk("Warning! GUS IRQ not selected\n");
+		printk(KERN_WARNING "Warning! GUS IRQ not selected\n");
 	irq_image |= tmp;
 	irq_image |= 0x40;	/* Combine IRQ1 (GF1) and IRQ2 (Midi) */
 
 	dual_dma_mode = 1;
 	if (gus_dma2 == gus_dma || gus_dma2 == -1)
-	  {
-		  dual_dma_mode = 0;
-		  dma_image = 0x40;	/* Combine DMA1 (DRAM) and IRQ2 (ADC) */
-
-		  tmp = gus_dma_map[gus_dma];
-		  if (!tmp)
-			  printk("Warning! GUS DMA not selected\n");
+	{
+		dual_dma_mode = 0;
+		dma_image = 0x40;	/* Combine DMA1 (DRAM) and IRQ2 (ADC) */
 
-		  dma_image |= tmp;
-	} else
+		tmp = gus_dma_map[gus_dma];
+		if (!tmp)
+			printk(KERN_WARNING "Warning! GUS DMA not selected\n");
+
+		dma_image |= tmp;
+	}
+	else
+	{
 		/* Setup dual DMA channel mode for GUS MAX */
-	  {
-		  dma_image = gus_dma_map[gus_dma];
-		  if (!dma_image)
-			  printk("Warning! GUS DMA not selected\n");
-
-		  tmp = gus_dma_map[gus_dma2] << 3;
-		  if (!tmp)
-		    {
-			    printk("Warning! Invalid GUS MAX DMA\n");
-			    tmp = 0x40;		/* Combine DMA channels */
+
+		dma_image = gus_dma_map[gus_dma];
+		if (!dma_image)
+			printk(KERN_WARNING "Warning! GUS DMA not selected\n");
+
+		tmp = gus_dma_map[gus_dma2] << 3;
+		if (!tmp)
+		{
+			printk(KERN_WARNING "Warning! Invalid GUS MAX DMA\n");
+			tmp = 0x40;		/* Combine DMA channels */
 			    dual_dma_mode = 0;
-		    }
-		  dma_image |= tmp;
-	  }
+		}
+		dma_image |= tmp;
+	}
 
 	/*
 	 * For some reason the IRQ and DMA addresses must be written twice
@@ -848,8 +830,8 @@
 	mix_image &= ~0x02;	/* Enable line out */
 	mix_image |= 0x08;	/* Enable IRQ */
 	outb((mix_image), u_Mixer);	/*
-					   * Turn mixer channels on
-					   * Note! Mic in is left off.
+					 * Turn mixer channels on
+					 * Note! Mic in is left off.
 					 */
 
 	gus_select_voice(0);	/* This disables writes to IRQ/DMA reg */
@@ -869,17 +851,16 @@
 }
 
 
-static void
-pnp_mem_init(void)
+static void pnp_mem_init(void)
 {
 #include "iwmem.h"
 #define CHUNK_SIZE (256*1024)
 #define BANK_SIZE (4*1024*1024)
 #define CHUNKS_PER_BANK (BANK_SIZE/CHUNK_SIZE)
 
-	int             bank, chunk, addr, total = 0;
-	int             bank_sizes[4];
-	int             i, j, bits = -1, nbanks = 0;
+	int bank, chunk, addr, total = 0;
+	int bank_sizes[4];
+	int i, j, bits = -1, nbanks = 0;
 
 /*
  * This routine determines what kind of RAM is installed in each of the four
@@ -902,133 +883,137 @@
  * Perform the DRAM size detection for each bank individually.
  */
 	for (bank = 0; bank < 4; bank++)
-	  {
-		  int             size = 0;
+	{
+		int size = 0;
+
+		addr = bank * BANK_SIZE;
 
-		  addr = bank * BANK_SIZE;
+		/* Clean check points of each chunk */
+		for (chunk = 0; chunk < CHUNKS_PER_BANK; chunk++)
+		{
+			gus_poke(addr + chunk * CHUNK_SIZE + 0L, 0x00);
+			gus_poke(addr + chunk * CHUNK_SIZE + 1L, 0x00);
+		}
 
-		  /* Clean check points of each chunk */
-		  for (chunk = 0; chunk < CHUNKS_PER_BANK; chunk++)
-		    {
-			    gus_poke(addr + chunk * CHUNK_SIZE + 0L, 0x00);
-			    gus_poke(addr + chunk * CHUNK_SIZE + 1L, 0x00);
-		    }
-
-		  /* Write a value to each chunk point and verify the result */
-		  for (chunk = 0; chunk < CHUNKS_PER_BANK; chunk++)
-		    {
-			    gus_poke(addr + chunk * CHUNK_SIZE + 0L, 0x55);
-			    gus_poke(addr + chunk * CHUNK_SIZE + 1L, 0xAA);
+		/* Write a value to each chunk point and verify the result */
+		for (chunk = 0; chunk < CHUNKS_PER_BANK; chunk++)
+		{
+			gus_poke(addr + chunk * CHUNK_SIZE + 0L, 0x55);
+			gus_poke(addr + chunk * CHUNK_SIZE + 1L, 0xAA);
 
-			    if (gus_peek(addr + chunk * CHUNK_SIZE + 0L) == 0x55 &&
+			if (gus_peek(addr + chunk * CHUNK_SIZE + 0L) == 0x55 &&
 				gus_peek(addr + chunk * CHUNK_SIZE + 1L) == 0xAA)
-			      {	/* OK. There is RAM. Now check for possible shadows */
-				      int             ok = 1, chunk2;
+			{
+				/* OK. There is RAM. Now check for possible shadows */
+				int ok = 1, chunk2;
 
-				      for (chunk2 = 0; ok && chunk2 < chunk; chunk2++)
-					      if (gus_peek(addr + chunk2 * CHUNK_SIZE + 0L) ||
-						  gus_peek(addr + chunk2 * CHUNK_SIZE + 1L))
-						      ok = 0;	/* Addressing wraps */
-
-				      if (ok)
-					      size = (chunk + 1) * CHUNK_SIZE;
-			      }
-			    gus_poke(addr + chunk * CHUNK_SIZE + 0L, 0x00);
-			    gus_poke(addr + chunk * CHUNK_SIZE + 1L, 0x00);
-		    }
-
-		  bank_sizes[bank] = size;
-		  if (size)
-			  nbanks = bank + 1;
-		  DDB(printk("Interwave: Bank %d, size=%dk\n", bank, size / 1024));
-	  }
+				for (chunk2 = 0; ok && chunk2 < chunk; chunk2++)
+					if (gus_peek(addr + chunk2 * CHUNK_SIZE + 0L) ||
+							gus_peek(addr + chunk2 * CHUNK_SIZE + 1L))
+						ok = 0;	/* Addressing wraps */
+
+				if (ok)
+					size = (chunk + 1) * CHUNK_SIZE;
+			}
+			gus_poke(addr + chunk * CHUNK_SIZE + 0L, 0x00);
+			gus_poke(addr + chunk * CHUNK_SIZE + 1L, 0x00);
+		}
+		bank_sizes[bank] = size;
+		if (size)
+			nbanks = bank + 1;
+		DDB(printk("Interwave: Bank %d, size=%dk\n", bank, size / 1024));
+	}
 
 	if (nbanks == 0)	/* No RAM - Give up */
-	  {
-		  printk("Sound: An Interwave audio chip detected but no DRAM\n");
-		  printk("Sound: Unable to work with this card.\n");
-		  gus_write8(0x19, gus_read8(0x19) & ~0x01);
-		  gus_mem_size = 0;
-		  return;
-	  }
-/*
- * Now we know how much DRAM there is in each bank. The next step is
- * to find a DRAM size encoding (0 to 12) which is best for the combination
- * we have.
- *
- * First try if any of the possible alternatives matches exactly the amount
- * of memory we have.
- */
+	{
+		printk(KERN_ERR "Sound: An Interwave audio chip detected but no DRAM\n");
+		printk(KERN_ERR "Sound: Unable to work with this card.\n");
+		gus_write8(0x19, gus_read8(0x19) & ~0x01);
+		gus_mem_size = 0;
+		return;
+	}
+
+	/*
+	 * Now we know how much DRAM there is in each bank. The next step is
+	 * to find a DRAM size encoding (0 to 12) which is best for the combination
+	 * we have.
+	 *
+	 * First try if any of the possible alternatives matches exactly the amount
+	 * of memory we have.
+	 */
 
 	for (i = 0; bits == -1 && i < 13; i++)
-	  {
-		  bits = i;
+	{
+		bits = i;
 
-		  for (j = 0; bits != -1 && j < 4; j++)
-			  if (mem_decode[i][j] != bank_sizes[j])
-				  bits = -1;	/* No hit */
-	  }
+		for (j = 0; bits != -1 && j < 4; j++)
+			if (mem_decode[i][j] != bank_sizes[j])
+				bits = -1;	/* No hit */
+	}
+
+	/*
+	 * If necessary, try to find a combination where other than the last
+	 * bank matches our configuration and the last bank is left oversized.
+	 * In this way we don't leave holes in the middle of memory.
+	 */
 
-/*
- * If necessary, try to find a combination where other than the last
- * bank matches our configuration and the last bank is left oversized.
- * In this way we don't leave holes in the middle of memory.
- */
 	if (bits == -1)		/* No luck yet */
+	{
 		for (i = 0; bits == -1 && i < 13; i++)
-		  {
-			  bits = i;
+		{
+			bits = i;
 
-			  for (j = 0; bits != -1 && j < nbanks - 1; j++)
-				  if (mem_decode[i][j] != bank_sizes[j])
-					  bits = -1;	/* No hit */
-			  if (mem_decode[i][nbanks - 1] < bank_sizes[nbanks - 1])
-				  bits = -1;	/* The last bank is too small */
-		  }
-/*
- * The last resort is to search for a combination where the last bank is
- * smaller than the actual SIMM. This leaves some memory in the last bank
- * unused but doesn't leave holes in the DRAM address space.
- */
+			for (j = 0; bits != -1 && j < nbanks - 1; j++)
+				if (mem_decode[i][j] != bank_sizes[j])
+					bits = -1;	/* No hit */
+			if (mem_decode[i][nbanks - 1] < bank_sizes[nbanks - 1])
+				bits = -1;	/* The last bank is too small */
+		}
+	}
+	/*
+	 * The last resort is to search for a combination where the last bank is
+	 * smaller than the actual SIMM. This leaves some memory in the last bank
+	 * unused but doesn't leave holes in the DRAM address space.
+	 */
 	if (bits == -1)		/* No luck yet */
-	  {
-		  for (i = 0; bits == -1 && i < 13; i++)
-		    {
-			    bits = i;
-
-			    for (j = 0; bits != -1 && j < nbanks - 1; j++)
-				    if (mem_decode[i][j] != bank_sizes[j])
-					    bits = -1;	/* No hit */
-		    }
-
-		  if (bits != -1)
-		    {
-			    printk("Interwave: Can't use all installed RAM.\n");
-			    printk("Interwave: Try reordering SIMMS.\n");
-		    }
-	  }
+	{
+		for (i = 0; bits == -1 && i < 13; i++)
+		{
+			bits = i;
+
+			for (j = 0; bits != -1 && j < nbanks - 1; j++)
+				if (mem_decode[i][j] != bank_sizes[j])
+					bits = -1;	/* No hit */
+		}
+		if (bits != -1)
+		{
+			printk(KERN_INFO "Interwave: Can't use all installed RAM.\n");
+			printk(KERN_INFO "Interwave: Try reordering SIMMS.\n");
+		}
+	}
 	if (bits == -1)
-	  {
-		  printk("Interwave: Can't find working DRAM encoding.\n");
-		  printk("Interwave: Defaulting to 256k. Try reordering SIMMS.\n");
-		  bits = 0;
-	  }
+	{
+		printk(KERN_INFO "Interwave: Can't find working DRAM encoding.\n");
+		printk(KERN_INFO "Interwave: Defaulting to 256k. Try reordering SIMMS.\n");
+		bits = 0;
+	}
 	DDB(printk("Interwave: Selecting DRAM addressing mode %d\n", bits));
 
 	for (bank = 0; bank < 4; bank++)
-	  {
-		  DDB(printk("  Bank %d, mem=%dk (limit %dk)\n", bank, bank_sizes[bank] / 1024, mem_decode[bits][bank] / 1024));
+	{
+		DDB(printk("  Bank %d, mem=%dk (limit %dk)\n", bank, bank_sizes[bank] / 1024, mem_decode[bits][bank] / 1024));
 
-		  if (bank_sizes[bank] > mem_decode[bits][bank])
-			  total += mem_decode[bits][bank];
-		  else
-			  total += bank_sizes[bank];
-	  }
+		if (bank_sizes[bank] > mem_decode[bits][bank])
+			total += mem_decode[bits][bank];
+		else
+			total += bank_sizes[bank];
+	}
 
 	DDB(printk("Total %dk of DRAM (enhanced mode)\n", total / 1024));
-/*
- *    Set the memory addressing mode.
- */
+
+	/*
+	 *    Set the memory addressing mode.
+	 */
 	gus_write16(0x52, (gus_look16(0x52) & 0xfff0) | bits);
 
 /*      Leave the chip into enhanced mode. Disable LFO  */
@@ -1037,8 +1022,7 @@
 	gus_write8(0x19, (gus_read8(0x19) | 0x01) & ~0x02);
 }
 
-int
-gus_wave_detect(int baseaddr)
+int gus_wave_detect(int baseaddr)
 {
 	unsigned long   i, max_mem = 1024L;
 	unsigned long   loc;
@@ -1059,15 +1043,18 @@
 	gus_write8(0x5b, ~val);	/* Invert all bits */
 
 	if ((gus_look8(0x5b) & 0xf0) == (val & 0xf0))	/* No change */
+	{
 		if ((gus_look8(0x5b) & 0x0f) == ((~val) & 0x0f))	/* Change */
-		  {
-			  DDB(printk("Interwave chip version %d detected\n", (val & 0xf0) >> 4));
-			  gus_pnp_flag = 1;
-		} else
-		  {
-			  DDB(printk("Not an Interwave chip (%x)\n", gus_look8(0x5b)));
-			  gus_pnp_flag = 0;
-		  }
+		{
+			DDB(printk("Interwave chip version %d detected\n", (val & 0xf0) >> 4));
+			gus_pnp_flag = 1;
+		}
+		else
+		{
+			DDB(printk("Not an Interwave chip (%x)\n", gus_look8(0x5b)));
+			gus_pnp_flag = 0;
+		}
+	}
 	gus_write8(0x5b, val);	/* Restore all bits */
 #endif
 
@@ -1084,28 +1071,26 @@
 	/* Now zero it out so that I can check for mirroring .. */
 	gus_poke(0L, 0x00);
 	for (i = 1L; i < max_mem; i++)
-	  {
-		  int             n, failed;
+	{
+		int n, failed;
 
-		  /* check for mirroring ... */
-		  if (gus_peek(0L) != 0)
-			  break;
-		  loc = i << 10;
-
-		  for (n = loc - 1, failed = 0; n <= loc; n++)
-		    {
-			    gus_poke(loc, 0xaa);
-			    if (gus_peek(loc) != 0xaa)
-				    failed = 1;
-
-			    gus_poke(loc, 0x55);
-			    if (gus_peek(loc) != 0x55)
-				    failed = 1;
-		    }
+		/* check for mirroring ... */
+		if (gus_peek(0L) != 0)
+			break;
+		loc = i << 10;
 
-		  if (failed)
-			  break;
-	  }
+		for (n = loc - 1, failed = 0; n <= loc; n++)
+		{
+			gus_poke(loc, 0xaa);
+			if (gus_peek(loc) != 0xaa)
+				failed = 1;
+			gus_poke(loc, 0x55);
+			if (gus_peek(loc) != 0x55)
+				failed = 1;
+		}
+		if (failed)
+			break;
+	}
 	gus_mem_size = i << 10;
 	return 1;
 }
@@ -1113,30 +1098,30 @@
 static int guswave_ioctl(int dev, unsigned int cmd, caddr_t arg)
 {
 
-	switch (cmd) {
-	case SNDCTL_SYNTH_INFO:
-		gus_info.nr_voices = nr_voices;
-		return __copy_to_user(arg, &gus_info, sizeof(gus_info));
-
-	case SNDCTL_SEQ_RESETSAMPLES:
-		reset_sample_memory();
-		return 0;
+	switch (cmd) 
+	{
+		case SNDCTL_SYNTH_INFO:
+			gus_info.nr_voices = nr_voices;
+			return copy_to_user(arg, &gus_info, sizeof(gus_info));
+
+		case SNDCTL_SEQ_RESETSAMPLES:
+			reset_sample_memory();
+			return 0;
 
-	case SNDCTL_SEQ_PERCMODE:
-		return 0;
+		case SNDCTL_SEQ_PERCMODE:
+			return 0;
 
-	case SNDCTL_SYNTH_MEMAVL:
-		return (gus_mem_size == 0) ? 0 : gus_mem_size - free_mem_ptr - 32;
+		case SNDCTL_SYNTH_MEMAVL:
+			return (gus_mem_size == 0) ? 0 : gus_mem_size - free_mem_ptr - 32;
 
-	default:
-		return -EINVAL;
+		default:
+			return -EINVAL;
 	}
 }
 
-static int
-guswave_set_instr(int dev, int voice, int instr_no)
+static int guswave_set_instr(int dev, int voice, int instr_no)
 {
-	int             sample_no;
+	int sample_no;
 
 	if (instr_no < 0 || instr_no > MAX_PATCH)
 		instr_no = 0;	/* Default to acoustic piano */
@@ -1145,103 +1130,97 @@
 		return -EINVAL;
 
 	if (voices[voice].volume_irq_mode == VMODE_START_NOTE)
-	  {
-		  voices[voice].sample_pending = instr_no;
-		  return 0;
-	  }
+	{
+		voices[voice].sample_pending = instr_no;
+		return 0;
+	}
 	sample_no = patch_table[instr_no];
 	patch_map[voice] = -1;
 
 	if (sample_no == NOT_SAMPLE)
-	  {
-		  printk("GUS: Undefined patch %d for voice %d\n", instr_no, voice);
-		  return -EINVAL;	/* Patch not defined */
-	  }
+	{
+/*		printk("GUS: Undefined patch %d for voice %d\n", instr_no, voice);*/
+		return -EINVAL;	/* Patch not defined */
+	}
 	if (sample_ptrs[sample_no] == -1)	/* Sample not loaded */
-	  {
-		  printk("GUS: Sample #%d not loaded for patch %d (voice %d)\n", sample_no, instr_no, voice);
-		  return -EINVAL;
-	  }
+	{
+/*		printk("GUS: Sample #%d not loaded for patch %d (voice %d)\n", sample_no, instr_no, voice);*/
+		return -EINVAL;
+	}
 	sample_map[voice] = sample_no;
 	patch_map[voice] = instr_no;
 	return 0;
 }
 
-static int
-guswave_kill_note(int dev, int voice, int note, int velocity)
+static int guswave_kill_note(int dev, int voice, int note, int velocity)
 {
-	unsigned long   flags;
+	unsigned long flags;
 
 	save_flags(flags);
 	cli();
 	/* voice_alloc->map[voice] = 0xffff; */
 	if (voices[voice].volume_irq_mode == VMODE_START_NOTE)
-	  {
-		  voices[voice].kill_pending = 1;
-		  restore_flags(flags);
-	} else
-	  {
-		  restore_flags(flags);
-		  gus_voice_fade(voice);
-	  }
+	{
+		voices[voice].kill_pending = 1;
+		restore_flags(flags);
+	}
+	else
+	{
+		restore_flags(flags);
+		gus_voice_fade(voice);
+	}
 
 	restore_flags(flags);
 	return 0;
 }
 
-static void
-guswave_aftertouch(int dev, int voice, int pressure)
+static void guswave_aftertouch(int dev, int voice, int pressure)
 {
 }
 
-static void
-guswave_panning(int dev, int voice, int value)
+static void guswave_panning(int dev, int voice, int value)
 {
 	if (voice >= 0 || voice < 32)
 		voices[voice].panning = value;
 }
 
-static void
-guswave_volume_method(int dev, int mode)
+static void guswave_volume_method(int dev, int mode)
 {
 	if (mode == VOL_METHOD_LINEAR || mode == VOL_METHOD_ADAGIO)
 		volume_method = mode;
 }
 
-static void
-compute_volume(int voice, int volume)
+static void compute_volume(int voice, int volume)
 {
 	if (volume < 128)
 		voices[voice].midi_volume = volume;
 
 	switch (volume_method)
-	  {
-	  case VOL_METHOD_ADAGIO:
-		  voices[voice].initial_volume =
-		      gus_adagio_vol(voices[voice].midi_volume, voices[voice].main_vol,
-				     voices[voice].expression_vol,
-				     voices[voice].patch_vol);
-		  break;
-
-	  case VOL_METHOD_LINEAR:	/* Totally ignores patch-volume and expression */
-		  voices[voice].initial_volume =
-		      gus_linear_vol(volume, voices[voice].main_vol);
-		  break;
-
-	  default:
-		  voices[voice].initial_volume = volume_base +
-		      (voices[voice].midi_volume * volume_scale);
-	  }
+	{
+		case VOL_METHOD_ADAGIO:
+			voices[voice].initial_volume =
+				gus_adagio_vol(voices[voice].midi_volume, voices[voice].main_vol,
+					voices[voice].expression_vol,
+					voices[voice].patch_vol);
+			break;
+
+		case VOL_METHOD_LINEAR:	/* Totally ignores patch-volume and expression */
+			voices[voice].initial_volume = gus_linear_vol(volume, voices[voice].main_vol);
+			break;
+
+		default:
+			voices[voice].initial_volume = volume_base +
+				(voices[voice].midi_volume * volume_scale);
+	}
 
 	if (voices[voice].initial_volume > 4030)
 		voices[voice].initial_volume = 4030;
 }
 
-static void
-compute_and_set_volume(int voice, int volume, int ramp_time)
+static void compute_and_set_volume(int voice, int volume, int ramp_time)
 {
-	int             curr, target, rate;
-	unsigned long   flags;
+	int curr, target, rate;
+	unsigned long flags;
 
 	compute_volume(voice, volume);
 	voices[voice].current_volume = voices[voice].initial_volume;
@@ -1249,7 +1228,7 @@
 	save_flags(flags);
 	cli();
 	/*
-	   * CAUTION! Interrupts disabled. Enable them before returning
+	 * CAUTION! Interrupts disabled. Enable them before returning
 	 */
 
 	gus_select_voice(voice);
@@ -1258,12 +1237,12 @@
 	target = voices[voice].initial_volume;
 
 	if (ramp_time == INSTANT_RAMP)
-	  {
-		  gus_rampoff();
-		  gus_voice_volume(target);
-		  restore_flags(flags);
-		  return;
-	  }
+	{
+		gus_rampoff();
+		gus_voice_volume(target);
+		restore_flags(flags);
+		return;
+	}
 	if (ramp_time == FAST_RAMP)
 		rate = 63;
 	else
@@ -1271,34 +1250,34 @@
 	gus_ramp_rate(0, rate);
 
 	if ((target - curr) / 64 == 0)	/* Close enough to target. */
-	  {
-		  gus_rampoff();
-		  gus_voice_volume(target);
-		  restore_flags(flags);
-		  return;
-	  }
+	{
+		gus_rampoff();
+		gus_voice_volume(target);
+		restore_flags(flags);
+		return;
+	}
 	if (target > curr)
-	  {
-		  if (target > (4095 - 65))
-			  target = 4095 - 65;
-		  gus_ramp_range(curr, target);
-		  gus_rampon(0x00);	/* Ramp up, once, no IRQ */
-	} else
-	  {
-		  if (target < 65)
-			  target = 65;
+	{
+		if (target > (4095 - 65))
+			target = 4095 - 65;
+		gus_ramp_range(curr, target);
+		gus_rampon(0x00);	/* Ramp up, once, no IRQ */
+	}
+	else
+	{
+		if (target < 65)
+			target = 65;
 
-		  gus_ramp_range(target, curr);
-		  gus_rampon(0x40);	/* Ramp down, once, no irq */
-	  }
+		gus_ramp_range(target, curr);
+		gus_rampon(0x40);	/* Ramp down, once, no irq */
+	}
 	restore_flags(flags);
 }
 
-static void
-dynamic_volume_change(int voice)
+static void dynamic_volume_change(int voice)
 {
-	unsigned char   status;
-	unsigned long   flags;
+	unsigned char status;
+	unsigned long flags;
 
 	save_flags(flags);
 	cli();
@@ -1310,10 +1289,11 @@
 		return;		/* Voice was not running */
 
 	if (!(voices[voice].mode & WAVE_ENVELOPES))
-	  {
-		  compute_and_set_volume(voice, voices[voice].midi_volume, 1);
-		  return;
-	  }
+	{
+		compute_and_set_volume(voice, voices[voice].midi_volume, 1);
+		return;
+	}
+	
 	/*
 	 * Voice is running and has envelopes.
 	 */
@@ -1325,10 +1305,10 @@
 	restore_flags(flags);
 
 	if (status & 0x03)	/* Sustain phase? */
-	  {
-		  compute_and_set_volume(voice, voices[voice].midi_volume, 1);
-		  return;
-	  }
+	{
+		compute_and_set_volume(voice, voices[voice].midi_volume, 1);
+		return;
+	}
 	if (voices[voice].env_phase < 0)
 		return;
 
@@ -1336,8 +1316,7 @@
 
 }
 
-static void
-guswave_controller(int dev, int voice, int ctrl_num, int value)
+static void guswave_controller(int dev, int voice, int ctrl_num, int value)
 {
 	unsigned long   flags;
 	unsigned long   freq;
@@ -1346,88 +1325,84 @@
 		return;
 
 	switch (ctrl_num)
-	  {
-	  case CTRL_PITCH_BENDER:
-		  voices[voice].bender = value;
-
-		  if (voices[voice].volume_irq_mode != VMODE_START_NOTE)
-		    {
-			    freq = compute_finetune(voices[voice].orig_freq, value,
-					  voices[voice].bender_range, 0);
-			    voices[voice].current_freq = freq;
-
-			    save_flags(flags);
-			    cli();
-			    gus_select_voice(voice);
-			    gus_voice_freq(freq);
-			    restore_flags(flags);
-		    }
-		  break;
-
-	  case CTRL_PITCH_BENDER_RANGE:
-		  voices[voice].bender_range = value;
-		  break;
-	  case CTL_EXPRESSION:
-		  value /= 128;
-	  case CTRL_EXPRESSION:
-		  if (volume_method == VOL_METHOD_ADAGIO)
-		    {
-			    voices[voice].expression_vol = value;
-			    if (voices[voice].volume_irq_mode != VMODE_START_NOTE)
-				    dynamic_volume_change(voice);
-		    }
-		  break;
-
-	  case CTL_PAN:
-		  voices[voice].panning = (value * 2) - 128;
-		  break;
-
-	  case CTL_MAIN_VOLUME:
-		  value = (value * 100) / 16383;
-
-	  case CTRL_MAIN_VOLUME:
-		  voices[voice].main_vol = value;
-		  if (voices[voice].volume_irq_mode != VMODE_START_NOTE)
-			  dynamic_volume_change(voice);
-		  break;
+	{
+		case CTRL_PITCH_BENDER:
+			voices[voice].bender = value;
 
-	  default:
-		  break;
-	  }
+			if (voices[voice].volume_irq_mode != VMODE_START_NOTE)
+			{
+				freq = compute_finetune(voices[voice].orig_freq, value, voices[voice].bender_range, 0);
+				voices[voice].current_freq = freq;
+
+				save_flags(flags);
+				cli();
+				gus_select_voice(voice);
+				gus_voice_freq(freq);
+				restore_flags(flags);
+			}
+			break;
+
+		case CTRL_PITCH_BENDER_RANGE:
+			voices[voice].bender_range = value;
+			break;
+		case CTL_EXPRESSION:
+			value /= 128;
+		case CTRL_EXPRESSION:
+			if (volume_method == VOL_METHOD_ADAGIO)
+			{
+				voices[voice].expression_vol = value;
+				if (voices[voice].volume_irq_mode != VMODE_START_NOTE)
+					dynamic_volume_change(voice);
+			}
+			break;
+
+		case CTL_PAN:
+			voices[voice].panning = (value * 2) - 128;
+			break;
+
+		case CTL_MAIN_VOLUME:
+			value = (value * 100) / 16383;
+
+		case CTRL_MAIN_VOLUME:
+			voices[voice].main_vol = value;
+			if (voices[voice].volume_irq_mode != VMODE_START_NOTE)
+				dynamic_volume_change(voice);
+			break;
+
+		default:
+			break;
+	}
 }
 
-static int
-guswave_start_note2(int dev, int voice, int note_num, int volume)
+static int guswave_start_note2(int dev, int voice, int note_num, int volume)
 {
-	int             sample, best_sample, best_delta, delta_freq;
-	int             is16bits, samplep, patch, pan;
+	int sample, best_sample, best_delta, delta_freq;
+	int is16bits, samplep, patch, pan;
 	unsigned long   note_freq, base_note, freq, flags;
 	unsigned char   mode = 0;
 
 	if (voice < 0 || voice > 31)
-	  {
-		  printk("GUS: Invalid voice\n");
-		  return -EINVAL;
-	  }
+	{
+/*		printk("GUS: Invalid voice\n");*/
+		return -EINVAL;
+	}
 	if (note_num == 255)
-	  {
-		  if (voices[voice].mode & WAVE_ENVELOPES)
-		    {
-			    voices[voice].midi_volume = volume;
-			    dynamic_volume_change(voice);
-			    return 0;
-		    }
-		  compute_and_set_volume(voice, volume, 1);
-		  return 0;
-	  }
+	{
+		if (voices[voice].mode & WAVE_ENVELOPES)
+		{
+			voices[voice].midi_volume = volume;
+			dynamic_volume_change(voice);
+			return 0;
+		}
+		compute_and_set_volume(voice, volume, 1);
+		return 0;
+	}
 	if ((patch = patch_map[voice]) == -1)
-	  {
-		  return -EINVAL;
-	  }
+		return -EINVAL;
 	if ((samplep = patch_table[patch]) == NOT_SAMPLE)
-	  {
-		  return -EINVAL;
-	  }
+	{
+		return -EINVAL;
+	}
 	note_freq = note_to_freq(note_num);
 
 	/*
@@ -1439,30 +1414,32 @@
 	best_sample = samplep;
 	best_delta = 1000000;
 	while (samplep != 0 && samplep != NOT_SAMPLE && sample == -1)
-	  {
-		  delta_freq = note_freq - samples[samplep].base_note;
-		  if (delta_freq < 0)
-			  delta_freq = -delta_freq;
-		  if (delta_freq < best_delta)
-		    {
-			    best_sample = samplep;
-			    best_delta = delta_freq;
-		    }
-		  if (samples[samplep].low_note <= note_freq &&
-		      note_freq <= samples[samplep].high_note)
-			  sample = samplep;
-		  else
-			  samplep = samples[samplep].key;	/* Link to next sample */
+	{
+		delta_freq = note_freq - samples[samplep].base_note;
+		if (delta_freq < 0)
+			delta_freq = -delta_freq;
+		if (delta_freq < best_delta)
+		{
+			best_sample = samplep;
+			best_delta = delta_freq;
+		}
+		if (samples[samplep].low_note <= note_freq &&
+			note_freq <= samples[samplep].high_note)
+		{
+			sample = samplep;
+		}
+		else
+			samplep = samples[samplep].key;	/* Link to next sample */
 	  }
 	if (sample == -1)
 		sample = best_sample;
 
 	if (sample == -1)
-	  {
-		  printk("GUS: Patch %d not defined for note %d\n", patch, note_num);
-		  return 0;	/* Should play default patch ??? */
-	  }
-	is16bits = (samples[sample].mode & WAVE_16_BITS) ? 1 : 0;
+	{
+/*		printk("GUS: Patch %d not defined for note %d\n", patch, note_num);*/
+		return 0;	/* Should play default patch ??? */
+	}
+	is16bits = (samples[sample].mode & WAVE_16_BITS) ? 1 : 0;
 	voices[voice].mode = samples[sample].mode;
 	voices[voice].patch_vol = samples[sample].volume;
 
@@ -1470,27 +1447,28 @@
 		gus_write8(0x15, 0x00);		/* RAM, Reset voice deactivate bit of SMSI */
 
 	if (voices[voice].mode & WAVE_ENVELOPES)
-	  {
-		  int             i;
+	{
+		int i;
 
-		  for (i = 0; i < 6; i++)
-		    {
-			    voices[voice].env_rate[i] = samples[sample].env_rate[i];
-			    voices[voice].env_offset[i] = samples[sample].env_offset[i];
-		    }
-	  }
+		for (i = 0; i < 6; i++)
+		{
+			voices[voice].env_rate[i] = samples[sample].env_rate[i];
+			voices[voice].env_offset[i] = samples[sample].env_offset[i];
+		}
+	}
 	sample_map[voice] = sample;
 
 	if (voices[voice].fixed_pitch)	/* Fixed pitch */
-	  {
+	{
 		  freq = samples[sample].base_freq;
-	} else
-	  {
-		  base_note = samples[sample].base_note / 100;
-		  note_freq /= 100;
+	}
+	else
+	{
+		base_note = samples[sample].base_note / 100;
+		note_freq /= 100;
 
-		  freq = samples[sample].base_freq * note_freq / base_note;
-	  }
+		freq = samples[sample].base_freq * note_freq / base_note;
+	}
 
 	voices[voice].orig_freq = freq;
 
@@ -1511,15 +1489,15 @@
 		pan = 15;
 
 	if (samples[sample].mode & WAVE_16_BITS)
-	  {
-		  mode |= 0x04;	/* 16 bits */
-		  if ((sample_ptrs[sample] / GUS_BANK_SIZE) !=
-		      ((sample_ptrs[sample] + samples[sample].len) / GUS_BANK_SIZE))
-			  printk("GUS: Sample address error\n");
-	  }
-  /*************************************************************************
-   *    CAUTION!        Interrupts disabled. Don't return before enabling
-   *************************************************************************/
+	{
+		mode |= 0x04;	/* 16 bits */
+		if ((sample_ptrs[sample] / GUS_BANK_SIZE) !=
+			((sample_ptrs[sample] + samples[sample].len) / GUS_BANK_SIZE))
+				printk(KERN_ERR "GUS: Sample address error\n");
+	}
+	/*************************************************************************
+	 *    CAUTION!        Interrupts disabled. Don't return before enabling
+	 *************************************************************************/
 
 	save_flags(flags);
 	cli();
@@ -1530,13 +1508,14 @@
 	restore_flags(flags);
 
 	if (voices[voice].mode & WAVE_ENVELOPES)
-	  {
-		  compute_volume(voice, volume);
-		  init_envelope(voice);
-	} else
-	  {
-		  compute_and_set_volume(voice, volume, 0);
-	  }
+	{
+		compute_volume(voice, volume);
+		init_envelope(voice);
+	}
+	else
+	{
+		compute_and_set_volume(voice, volume, 0);
+	}
 
 	save_flags(flags);
 	cli();
@@ -1544,43 +1523,38 @@
 
 	if (samples[sample].mode & WAVE_LOOP_BACK)
 		gus_write_addr(0x0a, sample_ptrs[sample] + samples[sample].len -
-			       voices[voice].offset_pending, 0, is16bits);	/* start=end */
+			voices[voice].offset_pending, 0, is16bits);	/* start=end */
 	else
-		gus_write_addr(0x0a, sample_ptrs[sample] + voices[voice].offset_pending,
-			       0, is16bits);	/* Sample start=begin */
+		gus_write_addr(0x0a, sample_ptrs[sample] + voices[voice].offset_pending, 0, is16bits);	/* Sample start=begin */
 
 	if (samples[sample].mode & WAVE_LOOPING)
-	  {
-		  mode |= 0x08;
+	{
+		mode |= 0x08;
 
-		  if (samples[sample].mode & WAVE_BIDIR_LOOP)
-			  mode |= 0x10;
+		if (samples[sample].mode & WAVE_BIDIR_LOOP)
+			mode |= 0x10;
 
-		  if (samples[sample].mode & WAVE_LOOP_BACK)
-		    {
-			    gus_write_addr(0x0a,
-					   sample_ptrs[sample] + samples[sample].loop_end -
+		if (samples[sample].mode & WAVE_LOOP_BACK)
+		{
+			gus_write_addr(0x0a, sample_ptrs[sample] + samples[sample].loop_end -
 					   voices[voice].offset_pending,
 					   (samples[sample].fractions >> 4) & 0x0f, is16bits);
-			    mode |= 0x40;
-		    }
-		  gus_write_addr(0x02, sample_ptrs[sample] + samples[sample].loop_start,
-				 samples[sample].fractions & 0x0f,
-				 is16bits);	/* Loop start location */
-		  gus_write_addr(0x04, sample_ptrs[sample] + samples[sample].loop_end,
-				 (samples[sample].fractions >> 4) & 0x0f,
-				 is16bits);	/* Loop end location */
-	} else
-	  {
-		  mode |= 0x20;	/* Loop IRQ at the end */
-		  voices[voice].loop_irq_mode = LMODE_FINISH;	/* Ramp down at the end */
-		  voices[voice].loop_irq_parm = 1;
-		  gus_write_addr(0x02, sample_ptrs[sample],
-				 0, is16bits);	/* Loop start location */
-		  gus_write_addr(0x04, sample_ptrs[sample] + samples[sample].len - 1,
-				 (samples[sample].fractions >> 4) & 0x0f,
-				 is16bits);	/* Loop end location */
-	  }
+			mode |= 0x40;
+		}
+		gus_write_addr(0x02, sample_ptrs[sample] + samples[sample].loop_start,
+			samples[sample].fractions & 0x0f, is16bits);	/* Loop start location */
+		gus_write_addr(0x04, sample_ptrs[sample] + samples[sample].loop_end,
+			(samples[sample].fractions >> 4) & 0x0f, is16bits);	/* Loop end location */
+	}
+	else
+	{
+		mode |= 0x20;	/* Loop IRQ at the end */
+		voices[voice].loop_irq_mode = LMODE_FINISH;	/* Ramp down at the end */
+		voices[voice].loop_irq_parm = 1;
+		gus_write_addr(0x02, sample_ptrs[sample], 0, is16bits);	/* Loop start location */
+		gus_write_addr(0x04, sample_ptrs[sample] + samples[sample].len - 1,
+			(samples[sample].fractions >> 4) & 0x0f, is16bits);	/* Loop end location */
+	}
 	gus_voice_freq(freq);
 	gus_voice_balance(pan);
 	gus_voice_on(mode);
@@ -1595,82 +1569,81 @@
  * ramping.
  */
 
-static int
-guswave_start_note(int dev, int voice, int note_num, int volume)
+static int guswave_start_note(int dev, int voice, int note_num, int volume)
 {
-	long int        flags;
-	int             mode;
-	int             ret_val = 0;
+	long int flags;
+	int mode;
+	int ret_val = 0;
 
 	save_flags(flags);
 	cli();
 	if (note_num == 255)
-	  {
-		  if (voices[voice].volume_irq_mode == VMODE_START_NOTE)
-		    {
-			    voices[voice].volume_pending = volume;
-		  } else
-		    {
-			    ret_val = guswave_start_note2(dev, voice, note_num, volume);
-		    }
-	} else
-	  {
-		  gus_select_voice(voice);
-		  mode = gus_read8(0x00);
-		  if (mode & 0x20)
-			  gus_write8(0x00, mode & 0xdf);	/* No interrupt! */
-
-		  voices[voice].offset_pending = 0;
-		  voices[voice].kill_pending = 0;
-		  voices[voice].volume_irq_mode = 0;
-		  voices[voice].loop_irq_mode = 0;
-
-		  if (voices[voice].sample_pending >= 0)
-		    {
-			    restore_flags(flags);	/* Run temporarily with interrupts enabled */
-			    guswave_set_instr(voices[voice].dev_pending, voice,
-					   voices[voice].sample_pending);
-			    voices[voice].sample_pending = -1;
-			    save_flags(flags);
-			    cli();
-			    gus_select_voice(voice);	/* Reselect the voice (just to be sure) */
-		    }
-		  if ((mode & 0x01) || (int) ((gus_read16(0x09) >> 4) < (unsigned) 2065))
-		    {
-			    ret_val = guswave_start_note2(dev, voice, note_num, volume);
-		  } else
-		    {
-			    voices[voice].dev_pending = dev;
-			    voices[voice].note_pending = note_num;
-			    voices[voice].volume_pending = volume;
-			    voices[voice].volume_irq_mode = VMODE_START_NOTE;
-
-			    gus_rampoff();
-			    gus_ramp_range(2000, 4065);
-			    gus_ramp_rate(0, 63);	/* Fastest possible rate */
-			    gus_rampon(0x20 | 0x40);	/* Ramp down, once, irq */
-		    }
-	  }
+	{
+		if (voices[voice].volume_irq_mode == VMODE_START_NOTE)
+		{
+			voices[voice].volume_pending = volume;
+		}
+		else
+		{
+			ret_val = guswave_start_note2(dev, voice, note_num, volume);
+		}
+	}
+	else
+	{
+		gus_select_voice(voice);
+		mode = gus_read8(0x00);
+		if (mode & 0x20)
+			gus_write8(0x00, mode & 0xdf);	/* No interrupt! */
+
+		voices[voice].offset_pending = 0;
+		voices[voice].kill_pending = 0;
+		voices[voice].volume_irq_mode = 0;
+		voices[voice].loop_irq_mode = 0;
+
+		if (voices[voice].sample_pending >= 0)
+		{
+			restore_flags(flags);	/* Run temporarily with interrupts enabled */
+			guswave_set_instr(voices[voice].dev_pending, voice, voices[voice].sample_pending);
+			voices[voice].sample_pending = -1;
+			save_flags(flags);
+			cli();
+			gus_select_voice(voice);	/* Reselect the voice (just to be sure) */
+		}
+		if ((mode & 0x01) || (int) ((gus_read16(0x09) >> 4) < (unsigned) 2065))
+		{
+			ret_val = guswave_start_note2(dev, voice, note_num, volume);
+		}
+		else
+		{
+			voices[voice].dev_pending = dev;
+			voices[voice].note_pending = note_num;
+			voices[voice].volume_pending = volume;
+			voices[voice].volume_irq_mode = VMODE_START_NOTE;
+
+			gus_rampoff();
+			gus_ramp_range(2000, 4065);
+			gus_ramp_rate(0, 63);	/* Fastest possible rate */
+			gus_rampon(0x20 | 0x40);	/* Ramp down, once, irq */
+		}
+	}
 	restore_flags(flags);
 	return ret_val;
 }
 
-static void
-guswave_reset(int dev)
+static void guswave_reset(int dev)
 {
-	int             i;
+	int i;
 
 	for (i = 0; i < 32; i++)
-	  {
-		  gus_voice_init(i);
-		  gus_voice_init2(i);
-	  }
+	{
+		gus_voice_init(i);
+		gus_voice_init2(i);
+	}
 }
 
-static int
-guswave_open(int dev, int mode)
+static int guswave_open(int dev, int mode)
 {
-	int             err;
+	int err;
 
 	if (gus_busy)
 		return -EBUSY;
@@ -1678,10 +1651,11 @@
 	voice_alloc->timestamp = 0;
 
 	if ((err = DMAbuf_open_dma(gus_devnum)) < 0)
-	  {
-		  /* printk( "GUS: Loading samples without DMA\n"); */
-		  gus_no_dma = 1;	/* Upload samples using PIO */
-	} else
+	{
+		/* printk( "GUS: Loading samples without DMA\n"); */
+		gus_no_dma = 1;	/* Upload samples using PIO */
+	}
+	else
 		gus_no_dma = 0;
 
 	dram_sleep_flag.opts = WK_NONE;
@@ -1696,8 +1670,7 @@
 	return 0;
 }
 
-static void
-guswave_close(int dev)
+static void guswave_close(int dev)
 {
 	gus_busy = 0;
 	active_device = 0;
@@ -1707,35 +1680,34 @@
 		DMAbuf_close_dma(gus_devnum);
 }
 
-static int
-guswave_load_patch(int dev, int format, const char *addr,
+static int guswave_load_patch(int dev, int format, const char *addr,
 		   int offs, int count, int pmgr_flag)
 {
 	struct patch_info patch;
-	int             instr;
-	long            sizeof_patch;
+	int instr;
+	long sizeof_patch;
 
-	unsigned long   blk_sz, blk_end, left, src_offs, target;
+	unsigned long blk_sz, blk_end, left, src_offs, target;
 
 	sizeof_patch = (long) &patch.data[0] - (long) &patch;	/* Header size */
 
 	if (format != GUS_PATCH)
-	  {
-		  printk("GUS Error: Invalid patch format (key) 0x%x\n", format);
-		  return -EINVAL;
-	  }
+	{
+/*		printk("GUS Error: Invalid patch format (key) 0x%x\n", format);*/
+		return -EINVAL;
+	}
 	if (count < sizeof_patch)
-	  {
-		  printk("GUS Error: Patch header too short\n");
+	{
+/*		  printk("GUS Error: Patch header too short\n");*/
 		  return -EINVAL;
-	  }
+	}
 	count -= sizeof_patch;
 
 	if (free_sample >= MAX_SAMPLE)
-	  {
-		  printk("GUS: Sample table full\n");
+	{
+/*		  printk("GUS: Sample table full\n");*/
 		  return -ENOSPC;
-	  }
+	}
 	/*
 	 * Copy the header from user space but ignore the first bytes which have
 	 * been transferred already.
@@ -1746,63 +1718,63 @@
 	if (patch.mode & WAVE_ROM)
 		return -EINVAL;
 	if (gus_mem_size == 0)
-
 		return -ENOSPC;
 
 	instr = patch.instr_no;
 
 	if (instr < 0 || instr > MAX_PATCH)
-	  {
-		  printk("GUS: Invalid patch number %d\n", instr);
-		  return -EINVAL;
-	  }
+	{
+/*		printk(KERN_ERR "GUS: Invalid patch number %d\n", instr);*/
+		return -EINVAL;
+	}
 	if (count < patch.len)
-	  {
-		  printk("GUS Warning: Patch record too short (%d<%d)\n", count, (int) patch.len);
-		  patch.len = count;
-	  }
+	{
+/*		printk(KERN_ERR "GUS Warning: Patch record too short (%d<%d)\n", count, (int) patch.len);*/
+		patch.len = count;
+	}
 	if (patch.len <= 0 || patch.len > gus_mem_size)
-	  {
-		  printk("GUS: Invalid sample length %d\n", (int) patch.len);
-		  return -EINVAL;
-	  }
+	{
+/*		printk(KERN_ERR "GUS: Invalid sample length %d\n", (int) patch.len);*/
+		return -EINVAL;
+	}
 	if (patch.mode & WAVE_LOOPING)
-	  {
-		  if (patch.loop_start < 0 || patch.loop_start >= patch.len)
-		    {
-			    printk("GUS: Invalid loop start\n");
-			    return -EINVAL;
-		    }
-		  if (patch.loop_end < patch.loop_start || patch.loop_end > patch.len)
-		    {
-			    printk("GUS: Invalid loop end\n");
-			    return -EINVAL;
-		    }
-	  }
+	{
+		if (patch.loop_start < 0 || patch.loop_start >= patch.len)
+		{
+/*			printk(KERN_ERR "GUS: Invalid loop start\n");*/
+			return -EINVAL;
+		}
+		if (patch.loop_end < patch.loop_start || patch.loop_end > patch.len)
+		{
+/*			printk(KERN_ERR "GUS: Invalid loop end\n");*/
+			return -EINVAL;
+		}
+	}
 	free_mem_ptr = (free_mem_ptr + 31) & ~31;	/* 32 byte alignment */
 
 	if (patch.mode & WAVE_16_BITS)
-	  {
-		  /*
-		   * 16 bit samples must fit one 256k bank.
-		   */
-		  if (patch.len >= GUS_BANK_SIZE)
-		    {
-			    printk("GUS: Sample (16 bit) too long %d\n", (int) patch.len);
-			    return -ENOSPC;
-		    }
-		  if ((free_mem_ptr / GUS_BANK_SIZE) !=
-		      ((free_mem_ptr + patch.len) / GUS_BANK_SIZE))
-		    {
-			    unsigned long   tmp_mem =	/* Align to 256K */
-			    ((free_mem_ptr / GUS_BANK_SIZE) + 1) * GUS_BANK_SIZE;
+	{
+		/*
+		 * 16 bit samples must fit one 256k bank.
+		 */
+		if (patch.len >= GUS_BANK_SIZE)
+		{
+/*			 printk("GUS: Sample (16 bit) too long %d\n", (int) patch.len);*/
+			return -ENOSPC;
+		}
+		if ((free_mem_ptr / GUS_BANK_SIZE) !=
+			((free_mem_ptr + patch.len) / GUS_BANK_SIZE))
+		{
+			unsigned long   tmp_mem =	
+				/* Align to 256K */
+					((free_mem_ptr / GUS_BANK_SIZE) + 1) * GUS_BANK_SIZE;
 
-			    if ((tmp_mem + patch.len) > gus_mem_size)
-				    return -ENOSPC;
+			if ((tmp_mem + patch.len) > gus_mem_size)
+				return -ENOSPC;
 
-			    free_mem_ptr = tmp_mem;	/* This leaves unusable memory */
-		    }
-	  }
+			free_mem_ptr = tmp_mem;		/* This leaves unusable memory */
+		}
+	}
 	if ((free_mem_ptr + patch.len) > gus_mem_size)
 		return -ENOSPC;
 
@@ -1816,9 +1788,9 @@
 		patch.mode &= ~WAVE_TREMOLO;
 
 	if (!(patch.mode & WAVE_FRACTIONS))
-	  {
+	{
 		  patch.fractions = 0;
-	  }
+	}
 	memcpy((char *) &samples[free_sample], &patch, sizeof_patch);
 
 	/*
@@ -1837,162 +1809,154 @@
 	target = free_mem_ptr;
 
 	while (left)		/* Not completely transferred yet */
-	  {
-		  blk_sz = audio_devs[gus_devnum]->dmap_out->bytes_in_use;
-		  if (blk_sz > left)
-			  blk_sz = left;
-
-		  /*
-		   * DMA cannot cross bank (256k) boundaries. Check for that.
-		   */
-		  blk_end = target + blk_sz;
-
-		  if ((target / GUS_BANK_SIZE) != (blk_end / GUS_BANK_SIZE))
-		    {		/* Split the block */
-
-			    blk_end &= ~(GUS_BANK_SIZE - 1);
-			    blk_sz = blk_end - target;
-		    }
-		  if (gus_no_dma)
-		    {
-			    /*
-			     * For some reason the DMA is not possible. We have to use PIO.
-			     */
-			    long            i;
-			    unsigned char   data;
-
-			    for (i = 0; i < blk_sz; i++)
-			      {
-				      get_user(*(unsigned char *) &data, (unsigned char *) &((addr)[sizeof_patch + i]));
-				      if (patch.mode & WAVE_UNSIGNED)
-					      if (!(patch.mode & WAVE_16_BITS) || (i & 0x01))
-						      data ^= 0x80;	/* Convert to signed */
-				      gus_poke(target + i, data);
-			      }
-		  } else
-		    {
-			    unsigned long   address, hold_address;
-			    unsigned char   dma_command;
-			    unsigned long   flags;
-
-			    if (audio_devs[gus_devnum]->dmap_out->raw_buf == NULL)
-			      {
-				      printk("GUS: DMA buffer == NULL\n");
-				      return -ENOSPC;
-			      }
-			    /*
-			     * OK, move now. First in and then out.
-			     */
-
-			    copy_from_user(audio_devs[gus_devnum]->dmap_out->raw_buf, &(addr)[sizeof_patch + src_offs], blk_sz);
-
-			    save_flags(flags);
-			    cli();
-/******** INTERRUPTS DISABLED NOW ********/
-			    gus_write8(0x41, 0);	/* Disable GF1 DMA */
-			    DMAbuf_start_dma(gus_devnum,
-					     audio_devs[gus_devnum]->dmap_out->raw_buf_phys,
-					     blk_sz, DMA_MODE_WRITE);
-
-			    /*
-			     * Set the DRAM address for the wave data
-			     */
-
-			    if (iw_mode)
-			      {
-				      /* Different address translation in enhanced mode */
-
-				      unsigned char   hi;
-
-				      if (gus_dma > 4)
-					      address = target >> 1;	/* Convert to 16 bit word address */
-				      else
-					      address = target;
-
-				      hi = (unsigned char) ((address >> 16) & 0xf0);
-				      hi += (unsigned char) (address & 0x0f);
-
-				      gus_write16(0x42, (address >> 4) & 0xffff);	/* DMA address (low) */
-				      gus_write8(0x50, hi);
-			    } else
-			      {
-				      address = target;
+	{
+		blk_sz = audio_devs[gus_devnum]->dmap_out->bytes_in_use;
+		if (blk_sz > left)
+			blk_sz = left;
 
-				      if (audio_devs[gus_devnum]->dmap_out->dma > 3)
-					{
-						hold_address = address;
-						address = address >> 1;
-						address &= 0x0001ffffL;
-						address |= (hold_address & 0x000c0000L);
-					}
-				      gus_write16(0x42, (address >> 4) & 0xffff);	/* DRAM DMA address */
-			      }
+		/*
+		 * DMA cannot cross bank (256k) boundaries. Check for that.
+		 */
+		 
+		blk_end = target + blk_sz;
 
-			    /*
-			     * Start the DMA transfer
-			     */
-
-			    dma_command = 0x21;		/* IRQ enable, DMA start */
-			    if (patch.mode & WAVE_UNSIGNED)
-				    dma_command |= 0x80;	/* Invert MSB */
-			    if (patch.mode & WAVE_16_BITS)
-				    dma_command |= 0x40;	/* 16 bit _DATA_ */
-			    if (audio_devs[gus_devnum]->dmap_out->dma > 3)
-				    dma_command |= 0x04;	/* 16 bit DMA _channel_ */
-
-			    gus_write8(0x41, dma_command);	/* Lets go luteet (=bugs) */
-
-			    /*
-			     * Sleep here until the DRAM DMA done interrupt is served
-			     */
-			    active_device = GUS_DEV_WAVE;
-
-
-			    {
-				    unsigned long   tlimit;
-
-				    if (HZ)
-					    current->timeout = tlimit = jiffies + (HZ);
-				    else
-					    tlimit = (unsigned long) -1;
-				    dram_sleep_flag.opts = WK_SLEEP;
-				    interruptible_sleep_on(&dram_sleeper);
-				    if (!(dram_sleep_flag.opts & WK_WAKEUP))
-				      {
-					      if (jiffies >= tlimit)
-						      dram_sleep_flag.opts |= WK_TIMEOUT;
-				      }
-				    dram_sleep_flag.opts &= ~WK_SLEEP;
-			    };
-			    if ((dram_sleep_flag.opts & WK_TIMEOUT))
-				    printk("GUS: DMA Transfer timed out\n");
-			    restore_flags(flags);
-		    }
-
-		  /*
-		   * Now the next part
-		   */
-
-		  left -= blk_sz;
-		  src_offs += blk_sz;
-		  target += blk_sz;
+		if ((target / GUS_BANK_SIZE) != (blk_end / GUS_BANK_SIZE))
+		{
+			/* Split the block */
+			blk_end &= ~(GUS_BANK_SIZE - 1);
+			blk_sz = blk_end - target;
+		}
+		if (gus_no_dma)
+		{
+			/*
+			 * For some reason the DMA is not possible. We have to use PIO.
+			 */
+			long i;
+			unsigned char data;
 
-		  gus_write8(0x41, 0);	/* Stop DMA */
-	  }
+			for (i = 0; i < blk_sz; i++)
+			{
+				get_user(*(unsigned char *) &data, (unsigned char *) &((addr)[sizeof_patch + i]));
+				if (patch.mode & WAVE_UNSIGNED)
+					if (!(patch.mode & WAVE_16_BITS) || (i & 0x01))
+						data ^= 0x80;	/* Convert to signed */
+				gus_poke(target + i, data);
+			}
+		}
+		else
+		{
+			unsigned long address, hold_address;
+			unsigned char dma_command;
+			unsigned long flags;
+			unsigned long tlimit;
 
-	free_mem_ptr += patch.len;
+			if (audio_devs[gus_devnum]->dmap_out->raw_buf == NULL)
+			{
+				printk(KERN_ERR "GUS: DMA buffer == NULL\n");
+				return -ENOSPC;
+			}
+			/*
+			 * OK, move now. First in and then out.
+			 */
+
+			copy_from_user(audio_devs[gus_devnum]->dmap_out->raw_buf, &(addr)[sizeof_patch + src_offs], blk_sz);
+
+			save_flags(flags);
+			cli();
+			/******** INTERRUPTS DISABLED NOW ********/
+			gus_write8(0x41, 0);	/* Disable GF1 DMA */
+			DMAbuf_start_dma(gus_devnum, audio_devs[gus_devnum]->dmap_out->raw_buf_phys,
+				blk_sz, DMA_MODE_WRITE);
+
+			/*
+			 * Set the DRAM address for the wave data
+			 */
 
+			if (iw_mode)
+			{
+				/* Different address translation in enhanced mode */
+
+				unsigned char   hi;
+
+				if (gus_dma > 4)
+					address = target >> 1;	/* Convert to 16 bit word address */
+				else
+					address = target;
+
+				hi = (unsigned char) ((address >> 16) & 0xf0);
+				hi += (unsigned char) (address & 0x0f);
+
+				gus_write16(0x42, (address >> 4) & 0xffff);	/* DMA address (low) */
+				gus_write8(0x50, hi);
+			}
+			else
+			{
+				address = target;
+				if (audio_devs[gus_devnum]->dmap_out->dma > 3)
+				{
+					hold_address = address;
+					address = address >> 1;
+					address &= 0x0001ffffL;
+					address |= (hold_address & 0x000c0000L);
+				}
+				gus_write16(0x42, (address >> 4) & 0xffff);	/* DRAM DMA address */
+			}
+
+			/*
+			 * Start the DMA transfer
+			 */
+
+			dma_command = 0x21;		/* IRQ enable, DMA start */
+			if (patch.mode & WAVE_UNSIGNED)
+				dma_command |= 0x80;	/* Invert MSB */
+			if (patch.mode & WAVE_16_BITS)
+				dma_command |= 0x40;	/* 16 bit _DATA_ */
+			if (audio_devs[gus_devnum]->dmap_out->dma > 3)
+				dma_command |= 0x04;	/* 16 bit DMA _channel_ */
+			
+			gus_write8(0x41, dma_command);	/* Lets go luteet (=bugs) */
+
+			/*
+			 * Sleep here until the DRAM DMA done interrupt is served
+			 */
+			active_device = GUS_DEV_WAVE;
+
+			current->timeout = tlimit = jiffies + HZ;
+			dram_sleep_flag.opts = WK_SLEEP;
+			interruptible_sleep_on(&dram_sleeper);
+			if (!(dram_sleep_flag.opts & WK_WAKEUP))
+			{
+				if (jiffies >= tlimit)
+					dram_sleep_flag.opts |= WK_TIMEOUT;
+			}
+			dram_sleep_flag.opts &= ~WK_SLEEP;
+			if ((dram_sleep_flag.opts & WK_TIMEOUT))
+				printk(KERN_WARNING "GUS: DMA Transfer timed out\n");
+			restore_flags(flags);
+		}
+
+		/*
+		 * Now the next part
+		 */
+
+		left -= blk_sz;
+		src_offs += blk_sz;
+		target += blk_sz;
+
+		gus_write8(0x41, 0);	/* Stop DMA */
+	}
+
+	free_mem_ptr += patch.len;
 	free_sample++;
 	return 0;
 }
 
-static void
-guswave_hw_control(int dev, unsigned char *event_rec)
+static void guswave_hw_control(int dev, unsigned char *event_rec)
 {
-	int             voice, cmd;
-	unsigned short  p1, p2;
-	unsigned int    plong;
-	unsigned        flags;
+	int voice, cmd;
+	unsigned short p1, p2;
+	unsigned int plong;
+	unsigned flags;
 
 	cmd = event_rec[2];
 	voice = event_rec[3];
@@ -2001,156 +1965,152 @@
 	plong = *(unsigned int *) &event_rec[4];
 
 	if ((voices[voice].volume_irq_mode == VMODE_START_NOTE) &&
-	    (cmd != _GUS_VOICESAMPLE) && (cmd != _GUS_VOICE_POS))
+		(cmd != _GUS_VOICESAMPLE) && (cmd != _GUS_VOICE_POS))
 		do_volume_irq(voice);
 
 	switch (cmd)
-	  {
+	{
+		case _GUS_NUMVOICES:
+			save_flags(flags);
+			cli();
+			gus_select_voice(voice);
+			gus_select_max_voices(p1);
+			restore_flags(flags);
+			break;
+
+		case _GUS_VOICESAMPLE:
+			guswave_set_instr(dev, voice, p1);
+			break;
 
-	  case _GUS_NUMVOICES:
-		  save_flags(flags);
-		  cli();
-		  gus_select_voice(voice);
-		  gus_select_max_voices(p1);
-		  restore_flags(flags);
-		  break;
-
-	  case _GUS_VOICESAMPLE:
-		  guswave_set_instr(dev, voice, p1);
-		  break;
-
-	  case _GUS_VOICEON:
-		  save_flags(flags);
-		  cli();
-		  gus_select_voice(voice);
-		  p1 &= ~0x20;	/* Don't allow interrupts */
-		  gus_voice_on(p1);
-		  restore_flags(flags);
-		  break;
-
-	  case _GUS_VOICEOFF:
-		  save_flags(flags);
-		  cli();
-		  gus_select_voice(voice);
-		  gus_voice_off();
-		  restore_flags(flags);
-		  break;
-
-	  case _GUS_VOICEFADE:
-		  gus_voice_fade(voice);
-		  break;
-
-	  case _GUS_VOICEMODE:
-		  save_flags(flags);
-		  cli();
-		  gus_select_voice(voice);
-		  p1 &= ~0x20;	/* Don't allow interrupts */
-		  gus_voice_mode(p1);
-		  restore_flags(flags);
-		  break;
-
-	  case _GUS_VOICEBALA:
-		  save_flags(flags);
-		  cli();
-		  gus_select_voice(voice);
-		  gus_voice_balance(p1);
-		  restore_flags(flags);
-		  break;
-
-	  case _GUS_VOICEFREQ:
-		  save_flags(flags);
-		  cli();
-		  gus_select_voice(voice);
-		  gus_voice_freq(plong);
-		  restore_flags(flags);
-		  break;
-
-	  case _GUS_VOICEVOL:
-		  save_flags(flags);
-		  cli();
-		  gus_select_voice(voice);
-		  gus_voice_volume(p1);
-		  restore_flags(flags);
-		  break;
-
-	  case _GUS_VOICEVOL2:	/* Just update the software voice level */
-		  voices[voice].initial_volume =
-		      voices[voice].current_volume = p1;
-		  break;
-
-	  case _GUS_RAMPRANGE:
-		  if (voices[voice].mode & WAVE_ENVELOPES)
-			  break;	/* NO-NO */
-		  save_flags(flags);
-		  cli();
-		  gus_select_voice(voice);
-		  gus_ramp_range(p1, p2);
-		  restore_flags(flags);
-		  break;
-
-	  case _GUS_RAMPRATE:
-		  if (voices[voice].mode & WAVE_ENVELOPES)
-			  break;	/* NJET-NJET */
-		  save_flags(flags);
-		  cli();
-		  gus_select_voice(voice);
-		  gus_ramp_rate(p1, p2);
-		  restore_flags(flags);
-		  break;
-
-	  case _GUS_RAMPMODE:
-		  if (voices[voice].mode & WAVE_ENVELOPES)
-			  break;	/* NO-NO */
-		  save_flags(flags);
-		  cli();
-		  gus_select_voice(voice);
-		  p1 &= ~0x20;	/* Don't allow interrupts */
-		  gus_ramp_mode(p1);
-		  restore_flags(flags);
-		  break;
-
-	  case _GUS_RAMPON:
-		  if (voices[voice].mode & WAVE_ENVELOPES)
-			  break;	/* EI-EI */
-		  save_flags(flags);
-		  cli();
-		  gus_select_voice(voice);
-		  p1 &= ~0x20;	/* Don't allow interrupts */
-		  gus_rampon(p1);
-		  restore_flags(flags);
-		  break;
-
-	  case _GUS_RAMPOFF:
-		  if (voices[voice].mode & WAVE_ENVELOPES)
-			  break;	/* NEJ-NEJ */
-		  save_flags(flags);
-		  cli();
-		  gus_select_voice(voice);
-		  gus_rampoff();
-		  restore_flags(flags);
-		  break;
-
-	  case _GUS_VOLUME_SCALE:
-		  volume_base = p1;
-		  volume_scale = p2;
-		  break;
-
-	  case _GUS_VOICE_POS:
-		  save_flags(flags);
-		  cli();
-		  gus_select_voice(voice);
-		  gus_set_voice_pos(voice, plong);
-		  restore_flags(flags);
-		  break;
+		case _GUS_VOICEON:
+			save_flags(flags);
+			cli();
+			gus_select_voice(voice);
+			p1 &= ~0x20;	/* Don't allow interrupts */
+			gus_voice_on(p1);
+			restore_flags(flags);
+			break;
 
-	  default:;
-	  }
+		case _GUS_VOICEOFF:
+			save_flags(flags);
+			cli();
+			gus_select_voice(voice);
+			gus_voice_off();
+			restore_flags(flags);
+			break;
+
+		case _GUS_VOICEFADE:
+			gus_voice_fade(voice);
+			break;
+
+		case _GUS_VOICEMODE:
+			save_flags(flags);
+			cli();
+			gus_select_voice(voice);
+			p1 &= ~0x20;	/* Don't allow interrupts */
+			gus_voice_mode(p1);
+			restore_flags(flags);
+			break;
+
+		case _GUS_VOICEBALA:
+			save_flags(flags);
+			cli();
+			gus_select_voice(voice);
+			gus_voice_balance(p1);
+			restore_flags(flags);
+			break;
+
+		case _GUS_VOICEFREQ:
+			save_flags(flags);
+			cli();
+			gus_select_voice(voice);
+			gus_voice_freq(plong);
+			restore_flags(flags);
+			break;
+
+		case _GUS_VOICEVOL:
+			save_flags(flags);
+			cli();
+			gus_select_voice(voice);
+			gus_voice_volume(p1);
+			restore_flags(flags);
+			break;
+
+		case _GUS_VOICEVOL2:	/* Just update the software voice level */
+			voices[voice].initial_volume = voices[voice].current_volume = p1;
+			break;
+
+		case _GUS_RAMPRANGE:
+			if (voices[voice].mode & WAVE_ENVELOPES)
+				break;	/* NO-NO */
+			save_flags(flags);
+			cli();
+			gus_select_voice(voice);
+			gus_ramp_range(p1, p2);
+			restore_flags(flags);
+			break;
+
+		case _GUS_RAMPRATE:
+			if (voices[voice].mode & WAVE_ENVELOPES)
+				break;	/* NJET-NJET */
+			save_flags(flags);
+			cli();
+			gus_select_voice(voice);
+			gus_ramp_rate(p1, p2);
+			restore_flags(flags);
+			break;
+
+		case _GUS_RAMPMODE:
+			if (voices[voice].mode & WAVE_ENVELOPES)
+				break;	/* NO-NO */
+			save_flags(flags);
+			cli();
+			gus_select_voice(voice);
+			p1 &= ~0x20;	/* Don't allow interrupts */
+			gus_ramp_mode(p1);
+			restore_flags(flags);
+			break;
+
+		case _GUS_RAMPON:
+			if (voices[voice].mode & WAVE_ENVELOPES)
+				break;	/* EI-EI */
+			save_flags(flags);
+			cli();
+			gus_select_voice(voice);
+			p1 &= ~0x20;	/* Don't allow interrupts */
+			gus_rampon(p1);
+			restore_flags(flags);
+			break;
+
+		case _GUS_RAMPOFF:
+			if (voices[voice].mode & WAVE_ENVELOPES)
+				break;	/* NEJ-NEJ */
+			save_flags(flags);
+			cli();
+			gus_select_voice(voice);
+			gus_rampoff();
+			restore_flags(flags);
+			break;
+
+		case _GUS_VOLUME_SCALE:
+			volume_base = p1;
+			volume_scale = p2;
+			break;
+
+		case _GUS_VOICE_POS:
+			save_flags(flags);
+			cli();
+			gus_select_voice(voice);
+			gus_set_voice_pos(voice, plong);
+			restore_flags(flags);
+			break;
+
+		default:
+	}
 }
 
-static int
-gus_audio_set_speed(int speed)
+static int gus_audio_set_speed(int speed)
 {
-
 	if (speed <= 0)
 		speed = gus_audio_speed;
 
@@ -2163,18 +2123,17 @@
 	gus_audio_speed = speed;
 
 	if (only_read_access)
-	  {
-		  /* Compute nearest valid recording speed  and return it */
+	{
+		/* Compute nearest valid recording speed  and return it */
 
-		  /* speed = (9878400 / (gus_audio_speed + 2)) / 16; */
-		  speed = (((9878400 + gus_audio_speed / 2) / (gus_audio_speed + 2)) + 8) / 16;
-		  speed = (9878400 / (speed * 16)) - 2;
-	  }
+		/* speed = (9878400 / (gus_audio_speed + 2)) / 16; */
+		speed = (((9878400 + gus_audio_speed / 2) / (gus_audio_speed + 2)) + 8) / 16;
+		speed = (9878400 / (speed * 16)) - 2;
+	}
 	return speed;
 }
 
-static int
-gus_audio_set_channels(int channels)
+static int gus_audio_set_channels(int channels)
 {
 	if (!channels)
 		return gus_audio_channels;
@@ -2186,8 +2145,7 @@
 	return channels;
 }
 
-static int
-gus_audio_set_bits(int bits)
+static int gus_audio_set_bits(int bits)
 {
 	if (!bits)
 		return gus_audio_bits;
@@ -2206,70 +2164,75 @@
 {
 	int val;
 
-	switch (cmd) {
-	case SOUND_PCM_WRITE_RATE:
-		if (__get_user(val, (int *)arg))
-			return -EFAULT;
-		val = gus_audio_set_speed(val);
-		return __put_user(val, (int *)arg);
+	switch (cmd) 
+	{
+		case SOUND_PCM_WRITE_RATE:
+			if (get_user(val, (int *)arg))
+				return -EFAULT;
+			val = gus_audio_set_speed(val);
+			break;
 
-	case SOUND_PCM_READ_RATE:
-		return __put_user(gus_audio_speed, (int *)arg);
+		case SOUND_PCM_READ_RATE:
+			val = gus_audio_speed;
+			break;
 
-	case SNDCTL_DSP_STEREO:
-		if (__get_user(val, (int *)arg))
-			return -EFAULT;
-		val = gus_audio_set_channels(val + 1) - 1;
-		return __put_user(val, (int *)arg);
+		case SNDCTL_DSP_STEREO:
+			if (get_user(val, (int *)arg))
+				return -EFAULT;
+			val = gus_audio_set_channels(val + 1) - 1;
+			break;
 
-	case SOUND_PCM_WRITE_CHANNELS:
-		if (__get_user(val, (int *)arg))
-			return -EFAULT;
-		val = gus_audio_set_channels(val);
-		return __put_user(val, (int *)arg);
+		case SOUND_PCM_WRITE_CHANNELS:
+			if (get_user(val, (int *)arg))
+				return -EFAULT;
+			val = gus_audio_set_channels(val);
+			break;
 
-	case SOUND_PCM_READ_CHANNELS:
-		return __put_user(gus_audio_channels, (int *)arg);
+		case SOUND_PCM_READ_CHANNELS:
+			val = gus_audio_channels;
+			break;
 		
-	case SNDCTL_DSP_SETFMT:
-		if (__get_user(val, (int *)arg))
-			return -EFAULT;
-		val = gus_audio_set_bits(val);
-		return __put_user(val, (int *)arg);
+		case SNDCTL_DSP_SETFMT:
+			if (get_user(val, (int *)arg))
+				return -EFAULT;
+			val = gus_audio_set_bits(val);
+			break;
 		
-	case SOUND_PCM_READ_BITS:
-		return __put_user(gus_audio_bits, (int *)arg);
+		case SOUND_PCM_READ_BITS:
+			val = gus_audio_bits;
+			break;
 		
-	case SOUND_PCM_WRITE_FILTER:		/* NOT POSSIBLE */
-	case SOUND_PCM_READ_FILTER:
-		return __put_user(-EINVAL, (int *)arg);
+		case SOUND_PCM_WRITE_FILTER:		/* NOT POSSIBLE */
+		case SOUND_PCM_READ_FILTER:
+			val = -EINVAL;
+			break;
+		default:
+			return -EINVAL;
 	}
-	return -EINVAL;
+	return put_user(val, (int *)arg);
 }
 
-static void
-gus_audio_reset(int dev)
+static void gus_audio_reset(int dev)
 {
 	if (recording_active)
-	  {
-		  gus_write8(0x49, 0x00);	/* Halt recording */
-		  set_input_volumes();
-	  }
+	{
+		gus_write8(0x49, 0x00);	/* Halt recording */
+		set_input_volumes();
+	}
 }
 
-static int      saved_iw_mode;	/* A hack hack hack */
+static int saved_iw_mode;	/* A hack hack hack */
 
-static int
-gus_audio_open(int dev, int mode)
+static int gus_audio_open(int dev, int mode)
 {
 	if (gus_busy)
 		return -EBUSY;
 
 	if (gus_pnp_flag && mode & OPEN_READ)
-	  {
-		  printk("GUS: Audio device #%d is playback only.\n", dev);
-		  return -EIO;
-	  }
+	{
+/*		printk(KERN_ERR "GUS: Audio device #%d is playback only.\n", dev);*/
+		return -EIO;
+	}
 	gus_initialize();
 
 	gus_busy = 1;
@@ -2280,19 +2243,19 @@
 	gus_select_max_voices(14);
 	saved_iw_mode = iw_mode;
 	if (iw_mode)
-	  {
-		  /* There are some problems with audio in enhanced mode so disable it */
-		  gus_write8(0x19, gus_read8(0x19) & ~0x01);	/* Disable enhanced mode */
-		  iw_mode = 0;
-	  }
+	{
+		/* There are some problems with audio in enhanced mode so disable it */
+		gus_write8(0x19, gus_read8(0x19) & ~0x01);	/* Disable enhanced mode */
+		iw_mode = 0;
+	}
 	pcm_active = 0;
 	dma_active = 0;
 	pcm_opened = 1;
 	if (mode & OPEN_READ)
-	  {
-		  recording_active = 1;
-		  set_input_volumes();
-	  }
+	{
+		recording_active = 1;
+		set_input_volumes();
+	}
 	only_read_access = !(mode & OPEN_WRITE);
 	only_8_bits = mode & OPEN_READ;
 	if (only_8_bits)
@@ -2303,8 +2266,7 @@
 	return 0;
 }
 
-static void
-gus_audio_close(int dev)
+static void gus_audio_close(int dev)
 {
 	iw_mode = saved_iw_mode;
 	gus_reset();
@@ -2313,40 +2275,38 @@
 	active_device = 0;
 
 	if (recording_active)
-	  {
-		  gus_write8(0x49, 0x00);	/* Halt recording */
-		  set_input_volumes();
-	  }
+	{
+		gus_write8(0x49, 0x00);	/* Halt recording */
+		set_input_volumes();
+	}
 	recording_active = 0;
 }
 
-static void
-gus_audio_update_volume(void)
+static void gus_audio_update_volume(void)
 {
-	unsigned long   flags;
-	int             voice;
+	unsigned long flags;
+	int voice;
 
 	if (pcm_active && pcm_opened)
 		for (voice = 0; voice < gus_audio_channels; voice++)
-		  {
-			  save_flags(flags);
-			  cli();
-			  gus_select_voice(voice);
-			  gus_rampoff();
-			  gus_voice_volume(1530 + (25 * gus_pcm_volume));
-			  gus_ramp_range(65, 1530 + (25 * gus_pcm_volume));
-			  restore_flags(flags);
-		  }
+		{
+			save_flags(flags);
+			cli();
+			gus_select_voice(voice);
+			gus_rampoff();
+			gus_voice_volume(1530 + (25 * gus_pcm_volume));
+			gus_ramp_range(65, 1530 + (25 * gus_pcm_volume));
+			restore_flags(flags);
+		}
 }
 
-static void
-play_next_pcm_block(void)
+static void play_next_pcm_block(void)
 {
-	unsigned long   flags;
-	int             speed = gus_audio_speed;
-	int             this_one, is16bits, chn;
-	unsigned long   dram_loc;
-	unsigned char   mode[2], ramp_mode[2];
+	unsigned long flags;
+	int speed = gus_audio_speed;
+	int this_one, is16bits, chn;
+	unsigned long dram_loc;
+	unsigned char mode[2], ramp_mode[2];
 
 	if (!pcm_qlen)
 		return;
@@ -2354,95 +2314,91 @@
 	this_one = pcm_head;
 
 	for (chn = 0; chn < gus_audio_channels; chn++)
-	  {
-		  mode[chn] = 0x00;
-		  ramp_mode[chn] = 0x03;	/* Ramping and rollover off */
-
-		  if (chn == 0)
-		    {
-			    mode[chn] |= 0x20;	/* Loop IRQ */
-			    voices[chn].loop_irq_mode = LMODE_PCM;
-		    }
-		  if (gus_audio_bits != 8)
-		    {
-			    is16bits = 1;
-			    mode[chn] |= 0x04;	/* 16 bit data */
-		  } else
-			  is16bits = 0;
-
-		  dram_loc = this_one * pcm_bsize;
-		  dram_loc += chn * pcm_banksize;
-
-		  if (this_one == (pcm_nblk - 1))	/* Last fragment of the DRAM buffer */
-		    {
-			    mode[chn] |= 0x08;	/* Enable loop */
-			    ramp_mode[chn] = 0x03;	/* Disable rollover bit */
-		  } else
-		    {
-			    if (chn == 0)
-				    ramp_mode[chn] = 0x04;	/* Enable rollover bit */
-		    }
-
-		  save_flags(flags);
-		  cli();
-		  gus_select_voice(chn);
-		  gus_voice_freq(speed);
-
-		  if (gus_audio_channels == 1)
-			  gus_voice_balance(7);		/* mono */
-		  else if (chn == 0)
-			  gus_voice_balance(0);		/* left */
-		  else
-			  gus_voice_balance(15);	/* right */
-
-		  if (!pcm_active)	/* Playback not already active */
-		    {
-			    /*
-			     * The playback was not started yet (or there has been a pause).
-			     * Start the voice (again) and ask for a rollover irq at the end of
-			     * this_one block. If this_one one is last of the buffers, use just
-			     * the normal loop with irq.
-			     */
-
-			    gus_voice_off();
-			    gus_rampoff();
-			    gus_voice_volume(1530 + (25 * gus_pcm_volume));
-			    gus_ramp_range(65, 1530 + (25 * gus_pcm_volume));
+	{
+		mode[chn] = 0x00;
+		ramp_mode[chn] = 0x03;	/* Ramping and rollover off */
 
-			    gus_write_addr(0x0a, chn * pcm_banksize, 0, is16bits);	/* Starting position */
-			    gus_write_addr(0x02, chn * pcm_banksize, 0, is16bits);	/* Loop start */
+		if (chn == 0)
+		{
+			mode[chn] |= 0x20;	/* Loop IRQ */
+			voices[chn].loop_irq_mode = LMODE_PCM;
+		}
+		if (gus_audio_bits != 8)
+		{
+			is16bits = 1;
+			mode[chn] |= 0x04;	/* 16 bit data */
+		}
+		else
+			is16bits = 0;
 
-			    if (chn != 0)
-				    gus_write_addr(0x04, pcm_banksize + (pcm_bsize * pcm_nblk) - 1,
-						   0, is16bits);	/* Loop end location */
-		    }
-		  if (chn == 0)
-			  gus_write_addr(0x04, dram_loc + pcm_bsize - 1,
-					 0, is16bits);	/* Loop end location */
-		  else
-			  mode[chn] |= 0x08;	/* Enable looping */
+		dram_loc = this_one * pcm_bsize;
+		dram_loc += chn * pcm_banksize;
 
+		if (this_one == (pcm_nblk - 1))	/* Last fragment of the DRAM buffer */
+		{
+			mode[chn] |= 0x08;	/* Enable loop */
+			ramp_mode[chn] = 0x03;	/* Disable rollover bit */
+		}
+		else
+		{
+			if (chn == 0)
+				ramp_mode[chn] = 0x04;	/* Enable rollover bit */
+		}
+		save_flags(flags);
+		cli();
+		gus_select_voice(chn);
+		gus_voice_freq(speed);
+
+		if (gus_audio_channels == 1)
+			gus_voice_balance(7);		/* mono */
+		else if (chn == 0)
+			gus_voice_balance(0);		/* left */
+		else
+			gus_voice_balance(15);		/* right */
 
-		  restore_flags(flags);
-	  }
+		if (!pcm_active)	/* Playback not already active */
+		{
+			/*
+			 * The playback was not started yet (or there has been a pause).
+			 * Start the voice (again) and ask for a rollover irq at the end of
+			 * this_one block. If this_one one is last of the buffers, use just
+			 * the normal loop with irq.
+			 */
+
+			gus_voice_off();
+			gus_rampoff();
+			gus_voice_volume(1530 + (25 * gus_pcm_volume));
+			gus_ramp_range(65, 1530 + (25 * gus_pcm_volume));
 
-	for (chn = 0; chn < gus_audio_channels; chn++)
-	  {
-		  save_flags(flags);
-		  cli();
-		  gus_select_voice(chn);
-		  gus_write8(0x0d, ramp_mode[chn]);
-		  if (iw_mode)
-			  gus_write8(0x15, 0x00);	/* Reset voice deactivate bit of SMSI */
-		  gus_voice_on(mode[chn]);
-		  restore_flags(flags);
-	  }
+			gus_write_addr(0x0a, chn * pcm_banksize, 0, is16bits);	/* Starting position */
+			gus_write_addr(0x02, chn * pcm_banksize, 0, is16bits);	/* Loop start */
 
+			if (chn != 0)
+				gus_write_addr(0x04, pcm_banksize + (pcm_bsize * pcm_nblk) - 1,
+						   0, is16bits);	/* Loop end location */
+		}
+		if (chn == 0)
+			gus_write_addr(0x04, dram_loc + pcm_bsize - 1,
+					 0, is16bits);	/* Loop end location */
+		else
+			mode[chn] |= 0x08;	/* Enable looping */
+		restore_flags(flags);
+	}
+	for (chn = 0; chn < gus_audio_channels; chn++)
+	{
+		save_flags(flags);
+		cli();
+		gus_select_voice(chn);
+		gus_write8(0x0d, ramp_mode[chn]);
+		if (iw_mode)
+			gus_write8(0x15, 0x00);	/* Reset voice deactivate bit of SMSI */
+		gus_voice_on(mode[chn]);
+		restore_flags(flags);
+	}
 	pcm_active = 1;
 }
 
-static void
-gus_transfer_output_block(int dev, unsigned long buf,
+static void gus_transfer_output_block(int dev, unsigned long buf,
 			  int total_count, int intrflag, int chn)
 {
 	/*
@@ -2454,10 +2410,10 @@
 	 * right data to the area pointed by gus_page_size.
 	 */
 
-	int             this_one, count;
-	unsigned long   flags;
-	unsigned char   dma_command;
-	unsigned long   address, hold_address;
+	int this_one, count;
+	unsigned long flags;
+	unsigned char dma_command;
+	unsigned long address, hold_address;
 
 	save_flags(flags);
 	cli();
@@ -2465,15 +2421,16 @@
 	count = total_count / gus_audio_channels;
 
 	if (chn == 0)
-	  {
-		  if (pcm_qlen >= pcm_nblk)
-			  printk("GUS Warning: PCM buffers out of sync\n");
-
-		  this_one = pcm_current_block = pcm_tail;
-		  pcm_qlen++;
-		  pcm_tail = (pcm_tail + 1) % pcm_nblk;
-		  pcm_datasize[this_one] = count;
-	} else
+	{
+		if (pcm_qlen >= pcm_nblk)
+			printk(KERN_WARNING "GUS Warning: PCM buffers out of sync\n");
+
+		this_one = pcm_current_block = pcm_tail;
+		pcm_qlen++;
+		pcm_tail = (pcm_tail + 1) % pcm_nblk;
+		pcm_datasize[this_one] = count;
+	}
+	else
 		this_one = pcm_current_block;
 
 	gus_write8(0x41, 0);	/* Disable GF1 DMA */
@@ -2483,12 +2440,12 @@
 	address += chn * pcm_banksize;
 
 	if (audio_devs[dev]->dmap_out->dma > 3)
-	  {
-		  hold_address = address;
-		  address = address >> 1;
-		  address &= 0x0001ffffL;
-		  address |= (hold_address & 0x000c0000L);
-	  }
+	{
+		hold_address = address;
+		address = address >> 1;
+		address &= 0x0001ffffL;
+		address |= (hold_address & 0x000c0000L);
+	}
 	gus_write16(0x42, (address >> 4) & 0xffff);	/* DRAM DMA address */
 
 	dma_command = 0x21;	/* IRQ enable, DMA start */
@@ -2504,62 +2461,60 @@
 	gus_write8(0x41, dma_command);	/* Kick start */
 
 	if (chn == (gus_audio_channels - 1))	/* Last channel */
-	  {
-		  /*
-		   * Last (right or mono) channel data
-		   */
-		  dma_active = 1;	/* DMA started. There is a unacknowledged buffer */
-		  active_device = GUS_DEV_PCM_DONE;
-		  if (!pcm_active && (pcm_qlen > 1 || count < pcm_bsize))
-		    {
-			    play_next_pcm_block();
-		    }
-	} else
-	  {
-		  /*
-		     * Left channel data. The right channel
-		     * is transferred after DMA interrupt
-		   */
-		  active_device = GUS_DEV_PCM_CONTINUE;
-	  }
+	{
+		/*
+		 * Last (right or mono) channel data
+		 */
+		dma_active = 1;	/* DMA started. There is a unacknowledged buffer */
+		active_device = GUS_DEV_PCM_DONE;
+		if (!pcm_active && (pcm_qlen > 1 || count < pcm_bsize))
+		{
+			play_next_pcm_block();
+		}
+	}
+	else
+	{
+		/*
+		 * Left channel data. The right channel
+		 * is transferred after DMA interrupt
+		 */
+		active_device = GUS_DEV_PCM_CONTINUE;
+	}
 
 	restore_flags(flags);
 }
 
-static void
-gus_uninterleave8(char *buf, int l)
+static void gus_uninterleave8(char *buf, int l)
 {
 /* This routine uninterleaves 8 bit stereo output (LRLRLR->LLLRRR) */
-	int             i, p = 0, halfsize = l / 2;
-	char           *buf2 = buf + halfsize, *src = bounce_buf;
+	int i, p = 0, halfsize = l / 2;
+	char *buf2 = buf + halfsize, *src = bounce_buf;
 
 	memcpy(bounce_buf, buf, l);
 
 	for (i = 0; i < halfsize; i++)
-	  {
-		  buf[i] = src[p++];	/* Left channel */
-		  buf2[i] = src[p++];	/* Right channel */
-	  }
+	{
+		buf[i] = src[p++];	/* Left channel */
+		buf2[i] = src[p++];	/* Right channel */
+	}
 }
 
-static void
-gus_uninterleave16(short *buf, int l)
+static void gus_uninterleave16(short *buf, int l)
 {
 /* This routine uninterleaves 16 bit stereo output (LRLRLR->LLLRRR) */
-	int             i, p = 0, halfsize = l / 2;
-	short          *buf2 = buf + halfsize, *src = (short *) bounce_buf;
+	int i, p = 0, halfsize = l / 2;
+	short *buf2 = buf + halfsize, *src = (short *) bounce_buf;
 
 	memcpy(bounce_buf, (char *) buf, l * 2);
 
 	for (i = 0; i < halfsize; i++)
-	  {
-		  buf[i] = src[p++];	/* Left channel */
-		  buf2[i] = src[p++];	/* Right channel */
-	  }
+	{
+		buf[i] = src[p++];	/* Left channel */
+		buf2[i] = src[p++];	/* Right channel */
+	}
 }
 
-static void
-gus_audio_output_block(int dev, unsigned long buf, int total_count,
+static void gus_audio_output_block(int dev, unsigned long buf, int total_count,
 		       int intrflag)
 {
 	struct dma_buffparms *dmap = audio_devs[dev]->dmap_out;
@@ -2571,29 +2526,27 @@
 	pcm_current_intrflag = intrflag;
 	pcm_current_dev = dev;
 	if (gus_audio_channels == 2)
-	  {
-		  char           *b = dmap->raw_buf + (buf - dmap->raw_buf_phys);
+	{
+		char *b = dmap->raw_buf + (buf - dmap->raw_buf_phys);
 
-		  if (gus_audio_bits == 8)
-			  gus_uninterleave8(b, total_count);
-		  else
-			  gus_uninterleave16((short *) b, total_count / 2);
-	  }
+		if (gus_audio_bits == 8)
+			gus_uninterleave8(b, total_count);
+		else
+			gus_uninterleave16((short *) b, total_count / 2);
+	}
 	gus_transfer_output_block(dev, buf, total_count, intrflag, 0);
 }
 
-static void
-gus_audio_start_input(int dev, unsigned long buf, int count,
+static void gus_audio_start_input(int dev, unsigned long buf, int count,
 		      int intrflag)
 {
-	unsigned long   flags;
-	unsigned char   mode;
+	unsigned long flags;
+	unsigned char mode;
 
 	save_flags(flags);
 	cli();
 
 	DMAbuf_start_dma(dev, buf, count, DMA_MODE_READ);
-
 	mode = 0xa0;		/* DMA IRQ enabled, invert MSB */
 
 	if (audio_devs[dev]->dmap_in->dma > 3)
@@ -2603,14 +2556,12 @@
 	mode |= 0x01;		/* DMA enable */
 
 	gus_write8(0x49, mode);
-
 	restore_flags(flags);
 }
 
-static int
-gus_audio_prepare_for_input(int dev, int bsize, int bcount)
+static int gus_audio_prepare_for_input(int dev, int bsize, int bcount)
 {
-	unsigned int    rate;
+	unsigned int rate;
 
 	gus_audio_bsize = bsize;
 	audio_devs[dev]->dmap_in->flags |= DMA_NODMA;
@@ -2619,19 +2570,18 @@
 	gus_write8(0x48, rate & 0xff);	/* Set sampling rate */
 
 	if (gus_audio_bits != 8)
-	  {
-		  printk("GUS Error: 16 bit recording not supported\n");
-		  return -EINVAL;
-	  }
+	{
+/*		printk("GUS Error: 16 bit recording not supported\n");*/
+		return -EINVAL;
+	}
 	return 0;
 }
 
-static int
-gus_audio_prepare_for_output(int dev, int bsize, int bcount)
+static int gus_audio_prepare_for_output(int dev, int bsize, int bcount)
 {
-	int             i;
+	int i;
 
-	long            mem_ptr, mem_size;
+	long mem_ptr, mem_size;
 
 	audio_devs[dev]->dmap_out->flags |= DMA_NODMA | DMA_NOTIMEOUT;
 	mem_ptr = 0;
@@ -2655,12 +2605,10 @@
 	if (gus_audio_bits != 8 && pcm_banksize == (256 * 1024))
 		pcm_nblk--;
 	gus_write8(0x41, 0);	/* Disable GF1 DMA */
-
 	return 0;
 }
 
-static int
-gus_local_qlen(int dev)
+static int gus_local_qlen(int dev)
 {
 	return pcm_qlen;
 }
@@ -2680,20 +2628,14 @@
 	NULL
 };
 
-static void
-guswave_setup_voice(int dev, int voice, int chn)
+static void guswave_setup_voice(int dev, int voice, int chn)
 {
-	struct channel_info *info =
-	&synth_devs[dev]->chn_info[chn];
+	struct channel_info *info = &synth_devs[dev]->chn_info[chn];
 
 	guswave_set_instr(dev, voice, info->pgm_num);
-
-	voices[voice].expression_vol =
-	    info->controllers[CTL_EXPRESSION];	/* Just MSB */
-	voices[voice].main_vol =
-	    (info->controllers[CTL_MAIN_VOLUME] * 100) / (unsigned) 128;
-	voices[voice].panning =
-	    (info->controllers[CTL_PAN] * 2) - 128;
+	voices[voice].expression_vol = info->controllers[CTL_EXPRESSION];	/* Just MSB */
+	voices[voice].main_vol = (info->controllers[CTL_MAIN_VOLUME] * 100) / (unsigned) 128;
+	voices[voice].panning = (info->controllers[CTL_PAN] * 2) - 128;
 	voices[voice].bender = 0;
 	voices[voice].bender_range = info->bender_range;
 
@@ -2701,15 +2643,13 @@
 		voices[voice].fixed_pitch = 1;
 }
 
-static void
-guswave_bender(int dev, int voice, int value)
+static void guswave_bender(int dev, int voice, int value)
 {
-	int             freq;
+	int freq;
 	unsigned long   flags;
 
 	voices[voice].bender = value - 8192;
-	freq = compute_finetune(voices[voice].orig_freq, value - 8192,
-				voices[voice].bender_range, 0);
+	freq = compute_finetune(voices[voice].orig_freq, value - 8192, voices[voice].bender_range, 0);
 	voices[voice].current_freq = freq;
 
 	save_flags(flags);
@@ -2719,45 +2659,43 @@
 	restore_flags(flags);
 }
 
-static int
-guswave_alloc(int dev, int chn, int note, struct voice_alloc_info *alloc)
+static int guswave_alloc(int dev, int chn, int note, struct voice_alloc_info *alloc)
 {
-	int             i, p, best = -1, best_time = 0x7fffffff;
+	int i, p, best = -1, best_time = 0x7fffffff;
 
 	p = alloc->ptr;
 	/*
-	   * First look for a completely stopped voice
+	 * First look for a completely stopped voice
 	 */
 
 	for (i = 0; i < alloc->max_voice; i++)
-	  {
-		  if (alloc->map[p] == 0)
-		    {
-			    alloc->ptr = p;
-			    return p;
-		    }
-		  if (alloc->alloc_times[p] < best_time)
-		    {
-			    best = p;
-			    best_time = alloc->alloc_times[p];
-		    }
-		  p = (p + 1) % alloc->max_voice;
-	  }
+	{
+		if (alloc->map[p] == 0)
+		{
+			alloc->ptr = p;
+			return p;
+		}
+		if (alloc->alloc_times[p] < best_time)
+		{
+			best = p;
+			best_time = alloc->alloc_times[p];
+		}
+		p = (p + 1) % alloc->max_voice;
+	}
 
 	/*
-	   * Then look for a releasing voice
+	 * Then look for a releasing voice
 	 */
 
 	for (i = 0; i < alloc->max_voice; i++)
-	  {
-		  if (alloc->map[p] == 0xffff)
-		    {
-			    alloc->ptr = p;
-			    return p;
-		    }
-		  p = (p + 1) % alloc->max_voice;
-	  }
-
+	{
+		if (alloc->map[p] == 0xffff)
+		{
+			alloc->ptr = p;
+			return p;
+		}
+		p = (p + 1) % alloc->max_voice;
+	}
 	if (best >= 0)
 		p = best;
 
@@ -2790,11 +2728,10 @@
 	guswave_setup_voice
 };
 
-static void
-set_input_volumes(void)
+static void set_input_volumes(void)
 {
-	unsigned long   flags;
-	unsigned char   mask = 0xff & ~0x06;	/* Just line out enabled */
+	unsigned long flags;
+	unsigned char mask = 0xff & ~0x06;	/* Just line out enabled */
 
 	if (have_gus_max)	/* Don't disturb GUS MAX */
 		return;
@@ -2813,15 +2750,15 @@
 		mask |= 0x04;
 
 	if (recording_active)
-	  {
-		  /*
-		   *    Disable channel, if not selected for recording
-		   */
-		  if (!(gus_recmask & SOUND_MASK_LINE))
-			  mask |= 0x01;
-		  if (!(gus_recmask & SOUND_MASK_MIC))
-			  mask &= ~0x04;
-	  }
+	{
+		/*
+		 *    Disable channel, if not selected for recording
+		 */
+		if (!(gus_recmask & SOUND_MASK_LINE))
+			mask |= 0x01;
+		if (!(gus_recmask & SOUND_MASK_MIC))
+			mask &= ~0x04;
+	}
 	mix_image &= ~0x07;
 	mix_image |= mask & 0x07;
 	outb((mix_image), u_Mixer);
@@ -2842,115 +2779,119 @@
 	if (!access_ok(VERIFY_WRITE, (int *)arg, sizeof(int)))
 		return -EFAULT;
 
-	if (_SIOC_DIR(cmd) & _SIOC_WRITE) {
+	if (_SIOC_DIR(cmd) & _SIOC_WRITE) 
+	{
 		if (__get_user(val, (int *) arg))
 			return -EFAULT;
 
-		switch (cmd & 0xff) {
-		case SOUND_MIXER_RECSRC:
-			gus_recmask = val & MIX_DEVS;
-			if (!(gus_recmask & (SOUND_MASK_MIC | SOUND_MASK_LINE)))
-				gus_recmask = SOUND_MASK_MIC;
-			/* Note! Input volumes are updated during next open for recording */
-			val = gus_recmask;
-			break;
-
-		case SOUND_MIXER_MIC:
-			vol = val & 0xff;
-			if (vol < 0)
-				vol = 0;
-			if (vol > 100)
-				vol = 100;
-			gus_mic_vol = vol;
-			set_input_volumes();
-			val = vol | (vol << 8);
-			break;
+		switch (cmd & 0xff) 
+		{
+			case SOUND_MIXER_RECSRC:
+				gus_recmask = val & MIX_DEVS;
+				if (!(gus_recmask & (SOUND_MASK_MIC | SOUND_MASK_LINE)))
+					gus_recmask = SOUND_MASK_MIC;
+				/* Note! Input volumes are updated during next open for recording */
+				val = gus_recmask;
+				break;
+
+			case SOUND_MIXER_MIC:
+				vol = val & 0xff;
+				if (vol < 0)
+					vol = 0;
+				if (vol > 100)
+					vol = 100;
+				gus_mic_vol = vol;
+				set_input_volumes();
+				val = vol | (vol << 8);
+				break;
 				
-		case SOUND_MIXER_LINE:
-			vol = val & 0xff;
-			if (vol < 0)
-				vol = 0;
-			if (vol > 100)
-				vol = 100;
-			gus_line_vol = vol;
-			set_input_volumes();
-			val = vol | (vol << 8);
-			break;
-
-		case SOUND_MIXER_PCM:
-			gus_pcm_volume = val & 0xff;
-			if (gus_pcm_volume < 0)
-				gus_pcm_volume = 0;
-			if (gus_pcm_volume > 100)
-				gus_pcm_volume = 100;
-			gus_audio_update_volume();
-			val = gus_pcm_volume | (gus_pcm_volume << 8);
-			break;
-
-		case SOUND_MIXER_SYNTH:
-			gus_wave_volume = val & 0xff;
-			if (gus_wave_volume < 0)
-				gus_wave_volume = 0;
-			if (gus_wave_volume > 100)
-				gus_wave_volume = 100;
-			if (active_device == GUS_DEV_WAVE) {
-				int voice;
-				for (voice = 0; voice < nr_voices; voice++)
+			case SOUND_MIXER_LINE:
+				vol = val & 0xff;
+				if (vol < 0)
+					vol = 0;
+				if (vol > 100)
+					vol = 100;
+				gus_line_vol = vol;
+				set_input_volumes();
+				val = vol | (vol << 8);
+				break;
+
+			case SOUND_MIXER_PCM:
+				gus_pcm_volume = val & 0xff;
+				if (gus_pcm_volume < 0)
+					gus_pcm_volume = 0;
+				if (gus_pcm_volume > 100)
+					gus_pcm_volume = 100;
+				gus_audio_update_volume();
+				val = gus_pcm_volume | (gus_pcm_volume << 8);
+				break;
+
+			case SOUND_MIXER_SYNTH:
+				gus_wave_volume = val & 0xff;
+				if (gus_wave_volume < 0)
+					gus_wave_volume = 0;
+				if (gus_wave_volume > 100)
+					gus_wave_volume = 100;
+				if (active_device == GUS_DEV_WAVE) 
+				{
+					int voice;
+					for (voice = 0; voice < nr_voices; voice++)
 					dynamic_volume_change(voice);	/* Apply the new vol */
-			}
-			val = gus_wave_volume | (gus_wave_volume << 8);
-			break;
+				}
+				val = gus_wave_volume | (gus_wave_volume << 8);
+				break;
 
-		default:
-			return -EINVAL;
+			default:
+				return -EINVAL;
 		}
-
-	} else {
-		switch (cmd & 0xff) {
-		/*
-		 * Return parameters
-		 */
-		case SOUND_MIXER_RECSRC:
-			val = gus_recmask;
-			break;
+	}
+	else
+	{
+		switch (cmd & 0xff) 
+		{
+			/*
+			 * Return parameters
+			 */
+			case SOUND_MIXER_RECSRC:
+				val = gus_recmask;
+				break;
 					
-		case SOUND_MIXER_DEVMASK:
-			val = MIX_DEVS;
-			break;
-
-		case SOUND_MIXER_STEREODEVS:
-			val = 0;
-			break;
-
-		case SOUND_MIXER_RECMASK:
-			val = SOUND_MASK_MIC | SOUND_MASK_LINE;
-			break;
-
-		case SOUND_MIXER_CAPS:
-			val = 0;
-			break;
-
-		case SOUND_MIXER_MIC:
-			val = gus_mic_vol | (gus_mic_vol << 8);
-			break;
-
-		case SOUND_MIXER_LINE:
-			val = gus_line_vol | (gus_line_vol << 8);
-			break;
+			case SOUND_MIXER_DEVMASK:
+				val = MIX_DEVS;
+				break;
+
+			case SOUND_MIXER_STEREODEVS:
+				val = 0;
+				break;
+
+			case SOUND_MIXER_RECMASK:
+				val = SOUND_MASK_MIC | SOUND_MASK_LINE;
+				break;
+
+			case SOUND_MIXER_CAPS:
+				val = 0;
+				break;
+
+			case SOUND_MIXER_MIC:
+				val = gus_mic_vol | (gus_mic_vol << 8);
+				break;
+
+			case SOUND_MIXER_LINE:
+				val = gus_line_vol | (gus_line_vol << 8);
+				break;
+
+			case SOUND_MIXER_PCM:
+				val = gus_pcm_volume | (gus_pcm_volume << 8);
+				break;
+
+			case SOUND_MIXER_SYNTH:
+				val = gus_wave_volume | (gus_wave_volume << 8);
+				break;
 
-		case SOUND_MIXER_PCM:
-			val = gus_pcm_volume | (gus_pcm_volume << 8);
-			break;
-
-		case SOUND_MIXER_SYNTH:
-			val = gus_wave_volume | (gus_wave_volume << 8);
-			break;
-
-		default:
-			return -EINVAL;
+			default:
+				return -EINVAL;
 		}
 	}
-
 	return __put_user(val, (int *)arg);
 }
 
@@ -2961,43 +2902,42 @@
 	gus_default_mixer_ioctl
 };
 
-static int
-gus_default_mixer_init(void)
+static int gus_default_mixer_init(void)
 {
-	int             n;
+	int n;
 
 	if ((n = sound_alloc_mixerdev()) != -1)
-	  {			/*
-				 * Don't install if there is another
-				 * mixer
-				 */
-		  mixer_devs[n] = &gus_mixer_operations;
-	  }
+	{	
+		/*
+		 * Don't install if there is another
+		 * mixer
+		 */
+		mixer_devs[n] = &gus_mixer_operations;
+	}
 	if (have_gus_max)
-	  {
-/*
- *  Enable all mixer channels on the GF1 side. Otherwise recording will
- *  not be possible using GUS MAX.
- */
-		  mix_image &= ~0x07;
-		  mix_image |= 0x04;	/* All channels enabled */
-		  outb((mix_image), u_Mixer);
-	  }
+	{
+		/*
+		 *  Enable all mixer channels on the GF1 side. Otherwise recording will
+		 *  not be possible using GUS MAX.
+		 */
+		mix_image &= ~0x07;
+		mix_image |= 0x04;	/* All channels enabled */
+		outb((mix_image), u_Mixer);
+	}
 	return n;
 }
 
 void gus_wave_init(struct address_info *hw_config)
 {
-	unsigned long   flags;
-	unsigned char   val;
-	char           *model_num = "2.4";
-	char            tmp[64], tmp2[64];
-	int             gus_type = 0x24;	/* 2.4 */
-
-	int             irq = hw_config->irq, dma = hw_config->dma,
-	                dma2 = hw_config->dma2;
-	int             dev;
-	int             sdev;
+	unsigned long flags;
+	unsigned char val;
+	char *model_num = "2.4";
+	char tmp[64], tmp2[64];
+	int gus_type = 0x24;	/* 2.4 */
+
+	int irq = hw_config->irq, dma = hw_config->dma, dma2 = hw_config->dma2;
+	int dev;
+	int sdev;
 
 	hw_config->slots[0] = -1;	/* No wave */
 	hw_config->slots[1] = -1;	/* No ad1848 */
@@ -3008,14 +2948,14 @@
 	{
 		if (irq < 0 || irq > 15)
 		{
-			printk("ERROR! Invalid IRQ#%d. GUS Disabled", irq);
+			printk(KERN_ERR "ERROR! Invalid IRQ#%d. GUS Disabled", irq);
 			return;
 		}
 	}
 	
 	if (dma < 0 || dma > 7 || dma == 4)
 	{
-		printk("ERROR! Invalid DMA#%d. GUS Disabled", dma);
+		printk(KERN_ERR "ERROR! Invalid DMA#%d. GUS Disabled", dma);
 		return;
 	}
 	gus_irq = irq;
@@ -3046,7 +2986,7 @@
 		/*
 		 * It has the digital ASIC so the card is at least v3.4.
 		 * Next try to detect the true model.
-		   */
+		 */
 
 		if (gus_pnp_flag)	/* Hack hack hack */
 			val = 10;
@@ -3124,9 +3064,9 @@
 				}
 			}
 			else
-				printk(KERN_WARNING "[Where's the CS4231?]");
+				printk(KERN_WARNING "GUS: No CS4231 ??");
 #else
-			printk("\n\n\nGUS MAX support was not compiled in!!!\n\n\n\n");
+			printk(KERN_ERR "GUS MAX found, but not compiled in\n");
 #endif
 		}
 	}
@@ -3291,78 +3231,77 @@
 	parm = voices[voice].loop_irq_parm;
 
 	switch (mode)
-	  {
+	{
+		case LMODE_FINISH:	/*
+					 * Final loop finished, shoot volume down
+					 */
 
-	  case LMODE_FINISH:	/*
-				 * Final loop finished, shoot volume down
-				 */
+			if ((int) (gus_read16(0x09) >> 4) < 100)	/*
+									 * Get current volume
+									 */
+			{
+				gus_voice_off();
+				gus_rampoff();
+				gus_voice_init(voice);
+				break;
+			}
+			gus_ramp_range(65, 4065);
+			gus_ramp_rate(0, 63);		/*
+							 * Fastest possible rate
+							 */
+			gus_rampon(0x20 | 0x40);	/*
+							 * Ramp down, once, irq
+							 */
+			voices[voice].volume_irq_mode = VMODE_HALT;
+			break;
 
-		  if ((int) (gus_read16(0x09) >> 4) < 100)	/*
-								 * Get current volume
-								 */
-		    {
-			    gus_voice_off();
-			    gus_rampoff();
-			    gus_voice_init(voice);
-			    break;
-		    }
-		  gus_ramp_range(65, 4065);
-		  gus_ramp_rate(0, 63);		/*
-						 * Fastest possible rate
-						 */
-		  gus_rampon(0x20 | 0x40);	/*
-						 * Ramp down, once, irq
-						 */
-		  voices[voice].volume_irq_mode = VMODE_HALT;
-		  break;
-
-	  case LMODE_PCM_STOP:
-		  pcm_active = 0;	/* Signal to the play_next_pcm_block routine */
-	  case LMODE_PCM:
-		  {
-
-			  pcm_qlen--;
-			  pcm_head = (pcm_head + 1) % pcm_nblk;
-			  if (pcm_qlen && pcm_active)
-			    {
-				    play_next_pcm_block();
-			  } else
-			    {	/* Underrun. Just stop the voice */
-				    gus_select_voice(0);	/* Left channel */
-				    gus_voice_off();
-				    gus_rampoff();
-				    gus_select_voice(1);	/* Right channel */
-				    gus_voice_off();
-				    gus_rampoff();
-				    pcm_active = 0;
-			    }
-
-			  /*
-			   * If the queue was full before this interrupt, the DMA transfer was
-			   * suspended. Let it continue now.
-			   */
-			  if (audio_devs[gus_devnum]->dmap_out->qlen > 0)
-				  DMAbuf_outputintr(gus_devnum, 0);
-		  }
-		  break;
+		case LMODE_PCM_STOP:
+			pcm_active = 0;	/* Signal to the play_next_pcm_block routine */
+		case LMODE_PCM:
+		{
+			pcm_qlen--;
+			pcm_head = (pcm_head + 1) % pcm_nblk;
+			if (pcm_qlen && pcm_active)
+			{
+				play_next_pcm_block();
+			}
+			else
+			{
+				/* Underrun. Just stop the voice */
+				gus_select_voice(0);	/* Left channel */
+				gus_voice_off();
+				gus_rampoff();
+				gus_select_voice(1);	/* Right channel */
+				gus_voice_off();
+				gus_rampoff();
+				pcm_active = 0;
+			}
 
-	  default:;
-	  }
+			/*
+			 * If the queue was full before this interrupt, the DMA transfer was
+			 * suspended. Let it continue now.
+			 */
+			
+			if (audio_devs[gus_devnum]->dmap_out->qlen > 0)
+				DMAbuf_outputintr(gus_devnum, 0);
+		}
+		break;
+
+		default:
+	}
 	restore_flags(flags);
 }
 
-static void
-do_volume_irq(int voice)
+static void do_volume_irq(int voice)
 {
-	unsigned char   tmp;
-	int             mode, parm;
-	unsigned long   flags;
+	unsigned char tmp;
+	int mode, parm;
+	unsigned long flags;
 
 	save_flags(flags);
 	cli();
 
 	gus_select_voice(voice);
-
 	tmp = gus_read8(0x0d);
 	tmp &= ~0x20;		/*
 				 * Disable volume ramp IRQ
@@ -3374,138 +3313,136 @@
 	parm = voices[voice].volume_irq_parm;
 
 	switch (mode)
-	  {
-	  case VMODE_HALT:	/* Decay phase finished */
-		  if (iw_mode)
-			  gus_write8(0x15, 0x02);	/* Set voice deactivate bit of SMSI */
-		  restore_flags(flags);
-		  gus_voice_init(voice);
-		  break;
-
-	  case VMODE_ENVELOPE:
-		  gus_rampoff();
-		  restore_flags(flags);
-		  step_envelope(voice);
-		  break;
-
-	  case VMODE_START_NOTE:
-		  restore_flags(flags);
-		  guswave_start_note2(voices[voice].dev_pending, voice,
+	{
+		case VMODE_HALT:	/* Decay phase finished */
+			if (iw_mode)
+				gus_write8(0x15, 0x02);	/* Set voice deactivate bit of SMSI */
+			restore_flags(flags);
+			gus_voice_init(voice);
+			break;
+
+		case VMODE_ENVELOPE:
+			gus_rampoff();
+			restore_flags(flags);
+			step_envelope(voice);
+			break;
+
+		case VMODE_START_NOTE:
+			restore_flags(flags);
+			guswave_start_note2(voices[voice].dev_pending, voice,
 				      voices[voice].note_pending, voices[voice].volume_pending);
-		  if (voices[voice].kill_pending)
-			  guswave_kill_note(voices[voice].dev_pending, voice,
+			if (voices[voice].kill_pending)
+				guswave_kill_note(voices[voice].dev_pending, voice,
 					  voices[voice].note_pending, 0);
 
-		  if (voices[voice].sample_pending >= 0)
-		    {
-			    guswave_set_instr(voices[voice].dev_pending, voice,
-					   voices[voice].sample_pending);
-			    voices[voice].sample_pending = -1;
-		    }
-		  break;
+			if (voices[voice].sample_pending >= 0)
+			{
+				guswave_set_instr(voices[voice].dev_pending, voice,
+					voices[voice].sample_pending);
+				voices[voice].sample_pending = -1;
+			}
+			break;
 
-	  default:
-		  restore_flags(flags);
-	  }
+		default:
+			restore_flags(flags);
+	}
 	restore_flags(flags);
 }
 
-void
-gus_voice_irq(void)
+void gus_voice_irq(void)
 {
-	unsigned long   wave_ignore = 0, volume_ignore = 0;
-	unsigned long   voice_bit;
+	unsigned long wave_ignore = 0, volume_ignore = 0;
+	unsigned long voice_bit;
 
-	unsigned char   src, voice;
+	unsigned char src, voice;
 
 	while (1)
-	  {
-		  src = gus_read8(0x0f);	/*
-						 * Get source info
-						 */
-		  voice = src & 0x1f;
-		  src &= 0xc0;
-
-		  if (src == (0x80 | 0x40))
-			  return;	/*
-					 * No interrupt
+	{
+		src = gus_read8(0x0f);	/*
+					 * Get source info
 					 */
+		voice = src & 0x1f;
+		src &= 0xc0;
+
+		if (src == (0x80 | 0x40))
+			return;	/*
+				 * No interrupt
+				 */
 
-		  voice_bit = 1 << voice;
+		voice_bit = 1 << voice;
 
-		  if (!(src & 0x80))	/*
+		if (!(src & 0x80))	/*
 					 * Wave IRQ pending
 					 */
-			  if (!(wave_ignore & voice_bit) && (int) voice < nr_voices)	/*
-											   * Not done
-											   * yet
+			if (!(wave_ignore & voice_bit) && (int) voice < nr_voices)	/*
+											 * Not done
+											 * yet
 											 */
-			    {
-				    wave_ignore |= voice_bit;
-				    do_loop_irq(voice);
-			    }
-		  if (!(src & 0x40))	/*
+			{
+				wave_ignore |= voice_bit;
+				do_loop_irq(voice);
+			}
+		if (!(src & 0x40))	/*
 					 * Volume IRQ pending
 					 */
-			  if (!(volume_ignore & voice_bit) && (int) voice < nr_voices)	/*
+			if (!(volume_ignore & voice_bit) && (int) voice < nr_voices)	/*
 											   * Not done
 											   * yet
 											 */
-			    {
-				    volume_ignore |= voice_bit;
-				    do_volume_irq(voice);
-			    }
-	  }
+			{
+				volume_ignore |= voice_bit;
+				do_volume_irq(voice);
+			}
+	}
 }
 
-void
-guswave_dma_irq(void)
+void guswave_dma_irq(void)
 {
 	unsigned char   status;
 
 	status = gus_look8(0x41);	/* Get DMA IRQ Status */
 	if (status & 0x40)	/* DMA interrupt pending */
 		switch (active_device)
-		  {
-		  case GUS_DEV_WAVE:
-			  if ((dram_sleep_flag.opts & WK_SLEEP))
-			    {
-				    dram_sleep_flag.opts = WK_WAKEUP;
-				    wake_up(&dram_sleeper);
-			    };
-			  break;
-
-		  case GUS_DEV_PCM_CONTINUE:	/* Left channel data transferred */
-			  gus_write8(0x41, 0);	/* Disable GF1 DMA */
-			  gus_transfer_output_block(pcm_current_dev, pcm_current_buf,
-						    pcm_current_count,
+		{
+			case GUS_DEV_WAVE:
+				if ((dram_sleep_flag.opts & WK_SLEEP))
+				{
+					dram_sleep_flag.opts = WK_WAKEUP;
+					wake_up(&dram_sleeper);
+				}
+				break;
+
+			case GUS_DEV_PCM_CONTINUE:	/* Left channel data transferred */
+				gus_write8(0x41, 0);	/* Disable GF1 DMA */
+				gus_transfer_output_block(pcm_current_dev, pcm_current_buf,
+						pcm_current_count,
 						pcm_current_intrflag, 1);
-			  break;
+				break;
 
-		  case GUS_DEV_PCM_DONE:	/* Right or mono channel data transferred */
-			  gus_write8(0x41, 0);	/* Disable GF1 DMA */
-			  if (pcm_qlen < pcm_nblk)
-			    {
-				    dma_active = 0;
-				    if (gus_busy)
-				      {
-					      if (audio_devs[gus_devnum]->dmap_out->qlen > 0)
-						      DMAbuf_outputintr(gus_devnum, 0);
-				      }
-			    }
-			  break;
+			case GUS_DEV_PCM_DONE:	/* Right or mono channel data transferred */
+				gus_write8(0x41, 0);	/* Disable GF1 DMA */
+				if (pcm_qlen < pcm_nblk)
+				{
+					dma_active = 0;
+					if (gus_busy)
+					{
+						if (audio_devs[gus_devnum]->dmap_out->qlen > 0)
+							DMAbuf_outputintr(gus_devnum, 0);
+					}
+				}
+				break;
 
-		  default:;
-		  }
+			default:
+	}
 	status = gus_look8(0x49);	/*
 					 * Get Sampling IRQ Status
 					 */
 	if (status & 0x40)	/*
 				 * Sampling Irq pending
 				 */
-	  {
-		  DMAbuf_inputintr(gus_devnum);
-	  }
+	{
+		DMAbuf_inputintr(gus_devnum);
+	}
 }
 
 #if defined(CONFIG_SEQUENCER) || defined(MODULE)
@@ -3517,10 +3454,9 @@
 static volatile int select_addr, data_addr;
 static volatile int curr_timer = 0;
 
-void
-gus_timer_command(unsigned int addr, unsigned int val)
+void gus_timer_command(unsigned int addr, unsigned int val)
 {
-	int             i;
+	int i;
 
 	outb(((unsigned char) (addr & 0xff)), select_addr);
 
@@ -3533,59 +3469,54 @@
 		inb(select_addr);
 }
 
-static void
-arm_timer(int timer, unsigned int interval)
+static void arm_timer(int timer, unsigned int interval)
 {
-
 	curr_timer = timer;
 
 	if (timer == 1)
-	  {
-		  gus_write8(0x46, 256 - interval);	/* Set counter for timer 1 */
-		  gus_write8(0x45, 0x04);	/* Enable timer 1 IRQ */
-		  gus_timer_command(0x04, 0x01);	/* Start timer 1 */
-	} else
-	  {
-		  gus_write8(0x47, 256 - interval);	/* Set counter for timer 2 */
-		  gus_write8(0x45, 0x08);	/* Enable timer 2 IRQ */
-		  gus_timer_command(0x04, 0x02);	/* Start timer 2 */
-	  }
+	{
+		gus_write8(0x46, 256 - interval);	/* Set counter for timer 1 */
+		gus_write8(0x45, 0x04);			/* Enable timer 1 IRQ */
+		gus_timer_command(0x04, 0x01);		/* Start timer 1 */
+	}
+	else
+	{
+		gus_write8(0x47, 256 - interval);	/* Set counter for timer 2 */
+		gus_write8(0x45, 0x08);			/* Enable timer 2 IRQ */
+		gus_timer_command(0x04, 0x02);		/* Start timer 2 */
+	}
 
 	gus_timer_enabled = 1;
 }
 
-static unsigned int
-gus_tmr_start(int dev, unsigned int usecs_per_tick)
+static unsigned int gus_tmr_start(int dev, unsigned int usecs_per_tick)
 {
-	int             timer_no, resolution;
-	int             divisor;
+	int timer_no, resolution;
+	int divisor;
 
 	if (usecs_per_tick > (256 * 80))
-	  {
-		  timer_no = 2;
-		  resolution = 320;	/* usec */
-	} else
-	  {
-		  timer_no = 1;
-		  resolution = 80;	/* usec */
-	  }
-
+	{
+		timer_no = 2;
+		resolution = 320;	/* usec */
+	}
+	else
+	{
+		timer_no = 1;
+		resolution = 80;	/* usec */
+	}
 	divisor = (usecs_per_tick + (resolution / 2)) / resolution;
-
 	arm_timer(timer_no, divisor);
 
 	return divisor * resolution;
 }
 
-static void
-gus_tmr_disable(int dev)
+static void gus_tmr_disable(int dev)
 {
 	gus_write8(0x45, 0);	/* Disable both timers */
 	gus_timer_enabled = 0;
 }
 
-static void
-gus_tmr_restart(int dev)
+static void gus_tmr_restart(int dev)
 {
 	if (curr_timer == 1)
 		gus_write8(0x45, 0x04);		/* Start timer 1 again */
@@ -3603,8 +3534,7 @@
 	gus_tmr_restart
 };
 
-static void
-gus_tmr_install(int io_base)
+static void gus_tmr_install(int io_base)
 {
 	struct sound_lowlev_timer *tmr;
 

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov