Lines Matching refs:chip
37 static int enable_midi_input(struct echoaudio *chip, char enable) in enable_midi_input() argument
39 dev_dbg(chip->card->dev, "enable_midi_input(%d)\n", enable); in enable_midi_input()
41 if (wait_handshake(chip)) in enable_midi_input()
45 chip->mtc_state = MIDI_IN_STATE_NORMAL; in enable_midi_input()
46 chip->comm_page->flags |= in enable_midi_input()
49 chip->comm_page->flags &= in enable_midi_input()
52 clear_handshake(chip); in enable_midi_input()
53 return send_vector(chip, DSP_VC_UPDATE_FLAGS); in enable_midi_input()
60 static int write_midi(struct echoaudio *chip, u8 *data, int bytes) in write_midi() argument
65 if (wait_handshake(chip)) in write_midi()
69 if (! (get_dsp_register(chip, CHI32_STATUS_REG) & CHI32_STATUS_REG_HF4)) in write_midi()
72 chip->comm_page->midi_output[0] = bytes; in write_midi()
73 memcpy(&chip->comm_page->midi_output[1], data, bytes); in write_midi()
74 chip->comm_page->midi_out_free_count = 0; in write_midi()
75 clear_handshake(chip); in write_midi()
76 send_vector(chip, DSP_VC_MIDI_WRITE); in write_midi()
77 dev_dbg(chip->card->dev, "write_midi: %d\n", bytes); in write_midi()
90 static inline int mtc_process_data(struct echoaudio *chip, short midi_byte) in mtc_process_data() argument
92 switch (chip->mtc_state) { in mtc_process_data()
95 chip->mtc_state = MIDI_IN_STATE_TS_HIGH; in mtc_process_data()
98 chip->mtc_state = MIDI_IN_STATE_TS_LOW; in mtc_process_data()
102 chip->mtc_state = MIDI_IN_STATE_F1_DATA; in mtc_process_data()
106 chip->mtc_state = MIDI_IN_STATE_NORMAL; in mtc_process_data()
116 static int midi_service_irq(struct echoaudio *chip) in midi_service_irq() argument
121 count = le16_to_cpu(chip->comm_page->midi_input[0]); in midi_service_irq()
131 midi_byte = le16_to_cpu(chip->comm_page->midi_input[i]); in midi_service_irq()
139 if (mtc_process_data(chip, midi_byte) == MIDI_IN_SKIP_DATA) in midi_service_irq()
142 chip->midi_buffer[received++] = (u8)midi_byte; in midi_service_irq()
157 struct echoaudio *chip = substream->rmidi->private_data; in snd_echo_midi_input_open() local
159 chip->midi_in = substream; in snd_echo_midi_input_open()
168 struct echoaudio *chip = substream->rmidi->private_data; in snd_echo_midi_input_trigger() local
170 if (up != chip->midi_input_enabled) { in snd_echo_midi_input_trigger()
171 spin_lock_irq(&chip->lock); in snd_echo_midi_input_trigger()
172 enable_midi_input(chip, up); in snd_echo_midi_input_trigger()
173 spin_unlock_irq(&chip->lock); in snd_echo_midi_input_trigger()
174 chip->midi_input_enabled = up; in snd_echo_midi_input_trigger()
182 struct echoaudio *chip = substream->rmidi->private_data; in snd_echo_midi_input_close() local
184 chip->midi_in = NULL; in snd_echo_midi_input_close()
192 struct echoaudio *chip = substream->rmidi->private_data; in snd_echo_midi_output_open() local
194 chip->tinuse = 0; in snd_echo_midi_output_open()
195 chip->midi_full = 0; in snd_echo_midi_output_open()
196 chip->midi_out = substream; in snd_echo_midi_output_open()
204 struct echoaudio *chip = from_timer(chip, t, timer); in snd_echo_midi_output_write() local
212 spin_lock_irqsave(&chip->lock, flags); in snd_echo_midi_output_write()
213 chip->midi_full = 0; in snd_echo_midi_output_write()
214 if (!snd_rawmidi_transmit_empty(chip->midi_out)) { in snd_echo_midi_output_write()
215 bytes = snd_rawmidi_transmit_peek(chip->midi_out, buf, in snd_echo_midi_output_write()
217 dev_dbg(chip->card->dev, "Try to send %d bytes...\n", bytes); in snd_echo_midi_output_write()
218 sent = write_midi(chip, buf, bytes); in snd_echo_midi_output_write()
220 dev_err(chip->card->dev, in snd_echo_midi_output_write()
224 chip->midi_full = 1; in snd_echo_midi_output_write()
226 dev_dbg(chip->card->dev, "%d bytes sent\n", sent); in snd_echo_midi_output_write()
227 snd_rawmidi_transmit_ack(chip->midi_out, sent); in snd_echo_midi_output_write()
231 dev_dbg(chip->card->dev, "Full\n"); in snd_echo_midi_output_write()
233 chip->midi_full = 1; in snd_echo_midi_output_write()
238 if (!snd_rawmidi_transmit_empty(chip->midi_out) && chip->tinuse) { in snd_echo_midi_output_write()
242 mod_timer(&chip->timer, jiffies + (time * HZ + 999) / 1000); in snd_echo_midi_output_write()
243 dev_dbg(chip->card->dev, in snd_echo_midi_output_write()
246 spin_unlock_irqrestore(&chip->lock, flags); in snd_echo_midi_output_write()
254 struct echoaudio *chip = substream->rmidi->private_data; in snd_echo_midi_output_trigger() local
256 dev_dbg(chip->card->dev, "snd_echo_midi_output_trigger(%d)\n", up); in snd_echo_midi_output_trigger()
257 spin_lock_irq(&chip->lock); in snd_echo_midi_output_trigger()
259 if (!chip->tinuse) { in snd_echo_midi_output_trigger()
260 timer_setup(&chip->timer, snd_echo_midi_output_write, in snd_echo_midi_output_trigger()
262 chip->tinuse = 1; in snd_echo_midi_output_trigger()
265 if (chip->tinuse) { in snd_echo_midi_output_trigger()
266 chip->tinuse = 0; in snd_echo_midi_output_trigger()
267 spin_unlock_irq(&chip->lock); in snd_echo_midi_output_trigger()
268 del_timer_sync(&chip->timer); in snd_echo_midi_output_trigger()
269 dev_dbg(chip->card->dev, "Timer removed\n"); in snd_echo_midi_output_trigger()
273 spin_unlock_irq(&chip->lock); in snd_echo_midi_output_trigger()
275 if (up && !chip->midi_full) in snd_echo_midi_output_trigger()
276 snd_echo_midi_output_write(&chip->timer); in snd_echo_midi_output_trigger()
283 struct echoaudio *chip = substream->rmidi->private_data; in snd_echo_midi_output_close() local
285 chip->midi_out = NULL; in snd_echo_midi_output_close()
307 struct echoaudio *chip) in snd_echo_midi_create() argument
312 &chip->rmidi)) < 0) in snd_echo_midi_create()
315 strcpy(chip->rmidi->name, card->shortname); in snd_echo_midi_create()
316 chip->rmidi->private_data = chip; in snd_echo_midi_create()
318 snd_rawmidi_set_ops(chip->rmidi, SNDRV_RAWMIDI_STREAM_INPUT, in snd_echo_midi_create()
320 snd_rawmidi_set_ops(chip->rmidi, SNDRV_RAWMIDI_STREAM_OUTPUT, in snd_echo_midi_create()
323 chip->rmidi->info_flags |= SNDRV_RAWMIDI_INFO_OUTPUT | in snd_echo_midi_create()