patch-2.1.67 linux/drivers/sound/gus_midi.c
Next file: linux/drivers/sound/gus_vol.c
Previous file: linux/drivers/sound/gus_card.c
Back to the patch index
Back to the overall index
- Lines: 450
- Date:
Sat Nov 29 10:33:20 1997
- Orig file:
v2.1.66/linux/drivers/sound/gus_midi.c
- Orig date:
Wed Nov 12 13:34:26 1997
diff -u --recursive --new-file v2.1.66/linux/drivers/sound/gus_midi.c linux/drivers/sound/gus_midi.c
@@ -17,8 +17,7 @@
#include "gus_hw.h"
-#ifdef CONFIG_GUSHW
-#ifdef CONFIG_MIDI
+#if ( defined(CONFIG_GUSHW) && defined(CONFIG_MIDI) ) || defined (MODULE)
static int midi_busy = 0, input_opened = 0;
static int my_dev;
@@ -34,183 +33,178 @@
extern int gus_base, gus_irq, gus_dma;
extern int *gus_osp;
-static int
-GUS_MIDI_STATUS (void)
+static int
+GUS_MIDI_STATUS(void)
{
- return inb (u_MidiStatus);
+ return inb(u_MidiStatus);
}
static int
-gus_midi_open (int dev, int mode,
- void (*input) (int dev, unsigned char data),
- void (*output) (int dev)
+gus_midi_open(int dev, int mode,
+ void (*input) (int dev, unsigned char data),
+ void (*output) (int dev)
)
{
- if (midi_busy)
- {
- printk ("GUS: Midi busy\n");
- return -EBUSY;
- }
-
- outb ((MIDI_RESET), u_MidiControl);
- gus_delay ();
-
- gus_midi_control = 0;
- input_opened = 0;
-
- if (mode == OPEN_READ || mode == OPEN_READWRITE)
- if (!gus_pnp_flag)
- {
- gus_midi_control |= MIDI_ENABLE_RCV;
- input_opened = 1;
- }
-
-
- outb ((gus_midi_control), u_MidiControl); /* Enable */
+ if (midi_busy)
+ {
+ printk("GUS: Midi busy\n");
+ return -EBUSY;
+ }
+ outb((MIDI_RESET), u_MidiControl);
+ gus_delay();
+
+ gus_midi_control = 0;
+ input_opened = 0;
+
+ if (mode == OPEN_READ || mode == OPEN_READWRITE)
+ if (!gus_pnp_flag)
+ {
+ gus_midi_control |= MIDI_ENABLE_RCV;
+ input_opened = 1;
+ }
+ outb((gus_midi_control), u_MidiControl); /* Enable */
+
+ midi_busy = 1;
+ qlen = qhead = qtail = output_used = 0;
+ midi_input_intr = input;
- midi_busy = 1;
- qlen = qhead = qtail = output_used = 0;
- midi_input_intr = input;
-
- return 0;
+ return 0;
}
static int
-dump_to_midi (unsigned char midi_byte)
+dump_to_midi(unsigned char midi_byte)
{
- unsigned long flags;
- int ok = 0;
+ unsigned long flags;
+ int ok = 0;
- output_used = 1;
+ output_used = 1;
- save_flags (flags);
- cli ();
-
- if (GUS_MIDI_STATUS () & MIDI_XMIT_EMPTY)
- {
- ok = 1;
- outb ((midi_byte), u_MidiData);
- }
- else
- {
- /*
- * Enable Midi xmit interrupts (again)
- */
- gus_midi_control |= MIDI_ENABLE_XMIT;
- outb ((gus_midi_control), u_MidiControl);
- }
+ save_flags(flags);
+ cli();
+
+ if (GUS_MIDI_STATUS() & MIDI_XMIT_EMPTY)
+ {
+ ok = 1;
+ outb((midi_byte), u_MidiData);
+ } else
+ {
+ /*
+ * Enable Midi xmit interrupts (again)
+ */
+ gus_midi_control |= MIDI_ENABLE_XMIT;
+ outb((gus_midi_control), u_MidiControl);
+ }
- restore_flags (flags);
- return ok;
+ restore_flags(flags);
+ return ok;
}
static void
-gus_midi_close (int dev)
+gus_midi_close(int dev)
{
- /*
- * Reset FIFO pointers, disable intrs
- */
+ /*
+ * Reset FIFO pointers, disable intrs
+ */
- outb ((MIDI_RESET), u_MidiControl);
- midi_busy = 0;
+ outb((MIDI_RESET), u_MidiControl);
+ midi_busy = 0;
}
static int
-gus_midi_out (int dev, unsigned char midi_byte)
+gus_midi_out(int dev, unsigned char midi_byte)
{
- unsigned long flags;
+ unsigned long flags;
- /*
- * Drain the local queue first
- */
+ /*
+ * Drain the local queue first
+ */
- save_flags (flags);
- cli ();
+ save_flags(flags);
+ cli();
- while (qlen && dump_to_midi (tmp_queue[qhead]))
- {
- qlen--;
- qhead++;
- }
+ while (qlen && dump_to_midi(tmp_queue[qhead]))
+ {
+ qlen--;
+ qhead++;
+ }
- restore_flags (flags);
+ restore_flags(flags);
- /*
- * Output the byte if the local queue is empty.
- */
+ /*
+ * Output the byte if the local queue is empty.
+ */
- if (!qlen)
- if (dump_to_midi (midi_byte))
- return 1; /*
- * OK
- */
+ if (!qlen)
+ if (dump_to_midi(midi_byte))
+ return 1; /*
+ * OK
+ */
- /*
- * Put to the local queue
- */
+ /*
+ * Put to the local queue
+ */
- if (qlen >= 256)
- return 0; /*
+ if (qlen >= 256)
+ return 0; /*
* Local queue full
*/
- save_flags (flags);
- cli ();
+ save_flags(flags);
+ cli();
- tmp_queue[qtail] = midi_byte;
- qlen++;
- qtail++;
+ tmp_queue[qtail] = midi_byte;
+ qlen++;
+ qtail++;
- restore_flags (flags);
+ restore_flags(flags);
- return 1;
+ return 1;
}
static int
-gus_midi_start_read (int dev)
+gus_midi_start_read(int dev)
{
- return 0;
+ return 0;
}
static int
-gus_midi_end_read (int dev)
+gus_midi_end_read(int dev)
{
- return 0;
+ return 0;
}
static int
-gus_midi_ioctl (int dev, unsigned cmd, caddr_t arg)
+gus_midi_ioctl(int dev, unsigned cmd, caddr_t arg)
{
- return -EINVAL;
+ return -EINVAL;
}
static void
-gus_midi_kick (int dev)
+gus_midi_kick(int dev)
{
}
static int
-gus_midi_buffer_status (int dev)
+gus_midi_buffer_status(int dev)
{
- unsigned long flags;
-
- if (!output_used)
- return 0;
+ unsigned long flags;
- save_flags (flags);
- cli ();
+ if (!output_used)
+ return 0;
- if (qlen && dump_to_midi (tmp_queue[qhead]))
- {
- qlen--;
- qhead++;
- }
+ save_flags(flags);
+ cli();
- restore_flags (flags);
+ if (qlen && dump_to_midi(tmp_queue[qhead]))
+ {
+ qlen--;
+ qhead++;
+ }
+ restore_flags(flags);
- return (qlen > 0) | !(GUS_MIDI_STATUS () & MIDI_XMIT_EMPTY);
+ return (qlen > 0) | !(GUS_MIDI_STATUS() & MIDI_XMIT_EMPTY);
}
#define MIDI_SYNTH_NAME "Gravis Ultrasound Midi"
@@ -219,82 +213,81 @@
static struct midi_operations gus_midi_operations =
{
- {"Gravis UltraSound Midi", 0, 0, SNDCARD_GUS},
- &std_midi_synth,
- {0},
- gus_midi_open,
- gus_midi_close,
- gus_midi_ioctl,
- gus_midi_out,
- gus_midi_start_read,
- gus_midi_end_read,
- gus_midi_kick,
- NULL, /*
+ {"Gravis UltraSound Midi", 0, 0, SNDCARD_GUS},
+ &std_midi_synth,
+ {0},
+ gus_midi_open,
+ gus_midi_close,
+ gus_midi_ioctl,
+ gus_midi_out,
+ gus_midi_start_read,
+ gus_midi_end_read,
+ gus_midi_kick,
+ NULL, /*
* command
*/
- gus_midi_buffer_status,
- NULL
+ gus_midi_buffer_status,
+ NULL
};
void
-gus_midi_init (void)
+gus_midi_init(struct address_info *hw_config)
{
- if (num_midis >= MAX_MIDI_DEV)
- {
- printk ("Sound: Too many midi devices detected\n");
- return;
- }
-
- outb ((MIDI_RESET), u_MidiControl);
-
- std_midi_synth.midi_dev = my_dev = num_midis;
- midi_devs[num_midis++] = &gus_midi_operations;
- sequencer_init ();
- return;
+ int dev = sound_alloc_mididev();
+
+ if (dev == -1)
+ {
+ printk(KERN_INFO "gus_midi: Too many midi devices detected\n");
+ return;
+ }
+ outb((MIDI_RESET), u_MidiControl);
+
+ std_midi_synth.midi_dev = my_dev = dev;
+ hw_config->slots[2] = dev;
+ midi_devs[dev] = &gus_midi_operations;
+ sequencer_init();
+ return;
}
void
-gus_midi_interrupt (int dummy)
+gus_midi_interrupt(int dummy)
{
- volatile unsigned char stat, data;
- unsigned long flags;
- int timeout = 10;
-
- save_flags (flags);
- cli ();
-
- while (timeout-- > 0 && (stat = GUS_MIDI_STATUS ()) & (MIDI_RCV_FULL | MIDI_XMIT_EMPTY))
- {
- if (stat & MIDI_RCV_FULL)
- {
- data = inb (u_MidiData);
- if (input_opened)
- midi_input_intr (my_dev, data);
- }
-
- if (stat & MIDI_XMIT_EMPTY)
- {
- while (qlen && dump_to_midi (tmp_queue[qhead]))
- {
- qlen--;
- qhead++;
- }
-
- if (!qlen)
- {
- /*
- * Disable Midi output interrupts, since no data in the buffer
- */
- gus_midi_control &= ~MIDI_ENABLE_XMIT;
- outb ((gus_midi_control), u_MidiControl);
- outb ((gus_midi_control), u_MidiControl);
- }
- }
-
- }
+ volatile unsigned char stat, data;
+ unsigned long flags;
+ int timeout = 10;
+
+ save_flags(flags);
+ cli();
+
+ while (timeout-- > 0 && (stat = GUS_MIDI_STATUS()) & (MIDI_RCV_FULL | MIDI_XMIT_EMPTY))
+ {
+ if (stat & MIDI_RCV_FULL)
+ {
+ data = inb(u_MidiData);
+ if (input_opened)
+ midi_input_intr(my_dev, data);
+ }
+ if (stat & MIDI_XMIT_EMPTY)
+ {
+ while (qlen && dump_to_midi(tmp_queue[qhead]))
+ {
+ qlen--;
+ qhead++;
+ }
+
+ if (!qlen)
+ {
+ /*
+ * Disable Midi output interrupts, since no data in the buffer
+ */
+ gus_midi_control &= ~MIDI_ENABLE_XMIT;
+ outb((gus_midi_control), u_MidiControl);
+ outb((gus_midi_control), u_MidiControl);
+ }
+ }
+ }
- restore_flags (flags);
+ restore_flags(flags);
}
-#endif
#endif
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov