patch-2.2.13 linux/drivers/sound/msnd.c

Next file: linux/drivers/sound/msnd.h
Previous file: linux/drivers/sound/esssolo1.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.2.12/linux/drivers/sound/msnd.c linux/drivers/sound/msnd.c
@@ -20,7 +20,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  *
- * $Id: msnd.c,v 1.16 1998/09/08 04:05:56 andrewtv Exp $
+ * $Id: msnd.c,v 1.17 1999/03/21 16:50:09 andrewtv Exp $
  *
  ********************************************************************/
 
@@ -66,7 +66,7 @@
 
 	if (i == MSND_MAX_DEVS)
 		return -ENOMEM;
-	
+
 	devs[i] = dev;
 	++num_devs;
 
@@ -106,13 +106,21 @@
 	for (i = 0; i < MSND_MAX_DEVS && j; ++i)
 		if (devs[i] != NULL)
 			--j;
-	
+
 	if (i == MSND_MAX_DEVS || j != 0)
 		return NULL;
 
 	return devs[i];
 }
 
+void msnd_init_queue(volatile BYTE *base, int start, int size)
+{
+	writew(PCTODSP_BASED(start), base + JQS_wStart);
+	writew(PCTODSP_OFFSET(size) - 1, base + JQS_wSize);
+	writew(0, base + JQS_wHead);
+	writew(0, base + JQS_wTail);
+}
+
 void msnd_fifo_init(msnd_fifo *f)
 {
 	f->data = NULL;
@@ -152,11 +160,11 @@
 
 	if (f->len == f->n)
 		return 0;
-	
+
 	while ((count < len) && (f->len != f->n)) {
-		
+
 		int nwritten;
-		
+
 		if (f->head <= f->tail) {
 			nwritten = len - count;
 			if (nwritten > f->n - f->tail)
@@ -180,7 +188,7 @@
 		f->tail += nwritten;
 		f->tail %= f->n;
 	}
-	
+
 	return count;
 }
 
@@ -190,11 +198,11 @@
 
 	if (f->len == 0)
 		return f->len;
-	
+
 	while ((count < len) && (f->len > 0)) {
-		
+
 		int nread;
-		
+
 		if (f->tail <= f->head) {
 			nread = len - count;
 			if (nread > f->n - f->head)
@@ -205,20 +213,20 @@
 			if (nread > len - count)
 				nread = len - count;
 		}
-		
+
 		if (user) {
 			if (copy_to_user(buf, f->data + f->head, nread))
 				return -EFAULT;
 		} else
 			memcpy(buf, f->data + f->head, nread);
-		
+
 		count += nread;
 		buf += nread;
 		f->len -= nread;
 		f->head += nread;
 		f->head %= f->n;
 	}
-	
+
 	return count;
 }
 
@@ -259,7 +267,7 @@
 	spin_unlock_irqrestore(&dev->lock, flags);
 
 	printk(KERN_DEBUG LOGNAME ": Send DSP command timeout\n");
-	
+
 	return -EIO;
 }
 
@@ -307,7 +315,7 @@
 		return 0;
 
 	printk(KERN_DEBUG LOGNAME ": Enabling IRQ\n");
-	
+
 	spin_lock_irqsave(&dev->lock, flags);
 	if (msnd_wait_TXDE(dev) == 0) {
 		outb(inb(dev->io + HP_ICR) | HPICR_TREQ, dev->io + HP_ICR);
@@ -316,6 +324,7 @@
 		outb(inb(dev->io + HP_ICR) & ~HPICR_TREQ, dev->io + HP_ICR);
 		outb(inb(dev->io + HP_ICR) | HPICR_RREQ, dev->io + HP_ICR);
 		enable_irq(dev->irq);
+		msnd_init_queue(dev->DSPQ, dev->dspq_data_buff, dev->dspq_buff_size);
 		spin_unlock_irqrestore(&dev->lock, flags);
 		return 0;
 	}
@@ -359,6 +368,8 @@
 EXPORT_SYMBOL(msnd_unregister);
 EXPORT_SYMBOL(msnd_get_num_devs);
 EXPORT_SYMBOL(msnd_get_dev);
+
+EXPORT_SYMBOL(msnd_init_queue);
 
 EXPORT_SYMBOL(msnd_fifo_init);
 EXPORT_SYMBOL(msnd_fifo_free);

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