From owner-FreeBSD-users-jp@jp.freebsd.org  Wed Dec 23 16:15:26 1998
Received: (from daemon@localhost)
	by jaz.jp.freebsd.org (8.9.1+3.1W/8.7.3) id QAA05114;
	Wed, 23 Dec 1998 16:15:26 +0900 (JST)
	(envelope-from owner-FreeBSD-users-jp@jp.FreeBSD.org)
Received: from ma2.seikyou.ne.jp (ma2.seikyou.ne.jp [202.211.152.197])
	by jaz.jp.freebsd.org (8.9.1+3.1W/8.7.3) with ESMTP id QAA05108
	for <FreeBSD-users-jp@jp.freebsd.org>; Wed, 23 Dec 1998 16:15:24 +0900 (JST)
	(envelope-from ysonoda@dontaku.csce.kyushu-u.ac.jp)
Received: from hornet.navy.or.jp (us-024.seikyou.ne.jp [202.33.58.24])
	by ma2.seikyou.ne.jp (8.8.8/3.6WNSK98032401) with ESMTP id QAA00896
	for <FreeBSD-users-jp@jp.freebsd.org>; Wed, 23 Dec 1998 16:15:23 +0900
Received: from localhost (localhost [127.0.0.1])
	by hornet.navy.or.jp (8.8.8/3.6W) with ESMTP id QAA00486
	for <FreeBSD-users-jp@jp.freebsd.org>; Wed, 23 Dec 1998 16:14:52 +0900 (JST)
To: FreeBSD-users-jp@jp.freebsd.org
From: SONODA Yoshihide (=?iso-2022-jp?B?GyRCMWBFRBsoQiAbJEI1SDFRGyhC?=) <ysonoda@dontaku.csce.kyushu-u.ac.jp>
In-Reply-To: Your message of "Tue, 22 Dec 1998 13:28:52 +0900"
	<367F2004.B210F474@post.cc.sasebo.ac.jp>
References: <367F2004.B210F474@post.cc.sasebo.ac.jp>
X-Mailer: Mew version 1.93 on XEmacs 20.4 (Emerald)
Mime-Version: 1.0
Content-Type: Multipart/Mixed;
	boundary="--Next_Part(Wed_Dec_23_16:13:46_1998_518)--"
Content-Transfer-Encoding: 7bit
Message-Id: <19981223161451P.ysonoda@dontaku.csce.kyushu-u.ac.jp>
Date: Wed, 23 Dec 1998 16:14:51 +0900
X-Dispatcher: imput version 980905(IM100)
Lines: 167
Reply-To: FreeBSD-users-jp@jp.freebsd.org
Precedence: list
X-Distribute: distribute version 2.1 (Alpha) patchlevel 24e+981115
X-Sequence: FreeBSD-users-jp 36727
Subject: [FreeBSD-users-jp 36727] Re: SUPER-MPU
Errors-To: owner-FreeBSD-users-jp@jp.freebsd.org
Sender: owner-FreeBSD-users-jp@jp.freebsd.org
X-Originator: ysonoda@dontaku.csce.kyushu-u.ac.jp

----Next_Part(Wed_Dec_23_16:13:46_1998_518)--
Content-Type: Text/Plain; charset=iso-2022-jp
Content-Transfer-Encoding: 7bit

$B1`ED!w6eBg$G$9!#(B

 [Shin Yokoyama <ae9712@post.cc.sasebo.ac.jp>] $B$5$s$,(B 
 [Tue, 22 Dec 1998 13:28:52 +0900] $B:"$K=q$+$l$?(B 
 $B!V(B[FreeBSD-users-jp 36695] SUPER-MPU$B!W$K$D$$$F(B 

ae9712> $B$5$C$=$/<ALd!"$H$$$&$+$*?R$M$G$9$,!"$I$J$?$+!V(BSuper-MPU-AT$B!W$r(B
ae9712> $B;H$C$F#M#I#D#I$r1iAU$G$-$k4D6-$r9=C[$7$F$*$i$l$kJ}$O$*$i$l$k$N(B
ae9712> $B$G$7$g$&$+!#(B

Super MPU II/AT $B$r(B MPU-401$B8_49%b!<%I$G;H$($F$$$^$9!#(B

ae9712> $B%+!<%M%k$G$O!"0l1~0J2<$N$h$&$K8+$D$1$F$$$k$h$&$G$9!#(B
ae9712> mpu0: <MPU-401 MIDI Interface 0.0>

$B3N$+$K$3$N$h$&$K$J$j$^$9!#(B

ae9712> Ports$B$N(Bplaymidi$B$r;H$C$F!"(Bmidi$B%U%!%$%k$r1iAU$5$;$F$_$^$7$?!#(B
ae9712> SB16$B$r0l=o$KF~$l$F$$$k$N$G!"$=$A$i$N2;8;$r;H$&!J(B-f$B%*%W%7%g%s!K(B
ae9712> $B$H!"1iAU$9$k$3$H$,$G$-$^$7$?!#(B
ae9712> $B$7$+$7!"(BMPU$B!J(B-e$B%*%W%7%g%s!K$G1iAU$7$h$&$H$9$k$H!"(B
ae9712> $B6/@)%7%c%C%H%@%&%s$5$l$F$7$^$$$^$9!#(B

$B$=$N$^$^$G$O$&$^$/F0$$$F$/$l$J$+$C$?$N$G!"%=!<%9(B
(/sys/i386/isa/sound/mpu401.c)$B$K>/$7<j$rF~$l$?3P$($,$"$j$^$9!#(B
$B$^$?;d$N$O(B S-MPU II $B$G(B PnP $B$N%\!<%I$G$7$?$N$G!"(B
kernel $B$G(B pnp $B$rM-8z$K$7$J$$$H:F@8$7$h$&$H$7$?$H$?$s$K(B
$B%j%V!<%H$7$F$7$^$&$H$$$&8=>]$,5/$3$j$^$7$?!#(B

ae9712> $B$H$$$&$o$1$G!"(BSuper-MPU-AT$B$G(BMIDI$B4D6-$r9=C[$7$F$*$i$l$kJ}$,(B
ae9712> $B$*$i$l$^$7$?$i!"$<$R$*65$($/$@$5$$!#(B

$B;29M$N$?$a$K(B mpu401.c $B$X$N%Q%C%A$r$D$1$F$*$-$^$9!#(BFreeBSD 2.2.x $BMQ$G$9!#(B
$BFbMF$NJ]>Z$O=PMh$J$$$N$G!"<+8J@UG$$K$*$$$F;H$C$F$/$@$5$$!#(B

$B$A$J$_$KJQ99E@$NBgItJ,$O(B
http://www.geocities.com/Tokyo/Pagoda/2842/unixmidi.html
$B$r;29M$K$7$F$$$^$9!#!J$H$$$&$+$=$N$^$s$^!K(B(^^;

---
$B6e=#Bg3XBg3X1!(B $B%7%9%F%`>pJs2J3X8&5f2J(B $B>pJs9)3X@l96(B $B=$;N(B1$BG/(B 
           $B1`ED(B $B5H1Q(B (Sonoda, Yoshihide)
     E-mail: ysonoda@dontaku.csce.kyushu-u.ac.jp
   URL: http://dontaku.csce.kyushu-u.ac.jp/~ysonoda/


----Next_Part(Wed_Dec_23_16:13:46_1998_518)--
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename=mpu401.c.diff

--- /sys/i386/isa/sound/mpu401.c.orig	Tue Sep 10 17:25:31 1996
+++ /sys/i386/isa/sound/mpu401.c	Wed Nov  4 14:25:30 1998
@@ -96,7 +96,7 @@
 
 #define	OUTPUT_READY	0x40
 #define	INPUT_AVAIL	0x80
-#define	MPU_ACK		0xF7
+#define	MPU_ACK		0xFE /* 0xF7 */
 #define	MPU_RESET	0xFF
 #define	UART_MODE_ON	0x3F
 
@@ -436,18 +436,29 @@
 
   if (irq < 1 || irq > 15)
     {
-      printk ("MPU-401: Interrupt #%d?\n", irq);
-      return;
+      /* printk ("MPU-401: Interrupt #%d?\n", irq); */
+      /* return; */
+      dev = -1;
     }
+  else
+    dev = irq2dev[irq];
 
-  dev = irq2dev[irq];
   if (dev == -1)
     {
-      /* printk ("MPU-401: Interrupt #%d?\n", irq); */
-      return;
+      int origirq = irq;
+      for (irq = 0; irq <= 16; irq++)
+	if (irq2dev[irq] != -1)
+	  break;
+      if (irq > 15)
+	{
+	  printk ("MPU-401: Interrupt #%d?\n", origirq);
+	  return;
+	}
+      dev = irq2dev[irq];
+      devc = &dev_conf[dev];
     }
-
-  devc = &dev_conf[dev];
+  else
+    devc = &dev_conf[dev];
 
   if (input_avail (devc->base))
     if (devc->base != 0 && (devc->opened & OPEN_READ || devc->mode == MODE_SYNTH))
@@ -574,7 +585,7 @@
    * (After reset). Normally it takes just about 10 loops.
    */
 
-  for (timeout = 3000; timeout > 0 && !output_ready (devc->base); timeout--);
+  for (timeout = 80000; timeout > 0 && !output_ready (devc->base); timeout--);
 
   DISABLE_INTR (flags);
   if (!output_ready (devc->base))
@@ -618,7 +629,7 @@
    * (After reset). Normally it takes just about 10 loops.
    */
 
-  timeout = 30000;
+  timeout = 80000;
 retry:
   if (timeout-- <= 0)
     {
@@ -908,6 +919,7 @@
     {
       exec_cmd (midi_dev, 0x8B, 0);	/* Enable data in stop mode */
       exec_cmd (midi_dev, 0x34, 0);	/* Return timing bytes in stop mode */
+      exec_cmd (midi_dev, 0x87, 0);
     }
 
   return 0;
@@ -1152,15 +1164,15 @@
 
   ok = 0;
 
-  timeout_limit = devc->initialized ? 30000 : 100000;
+  timeout_limit = devc->initialized ? 50000 : 100000;
   devc->initialized = 1;
 
   for (n = 0; n < 2 && !ok; n++)
     {
-      for (timeout = timeout_limit; timeout > 0 && !ok; timeout--)
-	ok = output_ready (devc->base);
+      for (timeout = timeout_limit; timeout > 0 && !output_ready (devc->base); timeout--);
 
-      write_command (devc->base, MPU_RESET);	/*
+      if (output_ready (devc->base))
+	write_command (devc->base, MPU_RESET);	/*
 						 * Send MPU-401 RESET Command
 						 */
 
@@ -1209,9 +1221,12 @@
     {
       if (exec_cmd (dev, UART_MODE_ON, 0) < 0)
 	{
-	  printk ("MPU%d: Can't enter UART mode\n", devc->devno);
-	  devc->uart_mode = 0;
-	  return;
+	  if (exec_cmd (dev, UART_MODE_ON, 0) < 0)
+	    {
+	      printk ("MPU%d: Can't enter UART mode\n", devc->devno);
+	      devc->uart_mode = 0;
+	      return;
+	    }
 	}
     }
   devc->uart_mode = arg;

----Next_Part(Wed_Dec_23_16:13:46_1998_518)----
