]> err.no Git - linux-2.6/blobdiff - sound/drivers/mpu401/mpu401_uart.c
Merge branch 'for-2.6.26' of master.kernel.org:/pub/scm/linux/kernel/git/jwboyer...
[linux-2.6] / sound / drivers / mpu401 / mpu401_uart.c
index b57f2d5a1c9dff920e17c2ada69d009e090bbd21..2af09996a3d01a39d4b913a23c1d08855ed54f06 100644 (file)
@@ -28,7 +28,6 @@
  *
  */
 
-#include <sound/driver.h>
 #include <asm/io.h>
 #include <linux/delay.h>
 #include <linux/init.h>
@@ -50,12 +49,10 @@ static void snd_mpu401_uart_output_write(struct snd_mpu401 * mpu);
 
  */
 
-#define snd_mpu401_input_avail(mpu)    (!(mpu->read(mpu, MPU401C(mpu)) & 0x80))
-#define snd_mpu401_output_ready(mpu)   (!(mpu->read(mpu, MPU401C(mpu)) & 0x40))
-
-#define MPU401_RESET           0xff
-#define MPU401_ENTER_UART      0x3f
-#define MPU401_ACK             0xfe
+#define snd_mpu401_input_avail(mpu) \
+       (!(mpu->read(mpu, MPU401C(mpu)) & MPU401_RX_EMPTY))
+#define snd_mpu401_output_ready(mpu) \
+       (!(mpu->read(mpu, MPU401C(mpu)) & MPU401_TX_FULL))
 
 /* Build in lowlevel io */
 static void mpu401_write_port(struct snd_mpu401 *mpu, unsigned char data,
@@ -246,7 +243,7 @@ static int snd_mpu401_uart_cmd(struct snd_mpu401 * mpu, unsigned char cmd,
 #endif
        }
        mpu->write(mpu, cmd, MPU401C(mpu));
-       if (ack) {
+       if (ack && !(mpu->info_flags & MPU401_INFO_NO_ACK)) {
                ok = 0;
                timeout = 10000;
                while (!ok && timeout-- > 0) {
@@ -426,16 +423,17 @@ static void snd_mpu401_uart_input_read(struct snd_mpu401 * mpu)
 static void snd_mpu401_uart_output_write(struct snd_mpu401 * mpu)
 {
        unsigned char byte;
-       int max = 256, timeout;
+       int max = 256;
 
        do {
                if (snd_rawmidi_transmit_peek(mpu->substream_output,
                                              &byte, 1) == 1) {
-                       for (timeout = 100; timeout > 0; timeout--) {
-                               if (snd_mpu401_output_ready(mpu))
-                                       break;
-                       }
-                       if (timeout == 0)
+                       /*
+                        * Try twice because there is hardware that insists on
+                        * setting the output busy bit after each write.
+                        */
+                       if (!snd_mpu401_output_ready(mpu) &&
+                           !snd_mpu401_output_ready(mpu))
                                break;  /* Tx FIFO full - try again later */
                        mpu->write(mpu, byte, MPU401D(mpu));
                        snd_rawmidi_transmit_ack(mpu->substream_output, 1);