Lines Matching refs:pm
77 static int portman_free(struct portman *pm) in portman_free() argument
79 kfree(pm); in portman_free()
87 struct portman *pm; in portman_create() local
91 pm = kzalloc(sizeof(struct portman), GFP_KERNEL); in portman_create()
92 if (pm == NULL) 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()
100 *rchip = pm; in portman_create()
180 static inline void portman_write_command(struct portman *pm, u8 value) in portman_write_command() argument
182 parport_write_control(pm->pardev->port, value); in portman_write_command()
185 static inline u8 portman_read_status(struct portman *pm) in portman_read_status() argument
187 return parport_read_status(pm->pardev->port); in portman_read_status()
190 static inline void portman_write_data(struct portman *pm, u8 value) in portman_write_data() argument
192 parport_write_data(pm->pardev->port, value); in portman_write_data()
195 static void portman_write_midi(struct portman *pm, in portman_write_midi() argument
217 portman_write_command(pm, command); in portman_write_midi()
223 portman_write_data(pm, mididata); in portman_write_midi()
228 } while ((portman_read_status(pm) & TXEMPTY) != TXEMPTY); in portman_write_midi()
235 portman_write_command(pm, command | STROBE); in portman_write_midi()
242 while ((portman_read_status(pm) & ESTB) == 0) in portman_write_midi()
246 portman_write_command(pm, command); in portman_write_midi()
248 while ((portman_read_status(pm) & ESTB) == ESTB) in portman_write_midi()
255 while ((portman_read_status(pm) & BUSY) == BUSY) in portman_write_midi()
267 static int portman_read_midi(struct portman *pm, int port) in portman_read_midi() argument
273 portman_write_data(pm, 0); /* Make sure edge is down. */ in portman_read_midi()
277 portman_write_command(pm, cmdout); in portman_read_midi()
279 while ((portman_read_status(pm) & ESTB) == ESTB) in portman_read_midi()
285 if ((portman_read_status(pm) & RXAVAIL) == 0) in portman_read_midi()
289 portman_write_command(pm, cmdout | STROBE); /* Write address+IE+Strobe. */ in portman_read_midi()
291 while ((portman_read_status(pm) & ESTB) == 0) in portman_read_midi()
295 midi_data = (portman_read_status(pm) & 128); in portman_read_midi()
296 portman_write_data(pm, 1); /* Cause rising edge, which shifts data. */ in portman_read_midi()
299 portman_write_data(pm, 0); /* Cause falling edge while data settles. */ in portman_read_midi()
300 midi_data |= (portman_read_status(pm) >> 1) & 64; in portman_read_midi()
301 portman_write_data(pm, 1); /* Cause rising edge, which shifts data. */ in portman_read_midi()
304 portman_write_data(pm, 0); /* Cause falling edge while data settles. */ in portman_read_midi()
305 midi_data |= (portman_read_status(pm) >> 2) & 32; in portman_read_midi()
306 portman_write_data(pm, 1); /* Cause rising edge, which shifts data. */ in portman_read_midi()
309 portman_write_data(pm, 0); /* Cause falling edge while data settles. */ in portman_read_midi()
310 midi_data |= (portman_read_status(pm) >> 3) & 16; in portman_read_midi()
311 portman_write_data(pm, 1); /* Cause rising edge, which shifts data. */ in portman_read_midi()
314 portman_write_data(pm, 0); /* Cause falling edge while data settles. */ in portman_read_midi()
315 midi_data |= (portman_read_status(pm) >> 4) & 8; in portman_read_midi()
316 portman_write_data(pm, 1); /* Cause rising edge, which shifts data. */ in portman_read_midi()
319 portman_write_data(pm, 0); /* Cause falling edge while data settles. */ in portman_read_midi()
320 midi_data |= (portman_read_status(pm) >> 5) & 4; in portman_read_midi()
321 portman_write_data(pm, 1); /* Cause rising edge, which shifts data. */ in portman_read_midi()
324 portman_write_data(pm, 0); /* Cause falling edge while data settles. */ in portman_read_midi()
325 midi_data |= (portman_read_status(pm) >> 6) & 2; in portman_read_midi()
326 portman_write_data(pm, 1); /* Cause rising edge, which shifts data. */ in portman_read_midi()
329 portman_write_data(pm, 0); /* Cause falling edge while data settles. */ in portman_read_midi()
330 midi_data |= (portman_read_status(pm) >> 7) & 1; in portman_read_midi()
331 portman_write_data(pm, 1); /* Cause rising edge, which shifts data. */ in portman_read_midi()
332 portman_write_data(pm, 0); /* Return data clock low. */ in portman_read_midi()
336 portman_write_command(pm, cmdout); /* Output saved address+IE. */ in portman_read_midi()
339 while ((portman_read_status(pm) & ESTB) == ESTB) in portman_read_midi()
349 static int portman_data_avail(struct portman *pm, int channel) in portman_data_avail() argument
361 portman_write_command(pm, command); in portman_data_avail()
363 if ((portman_read_status(pm) & RXAVAIL) == RXAVAIL) in portman_data_avail()
374 static void portman_flush_input(struct portman *pm, unsigned char port) in portman_flush_input() argument
395 portman_write_command(pm, command); in portman_flush_input()
398 portman_write_command(pm, command | STROBE); in portman_flush_input()
401 while ((portman_read_status(pm) & ESTB) == 0) in portman_flush_input()
405 portman_write_data(pm, 0); in portman_flush_input()
409 portman_write_data(pm, 1); in portman_flush_input()
410 portman_write_data(pm, 0); in portman_flush_input()
414 portman_write_command(pm, command | INT_EN); in portman_flush_input()
417 while ((portman_read_status(pm) & ESTB) == ESTB) in portman_flush_input()
475 static int portman_device_init(struct portman *pm) in portman_device_init() argument
477 portman_flush_input(pm, 0); in portman_device_init()
478 portman_flush_input(pm, 1); in portman_device_init()
499 struct portman *pm = substream->rmidi->private_data; in snd_portman_midi_input_trigger() local
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() local
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() local
552 rmidi->private_data = pm; in snd_portman_rawmidi_create()
558 pm->rmidi = rmidi; in snd_portman_rawmidi_create()
578 pm->midi_input[substream->number] = substream; in snd_portman_rawmidi_create()
592 struct portman *pm = ((struct snd_card*)userdata)->private_data; in snd_portman_interrupt() local
594 spin_lock(&pm->reg_lock); in snd_portman_interrupt()
597 while ((portman_read_status(pm) & INT_REQ) == INT_REQ) { in snd_portman_interrupt()
600 if (portman_data_avail(pm, 0)) { in snd_portman_interrupt()
602 midivalue = portman_read_midi(pm, 0); 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()
611 if (portman_data_avail(pm, 1)) { in snd_portman_interrupt()
613 midivalue = portman_read_midi(pm, 1); 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()
679 struct portman *pm = card->private_data; in snd_portman_card_private_free() local
680 struct pardevice *pardev = pm->pardev; in snd_portman_card_private_free()
687 portman_free(pm); in snd_portman_card_private_free()
696 struct portman *pm = NULL; in snd_portman_probe() local
742 err = portman_create(card, pardev, &pm); in snd_portman_probe()
747 card->private_data = pm; in snd_portman_probe()
763 err = portman_device_init(pm); in snd_portman_probe()