patch-2.1.6 linux/drivers/sound/pas2_midi.c
Next file: linux/drivers/sound/pas2_mixer.c
Previous file: linux/drivers/sound/pas2_card.c
Back to the patch index
Back to the overall index
- Lines: 191
- Date:
Tue Oct 29 16:36:36 1996
- Orig file:
v2.1.5/linux/drivers/sound/pas2_midi.c
- Orig date:
Sun Jun 30 12:31:09 1996
diff -u --recursive --new-file v2.1.5/linux/drivers/sound/pas2_midi.c linux/drivers/sound/pas2_midi.c
@@ -4,15 +4,13 @@
* The low level driver for the PAS Midi Interface.
*/
-#include <linux/config.h>
-
#include "sound_config.h"
+#include <linux/config.h>
#if defined(CONFIG_PAS) && defined(CONFIG_MIDI)
static int midi_busy = 0, input_opened = 0;
static int my_dev;
-static volatile int ofifo_bytes = 0;
static unsigned char tmp_queue[256];
static volatile int qlen;
@@ -34,7 +32,7 @@
if (midi_busy)
{
printk ("PAS2: Midi busy\n");
- return -(EBUSY);
+ return -EBUSY;
}
/*
@@ -59,29 +57,22 @@
if (mode == OPEN_READ || mode == OPEN_READWRITE)
{
- ctrl |= 0x04; /*
- * Enable input
- */
+ ctrl |= 0x04; /* Enable input */
input_opened = 1;
}
if (mode == OPEN_WRITE || mode == OPEN_READWRITE)
{
- ctrl |= 0x08 | /*
- * Enable output
- */
- 0x10;
+ ctrl |= 0x08 | 0x10; /* Enable output */
}
- pas_write (ctrl,
- 0x178b);
+ pas_write (ctrl, 0x178b);
/*
* Acknowledge any pending interrupts
*/
pas_write (0xff, 0x1B88);
- ofifo_bytes = 0;
restore_flags (flags);
@@ -110,18 +101,19 @@
fifo_space = ((x = pas_read (0x1B89)) >> 4) & 0x0f;
- if (fifo_space == 15 || (fifo_space < 2 && ofifo_bytes > 13)) /*
- * Fifo
- * full
- */
+/*
+ * The MIDI FIFO space register and it's documentation is nonunderstandable.
+ * There seem to be no way to differentiate between buffer full and buffer
+ * empty situations. For this reason we don't never write the buffer
+ * completely full. In this way we can assume that 0 (or is it 15)
+ * means that the buffer is empty.
+ */
+
+ if (fifo_space < 2 && fifo_space != 0) /* Full (almost) */
{
- return 0; /*
- * Upper layer will call again
- */
+ return 0; /* Ask upper layers to retry after some time */
}
- ofifo_bytes++;
-
pas_write (midi_byte, 0x178A);
return 1;
@@ -154,18 +146,14 @@
if (!qlen)
if (dump_to_midi (midi_byte))
- return 1; /*
- * OK
- */
+ return 1;
/*
* Put to the local queue
*/
if (qlen >= 256)
- return 0; /*
- * Local queue full
- */
+ return 0; /* Local queue full */
save_flags (flags);
cli ();
@@ -194,13 +182,12 @@
static int
pas_midi_ioctl (int dev, unsigned cmd, caddr_t arg)
{
- return -(EINVAL);
+ return -EINVAL;
}
static void
pas_midi_kick (int dev)
{
- ofifo_bytes = 0;
}
static int
@@ -225,9 +212,7 @@
pas_midi_start_read,
pas_midi_end_read,
pas_midi_kick,
- NULL, /*
- * command
- */
+ NULL,
pas_buffer_status,
NULL
};
@@ -254,13 +239,9 @@
stat = pas_read (0x1B88);
- if (stat & 0x04) /*
- * Input byte available
- */
+ if (stat & 0x04) /* Input data available */
{
- incount = pas_read (0x1B89) & 0x0f; /*
- * Input FIFO count
- */
+ incount = pas_read (0x1B89) & 0x0f; /* Input FIFO size */
if (!incount)
incount = 16;
@@ -270,22 +251,11 @@
midi_input_intr (my_dev, pas_read (0x178A));
}
else
- pas_read (0x178A); /*
- * Flush
- */
+ pas_read (0x178A); /* Flush */
}
if (stat & (0x08 | 0x10))
{
- if (!(stat & 0x08))
- {
- ofifo_bytes = 8;
- }
- else
- {
- ofifo_bytes = 0;
- }
-
save_flags (flags);
cli ();
@@ -301,13 +271,10 @@
if (stat & 0x40)
{
- printk ("MIDI output overrun %x,%x,%d \n", pas_read (0x1B89), stat, ofifo_bytes);
- ofifo_bytes = 100;
+ printk ("MIDI output overrun %x,%x\n", pas_read (0x1B89), stat);
}
- pas_write (stat, 0x1B88); /*
- * Acknowledge interrupts
- */
+ pas_write (stat, 0x1B88); /* Acknowledge interrupts */
}
#endif
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov