MIDI input patch

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

a year ago (crazy, it's actually to the day a year ago) I sent a patch to the list that Stas Sergeev sent me which fixed a MIDI input problem.  Today I've been installing Dosemu on another machine and found the patch hasn't been applied to the repository.  After applying it manually, everything works fine.  Any reason why it didn't make it into the SVN repository?  Would be great if someone could do it!

Thomas W.



Here is the patch:


Index: src/dosext/sound/sound.c
===================================================================
--- src/dosext/sound/sound.c	(revision 1864)
+++ src/dosext/sound/sound.c	(working copy)
@@ -660,6 +660,8 @@
     S_printf("MPU401: Read data port = 0x%02x, %i bytes still in queue\n",
       r,Q_HOLDS(mpu401_info.data));
     sb_deactivate_irq(SB_IRQ_MIDI);
+    if (Q_HOLDS(mpu401_info.data))
+      sb_activate_irq(SB_IRQ_MIDI);
     break;
   case 1:
      /* Read status port */
Index: src/base/init/config.c
===================================================================
--- src/base/init/config.c	(revision 1864)
+++ src/base/init/config.c	(working copy)
@@ -302,9 +302,9 @@
 	}
     }
 
-    (*print)("\nSOUND:\nsb_base 0x%x\nsb_dma %d\nsb_hdma %d\nsb_irq %d\n"
+    (*print)("\nSOUND:\nengine %d\nsb_base 0x%x\nsb_dma %d\nsb_hdma %d\nsb_irq %d\n"
 	"mpu401_base 0x%x\nsb_dsp \"%s\"\nsb_mixer \"%s\"\nsound_driver \"%s\"\n",
-        config.sb_base, config.sb_dma, config.sb_hdma, config.sb_irq,
+        config.sound, config.sb_base, config.sb_dma, config.sb_hdma, config.sb_irq,
 	config.mpu401_base, config.sb_dsp, config.sb_mixer, config.sound_driver);
     (*print)("\nSOUND_OSS:\noss_min_frags 0x%x\noss_max_frags 0x%x\n"
 	     "oss_stalled_frags 0x%x\noss_do_post %d\noss_min_extra_frags 0x%x\n"
Index: src/base/dev/sb16/sb16.h
===================================================================
--- src/base/dev/sb16/sb16.h	(revision 1864)
+++ src/base/dev/sb16/sb16.h	(working copy)
@@ -83,6 +83,7 @@
 #define DSP_OUT_FIFO_TRIGGER 32
 #define DSP_IN_FIFO_TRIGGER 32
 #define MIDI_FIFO_SIZE 32
+#define MPU401_IN_FIFO_TRIGGER 1
   struct rng_s midi_fifo_in;
   struct rng_s midi_fifo_out;
   void *dspio;
Index: src/base/dev/sb16/sb16.c
===================================================================
--- src/base/dev/sb16/sb16.c	(revision 1864)
+++ src/base/dev/sb16/sb16.c	(working copy)
@@ -323,6 +323,14 @@
     return (sb.mixer_regs[0x82] & type);
 }
 
+static void sb_request_irq(int type)
+{
+    if (type & SB_IRQ_DSP)
+	pic_request(pic_irq_list[sb_get_dsp_irq_num()]);
+    if (type & SB_IRQ_MPU401)
+	pic_request(pic_irq_list[CONFIG_MPU401_IRQ]);
+}
+
 static void sb_activate_irq(int type)
 {
     S_printf("SB: Activating irq type %d\n", type);
@@ -330,10 +338,7 @@
 	S_printf("SB: Warning: Interrupt already active!\n");
 	return;
     }
-    if (type & SB_IRQ_DSP)
-	pic_request(pic_irq_list[sb_get_dsp_irq_num()]);
-    if (type & SB_IRQ_MPU401)
-	pic_request(pic_irq_list[CONFIG_MPU401_IRQ]);
+    sb_request_irq(type);
     sb.mixer_regs[0x82] |= type;
 }
 
@@ -351,6 +356,14 @@
     }
 }
 
+static void sb_run_irq(int type)
+{
+    if (!sb_irq_active(type))
+	return;
+    S_printf("SB: Run irq type %d\n", type);
+    sb_request_irq(type);
+}
+
 void sb_handle_dma(void)
 {
     sb.dma_count--;
@@ -528,7 +541,7 @@
 		/* for High-Speed mode reset means only exit High-Speed */
 		S_printf("SB: Reset called, exiting High-Speed DMA mode\n");
 		sb.dma_cmd = 0;
-	    } else if (sb_midi_input() && sb_midi_uart()) {
+	    } else if (sb_midi_uart()) {
 		S_printf("SB: Reset called, exiting UART midi mode\n");
 		sb.midi_cmd = 0;
 	    } else {
@@ -1134,7 +1147,7 @@
 
 	/* == DSP == */
     case 0x0C:			/* dsp write register */
-	if (sb_midi_input() && sb_midi_uart()) {
+	if (sb_midi_uart()) {
 	    sb_write_midi(value);
 	    break;
 	}
@@ -1200,8 +1213,11 @@
 	rng_get(&sb.dsp_queue, &value);
 	S_printf("SB: Read 0x%x from SB DSP\n", value);
 	result = value;
-	if (sb_midi_input() && sb_midi_int())
-	    sb_deactivate_irq(SB_IRQ_MIDI);
+	if (sb_midi_int()) {
+	    if (!rng_count(&sb.dsp_queue))
+		sb_deactivate_irq(SB_IRQ_MIDI);
+	    sb_run_irq(SB_IRQ_MIDI);
+	}
 	break;
 
     case 0x0C:			/* DSP Write Buffer Status */
@@ -1284,6 +1300,7 @@
 	     r, rng_count(&sb.midi_fifo_in));
 	if (!rng_count(&sb.midi_fifo_in))
 	    sb_deactivate_irq(SB_IRQ_MPU401);
+	sb_run_irq(SB_IRQ_MPU401);
 	break;
     case 1:
 	/* Read status port */
@@ -1357,8 +1374,10 @@
 	    process_sb_midi_input();
 	if (sb_midi_int())
 	    sb_activate_irq(SB_IRQ_MIDI);
-    } else if (sb.mpu401_uart)
-	sb_activate_irq(SB_IRQ_MPU401);
+    } else if (sb.mpu401_uart) {
+	if (rng_count(&sb.midi_fifo_in) == MPU401_IN_FIFO_TRIGGER)
+	    sb_activate_irq(SB_IRQ_MPU401);
+    }
 }
 
 void run_new_sb(void)
@@ -1382,7 +1401,7 @@
     io_device.handler_name = "Midi Emulation";
     io_device.start_addr = config.mpu401_base;
     io_device.end_addr = config.mpu401_base + 0x001;
-    io_device.irq = EMU_NO_IRQ;
+    io_device.irq = CONFIG_MPU401_IRQ;
     io_device.fd = -1;
     if (port_register_handler(io_device, 0) != 0)
 	error("MPU-401: Cannot registering port handler\n");







______________________________________________________
GRATIS für alle WEB.DE-Nutzer: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://movieflat.web.de

--
To unsubscribe from this list: send the line "unsubscribe linux-msdos" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Console]     [Linux Audio]     [Linux for Hams]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite Camping]     [Yosemite Hiking]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Samba]     [Linux Media]     [Fedora Users]

  Powered by Linux