Lines Matching +full:timer +full:- +full:dsp
3 Copyright Echo Digital Audio Corporation (c) 1998 - 2004
21 Foundation, Inc., 59 Temple Place - Suite 330, Boston,
22 MA 02111-1307, USA.
26 Translation from C++ and adaptation for use in ALSA-Driver
39 dev_dbg(chip->card->dev, "enable_midi_input(%d)\n", enable); in enable_midi_input()
42 return -EIO; 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()
58 /* Send a buffer full of MIDI data to the DSP
63 return -EINVAL; in write_midi()
66 return -EIO; 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()
77 dev_dbg(chip->card->dev, "write_midi: %d\n", bytes); in write_midi()
85 this state machine to parse the incoming MIDI data stream. Every time the DSP
86 sees a 0xF1 byte come in, it adds the DSP sample position to the MIDI data
87 stream. The DSP sample position is represented as a 32 bit unsigned value,
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()
115 from the DSP's buffer. It returns the number of bytes received. */
121 count = le16_to_cpu(chip->comm_page->midi_input[0]); in midi_service_irq()
130 midi_byte = le16_to_cpu(chip->comm_page->midi_input[i]); in midi_service_irq()
141 chip->midi_buffer[received++] = (u8)midi_byte; in midi_service_irq()
156 struct echoaudio *chip = substream->rmidi->private_data; in snd_echo_midi_input_open()
158 chip->midi_in = substream; in snd_echo_midi_input_open()
167 struct echoaudio *chip = substream->rmidi->private_data; in snd_echo_midi_input_trigger()
169 if (up != chip->midi_input_enabled) { in snd_echo_midi_input_trigger()
170 spin_lock_irq(&chip->lock); in snd_echo_midi_input_trigger()
172 spin_unlock_irq(&chip->lock); in snd_echo_midi_input_trigger()
173 chip->midi_input_enabled = up; in snd_echo_midi_input_trigger()
181 struct echoaudio *chip = substream->rmidi->private_data; in snd_echo_midi_input_close()
183 chip->midi_in = NULL; in snd_echo_midi_input_close()
191 struct echoaudio *chip = substream->rmidi->private_data; in snd_echo_midi_output_open()
193 chip->tinuse = 0; in snd_echo_midi_output_open()
194 chip->midi_full = 0; in snd_echo_midi_output_open()
195 chip->midi_out = substream; in snd_echo_midi_output_open()
203 struct echoaudio *chip = from_timer(chip, t, timer); in snd_echo_midi_output_write()
206 unsigned char buf[MIDI_OUT_BUFFER_SIZE - 1]; in snd_echo_midi_output_write()
211 spin_lock_irqsave(&chip->lock, flags); in snd_echo_midi_output_write()
212 chip->midi_full = 0; in snd_echo_midi_output_write()
213 if (!snd_rawmidi_transmit_empty(chip->midi_out)) { in snd_echo_midi_output_write()
214 bytes = snd_rawmidi_transmit_peek(chip->midi_out, buf, in snd_echo_midi_output_write()
215 MIDI_OUT_BUFFER_SIZE - 1); in snd_echo_midi_output_write()
216 dev_dbg(chip->card->dev, "Try to send %d bytes...\n", bytes); in snd_echo_midi_output_write()
219 dev_err(chip->card->dev, in snd_echo_midi_output_write()
223 chip->midi_full = 1; in snd_echo_midi_output_write()
225 dev_dbg(chip->card->dev, "%d bytes sent\n", sent); in snd_echo_midi_output_write()
226 snd_rawmidi_transmit_ack(chip->midi_out, sent); in snd_echo_midi_output_write()
228 /* Buffer is full. DSP's internal buffer is 64 (128 ?) in snd_echo_midi_output_write()
230 dev_dbg(chip->card->dev, "Full\n"); in snd_echo_midi_output_write()
232 chip->midi_full = 1; in snd_echo_midi_output_write()
236 /* We restart the timer only if there is some data left to send */ in snd_echo_midi_output_write()
237 if (!snd_rawmidi_transmit_empty(chip->midi_out) && chip->tinuse) { in snd_echo_midi_output_write()
238 /* The timer will expire slightly after the data has been in snd_echo_midi_output_write()
241 mod_timer(&chip->timer, jiffies + (time * HZ + 999) / 1000); in snd_echo_midi_output_write()
242 dev_dbg(chip->card->dev, in snd_echo_midi_output_write()
243 "Timer armed(%d)\n", ((time * HZ + 999) / 1000)); in snd_echo_midi_output_write()
245 spin_unlock_irqrestore(&chip->lock, flags); in snd_echo_midi_output_write()
253 struct echoaudio *chip = substream->rmidi->private_data; in snd_echo_midi_output_trigger()
255 dev_dbg(chip->card->dev, "snd_echo_midi_output_trigger(%d)\n", up); in snd_echo_midi_output_trigger()
256 spin_lock_irq(&chip->lock); in snd_echo_midi_output_trigger()
258 if (!chip->tinuse) { in snd_echo_midi_output_trigger()
259 timer_setup(&chip->timer, snd_echo_midi_output_write, in snd_echo_midi_output_trigger()
261 chip->tinuse = 1; in snd_echo_midi_output_trigger()
264 if (chip->tinuse) { in snd_echo_midi_output_trigger()
265 chip->tinuse = 0; in snd_echo_midi_output_trigger()
266 spin_unlock_irq(&chip->lock); in snd_echo_midi_output_trigger()
267 del_timer_sync(&chip->timer); in snd_echo_midi_output_trigger()
268 dev_dbg(chip->card->dev, "Timer removed\n"); in snd_echo_midi_output_trigger()
272 spin_unlock_irq(&chip->lock); in snd_echo_midi_output_trigger()
274 if (up && !chip->midi_full) in snd_echo_midi_output_trigger()
275 snd_echo_midi_output_write(&chip->timer); in snd_echo_midi_output_trigger()
282 struct echoaudio *chip = substream->rmidi->private_data; in snd_echo_midi_output_close()
284 chip->midi_out = NULL; in snd_echo_midi_output_close()
304 /* <--snd_echo_probe() */
310 err = snd_rawmidi_new(card, card->shortname, 0, 1, 1, &chip->rmidi); in snd_echo_midi_create()
314 strcpy(chip->rmidi->name, card->shortname); in snd_echo_midi_create()
315 chip->rmidi->private_data = chip; in snd_echo_midi_create()
317 snd_rawmidi_set_ops(chip->rmidi, SNDRV_RAWMIDI_STREAM_INPUT, in snd_echo_midi_create()
319 snd_rawmidi_set_ops(chip->rmidi, SNDRV_RAWMIDI_STREAM_OUTPUT, in snd_echo_midi_create()
322 chip->rmidi->info_flags |= SNDRV_RAWMIDI_INFO_OUTPUT | in snd_echo_midi_create()