Lines Matching full:pm
77 static int portman_free(struct portman *pm)
79 kfree(pm);
87 struct portman *pm;
91 pm = kzalloc(sizeof(struct portman), GFP_KERNEL);
92 if (pm == NULL)
96 spin_lock_init(&pm->reg_lock);
97 pm->card = card;
98 pm->pardev = pardev;
100 *rchip = pm;
180 static inline void portman_write_command(struct portman *pm, u8 value)
182 parport_write_control(pm->pardev->port, value);
185 static inline u8 portman_read_status(struct portman *pm)
187 return parport_read_status(pm->pardev->port);
190 static inline void portman_write_data(struct portman *pm, u8 value)
192 parport_write_data(pm->pardev->port, value);
195 static void portman_write_midi(struct portman *pm,
217 portman_write_command(pm, command);
223 portman_write_data(pm, mididata);
228 } while ((portman_read_status(pm) & TXEMPTY) != TXEMPTY);
235 portman_write_command(pm, command | STROBE);
242 while ((portman_read_status(pm) & ESTB) == 0)
246 portman_write_command(pm, command);
248 while ((portman_read_status(pm) & ESTB) == ESTB)
255 while ((portman_read_status(pm) & BUSY) == BUSY)
267 static int portman_read_midi(struct portman *pm, int port)
273 portman_write_data(pm, 0); /* Make sure edge is down. */
277 portman_write_command(pm, cmdout);
279 while ((portman_read_status(pm) & ESTB) == ESTB)
285 if ((portman_read_status(pm) & RXAVAIL) == 0)
289 portman_write_command(pm, cmdout | STROBE); /* Write address+IE+Strobe. */
291 while ((portman_read_status(pm) & ESTB) == 0)
295 midi_data = (portman_read_status(pm) & 128);
296 portman_write_data(pm, 1); /* Cause rising edge, which shifts data. */
299 portman_write_data(pm, 0); /* Cause falling edge while data settles. */
300 midi_data |= (portman_read_status(pm) >> 1) & 64;
301 portman_write_data(pm, 1); /* Cause rising edge, which shifts data. */
304 portman_write_data(pm, 0); /* Cause falling edge while data settles. */
305 midi_data |= (portman_read_status(pm) >> 2) & 32;
306 portman_write_data(pm, 1); /* Cause rising edge, which shifts data. */
309 portman_write_data(pm, 0); /* Cause falling edge while data settles. */
310 midi_data |= (portman_read_status(pm) >> 3) & 16;
311 portman_write_data(pm, 1); /* Cause rising edge, which shifts data. */
314 portman_write_data(pm, 0); /* Cause falling edge while data settles. */
315 midi_data |= (portman_read_status(pm) >> 4) & 8;
316 portman_write_data(pm, 1); /* Cause rising edge, which shifts data. */
319 portman_write_data(pm, 0); /* Cause falling edge while data settles. */
320 midi_data |= (portman_read_status(pm) >> 5) & 4;
321 portman_write_data(pm, 1); /* Cause rising edge, which shifts data. */
324 portman_write_data(pm, 0); /* Cause falling edge while data settles. */
325 midi_data |= (portman_read_status(pm) >> 6) & 2;
326 portman_write_data(pm, 1); /* Cause rising edge, which shifts data. */
329 portman_write_data(pm, 0); /* Cause falling edge while data settles. */
330 midi_data |= (portman_read_status(pm) >> 7) & 1;
331 portman_write_data(pm, 1); /* Cause rising edge, which shifts data. */
332 portman_write_data(pm, 0); /* Return data clock low. */
336 portman_write_command(pm, cmdout); /* Output saved address+IE. */
339 while ((portman_read_status(pm) & ESTB) == ESTB)
349 static int portman_data_avail(struct portman *pm, int channel)
361 portman_write_command(pm, command);
363 if ((portman_read_status(pm) & RXAVAIL) == RXAVAIL)
374 static void portman_flush_input(struct portman *pm, unsigned char port)
388 dev_warn(pm->card->dev, "%s Won't flush port %i\n",
394 portman_write_command(pm, command);
397 portman_write_command(pm, command | STROBE);
400 while ((portman_read_status(pm) & ESTB) == 0)
404 portman_write_data(pm, 0);
408 portman_write_data(pm, 1);
409 portman_write_data(pm, 0);
413 portman_write_command(pm, command | INT_EN);
416 while ((portman_read_status(pm) & ESTB) == ESTB)
474 static int portman_device_init(struct portman *pm)
476 portman_flush_input(pm, 0);
477 portman_flush_input(pm, 1);
498 struct portman *pm = substream->rmidi->private_data;
500 guard(spinlock_irqsave)(&pm->reg_lock);
502 pm->mode[substream->number] |= PORTMAN2X4_MODE_INPUT_TRIGGERED;
504 pm->mode[substream->number] &= ~PORTMAN2X4_MODE_INPUT_TRIGGERED;
510 struct portman *pm = substream->rmidi->private_data;
513 guard(spinlock_irqsave)(&pm->reg_lock);
516 portman_write_midi(pm, substream->number, byte);
535 struct portman *pm = card->private_data;
547 rmidi->private_data = pm;
553 pm->rmidi = rmidi;
573 pm->midi_input[substream->number] = substream;
587 struct portman *pm = ((struct snd_card*)userdata)->private_data;
589 guard(spinlock)(&pm->reg_lock);
592 while ((portman_read_status(pm) & INT_REQ) == INT_REQ) {
595 if (portman_data_avail(pm, 0)) {
597 midivalue = portman_read_midi(pm, 0);
599 if (pm->mode[0] & PORTMAN2X4_MODE_INPUT_TRIGGERED)
600 snd_rawmidi_receive(pm->midi_input[0],
606 if (portman_data_avail(pm, 1)) {
608 midivalue = portman_read_midi(pm, 1);
610 if (pm->mode[1] & PORTMAN2X4_MODE_INPUT_TRIGGERED)
611 snd_rawmidi_receive(pm->midi_input[1],
671 struct portman *pm = card->private_data;
672 struct pardevice *pardev = pm->pardev;
679 portman_free(pm);
688 struct portman *pm = NULL;
734 err = portman_create(card, pardev, &pm);
739 card->private_data = pm;
755 err = portman_device_init(pm);