• Home
  • Raw
  • Download

Lines Matching +full:read +full:- +full:strobe +full:- +full:delay

1 // SPDX-License-Identifier: GPL-2.0-or-later
5 * Copyright (c) by Levent Guendogdu <levon@feature-it.com>
9 * - cleanup and rewrite
11 * - source code cleanup
13 * - fixed compilation problem with alsa 1.0.6a (removed MODULE_CLASSES,
17 * - added 2.6 kernel support
19 …* - added parport_unregister_driver to the startup routine if the driver fails to detect a po…
20 * - added support for all 4 output ports in portman_putmidi
22 * - added checks for opened input device in interrupt handler
24 * - ported from alsa 0.5 to 1.0
31 #include <linux/delay.h>
94 return -ENOMEM; in portman_create()
97 spin_lock_init(&pm->reg_lock); in portman_create()
98 pm->card = card; in portman_create()
99 pm->pardev = pardev; in portman_create()
112 #define PP_STAT_ACK 0x40 /* Acknowledge. Non-Inverted. */
113 #define PP_STAT_POUT 0x20 /* Paper Out. Non-Inverted. */
114 #define PP_STAT_SEL 0x10 /* Select. Non-Inverted. */
115 #define PP_STAT_ERR 0x08 /* Error. Non-Inverted. */
118 #define PP_CMD_IEN 0x10 /* IRQ Enable. Non-Inverted. */
120 #define PP_CMD_INIT 0x04 /* Init Printer. Non-Inverted. */
122 #define PP_CMD_STB 0x01 /* Strobe. Inverted. */
126 #define STROBE PP_CMD_STB /* Command strobe. */ macro
143 #define ESTB PP_STAT_POUT /* Echoed strobe. */
153 * --------
157 #define SYNC_STAT PP_STAT_SEL /* Reserved - Sync Status. 0 1 0 */
165 * --------
169 #define SYNC_DATA PP_STAT_BSY /* Reserved - Sync Data. 0 1 0 */
183 parport_write_control(pm->pardev->port, value); in portman_write_command()
188 return parport_read_control(pm->pardev->port); in portman_read_command()
193 return parport_read_status(pm->pardev->port); in portman_read_status()
198 return parport_read_data(pm->pardev->port); in portman_read_data()
203 parport_write_data(pm->pardev->port, value); in portman_write_data()
218 * set address for TXDatax, Strobe=0 in portman_write_midi()
224 * PP Command Reg. Do not set the Strobe signal yet. in portman_write_midi()
231 * PP Data Reg. This has no effect until Strobe signal is asserted. in portman_write_midi()
236 /* If PCP channel's TxEmpty is set (TxEmpty is read through the PP in portman_write_midi()
242 * Strobe through the PP Command Reg. This will Strobe data into in portman_write_midi()
246 portman_write_command(pm, command | STROBE); in portman_write_midi()
248 /* Wait for strobe line to settle and echo back through hardware. in portman_write_midi()
256 /* Release strobe and immediately re-allow interrupts. */ in portman_write_midi()
274 * Read MIDI byte from port
275 * Attempt to read input byte from specified hardware input port (0..).
276 * Return -1 if no data
287 cmdout = (port << 1) | INT_EN; /* Address + IE + No Strobe. */ in portman_read_midi()
291 cpu_relax(); /* Wait for strobe echo. */ in portman_read_midi()
294 * If data is available, read it. in portman_read_midi()
297 return -1; /* No data. */ in portman_read_midi()
299 /* Set the Strobe signal to enable the Rx clocking circuitry. */ in portman_read_midi()
300 portman_write_command(pm, cmdout | STROBE); /* Write address+IE+Strobe. */ in portman_read_midi()
303 cpu_relax(); /* Wait for strobe echo. */ in portman_read_midi()
346 /* De-assert Strobe and return data. */ in portman_read_midi()
349 /* Wait for strobe echo. */ in portman_read_midi()
371 /* Write hardware (assumme STROBE=0) */ in portman_data_avail()
408 /* Assert the Strobe and wait for echo back. */ in portman_flush_input()
409 portman_write_command(pm, command | STROBE); in portman_flush_input()
424 /* Deassert the Strobe signal of the port and wait for it to settle. */ in portman_flush_input()
443 * Strobe = 0 in portman_probe()
451 parport_write_control(p, RXDATA0); /* Write Strobe=0 to command reg. */ in portman_probe()
456 return 1; /* CODE 1 - Strobe Failure. */ in portman_probe()
460 parport_write_control(p, RXDATA0 | STROBE); /* Write Strobe=1 to command reg. */ in portman_probe()
464 return 1; /* CODE 1 - Strobe Failure. */ in portman_probe()
467 parport_write_control(p, 0); /* Reset Strobe=0. */ in portman_probe()
473 parport_write_control(p, TXDATA0); /* Tx channel 0, strobe off. */ in portman_probe()
475 /* If PCP channel's TxEmpty is set (TxEmpty is read through the PP in portman_probe()
510 struct portman *pm = substream->rmidi->private_data; in snd_portman_midi_input_trigger()
513 spin_lock_irqsave(&pm->reg_lock, flags); in snd_portman_midi_input_trigger()
515 pm->mode[substream->number] |= PORTMAN2X4_MODE_INPUT_TRIGGERED; in snd_portman_midi_input_trigger()
517 pm->mode[substream->number] &= ~PORTMAN2X4_MODE_INPUT_TRIGGERED; in snd_portman_midi_input_trigger()
518 spin_unlock_irqrestore(&pm->reg_lock, flags); in snd_portman_midi_input_trigger()
524 struct portman *pm = substream->rmidi->private_data; in snd_portman_midi_output_trigger()
528 spin_lock_irqsave(&pm->reg_lock, flags); in snd_portman_midi_output_trigger()
531 portman_write_midi(pm, substream->number, byte); in snd_portman_midi_output_trigger()
533 spin_unlock_irqrestore(&pm->reg_lock, flags); in snd_portman_midi_output_trigger()
551 struct portman *pm = card->private_data; in snd_portman_rawmidi_create()
563 rmidi->private_data = pm; in snd_portman_rawmidi_create()
564 strcpy(rmidi->name, CARD_NAME); in snd_portman_rawmidi_create()
565 rmidi->info_flags = SNDRV_RAWMIDI_INFO_OUTPUT | in snd_portman_rawmidi_create()
569 pm->rmidi = rmidi; in snd_portman_rawmidi_create()
580 &rmidi->streams[SNDRV_RAWMIDI_STREAM_OUTPUT].substreams, in snd_portman_rawmidi_create()
582 sprintf(substream->name, in snd_portman_rawmidi_create()
583 "Portman2x4 %d", substream->number+1); in snd_portman_rawmidi_create()
587 &rmidi->streams[SNDRV_RAWMIDI_STREAM_INPUT].substreams, in snd_portman_rawmidi_create()
589 pm->midi_input[substream->number] = substream; in snd_portman_rawmidi_create()
590 sprintf(substream->name, in snd_portman_rawmidi_create()
591 "Portman2x4 %d", substream->number+1); in snd_portman_rawmidi_create()
603 struct portman *pm = ((struct snd_card*)userdata)->private_data; in snd_portman_interrupt()
605 spin_lock(&pm->reg_lock); in snd_portman_interrupt()
610 read it and stuff it into the queue. */ in snd_portman_interrupt()
612 /* Read Midi */ in snd_portman_interrupt()
615 if (pm->mode[0] & PORTMAN2X4_MODE_INPUT_TRIGGERED) in snd_portman_interrupt()
616 snd_rawmidi_receive(pm->midi_input[0], in snd_portman_interrupt()
621 read it and stuff it into the queue. */ in snd_portman_interrupt()
623 /* Read Midi */ in snd_portman_interrupt()
626 if (pm->mode[1] & PORTMAN2X4_MODE_INPUT_TRIGGERED) in snd_portman_interrupt()
627 snd_rawmidi_receive(pm->midi_input[1], in snd_portman_interrupt()
633 spin_unlock(&pm->reg_lock); in snd_portman_interrupt()
671 if (strcmp(pardev->name, DRIVER_NAME)) in snd_portman_dev_probe()
672 return -ENODEV; in snd_portman_dev_probe()
690 struct portman *pm = card->private_data; in snd_portman_card_private_free()
691 struct pardevice *pardev = pm->pardev; in snd_portman_card_private_free()
705 int dev = pdev->id; in snd_portman_probe()
720 return -ENODEV; in snd_portman_probe()
722 return -ENOENT; in snd_portman_probe()
724 err = snd_card_new(&pdev->dev, index[dev], id[dev], THIS_MODULE, in snd_portman_probe()
730 strcpy(card->driver, DRIVER_NAME); in snd_portman_probe()
731 strcpy(card->shortname, CARD_NAME); in snd_portman_probe()
732 sprintf(card->longname, "%s at 0x%lx, irq %i", in snd_portman_probe()
733 card->shortname, p->base, p->irq); in snd_portman_probe()
739 pdev->id); /* device number */ in snd_portman_probe()
742 err = -EIO; in snd_portman_probe()
748 snd_printd("Cannot claim parport 0x%lx\n", pardev->port->base); in snd_portman_probe()
749 err = -EIO; in snd_portman_probe()
757 card->private_data = pm; in snd_portman_probe()
758 card->private_free = snd_portman_card_private_free; in snd_portman_probe()
762 err = -EIO; in snd_portman_probe()
783 snd_printk(KERN_INFO "Portman 2x4 on 0x%lx\n", p->base); in snd_portman_probe()
840 return -EIO; in snd_portman_module_init()
845 return -ENODEV; in snd_portman_module_init()