diff options
Diffstat (limited to 'sys/i386/isa/sound/sb16_midi.c')
-rw-r--r-- | sys/i386/isa/sound/sb16_midi.c | 81 |
1 files changed, 51 insertions, 30 deletions
diff --git a/sys/i386/isa/sound/sb16_midi.c b/sys/i386/isa/sound/sb16_midi.c index d15fe17..7b23b4b 100644 --- a/sys/i386/isa/sound/sb16_midi.c +++ b/sys/i386/isa/sound/sb16_midi.c @@ -25,7 +25,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id$ + * $Id: sb16_midi.c,v 1.3 1994/08/02 07:40:38 davidg Exp $ */ #include "sound_config.h" @@ -34,9 +34,11 @@ #if !defined(EXCLUDE_SB) && !defined(EXCLUDE_SB16) && !defined(EXCLUDE_MIDI) -#define DATAPORT (sb16midi_base) /* MPU-401 Data I/O Port on IBM */ -#define COMDPORT (sb16midi_base+1) /* MPU-401 Command Port on IBM */ -#define STATPORT (sb16midi_base+1) /* MPU-401 Status Port on IBM */ +#include "sb.h" + +#define DATAPORT (sb16midi_base) +#define COMDPORT (sb16midi_base+1) +#define STATPORT (sb16midi_base+1) #define sb16midi_status() INB(STATPORT) #define input_avail() (!(sb16midi_status()&INPUT_AVAIL)) @@ -45,26 +47,24 @@ #define sb16midi_read() INB(DATAPORT) #define sb16midi_write(byte) OUTB(byte, DATAPORT) -#define OUTPUT_READY 0x40 /* Mask for Data Read Redy Bit */ -#define INPUT_AVAIL 0x80 /* Mask for Data Send Ready Bit */ -#define MPU_ACK 0xFE /* MPU-401 Acknowledge Response */ -#define MPU_RESET 0xFF /* MPU-401 Total Reset Command */ -#define UART_MODE_ON 0x3F /* MPU-401 "Dumb UART Mode" */ +#define OUTPUT_READY 0x40 +#define INPUT_AVAIL 0x80 +#define MPU_ACK 0xFE +#define MPU_RESET 0xFF +#define UART_MODE_ON 0x3F static int sb16midi_opened = 0; static int sb16midi_base = 0x330; static int sb16midi_detected = 0; static int my_dev; +extern int sbc_base; static int reset_sb16midi (void); static void (*midi_input_intr) (int dev, unsigned char data); -extern int sbc_major; - static void sb16midi_input_loop (void) { - while (input_avail ()) { unsigned char c = sb16midi_read (); @@ -128,7 +128,9 @@ sb16midi_out (int dev, unsigned char midi_byte) * (After reset). Normally it takes just about 10 loops. */ - for (timeout = 30000; timeout > 0 && !output_ready (); timeout--); /* Wait */ + for (timeout = 30000; timeout > 0 && !output_ready (); timeout--); /* + * Wait + */ if (!output_ready ()) { @@ -141,12 +143,6 @@ sb16midi_out (int dev, unsigned char midi_byte) } static int -sb16midi_command (int dev, unsigned char midi_byte) -{ - return 1; -} - -static int sb16midi_start_read (int dev) { return 0; @@ -172,12 +168,19 @@ sb16midi_kick (int dev) static int sb16midi_buffer_status (int dev) { - return 0; /* No data in buffers */ + return 0; /* + * No data in buffers + */ } +#define MIDI_SYNTH_NAME "SoundBlaster 16 Midi" +#define MIDI_SYNTH_CAPS SYNTH_CAP_INPUT +#include "midi_synth.h" + static struct midi_operations sb16midi_operations = { - {"SoundBlaster MPU-401", 0, 0, SNDCARD_SB16MIDI}, + {"SoundBlaster 16 Midi", 0, 0, SNDCARD_SB16MIDI}, + &std_midi_synth, sb16midi_open, sb16midi_close, sb16midi_ioctl, @@ -185,8 +188,9 @@ static struct midi_operations sb16midi_operations = sb16midi_start_read, sb16midi_end_read, sb16midi_kick, - sb16midi_command, - sb16midi_buffer_status + NULL, + sb16midi_buffer_status, + NULL }; @@ -202,7 +206,9 @@ attach_sb16midi (long mem_start, struct address_info *hw_config) return RET_ERROR (EIO); DISABLE_INTR (flags); - for (timeout = 30000; timeout < 0 && !output_ready (); timeout--); /* Wait */ + for (timeout = 30000; timeout < 0 && !output_ready (); timeout--); /* + * Wait + */ sb16midi_cmd (UART_MODE_ON); ok = 0; @@ -213,13 +219,19 @@ attach_sb16midi (long mem_start, struct address_info *hw_config) RESTORE_INTR (flags); + if (num_midis >= MAX_MIDI_DEV) + { + printk ("Sound: Too many midi devices detected\n"); + return mem_start; + } + #ifdef __FreeBSD__ printk ("snd7: <SoundBlaster MPU-401>"); #else printk (" <SoundBlaster MPU-401>"); #endif - my_dev = num_midis; + std_midi_synth.midi_dev = my_dev = num_midis; midi_devs[num_midis++] = &sb16midi_operations; return mem_start; } @@ -240,8 +252,12 @@ reset_sb16midi (void) for (n = 0; n < 2 && !ok; n++) { - for (timeout = 30000; timeout < 0 && !output_ready (); timeout--); /* Wait */ - sb16midi_cmd (MPU_RESET); /* Send MPU-401 RESET Command */ + for (timeout = 30000; timeout < 0 && !output_ready (); timeout--); /* + * Wait + */ + sb16midi_cmd (MPU_RESET); /* + * Send MPU-401 RESET Command + */ /* * Wait at least 25 msec. This method is not accurate so let's make the @@ -257,7 +273,9 @@ reset_sb16midi (void) sb16midi_opened = 0; if (ok) - sb16midi_input_loop (); /* Flush input before enabling interrupts */ + sb16midi_input_loop (); /* + * Flush input before enabling interrupts + */ RESTORE_INTR (flags); @@ -269,10 +287,13 @@ int probe_sb16midi (struct address_info *hw_config) { int ok = 0; + int i; + extern int sbc_major; - sb16midi_base = hw_config->io_base; if (sbc_major < 4) - return 0; /* SB16 not detected */ + return 0; /* Not a SB16 */ + + sb16midi_base = hw_config->io_base; if (sb_get_irq () < 0) return 0; |