[parisc-linux-cvs] 2.4.17-pa9, harmony updates

Helge Deller deller@gmx.de
Tue, 15 Jan 2002 00:26:28 +0100


--------------Boundary-00=_4SBYFXIW5RUL45HJWK3L
Content-Type: text/plain;
  charset="iso-8859-1"
Content-Transfer-Encoding: 8bit

On Tuesday 15 January 2002 00:27, Helge Deller wrote:
> CVSROOT:	/var/cvs
> Module name:	linux
> Changes by:	deller	02/01/14 16:27:51
>
> Modified files:
> 	.              : Makefile
> 	drivers/sound  : harmony.c
>
> Log message:
> - 2.4.17-pa9
> - harmony updates:
> introduced a version number (starting with "0.9"),
> check value of dma_handle after pci_alloc_consistent(),
> return AFMT_S16_BE format for AFMT_S16_BE _and_ AFMT_S16_LE,
> clean up completely in case intializing of the card fails,
> allocate real size of mem region for harmony


--------------Boundary-00=_4SBYFXIW5RUL45HJWK3L
Content-Type: text/plain;
  charset="iso-8859-1";
  name="diff"
Content-Transfer-Encoding: 8bit
Content-Disposition: attachment; filename="diff"

Index: Makefile
===================================================================
RCS file: /var/cvs/linux/Makefile,v
retrieving revision 1.246
diff -u -p -r1.246 Makefile
--- Makefile	2002/01/13 16:01:17	1.246
+++ Makefile	2002/01/14 23:22:36
@@ -1,7 +1,7 @@
 VERSION = 2
 PATCHLEVEL = 4
 SUBLEVEL = 17
-EXTRAVERSION = -pa8
+EXTRAVERSION = -pa9
 
 KERNELRELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
 
Index: drivers/sound/harmony.c
===================================================================
RCS file: /var/cvs/linux/drivers/sound/harmony.c,v
retrieving revision 1.20
diff -u -p -r1.20 harmony.c
--- drivers/sound/harmony.c	2002/01/07 00:23:03	1.20
+++ drivers/sound/harmony.c	2002/01/14 23:22:37
@@ -61,9 +61,11 @@ Changes:
 #include "sound_config.h"
 
 
-#undef DEBUG
 #define PFX "harmony: "
+#define HARMONY_VERSION "0.9"
+
 
+#undef DEBUG
 #ifdef DEBUG
 # define DPRINTK printk 
 #else
