Lines Matching +full:dsp +full:- +full:reset

1 // SPDX-License-Identifier: GPL-2.0-or-later
4 * Routines for control of SoundBlaster cards - MIDI interface
6 * --
13 * Added full duplex UART mode for DSP version 2.0 and later.
31 rmidi = chip->rmidi; in snd_sb8dsp_midi_interrupt()
37 spin_lock(&chip->midi_input_lock); in snd_sb8dsp_midi_interrupt()
38 while (max-- > 0) { in snd_sb8dsp_midi_interrupt()
41 if (chip->open & SB_OPEN_MIDI_INPUT_TRIGGER) { in snd_sb8dsp_midi_interrupt()
42 snd_rawmidi_receive(chip->midi_substream_input, &byte, 1); in snd_sb8dsp_midi_interrupt()
46 spin_unlock(&chip->midi_input_lock); in snd_sb8dsp_midi_interrupt()
56 chip = substream->rmidi->private_data; in snd_sb8dsp_midi_input_open()
57 valid_open_flags = chip->hardware >= SB_HW_20 in snd_sb8dsp_midi_input_open()
59 spin_lock_irqsave(&chip->open_lock, flags); in snd_sb8dsp_midi_input_open()
60 if (chip->open & ~valid_open_flags) { in snd_sb8dsp_midi_input_open()
61 spin_unlock_irqrestore(&chip->open_lock, flags); in snd_sb8dsp_midi_input_open()
62 return -EAGAIN; in snd_sb8dsp_midi_input_open()
64 chip->open |= SB_OPEN_MIDI_INPUT; in snd_sb8dsp_midi_input_open()
65 chip->midi_substream_input = substream; in snd_sb8dsp_midi_input_open()
66 if (!(chip->open & SB_OPEN_MIDI_OUTPUT)) { in snd_sb8dsp_midi_input_open()
67 spin_unlock_irqrestore(&chip->open_lock, flags); in snd_sb8dsp_midi_input_open()
68 snd_sbdsp_reset(chip); /* reset DSP */ in snd_sb8dsp_midi_input_open()
69 if (chip->hardware >= SB_HW_20) in snd_sb8dsp_midi_input_open()
72 spin_unlock_irqrestore(&chip->open_lock, flags); in snd_sb8dsp_midi_input_open()
83 chip = substream->rmidi->private_data; in snd_sb8dsp_midi_output_open()
84 valid_open_flags = chip->hardware >= SB_HW_20 in snd_sb8dsp_midi_output_open()
86 spin_lock_irqsave(&chip->open_lock, flags); in snd_sb8dsp_midi_output_open()
87 if (chip->open & ~valid_open_flags) { in snd_sb8dsp_midi_output_open()
88 spin_unlock_irqrestore(&chip->open_lock, flags); in snd_sb8dsp_midi_output_open()
89 return -EAGAIN; in snd_sb8dsp_midi_output_open()
91 chip->open |= SB_OPEN_MIDI_OUTPUT; in snd_sb8dsp_midi_output_open()
92 chip->midi_substream_output = substream; in snd_sb8dsp_midi_output_open()
93 if (!(chip->open & SB_OPEN_MIDI_INPUT)) { in snd_sb8dsp_midi_output_open()
94 spin_unlock_irqrestore(&chip->open_lock, flags); in snd_sb8dsp_midi_output_open()
95 snd_sbdsp_reset(chip); /* reset DSP */ in snd_sb8dsp_midi_output_open()
96 if (chip->hardware >= SB_HW_20) in snd_sb8dsp_midi_output_open()
99 spin_unlock_irqrestore(&chip->open_lock, flags); in snd_sb8dsp_midi_output_open()
109 chip = substream->rmidi->private_data; in snd_sb8dsp_midi_input_close()
110 spin_lock_irqsave(&chip->open_lock, flags); in snd_sb8dsp_midi_input_close()
111 chip->open &= ~(SB_OPEN_MIDI_INPUT | SB_OPEN_MIDI_INPUT_TRIGGER); in snd_sb8dsp_midi_input_close()
112 chip->midi_substream_input = NULL; in snd_sb8dsp_midi_input_close()
113 if (!(chip->open & SB_OPEN_MIDI_OUTPUT)) { in snd_sb8dsp_midi_input_close()
114 spin_unlock_irqrestore(&chip->open_lock, flags); in snd_sb8dsp_midi_input_close()
115 snd_sbdsp_reset(chip); /* reset DSP */ in snd_sb8dsp_midi_input_close()
117 spin_unlock_irqrestore(&chip->open_lock, flags); in snd_sb8dsp_midi_input_close()
127 chip = substream->rmidi->private_data; in snd_sb8dsp_midi_output_close()
128 del_timer_sync(&chip->midi_timer); in snd_sb8dsp_midi_output_close()
129 spin_lock_irqsave(&chip->open_lock, flags); in snd_sb8dsp_midi_output_close()
130 chip->open &= ~(SB_OPEN_MIDI_OUTPUT | SB_OPEN_MIDI_OUTPUT_TRIGGER); in snd_sb8dsp_midi_output_close()
131 chip->midi_substream_output = NULL; in snd_sb8dsp_midi_output_close()
132 if (!(chip->open & SB_OPEN_MIDI_INPUT)) { in snd_sb8dsp_midi_output_close()
133 spin_unlock_irqrestore(&chip->open_lock, flags); in snd_sb8dsp_midi_output_close()
134 snd_sbdsp_reset(chip); /* reset DSP */ in snd_sb8dsp_midi_output_close()
136 spin_unlock_irqrestore(&chip->open_lock, flags); in snd_sb8dsp_midi_output_close()
146 chip = substream->rmidi->private_data; in snd_sb8dsp_midi_input_trigger()
147 spin_lock_irqsave(&chip->open_lock, flags); in snd_sb8dsp_midi_input_trigger()
149 if (!(chip->open & SB_OPEN_MIDI_INPUT_TRIGGER)) { in snd_sb8dsp_midi_input_trigger()
150 if (chip->hardware < SB_HW_20) in snd_sb8dsp_midi_input_trigger()
152 chip->open |= SB_OPEN_MIDI_INPUT_TRIGGER; in snd_sb8dsp_midi_input_trigger()
155 if (chip->open & SB_OPEN_MIDI_INPUT_TRIGGER) { in snd_sb8dsp_midi_input_trigger()
156 if (chip->hardware < SB_HW_20) in snd_sb8dsp_midi_input_trigger()
158 chip->open &= ~SB_OPEN_MIDI_INPUT_TRIGGER; in snd_sb8dsp_midi_input_trigger()
161 spin_unlock_irqrestore(&chip->open_lock, flags); in snd_sb8dsp_midi_input_trigger()
172 chip = substream->rmidi->private_data; in snd_sb8dsp_midi_output_write()
173 while (max-- > 0) { in snd_sb8dsp_midi_output_write()
174 spin_lock_irqsave(&chip->open_lock, flags); in snd_sb8dsp_midi_output_write()
176 chip->open &= ~SB_OPEN_MIDI_OUTPUT_TRIGGER; in snd_sb8dsp_midi_output_write()
177 del_timer(&chip->midi_timer); in snd_sb8dsp_midi_output_write()
178 spin_unlock_irqrestore(&chip->open_lock, flags); in snd_sb8dsp_midi_output_write()
181 if (chip->hardware >= SB_HW_20) { in snd_sb8dsp_midi_output_write()
183 while ((inb(SBP(chip, STATUS)) & 0x80) != 0 && --timeout > 0) in snd_sb8dsp_midi_output_write()
186 /* Tx FIFO full - try again later */ in snd_sb8dsp_midi_output_write()
187 spin_unlock_irqrestore(&chip->open_lock, flags); in snd_sb8dsp_midi_output_write()
196 spin_unlock_irqrestore(&chip->open_lock, flags); in snd_sb8dsp_midi_output_write()
203 struct snd_rawmidi_substream *substream = chip->midi_substream_output; in snd_sb8dsp_midi_output_timer()
206 spin_lock_irqsave(&chip->open_lock, flags); in snd_sb8dsp_midi_output_timer()
207 mod_timer(&chip->midi_timer, 1 + jiffies); in snd_sb8dsp_midi_output_timer()
208 spin_unlock_irqrestore(&chip->open_lock, flags); in snd_sb8dsp_midi_output_timer()
217 chip = substream->rmidi->private_data; in snd_sb8dsp_midi_output_trigger()
218 spin_lock_irqsave(&chip->open_lock, flags); in snd_sb8dsp_midi_output_trigger()
220 if (!(chip->open & SB_OPEN_MIDI_OUTPUT_TRIGGER)) { in snd_sb8dsp_midi_output_trigger()
221 mod_timer(&chip->midi_timer, 1 + jiffies); in snd_sb8dsp_midi_output_trigger()
222 chip->open |= SB_OPEN_MIDI_OUTPUT_TRIGGER; in snd_sb8dsp_midi_output_trigger()
225 if (chip->open & SB_OPEN_MIDI_OUTPUT_TRIGGER) { in snd_sb8dsp_midi_output_trigger()
226 chip->open &= ~SB_OPEN_MIDI_OUTPUT_TRIGGER; in snd_sb8dsp_midi_output_trigger()
229 spin_unlock_irqrestore(&chip->open_lock, flags); in snd_sb8dsp_midi_output_trigger()
254 err = snd_rawmidi_new(chip->card, "SB8 MIDI", device, 1, 1, &rmidi); in snd_sb8dsp_midi()
257 strcpy(rmidi->name, "SB8 MIDI"); in snd_sb8dsp_midi()
260 rmidi->info_flags |= SNDRV_RAWMIDI_INFO_OUTPUT | SNDRV_RAWMIDI_INFO_INPUT; in snd_sb8dsp_midi()
261 if (chip->hardware >= SB_HW_20) in snd_sb8dsp_midi()
262 rmidi->info_flags |= SNDRV_RAWMIDI_INFO_DUPLEX; in snd_sb8dsp_midi()
263 rmidi->private_data = chip; in snd_sb8dsp_midi()
264 timer_setup(&chip->midi_timer, snd_sb8dsp_midi_output_timer, 0); in snd_sb8dsp_midi()
265 chip->rmidi = rmidi; in snd_sb8dsp_midi()