patch-2.2.0-pre1 linux/drivers/sound/es1371.c

Next file: linux/drivers/sound/lowlevel/Config.in
Previous file: linux/drivers/sound/es1370.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.132/linux/drivers/sound/es1371.c linux/drivers/sound/es1371.c
@@ -50,6 +50,8 @@
  *    27.10.98   0.5   Fix joystick support
  *                     -- Oliver Neukum (c188@org.chemie.uni-muenchen.de)
  *    10.12.98   0.6   Fix drain_dac trying to wait on not yet initialized DMA
+ *    23.12.98   0.7   Fix a few f_file & FMODE_ bugs
+ *                     Don't wake up app until there are fragsize bytes to read/write
  *
  */
 
@@ -837,17 +839,14 @@
 		diff = get_hwptr(s, &s->dma_adc, ES1371_REG_ADC_FRAMECNT);
 		s->dma_adc.total_bytes += diff;
 		s->dma_adc.count += diff;
-		if (s->dma_adc.mapped) {
-			if (s->dma_adc.count >= s->dma_adc.fragsize) 
-				wake_up(&s->dma_adc.wait);
-		} else {
+		if (s->dma_adc.count >= (signed)s->dma_adc.fragsize) 
+			wake_up(&s->dma_adc.wait);
+		if (!s->dma_adc.mapped) {
 			if (s->dma_adc.count > (signed)(s->dma_adc.dmasize - ((3 * s->dma_adc.fragsize) >> 1))) {
 				s->ctrl &= ~CTRL_ADC_EN;
 				outl(s->ctrl, s->io+ES1371_REG_CONTROL);
 				s->dma_adc.error++;
 			}
-			if (s->dma_adc.count > 0)
-				wake_up(&s->dma_adc.wait);
 		}
 	}
 	/* update DAC1 pointer */
@@ -869,7 +868,7 @@
 					      s->dma_dac1.fragsize, (s->sctrl & SCTRL_P1SEB) ? 0 : 0x80);
 				s->dma_dac1.endcleared = 1;
 			}
-			if (s->dma_dac1.count < (signed)s->dma_dac1.dmasize)
+			if (s->dma_dac1.count + (signed)s->dma_dac1.fragsize <= (signed)s->dma_dac1.dmasize)
 				wake_up(&s->dma_dac1.wait);
 		}
 	}
@@ -892,7 +891,7 @@
 					      s->dma_dac2.fragsize, (s->sctrl & SCTRL_P2SEB) ? 0 : 0x80);
 				s->dma_dac2.endcleared = 1;
 			}
-			if (s->dma_dac2.count < (signed)s->dma_dac2.dmasize)
+			if (s->dma_dac2.count + (signed)s->dma_dac2.fragsize <= (signed)s->dma_dac2.dmasize)
 				wake_up(&s->dma_dac2.wait);
 		}
 	}
@@ -1625,27 +1624,22 @@
 	unsigned int mask = 0;
 
 	VALIDATE_STATE(s);
-	if (file->f_flags & FMODE_WRITE)
+	if (file->f_mode & FMODE_WRITE)
 		poll_wait(file, &s->dma_dac2.wait, wait);
-	if (file->f_flags & FMODE_READ)
+	if (file->f_mode & FMODE_READ)
 		poll_wait(file, &s->dma_adc.wait, wait);
 	spin_lock_irqsave(&s->lock, flags);
 	es1371_update_ptr(s);
-	if (file->f_flags & FMODE_READ) {
-		if (s->dma_adc.mapped) {
+	if (file->f_mode & FMODE_READ) {
 			if (s->dma_adc.count >= (signed)s->dma_adc.fragsize)
 				mask |= POLLIN | POLLRDNORM;
-		} else {
-			if (s->dma_adc.count > 0)
-				mask |= POLLIN | POLLRDNORM;
-		}
 	}
-	if (file->f_flags & FMODE_WRITE) {
+	if (file->f_mode & FMODE_WRITE) {
 		if (s->dma_dac2.mapped) {
 			if (s->dma_dac2.count >= (signed)s->dma_dac2.fragsize) 
 				mask |= POLLOUT | POLLWRNORM;
 		} else {
-			if ((signed)s->dma_dac2.dmasize > s->dma_dac2.count)
+			if ((signed)s->dma_dac2.dmasize >= s->dma_dac2.count + (signed)s->dma_dac2.fragsize)
 				mask |= POLLOUT | POLLWRNORM;
 		}
 	}
@@ -2046,11 +2040,11 @@
 	if (file->f_mode & FMODE_WRITE)
 		drain_dac2(s, file->f_flags & O_NONBLOCK);
 	down(&s->open_sem);
-	if (file->f_flags & FMODE_WRITE) {
+	if (file->f_mode & FMODE_WRITE) {
 		stop_dac2(s);
 		dealloc_dmabuf(&s->dma_dac2);
 	}
-	if (file->f_flags & FMODE_READ) {
+	if (file->f_mode & FMODE_READ) {
 		stop_adc(s);
 		dealloc_dmabuf(&s->dma_adc);
 	}
@@ -2150,7 +2144,7 @@
 		if (s->dma_dac1.count >= (signed)s->dma_dac1.fragsize)
 			mask |= POLLOUT | POLLWRNORM;
 	} else {
-		if ((signed)s->dma_dac1.dmasize > s->dma_dac1.count)
+		if ((signed)s->dma_dac1.dmasize >= s->dma_dac1.count + (signed)s->dma_dac1.fragsize)
 			mask |= POLLOUT | POLLWRNORM;
 	}
 	spin_unlock_irqrestore(&s->lock, flags);
@@ -2540,16 +2534,16 @@
 	unsigned int mask = 0;
 
 	VALIDATE_STATE(s);
-	if (file->f_flags & FMODE_WRITE)
+	if (file->f_mode & FMODE_WRITE)
 		poll_wait(file, &s->midi.owait, wait);
-	if (file->f_flags & FMODE_READ)
+	if (file->f_mode & FMODE_READ)
 		poll_wait(file, &s->midi.iwait, wait);
 	spin_lock_irqsave(&s->lock, flags);
-	if (file->f_flags & FMODE_READ) {
+	if (file->f_mode & FMODE_READ) {
 		if (s->midi.icnt > 0)
 			mask |= POLLIN | POLLRDNORM;
 	}
-	if (file->f_flags & FMODE_WRITE) {
+	if (file->f_mode & FMODE_WRITE) {
 		if (s->midi.ocnt < MIDIOUTBUF)
 			mask |= POLLOUT | POLLWRNORM;
 	}
@@ -2684,7 +2678,7 @@
 
 /* --------------------------------------------------------------------- */
 
-static const struct initvol {
+static struct initvol {
 	int mixch;
 	int vol;
 } initvol[] __initdata = {
@@ -2716,7 +2710,7 @@
 
 	if (!pci_present())   /* No PCI bus in this machine! */
 		return -ENODEV;
-	printk(KERN_INFO "es1371: version v0.6 time " __TIME__ " " __DATE__ "\n");
+	printk(KERN_INFO "es1371: version v0.7 time " __TIME__ " " __DATE__ "\n");
 	while (index < NR_DEVICE && 
 	       (pcidev = pci_find_device(PCI_VENDOR_ID_ENSONIQ, PCI_DEVICE_ID_ENSONIQ_ES1371, pcidev))) {
 		if (pcidev->base_address[0] == 0 || 

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