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
110 spin_lock_irqsave(&midi->input_lock, flags); in snd_emu10k1_midi_cmd()
111 mpu401_write_data(emu, midi, 0x00); in snd_emu10k1_midi_cmd()
114 mpu401_write_cmd(emu, midi, cmd); in snd_emu10k1_midi_cmd()
119 if (mpu401_input_avail(emu, midi)) { in snd_emu10k1_midi_cmd()
120 if (mpu401_read_data(emu, midi) == MPU401_ACK) in snd_emu10k1_midi_cmd()
124 if (!ok && mpu401_read_data(emu, midi) == MPU401_ACK) in snd_emu10k1_midi_cmd()
129 spin_unlock_irqrestore(&midi->input_lock, flags); in snd_emu10k1_midi_cmd()
134 mpu401_read_stat(emu, midi), in snd_emu10k1_midi_cmd()
135 mpu401_read_data(emu, midi)); in snd_emu10k1_midi_cmd()
144 struct snd_emu10k1_midi *midi = (struct snd_emu10k1_midi *)substream->rmidi->private_data; in snd_emu10k1_midi_input_open() local
147 emu = midi->emu; in snd_emu10k1_midi_input_open()
150 spin_lock_irqsave(&midi->open_lock, flags); in snd_emu10k1_midi_input_open()
151 midi->midi_mode |= EMU10K1_MIDI_MODE_INPUT; in snd_emu10k1_midi_input_open()
152 midi->substream_input = substream; in snd_emu10k1_midi_input_open()
153 if (!(midi->midi_mode & EMU10K1_MIDI_MODE_OUTPUT)) { in snd_emu10k1_midi_input_open()
154 spin_unlock_irqrestore(&midi->open_lock, flags); in snd_emu10k1_midi_input_open()
155 if (snd_emu10k1_midi_cmd(emu, midi, MPU401_RESET, 1)) in snd_emu10k1_midi_input_open()
157 if (snd_emu10k1_midi_cmd(emu, midi, MPU401_ENTER_UART, 1)) in snd_emu10k1_midi_input_open()
160 spin_unlock_irqrestore(&midi->open_lock, flags); in snd_emu10k1_midi_input_open()
171 struct snd_emu10k1_midi *midi = (struct snd_emu10k1_midi *)substream->rmidi->private_data; in snd_emu10k1_midi_output_open() local
174 emu = midi->emu; in snd_emu10k1_midi_output_open()
177 spin_lock_irqsave(&midi->open_lock, flags); in snd_emu10k1_midi_output_open()
178 midi->midi_mode |= EMU10K1_MIDI_MODE_OUTPUT; in snd_emu10k1_midi_output_open()
179 midi->substream_output = substream; in snd_emu10k1_midi_output_open()
180 if (!(midi->midi_mode & EMU10K1_MIDI_MODE_INPUT)) { in snd_emu10k1_midi_output_open()
181 spin_unlock_irqrestore(&midi->open_lock, flags); in snd_emu10k1_midi_output_open()
182 if (snd_emu10k1_midi_cmd(emu, midi, MPU401_RESET, 1)) in snd_emu10k1_midi_output_open()
184 if (snd_emu10k1_midi_cmd(emu, midi, MPU401_ENTER_UART, 1)) in snd_emu10k1_midi_output_open()
187 spin_unlock_irqrestore(&midi->open_lock, flags); in snd_emu10k1_midi_output_open()
198 struct snd_emu10k1_midi *midi = (struct snd_emu10k1_midi *)substream->rmidi->private_data; in snd_emu10k1_midi_input_close() local
202 emu = midi->emu; in snd_emu10k1_midi_input_close()
205 spin_lock_irqsave(&midi->open_lock, flags); in snd_emu10k1_midi_input_close()
206 snd_emu10k1_intr_disable(emu, midi->rx_enable); in snd_emu10k1_midi_input_close()
207 midi->midi_mode &= ~EMU10K1_MIDI_MODE_INPUT; in snd_emu10k1_midi_input_close()
208 midi->substream_input = NULL; in snd_emu10k1_midi_input_close()
209 if (!(midi->midi_mode & EMU10K1_MIDI_MODE_OUTPUT)) { in snd_emu10k1_midi_input_close()
210 spin_unlock_irqrestore(&midi->open_lock, flags); in snd_emu10k1_midi_input_close()
211 err = snd_emu10k1_midi_cmd(emu, midi, MPU401_RESET, 0); in snd_emu10k1_midi_input_close()
213 spin_unlock_irqrestore(&midi->open_lock, flags); in snd_emu10k1_midi_input_close()
221 struct snd_emu10k1_midi *midi = (struct snd_emu10k1_midi *)substream->rmidi->private_data; in snd_emu10k1_midi_output_close() local
225 emu = midi->emu; in snd_emu10k1_midi_output_close()
228 spin_lock_irqsave(&midi->open_lock, flags); in snd_emu10k1_midi_output_close()
229 snd_emu10k1_intr_disable(emu, midi->tx_enable); in snd_emu10k1_midi_output_close()
230 midi->midi_mode &= ~EMU10K1_MIDI_MODE_OUTPUT; in snd_emu10k1_midi_output_close()
231 midi->substream_output = NULL; in snd_emu10k1_midi_output_close()
232 if (!(midi->midi_mode & EMU10K1_MIDI_MODE_INPUT)) { in snd_emu10k1_midi_output_close()
233 spin_unlock_irqrestore(&midi->open_lock, flags); in snd_emu10k1_midi_output_close()
234 err = snd_emu10k1_midi_cmd(emu, midi, MPU401_RESET, 0); in snd_emu10k1_midi_output_close()
236 spin_unlock_irqrestore(&midi->open_lock, flags); in snd_emu10k1_midi_output_close()
244 struct snd_emu10k1_midi *midi = (struct snd_emu10k1_midi *)substream->rmidi->private_data; in snd_emu10k1_midi_input_trigger() local
245 emu = midi->emu; in snd_emu10k1_midi_input_trigger()
250 snd_emu10k1_intr_enable(emu, midi->rx_enable); in snd_emu10k1_midi_input_trigger()
252 snd_emu10k1_intr_disable(emu, midi->rx_enable); in snd_emu10k1_midi_input_trigger()
258 struct snd_emu10k1_midi *midi = (struct snd_emu10k1_midi *)substream->rmidi->private_data; in snd_emu10k1_midi_output_trigger() local
261 emu = midi->emu; in snd_emu10k1_midi_output_trigger()
270 spin_lock_irqsave(&midi->output_lock, flags); in snd_emu10k1_midi_output_trigger()
272 if (mpu401_output_ready(emu, midi)) { in snd_emu10k1_midi_output_trigger()
273 if (!(midi->midi_mode & EMU10K1_MIDI_MODE_OUTPUT) || in snd_emu10k1_midi_output_trigger()
276 spin_unlock_irqrestore(&midi->output_lock, flags); in snd_emu10k1_midi_output_trigger()
279 mpu401_write_data(emu, midi, byte); in snd_emu10k1_midi_output_trigger()
285 spin_unlock_irqrestore(&midi->output_lock, flags); in snd_emu10k1_midi_output_trigger()
286 snd_emu10k1_intr_enable(emu, midi->tx_enable); in snd_emu10k1_midi_output_trigger()
288 snd_emu10k1_intr_disable(emu, midi->tx_enable); in snd_emu10k1_midi_output_trigger()
312 struct snd_emu10k1_midi *midi = rmidi->private_data; in snd_emu10k1_midi_free() local
313 midi->interrupt = NULL; in snd_emu10k1_midi_free()
314 midi->rmidi = NULL; in snd_emu10k1_midi_free()
317 static int emu10k1_midi_init(struct snd_emu10k1 *emu, struct snd_emu10k1_midi *midi, int device, ch… in emu10k1_midi_init() argument
325 midi->emu = emu; in emu10k1_midi_init()
326 spin_lock_init(&midi->open_lock); in emu10k1_midi_init()
327 spin_lock_init(&midi->input_lock); in emu10k1_midi_init()
328 spin_lock_init(&midi->output_lock); in emu10k1_midi_init()
335 rmidi->private_data = midi; in emu10k1_midi_init()
337 midi->rmidi = rmidi; in emu10k1_midi_init()
343 struct snd_emu10k1_midi *midi = &emu->midi; in snd_emu10k1_midi() local
346 err = emu10k1_midi_init(emu, midi, 0, "EMU10K1 MPU-401 (UART)"); in snd_emu10k1_midi()
350 midi->tx_enable = INTE_MIDITXENABLE; in snd_emu10k1_midi()
351 midi->rx_enable = INTE_MIDIRXENABLE; in snd_emu10k1_midi()
352 midi->port = MUDATA; in snd_emu10k1_midi()
353 midi->ipr_tx = IPR_MIDITRANSBUFEMPTY; in snd_emu10k1_midi()
354 midi->ipr_rx = IPR_MIDIRECVBUFEMPTY; in snd_emu10k1_midi()
355 midi->interrupt = snd_emu10k1_midi_interrupt; in snd_emu10k1_midi()
361 struct snd_emu10k1_midi *midi; in snd_emu10k1_audigy_midi() local
364 midi = &emu->midi; in snd_emu10k1_audigy_midi()
365 err = emu10k1_midi_init(emu, midi, 0, "Audigy MPU-401 (UART)"); in snd_emu10k1_audigy_midi()
369 midi->tx_enable = INTE_MIDITXENABLE; in snd_emu10k1_audigy_midi()
370 midi->rx_enable = INTE_MIDIRXENABLE; in snd_emu10k1_audigy_midi()
371 midi->port = A_MUDATA1; in snd_emu10k1_audigy_midi()
372 midi->ipr_tx = IPR_MIDITRANSBUFEMPTY; in snd_emu10k1_audigy_midi()
373 midi->ipr_rx = IPR_MIDIRECVBUFEMPTY; in snd_emu10k1_audigy_midi()
374 midi->interrupt = snd_emu10k1_midi_interrupt; in snd_emu10k1_audigy_midi()
376 midi = &emu->midi2; in snd_emu10k1_audigy_midi()
377 err = emu10k1_midi_init(emu, midi, 1, "Audigy MPU-401 #2"); in snd_emu10k1_audigy_midi()
381 midi->tx_enable = INTE_A_MIDITXENABLE2; in snd_emu10k1_audigy_midi()
382 midi->rx_enable = INTE_A_MIDIRXENABLE2; in snd_emu10k1_audigy_midi()
383 midi->port = A_MUDATA2; in snd_emu10k1_audigy_midi()
384 midi->ipr_tx = IPR_A_MIDITRANSBUFEMPTY2; in snd_emu10k1_audigy_midi()
385 midi->ipr_rx = IPR_A_MIDIRECVBUFEMPTY2; in snd_emu10k1_audigy_midi()
386 midi->interrupt = snd_emu10k1_midi_interrupt2; in snd_emu10k1_audigy_midi()