This source file includes following definitions.
- mpu_input_scanner
- mpu401_input_loop
- mpuintr
- mpu401_open
- mpu401_close
- mpu401_out
- mpu401_command
- mpu_cmd
- mpu401_prefix_cmd
- mpu401_start_read
- mpu401_end_read
- mpu401_ioctl
- mpu401_kick
- mpu401_buffer_status
- mpu_synth_ioctl
- mpu_synth_open
- mpu_synth_close
- mpu401_chk_version
- attach_mpu401
- reset_mpu401
- set_uart_mode
- probe_mpu401
- unload_mpu401
- clocks2ticks
- set_timebase
- tmr_reset
- set_timer_mode
- stop_metronome
- setup_metronome
- mpu_start_timer
- mpu_timer_open
- mpu_timer_close
- mpu_timer_event
- mpu_timer_get_time
- mpu_timer_ioctl
- mpu_timer_arm
- mpu_timer_interrupt
- timer_ext_event
- mpu_timer_init
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33 #define USE_SEQ_MACROS
34 #define USE_SIMPLE_MACROS
35
36 #include "sound_config.h"
37
38 #ifdef CONFIGURE_SOUNDCARD
39
40 #if (!defined(EXCLUDE_MPU401) || !defined(EXCLUDE_MPU_EMU)) && !defined(EXCLUDE_MIDI)
41 #include "coproc.h"
42
43 static int init_sequence[20];
44
45 #ifndef EXCLUDE_SEQUENCER
46 static int timer_mode = TMR_INTERNAL, timer_caps = TMR_INTERNAL;
47
48 #endif
49
50 struct mpu_config
51 {
52 int base;
53
54
55 int irq;
56 int opened;
57
58
59 int devno;
60 int synthno;
61 int uart_mode;
62 int initialized;
63 int mode;
64 #define MODE_MIDI 1
65 #define MODE_SYNTH 2
66 unsigned char version, revision;
67 unsigned int capabilities;
68 #define MPU_CAP_INTLG 0x10000000
69 #define MPU_CAP_SYNC 0x00000010
70 #define MPU_CAP_FSK 0x00000020
71 #define MPU_CAP_CLS 0x00000040
72 #define MPU_CAP_SMPTE 0x00000080
73 #define MPU_CAP_2PORT 0x00000001
74 int timer_flag;
75
76 #define MBUF_MAX 10
77 #define BUFTEST(dc) if (dc->m_ptr >= MBUF_MAX || dc->m_ptr < 0) \
78 {printk("MPU: Invalid buffer pointer %d/%d, s=%d\n", dc->m_ptr, dc->m_left, dc->m_state);dc->m_ptr--;}
79 int m_busy;
80 unsigned char m_buf[MBUF_MAX];
81 int m_ptr;
82 int m_state;
83 int m_left;
84 unsigned char last_status;
85 void (*inputintr) (int dev, unsigned char data);
86 int shared_irq;
87 sound_os_info *osp;
88 };
89
90 #define DATAPORT(base) (base)
91 #define COMDPORT(base) (base+1)
92 #define STATPORT(base) (base+1)
93
94 #define mpu401_status(devc) inb( STATPORT(devc->base))
95 #define input_avail(devc) (!(mpu401_status(devc)&INPUT_AVAIL))
96 #define output_ready(devc) (!(mpu401_status(devc)&OUTPUT_READY))
97 #define write_command(devc, cmd) outb( cmd, COMDPORT(devc->base))
98 #define read_data(devc) inb( DATAPORT(devc->base))
99
100 #define write_data(devc, byte) outb( byte, DATAPORT(devc->base))
101
102 #define OUTPUT_READY 0x40
103 #define INPUT_AVAIL 0x80
104 #define MPU_ACK 0xFE
105 #define MPU_RESET 0xFF
106 #define UART_MODE_ON 0x3F
107
108 static struct mpu_config dev_conf[MAX_MIDI_DEV] =
109 {
110 {0}};
111
112 static int n_mpu_devs = 0;
113 static volatile int irq2dev[17] =
114 {-1, -1, -1, -1, -1, -1, -1, -1,
115 -1, -1, -1, -1, -1, -1, -1, -1, -1};
116
117 static int reset_mpu401 (struct mpu_config *devc);
118 static void set_uart_mode (int dev, struct mpu_config *devc, int arg);
119
120 static void mpu_timer_init (int midi_dev);
121 static void mpu_timer_interrupt (void);
122 static void timer_ext_event (struct mpu_config *devc, int event, int parm);
123
124 static struct synth_info mpu_synth_info_proto =
125 {"MPU-401 MIDI interface", 0, SYNTH_TYPE_MIDI, 0, 0, 128, 0, 128, SYNTH_CAP_INPUT};
126
127 static struct synth_info mpu_synth_info[MAX_MIDI_DEV];
128
129
130
131
132
133 #define ST_INIT 0
134 #define ST_TIMED 1
135 #define ST_DATABYTE 2
136
137 #define ST_SYSMSG 100
138 #define ST_SYSEX 101
139 #define ST_MTC 102
140 #define ST_SONGSEL 103
141 #define ST_SONGPOS 104
142
143 static unsigned char len_tab[] =
144
145 {
146 2,
147 2,
148 2,
149 2,
150 1,
151 1,
152 2,
153 0
154 };
155
156 #ifdef EXCLUDE_SEQUENCER
157 #define STORE(cmd)
158 #else
159 #define STORE(cmd) \
160 { \
161 int len; \
162 unsigned char obuf[8]; \
163 cmd; \
164 seq_input_event(obuf, len); \
165 }
166 #endif
167
168 #define _seqbuf obuf
169 #define _seqbufptr 0
170 #define _SEQ_ADVBUF(x) len=x
171
172 static int
173 mpu_input_scanner (struct mpu_config *devc, unsigned char midic)
174 {
175
176 switch (devc->m_state)
177 {
178 case ST_INIT:
179 switch (midic)
180 {
181 case 0xf8:
182
183 break;
184
185 case 0xfc:
186 printk ("<all end>");
187 break;
188
189 case 0xfd:
190 if (devc->timer_flag)
191 mpu_timer_interrupt ();
192 break;
193
194 case 0xfe:
195 return MPU_ACK;
196 break;
197
198 case 0xf0:
199 case 0xf1:
200 case 0xf2:
201 case 0xf3:
202 case 0xf4:
203 case 0xf5:
204 case 0xf6:
205 case 0xf7:
206 printk ("<Trk data rq #%d>", midic & 0x0f);
207 break;
208
209 case 0xf9:
210 printk ("<conductor rq>");
211 break;
212
213 case 0xff:
214 devc->m_state = ST_SYSMSG;
215 break;
216
217 default:
218 if (midic <= 0xef)
219 {
220
221 devc->m_state = ST_TIMED;
222 }
223 else
224 printk ("<MPU: Unknown event %02x> ", midic);
225 }
226 break;
227
228 case ST_TIMED:
229 {
230 int msg = ((int) (midic & 0xf0) >> 4);
231
232 devc->m_state = ST_DATABYTE;
233
234 if (msg < 8)
235 {
236
237 msg = ((int) (devc->last_status & 0xf0) >> 4);
238 msg -= 8;
239 devc->m_left = len_tab[msg] - 1;
240
241 devc->m_ptr = 2;
242 devc->m_buf[0] = devc->last_status;
243 devc->m_buf[1] = midic;
244
245 if (devc->m_left <= 0)
246 {
247 devc->m_state = ST_INIT;
248 do_midi_msg (devc->synthno, devc->m_buf, devc->m_ptr);
249 devc->m_ptr = 0;
250 }
251 }
252 else if (msg == 0xf)
253 {
254 devc->m_state = ST_INIT;
255
256 switch (midic)
257 {
258 case 0xf8:
259
260 break;
261
262 case 0xf9:
263
264 break;
265
266 case 0xfc:
267
268 break;
269
270 default:
271 printk ("Unknown MPU mark %02x\n", midic);
272 }
273 }
274 else
275 {
276 devc->last_status = midic;
277
278 msg -= 8;
279 devc->m_left = len_tab[msg];
280
281 devc->m_ptr = 1;
282 devc->m_buf[0] = midic;
283
284 if (devc->m_left <= 0)
285 {
286 devc->m_state = ST_INIT;
287 do_midi_msg (devc->synthno, devc->m_buf, devc->m_ptr);
288 devc->m_ptr = 0;
289 }
290 }
291 }
292 break;
293
294 case ST_SYSMSG:
295 switch (midic)
296 {
297 case 0xf0:
298 printk ("<SYX>");
299 devc->m_state = ST_SYSEX;
300 break;
301
302 case 0xf1:
303 devc->m_state = ST_MTC;
304 break;
305
306 case 0xf2:
307 devc->m_state = ST_SONGPOS;
308 devc->m_ptr = 0;
309 break;
310
311 case 0xf3:
312 devc->m_state = ST_SONGSEL;
313 break;
314
315 case 0xf6:
316
317 devc->m_state = ST_INIT;
318
319
320
321
322 case 0xf8:
323
324 devc->m_state = ST_INIT;
325 timer_ext_event (devc, TMR_CLOCK, 0);
326 break;
327
328 case 0xfA:
329 devc->m_state = ST_INIT;
330 timer_ext_event (devc, TMR_START, 0);
331 break;
332
333 case 0xFB:
334 devc->m_state = ST_INIT;
335 timer_ext_event (devc, TMR_CONTINUE, 0);
336 break;
337
338 case 0xFC:
339 devc->m_state = ST_INIT;
340 timer_ext_event (devc, TMR_STOP, 0);
341 break;
342
343 case 0xFE:
344
345 devc->m_state = ST_INIT;
346 break;
347
348 case 0xff:
349
350 devc->m_state = ST_INIT;
351 break;
352
353 default:
354 printk ("unknown MIDI sysmsg %0x\n", midic);
355 devc->m_state = ST_INIT;
356 }
357 break;
358
359 case ST_MTC:
360 devc->m_state = ST_INIT;
361 printk ("MTC frame %x02\n", midic);
362 break;
363
364 case ST_SYSEX:
365 if (midic == 0xf7)
366 {
367 printk ("<EOX>");
368 devc->m_state = ST_INIT;
369 }
370 else
371 printk ("%02x ", midic);
372 break;
373
374 case ST_SONGPOS:
375 BUFTEST (devc);
376 devc->m_buf[devc->m_ptr++] = midic;
377 if (devc->m_ptr == 2)
378 {
379 devc->m_state = ST_INIT;
380 devc->m_ptr = 0;
381 timer_ext_event (devc, TMR_SPP,
382 ((devc->m_buf[1] & 0x7f) << 7) |
383 (devc->m_buf[0] & 0x7f));
384 }
385 break;
386
387 case ST_DATABYTE:
388 BUFTEST (devc);
389 devc->m_buf[devc->m_ptr++] = midic;
390 if ((--devc->m_left) <= 0)
391 {
392 devc->m_state = ST_INIT;
393 do_midi_msg (devc->synthno, devc->m_buf, devc->m_ptr);
394 devc->m_ptr = 0;
395 }
396 break;
397
398 default:
399 printk ("Bad state %d ", devc->m_state);
400 devc->m_state = ST_INIT;
401 }
402
403 return 1;
404 }
405
406 static void
407 mpu401_input_loop (struct mpu_config *devc)
408 {
409 unsigned long flags;
410 int busy;
411 int n;
412
413 save_flags (flags);
414 cli ();
415 busy = devc->m_busy;
416 devc->m_busy = 1;
417 restore_flags (flags);
418
419 if (busy)
420 return;
421
422 n = 50;
423
424 while (input_avail (devc) && n-- > 0)
425 {
426 unsigned char c = read_data (devc);
427
428 if (devc->mode == MODE_SYNTH)
429 {
430 mpu_input_scanner (devc, c);
431 }
432 else if (devc->opened & OPEN_READ && devc->inputintr != NULL)
433 devc->inputintr (devc->devno, c);
434 }
435
436 devc->m_busy = 0;
437 }
438
439 void
440 mpuintr (int irq, struct pt_regs *dummy)
441 {
442 struct mpu_config *devc;
443 int dev;
444
445 sti ();
446
447
448
449
450
451
452 if (irq < 1 || irq > 15)
453 {
454 dev = -1;
455 }
456 else
457 dev = irq2dev[irq];
458
459 if (dev == -1)
460 {
461 int origirq = irq;
462
463 for (irq = 0; irq <= 16; irq++)
464 if (irq2dev[irq] != -1)
465 break;
466 if (irq > 15)
467 {
468 printk ("MPU-401: Bogus interrupt #%d?\n", origirq);
469 return;
470 }
471 dev = irq2dev[irq];
472 devc = &dev_conf[dev];
473 }
474 else
475 devc = &dev_conf[dev];
476
477 if (input_avail (devc))
478 if (devc->base != 0 && (devc->opened & OPEN_READ || devc->mode == MODE_SYNTH))
479 mpu401_input_loop (devc);
480 else
481 {
482
483 read_data (devc);
484 }
485
486 }
487
488 static int
489 mpu401_open (int dev, int mode,
490 void (*input) (int dev, unsigned char data),
491 void (*output) (int dev)
492 )
493 {
494 int err;
495 struct mpu_config *devc;
496
497 if (dev < 0 || dev >= num_midis)
498 return -ENXIO;
499
500 devc = &dev_conf[dev];
501
502 if (devc->opened)
503 {
504 printk ("MPU-401: Midi busy\n");
505 return -EBUSY;
506 }
507
508
509
510
511
512
513
514
515 if (!devc->initialized)
516 {
517 if (mpu401_status (devc) == 0xff)
518 {
519 printk ("MPU-401: Device not initialized properly\n");
520 return -EIO;
521 }
522 reset_mpu401 (devc);
523 }
524
525 irq2dev[devc->irq] = dev;
526
527 if (midi_devs[dev]->coproc)
528 if ((err = midi_devs[dev]->coproc->
529 open (midi_devs[dev]->coproc->devc, COPR_MIDI)) < 0)
530 {
531 printk ("MPU-401: Can't access coprocessor device\n");
532
533 return err;
534 }
535
536 set_uart_mode (dev, devc, 1);
537 devc->mode = MODE_MIDI;
538 devc->synthno = 0;
539
540 mpu401_input_loop (devc);
541
542 devc->inputintr = input;
543 devc->opened = mode;
544
545 return 0;
546 }
547
548 static void
549 mpu401_close (int dev)
550 {
551 struct mpu_config *devc;
552
553 devc = &dev_conf[dev];
554
555 if (devc->uart_mode)
556 reset_mpu401 (devc);
557
558
559 devc->mode = 0;
560
561 devc->inputintr = NULL;
562
563 if (midi_devs[dev]->coproc)
564 midi_devs[dev]->coproc->close (midi_devs[dev]->coproc->devc, COPR_MIDI);
565 devc->opened = 0;
566 }
567
568 static int
569 mpu401_out (int dev, unsigned char midi_byte)
570 {
571 int timeout;
572 unsigned long flags;
573
574 struct mpu_config *devc;
575
576 devc = &dev_conf[dev];
577
578
579
580
581
582
583 for (timeout = 3000; timeout > 0 && !output_ready (devc); timeout--);
584
585 save_flags (flags);
586 cli ();
587 if (!output_ready (devc))
588 {
589 printk ("MPU-401: Send data timeout\n");
590 restore_flags (flags);
591 return 0;
592 }
593
594 write_data (devc, midi_byte);
595 restore_flags (flags);
596 return 1;
597 }
598
599 static int
600 mpu401_command (int dev, mpu_command_rec * cmd)
601 {
602 int i, timeout, ok;
603 int ret = 0;
604 unsigned long flags;
605 struct mpu_config *devc;
606
607 devc = &dev_conf[dev];
608
609 if (devc->uart_mode)
610
611
612 {
613 printk ("MPU-401 commands not possible in the UART mode\n");
614 return -EINVAL;
615 }
616
617
618
619
620 if (input_avail (devc))
621 mpu401_input_loop (devc);
622
623
624
625
626
627
628 timeout = 30000;
629 retry:
630 if (timeout-- <= 0)
631 {
632 printk ("MPU-401: Command (0x%x) timeout\n", (int) cmd->cmd);
633 return -EIO;
634 }
635
636 save_flags (flags);
637 cli ();
638
639 if (!output_ready (devc))
640 {
641 restore_flags (flags);
642 goto retry;
643 }
644
645 write_command (devc, cmd->cmd);
646 ok = 0;
647 for (timeout = 50000; timeout > 0 && !ok; timeout--)
648 if (input_avail (devc))
649 if (devc->opened && devc->mode == MODE_SYNTH)
650 {
651 if (mpu_input_scanner (devc, read_data (devc)) == MPU_ACK)
652 ok = 1;
653 }
654 else
655 {
656 if (read_data (devc) == MPU_ACK)
657 ok = 1;
658 }
659
660 if (!ok)
661 {
662 restore_flags (flags);
663
664 return -EIO;
665 }
666
667 if (cmd->nr_args)
668 for (i = 0; i < cmd->nr_args; i++)
669 {
670 for (timeout = 3000; timeout > 0 && !output_ready (devc); timeout--);
671
672 if (!mpu401_out (dev, cmd->data[i]))
673 {
674 restore_flags (flags);
675 printk ("MPU: Command (0x%x), parm send failed.\n", (int) cmd->cmd);
676 return -EIO;
677 }
678 }
679
680 ret = 0;
681 cmd->data[0] = 0;
682
683 if (cmd->nr_returns)
684 for (i = 0; i < cmd->nr_returns; i++)
685 {
686 ok = 0;
687 for (timeout = 5000; timeout > 0 && !ok; timeout--)
688 if (input_avail (devc))
689 {
690 cmd->data[i] = read_data (devc);
691 ok = 1;
692 }
693
694 if (!ok)
695 {
696 restore_flags (flags);
697
698 return -EIO;
699 }
700 }
701
702 restore_flags (flags);
703
704 return ret;
705 }
706
707 static int
708 mpu_cmd (int dev, int cmd, int data)
709 {
710 int ret;
711
712 static mpu_command_rec rec;
713
714 rec.cmd = cmd & 0xff;
715 rec.nr_args = ((cmd & 0xf0) == 0xE0);
716 rec.nr_returns = ((cmd & 0xf0) == 0xA0);
717 rec.data[0] = data & 0xff;
718
719 if ((ret = mpu401_command (dev, &rec)) < 0)
720 {
721 return ret;
722 }
723 return (unsigned char) rec.data[0];
724 }
725
726 static int
727 mpu401_prefix_cmd (int dev, unsigned char status)
728 {
729 struct mpu_config *devc = &dev_conf[dev];
730
731 if (devc->uart_mode)
732 return 1;
733
734 if (status < 0xf0)
735 {
736 if (mpu_cmd (dev, 0xD0, 0) < 0)
737 {
738 return 0;
739 }
740
741 return 1;
742 }
743
744 switch (status)
745 {
746 case 0xF0:
747 if (mpu_cmd (dev, 0xDF, 0) < 0)
748 {
749 return 0;
750 }
751
752 return 1;
753 break;
754
755 default:
756 return 0;
757 }
758
759 }
760
761 static int
762 mpu401_start_read (int dev)
763 {
764 return 0;
765 }
766
767 static int
768 mpu401_end_read (int dev)
769 {
770 return 0;
771 }
772
773 static int
774 mpu401_ioctl (int dev, unsigned cmd, ioctl_arg arg)
775 {
776 struct mpu_config *devc;
777
778 devc = &dev_conf[dev];
779
780 switch (cmd)
781 {
782 case 1:
783 memcpy_fromfs ((char *) init_sequence, &(((char *) arg)[0]), sizeof (init_sequence));
784 return 0;
785 break;
786
787 case SNDCTL_MIDI_MPUMODE:
788 if (!(devc->capabilities & MPU_CAP_INTLG))
789 {
790 printk ("MPU-401: Intelligent mode not supported by the HW\n");
791 return -EINVAL;
792 }
793 set_uart_mode (dev, devc, !get_fs_long ((long *) arg));
794 return 0;
795 break;
796
797 case SNDCTL_MIDI_MPUCMD:
798 {
799 int ret;
800 mpu_command_rec rec;
801
802 memcpy_fromfs ((char *) &rec, &(((char *) arg)[0]), sizeof (rec));
803
804 if ((ret = mpu401_command (dev, &rec)) < 0)
805 return ret;
806
807 memcpy_tofs ((&((char *) arg)[0]), (char *) &rec, sizeof (rec));
808 return 0;
809 }
810 break;
811
812 default:
813 return -EINVAL;
814 }
815 }
816
817 static void
818 mpu401_kick (int dev)
819 {
820 }
821
822 static int
823 mpu401_buffer_status (int dev)
824 {
825 return 0;
826
827
828 }
829
830 static int
831 mpu_synth_ioctl (int dev,
832 unsigned int cmd, ioctl_arg arg)
833 {
834 int midi_dev;
835 struct mpu_config *devc;
836
837 midi_dev = synth_devs[dev]->midi_dev;
838
839 if (midi_dev < 0 || midi_dev > num_midis)
840 return -ENXIO;
841
842 devc = &dev_conf[midi_dev];
843
844 switch (cmd)
845 {
846
847 case SNDCTL_SYNTH_INFO:
848 memcpy_tofs ((&((char *) arg)[0]), &mpu_synth_info[midi_dev], sizeof (struct synth_info));
849
850 return 0;
851 break;
852
853 case SNDCTL_SYNTH_MEMAVL:
854 return 0x7fffffff;
855 break;
856
857 default:
858 return -EINVAL;
859 }
860 }
861
862 static int
863 mpu_synth_open (int dev, int mode)
864 {
865 int midi_dev, err;
866 struct mpu_config *devc;
867
868 midi_dev = synth_devs[dev]->midi_dev;
869
870 if (midi_dev < 0 || midi_dev > num_midis)
871 {
872 return -ENXIO;
873 }
874
875 devc = &dev_conf[midi_dev];
876
877
878
879
880
881
882
883
884 if (!devc->initialized)
885 {
886 if (mpu401_status (devc) == 0xff)
887 {
888 printk ("MPU-401: Device not initialized properly\n");
889 return -EIO;
890 }
891 reset_mpu401 (devc);
892 }
893
894 if (devc->opened)
895 {
896 printk ("MPU-401: Midi busy\n");
897 return -EBUSY;
898 }
899
900 devc->mode = MODE_SYNTH;
901 devc->synthno = dev;
902
903 devc->inputintr = NULL;
904 irq2dev[devc->irq] = midi_dev;
905
906 if (midi_devs[midi_dev]->coproc)
907 if ((err = midi_devs[midi_dev]->coproc->
908 open (midi_devs[midi_dev]->coproc->devc, COPR_MIDI)) < 0)
909 {
910 printk ("MPU-401: Can't access coprocessor device\n");
911
912 return err;
913 }
914
915 devc->opened = mode;
916 reset_mpu401 (devc);
917
918 if (mode & OPEN_READ)
919 {
920 mpu_cmd (midi_dev, 0x8B, 0);
921 mpu_cmd (midi_dev, 0x34, 0);
922 }
923
924 return 0;
925 }
926
927 static void
928 mpu_synth_close (int dev)
929 {
930 int midi_dev;
931 struct mpu_config *devc;
932
933 midi_dev = synth_devs[dev]->midi_dev;
934
935 devc = &dev_conf[midi_dev];
936 mpu_cmd (midi_dev, 0x15, 0);
937 mpu_cmd (midi_dev, 0x8a, 0);
938
939 devc->inputintr = NULL;
940
941 if (midi_devs[midi_dev]->coproc)
942 midi_devs[midi_dev]->coproc->close (midi_devs[midi_dev]->coproc->devc, COPR_MIDI);
943 devc->opened = 0;
944 devc->mode = 0;
945 }
946
947 #define MIDI_SYNTH_NAME "MPU-401 UART Midi"
948 #define MIDI_SYNTH_CAPS SYNTH_CAP_INPUT
949 #include "midi_synth.h"
950
951 static struct synth_operations mpu401_synth_proto =
952 {
953 NULL,
954 0,
955 SYNTH_TYPE_MIDI,
956 0,
957 mpu_synth_open,
958 mpu_synth_close,
959 mpu_synth_ioctl,
960 midi_synth_kill_note,
961 midi_synth_start_note,
962 midi_synth_set_instr,
963 midi_synth_reset,
964 midi_synth_hw_control,
965 midi_synth_load_patch,
966 midi_synth_aftertouch,
967 midi_synth_controller,
968 midi_synth_panning,
969 NULL,
970 midi_synth_patchmgr,
971 midi_synth_bender,
972 NULL,
973 midi_synth_setup_voice,
974 midi_synth_send_sysex
975 };
976
977 static struct synth_operations *mpu401_synth_operations[MAX_MIDI_DEV];
978
979 static struct midi_operations mpu401_midi_proto =
980 {
981 {"MPU-401 Midi", 0, MIDI_CAP_MPU401, SNDCARD_MPU401},
982 NULL,
983 {0},
984 mpu401_open,
985 mpu401_close,
986 mpu401_ioctl,
987 mpu401_out,
988 mpu401_start_read,
989 mpu401_end_read,
990 mpu401_kick,
991 NULL,
992 mpu401_buffer_status,
993 mpu401_prefix_cmd
994 };
995
996 static struct midi_operations mpu401_midi_operations[MAX_MIDI_DEV];
997
998 static void
999 mpu401_chk_version (struct mpu_config *devc)
1000 {
1001 int tmp;
1002
1003 devc->version = devc->revision = 0;
1004
1005 if ((tmp = mpu_cmd (num_midis, 0xAC, 0)) < 0)
1006 return;
1007
1008 if ((tmp & 0xf0) > 0x20)
1009 return;
1010
1011 devc->version = tmp;
1012
1013 if ((tmp = mpu_cmd (num_midis, 0xAD, 0)) < 0)
1014 {
1015 devc->version = 0;
1016 return;
1017 }
1018 devc->revision = tmp;
1019 }
1020
1021 long
1022 attach_mpu401 (long mem_start, struct address_info *hw_config)
1023 {
1024 unsigned long flags;
1025 char revision_char;
1026
1027 struct mpu_config *devc;
1028
1029 if (num_midis >= MAX_MIDI_DEV)
1030 {
1031 printk ("MPU-401: Too many midi devices detected\n");
1032 return mem_start;
1033 }
1034
1035 devc = &dev_conf[num_midis];
1036
1037 devc->base = hw_config->io_base;
1038 devc->osp = hw_config->osp;
1039 devc->irq = hw_config->irq;
1040 devc->opened = 0;
1041 devc->uart_mode = 0;
1042 devc->initialized = 0;
1043 devc->version = 0;
1044 devc->revision = 0;
1045 devc->capabilities = 0;
1046 devc->timer_flag = 0;
1047 devc->m_busy = 0;
1048 devc->m_state = ST_INIT;
1049 devc->shared_irq = hw_config->always_detect;
1050 devc->irq = hw_config->irq;
1051
1052 if (devc->irq < 0)
1053 {
1054 devc->irq *= -1;
1055 devc->shared_irq = 1;
1056 }
1057 irq2dev[devc->irq] = num_midis;
1058
1059 if (!hw_config->always_detect)
1060 {
1061
1062 if (!reset_mpu401 (devc))
1063 return mem_start;
1064
1065 if (!devc->shared_irq)
1066 if (snd_set_irq_handler (devc->irq, mpuintr, "mpu401", devc->osp) < 0)
1067 {
1068 return mem_start;
1069 }
1070
1071 save_flags (flags);
1072 cli ();
1073 mpu401_chk_version (devc);
1074 if (devc->version == 0)
1075 mpu401_chk_version (devc);
1076 restore_flags (flags);
1077 }
1078
1079 request_region (hw_config->io_base, 2, "mpu401");
1080
1081 if (devc->version != 0)
1082 if (mpu_cmd (num_midis, 0xC5, 0) >= 0)
1083 if (mpu_cmd (num_midis, 0xE0, 120) >= 0)
1084 devc->capabilities |= MPU_CAP_INTLG;
1085
1086
1087 mpu401_synth_operations[num_midis] = (struct synth_operations *) (sound_mem_blocks[sound_num_blocks] = kmalloc (sizeof (struct synth_operations), GFP_KERNEL));
1088
1089 if (sound_num_blocks < 1024)
1090 sound_num_blocks++;;
1091
1092 if (mpu401_synth_operations[num_midis] == NULL)
1093 {
1094 printk ("mpu401: Can't allocate memory\n");
1095 return mem_start;
1096 }
1097
1098 if (!(devc->capabilities & MPU_CAP_INTLG))
1099 {
1100 memcpy ((char *) mpu401_synth_operations[num_midis],
1101 (char *) &std_midi_synth,
1102 sizeof (struct synth_operations));
1103 }
1104 else
1105 {
1106 memcpy ((char *) mpu401_synth_operations[num_midis],
1107 (char *) &mpu401_synth_proto,
1108 sizeof (struct synth_operations));
1109 }
1110
1111 memcpy ((char *) &mpu401_midi_operations[num_midis],
1112 (char *) &mpu401_midi_proto,
1113 sizeof (struct midi_operations));
1114
1115 mpu401_midi_operations[num_midis].converter =
1116 mpu401_synth_operations[num_midis];
1117
1118 memcpy ((char *) &mpu_synth_info[num_midis],
1119 (char *) &mpu_synth_info_proto,
1120 sizeof (struct synth_info));
1121
1122 n_mpu_devs++;
1123
1124 if (devc->version == 0x20 && devc->revision >= 0x07)
1125 {
1126 int ports = (devc->revision & 0x08) ? 32 : 16;
1127
1128 devc->capabilities |= MPU_CAP_SYNC | MPU_CAP_SMPTE |
1129 MPU_CAP_CLS | MPU_CAP_2PORT;
1130
1131 revision_char = (devc->revision == 0x7f) ? 'M' : ' ';
1132 printk (" <MQX-%d%c MIDI Interface>",
1133 ports,
1134 revision_char);
1135 sprintf (mpu_synth_info[num_midis].name,
1136 "MQX-%d%c MIDI Interface #%d",
1137 ports,
1138 revision_char,
1139 n_mpu_devs);
1140 }
1141 else
1142 {
1143
1144 revision_char = devc->revision ? devc->revision + '@' : ' ';
1145 if ((int) devc->revision > ('Z' - '@'))
1146 revision_char = '+';
1147
1148 devc->capabilities |= MPU_CAP_SYNC | MPU_CAP_FSK;
1149
1150 printk (" <MPU-401 MIDI Interface %d.%d%c>",
1151 (int) (devc->version & 0xf0) >> 4,
1152 devc->version & 0x0f,
1153 revision_char);
1154 sprintf (mpu_synth_info[num_midis].name,
1155 "MPU-401 %d.%d%c Midi interface #%d",
1156 (int) (devc->version & 0xf0) >> 4,
1157 devc->version & 0x0f,
1158 revision_char,
1159 n_mpu_devs);
1160 }
1161
1162 strcpy (mpu401_midi_operations[num_midis].info.name,
1163 mpu_synth_info[num_midis].name);
1164
1165 mpu401_synth_operations[num_midis]->midi_dev = devc->devno = num_midis;
1166 mpu401_synth_operations[devc->devno]->info =
1167 &mpu_synth_info[devc->devno];
1168
1169 if (devc->capabilities & MPU_CAP_INTLG)
1170 mpu_timer_init (num_midis);
1171
1172 irq2dev[devc->irq] = num_midis;
1173 midi_devs[num_midis++] = &mpu401_midi_operations[devc->devno];
1174 return mem_start;
1175 }
1176
1177 static int
1178 reset_mpu401 (struct mpu_config *devc)
1179 {
1180 unsigned long flags;
1181 int ok, timeout, n;
1182 int timeout_limit;
1183
1184
1185
1186
1187
1188
1189 ok = 0;
1190
1191 timeout_limit = devc->initialized ? 30000 : 100000;
1192 devc->initialized = 1;
1193
1194 for (n = 0; n < 2 && !ok; n++)
1195 {
1196 for (timeout = timeout_limit; timeout > 0 && !ok; timeout--)
1197 ok = output_ready (devc);
1198
1199 write_command (devc, MPU_RESET);
1200
1201
1202
1203
1204
1205
1206
1207
1208 for (timeout = timeout_limit * 2; timeout > 0 && !ok; timeout--)
1209 {
1210 save_flags (flags);
1211 cli ();
1212 if (input_avail (devc))
1213 if (read_data (devc) == MPU_ACK)
1214 ok = 1;
1215 restore_flags (flags);
1216 }
1217
1218 }
1219
1220 devc->m_state = ST_INIT;
1221 devc->m_ptr = 0;
1222 devc->m_left = 0;
1223 devc->last_status = 0;
1224 devc->uart_mode = 0;
1225
1226 return ok;
1227 }
1228
1229 static void
1230 set_uart_mode (int dev, struct mpu_config *devc, int arg)
1231 {
1232 if (!arg && (devc->capabilities & MPU_CAP_INTLG))
1233 {
1234 return;
1235 }
1236
1237 if ((devc->uart_mode == 0) == (arg == 0))
1238 {
1239 return;
1240 }
1241
1242 reset_mpu401 (devc);
1243
1244 if (arg)
1245 {
1246 if (mpu_cmd (dev, UART_MODE_ON, 0) < 0)
1247 {
1248 printk ("MPU%d: Can't enter UART mode\n", devc->devno);
1249 devc->uart_mode = 0;
1250 return;
1251 }
1252 }
1253 devc->uart_mode = arg;
1254
1255 }
1256
1257 int
1258 probe_mpu401 (struct address_info *hw_config)
1259 {
1260 int ok = 0;
1261 struct mpu_config tmp_devc;
1262
1263 if (check_region (hw_config->io_base, 2))
1264 {
1265 printk ("\n\nmpu401.c: I/O port %x already in use\n\n",
1266 hw_config->io_base);
1267 return 0;
1268 }
1269
1270 tmp_devc.base = hw_config->io_base;
1271 tmp_devc.irq = hw_config->irq;
1272 tmp_devc.initialized = 0;
1273 tmp_devc.opened = 0;
1274 tmp_devc.osp = hw_config->osp;
1275
1276 #if !defined(EXCLUDE_AEDSP16) && defined(AEDSP16_MPU401)
1277
1278
1279
1280 InitAEDSP16_MPU401 (hw_config);
1281 #endif
1282
1283 if (hw_config->always_detect)
1284 return 1;
1285
1286 if (inb (hw_config->io_base + 1) == 0xff)
1287 {
1288 DDB (printk ("MPU401: Port %x looks dead.\n", hw_config->io_base));
1289 return 0;
1290 }
1291
1292 ok = reset_mpu401 (&tmp_devc);
1293
1294 if (!ok)
1295 {
1296 DDB (printk ("MPU401: Reset failed on port %x\n", hw_config->io_base));
1297 }
1298
1299 return ok;
1300 }
1301
1302 void
1303 unload_mpu401 (struct address_info *hw_config)
1304 {
1305 release_region (hw_config->io_base, 2);
1306 if (hw_config->always_detect == 0 && hw_config->irq > 0)
1307 snd_release_irq (hw_config->irq);
1308 }
1309
1310
1311
1312
1313
1314 #if !defined(EXCLUDE_SEQUENCER)
1315
1316 static volatile int timer_initialized = 0, timer_open = 0, tmr_running = 0;
1317 static volatile int curr_tempo, curr_timebase, hw_timebase;
1318 static int max_timebase = 8;
1319 static volatile unsigned long next_event_time;
1320 static volatile unsigned long curr_ticks, curr_clocks;
1321 static unsigned long prev_event_time;
1322 static int metronome_mode;
1323
1324 static unsigned long
1325 clocks2ticks (unsigned long clocks)
1326 {
1327
1328
1329
1330
1331
1332
1333
1334 return ((clocks * curr_timebase) + (hw_timebase / 2)) / hw_timebase;
1335 }
1336
1337 static void
1338 set_timebase (int midi_dev, int val)
1339 {
1340 int hw_val;
1341
1342 if (val < 48)
1343 val = 48;
1344 if (val > 1000)
1345 val = 1000;
1346
1347 hw_val = val;
1348 hw_val = (hw_val + 12) / 24;
1349 if (hw_val > max_timebase)
1350 hw_val = max_timebase;
1351
1352 if (mpu_cmd (midi_dev, 0xC0 | (hw_val & 0x0f), 0) < 0)
1353 {
1354 printk ("MPU: Can't set HW timebase to %d\n", hw_val * 24);
1355 return;
1356 }
1357 hw_timebase = hw_val * 24;
1358 curr_timebase = val;
1359
1360 }
1361
1362 static void
1363 tmr_reset (void)
1364 {
1365 unsigned long flags;
1366
1367 save_flags (flags);
1368 cli ();
1369 next_event_time = 0xffffffff;
1370 prev_event_time = 0;
1371 curr_ticks = curr_clocks = 0;
1372 restore_flags (flags);
1373 }
1374
1375 static void
1376 set_timer_mode (int midi_dev)
1377 {
1378 if (timer_mode & TMR_MODE_CLS)
1379 mpu_cmd (midi_dev, 0x3c, 0);
1380 else if (timer_mode & TMR_MODE_SMPTE)
1381 mpu_cmd (midi_dev, 0x3d, 0);
1382
1383 if (timer_mode & TMR_INTERNAL)
1384 {
1385 mpu_cmd (midi_dev, 0x80, 0);
1386 }
1387 else
1388 {
1389 if (timer_mode & (TMR_MODE_MIDI | TMR_MODE_CLS))
1390 {
1391 mpu_cmd (midi_dev, 0x82, 0);
1392 mpu_cmd (midi_dev, 0x91, 0);
1393 }
1394 else if (timer_mode & TMR_MODE_FSK)
1395 mpu_cmd (midi_dev, 0x81, 0);
1396 }
1397 }
1398
1399 static void
1400 stop_metronome (int midi_dev)
1401 {
1402 mpu_cmd (midi_dev, 0x84, 0);
1403 }
1404
1405 static void
1406 setup_metronome (int midi_dev)
1407 {
1408 int numerator, denominator;
1409 int clks_per_click, num_32nds_per_beat;
1410 int beats_per_measure;
1411
1412 numerator = ((unsigned) metronome_mode >> 24) & 0xff;
1413 denominator = ((unsigned) metronome_mode >> 16) & 0xff;
1414 clks_per_click = ((unsigned) metronome_mode >> 8) & 0xff;
1415 num_32nds_per_beat = (unsigned) metronome_mode & 0xff;
1416 beats_per_measure = (numerator * 4) >> denominator;
1417
1418 if (!metronome_mode)
1419 mpu_cmd (midi_dev, 0x84, 0);
1420 else
1421 {
1422 mpu_cmd (midi_dev, 0xE4, clks_per_click);
1423 mpu_cmd (midi_dev, 0xE6, beats_per_measure);
1424 mpu_cmd (midi_dev, 0x83, 0);
1425 }
1426 }
1427
1428 static int
1429 mpu_start_timer (int midi_dev)
1430 {
1431 tmr_reset ();
1432 set_timer_mode (midi_dev);
1433
1434 if (tmr_running)
1435 return TIMER_NOT_ARMED;
1436
1437 if (timer_mode & TMR_INTERNAL)
1438 {
1439 mpu_cmd (midi_dev, 0x02, 0);
1440 tmr_running = 1;
1441 return TIMER_NOT_ARMED;
1442 }
1443 else
1444 {
1445 mpu_cmd (midi_dev, 0x35, 0);
1446 mpu_cmd (midi_dev, 0x38, 0);
1447 mpu_cmd (midi_dev, 0x39, 0);
1448 mpu_cmd (midi_dev, 0x97, 0);
1449 }
1450
1451 return TIMER_ARMED;
1452 }
1453
1454 static int
1455 mpu_timer_open (int dev, int mode)
1456 {
1457 int midi_dev = sound_timer_devs[dev]->devlink;
1458
1459 if (timer_open)
1460 return -EBUSY;
1461
1462 tmr_reset ();
1463 curr_tempo = 50;
1464 mpu_cmd (midi_dev, 0xE0, 50);
1465 curr_timebase = hw_timebase = 120;
1466 set_timebase (midi_dev, 120);
1467 timer_open = 1;
1468 metronome_mode = 0;
1469 set_timer_mode (midi_dev);
1470
1471 mpu_cmd (midi_dev, 0xe7, 0x04);
1472 mpu_cmd (midi_dev, 0x95, 0);
1473
1474 return 0;
1475 }
1476
1477 static void
1478 mpu_timer_close (int dev)
1479 {
1480 int midi_dev = sound_timer_devs[dev]->devlink;
1481
1482 timer_open = tmr_running = 0;
1483 mpu_cmd (midi_dev, 0x15, 0);
1484 mpu_cmd (midi_dev, 0x94, 0);
1485 mpu_cmd (midi_dev, 0x8c, 0);
1486 stop_metronome (midi_dev);
1487 }
1488
1489 static int
1490 mpu_timer_event (int dev, unsigned char *event)
1491 {
1492 unsigned char command = event[1];
1493 unsigned long parm = *(unsigned int *) &event[4];
1494 int midi_dev = sound_timer_devs[dev]->devlink;
1495
1496 switch (command)
1497 {
1498 case TMR_WAIT_REL:
1499 parm += prev_event_time;
1500 case TMR_WAIT_ABS:
1501 if (parm > 0)
1502 {
1503 long time;
1504
1505 if (parm <= curr_ticks)
1506 return TIMER_NOT_ARMED;
1507
1508 time = parm;
1509 next_event_time = prev_event_time = time;
1510
1511 return TIMER_ARMED;
1512 }
1513 break;
1514
1515 case TMR_START:
1516 if (tmr_running)
1517 break;
1518 return mpu_start_timer (midi_dev);
1519 break;
1520
1521 case TMR_STOP:
1522 mpu_cmd (midi_dev, 0x01, 0);
1523 stop_metronome (midi_dev);
1524 tmr_running = 0;
1525 break;
1526
1527 case TMR_CONTINUE:
1528 if (tmr_running)
1529 break;
1530 mpu_cmd (midi_dev, 0x03, 0);
1531 setup_metronome (midi_dev);
1532 tmr_running = 1;
1533 break;
1534
1535 case TMR_TEMPO:
1536 if (parm)
1537 {
1538 if (parm < 8)
1539 parm = 8;
1540 if (parm > 250)
1541 parm = 250;
1542
1543 if (mpu_cmd (midi_dev, 0xE0, parm) < 0)
1544 printk ("MPU: Can't set tempo to %d\n", (int) parm);
1545 curr_tempo = parm;
1546 }
1547 break;
1548
1549 case TMR_ECHO:
1550 seq_copy_to_input (event, 8);
1551 break;
1552
1553 case TMR_TIMESIG:
1554 if (metronome_mode)
1555 {
1556 metronome_mode = parm;
1557 setup_metronome (midi_dev);
1558 }
1559 break;
1560
1561 default:;
1562 }
1563
1564 return TIMER_NOT_ARMED;
1565 }
1566
1567 static unsigned long
1568 mpu_timer_get_time (int dev)
1569 {
1570 if (!timer_open)
1571 return 0;
1572
1573 return curr_ticks;
1574 }
1575
1576 static int
1577 mpu_timer_ioctl (int dev,
1578 unsigned int command, ioctl_arg arg)
1579 {
1580 int midi_dev = sound_timer_devs[dev]->devlink;
1581
1582 switch (command)
1583 {
1584 case SNDCTL_TMR_SOURCE:
1585 {
1586 int parm = (int) get_fs_long ((long *) arg) & timer_caps;
1587
1588 if (parm != 0)
1589 {
1590 timer_mode = parm;
1591
1592 if (timer_mode & TMR_MODE_CLS)
1593 mpu_cmd (midi_dev, 0x3c, 0);
1594 else if (timer_mode & TMR_MODE_SMPTE)
1595 mpu_cmd (midi_dev, 0x3d, 0);
1596 }
1597
1598 return snd_ioctl_return ((int *) arg, timer_mode);
1599 }
1600 break;
1601
1602 case SNDCTL_TMR_START:
1603 mpu_start_timer (midi_dev);
1604 return 0;
1605 break;
1606
1607 case SNDCTL_TMR_STOP:
1608 tmr_running = 0;
1609 mpu_cmd (midi_dev, 0x01, 0);
1610 stop_metronome (midi_dev);
1611 return 0;
1612 break;
1613
1614 case SNDCTL_TMR_CONTINUE:
1615 if (tmr_running)
1616 return 0;
1617 tmr_running = 1;
1618 mpu_cmd (midi_dev, 0x03, 0);
1619 return 0;
1620 break;
1621
1622 case SNDCTL_TMR_TIMEBASE:
1623 {
1624 int val = (int) get_fs_long ((long *) arg);
1625
1626 if (val)
1627 set_timebase (midi_dev, val);
1628
1629 return snd_ioctl_return ((int *) arg, curr_timebase);
1630 }
1631 break;
1632
1633 case SNDCTL_TMR_TEMPO:
1634 {
1635 int val = (int) get_fs_long ((long *) arg);
1636 int ret;
1637
1638 if (val)
1639 {
1640 if (val < 8)
1641 val = 8;
1642 if (val > 250)
1643 val = 250;
1644 if ((ret = mpu_cmd (midi_dev, 0xE0, val)) < 0)
1645 {
1646 printk ("MPU: Can't set tempo to %d\n", (int) val);
1647 return ret;
1648 }
1649
1650 curr_tempo = val;
1651 }
1652
1653 return snd_ioctl_return ((int *) arg, curr_tempo);
1654 }
1655 break;
1656
1657 case SNDCTL_SEQ_CTRLRATE:
1658 if (get_fs_long ((long *) arg) != 0)
1659 return -EINVAL;
1660
1661 return snd_ioctl_return ((int *) arg, ((curr_tempo * curr_timebase) + 30) / 60);
1662 break;
1663
1664 case SNDCTL_TMR_METRONOME:
1665 metronome_mode = (int) get_fs_long ((long *) arg);
1666 setup_metronome (midi_dev);
1667 return 0;
1668 break;
1669
1670 default:;
1671 }
1672
1673 return -EINVAL;
1674 }
1675
1676 static void
1677 mpu_timer_arm (int dev, long time)
1678 {
1679 if (time < 0)
1680 time = curr_ticks + 1;
1681 else if (time <= curr_ticks)
1682 return;
1683
1684 next_event_time = prev_event_time = time;
1685
1686 return;
1687 }
1688
1689 static struct sound_timer_operations mpu_timer =
1690 {
1691 {"MPU-401 Timer", 0},
1692 10,
1693 0,
1694 mpu_timer_open,
1695 mpu_timer_close,
1696 mpu_timer_event,
1697 mpu_timer_get_time,
1698 mpu_timer_ioctl,
1699 mpu_timer_arm
1700 };
1701
1702 static void
1703 mpu_timer_interrupt (void)
1704 {
1705
1706 if (!timer_open)
1707 return;
1708
1709 if (!tmr_running)
1710 return;
1711
1712 curr_clocks++;
1713 curr_ticks = clocks2ticks (curr_clocks);
1714
1715 if (curr_ticks >= next_event_time)
1716 {
1717 next_event_time = 0xffffffff;
1718 sequencer_timer (0);
1719 }
1720 }
1721
1722 static void
1723 timer_ext_event (struct mpu_config *devc, int event, int parm)
1724 {
1725 int midi_dev = devc->devno;
1726
1727 if (!devc->timer_flag)
1728 return;
1729
1730 switch (event)
1731 {
1732 case TMR_CLOCK:
1733 printk ("<MIDI clk>");
1734 break;
1735
1736 case TMR_START:
1737 printk ("Ext MIDI start\n");
1738 if (!tmr_running)
1739 if (timer_mode & TMR_EXTERNAL)
1740 {
1741 tmr_running = 1;
1742 setup_metronome (midi_dev);
1743 next_event_time = 0;
1744 STORE (SEQ_START_TIMER ());
1745 }
1746 break;
1747
1748 case TMR_STOP:
1749 printk ("Ext MIDI stop\n");
1750 if (timer_mode & TMR_EXTERNAL)
1751 {
1752 tmr_running = 0;
1753 stop_metronome (midi_dev);
1754 STORE (SEQ_STOP_TIMER ());
1755 }
1756 break;
1757
1758 case TMR_CONTINUE:
1759 printk ("Ext MIDI continue\n");
1760 if (timer_mode & TMR_EXTERNAL)
1761 {
1762 tmr_running = 1;
1763 setup_metronome (midi_dev);
1764 STORE (SEQ_CONTINUE_TIMER ());
1765 }
1766 break;
1767
1768 case TMR_SPP:
1769 printk ("Songpos: %d\n", parm);
1770 if (timer_mode & TMR_EXTERNAL)
1771 {
1772 STORE (SEQ_SONGPOS (parm));
1773 }
1774 break;
1775 }
1776 }
1777
1778 static void
1779 mpu_timer_init (int midi_dev)
1780 {
1781 struct mpu_config *devc;
1782 int n;
1783
1784 devc = &dev_conf[midi_dev];
1785
1786 if (timer_initialized)
1787 return;
1788
1789 timer_initialized = 1;
1790
1791 mpu_timer.devlink = midi_dev;
1792 dev_conf[midi_dev].timer_flag = 1;
1793
1794 if (num_sound_timers >= MAX_TIMER_DEV)
1795 n = 0;
1796 else
1797 n = num_sound_timers++;
1798 sound_timer_devs[n] = &mpu_timer;
1799
1800 if (devc->version < 0x20)
1801 timer_caps = TMR_INTERNAL | TMR_EXTERNAL | TMR_MODE_FSK | TMR_MODE_MIDI;
1802 else
1803 {
1804
1805
1806
1807
1808
1809
1810
1811
1812 if (devc->revision)
1813 timer_caps |= TMR_EXTERNAL | TMR_MODE_MIDI;
1814
1815 if (devc->revision & 0x02)
1816 timer_caps |= TMR_MODE_CLS;
1817
1818
1819 if (devc->revision & 0x40)
1820 max_timebase = 10;
1821 }
1822
1823 timer_mode = (TMR_INTERNAL | TMR_MODE_MIDI) & timer_caps;
1824
1825 }
1826
1827 #endif
1828
1829
1830
1831 #endif
1832
1833 #endif