changeset 10531:3dbb42515756

6852870 audio distortion with nvidia mcp79 using audiohd driver
author Yang-Rong Jerry Zhou <Yangrong.Zhou@Sun.COM>
date Tue, 15 Sep 2009 10:38:49 +0800
parents 4d58e4327f11
children f0c47e0a91ac
files usr/src/uts/common/io/audio/drv/audiohd/audiohd.c usr/src/uts/common/io/audio/drv/audiohd/audiohd.h
diffstat 2 files changed, 24 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/usr/src/uts/common/io/audio/drv/audiohd/audiohd.c	Mon Sep 14 20:55:31 2009 -0400
+++ b/usr/src/uts/common/io/audio/drv/audiohd/audiohd.c	Tue Sep 15 10:38:49 2009 +0800
@@ -1064,7 +1064,6 @@
 	if (port->curpos >= port->samp_size * AUDIOHD_BDLE_NUMS)
 		port->curpos -= port->samp_size * AUDIOHD_BDLE_NUMS;
 
-	port->len = len;
 	port->count += len / (port->nchan * 2);
 
 
@@ -1104,8 +1103,8 @@
 
 	_NOTE(ARGUNUSED(nframes));
 
-	(void) ddi_dma_sync(port->samp_dmah, port->curpos,
-	    port->len, port->sync_dir);
+	(void) ddi_dma_sync(port->samp_dmah, 0,
+	    0, port->sync_dir);
 
 }
 
@@ -5339,16 +5338,34 @@
 			    rc);
 			return (DDI_FAILURE);
 		}
-		/* allocate DMA buffer */
+		/*
+		 * Warning: please be noted that allocating the dma memory
+		 * with the flag IOMEM_DATA_UNCACHED is a hack due
+		 * to an incorrect cache synchronization on NVidia MCP79
+		 * chipset which causes the audio distortion problem,
+		 * and that it should be fixed later. There should be
+		 * no reason you have to allocate UNCACHED memory. In
+		 * complex architectures with nested IO caches,
+		 * reliance on this flag might lead to failure.
+		 */
 		rc = ddi_dma_mem_alloc(port->samp_dmah, port->samp_size *
 		    AUDIOHD_BDLE_NUMS,
 		    &hda_dev_accattr,
-		    DDI_DMA_CONSISTENT,
+		    DDI_DMA_CONSISTENT | IOMEM_DATA_UNCACHED,
 		    DDI_DMA_SLEEP, NULL, &port->samp_kaddr,
 		    &real_size, &port->samp_acch);
 		if (rc == DDI_FAILURE) {
-			audio_dev_warn(adev, "dma_mem_alloc failed");
-			return (DDI_FAILURE);
+			if (ddi_dma_mem_alloc(port->samp_dmah,
+			    port->samp_size * AUDIOHD_BDLE_NUMS,
+			    &hda_dev_accattr,
+			    DDI_DMA_CONSISTENT,
+			    DDI_DMA_SLEEP, NULL,
+			    &port->samp_kaddr, &real_size,
+			    &port->samp_acch) != DDI_SUCCESS) {
+				audio_dev_warn(adev,
+				    "ddi_dma_mem_alloc failed");
+				return (DDI_FAILURE);
+			}
 		}
 
 		/* bind DMA buffer */
--- a/usr/src/uts/common/io/audio/drv/audiohd/audiohd.h	Mon Sep 14 20:55:31 2009 -0400
+++ b/usr/src/uts/common/io/audio/drv/audiohd/audiohd.h	Tue Sep 15 10:38:49 2009 +0800
@@ -679,7 +679,6 @@
 	unsigned		nframes;
 	uint64_t		count;
 	int			curpos;
-	int			len;
 	int			intrs;
 
 	uint_t			format;