• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-R7000-V1.0.7.12_1.2.5/components/opensource/linux/linux-2.6.36/sound/pci/korg1212/

Lines Matching defs:korg1212

404 MODULE_DESCRIPTION("korg1212");
406 MODULE_SUPPORTED_DEVICE("{{KORG,korg1212}}");
523 static int snd_korg1212_Send1212Command(struct snd_korg1212 *korg1212,
532 if (!korg1212->outDoorbellPtr) {
538 doorbellVal, mailBox0Val, stateName[korg1212->cardState]);
540 writel(mailBox3Val, korg1212->mailbox3Ptr);
541 writel(mailBox2Val, korg1212->mailbox2Ptr);
542 writel(mailBox1Val, korg1212->mailbox1Ptr);
543 writel(mailBox0Val, korg1212->mailbox0Ptr);
544 writel(doorbellVal, korg1212->outDoorbellPtr); // interrupt the card
562 mailBox3Lo = readl(korg1212->mailbox3Ptr);
571 korg1212->cmdRetryCount += retryCount;
582 static void snd_korg1212_SendStop(struct snd_korg1212 *korg1212)
584 if (! korg1212->stop_pending_cnt) {
585 korg1212->sharedBufferPtr->cardCommand = 0xffffffff;
587 korg1212->stop_pending_cnt = HZ;
588 korg1212->timer.expires = jiffies + 1;
589 add_timer(&korg1212->timer);
593 static void snd_korg1212_SendStopAndWait(struct snd_korg1212 *korg1212)
596 spin_lock_irqsave(&korg1212->lock, flags);
597 korg1212->dsp_stop_is_processed = 0;
598 snd_korg1212_SendStop(korg1212);
599 spin_unlock_irqrestore(&korg1212->lock, flags);
600 wait_event_timeout(korg1212->wait, korg1212->dsp_stop_is_processed, (HZ * 3) / 2);
606 struct snd_korg1212 *korg1212 = (struct snd_korg1212 *) data;
609 spin_lock_irqsave(&korg1212->lock, flags);
610 if (korg1212->sharedBufferPtr->cardCommand == 0) {
612 korg1212->stop_pending_cnt = 0;
613 korg1212->dsp_stop_is_processed = 1;
614 wake_up(&korg1212->wait);
616 stateName[korg1212->cardState]);
618 if (--korg1212->stop_pending_cnt > 0) {
620 korg1212->timer.expires = jiffies + 1;
621 add_timer(&korg1212->timer);
624 korg1212->sharedBufferPtr->cardCommand = 0;
625 korg1212->dsp_stop_is_processed = 1;
626 wake_up(&korg1212->wait);
628 stateName[korg1212->cardState]);
631 spin_unlock_irqrestore(&korg1212->lock, flags);
634 static int snd_korg1212_TurnOnIdleMonitor(struct snd_korg1212 *korg1212)
640 spin_lock_irqsave(&korg1212->lock, flags);
641 korg1212->idleMonitorOn = 1;
642 rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_SelectPlayMode,
644 spin_unlock_irqrestore(&korg1212->lock, flags);
648 static void snd_korg1212_TurnOffIdleMonitor(struct snd_korg1212 *korg1212)
650 if (korg1212->idleMonitorOn) {
651 snd_korg1212_SendStopAndWait(korg1212);
652 korg1212->idleMonitorOn = 0;
656 static inline void snd_korg1212_setCardState(struct snd_korg1212 * korg1212, enum CardState csState)
658 korg1212->cardState = csState;
661 static int snd_korg1212_OpenCard(struct snd_korg1212 * korg1212)
664 stateName[korg1212->cardState], korg1212->opencnt);
665 mutex_lock(&korg1212->open_mutex);
666 if (korg1212->opencnt++ == 0) {
667 snd_korg1212_TurnOffIdleMonitor(korg1212);
668 snd_korg1212_setCardState(korg1212, K1212_STATE_OPEN);
671 mutex_unlock(&korg1212->open_mutex);
675 static int snd_korg1212_CloseCard(struct snd_korg1212 * korg1212)
678 stateName[korg1212->cardState], korg1212->opencnt);
680 mutex_lock(&korg1212->open_mutex);
681 if (--(korg1212->opencnt)) {
682 mutex_unlock(&korg1212->open_mutex);
686 if (korg1212->cardState == K1212_STATE_SETUP) {
687 int rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_SelectPlayMode,
691 rc, stateName[korg1212->cardState]);
693 mutex_unlock(&korg1212->open_mutex);
696 } else if (korg1212->cardState > K1212_STATE_SETUP) {
697 snd_korg1212_SendStopAndWait(korg1212);
700 if (korg1212->cardState > K1212_STATE_READY) {
701 snd_korg1212_TurnOnIdleMonitor(korg1212);
702 snd_korg1212_setCardState(korg1212, K1212_STATE_READY);
705 mutex_unlock(&korg1212->open_mutex);
710 static int snd_korg1212_SetupForPlay(struct snd_korg1212 * korg1212)
715 stateName[korg1212->cardState], korg1212->setcnt);
717 if (korg1212->setcnt++)
720 snd_korg1212_setCardState(korg1212, K1212_STATE_SETUP);
721 rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_SelectPlayMode,
725 rc, stateName[korg1212->cardState]);
733 static int snd_korg1212_TriggerPlay(struct snd_korg1212 * korg1212)
738 stateName[korg1212->cardState], korg1212->playcnt);
740 if (korg1212->playcnt++)
743 snd_korg1212_setCardState(korg1212, K1212_STATE_PLAYING);
744 rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_TriggerPlay, 0, 0, 0, 0);
747 rc, stateName[korg1212->cardState]);
755 static int snd_korg1212_StopPlay(struct snd_korg1212 * korg1212)
758 stateName[korg1212->cardState], korg1212->playcnt);
760 if (--(korg1212->playcnt))
763 korg1212->setcnt = 0;
765 if (korg1212->cardState != K1212_STATE_ERRORSTOP)
766 snd_korg1212_SendStop(korg1212);
768 snd_korg1212_setCardState(korg1212, K1212_STATE_OPEN);
772 static void snd_korg1212_EnableCardInterrupts(struct snd_korg1212 * korg1212)
779 korg1212->statusRegPtr);
783 static inline int snd_korg1212_use_is_exclusive(struct snd_korg1212 *korg1212)
785 if (korg1212->playback_pid != korg1212->capture_pid &&
786 korg1212->playback_pid >= 0 && korg1212->capture_pid >= 0)
792 static int snd_korg1212_SetRate(struct snd_korg1212 *korg1212, int rate)
806 if (!snd_korg1212_use_is_exclusive (korg1212))
811 parm = s44[korg1212->clkSource];
815 parm = s48[korg1212->clkSource];
822 korg1212->clkSrcRate = parm;
823 korg1212->clkRate = rate;
826 rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_SetClockSourceRate,
827 ClockSourceSelector[korg1212->clkSrcRate],
831 rc, stateName[korg1212->cardState]);
836 static int snd_korg1212_SetClockSource(struct snd_korg1212 *korg1212, int source)
842 korg1212->clkSource = source;
844 snd_korg1212_SetRate(korg1212, korg1212->clkRate);
849 static void snd_korg1212_DisableCardInterrupts(struct snd_korg1212 *korg1212)
851 writel(0, korg1212->statusRegPtr);
854 static int snd_korg1212_WriteADCSensitivity(struct snd_korg1212 *korg1212)
867 stateName[korg1212->cardState]);
879 if (korg1212->cardState == K1212_STATE_MONITOR || korg1212->idleMonitorOn) {
881 snd_korg1212_SendStopAndWait(korg1212);
885 spin_lock_irqsave(&korg1212->lock, flags);
891 writel(0, korg1212->mailbox3Ptr);
898 switch (korg1212->clkSrcRate) {
918 sensVals.l.v.leftChanVal = korg1212->leftADCInSens;
919 sensVals.r.v.rightChanVal = korg1212->rightADCInSens;
932 writew(controlValue, korg1212->sensRegPtr); // load/shift goes low
949 writew(controlValue, korg1212->sensRegPtr); // clock goes low
952 writew(controlValue, korg1212->sensRegPtr); // clock goes high
963 writew(controlValue, korg1212->sensRegPtr); // load shift goes high - clk low
969 writew(controlValue, korg1212->sensRegPtr); // set/clear data bit
972 writew(controlValue, korg1212->sensRegPtr); // clock goes high
975 writew(controlValue, korg1212->sensRegPtr); // clock goes low
987 int rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_SelectPlayMode,
991 rc, stateName[korg1212->cardState]);
994 spin_unlock_irqrestore(&korg1212->lock, flags);
999 static void snd_korg1212_OnDSPDownloadComplete(struct snd_korg1212 *korg1212)
1004 stateName[korg1212->cardState]);
1009 rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_BootFromDSPPage4, 0, 0, 0, 0);
1013 rc, stateName[korg1212->cardState]);
1019 rc = snd_korg1212_Send1212Command(korg1212,
1021 LowerWordSwap(korg1212->PlayDataPhy),
1022 LowerWordSwap(korg1212->RecDataPhy),
1030 rc, stateName[korg1212->cardState]);
1034 rc = snd_korg1212_Send1212Command(korg1212,
1036 LowerWordSwap(korg1212->VolumeTablePhy),
1037 LowerWordSwap(korg1212->RoutingTablePhy),
1038 LowerWordSwap(korg1212->AdatTimeCodePhy),
1044 rc, stateName[korg1212->cardState]);
1052 korg1212->sharedBufferPtr->volumeData[channel] = k1212MaxVolume;
1053 //korg1212->sharedBufferPtr->routeData[channel] = channel;
1054 korg1212->sharedBufferPtr->routeData[channel] = 8 + (channel & 1);
1057 snd_korg1212_WriteADCSensitivity(korg1212);
1060 rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_SetClockSourceRate,
1061 ClockSourceSelector[korg1212->clkSrcRate],
1065 rc, stateName[korg1212->cardState]);
1067 rc = snd_korg1212_TurnOnIdleMonitor(korg1212);
1068 snd_korg1212_setCardState(korg1212, K1212_STATE_READY);
1072 rc, stateName[korg1212->cardState]);
1074 snd_korg1212_setCardState(korg1212, K1212_STATE_DSP_COMPLETE);
1080 struct snd_korg1212 *korg1212 = dev_id;
1082 doorbellValue = readl(korg1212->inDoorbellPtr);
1087 spin_lock(&korg1212->lock);
1089 writel(doorbellValue, korg1212->inDoorbellPtr);
1091 korg1212->irqcount++;
1093 korg1212->inIRQ++;
1098 korg1212->irqcount, doorbellValue,
1099 stateName[korg1212->cardState]);
1100 if (korg1212->cardState == K1212_STATE_DSP_IN_PROCESS) {
1101 korg1212->dsp_is_loaded = 1;
1102 wake_up(&korg1212->wait);
1111 korg1212->irqcount, doorbellValue,
1112 stateName[korg1212->cardState]);
1113 snd_printk(KERN_ERR "korg1212: DMA Error\n");
1114 korg1212->errorcnt++;
1115 korg1212->totalerrorcnt++;
1116 korg1212->sharedBufferPtr->cardCommand = 0;
1117 snd_korg1212_setCardState(korg1212, K1212_STATE_ERRORSTOP);
1126 korg1212->irqcount, doorbellValue,
1127 stateName[korg1212->cardState]);
1128 korg1212->sharedBufferPtr->cardCommand = 0;
1133 korg1212->irqcount, doorbellValue,
1134 korg1212->currentBuffer, stateName[korg1212->cardState]);
1135 if ((korg1212->cardState > K1212_STATE_SETUP) || korg1212->idleMonitorOn) {
1136 korg1212->currentBuffer++;
1138 if (korg1212->currentBuffer >= kNumBuffers)
1139 korg1212->currentBuffer = 0;
1141 if (!korg1212->running)
1144 if (korg1212->capture_substream) {
1145 spin_unlock(&korg1212->lock);
1146 snd_pcm_period_elapsed(korg1212->capture_substream);
1147 spin_lock(&korg1212->lock);
1150 if (korg1212->playback_substream) {
1151 spin_unlock(&korg1212->lock);
1152 snd_pcm_period_elapsed(korg1212->playback_substream);
1153 spin_lock(&korg1212->lock);
1159 korg1212->inIRQ--;
1161 spin_unlock(&korg1212->lock);
1166 static int snd_korg1212_downloadDSPCode(struct snd_korg1212 *korg1212)
1171 stateName[korg1212->cardState]);
1176 if (korg1212->cardState >= K1212_STATE_DSP_IN_PROCESS)
1179 snd_korg1212_setCardState(korg1212, K1212_STATE_DSP_IN_PROCESS);
1181 rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_StartDSPDownload,
1182 UpperWordSwap(korg1212->dma_dsp.addr),
1186 rc, stateName[korg1212->cardState]);
1188 korg1212->dsp_is_loaded = 0;
1189 wait_event_timeout(korg1212->wait, korg1212->dsp_is_loaded, HZ * CARD_BOOT_TIMEOUT);
1190 if (! korg1212->dsp_is_loaded )
1193 snd_korg1212_OnDSPDownloadComplete(korg1212);
1240 static int snd_korg1212_silence(struct snd_korg1212 *korg1212, int pos, int count, int offset, int size)
1242 struct KorgAudioFrame * dst = korg1212->playDataBufsPtr[0].bufferData + pos;
1252 if ( (void *) dst < (void *) korg1212->playDataBufsPtr ||
1253 (void *) dst > (void *) korg1212->playDataBufsPtr[8].bufferData ) {
1266 static int snd_korg1212_copy_to(struct snd_korg1212 *korg1212, void __user *dst, int pos, int count, int offset, int size)
1268 struct KorgAudioFrame * src = korg1212->recordDataBufsPtr[0].bufferData + pos;
1278 if ( (void *) src < (void *) korg1212->recordDataBufsPtr ||
1279 (void *) src > (void *) korg1212->recordDataBufsPtr[8].bufferData ) {
1296 static int snd_korg1212_copy_from(struct snd_korg1212 *korg1212, void __user *src, int pos, int count, int offset, int size)
1298 struct KorgAudioFrame * dst = korg1212->playDataBufsPtr[0].bufferData + pos;
1309 if ( (void *) dst < (void *) korg1212->playDataBufsPtr ||
1310 (void *) dst > (void *) korg1212->playDataBufsPtr[8].bufferData ) {
1329 struct snd_korg1212 *korg1212 = pcm->private_data;
1332 stateName[korg1212->cardState]);
1334 korg1212->pcm = NULL;
1340 struct snd_korg1212 *korg1212 = snd_pcm_substream_chip(substream);
1344 stateName[korg1212->cardState]);
1346 snd_korg1212_OpenCard(korg1212);
1349 snd_pcm_set_runtime_buffer(substream, &korg1212->dma_play);
1351 spin_lock_irqsave(&korg1212->lock, flags);
1353 korg1212->playback_substream = substream;
1354 korg1212->playback_pid = current->pid;
1355 korg1212->periodsize = K1212_PERIODS;
1356 korg1212->channels = K1212_CHANNELS;
1357 korg1212->errorcnt = 0;
1359 spin_unlock_irqrestore(&korg1212->lock, flags);
1369 struct snd_korg1212 *korg1212 = snd_pcm_substream_chip(substream);
1373 stateName[korg1212->cardState]);
1375 snd_korg1212_OpenCard(korg1212);
1378 snd_pcm_set_runtime_buffer(substream, &korg1212->dma_rec);
1380 spin_lock_irqsave(&korg1212->lock, flags);
1382 korg1212->capture_substream = substream;
1383 korg1212->capture_pid = current->pid;
1384 korg1212->periodsize = K1212_PERIODS;
1385 korg1212->channels = K1212_CHANNELS;
1387 spin_unlock_irqrestore(&korg1212->lock, flags);
1397 struct snd_korg1212 *korg1212 = snd_pcm_substream_chip(substream);
1400 stateName[korg1212->cardState]);
1402 snd_korg1212_silence(korg1212, 0, K1212_MAX_SAMPLES, 0, korg1212->channels * 2);
1404 spin_lock_irqsave(&korg1212->lock, flags);
1406 korg1212->playback_pid = -1;
1407 korg1212->playback_substream = NULL;
1408 korg1212->periodsize = 0;
1410 spin_unlock_irqrestore(&korg1212->lock, flags);
1412 snd_korg1212_CloseCard(korg1212);
1419 struct snd_korg1212 *korg1212 = snd_pcm_substream_chip(substream);
1422 stateName[korg1212->cardState]);
1424 spin_lock_irqsave(&korg1212->lock, flags);
1426 korg1212->capture_pid = -1;
1427 korg1212->capture_substream = NULL;
1428 korg1212->periodsize = 0;
1430 spin_unlock_irqrestore(&korg1212->lock, flags);
1432 snd_korg1212_CloseCard(korg1212);
1457 struct snd_korg1212 *korg1212 = snd_pcm_substream_chip(substream);
1463 stateName[korg1212->cardState]);
1465 spin_lock_irqsave(&korg1212->lock, flags);
1468 this_pid = korg1212->playback_pid;
1469 other_pid = korg1212->capture_pid;
1471 this_pid = korg1212->capture_pid;
1472 other_pid = korg1212->playback_pid;
1482 if ((int)params_rate(params) != korg1212->clkRate) {
1483 spin_unlock_irqrestore(&korg1212->lock, flags);
1488 spin_unlock_irqrestore(&korg1212->lock, flags);
1492 if ((err = snd_korg1212_SetRate(korg1212, params_rate(params))) < 0) {
1493 spin_unlock_irqrestore(&korg1212->lock, flags);
1497 korg1212->channels = params_channels(params);
1498 korg1212->periodsize = K1212_PERIOD_BYTES;
1500 spin_unlock_irqrestore(&korg1212->lock, flags);
1507 struct snd_korg1212 *korg1212 = snd_pcm_substream_chip(substream);
1511 stateName[korg1212->cardState]);
1513 spin_lock_irq(&korg1212->lock);
1515 if (korg1212->stop_pending_cnt > 0) {
1517 stateName[korg1212->cardState]);
1518 spin_unlock_irq(&korg1212->lock);
1521 korg1212->sharedBufferPtr->cardCommand = 0;
1522 del_timer(&korg1212->timer);
1523 korg1212->stop_pending_cnt = 0;
1527 rc = snd_korg1212_SetupForPlay(korg1212);
1529 korg1212->currentBuffer = 0;
1531 spin_unlock_irq(&korg1212->lock);
1539 struct snd_korg1212 *korg1212 = snd_pcm_substream_chip(substream);
1543 stateName[korg1212->cardState], cmd);
1545 spin_lock(&korg1212->lock);
1549 if (korg1212->running) {
1554 korg1212->running++;
1555 rc = snd_korg1212_TriggerPlay(korg1212);
1560 if (!korg1212->running) {
1565 korg1212->running--;
1566 rc = snd_korg1212_StopPlay(korg1212);
1573 spin_unlock(&korg1212->lock);
1579 struct snd_korg1212 *korg1212 = snd_pcm_substream_chip(substream);
1582 pos = korg1212->currentBuffer * kPlayBufferFrames;
1585 stateName[korg1212->cardState], pos);
1592 struct snd_korg1212 *korg1212 = snd_pcm_substream_chip(substream);
1595 pos = korg1212->currentBuffer * kPlayBufferFrames;
1598 stateName[korg1212->cardState], pos);
1609 struct snd_korg1212 *korg1212 = snd_pcm_substream_chip(substream);
1612 stateName[korg1212->cardState], pos, count);
1614 return snd_korg1212_copy_from(korg1212, src, pos, count, 0, korg1212->channels * 2);
1623 struct snd_korg1212 *korg1212 = snd_pcm_substream_chip(substream);
1626 stateName[korg1212->cardState]);
1628 return snd_korg1212_silence(korg1212, pos, count, 0, korg1212->channels * 2);
1637 struct snd_korg1212 *korg1212 = snd_pcm_substream_chip(substream);
1640 stateName[korg1212->cardState], pos, count);
1642 return snd_korg1212_copy_to(korg1212, dst, pos, count, 0, korg1212->channels * 2);
1683 struct snd_korg1212 *korg1212 = snd_kcontrol_chip(kcontrol);
1686 spin_lock_irq(&korg1212->lock);
1688 u->value.integer.value[0] = korg1212->volumePhase[i];
1691 u->value.integer.value[1] = korg1212->volumePhase[i+1];
1693 spin_unlock_irq(&korg1212->lock);
1701 struct snd_korg1212 *korg1212 = snd_kcontrol_chip(kcontrol);
1705 spin_lock_irq(&korg1212->lock);
1709 korg1212->volumePhase[i] = !!u->value.integer.value[0];
1711 val = korg1212->sharedBufferPtr->volumeData[kcontrol->private_value];
1714 val = abs(val) * (korg1212->volumePhase[i] > 0 ? -1 : 1);
1715 korg1212->sharedBufferPtr->volumeData[i] = val;
1720 korg1212->volumePhase[i+1] = !!u->value.integer.value[1];
1722 val = korg1212->sharedBufferPtr->volumeData[kcontrol->private_value+1];
1725 val = abs(val) * (korg1212->volumePhase[i+1] > 0 ? -1 : 1);
1726 korg1212->sharedBufferPtr->volumeData[i+1] = val;
1731 spin_unlock_irq(&korg1212->lock);
1749 struct snd_korg1212 *korg1212 = snd_kcontrol_chip(kcontrol);
1752 spin_lock_irq(&korg1212->lock);
1755 u->value.integer.value[0] = abs(korg1212->sharedBufferPtr->volumeData[i]);
1758 u->value.integer.value[1] = abs(korg1212->sharedBufferPtr->volumeData[i+1]);
1760 spin_unlock_irq(&korg1212->lock);
1768 struct snd_korg1212 *korg1212 = snd_kcontrol_chip(kcontrol);
1773 spin_lock_irq(&korg1212->lock);
1780 abs(korg1212->sharedBufferPtr->volumeData[i])) {
1781 val = korg1212->volumePhase[i] > 0 ? -1 : 1;
1783 korg1212->sharedBufferPtr->volumeData[i] = val;
1791 abs(korg1212->sharedBufferPtr->volumeData[i+1])) {
1792 val = korg1212->volumePhase[i+1] > 0 ? -1 : 1;
1794 korg1212->sharedBufferPtr->volumeData[i+1] = val;
1799 spin_unlock_irq(&korg1212->lock);
1820 struct snd_korg1212 *korg1212 = snd_kcontrol_chip(kcontrol);
1823 spin_lock_irq(&korg1212->lock);
1826 u->value.enumerated.item[0] = korg1212->sharedBufferPtr->routeData[i];
1829 u->value.enumerated.item[1] = korg1212->sharedBufferPtr->routeData[i+1];
1831 spin_unlock_irq(&korg1212->lock);
1839 struct snd_korg1212 *korg1212 = snd_kcontrol_chip(kcontrol);
1842 spin_lock_irq(&korg1212->lock);
1848 (unsigned) korg1212->sharedBufferPtr->volumeData[i]) {
1849 korg1212->sharedBufferPtr->routeData[i] = u->value.enumerated.item[0];
1856 (unsigned) korg1212->sharedBufferPtr->volumeData[i+1]) {
1857 korg1212->sharedBufferPtr->routeData[i+1] = u->value.enumerated.item[1];
1862 spin_unlock_irq(&korg1212->lock);
1880 struct snd_korg1212 *korg1212 = snd_kcontrol_chip(kcontrol);
1882 spin_lock_irq(&korg1212->lock);
1884 u->value.integer.value[0] = korg1212->leftADCInSens;
1885 u->value.integer.value[1] = korg1212->rightADCInSens;
1887 spin_unlock_irq(&korg1212->lock);
1895 struct snd_korg1212 *korg1212 = snd_kcontrol_chip(kcontrol);
1898 spin_lock_irq(&korg1212->lock);
1902 u->value.integer.value[0] != korg1212->leftADCInSens) {
1903 korg1212->leftADCInSens = u->value.integer.value[0];
1908 u->value.integer.value[1] != korg1212->rightADCInSens) {
1909 korg1212->rightADCInSens = u->value.integer.value[1];
1913 spin_unlock_irq(&korg1212->lock);
1916 snd_korg1212_WriteADCSensitivity(korg1212);
1937 struct snd_korg1212 *korg1212 = snd_kcontrol_chip(kcontrol);
1939 spin_lock_irq(&korg1212->lock);
1941 ucontrol->value.enumerated.item[0] = korg1212->clkSource;
1943 spin_unlock_irq(&korg1212->lock);
1950 struct snd_korg1212 *korg1212 = snd_kcontrol_chip(kcontrol);
1955 spin_lock_irq(&korg1212->lock);
1956 change = val != korg1212->clkSource;
1957 snd_korg1212_SetClockSource(korg1212, val);
1958 spin_unlock_irq(&korg1212->lock);
2022 struct snd_korg1212 *korg1212 = entry->private_data;
2024 snd_iprintf(buffer, korg1212->card->longname);
2025 snd_iprintf(buffer, " (index #%d)\n", korg1212->card->number + 1);
2028 snd_iprintf(buffer, " clock mode: %s\n", clockSourceName[korg1212->clkSrcRate] );
2029 snd_iprintf(buffer, " left ADC Sens: %d\n", korg1212->leftADCInSens );
2030 snd_iprintf(buffer, " right ADC Sens: %d\n", korg1212->rightADCInSens );
2035 channelName[korg1212->sharedBufferPtr->routeData[n]],
2036 korg1212->sharedBufferPtr->volumeData[n]);
2038 snd_iprintf(buffer, " ADAT Time Code: %d\n", korg1212->sharedBufferPtr->AdatTimeCode);
2039 snd_iprintf(buffer, " Card State: %s\n", stateName[korg1212->cardState]);
2040 snd_iprintf(buffer, "Idle mon. State: %d\n", korg1212->idleMonitorOn);
2041 snd_iprintf(buffer, "Cmd retry count: %d\n", korg1212->cmdRetryCount);
2042 snd_iprintf(buffer, " Irq count: %ld\n", korg1212->irqcount);
2043 snd_iprintf(buffer, " Error count: %ld\n", korg1212->totalerrorcnt);
2046 static void __devinit snd_korg1212_proc_init(struct snd_korg1212 *korg1212)
2050 if (! snd_card_proc_new(korg1212->card, "korg1212", &entry))
2051 snd_info_set_text_ops(entry, korg1212, snd_korg1212_proc_read);
2055 snd_korg1212_free(struct snd_korg1212 *korg1212)
2057 snd_korg1212_TurnOffIdleMonitor(korg1212);
2059 if (korg1212->irq >= 0) {
2060 snd_korg1212_DisableCardInterrupts(korg1212);
2061 free_irq(korg1212->irq, korg1212);
2062 korg1212->irq = -1;
2065 if (korg1212->iobase != NULL) {
2066 iounmap(korg1212->iobase);
2067 korg1212->iobase = NULL;
2070 pci_release_regions(korg1212->pci);
2075 if (korg1212->dma_dsp.area) {
2076 snd_dma_free_pages(&korg1212->dma_dsp);
2077 korg1212->dma_dsp.area = NULL;
2085 if (korg1212->dma_play.area) {
2086 snd_dma_free_pages(&korg1212->dma_play);
2087 korg1212->dma_play.area = NULL;
2090 if (korg1212->dma_rec.area) {
2091 snd_dma_free_pages(&korg1212->dma_rec);
2092 korg1212->dma_rec.area = NULL;
2100 if (korg1212->dma_shared.area) {
2101 snd_dma_free_pages(&korg1212->dma_shared);
2102 korg1212->dma_shared.area = NULL;
2105 pci_disable_device(korg1212->pci);
2106 kfree(korg1212);
2112 struct snd_korg1212 *korg1212 = device->device_data;
2114 return snd_korg1212_free(korg1212);
2124 struct snd_korg1212 * korg1212;
2135 korg1212 = kzalloc(sizeof(*korg1212), GFP_KERNEL);
2136 if (korg1212 == NULL) {
2141 korg1212->card = card;
2142 korg1212->pci = pci;
2144 init_waitqueue_head(&korg1212->wait);
2145 spin_lock_init(&korg1212->lock);
2146 mutex_init(&korg1212->open_mutex);
2147 init_timer(&korg1212->timer);
2148 korg1212->timer.function = snd_korg1212_timer_func;
2149 korg1212->timer.data = (unsigned long)korg1212;
2151 korg1212->irq = -1;
2152 korg1212->clkSource = K1212_CLKIDX_Local;
2153 korg1212->clkRate = 44100;
2154 korg1212->inIRQ = 0;
2155 korg1212->running = 0;
2156 korg1212->opencnt = 0;
2157 korg1212->playcnt = 0;
2158 korg1212->setcnt = 0;
2159 korg1212->totalerrorcnt = 0;
2160 korg1212->playback_pid = -1;
2161 korg1212->capture_pid = -1;
2162 snd_korg1212_setCardState(korg1212, K1212_STATE_UNINITIALIZED);
2163 korg1212->idleMonitorOn = 0;
2164 korg1212->clkSrcRate = K1212_CLKIDX_LocalAt44_1K;
2165 korg1212->leftADCInSens = k1212MaxADCSens;
2166 korg1212->rightADCInSens = k1212MaxADCSens;
2169 korg1212->volumePhase[i] = 0;
2171 if ((err = pci_request_regions(pci, "korg1212")) < 0) {
2172 kfree(korg1212);
2177 korg1212->iomem = pci_resource_start(korg1212->pci, 0);
2178 korg1212->ioport = pci_resource_start(korg1212->pci, 1);
2179 korg1212->iomem2 = pci_resource_start(korg1212->pci, 2);
2181 iomem_size = pci_resource_len(korg1212->pci, 0);
2182 ioport_size = pci_resource_len(korg1212->pci, 1);
2183 iomem2_size = pci_resource_len(korg1212->pci, 2);
2190 korg1212->iomem, iomem_size,
2191 korg1212->ioport, ioport_size,
2192 korg1212->iomem2, iomem2_size,
2193 stateName[korg1212->cardState]);
2195 if ((korg1212->iobase = ioremap(korg1212->iomem, iomem_size)) == NULL) {
2196 snd_printk(KERN_ERR "korg1212: unable to remap memory region 0x%lx-0x%lx\n", korg1212->iomem,
2197 korg1212->iomem + iomem_size - 1);
2198 snd_korg1212_free(korg1212);
2204 "korg1212", korg1212);
2207 snd_printk(KERN_ERR "korg1212: unable to grab IRQ %d\n", pci->irq);
2208 snd_korg1212_free(korg1212);
2212 korg1212->irq = pci->irq;
2214 pci_set_master(korg1212->pci);
2216 korg1212->statusRegPtr = (u32 __iomem *) (korg1212->iobase + STATUS_REG_OFFSET);
2217 korg1212->outDoorbellPtr = (u32 __iomem *) (korg1212->iobase + OUT_DOORBELL_OFFSET);
2218 korg1212->inDoorbellPtr = (u32 __iomem *) (korg1212->iobase + IN_DOORBELL_OFFSET);
2219 korg1212->mailbox0Ptr = (u32 __iomem *) (korg1212->iobase + MAILBOX0_OFFSET);
2220 korg1212->mailbox1Ptr = (u32 __iomem *) (korg1212->iobase + MAILBOX1_OFFSET);
2221 korg1212->mailbox2Ptr = (u32 __iomem *) (korg1212->iobase + MAILBOX2_OFFSET);
2222 korg1212->mailbox3Ptr = (u32 __iomem *) (korg1212->iobase + MAILBOX3_OFFSET);
2223 korg1212->controlRegPtr = (u32 __iomem *) (korg1212->iobase + PCI_CONTROL_OFFSET);
2224 korg1212->sensRegPtr = (u16 __iomem *) (korg1212->iobase + SENS_CONTROL_OFFSET);
2225 korg1212->idRegPtr = (u32 __iomem *) (korg1212->iobase + DEV_VEND_ID_OFFSET);
2239 korg1212->statusRegPtr,
2240 korg1212->outDoorbellPtr,
2241 korg1212->inDoorbellPtr,
2242 korg1212->mailbox0Ptr,
2243 korg1212->mailbox1Ptr,
2244 korg1212->mailbox2Ptr,
2245 korg1212->mailbox3Ptr,
2246 korg1212->controlRegPtr,
2247 korg1212->sensRegPtr,
2248 korg1212->idRegPtr,
2249 stateName[korg1212->cardState]);
2252 sizeof(struct KorgSharedBuffer), &korg1212->dma_shared) < 0) {
2253 snd_printk(KERN_ERR "korg1212: can not allocate shared buffer memory (%Zd bytes)\n", sizeof(struct KorgSharedBuffer));
2254 snd_korg1212_free(korg1212);
2257 korg1212->sharedBufferPtr = (struct KorgSharedBuffer *)korg1212->dma_shared.area;
2258 korg1212->sharedBufferPhy = korg1212->dma_shared.addr;
2260 K1212_DEBUG_PRINTK("K1212_DEBUG: Shared Buffer Area = 0x%p (0x%08lx), %d bytes\n", korg1212->sharedBufferPtr, korg1212->sharedBufferPhy, sizeof(struct KorgSharedBuffer));
2264 korg1212->DataBufsSize = sizeof(struct KorgAudioBuffer) * kNumBuffers;
2267 korg1212->DataBufsSize, &korg1212->dma_play) < 0) {
2268 snd_printk(KERN_ERR "korg1212: can not allocate play data buffer memory (%d bytes)\n", korg1212->DataBufsSize);
2269 snd_korg1212_free(korg1212);
2272 korg1212->playDataBufsPtr = (struct KorgAudioBuffer *)korg1212->dma_play.area;
2273 korg1212->PlayDataPhy = korg1212->dma_play.addr;
2276 korg1212->playDataBufsPtr, korg1212->PlayDataPhy, korg1212->DataBufsSize);
2279 korg1212->DataBufsSize, &korg1212->dma_rec) < 0) {
2280 snd_printk(KERN_ERR "korg1212: can not allocate record data buffer memory (%d bytes)\n", korg1212->DataBufsSize);
2281 snd_korg1212_free(korg1212);
2284 korg1212->recordDataBufsPtr = (struct KorgAudioBuffer *)korg1212->dma_rec.area;
2285 korg1212->RecDataPhy = korg1212->dma_rec.addr;
2288 korg1212->recordDataBufsPtr, korg1212->RecDataPhy, korg1212->DataBufsSize);
2292 korg1212->recordDataBufsPtr = korg1212->sharedBufferPtr->recordDataBufs;
2293 korg1212->playDataBufsPtr = korg1212->sharedBufferPtr->playDataBufs;
2294 korg1212->PlayDataPhy = (u32) &((struct KorgSharedBuffer *) korg1212->sharedBufferPhy)->playDataBufs;
2295 korg1212->RecDataPhy = (u32) &((struct KorgSharedBuffer *) korg1212->sharedBufferPhy)->recordDataBufs;
2299 korg1212->VolumeTablePhy = korg1212->sharedBufferPhy +
2301 korg1212->RoutingTablePhy = korg1212->sharedBufferPhy +
2303 korg1212->AdatTimeCodePhy = korg1212->sharedBufferPhy +
2310 snd_korg1212_free(korg1212);
2315 dsp_code->size, &korg1212->dma_dsp) < 0) {
2316 snd_printk(KERN_ERR "korg1212: cannot allocate dsp code memory (%zd bytes)\n", dsp_code->size);
2317 snd_korg1212_free(korg1212);
2323 korg1212->dma_dsp.area, korg1212->dma_dsp.addr, dsp_code->size,
2324 stateName[korg1212->cardState]);
2326 memcpy(korg1212->dma_dsp.area, dsp_code->data, dsp_code->size);
2330 rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_RebootCard, 0, 0, 0, 0);
2333 K1212_DEBUG_PRINTK("K1212_DEBUG: Reboot Card - RC = %d [%s]\n", rc, stateName[korg1212->cardState]);
2335 if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, korg1212, &ops)) < 0) {
2336 snd_korg1212_free(korg1212);
2340 snd_korg1212_EnableCardInterrupts(korg1212);
2344 if (snd_korg1212_downloadDSPCode(korg1212))
2347 K1212_DEBUG_PRINTK("korg1212: dspMemPhy = %08x U[%08x], "
2349 "korg1212: RecDataPhy = %08x L[%08x], "
2351 "korg1212: RoutingTablePhy = %08x L[%08x], "
2353 (int)korg1212->dma_dsp.addr, UpperWordSwap(korg1212->dma_dsp.addr),
2354 korg1212->PlayDataPhy, LowerWordSwap(korg1212->PlayDataPhy),
2355 korg1212->RecDataPhy, LowerWordSwap(korg1212->RecDataPhy),
2356 korg1212->VolumeTablePhy, LowerWordSwap(korg1212->VolumeTablePhy),
2357 korg1212->RoutingTablePhy, LowerWordSwap(korg1212->RoutingTablePhy),
2358 korg1212->AdatTimeCodePhy, LowerWordSwap(korg1212->AdatTimeCodePhy));
2360 if ((err = snd_pcm_new(korg1212->card, "korg1212", 0, 1, 1, &korg1212->pcm)) < 0)
2363 korg1212->pcm->private_data = korg1212;
2364 korg1212->pcm->private_free = snd_korg1212_free_pcm;
2365 strcpy(korg1212->pcm->name, "korg1212");
2367 snd_pcm_set_ops(korg1212->pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_korg1212_playback_ops);
2369 snd_pcm_set_ops(korg1212->pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_korg1212_capture_ops);
2371 korg1212->pcm->info_flags = SNDRV_PCM_INFO_JOINT_DUPLEX;
2374 err = snd_ctl_add(korg1212->card, snd_ctl_new1(&snd_korg1212_controls[i], korg1212));
2379 snd_korg1212_proc_init(korg1212);
2383 * rchip = korg1212;
2397 struct snd_korg1212 *korg1212;
2412 if ((err = snd_korg1212_create(card, pci, &korg1212)) < 0) {
2417 strcpy(card->driver, "korg1212");
2418 strcpy(card->shortname, "korg1212");
2420 korg1212->iomem, korg1212->irq);
2440 .name = "korg1212",