52 #include <linux/time.h>
53 #include <linux/wait.h>
61 return inb (midi->mpu_status_port);
82 return inb (midi->mpu_data_port);
89 outb (byte, midi->mpu_data_port);
102 card = substream->
rmidi->card;
120 unsigned char midi_byte;
143 for (timeout = 30000; timeout > 0; timeout--) {
150 spin_unlock_irqrestore (&midi->
virtual, flags);
158 write_data(midi, midi_byte);
166 spin_unlock_irqrestore (&midi->
virtual, flags);
170 spin_unlock_irqrestore (&midi->
virtual, flags);
173 spin_unlock_irqrestore (&midi->
virtual, flags);
186 for (timeout = 30000; timeout > 0; timeout--) {
197 spin_unlock_irqrestore (&midi->
virtual, flags);
212 write_data(midi, midi_byte);
221 spin_unlock_irqrestore (&midi->
virtual, flags);
225 spin_unlock_irqrestore (&midi->
virtual, flags);
228 spin_unlock_irqrestore (&midi->
virtual, flags);
245 if ((midi = get_wavefront_midi (substream)) ==
NULL)
251 spin_unlock_irqrestore (&midi->
open, flags);
269 if ((midi = get_wavefront_midi (substream)) ==
NULL)
275 spin_unlock_irqrestore (&midi->
open, flags);
293 if ((midi = get_wavefront_midi (substream)) ==
NULL)
298 spin_unlock_irqrestore (&midi->
open, flags);
316 if ((midi = get_wavefront_midi (substream)) ==
NULL)
320 midi->
mode[mpu] &= ~MPU401_MODE_OUTPUT;
321 spin_unlock_irqrestore (&midi->
open, flags);
334 if (substream->
rmidi->private_data ==
NULL)
339 if ((midi = get_wavefront_midi (substream)) ==
NULL) {
349 spin_unlock_irqrestore (&midi->
virtual, flags);
352 static void snd_wavefront_midi_output_timer(
unsigned long data)
361 spin_unlock_irqrestore (&midi->
virtual, flags);
362 snd_wavefront_midi_output_write(card);
374 if (substream->
rmidi->private_data ==
NULL)
379 if ((midi = get_wavefront_midi (substream)) ==
NULL) {
388 midi->
timer.function = snd_wavefront_midi_output_timer;
389 midi->
timer.data = (
unsigned long) substream->
rmidi->card->private_data;
390 midi->
timer.expires = 1 + jiffies;
397 midi->
mode[mpu] &= ~MPU401_MODE_OUTPUT_TRIGGER;
399 spin_unlock_irqrestore (&midi->
virtual, flags);
419 snd_wavefront_midi_output_write(card);
427 byte = read_data (midi);
442 if (substream ==
NULL) {
453 spin_unlock_irqrestore (&midi->
virtual, flags);
455 snd_wavefront_midi_output_write(card);
489 unsigned char rbuf[4], wbuf[4];
505 snd_printk (
"MIDI interface not ready for command\n");
517 for (ok = 0, i = 50000; i > 0 && !ok; i--) {
519 if (read_data (midi) ==
MPU_ACK) {
527 snd_printk (
"cannot set UART mode for MIDI interface");
535 snd_printk (
"can't enable MIDI-IN-2-synth routing.\n");
551 snd_printk (
"virtual MIDI mode not disabled\n");
558 snd_printk (
"cannot enable virtual MIDI mode.\n");
566 .open = snd_wavefront_midi_output_open,
567 .close = snd_wavefront_midi_output_close,
568 .trigger = snd_wavefront_midi_output_trigger,
573 .open = snd_wavefront_midi_input_open,
574 .close = snd_wavefront_midi_input_close,
575 .trigger = snd_wavefront_midi_input_trigger,