• Home
  • Raw
  • Download

Lines Matching refs:devc

84 static inline int mpu401_status(struct mpu_config *devc)  in mpu401_status()  argument
86 return inb(STATPORT(devc->base)); in mpu401_status()
89 #define input_avail(devc) (!(mpu401_status(devc)&INPUT_AVAIL)) argument
90 #define output_ready(devc) (!(mpu401_status(devc)&OUTPUT_READY)) argument
92 static inline void write_command(struct mpu_config *devc, unsigned char cmd) in write_command() argument
94 outb(cmd, COMDPORT(devc->base)); in write_command()
97 static inline int read_data(struct mpu_config *devc) in read_data() argument
99 return inb(DATAPORT(devc->base)); in read_data()
102 static inline void write_data(struct mpu_config *devc, unsigned char byte) in write_data() argument
104 outb(byte, DATAPORT(devc->base)); in write_data()
117 static int reset_mpu401(struct mpu_config *devc);
118 static void set_uart_mode(int dev, struct mpu_config *devc, int arg);
122 static void timer_ext_event(struct mpu_config *devc, int event, int parm);
175 static int mpu_input_scanner(struct mpu_config *devc, unsigned char midic) in mpu_input_scanner() argument
178 switch (devc->m_state) in mpu_input_scanner()
192 if (devc->timer_flag) in mpu_input_scanner()
215 devc->m_state = ST_SYSMSG; in mpu_input_scanner()
222 devc->m_state = ST_TIMED; in mpu_input_scanner()
233 devc->m_state = ST_DATABYTE; in mpu_input_scanner()
238 msg = ((int) (devc->last_status & 0xf0) >> 4); in mpu_input_scanner()
240 devc->m_left = len_tab[msg] - 1; in mpu_input_scanner()
242 devc->m_ptr = 2; in mpu_input_scanner()
243 devc->m_buf[0] = devc->last_status; in mpu_input_scanner()
244 devc->m_buf[1] = midic; in mpu_input_scanner()
246 if (devc->m_left <= 0) in mpu_input_scanner()
248 devc->m_state = ST_INIT; in mpu_input_scanner()
249 do_midi_msg(devc->synthno, devc->m_buf, devc->m_ptr); in mpu_input_scanner()
250 devc->m_ptr = 0; in mpu_input_scanner()
255 devc->m_state = ST_INIT; in mpu_input_scanner()
277 devc->last_status = midic; in mpu_input_scanner()
280 devc->m_left = len_tab[msg]; in mpu_input_scanner()
282 devc->m_ptr = 1; in mpu_input_scanner()
283 devc->m_buf[0] = midic; in mpu_input_scanner()
285 if (devc->m_left <= 0) in mpu_input_scanner()
287 devc->m_state = ST_INIT; in mpu_input_scanner()
288 do_midi_msg(devc->synthno, devc->m_buf, devc->m_ptr); in mpu_input_scanner()
289 devc->m_ptr = 0; in mpu_input_scanner()
300 devc->m_state = ST_SYSEX; in mpu_input_scanner()
304 devc->m_state = ST_MTC; in mpu_input_scanner()
308 devc->m_state = ST_SONGPOS; in mpu_input_scanner()
309 devc->m_ptr = 0; in mpu_input_scanner()
313 devc->m_state = ST_SONGSEL; in mpu_input_scanner()
318 devc->m_state = ST_INIT; in mpu_input_scanner()
326 devc->m_state = ST_INIT; in mpu_input_scanner()
327 timer_ext_event(devc, TMR_CLOCK, 0); in mpu_input_scanner()
331 devc->m_state = ST_INIT; in mpu_input_scanner()
332 timer_ext_event(devc, TMR_START, 0); in mpu_input_scanner()
336 devc->m_state = ST_INIT; in mpu_input_scanner()
337 timer_ext_event(devc, TMR_CONTINUE, 0); in mpu_input_scanner()
341 devc->m_state = ST_INIT; in mpu_input_scanner()
342 timer_ext_event(devc, TMR_STOP, 0); in mpu_input_scanner()
347 devc->m_state = ST_INIT; in mpu_input_scanner()
352 devc->m_state = ST_INIT; in mpu_input_scanner()
357 devc->m_state = ST_INIT; in mpu_input_scanner()
362 devc->m_state = ST_INIT; in mpu_input_scanner()
370 devc->m_state = ST_INIT; in mpu_input_scanner()
377 BUFTEST(devc); in mpu_input_scanner()
378 devc->m_buf[devc->m_ptr++] = midic; in mpu_input_scanner()
379 if (devc->m_ptr == 2) in mpu_input_scanner()
381 devc->m_state = ST_INIT; in mpu_input_scanner()
382 devc->m_ptr = 0; in mpu_input_scanner()
383 timer_ext_event(devc, TMR_SPP, in mpu_input_scanner()
384 ((devc->m_buf[1] & 0x7f) << 7) | in mpu_input_scanner()
385 (devc->m_buf[0] & 0x7f)); in mpu_input_scanner()
390 BUFTEST(devc); in mpu_input_scanner()
391 devc->m_buf[devc->m_ptr++] = midic; in mpu_input_scanner()
392 if ((--devc->m_left) <= 0) in mpu_input_scanner()
394 devc->m_state = ST_INIT; in mpu_input_scanner()
395 do_midi_msg(devc->synthno, devc->m_buf, devc->m_ptr); in mpu_input_scanner()
396 devc->m_ptr = 0; in mpu_input_scanner()
401 printk("Bad state %d ", devc->m_state); in mpu_input_scanner()
402 devc->m_state = ST_INIT; in mpu_input_scanner()
407 static void mpu401_input_loop(struct mpu_config *devc) in mpu401_input_loop() argument
413 spin_lock_irqsave(&devc->lock,flags); in mpu401_input_loop()
414 busy = devc->m_busy; in mpu401_input_loop()
415 devc->m_busy = 1; in mpu401_input_loop()
416 spin_unlock_irqrestore(&devc->lock,flags); in mpu401_input_loop()
423 while (input_avail(devc) && n-- > 0) in mpu401_input_loop()
425 unsigned char c = read_data(devc); in mpu401_input_loop()
427 if (devc->mode == MODE_SYNTH) in mpu401_input_loop()
429 mpu_input_scanner(devc, c); in mpu401_input_loop()
431 else if (devc->opened & OPEN_READ && devc->inputintr != NULL) in mpu401_input_loop()
432 devc->inputintr(devc->devno, c); in mpu401_input_loop()
434 devc->m_busy = 0; in mpu401_input_loop()
439 struct mpu_config *devc; in mpuintr() local
443 devc = &dev_conf[dev]; in mpuintr()
445 if (input_avail(devc)) in mpuintr()
448 if (devc->base != 0 && (devc->opened & OPEN_READ || devc->mode == MODE_SYNTH)) in mpuintr()
449 mpu401_input_loop(devc); in mpuintr()
453 read_data(devc); in mpuintr()
465 struct mpu_config *devc; in mpu401_open() local
471 devc = &dev_conf[dev]; in mpu401_open()
473 if (devc->opened) in mpu401_open()
482 if (!devc->initialized) in mpu401_open()
484 if (mpu401_status(devc) == 0xff) /* Bus float */ in mpu401_open()
489 reset_mpu401(devc); in mpu401_open()
499 if ((err = coprocessor->open(coprocessor->devc, COPR_MIDI)) < 0) in mpu401_open()
507 set_uart_mode(dev, devc, 1); in mpu401_open()
508 devc->mode = MODE_MIDI; in mpu401_open()
509 devc->synthno = 0; in mpu401_open()
511 mpu401_input_loop(devc); in mpu401_open()
513 devc->inputintr = input; in mpu401_open()
514 devc->opened = mode; in mpu401_open()
521 struct mpu_config *devc; in mpu401_close() local
524 devc = &dev_conf[dev]; in mpu401_close()
525 if (devc->uart_mode) in mpu401_close()
526 reset_mpu401(devc); /* in mpu401_close()
529 devc->mode = 0; in mpu401_close()
530 devc->inputintr = NULL; in mpu401_close()
534 coprocessor->close(coprocessor->devc, COPR_MIDI); in mpu401_close()
537 devc->opened = 0; in mpu401_close()
545 struct mpu_config *devc; in mpu401_out() local
547 devc = &dev_conf[dev]; in mpu401_out()
554 for (timeout = 30000; timeout > 0 && !output_ready(devc); timeout--); in mpu401_out()
556 spin_lock_irqsave(&devc->lock,flags); in mpu401_out()
557 if (!output_ready(devc)) in mpu401_out()
560 spin_unlock_irqrestore(&devc->lock,flags); in mpu401_out()
563 write_data(devc, midi_byte); in mpu401_out()
564 spin_unlock_irqrestore(&devc->lock,flags); in mpu401_out()
572 struct mpu_config *devc; in mpu401_command() local
574 devc = &dev_conf[dev]; in mpu401_command()
576 if (devc->uart_mode) /* in mpu401_command()
586 if (input_avail(devc)) in mpu401_command()
587 mpu401_input_loop(devc); in mpu401_command()
601 spin_lock_irqsave(&devc->lock,flags); in mpu401_command()
603 if (!output_ready(devc)) in mpu401_command()
605 spin_unlock_irqrestore(&devc->lock,flags); in mpu401_command()
608 write_command(devc, cmd->cmd); in mpu401_command()
613 if (input_avail(devc)) in mpu401_command()
615 if (devc->opened && devc->mode == MODE_SYNTH) in mpu401_command()
617 if (mpu_input_scanner(devc, read_data(devc)) == MPU_ACK) in mpu401_command()
623 if (read_data(devc) == MPU_ACK) in mpu401_command()
630 spin_unlock_irqrestore(&devc->lock,flags); in mpu401_command()
637 for (timeout = 3000; timeout > 0 && !output_ready(devc); timeout--); in mpu401_command()
641 spin_unlock_irqrestore(&devc->lock,flags); in mpu401_command()
655 if (input_avail(devc)) in mpu401_command()
657 cmd->data[i] = read_data(devc); in mpu401_command()
662 spin_unlock_irqrestore(&devc->lock,flags); in mpu401_command()
667 spin_unlock_irqrestore(&devc->lock,flags); in mpu401_command()
689 struct mpu_config *devc = &dev_conf[dev]; in mpu401_prefix_cmd() local
691 if (devc->uart_mode) in mpu401_prefix_cmd()
724 struct mpu_config *devc; in mpu401_ioctl() local
728 devc = &dev_conf[dev]; in mpu401_ioctl()
732 if (!(devc->capabilities & MPU_CAP_INTLG)) { /* No intelligent mode */ in mpu401_ioctl()
738 set_uart_mode(dev, devc, !val); in mpu401_ioctl()
769 struct mpu_config *devc; in mpu_synth_ioctl() local
776 devc = &dev_conf[midi_dev]; in mpu_synth_ioctl()
798 struct mpu_config *devc; in mpu_synth_open() local
806 devc = &dev_conf[midi_dev]; in mpu_synth_open()
815 if (!devc->initialized) in mpu_synth_open()
817 if (mpu401_status(devc) == 0xff) /* Bus float */ in mpu_synth_open()
822 reset_mpu401(devc); in mpu_synth_open()
824 if (devc->opened) in mpu_synth_open()
826 devc->mode = MODE_SYNTH; in mpu_synth_open()
827 devc->synthno = dev; in mpu_synth_open()
829 devc->inputintr = NULL; in mpu_synth_open()
836 if ((err = coprocessor->open(coprocessor->devc, COPR_MIDI)) < 0) in mpu_synth_open()
842 devc->opened = mode; in mpu_synth_open()
843 reset_mpu401(devc); in mpu_synth_open()
857 struct mpu_config *devc; in mpu_synth_close() local
862 devc = &dev_conf[midi_dev]; in mpu_synth_close()
866 devc->inputintr = NULL; in mpu_synth_close()
870 coprocessor->close(coprocessor->devc, COPR_MIDI); in mpu_synth_close()
873 devc->opened = 0; in mpu_synth_close()
874 devc->mode = 0; in mpu_synth_close()
926 static void mpu401_chk_version(int n, struct mpu_config *devc) in mpu401_chk_version() argument
930 devc->version = devc->revision = 0; in mpu401_chk_version()
937 devc->version = tmp; in mpu401_chk_version()
940 devc->version = 0; in mpu401_chk_version()
943 devc->revision = tmp; in mpu401_chk_version()
952 struct mpu_config *devc; in attach_mpu401() local
962 devc = &dev_conf[m]; in attach_mpu401()
963 devc->base = hw_config->io_base; in attach_mpu401()
964 devc->osp = hw_config->osp; in attach_mpu401()
965 devc->irq = hw_config->irq; in attach_mpu401()
966 devc->opened = 0; in attach_mpu401()
967 devc->uart_mode = 0; in attach_mpu401()
968 devc->initialized = 0; in attach_mpu401()
969 devc->version = 0; in attach_mpu401()
970 devc->revision = 0; in attach_mpu401()
971 devc->capabilities = 0; in attach_mpu401()
972 devc->timer_flag = 0; in attach_mpu401()
973 devc->m_busy = 0; in attach_mpu401()
974 devc->m_state = ST_INIT; in attach_mpu401()
975 devc->shared_irq = hw_config->always_detect; in attach_mpu401()
976 spin_lock_init(&devc->lock); in attach_mpu401()
978 if (devc->irq < 0) in attach_mpu401()
980 devc->irq *= -1; in attach_mpu401()
981 devc->shared_irq = 1; in attach_mpu401()
987 if (!reset_mpu401(devc)) in attach_mpu401()
993 if (!devc->shared_irq) in attach_mpu401()
995 if (request_irq(devc->irq, mpuintr, 0, "mpu401", in attach_mpu401()
998 printk(KERN_WARNING "mpu401: Failed to allocate IRQ%d\n", devc->irq); in attach_mpu401()
1003 spin_lock_irqsave(&devc->lock,flags); in attach_mpu401()
1004 mpu401_chk_version(m, devc); in attach_mpu401()
1005 if (devc->version == 0) in attach_mpu401()
1006 mpu401_chk_version(m, devc); in attach_mpu401()
1007 spin_unlock_irqrestore(&devc->lock, flags); in attach_mpu401()
1010 if (devc->version != 0) in attach_mpu401()
1013 devc->capabilities |= MPU_CAP_INTLG; /* Supports intelligent mode */ in attach_mpu401()
1024 if (!(devc->capabilities & MPU_CAP_INTLG)) /* No intelligent mode */ in attach_mpu401()
1051 if (devc->version == 0x20 && devc->revision >= 0x07) /* MusicQuest interface */ in attach_mpu401()
1053 int ports = (devc->revision & 0x08) ? 32 : 16; in attach_mpu401()
1055 devc->capabilities |= MPU_CAP_SYNC | MPU_CAP_SMPTE | in attach_mpu401()
1058 revision_char = (devc->revision == 0x7f) ? 'M' : ' '; in attach_mpu401()
1066 revision_char = devc->revision ? devc->revision + '@' : ' '; in attach_mpu401()
1067 if ((int) devc->revision > ('Z' - '@')) in attach_mpu401()
1070 devc->capabilities |= MPU_CAP_SYNC | MPU_CAP_FSK; in attach_mpu401()
1077 (int) (devc->version & 0xf0) >> 4, in attach_mpu401()
1078 devc->version & 0x0f, in attach_mpu401()
1088 mpu401_synth_operations[m]->midi_dev = devc->devno = m; in attach_mpu401()
1089 mpu401_synth_operations[devc->devno]->info = &mpu_synth_info[devc->devno]; in attach_mpu401()
1091 if (devc->capabilities & MPU_CAP_INTLG) /* Intelligent mode */ in attach_mpu401()
1094 midi_devs[m] = &mpu401_midi_operations[devc->devno]; in attach_mpu401()
1105 free_irq(devc->irq, hw_config); in attach_mpu401()
1113 static int reset_mpu401(struct mpu_config *devc) in reset_mpu401() argument
1126 timeout_limit = devc->initialized ? 30000 : 100000; in reset_mpu401()
1127 devc->initialized = 1; in reset_mpu401()
1132 ok = output_ready(devc); in reset_mpu401()
1134 write_command(devc, MPU_RESET); /* in reset_mpu401()
1145 spin_lock_irqsave(&devc->lock,flags); in reset_mpu401()
1146 if (input_avail(devc)) in reset_mpu401()
1147 if (read_data(devc) == MPU_ACK) in reset_mpu401()
1149 spin_unlock_irqrestore(&devc->lock,flags); in reset_mpu401()
1154 devc->m_state = ST_INIT; in reset_mpu401()
1155 devc->m_ptr = 0; in reset_mpu401()
1156 devc->m_left = 0; in reset_mpu401()
1157 devc->last_status = 0; in reset_mpu401()
1158 devc->uart_mode = 0; in reset_mpu401()
1163 static void set_uart_mode(int dev, struct mpu_config *devc, int arg) in set_uart_mode() argument
1165 if (!arg && (devc->capabilities & MPU_CAP_INTLG)) in set_uart_mode()
1167 if ((devc->uart_mode == 0) == (arg == 0)) in set_uart_mode()
1169 reset_mpu401(devc); /* This exits the uart mode */ in set_uart_mode()
1176 devc->uart_mode = 0; in set_uart_mode()
1180 devc->uart_mode = arg; in set_uart_mode()
1275 static void tmr_reset(struct mpu_config *devc) in tmr_reset() argument
1279 spin_lock_irqsave(&devc->lock,flags); in tmr_reset()
1283 spin_unlock_irqrestore(&devc->lock,flags); in tmr_reset()
1338 struct mpu_config *devc= &dev_conf[midi_dev]; in mpu_start_timer() local
1340 tmr_reset(devc); in mpu_start_timer()
1365 struct mpu_config *devc= &dev_conf[midi_dev]; in mpu_timer_open() local
1370 tmr_reset(devc); in mpu_timer_open()
1637 static void timer_ext_event(struct mpu_config *devc, int event, int parm) in timer_ext_event() argument
1639 int midi_dev = devc->devno; in timer_ext_event()
1641 if (!devc->timer_flag) in timer_ext_event()
1696 struct mpu_config *devc; in mpu_timer_init() local
1699 devc = &dev_conf[midi_dev]; in mpu_timer_init()
1714 if (devc->version < 0x20) /* Original MPU-401 */ in mpu_timer_init()
1726 if (devc->revision) in mpu_timer_init()
1729 if (devc->revision & 0x02) in mpu_timer_init()
1733 if (devc->revision & 0x40) in mpu_timer_init()