From ea6b5828cdbbedaf26b12ae64befbec18084ea3c Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Mon, 25 Feb 2008 10:59:52 +0100 Subject: [ALSA] mpu401: reduce tx loop timeout Reduce the number of times to check for a non-empty Tx FIFO from 100 to 2 because there is no MPU-401 implementation that needs more than one or two reads to determine the actual FIFO status. Signed-off-by: Clemens Ladisch --- sound/drivers/mpu401/mpu401_uart.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'sound/drivers/mpu401/mpu401_uart.c') diff --git a/sound/drivers/mpu401/mpu401_uart.c b/sound/drivers/mpu401/mpu401_uart.c index 5993864acbd..dd6ec426673 100644 --- a/sound/drivers/mpu401/mpu401_uart.c +++ b/sound/drivers/mpu401/mpu401_uart.c @@ -425,16 +425,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); -- cgit v1.2.3 From b415ed45f4db9f8365daac84cf2518642a174dc0 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Wed, 23 Apr 2008 17:47:28 +0200 Subject: [ALSA] Define MPU401 registers in sound/mpu401_uart.h Define some MPU401 registers in sound/mpu401_uart.h so that other drivers can refer to them. Signed-off-by: Takashi Iwai --- sound/drivers/mpu401/mpu401_uart.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'sound/drivers/mpu401/mpu401_uart.c') diff --git a/sound/drivers/mpu401/mpu401_uart.c b/sound/drivers/mpu401/mpu401_uart.c index dd6ec426673..18cca2457d4 100644 --- a/sound/drivers/mpu401/mpu401_uart.c +++ b/sound/drivers/mpu401/mpu401_uart.c @@ -49,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, -- cgit v1.2.3