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>
93 return -ENOMEM; in portman_create()
96 spin_lock_init(&pm->reg_lock); in portman_create()
97 pm->card = card; in portman_create()
98 pm->pardev = pardev; in portman_create()
111 #define PP_STAT_ACK 0x40 /* Acknowledge. Non-Inverted. */
112 #define PP_STAT_POUT 0x20 /* Paper Out. Non-Inverted. */
113 #define PP_STAT_SEL 0x10 /* Select. Non-Inverted. */
114 #define PP_STAT_ERR 0x08 /* Error. Non-Inverted. */
117 #define PP_CMD_IEN 0x10 /* IRQ Enable. Non-Inverted. */
119 #define PP_CMD_INIT 0x04 /* Init Printer. Non-Inverted. */
121 #define PP_CMD_STB 0x01 /* Strobe. Inverted. */
125 #define STROBE PP_CMD_STB /* Command strobe. */ macro
142 #define ESTB PP_STAT_POUT /* Echoed strobe. */
152 * --------
156 #define SYNC_STAT PP_STAT_SEL /* Reserved - Sync Status. 0 1 0 */
164 * --------
168 #define SYNC_DATA PP_STAT_BSY /* Reserved - Sync Data. 0 1 0 */
182 parport_write_control(pm->pardev->port, value); in portman_write_command()
187 return parport_read_status(pm->pardev->port); in portman_read_status()
192 parport_write_data(pm->pardev->port, value); in portman_write_data()
207 * set address for TXDatax, Strobe=0 in portman_write_midi()
213 * PP Command Reg. Do not set the Strobe signal yet. in portman_write_midi()
220 * PP Data Reg. This has no effect until Strobe signal is asserted. in portman_write_midi()
225 /* If PCP channel's TxEmpty is set (TxEmpty is read through the PP in portman_write_midi()
231 * Strobe through the PP Command Reg. This will Strobe data into in portman_write_midi()
235 portman_write_command(pm, command | STROBE); in portman_write_midi()
237 /* Wait for strobe line to settle and echo back through hardware. in portman_write_midi()
245 /* Release strobe and immediately re-allow interrupts. */ in portman_write_midi()
263 * Read MIDI byte from port
264 * Attempt to read input byte from specified hardware input port (0..).
265 * Return -1 if no data
276 cmdout = (port << 1) | INT_EN; /* Address + IE + No Strobe. */ in portman_read_midi()
280 cpu_relax(); /* Wait for strobe echo. */ in portman_read_midi()
283 * If data is available, read it. in portman_read_midi()
286 return -1; /* No data. */ in portman_read_midi()
288 /* Set the Strobe signal to enable the Rx clocking circuitry. */ in portman_read_midi()
289 portman_write_command(pm, cmdout | STROBE); /* Write address+IE+Strobe. */ in portman_read_midi()
292 cpu_relax(); /* Wait for strobe echo. */ in portman_read_midi()
335 /* De-assert Strobe and return data. */ in portman_read_midi()
338 /* Wait for strobe echo. */ in portman_read_midi()
360 /* Write hardware (assumme STROBE=0) */ in portman_data_avail()
397 /* Assert the Strobe and wait for echo back. */ in portman_flush_input()
398 portman_write_command(pm, command | STROBE); in portman_flush_input()
413 /* Deassert the Strobe signal of the port and wait for it to settle. */ in portman_flush_input()
432 * Strobe = 0 in portman_probe()
440 parport_write_control(p, RXDATA0); /* Write Strobe=0 to command reg. */ in portman_probe()
445 return 1; /* CODE 1 - Strobe Failure. */ in portman_probe()
449 parport_write_control(p, RXDATA0 | STROBE); /* Write Strobe=1 to command reg. */ in portman_probe()
453 return 1; /* CODE 1 - Strobe Failure. */ in portman_probe()
456 parport_write_control(p, 0); /* Reset Strobe=0. */ in portman_probe()
462 parport_write_control(p, TXDATA0); /* Tx channel 0, strobe off. */ in portman_probe()
464 /* If PCP channel's TxEmpty is set (TxEmpty is read through the PP in portman_probe()
499 struct portman *pm = substream->rmidi->private_data; in snd_portman_midi_input_trigger()
502 spin_lock_irqsave(&pm->reg_lock, flags); in snd_portman_midi_input_trigger()
504 pm->mode[substream->number] |= PORTMAN2X4_MODE_INPUT_TRIGGERED; in snd_portman_midi_input_trigger()
506 pm->mode[substream->number] &= ~PORTMAN2X4_MODE_INPUT_TRIGGERED; in snd_portman_midi_input_trigger()
507 spin_unlock_irqrestore(&pm->reg_lock, flags); in snd_portman_midi_input_trigger()
513 struct portman *pm = substream->rmidi->private_data; in snd_portman_midi_output_trigger()
517 spin_lock_irqsave(&pm->reg_lock, flags); in snd_portman_midi_output_trigger()
520 portman_write_midi(pm, substream->number, byte); in snd_portman_midi_output_trigger()
522 spin_unlock_irqrestore(&pm->reg_lock, flags); in snd_portman_midi_output_trigger()
540 struct portman *pm = card->private_data; in snd_portman_rawmidi_create()
552 rmidi->private_data = pm; in snd_portman_rawmidi_create()
553 strcpy(rmidi->name, CARD_NAME); in snd_portman_rawmidi_create()
554 rmidi->info_flags = SNDRV_RAWMIDI_INFO_OUTPUT | in snd_portman_rawmidi_create()
558 pm->rmidi = rmidi; in snd_portman_rawmidi_create()
569 &rmidi->streams[SNDRV_RAWMIDI_STREAM_OUTPUT].substreams, in snd_portman_rawmidi_create()
571 sprintf(substream->name, in snd_portman_rawmidi_create()
572 "Portman2x4 %d", substream->number+1); in snd_portman_rawmidi_create()
576 &rmidi->streams[SNDRV_RAWMIDI_STREAM_INPUT].substreams, in snd_portman_rawmidi_create()
578 pm->midi_input[substream->number] = substream; in snd_portman_rawmidi_create()
579 sprintf(substream->name, in snd_portman_rawmidi_create()
580 "Portman2x4 %d", substream->number+1); in snd_portman_rawmidi_create()
592 struct portman *pm = ((struct snd_card*)userdata)->private_data; in snd_portman_interrupt()
594 spin_lock(&pm->reg_lock); in snd_portman_interrupt()
599 read it and stuff it into the queue. */ in snd_portman_interrupt()
601 /* Read Midi */ in snd_portman_interrupt()
604 if (pm->mode[0] & PORTMAN2X4_MODE_INPUT_TRIGGERED) in snd_portman_interrupt()
605 snd_rawmidi_receive(pm->midi_input[0], 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[1] & PORTMAN2X4_MODE_INPUT_TRIGGERED) in snd_portman_interrupt()
616 snd_rawmidi_receive(pm->midi_input[1], in snd_portman_interrupt()
622 spin_unlock(&pm->reg_lock); in snd_portman_interrupt()
660 if (strcmp(pardev->name, DRIVER_NAME)) in snd_portman_dev_probe()
661 return -ENODEV; in snd_portman_dev_probe()
679 struct portman *pm = card->private_data; in snd_portman_card_private_free()
680 struct pardevice *pardev = pm->pardev; in snd_portman_card_private_free()
694 int dev = pdev->id; in snd_portman_probe()
709 return -ENODEV; in snd_portman_probe()
711 return -ENOENT; in snd_portman_probe()
713 err = snd_card_new(&pdev->dev, index[dev], id[dev], THIS_MODULE, in snd_portman_probe()
719 strcpy(card->driver, DRIVER_NAME); in snd_portman_probe()
720 strcpy(card->shortname, CARD_NAME); in snd_portman_probe()
721 sprintf(card->longname, "%s at 0x%lx, irq %i", in snd_portman_probe()
722 card->shortname, p->base, p->irq); in snd_portman_probe()
728 pdev->id); /* device number */ in snd_portman_probe()
731 err = -EIO; in snd_portman_probe()
737 snd_printd("Cannot claim parport 0x%lx\n", pardev->port->base); in snd_portman_probe()
738 err = -EIO; in snd_portman_probe()
747 card->private_data = pm; in snd_portman_probe()
748 card->private_free = snd_portman_card_private_free; in snd_portman_probe()
752 err = -EIO; in snd_portman_probe()
776 snd_printk(KERN_INFO "Portman 2x4 on 0x%lx\n", p->base); in snd_portman_probe()
832 return -EIO; in snd_portman_module_init()
837 return -ENODEV; in snd_portman_module_init()