• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-WNDR4500v2-V1.0.0.60_1.0.38/src/linux/linux-2.6/sound/drivers/mpu401/

Lines Matching refs:mpu

26  *      are port and mmio. For other kind of I/O, set mpu->read and
27 * mpu->write to your own I/O functions.
46 static void snd_mpu401_uart_input_read(struct snd_mpu401 * mpu);
47 static void snd_mpu401_uart_output_write(struct snd_mpu401 * mpu);
53 #define snd_mpu401_input_avail(mpu) (!(mpu->read(mpu, MPU401C(mpu)) & 0x80))
54 #define snd_mpu401_output_ready(mpu) (!(mpu->read(mpu, MPU401C(mpu)) & 0x40))
61 static void mpu401_write_port(struct snd_mpu401 *mpu, unsigned char data,
67 static unsigned char mpu401_read_port(struct snd_mpu401 *mpu,
73 static void mpu401_write_mmio(struct snd_mpu401 *mpu, unsigned char data,
79 static unsigned char mpu401_read_mmio(struct snd_mpu401 *mpu,
86 static void snd_mpu401_uart_clear_rx(struct snd_mpu401 *mpu)
89 for (; timeout > 0 && snd_mpu401_input_avail(mpu); timeout--)
90 mpu->read(mpu, MPU401D(mpu));
94 mpu->read(mpu, MPU401C(mpu)));
98 static void uart_interrupt_tx(struct snd_mpu401 *mpu)
100 if (test_bit(MPU401_MODE_BIT_OUTPUT, &mpu->mode) &&
101 test_bit(MPU401_MODE_BIT_OUTPUT_TRIGGER, &mpu->mode)) {
102 spin_lock(&mpu->output_lock);
103 snd_mpu401_uart_output_write(mpu);
104 spin_unlock(&mpu->output_lock);
108 static void _snd_mpu401_uart_interrupt(struct snd_mpu401 *mpu)
110 if (mpu->info_flags & MPU401_INFO_INPUT) {
111 spin_lock(&mpu->input_lock);
112 if (test_bit(MPU401_MODE_BIT_INPUT, &mpu->mode))
113 snd_mpu401_uart_input_read(mpu);
115 snd_mpu401_uart_clear_rx(mpu);
116 spin_unlock(&mpu->input_lock);
118 if (! (mpu->info_flags & MPU401_INFO_TX_IRQ))
121 uart_interrupt_tx(mpu);
133 struct snd_mpu401 *mpu = dev_id;
135 if (mpu == NULL)
137 _snd_mpu401_uart_interrupt(mpu);
152 struct snd_mpu401 *mpu = dev_id;
154 if (mpu == NULL)
156 uart_interrupt_tx(mpu);
168 struct snd_mpu401 *mpu = (struct snd_mpu401 *)data;
171 spin_lock_irqsave(&mpu->timer_lock, flags);
172 /*mpu->mode |= MPU401_MODE_TIMER;*/
173 mpu->timer.expires = 1 + jiffies;
174 add_timer(&mpu->timer);
175 spin_unlock_irqrestore(&mpu->timer_lock, flags);
176 if (mpu->rmidi)
177 _snd_mpu401_uart_interrupt(mpu);
183 static void snd_mpu401_uart_add_timer (struct snd_mpu401 *mpu, int input)
187 spin_lock_irqsave (&mpu->timer_lock, flags);
188 if (mpu->timer_invoked == 0) {
189 init_timer(&mpu->timer);
190 mpu->timer.data = (unsigned long)mpu;
191 mpu->timer.function = snd_mpu401_uart_timer;
192 mpu->timer.expires = 1 + jiffies;
193 add_timer(&mpu->timer);
195 mpu->timer_invoked |= input ? MPU401_MODE_INPUT_TIMER :
197 spin_unlock_irqrestore (&mpu->timer_lock, flags);
203 static void snd_mpu401_uart_remove_timer (struct snd_mpu401 *mpu, int input)
207 spin_lock_irqsave (&mpu->timer_lock, flags);
208 if (mpu->timer_invoked) {
209 mpu->timer_invoked &= input ? ~MPU401_MODE_INPUT_TIMER :
211 if (! mpu->timer_invoked)
212 del_timer(&mpu->timer);
214 spin_unlock_irqrestore (&mpu->timer_lock, flags);
222 static int snd_mpu401_uart_cmd(struct snd_mpu401 * mpu, unsigned char cmd,
228 spin_lock_irqsave(&mpu->input_lock, flags);
229 if (mpu->hardware != MPU401_HW_TRID4DWAVE) {
230 mpu->write(mpu, 0x00, MPU401D(mpu));
231 /*snd_mpu401_uart_clear_rx(mpu);*/
234 if (mpu->hardware != MPU401_HW_SB) {
236 !snd_mpu401_output_ready(mpu); timeout--)
241 mpu->read(mpu, MPU401C(mpu)));
244 mpu->write(mpu, cmd, MPU401C(mpu));
249 if (snd_mpu401_input_avail(mpu)) {
250 if (mpu->read(mpu, MPU401D(mpu)) == MPU401_ACK)
254 if (!ok && mpu->read(mpu, MPU401D(mpu)) == MPU401_ACK)
258 spin_unlock_irqrestore(&mpu->input_lock, flags);
261 "(status = 0x%x, data = 0x%x)\n", cmd, mpu->port,
262 mpu->read(mpu, MPU401C(mpu)),
263 mpu->read(mpu, MPU401D(mpu)));
269 static int snd_mpu401_do_reset(struct snd_mpu401 *mpu)
271 if (snd_mpu401_uart_cmd(mpu, MPU401_RESET, 1))
273 if (!(mpu->info_flags & MPU401_INFO_UART_ONLY) &&
274 snd_mpu401_uart_cmd(mpu, MPU401_ENTER_UART, 1))
284 struct snd_mpu401 *mpu;
287 mpu = substream->rmidi->private_data;
288 if (mpu->open_input && (err = mpu->open_input(mpu)) < 0)
290 if (! test_bit(MPU401_MODE_BIT_OUTPUT, &mpu->mode)) {
291 if (snd_mpu401_do_reset(mpu) < 0)
294 mpu->substream_input = substream;
295 set_bit(MPU401_MODE_BIT_INPUT, &mpu->mode);
299 if (mpu->open_input && mpu->close_input)
300 mpu->close_input(mpu);
306 struct snd_mpu401 *mpu;
309 mpu = substream->rmidi->private_data;
310 if (mpu->open_output && (err = mpu->open_output(mpu)) < 0)
312 if (! test_bit(MPU401_MODE_BIT_INPUT, &mpu->mode)) {
313 if (snd_mpu401_do_reset(mpu) < 0)
316 mpu->substream_output = substream;
317 set_bit(MPU401_MODE_BIT_OUTPUT, &mpu->mode);
321 if (mpu->open_output && mpu->close_output)
322 mpu->close_output(mpu);
328 struct snd_mpu401 *mpu;
331 mpu = substream->rmidi->private_data;
332 clear_bit(MPU401_MODE_BIT_INPUT, &mpu->mode);
333 mpu->substream_input = NULL;
334 if (! test_bit(MPU401_MODE_BIT_OUTPUT, &mpu->mode))
335 err = snd_mpu401_uart_cmd(mpu, MPU401_RESET, 0);
336 if (mpu->close_input)
337 mpu->close_input(mpu);
345 struct snd_mpu401 *mpu;
348 mpu = substream->rmidi->private_data;
349 clear_bit(MPU401_MODE_BIT_OUTPUT, &mpu->mode);
350 mpu->substream_output = NULL;
351 if (! test_bit(MPU401_MODE_BIT_INPUT, &mpu->mode))
352 err = snd_mpu401_uart_cmd(mpu, MPU401_RESET, 0);
353 if (mpu->close_output)
354 mpu->close_output(mpu);
367 struct snd_mpu401 *mpu;
370 mpu = substream->rmidi->private_data;
373 &mpu->mode)) {
376 mpu->read(mpu, MPU401D(mpu));
377 if (mpu->irq < 0)
378 snd_mpu401_uart_add_timer(mpu, 1);
382 spin_lock_irqsave(&mpu->input_lock, flags);
383 snd_mpu401_uart_input_read(mpu);
384 spin_unlock_irqrestore(&mpu->input_lock, flags);
386 if (mpu->irq < 0)
387 snd_mpu401_uart_remove_timer(mpu, 1);
388 clear_bit(MPU401_MODE_BIT_INPUT_TRIGGER, &mpu->mode);
397 static void snd_mpu401_uart_input_read(struct snd_mpu401 * mpu)
403 if (! snd_mpu401_input_avail(mpu))
405 byte = mpu->read(mpu, MPU401D(mpu));
406 if (test_bit(MPU401_MODE_BIT_INPUT_TRIGGER, &mpu->mode))
407 snd_rawmidi_receive(mpu->substream_input, &byte, 1);
423 static void snd_mpu401_uart_output_write(struct snd_mpu401 * mpu)
429 if (snd_rawmidi_transmit_peek(mpu->substream_output,
432 if (snd_mpu401_output_ready(mpu))
437 mpu->write(mpu, byte, MPU401D(mpu));
438 snd_rawmidi_transmit_ack(mpu->substream_output, 1);
440 snd_mpu401_uart_remove_timer (mpu, 0);
453 struct snd_mpu401 *mpu;
455 mpu = substream->rmidi->private_data;
457 set_bit(MPU401_MODE_BIT_OUTPUT_TRIGGER, &mpu->mode);
463 if (! (mpu->info_flags & MPU401_INFO_TX_IRQ))
464 snd_mpu401_uart_add_timer(mpu, 0);
467 spin_lock_irqsave(&mpu->output_lock, flags);
468 snd_mpu401_uart_output_write(mpu);
469 spin_unlock_irqrestore(&mpu->output_lock, flags);
471 if (! (mpu->info_flags & MPU401_INFO_TX_IRQ))
472 snd_mpu401_uart_remove_timer(mpu, 0);
473 clear_bit(MPU401_MODE_BIT_OUTPUT_TRIGGER, &mpu->mode);
497 struct snd_mpu401 *mpu = rmidi->private_data;
498 if (mpu->irq_flags && mpu->irq >= 0)
499 free_irq(mpu->irq, (void *) mpu);
500 release_and_free_resource(mpu->res);
501 kfree(mpu);
511 * @irq: the irq number, -1 if no interrupt for mpu
530 struct snd_mpu401 *mpu;
544 mpu = kzalloc(sizeof(*mpu), GFP_KERNEL);
545 if (mpu == NULL) {
550 rmidi->private_data = mpu;
552 spin_lock_init(&mpu->input_lock);
553 spin_lock_init(&mpu->output_lock);
554 spin_lock_init(&mpu->timer_lock);
555 mpu->hardware = hardware;
558 mpu->res = request_region(port, res_size, "MPU401 UART");
559 if (mpu->res == NULL) {
568 mpu->write = mpu401_write_mmio;
569 mpu->read = mpu401_read_mmio;
571 mpu->write = mpu401_write_port;
572 mpu->read = mpu401_read_port;
574 mpu->port = port;
576 mpu->cport = port + 2;
578 mpu->cport = port + 1;
581 "MPU401 UART", (void *) mpu)) {
588 mpu->info_flags = info_flags;
589 mpu->irq = irq;
590 mpu->irq_flags = irq_flags;
608 mpu->rmidi = rmidi;