@@ -235,9 +237,10 @@ static int __init harmony_alloc_buffer(s
 		int buffer_count)
 {
 	b->len = buffer_count * HARMONY_BUF_SIZE;
+	b->dma_handle = 0;
 	b->addr = pci_alloc_consistent(harmony.fake_pci_dev, 
 			  b->len, &b->dma_handle);
-	if (b->addr) {
+	if (b->addr && b->dma_handle) {
 		b->dma_consistent = 1;
 		DPRINTK(KERN_INFO PFX "consistent memory: 0x%lx, played_buf: 0x%lx\n",
 				(unsigned long)b->dma_handle, (unsigned long)b->addr);
@@ -264,7 +267,8 @@ static void __exit harmony_free_buffer(s
 				b->len, b->addr, b->dma_handle);
 	else
 		kfree(b->addr);
-	b->addr = NULL;
+
+	memset(b, 0, sizeof(*b));
 }
 
 
@@ -459,7 +463,7 @@ static ssize_t harmony_audio_read(struct
 			return -EBUSY;
 		
 		buf_to_read = harmony.first_filled_record;
-		
+
 		/* Copy the page to an aligned buffer */
 		copy_to_user(buffer+count, 
 			     recorded_buf.addr+(HARMONY_BUF_SIZE*buf_to_read), 
@@ -650,7 +654,7 @@ static int harmony_audio_ioctl(struct in
 		return put_user(ival, (int *) arg);
 
 	case SNDCTL_DSP_GETFMTS:
-		ival = (AFMT_S16_BE | AFMT_U16_BE | AFMT_MU_LAW | AFMT_A_LAW ); 
+		ival = (AFMT_S16_BE | AFMT_MU_LAW | AFMT_A_LAW ); 
 		return put_user(ival, (int *) arg);
 	
 	case SNDCTL_DSP_SETFMT:
@@ -660,12 +664,12 @@ static int harmony_audio_ioctl(struct in
 			switch (ival) {
 			case AFMT_MU_LAW:	new_format = HARMONY_DF_8BIT_ULAW; break;
 			case AFMT_A_LAW:	new_format = HARMONY_DF_8BIT_ALAW; break;
-			case AFMT_S16_BE:	/* fall through */
-			case AFMT_S16_LE:	/* fall through, this is wrong but some don't use _NE */
-			case AFMT_U16_BE:	new_format = HARMONY_DF_16BIT_LINEAR; break; 
-			case AFMT_U16_LE:	/* fall through, not supported */
+			case AFMT_S16_LE:	/* fall through, but not really supported */
+			case AFMT_S16_BE:	new_format = HARMONY_DF_16BIT_LINEAR;
+						ival = AFMT_S16_BE;
+						break; 
 			default: {
-				printk(KERN_WARNING PFX "can't set unsupported sound format (%d)\n",
+				printk(KERN_WARNING PFX "unsupported sound format 0x%04x requested.\n",
 						ival);
 				return -EINVAL;
 			}
@@ -1214,7 +1218,8 @@ harmony_driver_callback(struct parisc_de
 	cntl = gsc_readl(&harmony.hpa->cntl);
 	rev = (cntl>>20) & 0xff;
 
-	printk(KERN_INFO "Lasi Harmony Audio rev. %i at 0x%lx, using IRQ %i\n",
+	printk(KERN_INFO "Lasi Harmony Audio driver vers. " HARMONY_VERSION ", "
+			"h/w rev. %i at 0x%lx, IRQ %i\n",
 			rev, dev->hpa, harmony.irq);
 	
 	/* Make sure the control bit isn't set, although I don't think it 
@@ -1232,22 +1237,26 @@ harmony_driver_callback(struct parisc_de
 	    harmony_alloc_buffer(&recorded_buf, MAX_BUFS) ||
 	    harmony_alloc_buffer(&graveyard, 1) ||
 	    harmony_alloc_buffer(&silent, 1)) {
-		harmony_free_buffer(&played_buf);
-		harmony_free_buffer(&recorded_buf);
-		harmony_free_buffer(&graveyard);
-		harmony_free_buffer(&silent);
-		return -EBUSY;
+		ret = -EBUSY;
+		goto out_err;
 	}
 
 	/* Initialize /dev/mixer and /dev/audio  */
 	if ((ret=harmony_mixer_init())) 
-		return ret;
+		goto out_err;
 	if ((ret=harmony_audio_init())) 
-		return ret;
+		goto out_err;
 
-	request_mem_region(dev->hpa, 13, "harmony");
+	request_mem_region(dev->hpa, sizeof(struct harmony_hpa), "harmony");
 
 	return 0;
+
+out_err:
+	harmony_free_buffer(&played_buf);
+	harmony_free_buffer(&recorded_buf);
+	harmony_free_buffer(&graveyard);
+	harmony_free_buffer(&silent);
+	return ret;
 }
 
 
@@ -1274,7 +1283,8 @@ static void __exit cleanup_harmony(void)
 	free_irq(harmony.irq, &harmony);
 	unregister_sound_mixer(harmony.mixer_unit);
 	unregister_sound_dsp(harmony.dsp_unit);
-	release_mem_region((unsigned long)harmony.hpa, 13);
+	release_mem_region((unsigned long)harmony.hpa,
+			sizeof(struct harmony_hpa));
 	harmony_free_buffer(&played_buf);
 	harmony_free_buffer(&recorded_buf);
 	harmony_free_buffer(&graveyard);

--------------Boundary-00=_4SBYFXIW5RUL45HJWK3L--