16 #include <linux/stddef.h>
28 #define MAX_QUEUE_SIZE 4000
50 static void midi_poll(
unsigned long dummy);
55 static volatile int open_devs;
58 #define DATA_AVAIL(q) (q->len)
59 #define SPACE_AVAIL(q) (MAX_QUEUE_SIZE - q->len)
61 #define QUEUE_BYTE(q, data) \
64 unsigned long flags; \
65 spin_lock_irqsave(&lock, flags); \
66 q->queue[q->tail] = (data); \
67 q->len++; q->tail = (q->tail+1) % MAX_QUEUE_SIZE; \
68 spin_unlock_irqrestore(&lock, flags); \
71 #define REMOVE_BYTE(q, data) \
74 unsigned long flags; \
75 spin_lock_irqsave(&lock, flags); \
76 data = q->queue[q->head]; \
77 q->len--; q->head = (q->head+1) % MAX_QUEUE_SIZE; \
78 spin_unlock_irqrestore(&lock, flags); \
81 static void drain_midi_queue(
int dev)
94 static void midi_input_intr(
int dev,
unsigned char data)
96 if (midi_in_buf[dev] ==
NULL)
112 static void midi_output_intr(
int dev)
119 static void midi_poll(
unsigned long dummy)
128 if (midi_devs[dev] !=
NULL && midi_out_buf[dev] !=
NULL)
135 spin_unlock_irqrestore(&lock,flags);
147 poll_timer.expires = (1) + jiffies;
153 spin_unlock_irqrestore(&lock, flags);
161 mode = translate_mode(file);
177 midi_input_intr, midi_output_intr)) < 0)
183 if (midi_in_buf[dev] ==
NULL)
193 if (midi_out_buf[dev] ==
NULL)
197 vfree(midi_in_buf[dev]);
209 poll_timer.expires = 1 +
jiffies;
220 mode = translate_mode(file);
242 drain_midi_queue(dev);
252 vfree(midi_in_buf[dev]);
253 vfree(midi_out_buf[dev]);
263 unsigned char tmp_data;
296 for (i = 0; i <
n; i++)
317 unsigned char tmp_data;
347 fixit = (
char *) &tmp_data;
363 unsigned int cmd,
void __user *
arg)
369 if (((cmd >> 8) & 0xff) ==
'C')
385 val = (
HZ *
val) / 10;
400 unsigned int mask = 0;
405 poll_wait(file, &input_sleeper[dev], wait);
410 poll_wait(file, &midi_sleeper[dev], wait);
420 if (midi_in_buf[dev])