Lines Matching refs:midi
62 static void do_emu10k1_midi_interrupt(struct snd_emu10k1 *emu, struct snd_emu10k1_midi *midi, unsig… in do_emu10k1_midi_interrupt() argument
66 if (midi->rmidi == NULL) { in do_emu10k1_midi_interrupt()
67 snd_emu10k1_intr_disable(emu, midi->tx_enable | midi->rx_enable); in do_emu10k1_midi_interrupt()
71 spin_lock(&midi->input_lock); in do_emu10k1_midi_interrupt()
72 if ((status & midi->ipr_rx) && mpu401_input_avail(emu, midi)) { in do_emu10k1_midi_interrupt()
73 if (!(midi->midi_mode & EMU10K1_MIDI_MODE_INPUT)) { in do_emu10k1_midi_interrupt()
74 mpu401_clear_rx(emu, midi); in do_emu10k1_midi_interrupt()
76 byte = mpu401_read_data(emu, midi); in do_emu10k1_midi_interrupt()
77 if (midi->substream_input) in do_emu10k1_midi_interrupt()
78 snd_rawmidi_receive(midi->substream_input, &byte, 1); in do_emu10k1_midi_interrupt()
81 spin_unlock(&midi->input_lock); in do_emu10k1_midi_interrupt()
83 spin_lock(&midi->output_lock); in do_emu10k1_midi_interrupt()
84 if ((status & midi->ipr_tx) && mpu401_output_ready(emu, midi)) { in do_emu10k1_midi_interrupt()
85 if (midi->substream_output && in do_emu10k1_midi_interrupt()
86 snd_rawmidi_transmit(midi->substream_output, &byte, 1) == 1) { in do_emu10k1_midi_interrupt()
87 mpu401_write_data(emu, midi, byte); in do_emu10k1_midi_interrupt()
89 snd_emu10k1_intr_disable(emu, midi->tx_enable); in do_emu10k1_midi_interrupt()
92 spin_unlock(&midi->output_lock); in do_emu10k1_midi_interrupt()
97 do_emu10k1_midi_interrupt(emu, &emu->midi, status); in snd_emu10k1_midi_interrupt()
105 static int snd_emu10k1_midi_cmd(struct snd_emu10k1 * emu, struct snd_emu10k1_midi *midi, unsigned c… in snd_emu10k1_midi_cmd() argument
109 spin_lock_irq(&midi->input_lock); in snd_emu10k1_midi_cmd()
110 mpu401_write_data(emu, midi, 0x00); in snd_emu10k1_midi_cmd()
113 mpu401_write_cmd(emu, midi, cmd); in snd_emu10k1_midi_cmd()
118 if (mpu401_input_avail(emu, midi)) { in snd_emu10k1_midi_cmd()
119 if (mpu401_read_data(emu, midi) == MPU401_ACK) in snd_emu10k1_midi_cmd()
123 if (!ok && mpu401_read_data(emu, midi) == MPU401_ACK) in snd_emu10k1_midi_cmd()
128 spin_unlock_irq(&midi->input_lock); in snd_emu10k1_midi_cmd()
133 mpu401_read_stat(emu, midi), in snd_emu10k1_midi_cmd()
134 mpu401_read_data(emu, midi)); in snd_emu10k1_midi_cmd()
143 struct snd_emu10k1_midi *midi = (struct snd_emu10k1_midi *)substream->rmidi->private_data; in snd_emu10k1_midi_input_open() local
145 emu = midi->emu; in snd_emu10k1_midi_input_open()
148 spin_lock_irq(&midi->open_lock); in snd_emu10k1_midi_input_open()
149 midi->midi_mode |= EMU10K1_MIDI_MODE_INPUT; in snd_emu10k1_midi_input_open()
150 midi->substream_input = substream; in snd_emu10k1_midi_input_open()
151 if (!(midi->midi_mode & EMU10K1_MIDI_MODE_OUTPUT)) { in snd_emu10k1_midi_input_open()
152 spin_unlock_irq(&midi->open_lock); in snd_emu10k1_midi_input_open()
153 if (snd_emu10k1_midi_cmd(emu, midi, MPU401_RESET, 1)) in snd_emu10k1_midi_input_open()
155 if (snd_emu10k1_midi_cmd(emu, midi, MPU401_ENTER_UART, 1)) in snd_emu10k1_midi_input_open()
158 spin_unlock_irq(&midi->open_lock); in snd_emu10k1_midi_input_open()
169 struct snd_emu10k1_midi *midi = (struct snd_emu10k1_midi *)substream->rmidi->private_data; in snd_emu10k1_midi_output_open() local
171 emu = midi->emu; in snd_emu10k1_midi_output_open()
174 spin_lock_irq(&midi->open_lock); in snd_emu10k1_midi_output_open()
175 midi->midi_mode |= EMU10K1_MIDI_MODE_OUTPUT; in snd_emu10k1_midi_output_open()
176 midi->substream_output = substream; in snd_emu10k1_midi_output_open()
177 if (!(midi->midi_mode & EMU10K1_MIDI_MODE_INPUT)) { in snd_emu10k1_midi_output_open()
178 spin_unlock_irq(&midi->open_lock); in snd_emu10k1_midi_output_open()
179 if (snd_emu10k1_midi_cmd(emu, midi, MPU401_RESET, 1)) in snd_emu10k1_midi_output_open()
181 if (snd_emu10k1_midi_cmd(emu, midi, MPU401_ENTER_UART, 1)) in snd_emu10k1_midi_output_open()
184 spin_unlock_irq(&midi->open_lock); in snd_emu10k1_midi_output_open()
195 struct snd_emu10k1_midi *midi = (struct snd_emu10k1_midi *)substream->rmidi->private_data; in snd_emu10k1_midi_input_close() local
198 emu = midi->emu; in snd_emu10k1_midi_input_close()
201 spin_lock_irq(&midi->open_lock); in snd_emu10k1_midi_input_close()
202 snd_emu10k1_intr_disable(emu, midi->rx_enable); in snd_emu10k1_midi_input_close()
203 midi->midi_mode &= ~EMU10K1_MIDI_MODE_INPUT; in snd_emu10k1_midi_input_close()
204 midi->substream_input = NULL; in snd_emu10k1_midi_input_close()
205 if (!(midi->midi_mode & EMU10K1_MIDI_MODE_OUTPUT)) { in snd_emu10k1_midi_input_close()
206 spin_unlock_irq(&midi->open_lock); in snd_emu10k1_midi_input_close()
207 err = snd_emu10k1_midi_cmd(emu, midi, MPU401_RESET, 0); in snd_emu10k1_midi_input_close()
209 spin_unlock_irq(&midi->open_lock); in snd_emu10k1_midi_input_close()
217 struct snd_emu10k1_midi *midi = (struct snd_emu10k1_midi *)substream->rmidi->private_data; in snd_emu10k1_midi_output_close() local
220 emu = midi->emu; in snd_emu10k1_midi_output_close()
223 spin_lock_irq(&midi->open_lock); in snd_emu10k1_midi_output_close()
224 snd_emu10k1_intr_disable(emu, midi->tx_enable); in snd_emu10k1_midi_output_close()
225 midi->midi_mode &= ~EMU10K1_MIDI_MODE_OUTPUT; in snd_emu10k1_midi_output_close()
226 midi->substream_output = NULL; in snd_emu10k1_midi_output_close()
227 if (!(midi->midi_mode & EMU10K1_MIDI_MODE_INPUT)) { in snd_emu10k1_midi_output_close()
228 spin_unlock_irq(&midi->open_lock); in snd_emu10k1_midi_output_close()
229 err = snd_emu10k1_midi_cmd(emu, midi, MPU401_RESET, 0); in snd_emu10k1_midi_output_close()
231 spin_unlock_irq(&midi->open_lock); in snd_emu10k1_midi_output_close()
239 struct snd_emu10k1_midi *midi = (struct snd_emu10k1_midi *)substream->rmidi->private_data; in snd_emu10k1_midi_input_trigger() local
240 emu = midi->emu; in snd_emu10k1_midi_input_trigger()
245 snd_emu10k1_intr_enable(emu, midi->rx_enable); in snd_emu10k1_midi_input_trigger()
247 snd_emu10k1_intr_disable(emu, midi->rx_enable); in snd_emu10k1_midi_input_trigger()
253 struct snd_emu10k1_midi *midi = (struct snd_emu10k1_midi *)substream->rmidi->private_data; in snd_emu10k1_midi_output_trigger() local
255 emu = midi->emu; in snd_emu10k1_midi_output_trigger()
264 spin_lock_irq(&midi->output_lock); in snd_emu10k1_midi_output_trigger()
266 if (mpu401_output_ready(emu, midi)) { in snd_emu10k1_midi_output_trigger()
267 if (!(midi->midi_mode & EMU10K1_MIDI_MODE_OUTPUT) || in snd_emu10k1_midi_output_trigger()
270 spin_unlock_irq(&midi->output_lock); in snd_emu10k1_midi_output_trigger()
273 mpu401_write_data(emu, midi, byte); in snd_emu10k1_midi_output_trigger()
279 spin_unlock_irq(&midi->output_lock); in snd_emu10k1_midi_output_trigger()
280 snd_emu10k1_intr_enable(emu, midi->tx_enable); in snd_emu10k1_midi_output_trigger()
282 snd_emu10k1_intr_disable(emu, midi->tx_enable); in snd_emu10k1_midi_output_trigger()
306 struct snd_emu10k1_midi *midi = rmidi->private_data; in snd_emu10k1_midi_free() local
307 midi->interrupt = NULL; in snd_emu10k1_midi_free()
308 midi->rmidi = NULL; in snd_emu10k1_midi_free()
311 static int emu10k1_midi_init(struct snd_emu10k1 *emu, struct snd_emu10k1_midi *midi, int device, ch… in emu10k1_midi_init() argument
319 midi->emu = emu; in emu10k1_midi_init()
320 spin_lock_init(&midi->open_lock); in emu10k1_midi_init()
321 spin_lock_init(&midi->input_lock); in emu10k1_midi_init()
322 spin_lock_init(&midi->output_lock); in emu10k1_midi_init()
329 rmidi->private_data = midi; in emu10k1_midi_init()
331 midi->rmidi = rmidi; in emu10k1_midi_init()
337 struct snd_emu10k1_midi *midi = &emu->midi; in snd_emu10k1_midi() local
340 err = emu10k1_midi_init(emu, midi, 0, "EMU10K1 MPU-401 (UART)"); in snd_emu10k1_midi()
344 midi->tx_enable = INTE_MIDITXENABLE; in snd_emu10k1_midi()
345 midi->rx_enable = INTE_MIDIRXENABLE; in snd_emu10k1_midi()
346 midi->port = MUDATA; in snd_emu10k1_midi()
347 midi->ipr_tx = IPR_MIDITRANSBUFEMPTY; in snd_emu10k1_midi()
348 midi->ipr_rx = IPR_MIDIRECVBUFEMPTY; in snd_emu10k1_midi()
349 midi->interrupt = snd_emu10k1_midi_interrupt; in snd_emu10k1_midi()
355 struct snd_emu10k1_midi *midi; in snd_emu10k1_audigy_midi() local
358 midi = &emu->midi; in snd_emu10k1_audigy_midi()
359 err = emu10k1_midi_init(emu, midi, 0, "Audigy MPU-401 (UART)"); in snd_emu10k1_audigy_midi()
363 midi->tx_enable = INTE_MIDITXENABLE; in snd_emu10k1_audigy_midi()
364 midi->rx_enable = INTE_MIDIRXENABLE; in snd_emu10k1_audigy_midi()
365 midi->port = A_MUDATA1; in snd_emu10k1_audigy_midi()
366 midi->ipr_tx = IPR_MIDITRANSBUFEMPTY; in snd_emu10k1_audigy_midi()
367 midi->ipr_rx = IPR_MIDIRECVBUFEMPTY; in snd_emu10k1_audigy_midi()
368 midi->interrupt = snd_emu10k1_midi_interrupt; in snd_emu10k1_audigy_midi()
370 midi = &emu->midi2; in snd_emu10k1_audigy_midi()
371 err = emu10k1_midi_init(emu, midi, 1, "Audigy MPU-401 #2"); in snd_emu10k1_audigy_midi()
375 midi->tx_enable = INTE_A_MIDITXENABLE2; in snd_emu10k1_audigy_midi()
376 midi->rx_enable = INTE_A_MIDIRXENABLE2; in snd_emu10k1_audigy_midi()
377 midi->port = A_MUDATA2; in snd_emu10k1_audigy_midi()
378 midi->ipr_tx = IPR_A_MIDITRANSBUFEMPTY2; in snd_emu10k1_audigy_midi()
379 midi->ipr_rx = IPR_A_MIDIRECVBUFEMPTY2; in snd_emu10k1_audigy_midi()
380 midi->interrupt = snd_emu10k1_midi_interrupt2; in snd_emu10k1_audigy_midi()