Lines Matching refs:devc
47 #define DATAPORT (devc->base)
48 #define COMDPORT (devc->base+1)
49 #define STATPORT (devc->base+1)
51 static int uart401_status(uart401_devc * devc) in uart401_status() argument
56 #define input_avail(devc) (!(uart401_status(devc)&INPUT_AVAIL)) argument
57 #define output_ready(devc) (!(uart401_status(devc)&OUTPUT_READY)) argument
59 static void uart401_cmd(uart401_devc * devc, unsigned char cmd) in uart401_cmd() argument
64 static int uart401_read(uart401_devc * devc) in uart401_read() argument
69 static void uart401_write(uart401_devc * devc, unsigned char byte) in uart401_write() argument
80 static int reset_uart401(uart401_devc * devc);
81 static void enter_uart_mode(uart401_devc * devc);
83 static void uart401_input_loop(uart401_devc * devc) in uart401_input_loop() argument
87 while (input_avail(devc) && --work_limit) in uart401_input_loop()
89 unsigned char c = uart401_read(devc); in uart401_input_loop()
92 devc->input_byte = c; in uart401_input_loop()
93 else if (devc->opened & OPEN_READ && devc->midi_input_intr) in uart401_input_loop()
94 devc->midi_input_intr(devc->my_dev, c); in uart401_input_loop()
97 …printk(KERN_WARNING "Too much work in interrupt on uart401 (0x%X). UART jabbering ??\n", devc->bas… in uart401_input_loop()
102 uart401_devc *devc = dev_id; in uart401intr() local
104 if (devc == NULL) in uart401intr()
110 if (input_avail(devc)) in uart401intr()
111 uart401_input_loop(devc); in uart401intr()
121 uart401_devc *devc = (uart401_devc *) midi_devs[dev]->devc; in uart401_open() local
123 if (devc->opened) in uart401_open()
128 while (input_avail(devc)) in uart401_open()
129 uart401_read(devc); in uart401_open()
131 devc->midi_input_intr = input; in uart401_open()
132 devc->opened = mode; in uart401_open()
133 enter_uart_mode(devc); in uart401_open()
134 devc->disabled = 0; in uart401_open()
141 uart401_devc *devc = (uart401_devc *) midi_devs[dev]->devc; in uart401_close() local
143 reset_uart401(devc); in uart401_close()
144 devc->opened = 0; in uart401_close()
151 uart401_devc *devc = (uart401_devc *) midi_devs[dev]->devc; in uart401_out() local
153 if (devc->disabled) in uart401_out()
159 spin_lock_irqsave(&devc->lock,flags); in uart401_out()
160 if (input_avail(devc)) in uart401_out()
161 uart401_input_loop(devc); in uart401_out()
163 spin_unlock_irqrestore(&devc->lock,flags); in uart401_out()
170 for (timeout = 30000; timeout > 0 && !output_ready(devc); timeout--); in uart401_out()
172 if (!output_ready(devc)) in uart401_out()
175 devc->disabled = 1; in uart401_out()
176 reset_uart401(devc); in uart401_out()
177 enter_uart_mode(devc); in uart401_out()
180 uart401_write(devc, midi_byte); in uart401_out()
222 static void enter_uart_mode(uart401_devc * devc) in enter_uart_mode() argument
227 spin_lock_irqsave(&devc->lock,flags); in enter_uart_mode()
228 for (timeout = 30000; timeout > 0 && !output_ready(devc); timeout--); in enter_uart_mode()
230 devc->input_byte = 0; in enter_uart_mode()
231 uart401_cmd(devc, UART_MODE_ON); in enter_uart_mode()
235 if (devc->input_byte == MPU_ACK) in enter_uart_mode()
237 else if (input_avail(devc)) in enter_uart_mode()
238 if (uart401_read(devc) == MPU_ACK) in enter_uart_mode()
241 spin_unlock_irqrestore(&devc->lock,flags); in enter_uart_mode()
244 static int reset_uart401(uart401_devc * devc) in reset_uart401() argument
256 for (timeout = 30000; timeout > 0 && !output_ready(devc); timeout--); in reset_uart401()
257 devc->input_byte = 0; in reset_uart401()
258 uart401_cmd(devc, MPU_RESET); in reset_uart401()
267 if (devc->input_byte == MPU_ACK) /* Interrupt */ in reset_uart401()
269 else if (input_avail(devc)) in reset_uart401()
271 if (uart401_read(devc) == MPU_ACK) in reset_uart401()
286 uart401_input_loop(devc); /* in reset_uart401()
295 uart401_devc *devc; in probe_uart401() local
310 devc = kmalloc(sizeof(uart401_devc), GFP_KERNEL); in probe_uart401()
311 if (!devc) { in probe_uart401()
316 devc->base = hw_config->io_base; in probe_uart401()
317 devc->irq = hw_config->irq; in probe_uart401()
318 devc->osp = hw_config->osp; in probe_uart401()
319 devc->midi_input_intr = NULL; in probe_uart401()
320 devc->opened = 0; in probe_uart401()
321 devc->input_byte = 0; in probe_uart401()
322 devc->my_dev = 0; in probe_uart401()
323 devc->share_irq = 0; in probe_uart401()
324 spin_lock_init(&devc->lock); in probe_uart401()
326 spin_lock_irqsave(&devc->lock,flags); in probe_uart401()
327 ok = reset_uart401(devc); in probe_uart401()
328 spin_unlock_irqrestore(&devc->lock,flags); in probe_uart401()
336 if (devc->irq < 0) { in probe_uart401()
337 devc->share_irq = 1; in probe_uart401()
338 devc->irq *= -1; in probe_uart401()
340 devc->share_irq = 0; in probe_uart401()
342 if (!devc->share_irq) in probe_uart401()
343 if (request_irq(devc->irq, uart401intr, 0, "MPU-401 UART", devc) < 0) { in probe_uart401()
344 printk(KERN_WARNING "uart401: Failed to allocate IRQ%d\n", devc->irq); in probe_uart401()
345 devc->share_irq = 1; in probe_uart401()
347 devc->my_dev = sound_alloc_mididev(); in probe_uart401()
348 enter_uart_mode(devc); in probe_uart401()
350 if (devc->my_dev == -1) { in probe_uart401()
355 midi_devs[devc->my_dev] = kmalloc(sizeof(struct midi_operations), GFP_KERNEL); in probe_uart401()
356 if (!midi_devs[devc->my_dev]) { in probe_uart401()
360 memcpy(midi_devs[devc->my_dev], &uart401_operations, sizeof(struct midi_operations)); in probe_uart401()
363 midi_devs[devc->my_dev]->owner = owner; in probe_uart401()
365 midi_devs[devc->my_dev]->devc = devc; in probe_uart401()
366 midi_devs[devc->my_dev]->converter = kmalloc(sizeof(struct synth_operations), GFP_KERNEL); in probe_uart401()
367 if (!midi_devs[devc->my_dev]->converter) { in probe_uart401()
371 memcpy(midi_devs[devc->my_dev]->converter, &std_midi_synth, sizeof(struct synth_operations)); in probe_uart401()
372 strcpy(midi_devs[devc->my_dev]->info.name, name); in probe_uart401()
373 midi_devs[devc->my_dev]->converter->id = "UART401"; in probe_uart401()
374 midi_devs[devc->my_dev]->converter->midi_dev = devc->my_dev; in probe_uart401()
377 midi_devs[devc->my_dev]->converter->owner = owner; in probe_uart401()
379 hw_config->slots[4] = devc->my_dev; in probe_uart401()
381 devc->opened = 0; in probe_uart401()
384 kfree(midi_devs[devc->my_dev]); in probe_uart401()
386 sound_unload_mididev(devc->my_dev); in probe_uart401()
388 if (!devc->share_irq) in probe_uart401()
389 free_irq(devc->irq, devc); in probe_uart401()
391 kfree(devc); in probe_uart401()
399 uart401_devc *devc; in unload_uart401() local
408 devc = midi_devs[hw_config->slots[4]]->devc; in unload_uart401()
409 if (devc == NULL) in unload_uart401()
412 reset_uart401(devc); in unload_uart401()
415 if (!devc->share_irq) in unload_uart401()
416 free_irq(devc->irq, devc); in unload_uart401()
417 if (devc) in unload_uart401()
419 kfree(midi_devs[devc->my_dev]->converter); in unload_uart401()
420 kfree(midi_devs[devc->my_dev]); in unload_uart401()
421 kfree(devc); in unload_uart401()
422 devc = NULL; in unload_uart401()