emumpu401.c (c1f3ee120bb61045b1c0a3ead620d1d65af47130) | emumpu401.c (da3cec35dd3c31d8706db4bf379372ce70d92118) |
---|---|
1/* 2 * Copyright (c) by Jaroslav Kysela <perex@perex.cz> 3 * Routines for control of EMU10K1 MPU-401 in UART mode 4 * 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or --- 143 unchanged lines hidden (view full) --- 152 153static int snd_emu10k1_midi_input_open(struct snd_rawmidi_substream *substream) 154{ 155 struct snd_emu10k1 *emu; 156 struct snd_emu10k1_midi *midi = (struct snd_emu10k1_midi *)substream->rmidi->private_data; 157 unsigned long flags; 158 159 emu = midi->emu; | 1/* 2 * Copyright (c) by Jaroslav Kysela <perex@perex.cz> 3 * Routines for control of EMU10K1 MPU-401 in UART mode 4 * 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or --- 143 unchanged lines hidden (view full) --- 152 153static int snd_emu10k1_midi_input_open(struct snd_rawmidi_substream *substream) 154{ 155 struct snd_emu10k1 *emu; 156 struct snd_emu10k1_midi *midi = (struct snd_emu10k1_midi *)substream->rmidi->private_data; 157 unsigned long flags; 158 159 emu = midi->emu; |
160 snd_assert(emu, return -ENXIO); | 160 if (snd_BUG_ON(!emu)) 161 return -ENXIO; |
161 spin_lock_irqsave(&midi->open_lock, flags); 162 midi->midi_mode |= EMU10K1_MIDI_MODE_INPUT; 163 midi->substream_input = substream; 164 if (!(midi->midi_mode & EMU10K1_MIDI_MODE_OUTPUT)) { 165 spin_unlock_irqrestore(&midi->open_lock, flags); 166 if (snd_emu10k1_midi_cmd(emu, midi, MPU401_RESET, 1)) 167 goto error_out; 168 if (snd_emu10k1_midi_cmd(emu, midi, MPU401_ENTER_UART, 1)) --- 9 unchanged lines hidden (view full) --- 178 179static int snd_emu10k1_midi_output_open(struct snd_rawmidi_substream *substream) 180{ 181 struct snd_emu10k1 *emu; 182 struct snd_emu10k1_midi *midi = (struct snd_emu10k1_midi *)substream->rmidi->private_data; 183 unsigned long flags; 184 185 emu = midi->emu; | 162 spin_lock_irqsave(&midi->open_lock, flags); 163 midi->midi_mode |= EMU10K1_MIDI_MODE_INPUT; 164 midi->substream_input = substream; 165 if (!(midi->midi_mode & EMU10K1_MIDI_MODE_OUTPUT)) { 166 spin_unlock_irqrestore(&midi->open_lock, flags); 167 if (snd_emu10k1_midi_cmd(emu, midi, MPU401_RESET, 1)) 168 goto error_out; 169 if (snd_emu10k1_midi_cmd(emu, midi, MPU401_ENTER_UART, 1)) --- 9 unchanged lines hidden (view full) --- 179 180static int snd_emu10k1_midi_output_open(struct snd_rawmidi_substream *substream) 181{ 182 struct snd_emu10k1 *emu; 183 struct snd_emu10k1_midi *midi = (struct snd_emu10k1_midi *)substream->rmidi->private_data; 184 unsigned long flags; 185 186 emu = midi->emu; |
186 snd_assert(emu, return -ENXIO); | 187 if (snd_BUG_ON(!emu)) 188 return -ENXIO; |
187 spin_lock_irqsave(&midi->open_lock, flags); 188 midi->midi_mode |= EMU10K1_MIDI_MODE_OUTPUT; 189 midi->substream_output = substream; 190 if (!(midi->midi_mode & EMU10K1_MIDI_MODE_INPUT)) { 191 spin_unlock_irqrestore(&midi->open_lock, flags); 192 if (snd_emu10k1_midi_cmd(emu, midi, MPU401_RESET, 1)) 193 goto error_out; 194 if (snd_emu10k1_midi_cmd(emu, midi, MPU401_ENTER_UART, 1)) --- 10 unchanged lines hidden (view full) --- 205static int snd_emu10k1_midi_input_close(struct snd_rawmidi_substream *substream) 206{ 207 struct snd_emu10k1 *emu; 208 struct snd_emu10k1_midi *midi = (struct snd_emu10k1_midi *)substream->rmidi->private_data; 209 unsigned long flags; 210 int err = 0; 211 212 emu = midi->emu; | 189 spin_lock_irqsave(&midi->open_lock, flags); 190 midi->midi_mode |= EMU10K1_MIDI_MODE_OUTPUT; 191 midi->substream_output = substream; 192 if (!(midi->midi_mode & EMU10K1_MIDI_MODE_INPUT)) { 193 spin_unlock_irqrestore(&midi->open_lock, flags); 194 if (snd_emu10k1_midi_cmd(emu, midi, MPU401_RESET, 1)) 195 goto error_out; 196 if (snd_emu10k1_midi_cmd(emu, midi, MPU401_ENTER_UART, 1)) --- 10 unchanged lines hidden (view full) --- 207static int snd_emu10k1_midi_input_close(struct snd_rawmidi_substream *substream) 208{ 209 struct snd_emu10k1 *emu; 210 struct snd_emu10k1_midi *midi = (struct snd_emu10k1_midi *)substream->rmidi->private_data; 211 unsigned long flags; 212 int err = 0; 213 214 emu = midi->emu; |
213 snd_assert(emu, return -ENXIO); | 215 if (snd_BUG_ON(!emu)) 216 return -ENXIO; |
214 spin_lock_irqsave(&midi->open_lock, flags); 215 snd_emu10k1_intr_disable(emu, midi->rx_enable); 216 midi->midi_mode &= ~EMU10K1_MIDI_MODE_INPUT; 217 midi->substream_input = NULL; 218 if (!(midi->midi_mode & EMU10K1_MIDI_MODE_OUTPUT)) { 219 spin_unlock_irqrestore(&midi->open_lock, flags); 220 err = snd_emu10k1_midi_cmd(emu, midi, MPU401_RESET, 0); 221 } else { --- 5 unchanged lines hidden (view full) --- 227static int snd_emu10k1_midi_output_close(struct snd_rawmidi_substream *substream) 228{ 229 struct snd_emu10k1 *emu; 230 struct snd_emu10k1_midi *midi = (struct snd_emu10k1_midi *)substream->rmidi->private_data; 231 unsigned long flags; 232 int err = 0; 233 234 emu = midi->emu; | 217 spin_lock_irqsave(&midi->open_lock, flags); 218 snd_emu10k1_intr_disable(emu, midi->rx_enable); 219 midi->midi_mode &= ~EMU10K1_MIDI_MODE_INPUT; 220 midi->substream_input = NULL; 221 if (!(midi->midi_mode & EMU10K1_MIDI_MODE_OUTPUT)) { 222 spin_unlock_irqrestore(&midi->open_lock, flags); 223 err = snd_emu10k1_midi_cmd(emu, midi, MPU401_RESET, 0); 224 } else { --- 5 unchanged lines hidden (view full) --- 230static int snd_emu10k1_midi_output_close(struct snd_rawmidi_substream *substream) 231{ 232 struct snd_emu10k1 *emu; 233 struct snd_emu10k1_midi *midi = (struct snd_emu10k1_midi *)substream->rmidi->private_data; 234 unsigned long flags; 235 int err = 0; 236 237 emu = midi->emu; |
235 snd_assert(emu, return -ENXIO); | 238 if (snd_BUG_ON(!emu)) 239 return -ENXIO; |
236 spin_lock_irqsave(&midi->open_lock, flags); 237 snd_emu10k1_intr_disable(emu, midi->tx_enable); 238 midi->midi_mode &= ~EMU10K1_MIDI_MODE_OUTPUT; 239 midi->substream_output = NULL; 240 if (!(midi->midi_mode & EMU10K1_MIDI_MODE_INPUT)) { 241 spin_unlock_irqrestore(&midi->open_lock, flags); 242 err = snd_emu10k1_midi_cmd(emu, midi, MPU401_RESET, 0); 243 } else { 244 spin_unlock_irqrestore(&midi->open_lock, flags); 245 } 246 return err; 247} 248 249static void snd_emu10k1_midi_input_trigger(struct snd_rawmidi_substream *substream, int up) 250{ 251 struct snd_emu10k1 *emu; 252 struct snd_emu10k1_midi *midi = (struct snd_emu10k1_midi *)substream->rmidi->private_data; 253 emu = midi->emu; | 240 spin_lock_irqsave(&midi->open_lock, flags); 241 snd_emu10k1_intr_disable(emu, midi->tx_enable); 242 midi->midi_mode &= ~EMU10K1_MIDI_MODE_OUTPUT; 243 midi->substream_output = NULL; 244 if (!(midi->midi_mode & EMU10K1_MIDI_MODE_INPUT)) { 245 spin_unlock_irqrestore(&midi->open_lock, flags); 246 err = snd_emu10k1_midi_cmd(emu, midi, MPU401_RESET, 0); 247 } else { 248 spin_unlock_irqrestore(&midi->open_lock, flags); 249 } 250 return err; 251} 252 253static void snd_emu10k1_midi_input_trigger(struct snd_rawmidi_substream *substream, int up) 254{ 255 struct snd_emu10k1 *emu; 256 struct snd_emu10k1_midi *midi = (struct snd_emu10k1_midi *)substream->rmidi->private_data; 257 emu = midi->emu; |
254 snd_assert(emu, return); | 258 if (snd_BUG_ON(!emu)) 259 return; |
255 256 if (up) 257 snd_emu10k1_intr_enable(emu, midi->rx_enable); 258 else 259 snd_emu10k1_intr_disable(emu, midi->rx_enable); 260} 261 262static void snd_emu10k1_midi_output_trigger(struct snd_rawmidi_substream *substream, int up) 263{ 264 struct snd_emu10k1 *emu; 265 struct snd_emu10k1_midi *midi = (struct snd_emu10k1_midi *)substream->rmidi->private_data; 266 unsigned long flags; 267 268 emu = midi->emu; | 260 261 if (up) 262 snd_emu10k1_intr_enable(emu, midi->rx_enable); 263 else 264 snd_emu10k1_intr_disable(emu, midi->rx_enable); 265} 266 267static void snd_emu10k1_midi_output_trigger(struct snd_rawmidi_substream *substream, int up) 268{ 269 struct snd_emu10k1 *emu; 270 struct snd_emu10k1_midi *midi = (struct snd_emu10k1_midi *)substream->rmidi->private_data; 271 unsigned long flags; 272 273 emu = midi->emu; |
269 snd_assert(emu, return); | 274 if (snd_BUG_ON(!emu)) 275 return; |
270 271 if (up) { 272 int max = 4; 273 unsigned char byte; 274 275 /* try to send some amount of bytes here before interrupts */ 276 spin_lock_irqsave(&midi->output_lock, flags); 277 while (max > 0) { --- 113 unchanged lines hidden --- | 276 277 if (up) { 278 int max = 4; 279 unsigned char byte; 280 281 /* try to send some amount of bytes here before interrupts */ 282 spin_lock_irqsave(&midi->output_lock, flags); 283 while (max > 0) { --- 113 unchanged lines hidden --- |