Commit 8f7ba051d2abb3d3bde9b95e47246c60b704d2b4
Committed by
Jaroslav Kysela
1 parent
76e6306774
Exists in
master
and in
7 other branches
[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: Takashi Iwai <tiwai@suse.de> Signed-off-by: Jaroslav Kysela <perex@suse.cz>
Showing 4 changed files with 22 additions and 10 deletions Side-by-side Diff
Documentation/sound/alsa/ALSA-Configuration.txt
... | ... | @@ -1278,6 +1278,7 @@ |
1278 | 1278 | port - port number or -1 (disable) |
1279 | 1279 | irq - IRQ number or -1 (disable) |
1280 | 1280 | pnp - PnP detection - 0 = disable, 1 = enable (default) |
1281 | + uart_enter - Issue UART_ENTER command at open - bool, default = on | |
1281 | 1282 | |
1282 | 1283 | This module supports multiple devices and PnP. |
1283 | 1284 |
include/sound/mpu401.h
... | ... | @@ -50,6 +50,7 @@ |
50 | 50 | #define MPU401_INFO_INTEGRATED (1 << 2) /* integrated h/w port */ |
51 | 51 | #define MPU401_INFO_MMIO (1 << 3) /* MMIO access */ |
52 | 52 | #define MPU401_INFO_TX_IRQ (1 << 4) /* independent TX irq */ |
53 | +#define MPU401_INFO_UART_ONLY (1 << 5) /* No ENTER_UART cmd needed */ | |
53 | 54 | |
54 | 55 | #define MPU401_MODE_BIT_INPUT 0 |
55 | 56 | #define MPU401_MODE_BIT_OUTPUT 1 |
sound/drivers/mpu401/mpu401.c
... | ... | @@ -42,6 +42,7 @@ |
42 | 42 | #endif |
43 | 43 | static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* MPU-401 port number */ |
44 | 44 | static int irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; /* MPU-401 IRQ */ |
45 | +static int uart_enter[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1}; | |
45 | 46 | |
46 | 47 | module_param_array(index, int, NULL, 0444); |
47 | 48 | MODULE_PARM_DESC(index, "Index value for MPU-401 device."); |
... | ... | @@ -57,6 +58,8 @@ |
57 | 58 | MODULE_PARM_DESC(port, "Port # for MPU-401 device."); |
58 | 59 | module_param_array(irq, int, NULL, 0444); |
59 | 60 | MODULE_PARM_DESC(irq, "IRQ # for MPU-401 device."); |
61 | +module_param_array(uart_enter, bool, NULL, 0444); | |
62 | +MODULE_PARM_DESC(uart_enter, "Issue UART_ENTER command at open."); | |
60 | 63 | |
61 | 64 | static struct platform_device *platform_devices[SNDRV_CARDS]; |
62 | 65 | static int pnp_registered; |
... | ... | @@ -80,10 +83,11 @@ |
80 | 83 | strcat(card->longname, "polled"); |
81 | 84 | } |
82 | 85 | |
83 | - if ((err = snd_mpu401_uart_new(card, 0, | |
84 | - MPU401_HW_MPU401, | |
85 | - port[dev], 0, | |
86 | - irq[dev], irq[dev] >= 0 ? IRQF_DISABLED : 0, NULL)) < 0) { | |
86 | + err = snd_mpu401_uart_new(card, 0, MPU401_HW_MPU401, port[dev], | |
87 | + uart_enter[dev] ? 0 : MPU401_INFO_UART_ONLY, | |
88 | + irq[dev], irq[dev] >= 0 ? IRQF_DISABLED : 0, | |
89 | + NULL); | |
90 | + if (err < 0) { | |
87 | 91 | printk(KERN_ERR "MPU401 not detected at 0x%lx\n", port[dev]); |
88 | 92 | goto _err; |
89 | 93 | } |
sound/drivers/mpu401/mpu401_uart.c
... | ... | @@ -266,6 +266,16 @@ |
266 | 266 | return 0; |
267 | 267 | } |
268 | 268 | |
269 | +static int snd_mpu401_do_reset(struct snd_mpu401 *mpu) | |
270 | +{ | |
271 | + if (snd_mpu401_uart_cmd(mpu, MPU401_RESET, 1)) | |
272 | + return -EIO; | |
273 | + if (!(mpu->info_flags & MPU401_INFO_UART_ONLY) && | |
274 | + snd_mpu401_uart_cmd(mpu, MPU401_ENTER_UART, 1)) | |
275 | + return -EIO; | |
276 | + return 0; | |
277 | +} | |
278 | + | |
269 | 279 | /* |
270 | 280 | * input/output open/close - protected by open_mutex in rawmidi.c |
271 | 281 | */ |
272 | 282 | |
... | ... | @@ -278,10 +288,8 @@ |
278 | 288 | if (mpu->open_input && (err = mpu->open_input(mpu)) < 0) |
279 | 289 | return err; |
280 | 290 | if (! test_bit(MPU401_MODE_BIT_OUTPUT, &mpu->mode)) { |
281 | - if (snd_mpu401_uart_cmd(mpu, MPU401_RESET, 1)) | |
291 | + if (snd_mpu401_do_reset(mpu) < 0) | |
282 | 292 | goto error_out; |
283 | - if (snd_mpu401_uart_cmd(mpu, MPU401_ENTER_UART, 1)) | |
284 | - goto error_out; | |
285 | 293 | } |
286 | 294 | mpu->substream_input = substream; |
287 | 295 | set_bit(MPU401_MODE_BIT_INPUT, &mpu->mode); |
... | ... | @@ -302,9 +310,7 @@ |
302 | 310 | if (mpu->open_output && (err = mpu->open_output(mpu)) < 0) |
303 | 311 | return err; |
304 | 312 | if (! test_bit(MPU401_MODE_BIT_INPUT, &mpu->mode)) { |
305 | - if (snd_mpu401_uart_cmd(mpu, MPU401_RESET, 1)) | |
306 | - goto error_out; | |
307 | - if (snd_mpu401_uart_cmd(mpu, MPU401_ENTER_UART, 1)) | |
313 | + if (snd_mpu401_do_reset(mpu) < 0) | |
308 | 314 | goto error_out; |
309 | 315 | } |
310 | 316 | mpu->substream_output = substream; |