Lines Matching full:chip

22 irqreturn_t snd_sb8dsp_midi_interrupt(struct snd_sb *chip)  in snd_sb8dsp_midi_interrupt()  argument
28 if (!chip) in snd_sb8dsp_midi_interrupt()
31 rmidi = chip->rmidi; in snd_sb8dsp_midi_interrupt()
33 inb(SBP(chip, DATA_AVAIL)); /* ack interrupt */ in snd_sb8dsp_midi_interrupt()
37 spin_lock(&chip->midi_input_lock); in snd_sb8dsp_midi_interrupt()
39 if (inb(SBP(chip, DATA_AVAIL)) & 0x80) { in snd_sb8dsp_midi_interrupt()
40 byte = inb(SBP(chip, READ)); 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()
53 struct snd_sb *chip; in snd_sb8dsp_midi_input_open() local
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()
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()
70 snd_sbdsp_command(chip, SB_DSP_MIDI_UART_IRQ); in snd_sb8dsp_midi_input_open()
72 spin_unlock_irqrestore(&chip->open_lock, flags); in snd_sb8dsp_midi_input_open()
80 struct snd_sb *chip; in snd_sb8dsp_midi_output_open() local
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()
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()
97 snd_sbdsp_command(chip, SB_DSP_MIDI_UART_IRQ); in snd_sb8dsp_midi_output_open()
99 spin_unlock_irqrestore(&chip->open_lock, flags); in snd_sb8dsp_midi_output_open()
107 struct snd_sb *chip; in snd_sb8dsp_midi_input_close() local
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()
125 struct snd_sb *chip; in snd_sb8dsp_midi_output_close() local
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()
144 struct snd_sb *chip; in snd_sb8dsp_midi_input_trigger() local
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()
151 snd_sbdsp_command(chip, SB_DSP_MIDI_INPUT_IRQ); 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()
157 snd_sbdsp_command(chip, SB_DSP_MIDI_INPUT_IRQ); 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()
167 struct snd_sb *chip; in snd_sb8dsp_midi_output_write() local
172 chip = substream->rmidi->private_data; 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()
187 spin_unlock_irqrestore(&chip->open_lock, flags); in snd_sb8dsp_midi_output_write()
190 outb(byte, SBP(chip, WRITE)); in snd_sb8dsp_midi_output_write()
192 snd_sbdsp_command(chip, SB_DSP_MIDI_OUTPUT); in snd_sb8dsp_midi_output_write()
193 snd_sbdsp_command(chip, byte); in snd_sb8dsp_midi_output_write()
196 spin_unlock_irqrestore(&chip->open_lock, flags); in snd_sb8dsp_midi_output_write()
202 struct snd_sb *chip = from_timer(chip, t, midi_timer); in snd_sb8dsp_midi_output_timer() local
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()
215 struct snd_sb *chip; in snd_sb8dsp_midi_output_trigger() local
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()
249 int snd_sb8dsp_midi(struct snd_sb *chip, int device) in snd_sb8dsp_midi() argument
254 if ((err = snd_rawmidi_new(chip->card, "SB8 MIDI", device, 1, 1, &rmidi)) < 0) in snd_sb8dsp_midi()
260 if (chip->hardware >= SB_HW_20) in snd_sb8dsp_midi()
262 rmidi->private_data = chip; in snd_sb8dsp_midi()
263 timer_setup(&chip->midi_timer, snd_sb8dsp_midi_output_timer, 0); in snd_sb8dsp_midi()
264 chip->rmidi = rmidi; in snd_sb8dsp_midi()