Commit 8f7ba051 authored by Takashi Iwai's avatar Takashi Iwai Committed by Jaroslav Kysela

[ALSA] mpu401 - Add MPU401_INFO_UART_ONLY bitflag

Added MPU401_INFO_UART_ONLY bitflag to avoid issueing UART_ENTER command
at opening streams.  Some devices support only UART mode and give errors
to UART_ENTER.
A new module option, uart_enter, is added to snd-mpu401 driver.
For UART-only devices, set uart_enter=0.
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
Signed-off-by: default avatarJaroslav Kysela <perex@suse.cz>
parent 76e63067
...@@ -1278,6 +1278,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. ...@@ -1278,6 +1278,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed.
port - port number or -1 (disable) port - port number or -1 (disable)
irq - IRQ number or -1 (disable) irq - IRQ number or -1 (disable)
pnp - PnP detection - 0 = disable, 1 = enable (default) pnp - PnP detection - 0 = disable, 1 = enable (default)
uart_enter - Issue UART_ENTER command at open - bool, default = on
This module supports multiple devices and PnP. This module supports multiple devices and PnP.
......
...@@ -50,6 +50,7 @@ ...@@ -50,6 +50,7 @@
#define MPU401_INFO_INTEGRATED (1 << 2) /* integrated h/w port */ #define MPU401_INFO_INTEGRATED (1 << 2) /* integrated h/w port */
#define MPU401_INFO_MMIO (1 << 3) /* MMIO access */ #define MPU401_INFO_MMIO (1 << 3) /* MMIO access */
#define MPU401_INFO_TX_IRQ (1 << 4) /* independent TX irq */ #define MPU401_INFO_TX_IRQ (1 << 4) /* independent TX irq */
#define MPU401_INFO_UART_ONLY (1 << 5) /* No ENTER_UART cmd needed */
#define MPU401_MODE_BIT_INPUT 0 #define MPU401_MODE_BIT_INPUT 0
#define MPU401_MODE_BIT_OUTPUT 1 #define MPU401_MODE_BIT_OUTPUT 1
......
...@@ -42,6 +42,7 @@ static int pnp[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1}; ...@@ -42,6 +42,7 @@ static int pnp[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1};
#endif #endif
static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* MPU-401 port number */ static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* MPU-401 port number */
static int irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; /* MPU-401 IRQ */ static int irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; /* MPU-401 IRQ */
static int uart_enter[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1};
module_param_array(index, int, NULL, 0444); module_param_array(index, int, NULL, 0444);
MODULE_PARM_DESC(index, "Index value for MPU-401 device."); MODULE_PARM_DESC(index, "Index value for MPU-401 device.");
...@@ -57,6 +58,8 @@ module_param_array(port, long, NULL, 0444); ...@@ -57,6 +58,8 @@ module_param_array(port, long, NULL, 0444);
MODULE_PARM_DESC(port, "Port # for MPU-401 device."); MODULE_PARM_DESC(port, "Port # for MPU-401 device.");
module_param_array(irq, int, NULL, 0444); module_param_array(irq, int, NULL, 0444);
MODULE_PARM_DESC(irq, "IRQ # for MPU-401 device."); MODULE_PARM_DESC(irq, "IRQ # for MPU-401 device.");
module_param_array(uart_enter, bool, NULL, 0444);
MODULE_PARM_DESC(uart_enter, "Issue UART_ENTER command at open.");
static struct platform_device *platform_devices[SNDRV_CARDS]; static struct platform_device *platform_devices[SNDRV_CARDS];
static int pnp_registered; static int pnp_registered;
...@@ -80,10 +83,11 @@ static int snd_mpu401_create(int dev, struct snd_card **rcard) ...@@ -80,10 +83,11 @@ static int snd_mpu401_create(int dev, struct snd_card **rcard)
strcat(card->longname, "polled"); strcat(card->longname, "polled");
} }
if ((err = snd_mpu401_uart_new(card, 0, err = snd_mpu401_uart_new(card, 0, MPU401_HW_MPU401, port[dev],
MPU401_HW_MPU401, uart_enter[dev] ? 0 : MPU401_INFO_UART_ONLY,
port[dev], 0, irq[dev], irq[dev] >= 0 ? IRQF_DISABLED : 0,
irq[dev], irq[dev] >= 0 ? IRQF_DISABLED : 0, NULL)) < 0) { NULL);
if (err < 0) {
printk(KERN_ERR "MPU401 not detected at 0x%lx\n", port[dev]); printk(KERN_ERR "MPU401 not detected at 0x%lx\n", port[dev]);
goto _err; goto _err;
} }
......
...@@ -266,6 +266,16 @@ static int snd_mpu401_uart_cmd(struct snd_mpu401 * mpu, unsigned char cmd, ...@@ -266,6 +266,16 @@ static int snd_mpu401_uart_cmd(struct snd_mpu401 * mpu, unsigned char cmd,
return 0; return 0;
} }
static int snd_mpu401_do_reset(struct snd_mpu401 *mpu)
{
if (snd_mpu401_uart_cmd(mpu, MPU401_RESET, 1))
return -EIO;
if (!(mpu->info_flags & MPU401_INFO_UART_ONLY) &&
snd_mpu401_uart_cmd(mpu, MPU401_ENTER_UART, 1))
return -EIO;
return 0;
}
/* /*
* input/output open/close - protected by open_mutex in rawmidi.c * input/output open/close - protected by open_mutex in rawmidi.c
*/ */
...@@ -278,9 +288,7 @@ static int snd_mpu401_uart_input_open(struct snd_rawmidi_substream *substream) ...@@ -278,9 +288,7 @@ static int snd_mpu401_uart_input_open(struct snd_rawmidi_substream *substream)
if (mpu->open_input && (err = mpu->open_input(mpu)) < 0) if (mpu->open_input && (err = mpu->open_input(mpu)) < 0)
return err; return err;
if (! test_bit(MPU401_MODE_BIT_OUTPUT, &mpu->mode)) { if (! test_bit(MPU401_MODE_BIT_OUTPUT, &mpu->mode)) {
if (snd_mpu401_uart_cmd(mpu, MPU401_RESET, 1)) if (snd_mpu401_do_reset(mpu) < 0)
goto error_out;
if (snd_mpu401_uart_cmd(mpu, MPU401_ENTER_UART, 1))
goto error_out; goto error_out;
} }
mpu->substream_input = substream; mpu->substream_input = substream;
...@@ -302,9 +310,7 @@ static int snd_mpu401_uart_output_open(struct snd_rawmidi_substream *substream) ...@@ -302,9 +310,7 @@ static int snd_mpu401_uart_output_open(struct snd_rawmidi_substream *substream)
if (mpu->open_output && (err = mpu->open_output(mpu)) < 0) if (mpu->open_output && (err = mpu->open_output(mpu)) < 0)
return err; return err;
if (! test_bit(MPU401_MODE_BIT_INPUT, &mpu->mode)) { if (! test_bit(MPU401_MODE_BIT_INPUT, &mpu->mode)) {
if (snd_mpu401_uart_cmd(mpu, MPU401_RESET, 1)) if (snd_mpu401_do_reset(mpu) < 0)
goto error_out;
if (snd_mpu401_uart_cmd(mpu, MPU401_ENTER_UART, 1))
goto error_out; goto error_out;
} }
mpu->substream_output = substream; mpu->substream_output = substream;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment