Lines Matching refs:dev
82 static void drain_midi_queue(int dev) in drain_midi_queue() argument
89 if (midi_devs[dev]->buffer_status != NULL) in drain_midi_queue()
90 while (!signal_pending(current) && midi_devs[dev]->buffer_status(dev)) in drain_midi_queue()
91 interruptible_sleep_on_timeout(&midi_sleeper[dev], in drain_midi_queue()
95 static void midi_input_intr(int dev, unsigned char data) in midi_input_intr() argument
97 if (midi_in_buf[dev] == NULL) in midi_input_intr()
107 if (SPACE_AVAIL(midi_in_buf[dev])) { in midi_input_intr()
108 QUEUE_BYTE(midi_in_buf[dev], data); in midi_input_intr()
109 wake_up(&input_sleeper[dev]); in midi_input_intr()
113 static void midi_output_intr(int dev) in midi_output_intr() argument
123 int dev; in midi_poll() local
129 for (dev = 0; dev < num_midis; dev++) in midi_poll()
130 if (midi_devs[dev] != NULL && midi_out_buf[dev] != NULL) in midi_poll()
132 while (DATA_AVAIL(midi_out_buf[dev])) in midi_poll()
135 int c = midi_out_buf[dev]->queue[midi_out_buf[dev]->head]; in midi_poll()
138 ok = midi_devs[dev]->outputc(dev, c); in midi_poll()
142 midi_out_buf[dev]->head = (midi_out_buf[dev]->head + 1) % MAX_QUEUE_SIZE; in midi_poll()
143 midi_out_buf[dev]->len--; in midi_poll()
146 if (DATA_AVAIL(midi_out_buf[dev]) < 100) in midi_poll()
147 wake_up(&midi_sleeper[dev]); in midi_poll()
158 int MIDIbuf_open(int dev, struct file *file) in MIDIbuf_open() argument
162 dev = dev >> 4; in MIDIbuf_open()
170 if (dev < 0 || dev >= num_midis || midi_devs[dev] == NULL) in MIDIbuf_open()
176 if (midi_devs[dev]->owner) in MIDIbuf_open()
177 __MOD_INC_USE_COUNT (midi_devs[dev]->owner); in MIDIbuf_open()
179 if ((err = midi_devs[dev]->open(dev, mode, in MIDIbuf_open()
183 parms[dev].prech_timeout = MAX_SCHEDULE_TIMEOUT; in MIDIbuf_open()
184 midi_in_buf[dev] = (struct midi_buf *) vmalloc(sizeof(struct midi_buf)); in MIDIbuf_open()
186 if (midi_in_buf[dev] == NULL) in MIDIbuf_open()
189 midi_devs[dev]->close(dev); in MIDIbuf_open()
192 midi_in_buf[dev]->len = midi_in_buf[dev]->head = midi_in_buf[dev]->tail = 0; in MIDIbuf_open()
194 midi_out_buf[dev] = (struct midi_buf *) vmalloc(sizeof(struct midi_buf)); in MIDIbuf_open()
196 if (midi_out_buf[dev] == NULL) in MIDIbuf_open()
199 midi_devs[dev]->close(dev); in MIDIbuf_open()
200 vfree(midi_in_buf[dev]); in MIDIbuf_open()
201 midi_in_buf[dev] = NULL; in MIDIbuf_open()
204 midi_out_buf[dev]->len = midi_out_buf[dev]->head = midi_out_buf[dev]->tail = 0; in MIDIbuf_open()
207 init_waitqueue_head(&midi_sleeper[dev]); in MIDIbuf_open()
208 init_waitqueue_head(&input_sleeper[dev]); in MIDIbuf_open()
218 void MIDIbuf_release(int dev, struct file *file) in MIDIbuf_release() argument
223 dev = dev >> 4; in MIDIbuf_release()
226 if (dev < 0 || dev >= num_midis || midi_devs[dev] == NULL) in MIDIbuf_release()
238 midi_devs[dev]->outputc(dev, 0xfe); /* in MIDIbuf_release()
243 while (!signal_pending(current) && DATA_AVAIL(midi_out_buf[dev])) in MIDIbuf_release()
244 interruptible_sleep_on(&midi_sleeper[dev]); in MIDIbuf_release()
249 drain_midi_queue(dev); /* in MIDIbuf_release()
255 midi_devs[dev]->close(dev); in MIDIbuf_release()
260 vfree(midi_in_buf[dev]); in MIDIbuf_release()
261 vfree(midi_out_buf[dev]); in MIDIbuf_release()
262 midi_in_buf[dev] = NULL; in MIDIbuf_release()
263 midi_out_buf[dev] = NULL; in MIDIbuf_release()
265 if (midi_devs[dev]->owner) in MIDIbuf_release()
266 __MOD_DEC_USE_COUNT (midi_devs[dev]->owner); in MIDIbuf_release()
269 int MIDIbuf_write(int dev, struct file *file, const char *buf, int count) in MIDIbuf_write() argument
275 dev = dev >> 4; in MIDIbuf_write()
287 n = SPACE_AVAIL(midi_out_buf[dev]); in MIDIbuf_write()
298 interruptible_sleep_on(&midi_sleeper[dev]); in MIDIbuf_write()
304 n = SPACE_AVAIL(midi_out_buf[dev]); in MIDIbuf_write()
313 QUEUE_BYTE(midi_out_buf[dev], tmp_data); in MIDIbuf_write()
322 int MIDIbuf_read(int dev, struct file *file, char *buf, int count) in MIDIbuf_read() argument
328 dev = dev >> 4; in MIDIbuf_read()
333 if (!DATA_AVAIL(midi_in_buf[dev])) { /* in MIDIbuf_read()
340 interruptible_sleep_on_timeout(&input_sleeper[dev], in MIDIbuf_read()
341 parms[dev].prech_timeout); in MIDIbuf_read()
346 if (c == 0 && DATA_AVAIL(midi_in_buf[dev])) /* in MIDIbuf_read()
350 n = DATA_AVAIL(midi_in_buf[dev]); in MIDIbuf_read()
358 REMOVE_BYTE(midi_in_buf[dev], tmp_data); in MIDIbuf_read()
369 int MIDIbuf_ioctl(int dev, struct file *file, in MIDIbuf_ioctl() argument
374 dev = dev >> 4; in MIDIbuf_ioctl()
378 if (midi_devs[dev]->coproc) /* Coprocessor ioctl */ in MIDIbuf_ioctl()
379 return midi_devs[dev]->coproc->ioctl(midi_devs[dev]->coproc->devc, cmd, arg, 0); in MIDIbuf_ioctl()
393 parms[dev].prech_timeout = val; in MIDIbuf_ioctl()
397 if (!midi_devs[dev]->ioctl) in MIDIbuf_ioctl()
399 return midi_devs[dev]->ioctl(dev, cmd, arg); in MIDIbuf_ioctl()
405 unsigned int MIDIbuf_poll(int dev, struct file *file, poll_table * wait) in MIDIbuf_poll() argument
409 dev = dev >> 4; in MIDIbuf_poll()
412 poll_wait(file, &input_sleeper[dev], wait); in MIDIbuf_poll()
413 if (DATA_AVAIL(midi_in_buf[dev])) in MIDIbuf_poll()
417 poll_wait(file, &midi_sleeper[dev], wait); in MIDIbuf_poll()
418 if (!SPACE_AVAIL(midi_out_buf[dev])) in MIDIbuf_poll()
434 int MIDIbuf_avail(int dev) in MIDIbuf_avail() argument
436 if (midi_in_buf[dev]) in MIDIbuf_avail()
437 return DATA_AVAIL (midi_in_buf[dev]); in MIDIbuf_avail()