summaryrefslogtreecommitdiffstats
path: root/drivers/sound/pas2_midi.c
diff options
context:
space:
mode:
authorRalf Baechle <ralf@linux-mips.org>1997-01-07 02:33:00 +0000
committer <ralf@linux-mips.org>1997-01-07 02:33:00 +0000
commitbeb116954b9b7f3bb56412b2494b562f02b864b1 (patch)
tree120e997879884e1b9d93b265221b939d2ef1ade1 /drivers/sound/pas2_midi.c
parent908d4681a1dc3792ecafbe64265783a86c4cccb6 (diff)
Import of Linux/MIPS 2.1.14
Diffstat (limited to 'drivers/sound/pas2_midi.c')
-rw-r--r--drivers/sound/pas2_midi.c174
1 files changed, 62 insertions, 112 deletions
diff --git a/drivers/sound/pas2_midi.c b/drivers/sound/pas2_midi.c
index 1c6bf5937..74d04750e 100644
--- a/drivers/sound/pas2_midi.c
+++ b/drivers/sound/pas2_midi.c
@@ -2,42 +2,23 @@
* sound/pas2_midi.c
*
* The low level driver for the PAS Midi Interface.
+ */
+/*
+ * Copyright (C) by Hannu Savolainen 1993-1996
*
- * Copyright by Hannu Savolainen 1993
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met: 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer. 2.
- * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
+ * OSS/Free for Linux is distributed under the GNU GENERAL PUBLIC LICENSE (GPL)
+ * Version 2 (June 1991). See the "COPYING" file distributed with this software
+ * for more info.
*/
+#include <linux/config.h>
-#include "sound_config.h"
-
-#ifdef CONFIGURE_SOUNDCARD
-#include "pas.h"
+#include "sound_config.h"
-#if !defined(EXCLUDE_PAS) && !defined(EXCLUDE_MIDI) && defined(EXCLUDE_PRO_MIDI)
+#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;
@@ -59,18 +40,19 @@ pas_midi_open (int dev, int mode,
if (midi_busy)
{
printk ("PAS2: Midi busy\n");
- return RET_ERROR (EBUSY);
+ return -EBUSY;
}
/*
* Reset input and output FIFO pointers
*/
- pas_write (M_C_RESET_INPUT_FIFO | M_C_RESET_OUTPUT_FIFO,
- MIDI_CONTROL);
+ pas_write (0x20 | 0x40,
+ 0x178b);
- DISABLE_INTR (flags);
+ save_flags (flags);
+ cli ();
- if ((err = pas_set_intr (I_M_MIDI_IRQ_ENABLE)) < 0)
+ if ((err = pas_set_intr (0x10)) < 0)
return err;
/*
@@ -83,31 +65,24 @@ pas_midi_open (int dev, int mode,
if (mode == OPEN_READ || mode == OPEN_READWRITE)
{
- ctrl |= M_C_ENA_INPUT_IRQ;/*
- * Enable input
- */
+ ctrl |= 0x04; /* Enable input */
input_opened = 1;
}
if (mode == OPEN_WRITE || mode == OPEN_READWRITE)
{
- ctrl |= M_C_ENA_OUTPUT_IRQ | /*
- * Enable output
- */
- M_C_ENA_OUTPUT_HALF_IRQ;
+ ctrl |= 0x08 | 0x10; /* Enable output */
}
- pas_write (ctrl,
- MIDI_CONTROL);
+ pas_write (ctrl, 0x178b);
/*
* Acknowledge any pending interrupts
*/
- pas_write (0xff, MIDI_STATUS);
- ofifo_bytes = 0;
+ pas_write (0xff, 0x1B88);
- RESTORE_INTR (flags);
+ restore_flags (flags);
midi_busy = 1;
qlen = qhead = qtail = 0;
@@ -121,9 +96,9 @@ pas_midi_close (int dev)
/*
* Reset FIFO pointers, disable intrs
*/
- pas_write (M_C_RESET_INPUT_FIFO | M_C_RESET_OUTPUT_FIFO, MIDI_CONTROL);
+ pas_write (0x20 | 0x40, 0x178b);
- pas_remove_intr (I_M_MIDI_IRQ_ENABLE);
+ pas_remove_intr (0x10);
midi_busy = 0;
}
@@ -132,21 +107,22 @@ dump_to_midi (unsigned char midi_byte)
{
int fifo_space, x;
- fifo_space = ((x = pas_read (MIDI_FIFO_STATUS)) >> 4) & 0x0f;
+ fifo_space = ((x = pas_read (0x1B89)) >> 4) & 0x0f;
+
+/*
+ * 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 == 15 || (fifo_space < 2 && ofifo_bytes > 13)) /*
- * Fifo
- * full
- */
+ 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, MIDI_DATA);
+ pas_write (midi_byte, 0x178A);
return 1;
}
@@ -161,7 +137,8 @@ pas_midi_out (int dev, unsigned char midi_byte)
* Drain the local queue first
*/
- DISABLE_INTR (flags);
+ save_flags (flags);
+ cli ();
while (qlen && dump_to_midi (tmp_queue[qhead]))
{
@@ -169,7 +146,7 @@ pas_midi_out (int dev, unsigned char midi_byte)
qhead++;
}
- RESTORE_INTR (flags);
+ restore_flags (flags);
/*
* Output the byte if the local queue is empty.
@@ -177,26 +154,23 @@ pas_midi_out (int dev, unsigned char midi_byte)
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 */
- DISABLE_INTR (flags);
+ save_flags (flags);
+ cli ();
tmp_queue[qtail] = midi_byte;
qlen++;
qtail++;
- RESTORE_INTR (flags);
+ restore_flags (flags);
return 1;
}
@@ -214,21 +188,20 @@ pas_midi_end_read (int dev)
}
static int
-pas_midi_ioctl (int dev, unsigned cmd, unsigned arg)
+pas_midi_ioctl (int dev, unsigned cmd, caddr_t arg)
{
- return RET_ERROR (EINVAL);
+ return -EINVAL;
}
static void
pas_midi_kick (int dev)
{
- ofifo_bytes = 0;
}
static int
pas_buffer_status (int dev)
{
- return !qlen;
+ return qlen;
}
#define MIDI_SYNTH_NAME "Pro Audio Spectrum Midi"
@@ -239,6 +212,7 @@ static struct midi_operations pas_midi_operations =
{
{"Pro Audio Spectrum", 0, 0, SNDCARD_PAS},
&std_midi_synth,
+ {0},
pas_midi_open,
pas_midi_close,
pas_midi_ioctl,
@@ -246,25 +220,22 @@ static struct midi_operations pas_midi_operations =
pas_midi_start_read,
pas_midi_end_read,
pas_midi_kick,
- NULL, /*
- * command
- */
+ NULL,
pas_buffer_status,
NULL
};
-long
-pas_midi_init (long mem_start)
+void
+pas_midi_init (void)
{
if (num_midis >= MAX_MIDI_DEV)
{
printk ("Sound: Too many midi devices detected\n");
- return mem_start;
+ return;
}
std_midi_synth.midi_dev = my_dev = num_midis;
midi_devs[num_midis++] = &pas_midi_operations;
- return mem_start;
}
void
@@ -274,41 +245,27 @@ pas_midi_interrupt (void)
int i, incount;
unsigned long flags;
- stat = pas_read (MIDI_STATUS);
+ stat = pas_read (0x1B88);
- if (stat & M_S_INPUT_AVAIL) /*
- * Input byte available
- */
+ if (stat & 0x04) /* Input data available */
{
- incount = pas_read (MIDI_FIFO_STATUS) & 0x0f; /*
- * Input FIFO count
- */
+ incount = pas_read (0x1B89) & 0x0f; /* Input FIFO size */
if (!incount)
incount = 16;
for (i = 0; i < incount; i++)
if (input_opened)
{
- midi_input_intr (my_dev, pas_read (MIDI_DATA));
+ midi_input_intr (my_dev, pas_read (0x178A));
}
else
- pas_read (MIDI_DATA); /*
- * Flush
- */
+ pas_read (0x178A); /* Flush */
}
- if (stat & (M_S_OUTPUT_EMPTY | M_S_OUTPUT_HALF_EMPTY))
+ if (stat & (0x08 | 0x10))
{
- if (!(stat & M_S_OUTPUT_EMPTY))
- {
- ofifo_bytes = 8;
- }
- else
- {
- ofifo_bytes = 0;
- }
-
- DISABLE_INTR (flags);
+ save_flags (flags);
+ cli ();
while (qlen && dump_to_midi (tmp_queue[qhead]))
{
@@ -316,23 +273,16 @@ pas_midi_interrupt (void)
qhead++;
}
- RESTORE_INTR (flags);
+ restore_flags (flags);
}
- if (stat & M_S_FRAMING_ERROR)
- printk ("MIDI framing error\n");
- if (stat & M_S_OUTPUT_OVERRUN)
+ if (stat & 0x40)
{
- printk ("MIDI output overrun %x,%x,%d \n", pas_read (MIDI_FIFO_STATUS), stat, ofifo_bytes);
- ofifo_bytes = 100;
+ printk ("MIDI output overrun %x,%x\n", pas_read (0x1B89), stat);
}
- pas_write (stat, MIDI_STATUS);/*
- * Acknowledge interrupts
- */
+ pas_write (stat, 0x1B88); /* Acknowledge interrupts */
}
#endif
-
-#endif