korg1212          508 sound/pci/korg1212/korg1212.c static int snd_korg1212_Send1212Command(struct snd_korg1212 *korg1212,
korg1212          517 sound/pci/korg1212/korg1212.c         if (!korg1212->outDoorbellPtr) {
korg1212          523 sound/pci/korg1212/korg1212.c 			   doorbellVal, mailBox0Val, stateName[korg1212->cardState]);
korg1212          525 sound/pci/korg1212/korg1212.c 		writel(mailBox3Val, korg1212->mailbox3Ptr);
korg1212          526 sound/pci/korg1212/korg1212.c                 writel(mailBox2Val, korg1212->mailbox2Ptr);
korg1212          527 sound/pci/korg1212/korg1212.c                 writel(mailBox1Val, korg1212->mailbox1Ptr);
korg1212          528 sound/pci/korg1212/korg1212.c                 writel(mailBox0Val, korg1212->mailbox0Ptr);
korg1212          529 sound/pci/korg1212/korg1212.c                 writel(doorbellVal, korg1212->outDoorbellPtr);  // interrupt the card
korg1212          547 sound/pci/korg1212/korg1212.c                 mailBox3Lo = readl(korg1212->mailbox3Ptr);
korg1212          556 sound/pci/korg1212/korg1212.c         korg1212->cmdRetryCount += retryCount;
korg1212          567 sound/pci/korg1212/korg1212.c static void snd_korg1212_SendStop(struct snd_korg1212 *korg1212)
korg1212          569 sound/pci/korg1212/korg1212.c 	if (! korg1212->stop_pending_cnt) {
korg1212          570 sound/pci/korg1212/korg1212.c 		korg1212->sharedBufferPtr->cardCommand = 0xffffffff;
korg1212          572 sound/pci/korg1212/korg1212.c 		korg1212->stop_pending_cnt = HZ;
korg1212          573 sound/pci/korg1212/korg1212.c 		mod_timer(&korg1212->timer, jiffies + 1);
korg1212          577 sound/pci/korg1212/korg1212.c static void snd_korg1212_SendStopAndWait(struct snd_korg1212 *korg1212)
korg1212          580 sound/pci/korg1212/korg1212.c 	spin_lock_irqsave(&korg1212->lock, flags);
korg1212          581 sound/pci/korg1212/korg1212.c 	korg1212->dsp_stop_is_processed = 0;
korg1212          582 sound/pci/korg1212/korg1212.c 	snd_korg1212_SendStop(korg1212);
korg1212          583 sound/pci/korg1212/korg1212.c 	spin_unlock_irqrestore(&korg1212->lock, flags);
korg1212          584 sound/pci/korg1212/korg1212.c 	wait_event_timeout(korg1212->wait, korg1212->dsp_stop_is_processed, (HZ * 3) / 2);
korg1212          590 sound/pci/korg1212/korg1212.c 	struct snd_korg1212 *korg1212 = from_timer(korg1212, t, timer);
korg1212          593 sound/pci/korg1212/korg1212.c 	spin_lock_irqsave(&korg1212->lock, flags);
korg1212          594 sound/pci/korg1212/korg1212.c 	if (korg1212->sharedBufferPtr->cardCommand == 0) {
korg1212          596 sound/pci/korg1212/korg1212.c 		korg1212->stop_pending_cnt = 0;
korg1212          597 sound/pci/korg1212/korg1212.c 		korg1212->dsp_stop_is_processed = 1;
korg1212          598 sound/pci/korg1212/korg1212.c 		wake_up(&korg1212->wait);
korg1212          600 sound/pci/korg1212/korg1212.c 					   stateName[korg1212->cardState]);
korg1212          602 sound/pci/korg1212/korg1212.c 		if (--korg1212->stop_pending_cnt > 0) {
korg1212          604 sound/pci/korg1212/korg1212.c 			mod_timer(&korg1212->timer, jiffies + 1);
korg1212          607 sound/pci/korg1212/korg1212.c 			korg1212->sharedBufferPtr->cardCommand = 0;
korg1212          608 sound/pci/korg1212/korg1212.c 			korg1212->dsp_stop_is_processed = 1;
korg1212          609 sound/pci/korg1212/korg1212.c 			wake_up(&korg1212->wait);
korg1212          611 sound/pci/korg1212/korg1212.c 					   stateName[korg1212->cardState]);
korg1212          614 sound/pci/korg1212/korg1212.c 	spin_unlock_irqrestore(&korg1212->lock, flags);
korg1212          617 sound/pci/korg1212/korg1212.c static int snd_korg1212_TurnOnIdleMonitor(struct snd_korg1212 *korg1212)
korg1212          623 sound/pci/korg1212/korg1212.c 	spin_lock_irqsave(&korg1212->lock, flags);
korg1212          624 sound/pci/korg1212/korg1212.c         korg1212->idleMonitorOn = 1;
korg1212          625 sound/pci/korg1212/korg1212.c         rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_SelectPlayMode,
korg1212          627 sound/pci/korg1212/korg1212.c         spin_unlock_irqrestore(&korg1212->lock, flags);
korg1212          631 sound/pci/korg1212/korg1212.c static void snd_korg1212_TurnOffIdleMonitor(struct snd_korg1212 *korg1212)
korg1212          633 sound/pci/korg1212/korg1212.c         if (korg1212->idleMonitorOn) {
korg1212          634 sound/pci/korg1212/korg1212.c 		snd_korg1212_SendStopAndWait(korg1212);
korg1212          635 sound/pci/korg1212/korg1212.c                 korg1212->idleMonitorOn = 0;
korg1212          639 sound/pci/korg1212/korg1212.c static inline void snd_korg1212_setCardState(struct snd_korg1212 * korg1212, enum CardState csState)
korg1212          641 sound/pci/korg1212/korg1212.c         korg1212->cardState = csState;
korg1212          644 sound/pci/korg1212/korg1212.c static int snd_korg1212_OpenCard(struct snd_korg1212 * korg1212)
korg1212          647 sound/pci/korg1212/korg1212.c 			   stateName[korg1212->cardState], korg1212->opencnt);
korg1212          648 sound/pci/korg1212/korg1212.c 	mutex_lock(&korg1212->open_mutex);
korg1212          649 sound/pci/korg1212/korg1212.c         if (korg1212->opencnt++ == 0) {
korg1212          650 sound/pci/korg1212/korg1212.c 		snd_korg1212_TurnOffIdleMonitor(korg1212);
korg1212          651 sound/pci/korg1212/korg1212.c 		snd_korg1212_setCardState(korg1212, K1212_STATE_OPEN);
korg1212          654 sound/pci/korg1212/korg1212.c 	mutex_unlock(&korg1212->open_mutex);
korg1212          658 sound/pci/korg1212/korg1212.c static int snd_korg1212_CloseCard(struct snd_korg1212 * korg1212)
korg1212          661 sound/pci/korg1212/korg1212.c 			   stateName[korg1212->cardState], korg1212->opencnt);
korg1212          663 sound/pci/korg1212/korg1212.c 	mutex_lock(&korg1212->open_mutex);
korg1212          664 sound/pci/korg1212/korg1212.c 	if (--(korg1212->opencnt)) {
korg1212          665 sound/pci/korg1212/korg1212.c 		mutex_unlock(&korg1212->open_mutex);
korg1212          669 sound/pci/korg1212/korg1212.c         if (korg1212->cardState == K1212_STATE_SETUP) {
korg1212          670 sound/pci/korg1212/korg1212.c                 int rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_SelectPlayMode,
korg1212          674 sound/pci/korg1212/korg1212.c 					   rc, stateName[korg1212->cardState]);
korg1212          676 sound/pci/korg1212/korg1212.c 			mutex_unlock(&korg1212->open_mutex);
korg1212          679 sound/pci/korg1212/korg1212.c         } else if (korg1212->cardState > K1212_STATE_SETUP) {
korg1212          680 sound/pci/korg1212/korg1212.c 		snd_korg1212_SendStopAndWait(korg1212);
korg1212          683 sound/pci/korg1212/korg1212.c         if (korg1212->cardState > K1212_STATE_READY) {
korg1212          684 sound/pci/korg1212/korg1212.c 		snd_korg1212_TurnOnIdleMonitor(korg1212);
korg1212          685 sound/pci/korg1212/korg1212.c                 snd_korg1212_setCardState(korg1212, K1212_STATE_READY);
korg1212          688 sound/pci/korg1212/korg1212.c 	mutex_unlock(&korg1212->open_mutex);
korg1212          693 sound/pci/korg1212/korg1212.c static int snd_korg1212_SetupForPlay(struct snd_korg1212 * korg1212)
korg1212          698 sound/pci/korg1212/korg1212.c 			   stateName[korg1212->cardState], korg1212->setcnt);
korg1212          700 sound/pci/korg1212/korg1212.c         if (korg1212->setcnt++)
korg1212          703 sound/pci/korg1212/korg1212.c         snd_korg1212_setCardState(korg1212, K1212_STATE_SETUP);
korg1212          704 sound/pci/korg1212/korg1212.c         rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_SelectPlayMode,
korg1212          708 sound/pci/korg1212/korg1212.c 				   rc, stateName[korg1212->cardState]);
korg1212          716 sound/pci/korg1212/korg1212.c static int snd_korg1212_TriggerPlay(struct snd_korg1212 * korg1212)
korg1212          721 sound/pci/korg1212/korg1212.c 			   stateName[korg1212->cardState], korg1212->playcnt);
korg1212          723 sound/pci/korg1212/korg1212.c         if (korg1212->playcnt++)
korg1212          726 sound/pci/korg1212/korg1212.c         snd_korg1212_setCardState(korg1212, K1212_STATE_PLAYING);
korg1212          727 sound/pci/korg1212/korg1212.c         rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_TriggerPlay, 0, 0, 0, 0);
korg1212          730 sound/pci/korg1212/korg1212.c 				   rc, stateName[korg1212->cardState]);
korg1212          738 sound/pci/korg1212/korg1212.c static int snd_korg1212_StopPlay(struct snd_korg1212 * korg1212)
korg1212          741 sound/pci/korg1212/korg1212.c 			   stateName[korg1212->cardState], korg1212->playcnt);
korg1212          743 sound/pci/korg1212/korg1212.c         if (--(korg1212->playcnt)) 
korg1212          746 sound/pci/korg1212/korg1212.c 	korg1212->setcnt = 0;
korg1212          748 sound/pci/korg1212/korg1212.c         if (korg1212->cardState != K1212_STATE_ERRORSTOP)
korg1212          749 sound/pci/korg1212/korg1212.c 		snd_korg1212_SendStop(korg1212);
korg1212          751 sound/pci/korg1212/korg1212.c 	snd_korg1212_setCardState(korg1212, K1212_STATE_OPEN);
korg1212          755 sound/pci/korg1212/korg1212.c static void snd_korg1212_EnableCardInterrupts(struct snd_korg1212 * korg1212)
korg1212          762 sound/pci/korg1212/korg1212.c 	       korg1212->statusRegPtr);
korg1212          767 sound/pci/korg1212/korg1212.c static int snd_korg1212_SetMonitorMode(struct snd_korg1212 *korg1212,
korg1212          771 sound/pci/korg1212/korg1212.c 			   stateName[korg1212->cardState]);
korg1212          775 sound/pci/korg1212/korg1212.c 		if (korg1212->cardState != K1212_STATE_MONITOR)
korg1212          778 sound/pci/korg1212/korg1212.c 			snd_korg1212_SendStopAndWait(korg1212);
korg1212          779 sound/pci/korg1212/korg1212.c 			snd_korg1212_setCardState(korg1212, K1212_STATE_OPEN);
korg1212          784 sound/pci/korg1212/korg1212.c 		if (korg1212->cardState != K1212_STATE_OPEN)
korg1212          788 sound/pci/korg1212/korg1212.c 			snd_korg1212_setCardState(korg1212, K1212_STATE_MONITOR);
korg1212          789 sound/pci/korg1212/korg1212.c 			rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_SelectPlayMode,
korg1212          805 sound/pci/korg1212/korg1212.c static inline int snd_korg1212_use_is_exclusive(struct snd_korg1212 *korg1212)
korg1212          807 sound/pci/korg1212/korg1212.c 	if (korg1212->playback_pid != korg1212->capture_pid &&
korg1212          808 sound/pci/korg1212/korg1212.c 	    korg1212->playback_pid >= 0 && korg1212->capture_pid >= 0)
korg1212          814 sound/pci/korg1212/korg1212.c static int snd_korg1212_SetRate(struct snd_korg1212 *korg1212, int rate)
korg1212          828 sound/pci/korg1212/korg1212.c 	if (!snd_korg1212_use_is_exclusive (korg1212))
korg1212          833 sound/pci/korg1212/korg1212.c 		parm = s44[korg1212->clkSource];
korg1212          837 sound/pci/korg1212/korg1212.c 		parm = s48[korg1212->clkSource];
korg1212          844 sound/pci/korg1212/korg1212.c         korg1212->clkSrcRate = parm;
korg1212          845 sound/pci/korg1212/korg1212.c         korg1212->clkRate = rate;
korg1212          848 sound/pci/korg1212/korg1212.c 	rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_SetClockSourceRate,
korg1212          849 sound/pci/korg1212/korg1212.c 					  ClockSourceSelector[korg1212->clkSrcRate],
korg1212          853 sound/pci/korg1212/korg1212.c 				   rc, stateName[korg1212->cardState]);
korg1212          858 sound/pci/korg1212/korg1212.c static int snd_korg1212_SetClockSource(struct snd_korg1212 *korg1212, int source)
korg1212          864 sound/pci/korg1212/korg1212.c         korg1212->clkSource = source;
korg1212          866 sound/pci/korg1212/korg1212.c         snd_korg1212_SetRate(korg1212, korg1212->clkRate);
korg1212          871 sound/pci/korg1212/korg1212.c static void snd_korg1212_DisableCardInterrupts(struct snd_korg1212 *korg1212)
korg1212          873 sound/pci/korg1212/korg1212.c 	writel(0, korg1212->statusRegPtr);
korg1212          876 sound/pci/korg1212/korg1212.c static int snd_korg1212_WriteADCSensitivity(struct snd_korg1212 *korg1212)
korg1212          889 sound/pci/korg1212/korg1212.c 			   stateName[korg1212->cardState]);
korg1212          901 sound/pci/korg1212/korg1212.c         if (korg1212->cardState == K1212_STATE_MONITOR || korg1212->idleMonitorOn) {
korg1212          903 sound/pci/korg1212/korg1212.c 		snd_korg1212_SendStopAndWait(korg1212);
korg1212          907 sound/pci/korg1212/korg1212.c 	spin_lock_irqsave(&korg1212->lock, flags);
korg1212          913 sound/pci/korg1212/korg1212.c         writel(0, korg1212->mailbox3Ptr);
korg1212          920 sound/pci/korg1212/korg1212.c         switch (korg1212->clkSrcRate) {
korg1212          940 sound/pci/korg1212/korg1212.c         sensVals.l.v.leftChanVal  = korg1212->leftADCInSens;
korg1212          941 sound/pci/korg1212/korg1212.c         sensVals.r.v.rightChanVal = korg1212->rightADCInSens;
korg1212          954 sound/pci/korg1212/korg1212.c                 writew(controlValue, korg1212->sensRegPtr);                          // load/shift goes low
korg1212          971 sound/pci/korg1212/korg1212.c                         writew(controlValue, korg1212->sensRegPtr);                       // clock goes low
korg1212          974 sound/pci/korg1212/korg1212.c                         writew(controlValue, korg1212->sensRegPtr);                       // clock goes high
korg1212          985 sound/pci/korg1212/korg1212.c                 writew(controlValue, korg1212->sensRegPtr);                   // load shift goes high - clk low
korg1212          991 sound/pci/korg1212/korg1212.c                 writew(controlValue, korg1212->sensRegPtr);                   // set/clear data bit
korg1212          994 sound/pci/korg1212/korg1212.c                 writew(controlValue, korg1212->sensRegPtr);                   // clock goes high
korg1212          997 sound/pci/korg1212/korg1212.c                 writew(controlValue, korg1212->sensRegPtr);                   // clock goes low
korg1212         1009 sound/pci/korg1212/korg1212.c                 int rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_SelectPlayMode,
korg1212         1013 sound/pci/korg1212/korg1212.c 					   rc, stateName[korg1212->cardState]);
korg1212         1016 sound/pci/korg1212/korg1212.c 	spin_unlock_irqrestore(&korg1212->lock, flags);
korg1212         1021 sound/pci/korg1212/korg1212.c static void snd_korg1212_OnDSPDownloadComplete(struct snd_korg1212 *korg1212)
korg1212         1026 sound/pci/korg1212/korg1212.c 			   stateName[korg1212->cardState]);
korg1212         1031 sound/pci/korg1212/korg1212.c         rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_BootFromDSPPage4, 0, 0, 0, 0);
korg1212         1035 sound/pci/korg1212/korg1212.c 				   rc, stateName[korg1212->cardState]);
korg1212         1041 sound/pci/korg1212/korg1212.c         rc = snd_korg1212_Send1212Command(korg1212,
korg1212         1043 sound/pci/korg1212/korg1212.c                         LowerWordSwap(korg1212->PlayDataPhy),
korg1212         1044 sound/pci/korg1212/korg1212.c                         LowerWordSwap(korg1212->RecDataPhy),
korg1212         1052 sound/pci/korg1212/korg1212.c 				   rc, stateName[korg1212->cardState]);
korg1212         1056 sound/pci/korg1212/korg1212.c         rc = snd_korg1212_Send1212Command(korg1212,
korg1212         1058 sound/pci/korg1212/korg1212.c                         LowerWordSwap(korg1212->VolumeTablePhy),
korg1212         1059 sound/pci/korg1212/korg1212.c                         LowerWordSwap(korg1212->RoutingTablePhy),
korg1212         1060 sound/pci/korg1212/korg1212.c                         LowerWordSwap(korg1212->AdatTimeCodePhy),
korg1212         1066 sound/pci/korg1212/korg1212.c 				   rc, stateName[korg1212->cardState]);
korg1212         1074 sound/pci/korg1212/korg1212.c                 korg1212->sharedBufferPtr->volumeData[channel] = k1212MaxVolume;
korg1212         1076 sound/pci/korg1212/korg1212.c                 korg1212->sharedBufferPtr->routeData[channel] = 8 + (channel & 1);
korg1212         1079 sound/pci/korg1212/korg1212.c         snd_korg1212_WriteADCSensitivity(korg1212);
korg1212         1082 sound/pci/korg1212/korg1212.c 	rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_SetClockSourceRate,
korg1212         1083 sound/pci/korg1212/korg1212.c 					  ClockSourceSelector[korg1212->clkSrcRate],
korg1212         1087 sound/pci/korg1212/korg1212.c 				   rc, stateName[korg1212->cardState]);
korg1212         1089 sound/pci/korg1212/korg1212.c 	rc = snd_korg1212_TurnOnIdleMonitor(korg1212);
korg1212         1090 sound/pci/korg1212/korg1212.c 	snd_korg1212_setCardState(korg1212, K1212_STATE_READY);
korg1212         1094 sound/pci/korg1212/korg1212.c 				   rc, stateName[korg1212->cardState]);
korg1212         1096 sound/pci/korg1212/korg1212.c 	snd_korg1212_setCardState(korg1212, K1212_STATE_DSP_COMPLETE);
korg1212         1102 sound/pci/korg1212/korg1212.c         struct snd_korg1212 *korg1212 = dev_id;
korg1212         1104 sound/pci/korg1212/korg1212.c         doorbellValue = readl(korg1212->inDoorbellPtr);
korg1212         1109 sound/pci/korg1212/korg1212.c 	spin_lock(&korg1212->lock);
korg1212         1111 sound/pci/korg1212/korg1212.c 	writel(doorbellValue, korg1212->inDoorbellPtr);
korg1212         1113 sound/pci/korg1212/korg1212.c         korg1212->irqcount++;
korg1212         1115 sound/pci/korg1212/korg1212.c 	korg1212->inIRQ++;
korg1212         1120 sound/pci/korg1212/korg1212.c 					   korg1212->irqcount, doorbellValue,
korg1212         1121 sound/pci/korg1212/korg1212.c 					   stateName[korg1212->cardState]);
korg1212         1122 sound/pci/korg1212/korg1212.c                         if (korg1212->cardState == K1212_STATE_DSP_IN_PROCESS) {
korg1212         1123 sound/pci/korg1212/korg1212.c 				korg1212->dsp_is_loaded = 1;
korg1212         1124 sound/pci/korg1212/korg1212.c 				wake_up(&korg1212->wait);
korg1212         1133 sound/pci/korg1212/korg1212.c 						   korg1212->irqcount, doorbellValue,
korg1212         1134 sound/pci/korg1212/korg1212.c 						   stateName[korg1212->cardState]);
korg1212         1136 sound/pci/korg1212/korg1212.c 			korg1212->errorcnt++;
korg1212         1137 sound/pci/korg1212/korg1212.c 			korg1212->totalerrorcnt++;
korg1212         1138 sound/pci/korg1212/korg1212.c 			korg1212->sharedBufferPtr->cardCommand = 0;
korg1212         1139 sound/pci/korg1212/korg1212.c 			snd_korg1212_setCardState(korg1212, K1212_STATE_ERRORSTOP);
korg1212         1148 sound/pci/korg1212/korg1212.c 						   korg1212->irqcount, doorbellValue,
korg1212         1149 sound/pci/korg1212/korg1212.c 						   stateName[korg1212->cardState]);
korg1212         1150 sound/pci/korg1212/korg1212.c 			korg1212->sharedBufferPtr->cardCommand = 0;
korg1212         1155 sound/pci/korg1212/korg1212.c 			       korg1212->irqcount, doorbellValue, 
korg1212         1156 sound/pci/korg1212/korg1212.c 			       korg1212->currentBuffer, stateName[korg1212->cardState]);
korg1212         1157 sound/pci/korg1212/korg1212.c                         if ((korg1212->cardState > K1212_STATE_SETUP) || korg1212->idleMonitorOn) {
korg1212         1158 sound/pci/korg1212/korg1212.c                                 korg1212->currentBuffer++;
korg1212         1160 sound/pci/korg1212/korg1212.c                                 if (korg1212->currentBuffer >= kNumBuffers)
korg1212         1161 sound/pci/korg1212/korg1212.c                                         korg1212->currentBuffer = 0;
korg1212         1163 sound/pci/korg1212/korg1212.c                                 if (!korg1212->running)
korg1212         1166 sound/pci/korg1212/korg1212.c                                 if (korg1212->capture_substream) {
korg1212         1167 sound/pci/korg1212/korg1212.c 					spin_unlock(&korg1212->lock);
korg1212         1168 sound/pci/korg1212/korg1212.c                                         snd_pcm_period_elapsed(korg1212->capture_substream);
korg1212         1169 sound/pci/korg1212/korg1212.c 					spin_lock(&korg1212->lock);
korg1212         1172 sound/pci/korg1212/korg1212.c                                 if (korg1212->playback_substream) {
korg1212         1173 sound/pci/korg1212/korg1212.c 					spin_unlock(&korg1212->lock);
korg1212         1174 sound/pci/korg1212/korg1212.c                                         snd_pcm_period_elapsed(korg1212->playback_substream);
korg1212         1175 sound/pci/korg1212/korg1212.c 					spin_lock(&korg1212->lock);
korg1212         1181 sound/pci/korg1212/korg1212.c 	korg1212->inIRQ--;
korg1212         1183 sound/pci/korg1212/korg1212.c 	spin_unlock(&korg1212->lock);
korg1212         1188 sound/pci/korg1212/korg1212.c static int snd_korg1212_downloadDSPCode(struct snd_korg1212 *korg1212)
korg1212         1193 sound/pci/korg1212/korg1212.c 			   stateName[korg1212->cardState]);
korg1212         1198 sound/pci/korg1212/korg1212.c         if (korg1212->cardState >= K1212_STATE_DSP_IN_PROCESS)
korg1212         1201 sound/pci/korg1212/korg1212.c         snd_korg1212_setCardState(korg1212, K1212_STATE_DSP_IN_PROCESS);
korg1212         1203 sound/pci/korg1212/korg1212.c         rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_StartDSPDownload,
korg1212         1204 sound/pci/korg1212/korg1212.c                                      UpperWordSwap(korg1212->dma_dsp.addr),
korg1212         1208 sound/pci/korg1212/korg1212.c 				   rc, stateName[korg1212->cardState]);
korg1212         1210 sound/pci/korg1212/korg1212.c 	korg1212->dsp_is_loaded = 0;
korg1212         1211 sound/pci/korg1212/korg1212.c 	wait_event_timeout(korg1212->wait, korg1212->dsp_is_loaded, HZ * CARD_BOOT_TIMEOUT);
korg1212         1212 sound/pci/korg1212/korg1212.c 	if (! korg1212->dsp_is_loaded )
korg1212         1215 sound/pci/korg1212/korg1212.c 	snd_korg1212_OnDSPDownloadComplete(korg1212);
korg1212         1262 sound/pci/korg1212/korg1212.c static int snd_korg1212_silence(struct snd_korg1212 *korg1212, int pos, int count, int offset, int size)
korg1212         1264 sound/pci/korg1212/korg1212.c 	struct KorgAudioFrame * dst =  korg1212->playDataBufsPtr[0].bufferData + pos;
korg1212         1274 sound/pci/korg1212/korg1212.c 		if ( (void *) dst < (void *) korg1212->playDataBufsPtr ||
korg1212         1275 sound/pci/korg1212/korg1212.c 		     (void *) dst > (void *) korg1212->playDataBufsPtr[8].bufferData ) {
korg1212         1293 sound/pci/korg1212/korg1212.c         struct snd_korg1212 *korg1212 = snd_pcm_substream_chip(substream);
korg1212         1299 sound/pci/korg1212/korg1212.c 	size = korg1212->channels * 2;
korg1212         1300 sound/pci/korg1212/korg1212.c 	src = korg1212->recordDataBufsPtr[0].bufferData + pos;
korg1212         1308 sound/pci/korg1212/korg1212.c 		if ( (void *) src < (void *) korg1212->recordDataBufsPtr ||
korg1212         1309 sound/pci/korg1212/korg1212.c 		     (void *) src > (void *) korg1212->recordDataBufsPtr[8].bufferData ) {
korg1212         1330 sound/pci/korg1212/korg1212.c 	struct snd_korg1212 *korg1212 = snd_pcm_substream_chip(substream);
korg1212         1336 sound/pci/korg1212/korg1212.c 	size = korg1212->channels * 2;
korg1212         1337 sound/pci/korg1212/korg1212.c 	dst = korg1212->playDataBufsPtr[0].bufferData + pos;
korg1212         1347 sound/pci/korg1212/korg1212.c 		if ( (void *) dst < (void *) korg1212->playDataBufsPtr ||
korg1212         1348 sound/pci/korg1212/korg1212.c 		     (void *) dst > (void *) korg1212->playDataBufsPtr[8].bufferData ) {
korg1212         1366 sound/pci/korg1212/korg1212.c         struct snd_korg1212 *korg1212 = pcm->private_data;
korg1212         1369 sound/pci/korg1212/korg1212.c 			   stateName[korg1212->cardState]);
korg1212         1371 sound/pci/korg1212/korg1212.c         korg1212->pcm = NULL;
korg1212         1377 sound/pci/korg1212/korg1212.c         struct snd_korg1212 *korg1212 = snd_pcm_substream_chip(substream);
korg1212         1381 sound/pci/korg1212/korg1212.c 			   stateName[korg1212->cardState]);
korg1212         1383 sound/pci/korg1212/korg1212.c 	snd_korg1212_OpenCard(korg1212);
korg1212         1386 sound/pci/korg1212/korg1212.c 	snd_pcm_set_runtime_buffer(substream, &korg1212->dma_play);
korg1212         1388 sound/pci/korg1212/korg1212.c         spin_lock_irqsave(&korg1212->lock, flags);
korg1212         1390 sound/pci/korg1212/korg1212.c         korg1212->playback_substream = substream;
korg1212         1391 sound/pci/korg1212/korg1212.c 	korg1212->playback_pid = current->pid;
korg1212         1392 sound/pci/korg1212/korg1212.c         korg1212->periodsize = K1212_PERIODS;
korg1212         1393 sound/pci/korg1212/korg1212.c 	korg1212->channels = K1212_CHANNELS;
korg1212         1394 sound/pci/korg1212/korg1212.c 	korg1212->errorcnt = 0;
korg1212         1396 sound/pci/korg1212/korg1212.c         spin_unlock_irqrestore(&korg1212->lock, flags);
korg1212         1408 sound/pci/korg1212/korg1212.c         struct snd_korg1212 *korg1212 = snd_pcm_substream_chip(substream);
korg1212         1412 sound/pci/korg1212/korg1212.c 			   stateName[korg1212->cardState]);
korg1212         1414 sound/pci/korg1212/korg1212.c 	snd_korg1212_OpenCard(korg1212);
korg1212         1417 sound/pci/korg1212/korg1212.c 	snd_pcm_set_runtime_buffer(substream, &korg1212->dma_rec);
korg1212         1419 sound/pci/korg1212/korg1212.c         spin_lock_irqsave(&korg1212->lock, flags);
korg1212         1421 sound/pci/korg1212/korg1212.c         korg1212->capture_substream = substream;
korg1212         1422 sound/pci/korg1212/korg1212.c 	korg1212->capture_pid = current->pid;
korg1212         1423 sound/pci/korg1212/korg1212.c         korg1212->periodsize = K1212_PERIODS;
korg1212         1424 sound/pci/korg1212/korg1212.c 	korg1212->channels = K1212_CHANNELS;
korg1212         1426 sound/pci/korg1212/korg1212.c         spin_unlock_irqrestore(&korg1212->lock, flags);
korg1212         1436 sound/pci/korg1212/korg1212.c         struct snd_korg1212 *korg1212 = snd_pcm_substream_chip(substream);
korg1212         1439 sound/pci/korg1212/korg1212.c 			   stateName[korg1212->cardState]);
korg1212         1441 sound/pci/korg1212/korg1212.c 	snd_korg1212_silence(korg1212, 0, K1212_MAX_SAMPLES, 0, korg1212->channels * 2);
korg1212         1443 sound/pci/korg1212/korg1212.c         spin_lock_irqsave(&korg1212->lock, flags);
korg1212         1445 sound/pci/korg1212/korg1212.c 	korg1212->playback_pid = -1;
korg1212         1446 sound/pci/korg1212/korg1212.c         korg1212->playback_substream = NULL;
korg1212         1447 sound/pci/korg1212/korg1212.c         korg1212->periodsize = 0;
korg1212         1449 sound/pci/korg1212/korg1212.c         spin_unlock_irqrestore(&korg1212->lock, flags);
korg1212         1451 sound/pci/korg1212/korg1212.c 	snd_korg1212_CloseCard(korg1212);
korg1212         1458 sound/pci/korg1212/korg1212.c         struct snd_korg1212 *korg1212 = snd_pcm_substream_chip(substream);
korg1212         1461 sound/pci/korg1212/korg1212.c 			   stateName[korg1212->cardState]);
korg1212         1463 sound/pci/korg1212/korg1212.c         spin_lock_irqsave(&korg1212->lock, flags);
korg1212         1465 sound/pci/korg1212/korg1212.c 	korg1212->capture_pid = -1;
korg1212         1466 sound/pci/korg1212/korg1212.c         korg1212->capture_substream = NULL;
korg1212         1467 sound/pci/korg1212/korg1212.c         korg1212->periodsize = 0;
korg1212         1469 sound/pci/korg1212/korg1212.c         spin_unlock_irqrestore(&korg1212->lock, flags);
korg1212         1471 sound/pci/korg1212/korg1212.c 	snd_korg1212_CloseCard(korg1212);
korg1212         1496 sound/pci/korg1212/korg1212.c         struct snd_korg1212 *korg1212 = snd_pcm_substream_chip(substream);
korg1212         1502 sound/pci/korg1212/korg1212.c 			   stateName[korg1212->cardState]);
korg1212         1504 sound/pci/korg1212/korg1212.c         spin_lock_irqsave(&korg1212->lock, flags);
korg1212         1507 sound/pci/korg1212/korg1212.c 		this_pid = korg1212->playback_pid;
korg1212         1508 sound/pci/korg1212/korg1212.c 		other_pid = korg1212->capture_pid;
korg1212         1510 sound/pci/korg1212/korg1212.c 		this_pid = korg1212->capture_pid;
korg1212         1511 sound/pci/korg1212/korg1212.c 		other_pid = korg1212->playback_pid;
korg1212         1521 sound/pci/korg1212/korg1212.c 		if ((int)params_rate(params) != korg1212->clkRate) {
korg1212         1522 sound/pci/korg1212/korg1212.c 			spin_unlock_irqrestore(&korg1212->lock, flags);
korg1212         1527 sound/pci/korg1212/korg1212.c         	spin_unlock_irqrestore(&korg1212->lock, flags);
korg1212         1531 sound/pci/korg1212/korg1212.c         if ((err = snd_korg1212_SetRate(korg1212, params_rate(params))) < 0) {
korg1212         1532 sound/pci/korg1212/korg1212.c                 spin_unlock_irqrestore(&korg1212->lock, flags);
korg1212         1536 sound/pci/korg1212/korg1212.c 	korg1212->channels = params_channels(params);
korg1212         1537 sound/pci/korg1212/korg1212.c         korg1212->periodsize = K1212_PERIOD_BYTES;
korg1212         1539 sound/pci/korg1212/korg1212.c         spin_unlock_irqrestore(&korg1212->lock, flags);
korg1212         1546 sound/pci/korg1212/korg1212.c         struct snd_korg1212 *korg1212 = snd_pcm_substream_chip(substream);
korg1212         1550 sound/pci/korg1212/korg1212.c 			   stateName[korg1212->cardState]);
korg1212         1552 sound/pci/korg1212/korg1212.c 	spin_lock_irq(&korg1212->lock);
korg1212         1555 sound/pci/korg1212/korg1212.c 	if (korg1212->stop_pending_cnt > 0) {
korg1212         1557 sound/pci/korg1212/korg1212.c 				   stateName[korg1212->cardState]);
korg1212         1558 sound/pci/korg1212/korg1212.c         	spin_unlock_irq(&korg1212->lock);
korg1212         1567 sound/pci/korg1212/korg1212.c         rc = snd_korg1212_SetupForPlay(korg1212);
korg1212         1569 sound/pci/korg1212/korg1212.c         korg1212->currentBuffer = 0;
korg1212         1571 sound/pci/korg1212/korg1212.c         spin_unlock_irq(&korg1212->lock);
korg1212         1579 sound/pci/korg1212/korg1212.c         struct snd_korg1212 *korg1212 = snd_pcm_substream_chip(substream);
korg1212         1583 sound/pci/korg1212/korg1212.c 			   stateName[korg1212->cardState], cmd);
korg1212         1585 sound/pci/korg1212/korg1212.c 	spin_lock(&korg1212->lock);
korg1212         1594 sound/pci/korg1212/korg1212.c                         korg1212->running++;
korg1212         1595 sound/pci/korg1212/korg1212.c                         rc = snd_korg1212_TriggerPlay(korg1212);
korg1212         1605 sound/pci/korg1212/korg1212.c                         korg1212->running--;
korg1212         1606 sound/pci/korg1212/korg1212.c                         rc = snd_korg1212_StopPlay(korg1212);
korg1212         1613 sound/pci/korg1212/korg1212.c 	spin_unlock(&korg1212->lock);
korg1212         1619 sound/pci/korg1212/korg1212.c         struct snd_korg1212 *korg1212 = snd_pcm_substream_chip(substream);
korg1212         1622 sound/pci/korg1212/korg1212.c 	pos = korg1212->currentBuffer * kPlayBufferFrames;
korg1212         1625 sound/pci/korg1212/korg1212.c 				   stateName[korg1212->cardState], pos);
korg1212         1632 sound/pci/korg1212/korg1212.c         struct snd_korg1212 *korg1212 = snd_pcm_substream_chip(substream);
korg1212         1635 sound/pci/korg1212/korg1212.c 	pos = korg1212->currentBuffer * kPlayBufferFrames;
korg1212         1638 sound/pci/korg1212/korg1212.c 				   stateName[korg1212->cardState], pos);
korg1212         1664 sound/pci/korg1212/korg1212.c         struct snd_korg1212 *korg1212 = snd_pcm_substream_chip(substream);
korg1212         1666 sound/pci/korg1212/korg1212.c 	return snd_korg1212_silence(korg1212, bytes_to_frames(runtime, pos),
korg1212         1668 sound/pci/korg1212/korg1212.c 				    0, korg1212->channels * 2);
korg1212         1726 sound/pci/korg1212/korg1212.c 	struct snd_korg1212 *korg1212 = snd_kcontrol_chip(kcontrol);
korg1212         1729 sound/pci/korg1212/korg1212.c 	spin_lock_irq(&korg1212->lock);
korg1212         1731 sound/pci/korg1212/korg1212.c         u->value.integer.value[0] = korg1212->volumePhase[i];
korg1212         1734 sound/pci/korg1212/korg1212.c         	u->value.integer.value[1] = korg1212->volumePhase[i+1];
korg1212         1736 sound/pci/korg1212/korg1212.c 	spin_unlock_irq(&korg1212->lock);
korg1212         1744 sound/pci/korg1212/korg1212.c 	struct snd_korg1212 *korg1212 = snd_kcontrol_chip(kcontrol);
korg1212         1748 sound/pci/korg1212/korg1212.c 	spin_lock_irq(&korg1212->lock);
korg1212         1752 sound/pci/korg1212/korg1212.c 	korg1212->volumePhase[i] = !!u->value.integer.value[0];
korg1212         1754 sound/pci/korg1212/korg1212.c 	val = korg1212->sharedBufferPtr->volumeData[kcontrol->private_value];
korg1212         1757 sound/pci/korg1212/korg1212.c 		val = abs(val) * (korg1212->volumePhase[i] > 0 ? -1 : 1);
korg1212         1758 sound/pci/korg1212/korg1212.c 		korg1212->sharedBufferPtr->volumeData[i] = val;
korg1212         1763 sound/pci/korg1212/korg1212.c 		korg1212->volumePhase[i+1] = !!u->value.integer.value[1];
korg1212         1765 sound/pci/korg1212/korg1212.c 		val = korg1212->sharedBufferPtr->volumeData[kcontrol->private_value+1];
korg1212         1768 sound/pci/korg1212/korg1212.c 			val = abs(val) * (korg1212->volumePhase[i+1] > 0 ? -1 : 1);
korg1212         1769 sound/pci/korg1212/korg1212.c 			korg1212->sharedBufferPtr->volumeData[i+1] = val;
korg1212         1774 sound/pci/korg1212/korg1212.c 	spin_unlock_irq(&korg1212->lock);
korg1212         1792 sound/pci/korg1212/korg1212.c 	struct snd_korg1212 *korg1212 = snd_kcontrol_chip(kcontrol);
korg1212         1795 sound/pci/korg1212/korg1212.c 	spin_lock_irq(&korg1212->lock);
korg1212         1798 sound/pci/korg1212/korg1212.c         u->value.integer.value[0] = abs(korg1212->sharedBufferPtr->volumeData[i]);
korg1212         1801 sound/pci/korg1212/korg1212.c                 u->value.integer.value[1] = abs(korg1212->sharedBufferPtr->volumeData[i+1]);
korg1212         1803 sound/pci/korg1212/korg1212.c         spin_unlock_irq(&korg1212->lock);
korg1212         1811 sound/pci/korg1212/korg1212.c 	struct snd_korg1212 *korg1212 = snd_kcontrol_chip(kcontrol);
korg1212         1816 sound/pci/korg1212/korg1212.c 	spin_lock_irq(&korg1212->lock);
korg1212         1823 sound/pci/korg1212/korg1212.c 	    abs(korg1212->sharedBufferPtr->volumeData[i])) {
korg1212         1824 sound/pci/korg1212/korg1212.c 		val = korg1212->volumePhase[i] > 0 ? -1 : 1;
korg1212         1826 sound/pci/korg1212/korg1212.c 		korg1212->sharedBufferPtr->volumeData[i] = val;
korg1212         1834 sound/pci/korg1212/korg1212.c 		    abs(korg1212->sharedBufferPtr->volumeData[i+1])) {
korg1212         1835 sound/pci/korg1212/korg1212.c 			val = korg1212->volumePhase[i+1] > 0 ? -1 : 1;
korg1212         1837 sound/pci/korg1212/korg1212.c 			korg1212->sharedBufferPtr->volumeData[i+1] = val;
korg1212         1842 sound/pci/korg1212/korg1212.c 	spin_unlock_irq(&korg1212->lock);
korg1212         1858 sound/pci/korg1212/korg1212.c 	struct snd_korg1212 *korg1212 = snd_kcontrol_chip(kcontrol);
korg1212         1861 sound/pci/korg1212/korg1212.c 	spin_lock_irq(&korg1212->lock);
korg1212         1864 sound/pci/korg1212/korg1212.c 	u->value.enumerated.item[0] = korg1212->sharedBufferPtr->routeData[i];
korg1212         1867 sound/pci/korg1212/korg1212.c 		u->value.enumerated.item[1] = korg1212->sharedBufferPtr->routeData[i+1];
korg1212         1869 sound/pci/korg1212/korg1212.c         spin_unlock_irq(&korg1212->lock);
korg1212         1877 sound/pci/korg1212/korg1212.c 	struct snd_korg1212 *korg1212 = snd_kcontrol_chip(kcontrol);
korg1212         1880 sound/pci/korg1212/korg1212.c 	spin_lock_irq(&korg1212->lock);
korg1212         1886 sound/pci/korg1212/korg1212.c 	    (unsigned) korg1212->sharedBufferPtr->volumeData[i]) {
korg1212         1887 sound/pci/korg1212/korg1212.c 		korg1212->sharedBufferPtr->routeData[i] = u->value.enumerated.item[0];
korg1212         1894 sound/pci/korg1212/korg1212.c 		    (unsigned) korg1212->sharedBufferPtr->volumeData[i+1]) {
korg1212         1895 sound/pci/korg1212/korg1212.c 			korg1212->sharedBufferPtr->routeData[i+1] = u->value.enumerated.item[1];
korg1212         1900 sound/pci/korg1212/korg1212.c 	spin_unlock_irq(&korg1212->lock);
korg1212         1918 sound/pci/korg1212/korg1212.c 	struct snd_korg1212 *korg1212 = snd_kcontrol_chip(kcontrol);
korg1212         1920 sound/pci/korg1212/korg1212.c 	spin_lock_irq(&korg1212->lock);
korg1212         1922 sound/pci/korg1212/korg1212.c         u->value.integer.value[0] = korg1212->leftADCInSens;
korg1212         1923 sound/pci/korg1212/korg1212.c         u->value.integer.value[1] = korg1212->rightADCInSens;
korg1212         1925 sound/pci/korg1212/korg1212.c 	spin_unlock_irq(&korg1212->lock);
korg1212         1933 sound/pci/korg1212/korg1212.c 	struct snd_korg1212 *korg1212 = snd_kcontrol_chip(kcontrol);
korg1212         1936 sound/pci/korg1212/korg1212.c 	spin_lock_irq(&korg1212->lock);
korg1212         1940 sound/pci/korg1212/korg1212.c 	    u->value.integer.value[0] != korg1212->leftADCInSens) {
korg1212         1941 sound/pci/korg1212/korg1212.c                 korg1212->leftADCInSens = u->value.integer.value[0];
korg1212         1946 sound/pci/korg1212/korg1212.c 	    u->value.integer.value[1] != korg1212->rightADCInSens) {
korg1212         1947 sound/pci/korg1212/korg1212.c                 korg1212->rightADCInSens = u->value.integer.value[1];
korg1212         1951 sound/pci/korg1212/korg1212.c 	spin_unlock_irq(&korg1212->lock);
korg1212         1954 sound/pci/korg1212/korg1212.c                 snd_korg1212_WriteADCSensitivity(korg1212);
korg1212         1968 sound/pci/korg1212/korg1212.c 	struct snd_korg1212 *korg1212 = snd_kcontrol_chip(kcontrol);
korg1212         1970 sound/pci/korg1212/korg1212.c 	spin_lock_irq(&korg1212->lock);
korg1212         1972 sound/pci/korg1212/korg1212.c 	ucontrol->value.enumerated.item[0] = korg1212->clkSource;
korg1212         1974 sound/pci/korg1212/korg1212.c 	spin_unlock_irq(&korg1212->lock);
korg1212         1981 sound/pci/korg1212/korg1212.c 	struct snd_korg1212 *korg1212 = snd_kcontrol_chip(kcontrol);
korg1212         1986 sound/pci/korg1212/korg1212.c 	spin_lock_irq(&korg1212->lock);
korg1212         1987 sound/pci/korg1212/korg1212.c 	change = val != korg1212->clkSource;
korg1212         1988 sound/pci/korg1212/korg1212.c         snd_korg1212_SetClockSource(korg1212, val);
korg1212         1989 sound/pci/korg1212/korg1212.c 	spin_unlock_irq(&korg1212->lock);
korg1212         2053 sound/pci/korg1212/korg1212.c 	struct snd_korg1212 *korg1212 = entry->private_data;
korg1212         2055 sound/pci/korg1212/korg1212.c 	snd_iprintf(buffer, korg1212->card->longname);
korg1212         2056 sound/pci/korg1212/korg1212.c 	snd_iprintf(buffer, " (index #%d)\n", korg1212->card->number + 1);
korg1212         2059 sound/pci/korg1212/korg1212.c 	snd_iprintf(buffer, "     clock mode: %s\n", clockSourceName[korg1212->clkSrcRate] );
korg1212         2060 sound/pci/korg1212/korg1212.c 	snd_iprintf(buffer, "  left ADC Sens: %d\n", korg1212->leftADCInSens );
korg1212         2061 sound/pci/korg1212/korg1212.c 	snd_iprintf(buffer, " right ADC Sens: %d\n", korg1212->rightADCInSens );
korg1212         2066 sound/pci/korg1212/korg1212.c                                     channelName[korg1212->sharedBufferPtr->routeData[n]],
korg1212         2067 sound/pci/korg1212/korg1212.c                                     korg1212->sharedBufferPtr->volumeData[n]);
korg1212         2069 sound/pci/korg1212/korg1212.c         snd_iprintf(buffer, " ADAT Time Code: %d\n", korg1212->sharedBufferPtr->AdatTimeCode);
korg1212         2070 sound/pci/korg1212/korg1212.c         snd_iprintf(buffer, "     Card State: %s\n", stateName[korg1212->cardState]);
korg1212         2071 sound/pci/korg1212/korg1212.c         snd_iprintf(buffer, "Idle mon. State: %d\n", korg1212->idleMonitorOn);
korg1212         2072 sound/pci/korg1212/korg1212.c         snd_iprintf(buffer, "Cmd retry count: %d\n", korg1212->cmdRetryCount);
korg1212         2073 sound/pci/korg1212/korg1212.c         snd_iprintf(buffer, "      Irq count: %ld\n", korg1212->irqcount);
korg1212         2074 sound/pci/korg1212/korg1212.c         snd_iprintf(buffer, "    Error count: %ld\n", korg1212->totalerrorcnt);
korg1212         2077 sound/pci/korg1212/korg1212.c static void snd_korg1212_proc_init(struct snd_korg1212 *korg1212)
korg1212         2079 sound/pci/korg1212/korg1212.c 	snd_card_ro_proc_new(korg1212->card, "korg1212", korg1212,
korg1212         2084 sound/pci/korg1212/korg1212.c snd_korg1212_free(struct snd_korg1212 *korg1212)
korg1212         2086 sound/pci/korg1212/korg1212.c         snd_korg1212_TurnOffIdleMonitor(korg1212);
korg1212         2088 sound/pci/korg1212/korg1212.c         if (korg1212->irq >= 0) {
korg1212         2089 sound/pci/korg1212/korg1212.c                 snd_korg1212_DisableCardInterrupts(korg1212);
korg1212         2090 sound/pci/korg1212/korg1212.c                 free_irq(korg1212->irq, korg1212);
korg1212         2091 sound/pci/korg1212/korg1212.c                 korg1212->irq = -1;
korg1212         2094 sound/pci/korg1212/korg1212.c         if (korg1212->iobase != NULL) {
korg1212         2095 sound/pci/korg1212/korg1212.c                 iounmap(korg1212->iobase);
korg1212         2096 sound/pci/korg1212/korg1212.c                 korg1212->iobase = NULL;
korg1212         2099 sound/pci/korg1212/korg1212.c 	pci_release_regions(korg1212->pci);
korg1212         2104 sound/pci/korg1212/korg1212.c         if (korg1212->dma_dsp.area) {
korg1212         2105 sound/pci/korg1212/korg1212.c         	snd_dma_free_pages(&korg1212->dma_dsp);
korg1212         2106 sound/pci/korg1212/korg1212.c         	korg1212->dma_dsp.area = NULL;
korg1212         2114 sound/pci/korg1212/korg1212.c 	if (korg1212->dma_play.area) {
korg1212         2115 sound/pci/korg1212/korg1212.c 		snd_dma_free_pages(&korg1212->dma_play);
korg1212         2116 sound/pci/korg1212/korg1212.c 		korg1212->dma_play.area = NULL;
korg1212         2119 sound/pci/korg1212/korg1212.c 	if (korg1212->dma_rec.area) {
korg1212         2120 sound/pci/korg1212/korg1212.c 		snd_dma_free_pages(&korg1212->dma_rec);
korg1212         2121 sound/pci/korg1212/korg1212.c 		korg1212->dma_rec.area = NULL;
korg1212         2129 sound/pci/korg1212/korg1212.c 	if (korg1212->dma_shared.area) {
korg1212         2130 sound/pci/korg1212/korg1212.c 		snd_dma_free_pages(&korg1212->dma_shared);
korg1212         2131 sound/pci/korg1212/korg1212.c 		korg1212->dma_shared.area = NULL;
korg1212         2134 sound/pci/korg1212/korg1212.c 	pci_disable_device(korg1212->pci);
korg1212         2135 sound/pci/korg1212/korg1212.c         kfree(korg1212);
korg1212         2141 sound/pci/korg1212/korg1212.c         struct snd_korg1212 *korg1212 = device->device_data;
korg1212         2143 sound/pci/korg1212/korg1212.c 	return snd_korg1212_free(korg1212);
korg1212         2153 sound/pci/korg1212/korg1212.c         struct snd_korg1212 * korg1212;
korg1212         2164 sound/pci/korg1212/korg1212.c         korg1212 = kzalloc(sizeof(*korg1212), GFP_KERNEL);
korg1212         2165 sound/pci/korg1212/korg1212.c         if (korg1212 == NULL) {
korg1212         2170 sound/pci/korg1212/korg1212.c 	korg1212->card = card;
korg1212         2171 sound/pci/korg1212/korg1212.c 	korg1212->pci = pci;
korg1212         2173 sound/pci/korg1212/korg1212.c         init_waitqueue_head(&korg1212->wait);
korg1212         2174 sound/pci/korg1212/korg1212.c         spin_lock_init(&korg1212->lock);
korg1212         2175 sound/pci/korg1212/korg1212.c 	mutex_init(&korg1212->open_mutex);
korg1212         2176 sound/pci/korg1212/korg1212.c 	timer_setup(&korg1212->timer, snd_korg1212_timer_func, 0);
korg1212         2178 sound/pci/korg1212/korg1212.c         korg1212->irq = -1;
korg1212         2179 sound/pci/korg1212/korg1212.c         korg1212->clkSource = K1212_CLKIDX_Local;
korg1212         2180 sound/pci/korg1212/korg1212.c         korg1212->clkRate = 44100;
korg1212         2181 sound/pci/korg1212/korg1212.c         korg1212->inIRQ = 0;
korg1212         2182 sound/pci/korg1212/korg1212.c         korg1212->running = 0;
korg1212         2183 sound/pci/korg1212/korg1212.c 	korg1212->opencnt = 0;
korg1212         2184 sound/pci/korg1212/korg1212.c 	korg1212->playcnt = 0;
korg1212         2185 sound/pci/korg1212/korg1212.c 	korg1212->setcnt = 0;
korg1212         2186 sound/pci/korg1212/korg1212.c 	korg1212->totalerrorcnt = 0;
korg1212         2187 sound/pci/korg1212/korg1212.c 	korg1212->playback_pid = -1;
korg1212         2188 sound/pci/korg1212/korg1212.c 	korg1212->capture_pid = -1;
korg1212         2189 sound/pci/korg1212/korg1212.c         snd_korg1212_setCardState(korg1212, K1212_STATE_UNINITIALIZED);
korg1212         2190 sound/pci/korg1212/korg1212.c         korg1212->idleMonitorOn = 0;
korg1212         2191 sound/pci/korg1212/korg1212.c         korg1212->clkSrcRate = K1212_CLKIDX_LocalAt44_1K;
korg1212         2192 sound/pci/korg1212/korg1212.c         korg1212->leftADCInSens = k1212MaxADCSens;
korg1212         2193 sound/pci/korg1212/korg1212.c         korg1212->rightADCInSens = k1212MaxADCSens;
korg1212         2196 sound/pci/korg1212/korg1212.c                 korg1212->volumePhase[i] = 0;
korg1212         2199 sound/pci/korg1212/korg1212.c 		kfree(korg1212);
korg1212         2204 sound/pci/korg1212/korg1212.c         korg1212->iomem = pci_resource_start(korg1212->pci, 0);
korg1212         2205 sound/pci/korg1212/korg1212.c         korg1212->ioport = pci_resource_start(korg1212->pci, 1);
korg1212         2206 sound/pci/korg1212/korg1212.c         korg1212->iomem2 = pci_resource_start(korg1212->pci, 2);
korg1212         2208 sound/pci/korg1212/korg1212.c 	iomem_size = pci_resource_len(korg1212->pci, 0);
korg1212         2209 sound/pci/korg1212/korg1212.c 	ioport_size = pci_resource_len(korg1212->pci, 1);
korg1212         2210 sound/pci/korg1212/korg1212.c 	iomem2_size = pci_resource_len(korg1212->pci, 2);
korg1212         2217 sound/pci/korg1212/korg1212.c 		   korg1212->iomem, iomem_size,
korg1212         2218 sound/pci/korg1212/korg1212.c 		   korg1212->ioport, ioport_size,
korg1212         2219 sound/pci/korg1212/korg1212.c 		   korg1212->iomem2, iomem2_size,
korg1212         2220 sound/pci/korg1212/korg1212.c 		   stateName[korg1212->cardState]);
korg1212         2222 sound/pci/korg1212/korg1212.c         if ((korg1212->iobase = ioremap(korg1212->iomem, iomem_size)) == NULL) {
korg1212         2223 sound/pci/korg1212/korg1212.c 		snd_printk(KERN_ERR "korg1212: unable to remap memory region 0x%lx-0x%lx\n", korg1212->iomem,
korg1212         2224 sound/pci/korg1212/korg1212.c                            korg1212->iomem + iomem_size - 1);
korg1212         2225 sound/pci/korg1212/korg1212.c                 snd_korg1212_free(korg1212);
korg1212         2231 sound/pci/korg1212/korg1212.c                           KBUILD_MODNAME, korg1212);
korg1212         2235 sound/pci/korg1212/korg1212.c                 snd_korg1212_free(korg1212);
korg1212         2239 sound/pci/korg1212/korg1212.c         korg1212->irq = pci->irq;
korg1212         2241 sound/pci/korg1212/korg1212.c 	pci_set_master(korg1212->pci);
korg1212         2243 sound/pci/korg1212/korg1212.c         korg1212->statusRegPtr = (u32 __iomem *) (korg1212->iobase + STATUS_REG_OFFSET);
korg1212         2244 sound/pci/korg1212/korg1212.c         korg1212->outDoorbellPtr = (u32 __iomem *) (korg1212->iobase + OUT_DOORBELL_OFFSET);
korg1212         2245 sound/pci/korg1212/korg1212.c         korg1212->inDoorbellPtr = (u32 __iomem *) (korg1212->iobase + IN_DOORBELL_OFFSET);
korg1212         2246 sound/pci/korg1212/korg1212.c         korg1212->mailbox0Ptr = (u32 __iomem *) (korg1212->iobase + MAILBOX0_OFFSET);
korg1212         2247 sound/pci/korg1212/korg1212.c         korg1212->mailbox1Ptr = (u32 __iomem *) (korg1212->iobase + MAILBOX1_OFFSET);
korg1212         2248 sound/pci/korg1212/korg1212.c         korg1212->mailbox2Ptr = (u32 __iomem *) (korg1212->iobase + MAILBOX2_OFFSET);
korg1212         2249 sound/pci/korg1212/korg1212.c         korg1212->mailbox3Ptr = (u32 __iomem *) (korg1212->iobase + MAILBOX3_OFFSET);
korg1212         2250 sound/pci/korg1212/korg1212.c         korg1212->controlRegPtr = (u32 __iomem *) (korg1212->iobase + PCI_CONTROL_OFFSET);
korg1212         2251 sound/pci/korg1212/korg1212.c         korg1212->sensRegPtr = (u16 __iomem *) (korg1212->iobase + SENS_CONTROL_OFFSET);
korg1212         2252 sound/pci/korg1212/korg1212.c         korg1212->idRegPtr = (u32 __iomem *) (korg1212->iobase + DEV_VEND_ID_OFFSET);
korg1212         2266 sound/pci/korg1212/korg1212.c                    korg1212->statusRegPtr,
korg1212         2267 sound/pci/korg1212/korg1212.c 		   korg1212->outDoorbellPtr,
korg1212         2268 sound/pci/korg1212/korg1212.c 		   korg1212->inDoorbellPtr,
korg1212         2269 sound/pci/korg1212/korg1212.c                    korg1212->mailbox0Ptr,
korg1212         2270 sound/pci/korg1212/korg1212.c                    korg1212->mailbox1Ptr,
korg1212         2271 sound/pci/korg1212/korg1212.c                    korg1212->mailbox2Ptr,
korg1212         2272 sound/pci/korg1212/korg1212.c                    korg1212->mailbox3Ptr,
korg1212         2273 sound/pci/korg1212/korg1212.c                    korg1212->controlRegPtr,
korg1212         2274 sound/pci/korg1212/korg1212.c                    korg1212->sensRegPtr,
korg1212         2275 sound/pci/korg1212/korg1212.c                    korg1212->idRegPtr,
korg1212         2276 sound/pci/korg1212/korg1212.c 		   stateName[korg1212->cardState]);
korg1212         2279 sound/pci/korg1212/korg1212.c 				sizeof(struct KorgSharedBuffer), &korg1212->dma_shared) < 0) {
korg1212         2281 sound/pci/korg1212/korg1212.c                 snd_korg1212_free(korg1212);
korg1212         2284 sound/pci/korg1212/korg1212.c         korg1212->sharedBufferPtr = (struct KorgSharedBuffer *)korg1212->dma_shared.area;
korg1212         2285 sound/pci/korg1212/korg1212.c         korg1212->sharedBufferPhy = korg1212->dma_shared.addr;
korg1212         2287 sound/pci/korg1212/korg1212.c         K1212_DEBUG_PRINTK("K1212_DEBUG: Shared Buffer Area = 0x%p (0x%08lx), %d bytes\n", korg1212->sharedBufferPtr, korg1212->sharedBufferPhy, sizeof(struct KorgSharedBuffer));
korg1212         2291 sound/pci/korg1212/korg1212.c         korg1212->DataBufsSize = sizeof(struct KorgAudioBuffer) * kNumBuffers;
korg1212         2294 sound/pci/korg1212/korg1212.c 				korg1212->DataBufsSize, &korg1212->dma_play) < 0) {
korg1212         2295 sound/pci/korg1212/korg1212.c 		snd_printk(KERN_ERR "korg1212: can not allocate play data buffer memory (%d bytes)\n", korg1212->DataBufsSize);
korg1212         2296 sound/pci/korg1212/korg1212.c                 snd_korg1212_free(korg1212);
korg1212         2299 sound/pci/korg1212/korg1212.c 	korg1212->playDataBufsPtr = (struct KorgAudioBuffer *)korg1212->dma_play.area;
korg1212         2300 sound/pci/korg1212/korg1212.c 	korg1212->PlayDataPhy = korg1212->dma_play.addr;
korg1212         2303 sound/pci/korg1212/korg1212.c 		korg1212->playDataBufsPtr, korg1212->PlayDataPhy, korg1212->DataBufsSize);
korg1212         2306 sound/pci/korg1212/korg1212.c 				korg1212->DataBufsSize, &korg1212->dma_rec) < 0) {
korg1212         2307 sound/pci/korg1212/korg1212.c 		snd_printk(KERN_ERR "korg1212: can not allocate record data buffer memory (%d bytes)\n", korg1212->DataBufsSize);
korg1212         2308 sound/pci/korg1212/korg1212.c                 snd_korg1212_free(korg1212);
korg1212         2311 sound/pci/korg1212/korg1212.c         korg1212->recordDataBufsPtr = (struct KorgAudioBuffer *)korg1212->dma_rec.area;
korg1212         2312 sound/pci/korg1212/korg1212.c         korg1212->RecDataPhy = korg1212->dma_rec.addr;
korg1212         2315 sound/pci/korg1212/korg1212.c 		korg1212->recordDataBufsPtr, korg1212->RecDataPhy, korg1212->DataBufsSize);
korg1212         2319 sound/pci/korg1212/korg1212.c         korg1212->recordDataBufsPtr = korg1212->sharedBufferPtr->recordDataBufs;
korg1212         2320 sound/pci/korg1212/korg1212.c         korg1212->playDataBufsPtr = korg1212->sharedBufferPtr->playDataBufs;
korg1212         2321 sound/pci/korg1212/korg1212.c         korg1212->PlayDataPhy = (u32) &((struct KorgSharedBuffer *) korg1212->sharedBufferPhy)->playDataBufs;
korg1212         2322 sound/pci/korg1212/korg1212.c         korg1212->RecDataPhy  = (u32) &((struct KorgSharedBuffer *) korg1212->sharedBufferPhy)->recordDataBufs;
korg1212         2326 sound/pci/korg1212/korg1212.c         korg1212->VolumeTablePhy = korg1212->sharedBufferPhy +
korg1212         2328 sound/pci/korg1212/korg1212.c         korg1212->RoutingTablePhy = korg1212->sharedBufferPhy +
korg1212         2330 sound/pci/korg1212/korg1212.c         korg1212->AdatTimeCodePhy = korg1212->sharedBufferPhy +
korg1212         2336 sound/pci/korg1212/korg1212.c 		snd_korg1212_free(korg1212);
korg1212         2341 sound/pci/korg1212/korg1212.c 				dsp_code->size, &korg1212->dma_dsp) < 0) {
korg1212         2343 sound/pci/korg1212/korg1212.c                 snd_korg1212_free(korg1212);
korg1212         2349 sound/pci/korg1212/korg1212.c 		   korg1212->dma_dsp.area, korg1212->dma_dsp.addr, dsp_code->size,
korg1212         2350 sound/pci/korg1212/korg1212.c 		   stateName[korg1212->cardState]);
korg1212         2352 sound/pci/korg1212/korg1212.c 	memcpy(korg1212->dma_dsp.area, dsp_code->data, dsp_code->size);
korg1212         2356 sound/pci/korg1212/korg1212.c 	rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_RebootCard, 0, 0, 0, 0);
korg1212         2359 sound/pci/korg1212/korg1212.c 		K1212_DEBUG_PRINTK("K1212_DEBUG: Reboot Card - RC = %d [%s]\n", rc, stateName[korg1212->cardState]);
korg1212         2361 sound/pci/korg1212/korg1212.c         if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, korg1212, &ops)) < 0) {
korg1212         2362 sound/pci/korg1212/korg1212.c                 snd_korg1212_free(korg1212);
korg1212         2366 sound/pci/korg1212/korg1212.c 	snd_korg1212_EnableCardInterrupts(korg1212);
korg1212         2370 sound/pci/korg1212/korg1212.c         if (snd_korg1212_downloadDSPCode(korg1212))
korg1212         2379 sound/pci/korg1212/korg1212.c 	       (int)korg1212->dma_dsp.addr,    UpperWordSwap(korg1212->dma_dsp.addr),
korg1212         2380 sound/pci/korg1212/korg1212.c                korg1212->PlayDataPhy,     LowerWordSwap(korg1212->PlayDataPhy),
korg1212         2381 sound/pci/korg1212/korg1212.c                korg1212->RecDataPhy,      LowerWordSwap(korg1212->RecDataPhy),
korg1212         2382 sound/pci/korg1212/korg1212.c                korg1212->VolumeTablePhy,  LowerWordSwap(korg1212->VolumeTablePhy),
korg1212         2383 sound/pci/korg1212/korg1212.c                korg1212->RoutingTablePhy, LowerWordSwap(korg1212->RoutingTablePhy),
korg1212         2384 sound/pci/korg1212/korg1212.c                korg1212->AdatTimeCodePhy, LowerWordSwap(korg1212->AdatTimeCodePhy));
korg1212         2386 sound/pci/korg1212/korg1212.c         if ((err = snd_pcm_new(korg1212->card, "korg1212", 0, 1, 1, &korg1212->pcm)) < 0)
korg1212         2389 sound/pci/korg1212/korg1212.c 	korg1212->pcm->private_data = korg1212;
korg1212         2390 sound/pci/korg1212/korg1212.c         korg1212->pcm->private_free = snd_korg1212_free_pcm;
korg1212         2391 sound/pci/korg1212/korg1212.c         strcpy(korg1212->pcm->name, "korg1212");
korg1212         2393 sound/pci/korg1212/korg1212.c         snd_pcm_set_ops(korg1212->pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_korg1212_playback_ops);
korg1212         2395 sound/pci/korg1212/korg1212.c 	snd_pcm_set_ops(korg1212->pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_korg1212_capture_ops);
korg1212         2397 sound/pci/korg1212/korg1212.c 	korg1212->pcm->info_flags = SNDRV_PCM_INFO_JOINT_DUPLEX;
korg1212         2400 sound/pci/korg1212/korg1212.c                 err = snd_ctl_add(korg1212->card, snd_ctl_new1(&snd_korg1212_controls[i], korg1212));
korg1212         2405 sound/pci/korg1212/korg1212.c         snd_korg1212_proc_init(korg1212);
korg1212         2407 sound/pci/korg1212/korg1212.c         * rchip = korg1212;
korg1212         2421 sound/pci/korg1212/korg1212.c 	struct snd_korg1212 *korg1212;
korg1212         2437 sound/pci/korg1212/korg1212.c         if ((err = snd_korg1212_create(card, pci, &korg1212)) < 0) {
korg1212         2445 sound/pci/korg1212/korg1212.c 		korg1212->iomem, korg1212->irq);