Example #1
0
static int
sb16midi_out (int dev, unsigned char midi_byte)
{
  int             timeout;
  unsigned long   flags;

  /*
   * Test for input since pending input seems to block the output.
   */

  DISABLE_INTR (flags);

  if (input_avail ())
    sb16midi_input_loop ();

  RESTORE_INTR (flags);

  /*
   * Sometimes it takes about 13000 loops before the output becomes ready
   * (After reset). Normally it takes just about 10 loops.
   */

  for (timeout = 30000; timeout > 0 && !output_ready (); timeout--);	/*
									 * Wait
									 */

  if (!output_ready ())
    {
      printk ("MPU-401: Timeout\n");
      return 0;
    }

  sb16midi_write (midi_byte);
  return 1;
}
Example #2
0
static int uart6850_out(int dev, unsigned char midi_byte)
{
	int timeout;
	unsigned long flags;

	/*
	 * Test for input since pending input seems to block the output.
	 */

	spin_lock_irqsave(&lock,flags);

	if (input_avail())
		uart6850_input_loop();

	spin_unlock_irqrestore(&lock,flags);

	/*
	 * Sometimes it takes about 13000 loops before the output becomes ready
	 * (After reset). Normally it takes just about 10 loops.
	 */

	for (timeout = 30000; timeout > 0 && !output_ready(); timeout--);	/*
										 * Wait
										 */
	if (!output_ready())
	{
		printk(KERN_WARNING "Midi6850: Timeout\n");
		return 0;
	}
	uart6850_write(midi_byte);
	return 1;
}
Example #3
0
static int
sb16midi_out(int dev, u_char midi_byte)
{
	int             timeout;
	u_long   flags;

	/*
	 * Test for input since pending input seems to block the output.
	 */

	flags = splhigh();

	if (input_avail())
		sb16midi_input_loop();

	splx(flags);

	/*
	 * Sometimes it takes about 13000 loops before the output becomes
	 * ready (After reset). Normally it takes just about 10 loops.
	 */

	for (timeout = 30000; timeout > 0 && !output_ready(); timeout--);	/* Wait */

	if (!output_ready()) {
		printf("MPU-401: Timeout\n");
		return 0;
	}
	sb16midi_write(midi_byte);
	return 1;
}
Example #4
0
static void __init attach_uart6850(struct address_info *hw_config)
{
	int ok, timeout;
	unsigned long   flags;

	if (!uart6850_detected)
		return;

	if ((my_dev = sound_alloc_mididev()) == -1)
	{
		printk(KERN_INFO "uart6850: Too many midi devices detected\n");
		return;
	}
	uart6850_base = hw_config->io_base;
	uart6850_osp = hw_config->osp;
	uart6850_irq = hw_config->irq;

	spin_lock_irqsave(&lock,flags);

	for (timeout = 30000; timeout > 0 && !output_ready(); timeout--);	/*
										 * Wait
										 */
	uart6850_cmd(UART_MODE_ON);
	ok = 1;
	spin_unlock_irqrestore(&lock,flags);

	conf_printf("6850 Midi Interface", hw_config);

	std_midi_synth.midi_dev = my_dev;
	hw_config->slots[4] = my_dev;
	midi_devs[my_dev] = &uart6850_operations;
	sequencer_init();
}
Example #5
0
static int uart401_out(int dev, unsigned char midi_byte)
{
	int timeout;
	unsigned long flags;
	uart401_devc *devc = (uart401_devc *) midi_devs[dev]->devc;

	if (devc->disabled)
		return 1;
	/*
	 * Test for input since pending input seems to block the output.
	 */

	save_flags(flags);
	cli();

	if (input_avail(devc))
		uart401_input_loop(devc);

	restore_flags(flags);

	/*
	 * Sometimes it takes about 13000 loops before the output becomes ready
	 * (After reset). Normally it takes just about 10 loops.
	 */

	for (timeout = 30000; timeout > 0 && !output_ready(devc); timeout--);

	if (!output_ready(devc))
	{
		  printk(KERN_WARNING "uart401: Timeout - Device not responding\n");
		  devc->disabled = 1;
		  reset_uart401(devc);
		  enter_uart_mode(devc);
		  return 1;
	}
	uart401_write(devc, midi_byte);
	return 1;
}
Example #6
0
static int reset_uart401(uart401_devc * devc)
{
	int ok, timeout, n;

	/*
	 * Send the RESET command. Try again if no success at the first time.
	 */

	ok = 0;

	for (n = 0; n < 2 && !ok; n++)
	{
		for (timeout = 30000; timeout > 0 && !output_ready(devc); timeout--);
		devc->input_byte = 0;
		uart401_cmd(devc, MPU_RESET);

		/*
		 * Wait at least 25 msec. This method is not accurate so let's make the
		 * loop bit longer. Cannot sleep since this is called during boot.
		 */

		for (timeout = 50000; timeout > 0 && !ok; timeout--)
		{
			if (devc->input_byte == MPU_ACK)	/* Interrupt */
				ok = 1;
			else if (input_avail(devc))
			{
				if (uart401_read(devc) == MPU_ACK)
					ok = 1;
			}
		}
	}


	if (ok)
	{
		DEB(printk("Reset UART401 OK\n"));
	}
	else
		DDB(printk("Reset UART401 failed - No hardware detected.\n"));

	if (ok)
		uart401_input_loop(devc);	/*
						 * Flush input before enabling interrupts
						 */

	return ok;
}
Example #7
0
static int
reset_sb16midi (void)
{
  unsigned long   flags;
  int             ok, timeout, n;

  /*
   * Send the RESET command. Try again if no success at the first time.
   */

  ok = 0;

  DISABLE_INTR (flags);

  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
				 */

      /*
       * Wait at least 25 msec. This method is not accurate so let's make the
       * loop bit longer. Cannot sleep since this is called during boot.
       */

      for (timeout = 50000; timeout > 0 && !ok; timeout--)
	if (input_avail ())
	  if (sb16midi_read () == MPU_ACK)
	    ok = 1;

    }

  sb16midi_opened = 0;
  if (ok)
    sb16midi_input_loop ();	/*
				 * Flush input before enabling interrupts
				 */

  RESTORE_INTR (flags);

  return ok;
}
Example #8
0
static int
reset_sb16midi(void)
{
	int             ok, timeout, n;

	/*
	 * Send the RESET command. Try again if no success at the first time.
	 */

	if (inb(STATPORT) == 0xff)
		return 0;

	ok = 0;

	/* flags = splhigh(); */

	for (n = 0; n < 2 && !ok; n++) {
		for (timeout = 30000; timeout < 0 && !output_ready(); timeout--);	/* Wait */
		input_byte = 0;
		sb16midi_cmd(MPU_RESET);	/* Send MPU-401 RESET Command */

		/*
		 * Wait at least 25 msec. This method is not accurate so
		 * let's make the loop bit longer. Cannot sleep since this is
		 * called during boot.
		 */

		for (timeout = 50000; timeout > 0 && !ok; timeout--)
			if (input_byte == MPU_ACK)	/* Interrupt */
				ok = 1;
			else if (input_avail())
				if (sb16midi_read() == MPU_ACK)
					ok = 1;

	}

	sb16midi_opened = 0;
	if (ok)
		sb16midi_input_loop();	/* Flush input before enabling
					 * interrupts */

	/* splx(flags); */

	return ok;
}
Example #9
0
long
attach_sb16midi (long mem_start, struct address_info *hw_config)
{
  int             ok, timeout;
  unsigned long   flags;

  sb16midi_base = hw_config->io_base;

  if (!sb16midi_detected)
    return RET_ERROR (EIO);

  DISABLE_INTR (flags);
  for (timeout = 30000; timeout < 0 && !output_ready (); timeout--);	/*
									 * Wait
									 */
  sb16midi_cmd (UART_MODE_ON);

  ok = 0;
  for (timeout = 50000; timeout > 0 && !ok; timeout--)
    if (input_avail ())
      if (sb16midi_read () == MPU_ACK)
	ok = 1;

  RESTORE_INTR (flags);

  if (num_midis >= MAX_MIDI_DEV)
    {
      printk ("Sound: Too many midi devices detected\n");
      return mem_start;
    }

#if defined(__FreeBSD__)
  printk ("sbmidi0: <SoundBlaster MPU-401>");
#else
  printk (" <SoundBlaster MPU-401>");
#endif

  std_midi_synth.midi_dev = my_dev = num_midis;
  midi_devs[num_midis++] = &sb16midi_operations;
  return mem_start;
}
Example #10
0
static void enter_uart_mode(uart401_devc * devc)
{
	int ok, timeout;
	unsigned long flags;

	spin_lock_irqsave(&devc->lock,flags);	
	for (timeout = 30000; timeout > 0 && !output_ready(devc); timeout--);

	devc->input_byte = 0;
	uart401_cmd(devc, UART_MODE_ON);

	ok = 0;
	for (timeout = 50000; timeout > 0 && !ok; timeout--)
		if (devc->input_byte == MPU_ACK)
			ok = 1;
		else if (input_avail(devc))
			if (uart401_read(devc) == MPU_ACK)
				ok = 1;

	spin_unlock_irqrestore(&devc->lock,flags);
}
Example #11
0
long
attach_uart6850 (long mem_start, struct address_info *hw_config)
{
  int             ok, timeout;
  unsigned long   flags;

  if (num_midis >= MAX_MIDI_DEV)
    {
      printk ("Sound: Too many midi devices detected\n");
      return mem_start;
    }

  uart6850_base = hw_config->io_base;
  uart6850_irq = hw_config->irq;

  if (!uart6850_detected)
    return RET_ERROR (EIO);

  DISABLE_INTR (flags);

  for (timeout = 30000; timeout < 0 && !output_ready (); timeout--);	/*
									 * Wait
									 */
  uart6850_cmd (UART_MODE_ON);

  ok = 1;

  RESTORE_INTR (flags);

#if defined(__FreeBSD__)
  printk ("uart0: <6850 Midi Interface>");
#else
  printk (" <6850 Midi Interface>");
#endif

  std_midi_synth.midi_dev = my_dev = num_midis;
  midi_devs[num_midis++] = &uart6850_operations;
  return mem_start;
}
Example #12
0
void
attach_sb16midi(struct address_info * hw_config)
{
	int             ok, timeout;
	u_long   flags;

	sb16midi_base = hw_config->io_base;

	if (!sb16midi_detected)
		return;

	flags = splhigh();
	for (timeout = 30000; timeout < 0 && !output_ready(); timeout--);	/* Wait */
	input_byte = 0;
	sb16midi_cmd(UART_MODE_ON);

	ok = 0;
	for (timeout = 50000; timeout > 0 && !ok; timeout--)
		if (input_byte == MPU_ACK)
			ok = 1;
		else if (input_avail())
			if (sb16midi_read() == MPU_ACK)
				ok = 1;

	splx(flags);

	if (num_midis >= MAX_MIDI_DEV) {
		printf("Sound: Too many midi devices detected\n");
		return;
	}
	
	conf_printf("SoundBlaster MPU-401", hw_config);
	std_midi_synth.midi_dev = my_dev = num_midis;
	midi_devs[num_midis++] = &sb16midi_operations;
	return;
}