Lines Matching full:midi

62 #define IPR_MIDITRANSBUFEMPTY   0x00000001	/* MIDI UART transmit buffer empty		*/
63 #define IPR_MIDIRECVBUFEMPTY 0x00000002 /* MIDI UART receive buffer empty */
70 #define INTE_MIDITXENABLE 0x00000001 /* Enable MIDI transmit-buffer-empty interrupts */
71 #define INTE_MIDIRXENABLE 0x00000002 /* Enable MIDI receive-buffer-empty interrupts */
237 struct emu10k1x_midi midi; member
788 if (chip->midi.interrupt) in snd_emu10k1x_interrupt()
789 chip->midi.interrupt(chip, status); in snd_emu10k1x_interrupt()
1199 struct emu10k1x_midi *midi, unsigned int status) in do_emu10k1x_midi_interrupt() argument
1203 if (midi->rmidi == NULL) { in do_emu10k1x_midi_interrupt()
1204 snd_emu10k1x_intr_disable(emu, midi->tx_enable | midi->rx_enable); in do_emu10k1x_midi_interrupt()
1208 spin_lock(&midi->input_lock); in do_emu10k1x_midi_interrupt()
1209 if ((status & midi->ipr_rx) && mpu401_input_avail(emu, midi)) { in do_emu10k1x_midi_interrupt()
1210 if (!(midi->midi_mode & EMU10K1X_MIDI_MODE_INPUT)) { in do_emu10k1x_midi_interrupt()
1211 mpu401_clear_rx(emu, midi); in do_emu10k1x_midi_interrupt()
1213 byte = mpu401_read_data(emu, midi); in do_emu10k1x_midi_interrupt()
1214 if (midi->substream_input) in do_emu10k1x_midi_interrupt()
1215 snd_rawmidi_receive(midi->substream_input, &byte, 1); in do_emu10k1x_midi_interrupt()
1218 spin_unlock(&midi->input_lock); in do_emu10k1x_midi_interrupt()
1220 spin_lock(&midi->output_lock); in do_emu10k1x_midi_interrupt()
1221 if ((status & midi->ipr_tx) && mpu401_output_ready(emu, midi)) { in do_emu10k1x_midi_interrupt()
1222 if (midi->substream_output && in do_emu10k1x_midi_interrupt()
1223 snd_rawmidi_transmit(midi->substream_output, &byte, 1) == 1) { in do_emu10k1x_midi_interrupt()
1224 mpu401_write_data(emu, midi, byte); in do_emu10k1x_midi_interrupt()
1226 snd_emu10k1x_intr_disable(emu, midi->tx_enable); in do_emu10k1x_midi_interrupt()
1229 spin_unlock(&midi->output_lock); in do_emu10k1x_midi_interrupt()
1234 do_emu10k1x_midi_interrupt(emu, &emu->midi, status); in snd_emu10k1x_midi_interrupt()
1238 struct emu10k1x_midi *midi, unsigned char cmd, int ack) in snd_emu10k1x_midi_cmd() argument
1243 spin_lock_irqsave(&midi->input_lock, flags); in snd_emu10k1x_midi_cmd()
1244 mpu401_write_data(emu, midi, 0x00); in snd_emu10k1x_midi_cmd()
1245 /* mpu401_clear_rx(emu, midi); */ in snd_emu10k1x_midi_cmd()
1247 mpu401_write_cmd(emu, midi, cmd); in snd_emu10k1x_midi_cmd()
1252 if (mpu401_input_avail(emu, midi)) { in snd_emu10k1x_midi_cmd()
1253 if (mpu401_read_data(emu, midi) == MPU401_ACK) in snd_emu10k1x_midi_cmd()
1257 if (!ok && mpu401_read_data(emu, midi) == MPU401_ACK) in snd_emu10k1x_midi_cmd()
1262 spin_unlock_irqrestore(&midi->input_lock, flags); in snd_emu10k1x_midi_cmd()
1267 mpu401_read_stat(emu, midi), in snd_emu10k1x_midi_cmd()
1268 mpu401_read_data(emu, midi)); in snd_emu10k1x_midi_cmd()
1277 struct emu10k1x_midi *midi = substream->rmidi->private_data; in snd_emu10k1x_midi_input_open() local
1280 emu = midi->emu; in snd_emu10k1x_midi_input_open()
1283 spin_lock_irqsave(&midi->open_lock, flags); in snd_emu10k1x_midi_input_open()
1284 midi->midi_mode |= EMU10K1X_MIDI_MODE_INPUT; in snd_emu10k1x_midi_input_open()
1285 midi->substream_input = substream; in snd_emu10k1x_midi_input_open()
1286 if (!(midi->midi_mode & EMU10K1X_MIDI_MODE_OUTPUT)) { in snd_emu10k1x_midi_input_open()
1287 spin_unlock_irqrestore(&midi->open_lock, flags); in snd_emu10k1x_midi_input_open()
1288 if (snd_emu10k1x_midi_cmd(emu, midi, MPU401_RESET, 1)) in snd_emu10k1x_midi_input_open()
1290 if (snd_emu10k1x_midi_cmd(emu, midi, MPU401_ENTER_UART, 1)) in snd_emu10k1x_midi_input_open()
1293 spin_unlock_irqrestore(&midi->open_lock, flags); in snd_emu10k1x_midi_input_open()
1304 struct emu10k1x_midi *midi = substream->rmidi->private_data; in snd_emu10k1x_midi_output_open() local
1307 emu = midi->emu; in snd_emu10k1x_midi_output_open()
1310 spin_lock_irqsave(&midi->open_lock, flags); in snd_emu10k1x_midi_output_open()
1311 midi->midi_mode |= EMU10K1X_MIDI_MODE_OUTPUT; in snd_emu10k1x_midi_output_open()
1312 midi->substream_output = substream; in snd_emu10k1x_midi_output_open()
1313 if (!(midi->midi_mode & EMU10K1X_MIDI_MODE_INPUT)) { in snd_emu10k1x_midi_output_open()
1314 spin_unlock_irqrestore(&midi->open_lock, flags); in snd_emu10k1x_midi_output_open()
1315 if (snd_emu10k1x_midi_cmd(emu, midi, MPU401_RESET, 1)) in snd_emu10k1x_midi_output_open()
1317 if (snd_emu10k1x_midi_cmd(emu, midi, MPU401_ENTER_UART, 1)) in snd_emu10k1x_midi_output_open()
1320 spin_unlock_irqrestore(&midi->open_lock, flags); in snd_emu10k1x_midi_output_open()
1331 struct emu10k1x_midi *midi = substream->rmidi->private_data; in snd_emu10k1x_midi_input_close() local
1335 emu = midi->emu; in snd_emu10k1x_midi_input_close()
1338 spin_lock_irqsave(&midi->open_lock, flags); in snd_emu10k1x_midi_input_close()
1339 snd_emu10k1x_intr_disable(emu, midi->rx_enable); in snd_emu10k1x_midi_input_close()
1340 midi->midi_mode &= ~EMU10K1X_MIDI_MODE_INPUT; in snd_emu10k1x_midi_input_close()
1341 midi->substream_input = NULL; in snd_emu10k1x_midi_input_close()
1342 if (!(midi->midi_mode & EMU10K1X_MIDI_MODE_OUTPUT)) { in snd_emu10k1x_midi_input_close()
1343 spin_unlock_irqrestore(&midi->open_lock, flags); in snd_emu10k1x_midi_input_close()
1344 err = snd_emu10k1x_midi_cmd(emu, midi, MPU401_RESET, 0); in snd_emu10k1x_midi_input_close()
1346 spin_unlock_irqrestore(&midi->open_lock, flags); in snd_emu10k1x_midi_input_close()
1354 struct emu10k1x_midi *midi = substream->rmidi->private_data; in snd_emu10k1x_midi_output_close() local
1358 emu = midi->emu; in snd_emu10k1x_midi_output_close()
1361 spin_lock_irqsave(&midi->open_lock, flags); in snd_emu10k1x_midi_output_close()
1362 snd_emu10k1x_intr_disable(emu, midi->tx_enable); in snd_emu10k1x_midi_output_close()
1363 midi->midi_mode &= ~EMU10K1X_MIDI_MODE_OUTPUT; in snd_emu10k1x_midi_output_close()
1364 midi->substream_output = NULL; in snd_emu10k1x_midi_output_close()
1365 if (!(midi->midi_mode & EMU10K1X_MIDI_MODE_INPUT)) { in snd_emu10k1x_midi_output_close()
1366 spin_unlock_irqrestore(&midi->open_lock, flags); in snd_emu10k1x_midi_output_close()
1367 err = snd_emu10k1x_midi_cmd(emu, midi, MPU401_RESET, 0); in snd_emu10k1x_midi_output_close()
1369 spin_unlock_irqrestore(&midi->open_lock, flags); in snd_emu10k1x_midi_output_close()
1377 struct emu10k1x_midi *midi = substream->rmidi->private_data; in snd_emu10k1x_midi_input_trigger() local
1378 emu = midi->emu; in snd_emu10k1x_midi_input_trigger()
1383 snd_emu10k1x_intr_enable(emu, midi->rx_enable); in snd_emu10k1x_midi_input_trigger()
1385 snd_emu10k1x_intr_disable(emu, midi->rx_enable); in snd_emu10k1x_midi_input_trigger()
1391 struct emu10k1x_midi *midi = substream->rmidi->private_data; in snd_emu10k1x_midi_output_trigger() local
1394 emu = midi->emu; in snd_emu10k1x_midi_output_trigger()
1403 spin_lock_irqsave(&midi->output_lock, flags); in snd_emu10k1x_midi_output_trigger()
1405 if (mpu401_output_ready(emu, midi)) { in snd_emu10k1x_midi_output_trigger()
1406 if (!(midi->midi_mode & EMU10K1X_MIDI_MODE_OUTPUT) || in snd_emu10k1x_midi_output_trigger()
1409 spin_unlock_irqrestore(&midi->output_lock, flags); in snd_emu10k1x_midi_output_trigger()
1412 mpu401_write_data(emu, midi, byte); in snd_emu10k1x_midi_output_trigger()
1418 spin_unlock_irqrestore(&midi->output_lock, flags); in snd_emu10k1x_midi_output_trigger()
1419 snd_emu10k1x_intr_enable(emu, midi->tx_enable); in snd_emu10k1x_midi_output_trigger()
1421 snd_emu10k1x_intr_disable(emu, midi->tx_enable); in snd_emu10k1x_midi_output_trigger()
1445 struct emu10k1x_midi *midi = rmidi->private_data; in snd_emu10k1x_midi_free() local
1446 midi->interrupt = NULL; in snd_emu10k1x_midi_free()
1447 midi->rmidi = NULL; in snd_emu10k1x_midi_free()
1451 struct emu10k1x_midi *midi, int device, in emu10k1x_midi_init() argument
1460 midi->emu = emu; in emu10k1x_midi_init()
1461 spin_lock_init(&midi->open_lock); in emu10k1x_midi_init()
1462 spin_lock_init(&midi->input_lock); in emu10k1x_midi_init()
1463 spin_lock_init(&midi->output_lock); in emu10k1x_midi_init()
1470 rmidi->private_data = midi; in emu10k1x_midi_init()
1472 midi->rmidi = rmidi; in emu10k1x_midi_init()
1478 struct emu10k1x_midi *midi = &emu->midi; in snd_emu10k1x_midi() local
1481 err = emu10k1x_midi_init(emu, midi, 0, "EMU10K1X MPU-401 (UART)"); in snd_emu10k1x_midi()
1485 midi->tx_enable = INTE_MIDITXENABLE; in snd_emu10k1x_midi()
1486 midi->rx_enable = INTE_MIDIRXENABLE; in snd_emu10k1x_midi()
1487 midi->port = MUDATA; in snd_emu10k1x_midi()
1488 midi->ipr_tx = IPR_MIDITRANSBUFEMPTY; in snd_emu10k1x_midi()
1489 midi->ipr_rx = IPR_MIDIRECVBUFEMPTY; in snd_emu10k1x_midi()
1490 midi->interrupt = snd_emu10k1x_midi_interrupt; in snd_emu10k1x_midi()