Lines Matching defs:card_mpuin
42 static int emu10k1_mpuin_callback(struct emu10k1_mpuin *card_mpuin, u32 msg, unsigned long data, u32 bytesvalid);
99 struct emu10k1_mpuin *card_mpuin = card->mpuin;
103 if (!(card_mpuin->status & FLAGS_AVAILABLE))
107 card_mpuin->openinfo = *openinfo;
108 card_mpuin->status &= ~FLAGS_AVAILABLE; /* clear */
109 card_mpuin->status |= FLAGS_READY; /* set */
110 card_mpuin->status &= ~FLAGS_MIDM_STARTED; /* clear */
111 card_mpuin->firstmidiq = NULL;
112 card_mpuin->lastmidiq = NULL;
113 card_mpuin->qhead = 0;
114 card_mpuin->qtail = 0;
116 sblive_miStateInit(card_mpuin);
126 struct emu10k1_mpuin *card_mpuin = card->mpuin;
131 if (card_mpuin->firstmidiq != NULL) {
141 card_mpuin->status |= FLAGS_AVAILABLE; /* set */
142 card_mpuin->status &= ~FLAGS_MIDM_STARTED; /* clear */
149 int emu10k1_mpuin_add_buffer(struct emu10k1_mpuin *card_mpuin, struct midi_hdr *midihdr)
172 spin_lock_irqsave(&card_mpuin->lock, flags);
174 if (card_mpuin->firstmidiq == NULL) {
175 card_mpuin->firstmidiq = midiq;
176 card_mpuin->lastmidiq = midiq;
178 (card_mpuin->lastmidiq)->next = midiq;
179 card_mpuin->lastmidiq = midiq;
182 spin_unlock_irqrestore(&card_mpuin->lock, flags);
193 struct emu10k1_mpuin *card_mpuin = card->mpuin;
199 if (card_mpuin->status & FLAGS_MIDM_STARTED) {
204 card_mpuin->status |= FLAGS_MIDM_STARTED; /* set */
207 card_mpuin->timestart = (jiffies * 1000) / HZ;
208 DPD(2, "New Time Stamp = %d\n", card_mpuin->timestart);
210 card_mpuin->qhead = 0;
211 card_mpuin->qtail = 0;
225 struct emu10k1_mpuin *card_mpuin = card->mpuin;
233 card_mpuin->status &= ~FLAGS_MIDM_STARTED; /* clear */
235 if (card_mpuin->firstmidiq) {
236 spin_lock_irqsave(&card_mpuin->lock, flags);
238 midiq = card_mpuin->firstmidiq;
243 card_mpuin->firstmidiq = midiq->next;
244 if (card_mpuin->firstmidiq == NULL)
245 card_mpuin->lastmidiq = NULL;
249 spin_unlock_irqrestore(&card_mpuin->lock, flags);
252 emu10k1_mpuin_callback(card_mpuin, ICARDMIDI_INLONGERROR, (unsigned long) midiq, 0);
265 struct emu10k1_mpuin *card_mpuin = card->mpuin;
272 while (card_mpuin->firstmidiq) {
273 midiq = card_mpuin->firstmidiq;
274 card_mpuin->firstmidiq = midiq->next;
277 emu10k1_mpuin_callback(card_mpuin, ICARDMIDI_INLONGDATA, (unsigned long) midiq, 0);
279 emu10k1_mpuin_callback(card_mpuin, ICARDMIDI_INLONGERROR, (unsigned long) midiq, 0);
284 card_mpuin->lastmidiq = NULL;
285 card_mpuin->status &= ~FLAGS_MIDM_STARTED;
293 static int emu10k1_mpuin_callback(struct emu10k1_mpuin *card_mpuin, u32 msg, unsigned long data, u32 bytesvalid)
301 * 1. card_mpuin
305 timein = card_mpuin->timein;
306 if (card_mpuin->timestart <= timein)
307 callback_msg[0] = timein - card_mpuin->timestart;
309 callback_msg[0] = (~0x0L - card_mpuin->timestart) + timein;
328 emu10k1_midi_callback(msg, card_mpuin->openinfo.refdata, callback_msg);
337 struct emu10k1_mpuin *card_mpuin = (struct emu10k1_mpuin *) refdata;
340 while (card_mpuin->qhead != card_mpuin->qtail) {
341 spin_lock_irqsave(&card_mpuin->lock, flags);
342 idx = card_mpuin->qhead;
343 data = card_mpuin->midiq[idx].data;
344 card_mpuin->timein = card_mpuin->midiq[idx].timein;
346 card_mpuin->qhead = idx;
347 spin_unlock_irqrestore(&card_mpuin->lock, flags);
349 sblive_miStateEntry(card_mpuin, data);
362 struct emu10k1_mpuin *card_mpuin = card->mpuin;
365 * 1. card_mpuin
369 idx = card_mpuin->qtail;
376 card_mpuin->midiq[idx].data = MPUIvalue;
377 card_mpuin->midiq[idx].timein = (jiffies * 1000) / HZ;
383 card_mpuin->qtail = idx;
385 tasklet_hi_schedule(&card_mpuin->tasklet);
397 static int sblive_miStateInit(struct emu10k1_mpuin *card_mpuin)
399 card_mpuin->status = 0; /* For MIDI running status */
400 card_mpuin->fstatus = 0; /* For 0xFn status only */
401 card_mpuin->curstate = STIN_PARSE;
402 card_mpuin->laststate = STIN_PARSE;
403 card_mpuin->data = 0;
404 card_mpuin->timestart = 0;
405 card_mpuin->timein = 0;
410 static int sblive_miStateEntry(struct emu10k1_mpuin *card_mpuin, u8 data)
412 return midistatefn[card_mpuin->curstate].Fn(card_mpuin, data);
415 static int sblive_miStateParse(struct emu10k1_mpuin *card_mpuin, u8 data)
423 card_mpuin->curstate = STIN_3BYTE;
428 card_mpuin->curstate = STIN_2BYTE;
435 card_mpuin->laststate = card_mpuin->curstate;
436 card_mpuin->curstate = STIN_SYS_EX_NORM;
438 if (card_mpuin->firstmidiq) {
441 midiq = card_mpuin->firstmidiq;
450 emu10k1_mpuin_callback(card_mpuin, ICARDMIDI_INDATAERROR, 0xf7, 0);
454 card_mpuin->laststate = card_mpuin->curstate;
455 card_mpuin->curstate = STIN_SYS_COMMON_3;
460 card_mpuin->laststate = card_mpuin->curstate;
461 card_mpuin->curstate = STIN_SYS_COMMON_2;
466 return midistatefn[STIN_SYS_REAL].Fn(card_mpuin, data);
476 return midistatefn[card_mpuin->curstate].Fn(card_mpuin, data);
479 static int sblive_miState3Byte(struct emu10k1_mpuin *card_mpuin, u8 data)
484 return midistatefn[STIN_3BYTE_KEY].Fn(card_mpuin, data);
486 card_mpuin->status = data;
487 card_mpuin->curstate = STIN_3BYTE_KEY;
492 return midistatefn[STIN_PARSE].Fn(card_mpuin, data);
495 static int sblive_miState3ByteKey(struct emu10k1_mpuin *card_mpuin, u8 data)
503 return midistatefn[STIN_SYS_REAL].Fn(card_mpuin, data);
508 card_mpuin->curstate = STIN_PARSE;
510 tmp |= (unsigned long) card_mpuin->status;
512 emu10k1_mpuin_callback(card_mpuin, ICARDMIDI_INDATAERROR, tmp, 0);
517 card_mpuin->data = data;
518 card_mpuin->curstate = STIN_3BYTE_VEL;
523 static int sblive_miState3ByteVel(struct emu10k1_mpuin *card_mpuin, u8 data)
531 return midistatefn[STIN_SYS_REAL].Fn(card_mpuin, data);
536 card_mpuin->curstate = STIN_PARSE;
538 tmp |= card_mpuin->data;
540 tmp |= (unsigned long) card_mpuin->status;
542 emu10k1_mpuin_callback(card_mpuin, ICARDMIDI_INDATAERROR, tmp, 0);
547 card_mpuin->curstate = STIN_3BYTE;
550 tmp |= (unsigned long) card_mpuin->data;
552 tmp |= (unsigned long) card_mpuin->status;
554 emu10k1_mpuin_callback(card_mpuin, ICARDMIDI_INDATA, tmp, 3);
559 static int sblive_miState2Byte(struct emu10k1_mpuin *card_mpuin, u8 data)
564 card_mpuin->status = data;
565 card_mpuin->curstate = STIN_2BYTE_KEY;
571 return midistatefn[STIN_2BYTE_KEY].Fn(card_mpuin, data);
573 return midistatefn[STIN_PARSE].Fn(card_mpuin, data);
576 static int sblive_miState2ByteKey(struct emu10k1_mpuin *card_mpuin, u8 data)
584 return midistatefn[STIN_SYS_REAL].Fn(card_mpuin, data);
589 card_mpuin->curstate = STIN_PARSE;
592 tmp |= (unsigned long) card_mpuin->status;
594 emu10k1_mpuin_callback(card_mpuin, ICARDMIDI_INDATAERROR, tmp, 0);
599 card_mpuin->curstate = STIN_2BYTE;
602 tmp |= (unsigned long) card_mpuin->status;
604 emu10k1_mpuin_callback(card_mpuin, ICARDMIDI_INDATA, tmp, 2);
609 static int sblive_miStateSysCommon2(struct emu10k1_mpuin *card_mpuin, u8 data)
611 card_mpuin->fstatus = data;
612 card_mpuin->curstate = STIN_SYS_COMMON_2_KEY;
617 static int sblive_miStateSysCommon2Key(struct emu10k1_mpuin *card_mpuin, u8 data)
625 return midistatefn[STIN_SYS_REAL].Fn(card_mpuin, data);
630 card_mpuin->curstate = card_mpuin->laststate;
633 tmp |= (unsigned long) card_mpuin->fstatus;
635 emu10k1_mpuin_callback(card_mpuin, ICARDMIDI_INDATAERROR, tmp, 0);
640 card_mpuin->curstate = card_mpuin->laststate;
643 tmp |= (unsigned long) card_mpuin->fstatus;
645 emu10k1_mpuin_callback(card_mpuin, ICARDMIDI_INDATA, tmp, 2);
650 static int sblive_miStateSysCommon3(struct emu10k1_mpuin *card_mpuin, u8 data)
652 card_mpuin->fstatus = data;
653 card_mpuin->curstate = STIN_SYS_COMMON_3_KEY;
658 static int sblive_miStateSysCommon3Key(struct emu10k1_mpuin *card_mpuin, u8 data)
666 return midistatefn[STIN_SYS_REAL].Fn(card_mpuin, data);
671 card_mpuin->curstate = card_mpuin->laststate;
674 tmp |= (unsigned long) card_mpuin->fstatus;
676 emu10k1_mpuin_callback(card_mpuin, ICARDMIDI_INDATAERROR, tmp, 0);
681 card_mpuin->data = data;
682 card_mpuin->curstate = STIN_SYS_COMMON_3_VEL;
687 static int sblive_miStateSysCommon3Vel(struct emu10k1_mpuin *card_mpuin, u8 data)
695 return midistatefn[STIN_SYS_REAL].Fn(card_mpuin, data);
700 card_mpuin->curstate = card_mpuin->laststate;
703 tmp |= (unsigned long) card_mpuin->data;
705 tmp |= (unsigned long) card_mpuin->fstatus;
707 emu10k1_mpuin_callback(card_mpuin, ICARDMIDI_INDATAERROR, tmp, 0);
712 card_mpuin->curstate = card_mpuin->laststate;
715 tmp |= (unsigned long) card_mpuin->data;
717 tmp |= (unsigned long) card_mpuin->fstatus;
719 emu10k1_mpuin_callback(card_mpuin, ICARDMIDI_INDATA, tmp, 3);
724 static int sblive_miStateSysExNorm(struct emu10k1_mpuin *card_mpuin, u8 data)
731 return midistatefn[STIN_SYS_REAL].Fn(card_mpuin, data);
736 card_mpuin->curstate = card_mpuin->laststate;
738 if (card_mpuin->firstmidiq) {
741 midiq = card_mpuin->firstmidiq;
746 spin_lock_irqsave(&card_mpuin->lock, flags);
748 card_mpuin->firstmidiq = midiq->next;
749 if (card_mpuin->firstmidiq == NULL)
750 card_mpuin->lastmidiq = NULL;
752 spin_unlock_irqrestore(&card_mpuin->lock, flags);
754 emu10k1_mpuin_callback(card_mpuin, ICARDMIDI_INLONGERROR, (unsigned long) midiq, 0);
762 if (card_mpuin->firstmidiq) {
765 midiq = card_mpuin->firstmidiq;
775 card_mpuin->curstate = card_mpuin->laststate;
777 if (card_mpuin->firstmidiq) {
780 midiq = card_mpuin->firstmidiq;
782 spin_lock_irqsave(&card_mpuin->lock, flags);
784 card_mpuin->firstmidiq = midiq->next;
785 if (card_mpuin->firstmidiq == NULL)
786 card_mpuin->lastmidiq = NULL;
788 spin_unlock_irqrestore(&card_mpuin->lock, flags);
790 emu10k1_mpuin_callback(card_mpuin, ICARDMIDI_INLONGDATA, (unsigned long) midiq, 0);
798 if (card_mpuin->firstmidiq) {
801 midiq = card_mpuin->firstmidiq;
806 spin_lock_irqsave(&card_mpuin->lock, flags);
808 card_mpuin->firstmidiq = midiq->next;
809 if (card_mpuin->firstmidiq == NULL)
810 card_mpuin->lastmidiq = NULL;
812 spin_unlock_irqrestore(&card_mpuin->lock, flags);
814 emu10k1_mpuin_callback(card_mpuin, ICARDMIDI_INLONGDATA, (unsigned long) midiq, 0);
825 static int sblive_miStateSysReal(struct emu10k1_mpuin *card_mpuin, u8 data)
827 emu10k1_mpuin_callback(card_mpuin, ICARDMIDI_INDATA, data, 1);