Lines Matching refs:midi
75 static void do_emu10k1_midi_interrupt(struct snd_emu10k1 *emu, struct snd_emu10k1_midi *midi, unsig… in do_emu10k1_midi_interrupt() argument
79 if (midi->rmidi == NULL) { in do_emu10k1_midi_interrupt()
80 snd_emu10k1_intr_disable(emu, midi->tx_enable | midi->rx_enable); in do_emu10k1_midi_interrupt()
84 spin_lock(&midi->input_lock); in do_emu10k1_midi_interrupt()
85 if ((status & midi->ipr_rx) && mpu401_input_avail(emu, midi)) { in do_emu10k1_midi_interrupt()
86 if (!(midi->midi_mode & EMU10K1_MIDI_MODE_INPUT)) { in do_emu10k1_midi_interrupt()
87 mpu401_clear_rx(emu, midi); in do_emu10k1_midi_interrupt()
89 byte = mpu401_read_data(emu, midi); in do_emu10k1_midi_interrupt()
90 if (midi->substream_input) in do_emu10k1_midi_interrupt()
91 snd_rawmidi_receive(midi->substream_input, &byte, 1); in do_emu10k1_midi_interrupt()
94 spin_unlock(&midi->input_lock); in do_emu10k1_midi_interrupt()
96 spin_lock(&midi->output_lock); in do_emu10k1_midi_interrupt()
97 if ((status & midi->ipr_tx) && mpu401_output_ready(emu, midi)) { in do_emu10k1_midi_interrupt()
98 if (midi->substream_output && in do_emu10k1_midi_interrupt()
99 snd_rawmidi_transmit(midi->substream_output, &byte, 1) == 1) { in do_emu10k1_midi_interrupt()
100 mpu401_write_data(emu, midi, byte); in do_emu10k1_midi_interrupt()
102 snd_emu10k1_intr_disable(emu, midi->tx_enable); in do_emu10k1_midi_interrupt()
105 spin_unlock(&midi->output_lock); in do_emu10k1_midi_interrupt()
110 do_emu10k1_midi_interrupt(emu, &emu->midi, status); in snd_emu10k1_midi_interrupt()
118 static int snd_emu10k1_midi_cmd(struct snd_emu10k1 * emu, struct snd_emu10k1_midi *midi, unsigned c… in snd_emu10k1_midi_cmd() argument
123 spin_lock_irqsave(&midi->input_lock, flags); in snd_emu10k1_midi_cmd()
124 mpu401_write_data(emu, midi, 0x00); in snd_emu10k1_midi_cmd()
127 mpu401_write_cmd(emu, midi, cmd); in snd_emu10k1_midi_cmd()
132 if (mpu401_input_avail(emu, midi)) { in snd_emu10k1_midi_cmd()
133 if (mpu401_read_data(emu, midi) == MPU401_ACK) in snd_emu10k1_midi_cmd()
137 if (!ok && mpu401_read_data(emu, midi) == MPU401_ACK) in snd_emu10k1_midi_cmd()
142 spin_unlock_irqrestore(&midi->input_lock, flags); in snd_emu10k1_midi_cmd()
146 mpu401_read_stat(emu, midi), in snd_emu10k1_midi_cmd()
147 mpu401_read_data(emu, midi)); in snd_emu10k1_midi_cmd()
156 struct snd_emu10k1_midi *midi = (struct snd_emu10k1_midi *)substream->rmidi->private_data; in snd_emu10k1_midi_input_open() local
159 emu = midi->emu; in snd_emu10k1_midi_input_open()
162 spin_lock_irqsave(&midi->open_lock, flags); in snd_emu10k1_midi_input_open()
163 midi->midi_mode |= EMU10K1_MIDI_MODE_INPUT; in snd_emu10k1_midi_input_open()
164 midi->substream_input = substream; in snd_emu10k1_midi_input_open()
165 if (!(midi->midi_mode & EMU10K1_MIDI_MODE_OUTPUT)) { in snd_emu10k1_midi_input_open()
166 spin_unlock_irqrestore(&midi->open_lock, flags); in snd_emu10k1_midi_input_open()
167 if (snd_emu10k1_midi_cmd(emu, midi, MPU401_RESET, 1)) in snd_emu10k1_midi_input_open()
169 if (snd_emu10k1_midi_cmd(emu, midi, MPU401_ENTER_UART, 1)) in snd_emu10k1_midi_input_open()
172 spin_unlock_irqrestore(&midi->open_lock, flags); in snd_emu10k1_midi_input_open()
183 struct snd_emu10k1_midi *midi = (struct snd_emu10k1_midi *)substream->rmidi->private_data; in snd_emu10k1_midi_output_open() local
186 emu = midi->emu; in snd_emu10k1_midi_output_open()
189 spin_lock_irqsave(&midi->open_lock, flags); in snd_emu10k1_midi_output_open()
190 midi->midi_mode |= EMU10K1_MIDI_MODE_OUTPUT; in snd_emu10k1_midi_output_open()
191 midi->substream_output = substream; in snd_emu10k1_midi_output_open()
192 if (!(midi->midi_mode & EMU10K1_MIDI_MODE_INPUT)) { in snd_emu10k1_midi_output_open()
193 spin_unlock_irqrestore(&midi->open_lock, flags); in snd_emu10k1_midi_output_open()
194 if (snd_emu10k1_midi_cmd(emu, midi, MPU401_RESET, 1)) in snd_emu10k1_midi_output_open()
196 if (snd_emu10k1_midi_cmd(emu, midi, MPU401_ENTER_UART, 1)) in snd_emu10k1_midi_output_open()
199 spin_unlock_irqrestore(&midi->open_lock, flags); in snd_emu10k1_midi_output_open()
210 struct snd_emu10k1_midi *midi = (struct snd_emu10k1_midi *)substream->rmidi->private_data; in snd_emu10k1_midi_input_close() local
214 emu = midi->emu; in snd_emu10k1_midi_input_close()
217 spin_lock_irqsave(&midi->open_lock, flags); in snd_emu10k1_midi_input_close()
218 snd_emu10k1_intr_disable(emu, midi->rx_enable); in snd_emu10k1_midi_input_close()
219 midi->midi_mode &= ~EMU10K1_MIDI_MODE_INPUT; in snd_emu10k1_midi_input_close()
220 midi->substream_input = NULL; in snd_emu10k1_midi_input_close()
221 if (!(midi->midi_mode & EMU10K1_MIDI_MODE_OUTPUT)) { in snd_emu10k1_midi_input_close()
222 spin_unlock_irqrestore(&midi->open_lock, flags); in snd_emu10k1_midi_input_close()
223 err = snd_emu10k1_midi_cmd(emu, midi, MPU401_RESET, 0); in snd_emu10k1_midi_input_close()
225 spin_unlock_irqrestore(&midi->open_lock, flags); in snd_emu10k1_midi_input_close()
233 struct snd_emu10k1_midi *midi = (struct snd_emu10k1_midi *)substream->rmidi->private_data; in snd_emu10k1_midi_output_close() local
237 emu = midi->emu; in snd_emu10k1_midi_output_close()
240 spin_lock_irqsave(&midi->open_lock, flags); in snd_emu10k1_midi_output_close()
241 snd_emu10k1_intr_disable(emu, midi->tx_enable); in snd_emu10k1_midi_output_close()
242 midi->midi_mode &= ~EMU10K1_MIDI_MODE_OUTPUT; in snd_emu10k1_midi_output_close()
243 midi->substream_output = NULL; in snd_emu10k1_midi_output_close()
244 if (!(midi->midi_mode & EMU10K1_MIDI_MODE_INPUT)) { in snd_emu10k1_midi_output_close()
245 spin_unlock_irqrestore(&midi->open_lock, flags); in snd_emu10k1_midi_output_close()
246 err = snd_emu10k1_midi_cmd(emu, midi, MPU401_RESET, 0); in snd_emu10k1_midi_output_close()
248 spin_unlock_irqrestore(&midi->open_lock, flags); in snd_emu10k1_midi_output_close()
256 struct snd_emu10k1_midi *midi = (struct snd_emu10k1_midi *)substream->rmidi->private_data; in snd_emu10k1_midi_input_trigger() local
257 emu = midi->emu; in snd_emu10k1_midi_input_trigger()
262 snd_emu10k1_intr_enable(emu, midi->rx_enable); in snd_emu10k1_midi_input_trigger()
264 snd_emu10k1_intr_disable(emu, midi->rx_enable); in snd_emu10k1_midi_input_trigger()
270 struct snd_emu10k1_midi *midi = (struct snd_emu10k1_midi *)substream->rmidi->private_data; in snd_emu10k1_midi_output_trigger() local
273 emu = midi->emu; in snd_emu10k1_midi_output_trigger()
282 spin_lock_irqsave(&midi->output_lock, flags); in snd_emu10k1_midi_output_trigger()
284 if (mpu401_output_ready(emu, midi)) { in snd_emu10k1_midi_output_trigger()
285 if (!(midi->midi_mode & EMU10K1_MIDI_MODE_OUTPUT) || in snd_emu10k1_midi_output_trigger()
288 spin_unlock_irqrestore(&midi->output_lock, flags); in snd_emu10k1_midi_output_trigger()
291 mpu401_write_data(emu, midi, byte); in snd_emu10k1_midi_output_trigger()
297 spin_unlock_irqrestore(&midi->output_lock, flags); in snd_emu10k1_midi_output_trigger()
298 snd_emu10k1_intr_enable(emu, midi->tx_enable); in snd_emu10k1_midi_output_trigger()
300 snd_emu10k1_intr_disable(emu, midi->tx_enable); in snd_emu10k1_midi_output_trigger()
324 struct snd_emu10k1_midi *midi = rmidi->private_data; in snd_emu10k1_midi_free() local
325 midi->interrupt = NULL; in snd_emu10k1_midi_free()
326 midi->rmidi = NULL; in snd_emu10k1_midi_free()
329 static int emu10k1_midi_init(struct snd_emu10k1 *emu, struct snd_emu10k1_midi *midi, int device, ch… in emu10k1_midi_init() argument
336 midi->emu = emu; in emu10k1_midi_init()
337 spin_lock_init(&midi->open_lock); in emu10k1_midi_init()
338 spin_lock_init(&midi->input_lock); in emu10k1_midi_init()
339 spin_lock_init(&midi->output_lock); in emu10k1_midi_init()
346 rmidi->private_data = midi; in emu10k1_midi_init()
348 midi->rmidi = rmidi; in emu10k1_midi_init()
354 struct snd_emu10k1_midi *midi = &emu->midi; in snd_emu10k1_midi() local
357 if ((err = emu10k1_midi_init(emu, midi, 0, "EMU10K1 MPU-401 (UART)")) < 0) in snd_emu10k1_midi()
360 midi->tx_enable = INTE_MIDITXENABLE; in snd_emu10k1_midi()
361 midi->rx_enable = INTE_MIDIRXENABLE; in snd_emu10k1_midi()
362 midi->port = MUDATA; in snd_emu10k1_midi()
363 midi->ipr_tx = IPR_MIDITRANSBUFEMPTY; in snd_emu10k1_midi()
364 midi->ipr_rx = IPR_MIDIRECVBUFEMPTY; in snd_emu10k1_midi()
365 midi->interrupt = snd_emu10k1_midi_interrupt; in snd_emu10k1_midi()
371 struct snd_emu10k1_midi *midi; in snd_emu10k1_audigy_midi() local
374 midi = &emu->midi; in snd_emu10k1_audigy_midi()
375 if ((err = emu10k1_midi_init(emu, midi, 0, "Audigy MPU-401 (UART)")) < 0) in snd_emu10k1_audigy_midi()
378 midi->tx_enable = INTE_MIDITXENABLE; in snd_emu10k1_audigy_midi()
379 midi->rx_enable = INTE_MIDIRXENABLE; in snd_emu10k1_audigy_midi()
380 midi->port = A_MUDATA1; in snd_emu10k1_audigy_midi()
381 midi->ipr_tx = IPR_MIDITRANSBUFEMPTY; in snd_emu10k1_audigy_midi()
382 midi->ipr_rx = IPR_MIDIRECVBUFEMPTY; in snd_emu10k1_audigy_midi()
383 midi->interrupt = snd_emu10k1_midi_interrupt; in snd_emu10k1_audigy_midi()
385 midi = &emu->midi2; in snd_emu10k1_audigy_midi()
386 if ((err = emu10k1_midi_init(emu, midi, 1, "Audigy MPU-401 #2")) < 0) in snd_emu10k1_audigy_midi()
389 midi->tx_enable = INTE_A_MIDITXENABLE2; in snd_emu10k1_audigy_midi()
390 midi->rx_enable = INTE_A_MIDIRXENABLE2; in snd_emu10k1_audigy_midi()
391 midi->port = A_MUDATA2; in snd_emu10k1_audigy_midi()
392 midi->ipr_tx = IPR_A_MIDITRANSBUFEMPTY2; in snd_emu10k1_audigy_midi()
393 midi->ipr_rx = IPR_A_MIDIRECVBUFEMPTY2; in snd_emu10k1_audigy_midi()
394 midi->interrupt = snd_emu10k1_midi_interrupt2; in snd_emu10k1_audigy_midi()