diff options
author | Takashi Iwai <tiwai@suse.de> | 2005-11-17 04:45:48 -0500 |
---|---|---|
committer | Jaroslav Kysela <perex@suse.cz> | 2006-01-03 06:17:07 -0500 |
commit | 9fd9156c6b0dfb8630f68d11dc48a3e824aa64e6 (patch) | |
tree | ec4c9a37b16a67aa477d06cb33d6170d761c0e15 | |
parent | e017fa5772cd2536b2b2fb210f5a6e86cceaa633 (diff) |
[ALSA] korg1212 - Clean up debug prints
Modules: KORG1212 driver
Clean up debug prints in korg1212 driver.
Also, clean up spaces/indents in some places.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
-rw-r--r-- | sound/pci/korg1212/korg1212.c | 574 |
1 files changed, 247 insertions, 327 deletions
diff --git a/sound/pci/korg1212/korg1212.c b/sound/pci/korg1212/korg1212.c index a110d664f626..ec716133ec3a 100644 --- a/sound/pci/korg1212/korg1212.c +++ b/sound/pci/korg1212/korg1212.c | |||
@@ -41,8 +41,16 @@ | |||
41 | // Debug Stuff | 41 | // Debug Stuff |
42 | // ---------------------------------------------------------------------------- | 42 | // ---------------------------------------------------------------------------- |
43 | #define K1212_DEBUG_LEVEL 0 | 43 | #define K1212_DEBUG_LEVEL 0 |
44 | #define K1212_DEBUG_PRINTK printk | 44 | #if K1212_DEBUG_LEVEL > 0 |
45 | //#define K1212_DEBUG_PRINTK(x...) printk("<0>" x) | 45 | #define K1212_DEBUG_PRINTK(fmt,args...) printk(KERN_DEBUG fmt,##args) |
46 | #else | ||
47 | #define K1212_DEBUG_PRINTK(fmt,...) | ||
48 | #endif | ||
49 | #if K1212_DEBUG_LEVEL > 1 | ||
50 | #define K1212_DEBUG_PRINTK_VERBOSE(fmt,args...) printk(KERN_DEBUG fmt,##args) | ||
51 | #else | ||
52 | #define K1212_DEBUG_PRINTK_VERBOSE(fmt,...) | ||
53 | #endif | ||
46 | 54 | ||
47 | // ---------------------------------------------------------------------------- | 55 | // ---------------------------------------------------------------------------- |
48 | // Record/Play Buffer Allocation Method. If K1212_LARGEALLOC is defined all | 56 | // Record/Play Buffer Allocation Method. If K1212_LARGEALLOC is defined all |
@@ -432,54 +440,54 @@ static struct pci_device_id snd_korg1212_ids[] = { | |||
432 | { 0, }, | 440 | { 0, }, |
433 | }; | 441 | }; |
434 | 442 | ||
435 | static char* stateName[] = { | 443 | static char *stateName[] = { |
436 | "Non-existent", | 444 | "Non-existent", |
437 | "Uninitialized", | 445 | "Uninitialized", |
438 | "DSP download in process", | 446 | "DSP download in process", |
439 | "DSP download complete", | 447 | "DSP download complete", |
440 | "Ready", | 448 | "Ready", |
441 | "Open", | 449 | "Open", |
442 | "Setup for play", | 450 | "Setup for play", |
443 | "Playing", | 451 | "Playing", |
444 | "Monitor mode on", | 452 | "Monitor mode on", |
445 | "Calibrating", | 453 | "Calibrating", |
446 | "Invalid" | 454 | "Invalid" |
447 | }; | 455 | }; |
448 | 456 | ||
449 | static char* clockSourceTypeName[] = { "ADAT", "S/PDIF", "local" }; | 457 | static char *clockSourceTypeName[] = { "ADAT", "S/PDIF", "local" }; |
450 | 458 | ||
451 | static char* clockSourceName[] = { | 459 | static char *clockSourceName[] = { |
452 | "ADAT at 44.1 kHz", | 460 | "ADAT at 44.1 kHz", |
453 | "ADAT at 48 kHz", | 461 | "ADAT at 48 kHz", |
454 | "S/PDIF at 44.1 kHz", | 462 | "S/PDIF at 44.1 kHz", |
455 | "S/PDIF at 48 kHz", | 463 | "S/PDIF at 48 kHz", |
456 | "local clock at 44.1 kHz", | 464 | "local clock at 44.1 kHz", |
457 | "local clock at 48 kHz" | 465 | "local clock at 48 kHz" |
458 | }; | 466 | }; |
459 | 467 | ||
460 | static char* channelName[] = { | 468 | static char *channelName[] = { |
461 | "ADAT-1", | 469 | "ADAT-1", |
462 | "ADAT-2", | 470 | "ADAT-2", |
463 | "ADAT-3", | 471 | "ADAT-3", |
464 | "ADAT-4", | 472 | "ADAT-4", |
465 | "ADAT-5", | 473 | "ADAT-5", |
466 | "ADAT-6", | 474 | "ADAT-6", |
467 | "ADAT-7", | 475 | "ADAT-7", |
468 | "ADAT-8", | 476 | "ADAT-8", |
469 | "Analog-L", | 477 | "Analog-L", |
470 | "Analog-R", | 478 | "Analog-R", |
471 | "SPDIF-L", | 479 | "SPDIF-L", |
472 | "SPDIF-R", | 480 | "SPDIF-R", |
473 | }; | 481 | }; |
474 | 482 | ||
475 | static u16 ClockSourceSelector[] = | 483 | static u16 ClockSourceSelector[] = { |
476 | {0x8000, // selects source as ADAT at 44.1 kHz | 484 | 0x8000, // selects source as ADAT at 44.1 kHz |
477 | 0x0000, // selects source as ADAT at 48 kHz | 485 | 0x0000, // selects source as ADAT at 48 kHz |
478 | 0x8001, // selects source as S/PDIF at 44.1 kHz | 486 | 0x8001, // selects source as S/PDIF at 44.1 kHz |
479 | 0x0001, // selects source as S/PDIF at 48 kHz | 487 | 0x0001, // selects source as S/PDIF at 48 kHz |
480 | 0x8002, // selects source as local clock at 44.1 kHz | 488 | 0x8002, // selects source as local clock at 44.1 kHz |
481 | 0x0002 // selects source as local clock at 48 kHz | 489 | 0x0002 // selects source as local clock at 48 kHz |
482 | }; | 490 | }; |
483 | 491 | ||
484 | static snd_korg1212rc rc; | 492 | static snd_korg1212rc rc; |
485 | 493 | ||
@@ -521,23 +529,6 @@ static u32 LowerWordSwap(u32 swappee) | |||
521 | return retVal.i; | 529 | return retVal.i; |
522 | } | 530 | } |
523 | 531 | ||
524 | #if 0 /* not used */ | ||
525 | |||
526 | static u32 EndianSwap(u32 swappee) | ||
527 | { | ||
528 | swap_u32 retVal, swapper; | ||
529 | |||
530 | swapper.i = swappee; | ||
531 | retVal.c[0] = swapper.c[3]; | ||
532 | retVal.c[1] = swapper.c[2]; | ||
533 | retVal.c[2] = swapper.c[1]; | ||
534 | retVal.c[3] = swapper.c[0]; | ||
535 | |||
536 | return retVal.i; | ||
537 | } | ||
538 | |||
539 | #endif /* not used */ | ||
540 | |||
541 | #define SetBitInWord(theWord,bitPosition) (*theWord) |= (0x0001 << bitPosition) | 532 | #define SetBitInWord(theWord,bitPosition) (*theWord) |= (0x0001 << bitPosition) |
542 | #define SetBitInDWord(theWord,bitPosition) (*theWord) |= (0x00000001 << bitPosition) | 533 | #define SetBitInDWord(theWord,bitPosition) (*theWord) |= (0x00000001 << bitPosition) |
543 | #define ClearBitInWord(theWord,bitPosition) (*theWord) &= ~(0x0001 << bitPosition) | 534 | #define ClearBitInWord(theWord,bitPosition) (*theWord) &= ~(0x0001 << bitPosition) |
@@ -551,15 +542,12 @@ static snd_korg1212rc snd_korg1212_Send1212Command(korg1212_t *korg1212, korg121 | |||
551 | snd_korg1212rc rc = K1212_CMDRET_Success; | 542 | snd_korg1212rc rc = K1212_CMDRET_Success; |
552 | 543 | ||
553 | if (!korg1212->outDoorbellPtr) { | 544 | if (!korg1212->outDoorbellPtr) { |
554 | #if K1212_DEBUG_LEVEL > 1 | 545 | K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: CardUninitialized\n"); |
555 | K1212_DEBUG_PRINTK("K1212_DEBUG: CardUninitialized\n"); | ||
556 | #endif | ||
557 | return K1212_CMDRET_CardUninitialized; | 546 | return K1212_CMDRET_CardUninitialized; |
558 | } | 547 | } |
559 | 548 | ||
560 | #if K1212_DEBUG_LEVEL > 0 | 549 | K1212_DEBUG_PRINTK("K1212_DEBUG: Card <- 0x%08x 0x%08x [%s]\n", |
561 | K1212_DEBUG_PRINTK("K1212_DEBUG: Card <- 0x%08x 0x%08x [%s]\n", doorbellVal, mailBox0Val, stateName[korg1212->cardState]); | 550 | doorbellVal, mailBox0Val, stateName[korg1212->cardState]); |
562 | #endif | ||
563 | for (retryCount = 0; retryCount < MAX_COMMAND_RETRIES; retryCount++) { | 551 | for (retryCount = 0; retryCount < MAX_COMMAND_RETRIES; retryCount++) { |
564 | writel(mailBox3Val, korg1212->mailbox3Ptr); | 552 | writel(mailBox3Val, korg1212->mailbox3Ptr); |
565 | writel(mailBox2Val, korg1212->mailbox2Ptr); | 553 | writel(mailBox2Val, korg1212->mailbox2Ptr); |
@@ -586,9 +574,7 @@ static snd_korg1212rc snd_korg1212_Send1212Command(korg1212_t *korg1212, korg121 | |||
586 | mailBox3Lo = readl(korg1212->mailbox3Ptr); | 574 | mailBox3Lo = readl(korg1212->mailbox3Ptr); |
587 | if (mailBox3Lo & COMMAND_ACK_MASK) { | 575 | if (mailBox3Lo & COMMAND_ACK_MASK) { |
588 | if ((mailBox3Lo & DOORBELL_VAL_MASK) == (doorbellVal & DOORBELL_VAL_MASK)) { | 576 | if ((mailBox3Lo & DOORBELL_VAL_MASK) == (doorbellVal & DOORBELL_VAL_MASK)) { |
589 | #if K1212_DEBUG_LEVEL > 1 | 577 | K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: Card <- Success\n"); |
590 | K1212_DEBUG_PRINTK("K1212_DEBUG: Card <- Success\n"); | ||
591 | #endif | ||
592 | rc = K1212_CMDRET_Success; | 578 | rc = K1212_CMDRET_Success; |
593 | break; | 579 | break; |
594 | } | 580 | } |
@@ -597,9 +583,7 @@ static snd_korg1212rc snd_korg1212_Send1212Command(korg1212_t *korg1212, korg121 | |||
597 | korg1212->cmdRetryCount += retryCount; | 583 | korg1212->cmdRetryCount += retryCount; |
598 | 584 | ||
599 | if (retryCount >= MAX_COMMAND_RETRIES) { | 585 | if (retryCount >= MAX_COMMAND_RETRIES) { |
600 | #if K1212_DEBUG_LEVEL > 1 | 586 | K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: Card <- NoAckFromCard\n"); |
601 | K1212_DEBUG_PRINTK("K1212_DEBUG: Card <- NoAckFromCard\n"); | ||
602 | #endif | ||
603 | rc = K1212_CMDRET_NoAckFromCard; | 587 | rc = K1212_CMDRET_NoAckFromCard; |
604 | } | 588 | } |
605 | 589 | ||
@@ -639,9 +623,8 @@ static void snd_korg1212_timer_func(unsigned long data) | |||
639 | korg1212->stop_pending_cnt = 0; | 623 | korg1212->stop_pending_cnt = 0; |
640 | korg1212->dsp_stop_is_processed = 1; | 624 | korg1212->dsp_stop_is_processed = 1; |
641 | wake_up(&korg1212->wait); | 625 | wake_up(&korg1212->wait); |
642 | #if K1212_DEBUG_LEVEL > 1 | 626 | K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: Stop ack'ed [%s]\n", |
643 | K1212_DEBUG_PRINTK("K1212_DEBUG: Stop ack'ed [%s]\n", stateName[korg1212->cardState]); | 627 | stateName[korg1212->cardState]); |
644 | #endif | ||
645 | } else { | 628 | } else { |
646 | if (--korg1212->stop_pending_cnt > 0) { | 629 | if (--korg1212->stop_pending_cnt > 0) { |
647 | /* reprogram timer */ | 630 | /* reprogram timer */ |
@@ -652,17 +635,17 @@ static void snd_korg1212_timer_func(unsigned long data) | |||
652 | korg1212->sharedBufferPtr->cardCommand = 0; | 635 | korg1212->sharedBufferPtr->cardCommand = 0; |
653 | korg1212->dsp_stop_is_processed = 1; | 636 | korg1212->dsp_stop_is_processed = 1; |
654 | wake_up(&korg1212->wait); | 637 | wake_up(&korg1212->wait); |
655 | #if K1212_DEBUG_LEVEL > 0 | 638 | K1212_DEBUG_PRINTK("K1212_DEBUG: Stop timeout [%s]\n", |
656 | K1212_DEBUG_PRINTK("K1212_DEBUG: Stop timeout [%s]\n", stateName[korg1212->cardState]); | 639 | stateName[korg1212->cardState]); |
657 | #endif | ||
658 | } | 640 | } |
659 | } | 641 | } |
660 | spin_unlock(&korg1212->lock); | 642 | spin_unlock(&korg1212->lock); |
661 | } | 643 | } |
662 | 644 | ||
663 | static void snd_korg1212_TurnOnIdleMonitor(korg1212_t *korg1212) | 645 | static int snd_korg1212_TurnOnIdleMonitor(korg1212_t *korg1212) |
664 | { | 646 | { |
665 | unsigned long flags; | 647 | unsigned long flags; |
648 | int rc; | ||
666 | 649 | ||
667 | udelay(INTERCOMMAND_DELAY); | 650 | udelay(INTERCOMMAND_DELAY); |
668 | spin_lock_irqsave(&korg1212->lock, flags); | 651 | spin_lock_irqsave(&korg1212->lock, flags); |
@@ -670,6 +653,7 @@ static void snd_korg1212_TurnOnIdleMonitor(korg1212_t *korg1212) | |||
670 | rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_SelectPlayMode, | 653 | rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_SelectPlayMode, |
671 | K1212_MODE_MonitorOn, 0, 0, 0); | 654 | K1212_MODE_MonitorOn, 0, 0, 0); |
672 | spin_unlock_irqrestore(&korg1212->lock, flags); | 655 | spin_unlock_irqrestore(&korg1212->lock, flags); |
656 | return rc; | ||
673 | } | 657 | } |
674 | 658 | ||
675 | static void snd_korg1212_TurnOffIdleMonitor(korg1212_t *korg1212) | 659 | static void snd_korg1212_TurnOffIdleMonitor(korg1212_t *korg1212) |
@@ -687,9 +671,8 @@ static inline void snd_korg1212_setCardState(korg1212_t * korg1212, CardState cs | |||
687 | 671 | ||
688 | static int snd_korg1212_OpenCard(korg1212_t * korg1212) | 672 | static int snd_korg1212_OpenCard(korg1212_t * korg1212) |
689 | { | 673 | { |
690 | #if K1212_DEBUG_LEVEL > 0 | 674 | K1212_DEBUG_PRINTK("K1212_DEBUG: OpenCard [%s] %d\n", |
691 | K1212_DEBUG_PRINTK("K1212_DEBUG: OpenCard [%s] %d\n", stateName[korg1212->cardState], korg1212->opencnt); | 675 | stateName[korg1212->cardState], korg1212->opencnt); |
692 | #endif | ||
693 | down(&korg1212->open_mutex); | 676 | down(&korg1212->open_mutex); |
694 | if (korg1212->opencnt++ == 0) { | 677 | if (korg1212->opencnt++ == 0) { |
695 | snd_korg1212_TurnOffIdleMonitor(korg1212); | 678 | snd_korg1212_TurnOffIdleMonitor(korg1212); |
@@ -702,9 +685,8 @@ static int snd_korg1212_OpenCard(korg1212_t * korg1212) | |||
702 | 685 | ||
703 | static int snd_korg1212_CloseCard(korg1212_t * korg1212) | 686 | static int snd_korg1212_CloseCard(korg1212_t * korg1212) |
704 | { | 687 | { |
705 | #if K1212_DEBUG_LEVEL > 0 | 688 | K1212_DEBUG_PRINTK("K1212_DEBUG: CloseCard [%s] %d\n", |
706 | K1212_DEBUG_PRINTK("K1212_DEBUG: CloseCard [%s] %d\n", stateName[korg1212->cardState], korg1212->opencnt); | 689 | stateName[korg1212->cardState], korg1212->opencnt); |
707 | #endif | ||
708 | 690 | ||
709 | down(&korg1212->open_mutex); | 691 | down(&korg1212->open_mutex); |
710 | if (--(korg1212->opencnt)) { | 692 | if (--(korg1212->opencnt)) { |
@@ -713,12 +695,11 @@ static int snd_korg1212_CloseCard(korg1212_t * korg1212) | |||
713 | } | 695 | } |
714 | 696 | ||
715 | if (korg1212->cardState == K1212_STATE_SETUP) { | 697 | if (korg1212->cardState == K1212_STATE_SETUP) { |
716 | rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_SelectPlayMode, | 698 | int rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_SelectPlayMode, |
717 | K1212_MODE_StopPlay, 0, 0, 0); | 699 | K1212_MODE_StopPlay, 0, 0, 0); |
718 | #if K1212_DEBUG_LEVEL > 0 | 700 | if (rc) |
719 | if (rc) K1212_DEBUG_PRINTK("K1212_DEBUG: CloseCard - RC = %d [%s]\n", rc, stateName[korg1212->cardState]); | 701 | K1212_DEBUG_PRINTK("K1212_DEBUG: CloseCard - RC = %d [%s]\n", |
720 | #endif | 702 | rc, stateName[korg1212->cardState]); |
721 | |||
722 | if (rc != K1212_CMDRET_Success) { | 703 | if (rc != K1212_CMDRET_Success) { |
723 | up(&korg1212->open_mutex); | 704 | up(&korg1212->open_mutex); |
724 | return 0; | 705 | return 0; |
@@ -739,9 +720,10 @@ static int snd_korg1212_CloseCard(korg1212_t * korg1212) | |||
739 | /* spinlock already held */ | 720 | /* spinlock already held */ |
740 | static int snd_korg1212_SetupForPlay(korg1212_t * korg1212) | 721 | static int snd_korg1212_SetupForPlay(korg1212_t * korg1212) |
741 | { | 722 | { |
742 | #if K1212_DEBUG_LEVEL > 0 | 723 | int rc; |
743 | K1212_DEBUG_PRINTK("K1212_DEBUG: SetupForPlay [%s] %d\n", stateName[korg1212->cardState], korg1212->setcnt); | 724 | |
744 | #endif | 725 | K1212_DEBUG_PRINTK("K1212_DEBUG: SetupForPlay [%s] %d\n", |
726 | stateName[korg1212->cardState], korg1212->setcnt); | ||
745 | 727 | ||
746 | if (korg1212->setcnt++) | 728 | if (korg1212->setcnt++) |
747 | return 0; | 729 | return 0; |
@@ -749,10 +731,9 @@ static int snd_korg1212_SetupForPlay(korg1212_t * korg1212) | |||
749 | snd_korg1212_setCardState(korg1212, K1212_STATE_SETUP); | 731 | snd_korg1212_setCardState(korg1212, K1212_STATE_SETUP); |
750 | rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_SelectPlayMode, | 732 | rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_SelectPlayMode, |
751 | K1212_MODE_SetupPlay, 0, 0, 0); | 733 | K1212_MODE_SetupPlay, 0, 0, 0); |
752 | 734 | if (rc) | |
753 | #if K1212_DEBUG_LEVEL > 0 | 735 | K1212_DEBUG_PRINTK("K1212_DEBUG: SetupForPlay - RC = %d [%s]\n", |
754 | if (rc) K1212_DEBUG_PRINTK("K1212_DEBUG: SetupForPlay - RC = %d [%s]\n", rc, stateName[korg1212->cardState]); | 736 | rc, stateName[korg1212->cardState]); |
755 | #endif | ||
756 | if (rc != K1212_CMDRET_Success) { | 737 | if (rc != K1212_CMDRET_Success) { |
757 | return 1; | 738 | return 1; |
758 | } | 739 | } |
@@ -762,20 +743,19 @@ static int snd_korg1212_SetupForPlay(korg1212_t * korg1212) | |||
762 | /* spinlock already held */ | 743 | /* spinlock already held */ |
763 | static int snd_korg1212_TriggerPlay(korg1212_t * korg1212) | 744 | static int snd_korg1212_TriggerPlay(korg1212_t * korg1212) |
764 | { | 745 | { |
765 | #if K1212_DEBUG_LEVEL > 0 | 746 | int rc; |
766 | K1212_DEBUG_PRINTK("K1212_DEBUG: TriggerPlay [%s] %d\n", stateName[korg1212->cardState], korg1212->playcnt); | 747 | |
767 | #endif | 748 | K1212_DEBUG_PRINTK("K1212_DEBUG: TriggerPlay [%s] %d\n", |
749 | stateName[korg1212->cardState], korg1212->playcnt); | ||
768 | 750 | ||
769 | if (korg1212->playcnt++) | 751 | if (korg1212->playcnt++) |
770 | return 0; | 752 | return 0; |
771 | 753 | ||
772 | snd_korg1212_setCardState(korg1212, K1212_STATE_PLAYING); | 754 | snd_korg1212_setCardState(korg1212, K1212_STATE_PLAYING); |
773 | rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_TriggerPlay, 0, 0, 0, 0); | 755 | rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_TriggerPlay, 0, 0, 0, 0); |
774 | 756 | if (rc) | |
775 | #if K1212_DEBUG_LEVEL > 0 | 757 | K1212_DEBUG_PRINTK("K1212_DEBUG: TriggerPlay - RC = %d [%s]\n", |
776 | if (rc) K1212_DEBUG_PRINTK("K1212_DEBUG: TriggerPlay - RC = %d [%s]\n", rc, stateName[korg1212->cardState]); | 758 | rc, stateName[korg1212->cardState]); |
777 | #endif | ||
778 | |||
779 | if (rc != K1212_CMDRET_Success) { | 759 | if (rc != K1212_CMDRET_Success) { |
780 | return 1; | 760 | return 1; |
781 | } | 761 | } |
@@ -785,9 +765,8 @@ static int snd_korg1212_TriggerPlay(korg1212_t * korg1212) | |||
785 | /* spinlock already held */ | 765 | /* spinlock already held */ |
786 | static int snd_korg1212_StopPlay(korg1212_t * korg1212) | 766 | static int snd_korg1212_StopPlay(korg1212_t * korg1212) |
787 | { | 767 | { |
788 | #if K1212_DEBUG_LEVEL > 0 | 768 | K1212_DEBUG_PRINTK("K1212_DEBUG: StopPlay [%s] %d\n", |
789 | K1212_DEBUG_PRINTK("K1212_DEBUG: StopPlay [%s] %d\n", stateName[korg1212->cardState], korg1212->playcnt); | 769 | stateName[korg1212->cardState], korg1212->playcnt); |
790 | #endif | ||
791 | 770 | ||
792 | if (--(korg1212->playcnt)) | 771 | if (--(korg1212->playcnt)) |
793 | return 0; | 772 | return 0; |
@@ -815,35 +794,34 @@ static void snd_korg1212_EnableCardInterrupts(korg1212_t * korg1212) | |||
815 | 794 | ||
816 | static int snd_korg1212_SetMonitorMode(korg1212_t *korg1212, MonitorModeSelector mode) | 795 | static int snd_korg1212_SetMonitorMode(korg1212_t *korg1212, MonitorModeSelector mode) |
817 | { | 796 | { |
818 | #if K1212_DEBUG_LEVEL > 0 | 797 | K1212_DEBUG_PRINTK("K1212_DEBUG: SetMonitorMode [%s]\n", |
819 | K1212_DEBUG_PRINTK("K1212_DEBUG: SetMonitorMode [%s]\n", stateName[korg1212->cardState]); | 798 | stateName[korg1212->cardState]); |
820 | #endif | ||
821 | 799 | ||
822 | switch (mode) { | 800 | switch (mode) { |
823 | case K1212_MONMODE_Off: | 801 | case K1212_MONMODE_Off: |
824 | if (korg1212->cardState != K1212_STATE_MONITOR) { | 802 | if (korg1212->cardState != K1212_STATE_MONITOR) |
825 | return 0; | 803 | return 0; |
826 | } else { | 804 | else { |
827 | snd_korg1212_SendStopAndWait(korg1212); | 805 | snd_korg1212_SendStopAndWait(korg1212); |
828 | snd_korg1212_setCardState(korg1212, K1212_STATE_OPEN); | 806 | snd_korg1212_setCardState(korg1212, K1212_STATE_OPEN); |
829 | } | 807 | } |
830 | break; | 808 | break; |
831 | 809 | ||
832 | case K1212_MONMODE_On: | 810 | case K1212_MONMODE_On: |
833 | if (korg1212->cardState != K1212_STATE_OPEN) { | 811 | if (korg1212->cardState != K1212_STATE_OPEN) |
834 | return 0; | 812 | return 0; |
835 | } else { | 813 | else { |
836 | snd_korg1212_setCardState(korg1212, K1212_STATE_MONITOR); | 814 | int rc; |
837 | rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_SelectPlayMode, | 815 | snd_korg1212_setCardState(korg1212, K1212_STATE_MONITOR); |
838 | K1212_MODE_MonitorOn, 0, 0, 0); | 816 | rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_SelectPlayMode, |
839 | if (rc != K1212_CMDRET_Success) { | 817 | K1212_MODE_MonitorOn, 0, 0, 0); |
840 | return 0; | 818 | if (rc != K1212_CMDRET_Success) |
841 | } | 819 | return 0; |
842 | } | 820 | } |
843 | break; | 821 | break; |
844 | 822 | ||
845 | default: | 823 | default: |
846 | return 0; | 824 | return 0; |
847 | } | 825 | } |
848 | 826 | ||
849 | return 1; | 827 | return 1; |
@@ -853,42 +831,42 @@ static int snd_korg1212_SetMonitorMode(korg1212_t *korg1212, MonitorModeSelector | |||
853 | 831 | ||
854 | static inline int snd_korg1212_use_is_exclusive(korg1212_t *korg1212) | 832 | static inline int snd_korg1212_use_is_exclusive(korg1212_t *korg1212) |
855 | { | 833 | { |
856 | int ret = 1; | 834 | if (korg1212->playback_pid != korg1212->capture_pid && |
835 | korg1212->playback_pid >= 0 && korg1212->capture_pid >= 0) | ||
836 | return 0; | ||
857 | 837 | ||
858 | if ((korg1212->playback_pid != korg1212->capture_pid) && | 838 | return 1; |
859 | (korg1212->playback_pid >= 0) && (korg1212->capture_pid >= 0)) { | ||
860 | ret = 0; | ||
861 | } | ||
862 | return ret; | ||
863 | } | 839 | } |
864 | 840 | ||
865 | static int snd_korg1212_SetRate(korg1212_t *korg1212, int rate) | 841 | static int snd_korg1212_SetRate(korg1212_t *korg1212, int rate) |
866 | { | 842 | { |
867 | static ClockSourceIndex s44[] = { K1212_CLKIDX_AdatAt44_1K, | 843 | static ClockSourceIndex s44[] = { |
868 | K1212_CLKIDX_WordAt44_1K, | 844 | K1212_CLKIDX_AdatAt44_1K, |
869 | K1212_CLKIDX_LocalAt44_1K }; | 845 | K1212_CLKIDX_WordAt44_1K, |
846 | K1212_CLKIDX_LocalAt44_1K | ||
847 | }; | ||
870 | static ClockSourceIndex s48[] = { | 848 | static ClockSourceIndex s48[] = { |
871 | K1212_CLKIDX_AdatAt48K, | 849 | K1212_CLKIDX_AdatAt48K, |
872 | K1212_CLKIDX_WordAt48K, | 850 | K1212_CLKIDX_WordAt48K, |
873 | K1212_CLKIDX_LocalAt48K }; | 851 | K1212_CLKIDX_LocalAt48K |
874 | int parm; | 852 | }; |
853 | int parm, rc; | ||
875 | 854 | ||
876 | if (!snd_korg1212_use_is_exclusive (korg1212)) { | 855 | if (!snd_korg1212_use_is_exclusive (korg1212)) |
877 | return -EBUSY; | 856 | return -EBUSY; |
878 | } | ||
879 | 857 | ||
880 | switch(rate) { | 858 | switch(rate) { |
881 | case 44100: | 859 | case 44100: |
882 | parm = s44[korg1212->clkSource]; | 860 | parm = s44[korg1212->clkSource]; |
883 | break; | 861 | break; |
884 | 862 | ||
885 | case 48000: | 863 | case 48000: |
886 | parm = s48[korg1212->clkSource]; | 864 | parm = s48[korg1212->clkSource]; |
887 | break; | 865 | break; |
888 | 866 | ||
889 | default: | 867 | default: |
890 | return -EINVAL; | 868 | return -EINVAL; |
891 | } | 869 | } |
892 | 870 | ||
893 | korg1212->clkSrcRate = parm; | 871 | korg1212->clkSrcRate = parm; |
894 | korg1212->clkRate = rate; | 872 | korg1212->clkRate = rate; |
@@ -898,9 +876,9 @@ static int snd_korg1212_SetRate(korg1212_t *korg1212, int rate) | |||
898 | ClockSourceSelector[korg1212->clkSrcRate], | 876 | ClockSourceSelector[korg1212->clkSrcRate], |
899 | 0, 0, 0); | 877 | 0, 0, 0); |
900 | 878 | ||
901 | #if K1212_DEBUG_LEVEL > 0 | 879 | if (rc) |
902 | if (rc) K1212_DEBUG_PRINTK("K1212_DEBUG: Set Clock Source Selector - RC = %d [%s]\n", rc, stateName[korg1212->cardState]); | 880 | K1212_DEBUG_PRINTK("K1212_DEBUG: Set Clock Source Selector - RC = %d [%s]\n", |
903 | #endif | 881 | rc, stateName[korg1212->cardState]); |
904 | 882 | ||
905 | return 0; | 883 | return 0; |
906 | } | 884 | } |
@@ -908,8 +886,8 @@ static int snd_korg1212_SetRate(korg1212_t *korg1212, int rate) | |||
908 | static int snd_korg1212_SetClockSource(korg1212_t *korg1212, int source) | 886 | static int snd_korg1212_SetClockSource(korg1212_t *korg1212, int source) |
909 | { | 887 | { |
910 | 888 | ||
911 | if (source<0 || source >2) | 889 | if (source < 0 || source > 2) |
912 | return -EINVAL; | 890 | return -EINVAL; |
913 | 891 | ||
914 | korg1212->clkSource = source; | 892 | korg1212->clkSource = source; |
915 | 893 | ||
@@ -935,9 +913,8 @@ static int snd_korg1212_WriteADCSensitivity(korg1212_t *korg1212) | |||
935 | u16 count; | 913 | u16 count; |
936 | unsigned long flags; | 914 | unsigned long flags; |
937 | 915 | ||
938 | #if K1212_DEBUG_LEVEL > 0 | 916 | K1212_DEBUG_PRINTK("K1212_DEBUG: WriteADCSensivity [%s]\n", |
939 | K1212_DEBUG_PRINTK("K1212_DEBUG: WriteADCSensivity [%s]\n", stateName[korg1212->cardState]); | 917 | stateName[korg1212->cardState]); |
940 | #endif | ||
941 | 918 | ||
942 | // ---------------------------------------------------------------------------- | 919 | // ---------------------------------------------------------------------------- |
943 | // initialize things. The local init bit is always set when writing to the | 920 | // initialize things. The local init bit is always set when writing to the |
@@ -1006,19 +983,17 @@ static int snd_korg1212_WriteADCSensitivity(korg1212_t *korg1212) | |||
1006 | udelay(LOADSHIFT_DELAY); | 983 | udelay(LOADSHIFT_DELAY); |
1007 | 984 | ||
1008 | for (bitPosition = 15; bitPosition >= 0; bitPosition--) { // for all the bits | 985 | for (bitPosition = 15; bitPosition >= 0; bitPosition--) { // for all the bits |
1009 | if (channel == 0) { | 986 | if (channel == 0) { |
1010 | if (sensVals.l.leftSensBits & (0x0001 << bitPosition)) { | 987 | if (sensVals.l.leftSensBits & (0x0001 << bitPosition)) |
1011 | SetBitInWord(&controlValue, SET_SENS_DATA_BITPOS); // data bit set high | 988 | SetBitInWord(&controlValue, SET_SENS_DATA_BITPOS); // data bit set high |
1012 | } else { | 989 | else |
1013 | ClearBitInWord(&controlValue, SET_SENS_DATA_BITPOS); // data bit set low | 990 | ClearBitInWord(&controlValue, SET_SENS_DATA_BITPOS); // data bit set low |
1014 | } | 991 | } else { |
1015 | } else { | 992 | if (sensVals.r.rightSensBits & (0x0001 << bitPosition)) |
1016 | if (sensVals.r.rightSensBits & (0x0001 << bitPosition)) { | 993 | SetBitInWord(&controlValue, SET_SENS_DATA_BITPOS); // data bit set high |
1017 | SetBitInWord(&controlValue, SET_SENS_DATA_BITPOS); // data bit set high | 994 | else |
1018 | } else { | 995 | ClearBitInWord(&controlValue, SET_SENS_DATA_BITPOS); // data bit set low |
1019 | ClearBitInWord(&controlValue, SET_SENS_DATA_BITPOS); // data bit set low | 996 | } |
1020 | } | ||
1021 | } | ||
1022 | 997 | ||
1023 | ClearBitInWord(&controlValue, SET_SENS_CLOCK_BITPOS); | 998 | ClearBitInWord(&controlValue, SET_SENS_CLOCK_BITPOS); |
1024 | writew(controlValue, korg1212->sensRegPtr); // clock goes low | 999 | writew(controlValue, korg1212->sensRegPtr); // clock goes low |
@@ -1061,10 +1036,9 @@ static int snd_korg1212_WriteADCSensitivity(korg1212_t *korg1212) | |||
1061 | if (monModeSet) { | 1036 | if (monModeSet) { |
1062 | rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_SelectPlayMode, | 1037 | rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_SelectPlayMode, |
1063 | K1212_MODE_MonitorOn, 0, 0, 0); | 1038 | K1212_MODE_MonitorOn, 0, 0, 0); |
1064 | #if K1212_DEBUG_LEVEL > 0 | 1039 | if (rc) |
1065 | if (rc) K1212_DEBUG_PRINTK("K1212_DEBUG: WriteADCSensivity - RC = %d [%s]\n", rc, stateName[korg1212->cardState]); | 1040 | K1212_DEBUG_PRINTK("K1212_DEBUG: WriteADCSensivity - RC = %d [%s]\n", |
1066 | #endif | 1041 | rc, stateName[korg1212->cardState]); |
1067 | |||
1068 | } | 1042 | } |
1069 | 1043 | ||
1070 | spin_unlock_irqrestore(&korg1212->lock, flags); | 1044 | spin_unlock_irqrestore(&korg1212->lock, flags); |
@@ -1076,19 +1050,18 @@ static void snd_korg1212_OnDSPDownloadComplete(korg1212_t *korg1212) | |||
1076 | { | 1050 | { |
1077 | int channel; | 1051 | int channel; |
1078 | 1052 | ||
1079 | #if K1212_DEBUG_LEVEL > 0 | 1053 | K1212_DEBUG_PRINTK("K1212_DEBUG: DSP download is complete. [%s]\n", |
1080 | K1212_DEBUG_PRINTK("K1212_DEBUG: DSP download is complete. [%s]\n", stateName[korg1212->cardState]); | 1054 | stateName[korg1212->cardState]); |
1081 | #endif | ||
1082 | 1055 | ||
1083 | // ---------------------------------------------------- | 1056 | // ---------------------------------------------------- |
1084 | // tell the card to boot | 1057 | // tell the card to boot |
1085 | // ---------------------------------------------------- | 1058 | // ---------------------------------------------------- |
1086 | rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_BootFromDSPPage4, 0, 0, 0, 0); | 1059 | rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_BootFromDSPPage4, 0, 0, 0, 0); |
1087 | 1060 | ||
1088 | #if K1212_DEBUG_LEVEL > 0 | 1061 | if (rc) |
1089 | if (rc) K1212_DEBUG_PRINTK("K1212_DEBUG: Boot from Page 4 - RC = %d [%s]\n", rc, stateName[korg1212->cardState]); | 1062 | K1212_DEBUG_PRINTK("K1212_DEBUG: Boot from Page 4 - RC = %d [%s]\n", |
1090 | #endif | 1063 | rc, stateName[korg1212->cardState]); |
1091 | mdelay(DSP_BOOT_DELAY_IN_MS); | 1064 | msleep(DSP_BOOT_DELAY_IN_MS); |
1092 | 1065 | ||
1093 | // -------------------------------------------------------------------------------- | 1066 | // -------------------------------------------------------------------------------- |
1094 | // Let the card know where all the buffers are. | 1067 | // Let the card know where all the buffers are. |
@@ -1102,9 +1075,9 @@ static void snd_korg1212_OnDSPDownloadComplete(korg1212_t *korg1212) | |||
1102 | 0 | 1075 | 0 |
1103 | ); | 1076 | ); |
1104 | 1077 | ||
1105 | #if K1212_DEBUG_LEVEL > 0 | 1078 | if (rc) |
1106 | if (rc) K1212_DEBUG_PRINTK("K1212_DEBUG: Configure Buffer Memory - RC = %d [%s]\n", rc, stateName[korg1212->cardState]); | 1079 | K1212_DEBUG_PRINTK("K1212_DEBUG: Configure Buffer Memory - RC = %d [%s]\n", |
1107 | #endif | 1080 | rc, stateName[korg1212->cardState]); |
1108 | 1081 | ||
1109 | udelay(INTERCOMMAND_DELAY); | 1082 | udelay(INTERCOMMAND_DELAY); |
1110 | 1083 | ||
@@ -1116,10 +1089,9 @@ static void snd_korg1212_OnDSPDownloadComplete(korg1212_t *korg1212) | |||
1116 | 0 | 1089 | 0 |
1117 | ); | 1090 | ); |
1118 | 1091 | ||
1119 | #if K1212_DEBUG_LEVEL > 0 | 1092 | if (rc) |
1120 | if (rc) K1212_DEBUG_PRINTK("K1212_DEBUG: Configure Misc Memory - RC = %d [%s]\n", rc, stateName[korg1212->cardState]); | 1093 | K1212_DEBUG_PRINTK("K1212_DEBUG: Configure Misc Memory - RC = %d [%s]\n", |
1121 | #endif | 1094 | rc, stateName[korg1212->cardState]); |
1122 | |||
1123 | 1095 | ||
1124 | // -------------------------------------------------------------------------------- | 1096 | // -------------------------------------------------------------------------------- |
1125 | // Initialize the routing and volume tables, then update the card's state. | 1097 | // Initialize the routing and volume tables, then update the card's state. |
@@ -1138,16 +1110,16 @@ static void snd_korg1212_OnDSPDownloadComplete(korg1212_t *korg1212) | |||
1138 | rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_SetClockSourceRate, | 1110 | rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_SetClockSourceRate, |
1139 | ClockSourceSelector[korg1212->clkSrcRate], | 1111 | ClockSourceSelector[korg1212->clkSrcRate], |
1140 | 0, 0, 0); | 1112 | 0, 0, 0); |
1141 | #if K1212_DEBUG_LEVEL > 0 | 1113 | if (rc) |
1142 | if (rc) K1212_DEBUG_PRINTK("K1212_DEBUG: Set Clock Source Selector - RC = %d [%s]\n", rc, stateName[korg1212->cardState]); | 1114 | K1212_DEBUG_PRINTK("K1212_DEBUG: Set Clock Source Selector - RC = %d [%s]\n", |
1143 | #endif | 1115 | rc, stateName[korg1212->cardState]); |
1144 | 1116 | ||
1145 | snd_korg1212_TurnOnIdleMonitor(korg1212); | 1117 | rc = snd_korg1212_TurnOnIdleMonitor(korg1212); |
1146 | snd_korg1212_setCardState(korg1212, K1212_STATE_READY); | 1118 | snd_korg1212_setCardState(korg1212, K1212_STATE_READY); |
1147 | 1119 | ||
1148 | #if K1212_DEBUG_LEVEL > 0 | 1120 | if (rc) |
1149 | if (rc) K1212_DEBUG_PRINTK("K1212_DEBUG: Set Monitor On - RC = %d [%s]\n", rc, stateName[korg1212->cardState]); | 1121 | K1212_DEBUG_PRINTK("K1212_DEBUG: Set Monitor On - RC = %d [%s]\n", |
1150 | #endif | 1122 | rc, stateName[korg1212->cardState]); |
1151 | 1123 | ||
1152 | snd_korg1212_setCardState(korg1212, K1212_STATE_DSP_COMPLETE); | 1124 | snd_korg1212_setCardState(korg1212, K1212_STATE_DSP_COMPLETE); |
1153 | } | 1125 | } |
@@ -1176,9 +1148,9 @@ static irqreturn_t snd_korg1212_interrupt(int irq, void *dev_id, struct pt_regs | |||
1176 | 1148 | ||
1177 | switch (doorbellValue) { | 1149 | switch (doorbellValue) { |
1178 | case K1212_DB_DSPDownloadDone: | 1150 | case K1212_DB_DSPDownloadDone: |
1179 | #if K1212_DEBUG_LEVEL > 0 | 1151 | K1212_DEBUG_PRINTK("K1212_DEBUG: IRQ DNLD count - %ld, %x, [%s].\n", |
1180 | K1212_DEBUG_PRINTK("K1212_DEBUG: IRQ DNLD count - %ld, %x, [%s].\n", korg1212->irqcount, doorbellValue, stateName[korg1212->cardState]); | 1152 | korg1212->irqcount, doorbellValue, |
1181 | #endif | 1153 | stateName[korg1212->cardState]); |
1182 | if (korg1212->cardState == K1212_STATE_DSP_IN_PROCESS) { | 1154 | if (korg1212->cardState == K1212_STATE_DSP_IN_PROCESS) { |
1183 | korg1212->dsp_is_loaded = 1; | 1155 | korg1212->dsp_is_loaded = 1; |
1184 | wake_up(&korg1212->wait); | 1156 | wake_up(&korg1212->wait); |
@@ -1189,10 +1161,10 @@ static irqreturn_t snd_korg1212_interrupt(int irq, void *dev_id, struct pt_regs | |||
1189 | // an error occurred - stop the card | 1161 | // an error occurred - stop the card |
1190 | // ------------------------------------------------------------------------ | 1162 | // ------------------------------------------------------------------------ |
1191 | case K1212_DB_DMAERROR: | 1163 | case K1212_DB_DMAERROR: |
1192 | #if K1212_DEBUG_LEVEL > 1 | 1164 | K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: IRQ DMAE count - %ld, %x, [%s].\n", |
1193 | K1212_DEBUG_PRINTK("K1212_DEBUG: IRQ DMAE count - %ld, %x, [%s].\n", korg1212->irqcount, doorbellValue, stateName[korg1212->cardState]); | 1165 | korg1212->irqcount, doorbellValue, |
1194 | #endif | 1166 | stateName[korg1212->cardState]); |
1195 | snd_printk(KERN_ERR "korg1212: DMA Error\n"); | 1167 | snd_printk(KERN_ERR "korg1212: DMA Error\n"); |
1196 | korg1212->errorcnt++; | 1168 | korg1212->errorcnt++; |
1197 | korg1212->totalerrorcnt++; | 1169 | korg1212->totalerrorcnt++; |
1198 | korg1212->sharedBufferPtr->cardCommand = 0; | 1170 | korg1212->sharedBufferPtr->cardCommand = 0; |
@@ -1204,17 +1176,17 @@ static irqreturn_t snd_korg1212_interrupt(int irq, void *dev_id, struct pt_regs | |||
1204 | // the semaphore in case someone is waiting for this. | 1176 | // the semaphore in case someone is waiting for this. |
1205 | // ------------------------------------------------------------------------ | 1177 | // ------------------------------------------------------------------------ |
1206 | case K1212_DB_CARDSTOPPED: | 1178 | case K1212_DB_CARDSTOPPED: |
1207 | #if K1212_DEBUG_LEVEL > 1 | 1179 | K1212_DEBUG_PRINTK_VEROBSE("K1212_DEBUG: IRQ CSTP count - %ld, %x, [%s].\n", |
1208 | K1212_DEBUG_PRINTK("K1212_DEBUG: IRQ CSTP count - %ld, %x, [%s].\n", korg1212->irqcount, doorbellValue, stateName[korg1212->cardState]); | 1180 | korg1212->irqcount, doorbellValue, |
1209 | #endif | 1181 | stateName[korg1212->cardState]); |
1210 | korg1212->sharedBufferPtr->cardCommand = 0; | 1182 | korg1212->sharedBufferPtr->cardCommand = 0; |
1211 | break; | 1183 | break; |
1212 | 1184 | ||
1213 | default: | 1185 | default: |
1214 | #if K1212_DEBUG_LEVEL > 3 | 1186 | K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: IRQ DFLT count - %ld, %x, cpos=%d [%s].\n", |
1215 | K1212_DEBUG_PRINTK("K1212_DEBUG: IRQ DFLT count - %ld, %x, cpos=%d [%s].\n", korg1212->irqcount, doorbellValue, | 1187 | korg1212->irqcount, doorbellValue, |
1216 | korg1212->currentBuffer, stateName[korg1212->cardState]); | 1188 | korg1212->currentBuffer, |
1217 | #endif | 1189 | stateName[korg1212->cardState]); |
1218 | if ((korg1212->cardState > K1212_STATE_SETUP) || korg1212->idleMonitorOn) { | 1190 | if ((korg1212->cardState > K1212_STATE_SETUP) || korg1212->idleMonitorOn) { |
1219 | korg1212->currentBuffer++; | 1191 | korg1212->currentBuffer++; |
1220 | 1192 | ||
@@ -1249,16 +1221,14 @@ static irqreturn_t snd_korg1212_interrupt(int irq, void *dev_id, struct pt_regs | |||
1249 | static int snd_korg1212_downloadDSPCode(korg1212_t *korg1212) | 1221 | static int snd_korg1212_downloadDSPCode(korg1212_t *korg1212) |
1250 | { | 1222 | { |
1251 | 1223 | ||
1252 | #if K1212_DEBUG_LEVEL > 0 | 1224 | K1212_DEBUG_PRINTK("K1212_DEBUG: DSP download is starting... [%s]\n", |
1253 | K1212_DEBUG_PRINTK("K1212_DEBUG: DSP download is starting... [%s]\n", stateName[korg1212->cardState]); | 1225 | stateName[korg1212->cardState]); |
1254 | #endif | ||
1255 | 1226 | ||
1256 | // --------------------------------------------------------------- | 1227 | // --------------------------------------------------------------- |
1257 | // verify the state of the card before proceeding. | 1228 | // verify the state of the card before proceeding. |
1258 | // --------------------------------------------------------------- | 1229 | // --------------------------------------------------------------- |
1259 | if (korg1212->cardState >= K1212_STATE_DSP_IN_PROCESS) { | 1230 | if (korg1212->cardState >= K1212_STATE_DSP_IN_PROCESS) |
1260 | return 1; | 1231 | return 1; |
1261 | } | ||
1262 | 1232 | ||
1263 | snd_korg1212_setCardState(korg1212, K1212_STATE_DSP_IN_PROCESS); | 1233 | snd_korg1212_setCardState(korg1212, K1212_STATE_DSP_IN_PROCESS); |
1264 | 1234 | ||
@@ -1267,10 +1237,9 @@ static int snd_korg1212_downloadDSPCode(korg1212_t *korg1212) | |||
1267 | rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_StartDSPDownload, | 1237 | rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_StartDSPDownload, |
1268 | UpperWordSwap(korg1212->dma_dsp.addr), | 1238 | UpperWordSwap(korg1212->dma_dsp.addr), |
1269 | 0, 0, 0); | 1239 | 0, 0, 0); |
1270 | 1240 | if (rc) | |
1271 | #if K1212_DEBUG_LEVEL > 0 | 1241 | K1212_DEBUG_PRINTK("K1212_DEBUG: Start DSP Download RC = %d [%s]\n", |
1272 | if (rc) K1212_DEBUG_PRINTK("K1212_DEBUG: Start DSP Download RC = %d [%s]\n", rc, stateName[korg1212->cardState]); | 1242 | rc, stateName[korg1212->cardState]); |
1273 | #endif | ||
1274 | 1243 | ||
1275 | korg1212->dsp_is_loaded = 0; | 1244 | korg1212->dsp_is_loaded = 0; |
1276 | wait_event_timeout(korg1212->wait, korg1212->dsp_is_loaded, HZ * CARD_BOOT_TIMEOUT); | 1245 | wait_event_timeout(korg1212->wait, korg1212->dsp_is_loaded, HZ * CARD_BOOT_TIMEOUT); |
@@ -1327,16 +1296,16 @@ static int snd_korg1212_silence(korg1212_t *korg1212, int pos, int count, int of | |||
1327 | KorgAudioFrame * dst = korg1212->playDataBufsPtr[0].bufferData + pos; | 1296 | KorgAudioFrame * dst = korg1212->playDataBufsPtr[0].bufferData + pos; |
1328 | int i; | 1297 | int i; |
1329 | 1298 | ||
1330 | #if K1212_DEBUG_LEVEL > 2 | 1299 | K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: snd_korg1212_silence pos=%d offset=%d size=%d count=%d\n", |
1331 | K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_silence pos=%d offset=%d size=%d count=%d\n", pos, offset, size, count); | 1300 | pos, offset, size, count); |
1332 | #endif | ||
1333 | snd_assert(pos + count <= K1212_MAX_SAMPLES, return -EINVAL); | 1301 | snd_assert(pos + count <= K1212_MAX_SAMPLES, return -EINVAL); |
1334 | 1302 | ||
1335 | for (i=0; i < count; i++) { | 1303 | for (i=0; i < count; i++) { |
1336 | #if K1212_DEBUG_LEVEL > 0 | 1304 | #if K1212_DEBUG_LEVEL > 0 |
1337 | if ( (void *) dst < (void *) korg1212->playDataBufsPtr || | 1305 | if ( (void *) dst < (void *) korg1212->playDataBufsPtr || |
1338 | (void *) dst > (void *) korg1212->playDataBufsPtr[8].bufferData ) { | 1306 | (void *) dst > (void *) korg1212->playDataBufsPtr[8].bufferData ) { |
1339 | K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_silence KERNEL EFAULT dst=%p iter=%d\n", dst, i); | 1307 | printk(KERN_DEBUG "K1212_DEBUG: snd_korg1212_silence KERNEL EFAULT dst=%p iter=%d\n", |
1308 | dst, i); | ||
1340 | return -EFAULT; | 1309 | return -EFAULT; |
1341 | } | 1310 | } |
1342 | #endif | 1311 | #endif |
@@ -1352,24 +1321,21 @@ static int snd_korg1212_copy_to(korg1212_t *korg1212, void __user *dst, int pos, | |||
1352 | KorgAudioFrame * src = korg1212->recordDataBufsPtr[0].bufferData + pos; | 1321 | KorgAudioFrame * src = korg1212->recordDataBufsPtr[0].bufferData + pos; |
1353 | int i, rc; | 1322 | int i, rc; |
1354 | 1323 | ||
1355 | #if K1212_DEBUG_LEVEL > 2 | 1324 | K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: snd_korg1212_copy_to pos=%d offset=%d size=%d\n", |
1356 | K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_copy_to pos=%d offset=%d size=%d\n", pos, offset, size); | 1325 | pos, offset, size); |
1357 | #endif | ||
1358 | snd_assert(pos + count <= K1212_MAX_SAMPLES, return -EINVAL); | 1326 | snd_assert(pos + count <= K1212_MAX_SAMPLES, return -EINVAL); |
1359 | 1327 | ||
1360 | for (i=0; i < count; i++) { | 1328 | for (i=0; i < count; i++) { |
1361 | #if K1212_DEBUG_LEVEL > 0 | 1329 | #if K1212_DEBUG_LEVEL > 0 |
1362 | if ( (void *) src < (void *) korg1212->recordDataBufsPtr || | 1330 | if ( (void *) src < (void *) korg1212->recordDataBufsPtr || |
1363 | (void *) src > (void *) korg1212->recordDataBufsPtr[8].bufferData ) { | 1331 | (void *) src > (void *) korg1212->recordDataBufsPtr[8].bufferData ) { |
1364 | K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_copy_to KERNEL EFAULT, src=%p dst=%p iter=%d\n", src, dst, i); | 1332 | printk(KERN_DEBUG "K1212_DEBUG: snd_korg1212_copy_to KERNEL EFAULT, src=%p dst=%p iter=%d\n", src, dst, i); |
1365 | return -EFAULT; | 1333 | return -EFAULT; |
1366 | } | 1334 | } |
1367 | #endif | 1335 | #endif |
1368 | rc = copy_to_user(dst + offset, src, size); | 1336 | rc = copy_to_user(dst + offset, src, size); |
1369 | if (rc) { | 1337 | if (rc) { |
1370 | #if K1212_DEBUG_LEVEL > 0 | ||
1371 | K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_copy_to USER EFAULT src=%p dst=%p iter=%d\n", src, dst, i); | 1338 | K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_copy_to USER EFAULT src=%p dst=%p iter=%d\n", src, dst, i); |
1372 | #endif | ||
1373 | return -EFAULT; | 1339 | return -EFAULT; |
1374 | } | 1340 | } |
1375 | src++; | 1341 | src++; |
@@ -1384,9 +1350,8 @@ static int snd_korg1212_copy_from(korg1212_t *korg1212, void __user *src, int po | |||
1384 | KorgAudioFrame * dst = korg1212->playDataBufsPtr[0].bufferData + pos; | 1350 | KorgAudioFrame * dst = korg1212->playDataBufsPtr[0].bufferData + pos; |
1385 | int i, rc; | 1351 | int i, rc; |
1386 | 1352 | ||
1387 | #if K1212_DEBUG_LEVEL > 2 | 1353 | K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: snd_korg1212_copy_from pos=%d offset=%d size=%d count=%d\n", |
1388 | K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_copy_from pos=%d offset=%d size=%d count=%d\n", pos, offset, size, count); | 1354 | pos, offset, size, count); |
1389 | #endif | ||
1390 | 1355 | ||
1391 | snd_assert(pos + count <= K1212_MAX_SAMPLES, return -EINVAL); | 1356 | snd_assert(pos + count <= K1212_MAX_SAMPLES, return -EINVAL); |
1392 | 1357 | ||
@@ -1394,15 +1359,15 @@ static int snd_korg1212_copy_from(korg1212_t *korg1212, void __user *src, int po | |||
1394 | #if K1212_DEBUG_LEVEL > 0 | 1359 | #if K1212_DEBUG_LEVEL > 0 |
1395 | if ( (void *) dst < (void *) korg1212->playDataBufsPtr || | 1360 | if ( (void *) dst < (void *) korg1212->playDataBufsPtr || |
1396 | (void *) dst > (void *) korg1212->playDataBufsPtr[8].bufferData ) { | 1361 | (void *) dst > (void *) korg1212->playDataBufsPtr[8].bufferData ) { |
1397 | K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_copy_from KERNEL EFAULT, src=%p dst=%p iter=%d\n", src, dst, i); | 1362 | printk(KERN_DEBUG "K1212_DEBUG: snd_korg1212_copy_from KERNEL EFAULT, src=%p dst=%p iter=%d\n", |
1363 | src, dst, i); | ||
1398 | return -EFAULT; | 1364 | return -EFAULT; |
1399 | } | 1365 | } |
1400 | #endif | 1366 | #endif |
1401 | rc = copy_from_user((void*) dst + offset, src, size); | 1367 | rc = copy_from_user((void*) dst + offset, src, size); |
1402 | if (rc) { | 1368 | if (rc) { |
1403 | #if K1212_DEBUG_LEVEL > 0 | 1369 | K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_copy_from USER EFAULT src=%p dst=%p iter=%d\n", |
1404 | K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_copy_from USER EFAULT src=%p dst=%p iter=%d\n", src, dst, i); | 1370 | src, dst, i); |
1405 | #endif | ||
1406 | return -EFAULT; | 1371 | return -EFAULT; |
1407 | } | 1372 | } |
1408 | dst++; | 1373 | dst++; |
@@ -1416,9 +1381,8 @@ static void snd_korg1212_free_pcm(snd_pcm_t *pcm) | |||
1416 | { | 1381 | { |
1417 | korg1212_t *korg1212 = (korg1212_t *) pcm->private_data; | 1382 | korg1212_t *korg1212 = (korg1212_t *) pcm->private_data; |
1418 | 1383 | ||
1419 | #if K1212_DEBUG_LEVEL > 0 | 1384 | K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_free_pcm [%s]\n", |
1420 | K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_free_pcm [%s]\n", stateName[korg1212->cardState]); | 1385 | stateName[korg1212->cardState]); |
1421 | #endif | ||
1422 | 1386 | ||
1423 | korg1212->pcm = NULL; | 1387 | korg1212->pcm = NULL; |
1424 | } | 1388 | } |
@@ -1429,9 +1393,8 @@ static int snd_korg1212_playback_open(snd_pcm_substream_t *substream) | |||
1429 | korg1212_t *korg1212 = snd_pcm_substream_chip(substream); | 1393 | korg1212_t *korg1212 = snd_pcm_substream_chip(substream); |
1430 | snd_pcm_runtime_t *runtime = substream->runtime; | 1394 | snd_pcm_runtime_t *runtime = substream->runtime; |
1431 | 1395 | ||
1432 | #if K1212_DEBUG_LEVEL > 0 | 1396 | K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_playback_open [%s]\n", |
1433 | K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_playback_open [%s]\n", stateName[korg1212->cardState]); | 1397 | stateName[korg1212->cardState]); |
1434 | #endif | ||
1435 | 1398 | ||
1436 | snd_pcm_set_sync(substream); // ??? | 1399 | snd_pcm_set_sync(substream); // ??? |
1437 | 1400 | ||
@@ -1461,9 +1424,8 @@ static int snd_korg1212_capture_open(snd_pcm_substream_t *substream) | |||
1461 | korg1212_t *korg1212 = snd_pcm_substream_chip(substream); | 1424 | korg1212_t *korg1212 = snd_pcm_substream_chip(substream); |
1462 | snd_pcm_runtime_t *runtime = substream->runtime; | 1425 | snd_pcm_runtime_t *runtime = substream->runtime; |
1463 | 1426 | ||
1464 | #if K1212_DEBUG_LEVEL > 0 | 1427 | K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_capture_open [%s]\n", |
1465 | K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_capture_open [%s]\n", stateName[korg1212->cardState]); | 1428 | stateName[korg1212->cardState]); |
1466 | #endif | ||
1467 | 1429 | ||
1468 | snd_pcm_set_sync(substream); | 1430 | snd_pcm_set_sync(substream); |
1469 | 1431 | ||
@@ -1490,9 +1452,8 @@ static int snd_korg1212_playback_close(snd_pcm_substream_t *substream) | |||
1490 | unsigned long flags; | 1452 | unsigned long flags; |
1491 | korg1212_t *korg1212 = snd_pcm_substream_chip(substream); | 1453 | korg1212_t *korg1212 = snd_pcm_substream_chip(substream); |
1492 | 1454 | ||
1493 | #if K1212_DEBUG_LEVEL > 0 | 1455 | K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_playback_close [%s]\n", |
1494 | K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_playback_close [%s]\n", stateName[korg1212->cardState]); | 1456 | stateName[korg1212->cardState]); |
1495 | #endif | ||
1496 | 1457 | ||
1497 | snd_korg1212_silence(korg1212, 0, K1212_MAX_SAMPLES, 0, korg1212->channels * 2); | 1458 | snd_korg1212_silence(korg1212, 0, K1212_MAX_SAMPLES, 0, korg1212->channels * 2); |
1498 | 1459 | ||
@@ -1513,9 +1474,8 @@ static int snd_korg1212_capture_close(snd_pcm_substream_t *substream) | |||
1513 | unsigned long flags; | 1474 | unsigned long flags; |
1514 | korg1212_t *korg1212 = snd_pcm_substream_chip(substream); | 1475 | korg1212_t *korg1212 = snd_pcm_substream_chip(substream); |
1515 | 1476 | ||
1516 | #if K1212_DEBUG_LEVEL > 0 | 1477 | K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_capture_close [%s]\n", |
1517 | K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_capture_close [%s]\n", stateName[korg1212->cardState]); | 1478 | stateName[korg1212->cardState]); |
1518 | #endif | ||
1519 | 1479 | ||
1520 | spin_lock_irqsave(&korg1212->lock, flags); | 1480 | spin_lock_irqsave(&korg1212->lock, flags); |
1521 | 1481 | ||
@@ -1532,18 +1492,14 @@ static int snd_korg1212_capture_close(snd_pcm_substream_t *substream) | |||
1532 | static int snd_korg1212_ioctl(snd_pcm_substream_t *substream, | 1492 | static int snd_korg1212_ioctl(snd_pcm_substream_t *substream, |
1533 | unsigned int cmd, void *arg) | 1493 | unsigned int cmd, void *arg) |
1534 | { | 1494 | { |
1535 | #if K1212_DEBUG_LEVEL > 0 | 1495 | K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_ioctl: cmd=%d\n", cmd); |
1536 | K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_ioctl: cmd=%d\n", cmd); | ||
1537 | #endif | ||
1538 | 1496 | ||
1539 | if (cmd == SNDRV_PCM_IOCTL1_CHANNEL_INFO ) { | 1497 | if (cmd == SNDRV_PCM_IOCTL1_CHANNEL_INFO ) { |
1540 | snd_pcm_channel_info_t *info = arg; | 1498 | snd_pcm_channel_info_t *info = arg; |
1541 | info->offset = 0; | 1499 | info->offset = 0; |
1542 | info->first = info->channel * 16; | 1500 | info->first = info->channel * 16; |
1543 | info->step = 256; | 1501 | info->step = 256; |
1544 | #if K1212_DEBUG_LEVEL > 0 | ||
1545 | K1212_DEBUG_PRINTK("K1212_DEBUG: channel_info %d:, offset=%ld, first=%d, step=%d\n", info->channel, info->offset, info->first, info->step); | 1502 | K1212_DEBUG_PRINTK("K1212_DEBUG: channel_info %d:, offset=%ld, first=%d, step=%d\n", info->channel, info->offset, info->first, info->step); |
1546 | #endif | ||
1547 | return 0; | 1503 | return 0; |
1548 | } | 1504 | } |
1549 | 1505 | ||
@@ -1559,9 +1515,8 @@ static int snd_korg1212_hw_params(snd_pcm_substream_t *substream, | |||
1559 | pid_t this_pid; | 1515 | pid_t this_pid; |
1560 | pid_t other_pid; | 1516 | pid_t other_pid; |
1561 | 1517 | ||
1562 | #if K1212_DEBUG_LEVEL > 0 | 1518 | K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_hw_params [%s]\n", |
1563 | K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_hw_params [%s]\n", stateName[korg1212->cardState]); | 1519 | stateName[korg1212->cardState]); |
1564 | #endif | ||
1565 | 1520 | ||
1566 | spin_lock_irqsave(&korg1212->lock, flags); | 1521 | spin_lock_irqsave(&korg1212->lock, flags); |
1567 | 1522 | ||
@@ -1608,17 +1563,15 @@ static int snd_korg1212_prepare(snd_pcm_substream_t *substream) | |||
1608 | korg1212_t *korg1212 = snd_pcm_substream_chip(substream); | 1563 | korg1212_t *korg1212 = snd_pcm_substream_chip(substream); |
1609 | int rc; | 1564 | int rc; |
1610 | 1565 | ||
1611 | #if K1212_DEBUG_LEVEL > 0 | 1566 | K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_prepare [%s]\n", |
1612 | K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_prepare [%s]\n", stateName[korg1212->cardState]); | 1567 | stateName[korg1212->cardState]); |
1613 | #endif | ||
1614 | 1568 | ||
1615 | spin_lock_irq(&korg1212->lock); | 1569 | spin_lock_irq(&korg1212->lock); |
1616 | 1570 | ||
1617 | /* FIXME: we should wait for ack! */ | 1571 | /* FIXME: we should wait for ack! */ |
1618 | if (korg1212->stop_pending_cnt > 0) { | 1572 | if (korg1212->stop_pending_cnt > 0) { |
1619 | #if K1212_DEBUG_LEVEL > 0 | 1573 | K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_prepare - Stop is pending... [%s]\n", |
1620 | K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_prepare - Stop is pending... [%s]\n", stateName[korg1212->cardState]); | 1574 | stateName[korg1212->cardState]); |
1621 | #endif | ||
1622 | spin_unlock_irq(&korg1212->lock); | 1575 | spin_unlock_irq(&korg1212->lock); |
1623 | return -EAGAIN; | 1576 | return -EAGAIN; |
1624 | /* | 1577 | /* |
@@ -1643,18 +1596,15 @@ static int snd_korg1212_trigger(snd_pcm_substream_t *substream, | |||
1643 | korg1212_t *korg1212 = snd_pcm_substream_chip(substream); | 1596 | korg1212_t *korg1212 = snd_pcm_substream_chip(substream); |
1644 | int rc; | 1597 | int rc; |
1645 | 1598 | ||
1646 | #if K1212_DEBUG_LEVEL > 0 | 1599 | K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_trigger [%s] cmd=%d\n", |
1647 | K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_trigger [%s] cmd=%d\n", stateName[korg1212->cardState], cmd); | 1600 | stateName[korg1212->cardState], cmd); |
1648 | #endif | ||
1649 | 1601 | ||
1650 | spin_lock(&korg1212->lock); | 1602 | spin_lock(&korg1212->lock); |
1651 | switch (cmd) { | 1603 | switch (cmd) { |
1652 | case SNDRV_PCM_TRIGGER_START: | 1604 | case SNDRV_PCM_TRIGGER_START: |
1653 | /* | 1605 | /* |
1654 | if (korg1212->running) { | 1606 | if (korg1212->running) { |
1655 | #if K1212_DEBUG_LEVEL > 1 | 1607 | K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: snd_korg1212_trigger: Already running?\n"); |
1656 | K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_trigger: Already running?\n"); | ||
1657 | #endif | ||
1658 | break; | 1608 | break; |
1659 | } | 1609 | } |
1660 | */ | 1610 | */ |
@@ -1665,9 +1615,7 @@ static int snd_korg1212_trigger(snd_pcm_substream_t *substream, | |||
1665 | case SNDRV_PCM_TRIGGER_STOP: | 1615 | case SNDRV_PCM_TRIGGER_STOP: |
1666 | /* | 1616 | /* |
1667 | if (!korg1212->running) { | 1617 | if (!korg1212->running) { |
1668 | #if K1212_DEBUG_LEVEL > 1 | 1618 | K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: snd_korg1212_trigger: Already stopped?\n"); |
1669 | K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_trigger: Already stopped?\n"); | ||
1670 | #endif | ||
1671 | break; | 1619 | break; |
1672 | } | 1620 | } |
1673 | */ | 1621 | */ |
@@ -1690,10 +1638,8 @@ static snd_pcm_uframes_t snd_korg1212_playback_pointer(snd_pcm_substream_t *subs | |||
1690 | 1638 | ||
1691 | pos = korg1212->currentBuffer * kPlayBufferFrames; | 1639 | pos = korg1212->currentBuffer * kPlayBufferFrames; |
1692 | 1640 | ||
1693 | #if K1212_DEBUG_LEVEL > 2 | 1641 | K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: snd_korg1212_playback_pointer [%s] %ld\n", |
1694 | K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_playback_pointer [%s] %ld\n", | 1642 | stateName[korg1212->cardState], pos); |
1695 | stateName[korg1212->cardState], pos); | ||
1696 | #endif | ||
1697 | 1643 | ||
1698 | return pos; | 1644 | return pos; |
1699 | } | 1645 | } |
@@ -1705,10 +1651,8 @@ static snd_pcm_uframes_t snd_korg1212_capture_pointer(snd_pcm_substream_t *subst | |||
1705 | 1651 | ||
1706 | pos = korg1212->currentBuffer * kPlayBufferFrames; | 1652 | pos = korg1212->currentBuffer * kPlayBufferFrames; |
1707 | 1653 | ||
1708 | #if K1212_DEBUG_LEVEL > 2 | 1654 | K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: snd_korg1212_capture_pointer [%s] %ld\n", |
1709 | K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_capture_pointer [%s] %ld\n", | 1655 | stateName[korg1212->cardState], pos); |
1710 | stateName[korg1212->cardState], pos); | ||
1711 | #endif | ||
1712 | 1656 | ||
1713 | return pos; | 1657 | return pos; |
1714 | } | 1658 | } |
@@ -1721,9 +1665,8 @@ static int snd_korg1212_playback_copy(snd_pcm_substream_t *substream, | |||
1721 | { | 1665 | { |
1722 | korg1212_t *korg1212 = snd_pcm_substream_chip(substream); | 1666 | korg1212_t *korg1212 = snd_pcm_substream_chip(substream); |
1723 | 1667 | ||
1724 | #if K1212_DEBUG_LEVEL > 2 | 1668 | K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: snd_korg1212_playback_copy [%s] %ld %ld\n", |
1725 | K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_playback_copy [%s] %ld %ld\n", stateName[korg1212->cardState], pos, count); | 1669 | stateName[korg1212->cardState], pos, count); |
1726 | #endif | ||
1727 | 1670 | ||
1728 | return snd_korg1212_copy_from(korg1212, src, pos, count, 0, korg1212->channels * 2); | 1671 | return snd_korg1212_copy_from(korg1212, src, pos, count, 0, korg1212->channels * 2); |
1729 | 1672 | ||
@@ -1736,9 +1679,8 @@ static int snd_korg1212_playback_silence(snd_pcm_substream_t *substream, | |||
1736 | { | 1679 | { |
1737 | korg1212_t *korg1212 = snd_pcm_substream_chip(substream); | 1680 | korg1212_t *korg1212 = snd_pcm_substream_chip(substream); |
1738 | 1681 | ||
1739 | #if K1212_DEBUG_LEVEL > 0 | 1682 | K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: snd_korg1212_playback_silence [%s]\n", |
1740 | K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_playback_silence [%s]\n", stateName[korg1212->cardState]); | 1683 | stateName[korg1212->cardState]); |
1741 | #endif | ||
1742 | 1684 | ||
1743 | return snd_korg1212_silence(korg1212, pos, count, 0, korg1212->channels * 2); | 1685 | return snd_korg1212_silence(korg1212, pos, count, 0, korg1212->channels * 2); |
1744 | } | 1686 | } |
@@ -1751,9 +1693,8 @@ static int snd_korg1212_capture_copy(snd_pcm_substream_t *substream, | |||
1751 | { | 1693 | { |
1752 | korg1212_t *korg1212 = snd_pcm_substream_chip(substream); | 1694 | korg1212_t *korg1212 = snd_pcm_substream_chip(substream); |
1753 | 1695 | ||
1754 | #if K1212_DEBUG_LEVEL > 2 | 1696 | K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: snd_korg1212_capture_copy [%s] %ld %ld\n", |
1755 | K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_capture_copy [%s] %ld %ld\n", stateName[korg1212->cardState], pos, count); | 1697 | stateName[korg1212->cardState], pos, count); |
1756 | #endif | ||
1757 | 1698 | ||
1758 | return snd_korg1212_copy_to(korg1212, dst, pos, count, 0, korg1212->channels * 2); | 1699 | return snd_korg1212_copy_to(korg1212, dst, pos, count, 0, korg1212->channels * 2); |
1759 | } | 1700 | } |
@@ -2145,7 +2086,7 @@ snd_korg1212_free(korg1212_t *korg1212) | |||
2145 | if (korg1212->irq >= 0) { | 2086 | if (korg1212->irq >= 0) { |
2146 | synchronize_irq(korg1212->irq); | 2087 | synchronize_irq(korg1212->irq); |
2147 | snd_korg1212_DisableCardInterrupts(korg1212); | 2088 | snd_korg1212_DisableCardInterrupts(korg1212); |
2148 | free_irq(korg1212->irq, (void *)korg1212); | 2089 | free_irq(korg1212->irq, korg1212); |
2149 | korg1212->irq = -1; | 2090 | korg1212->irq = -1; |
2150 | } | 2091 | } |
2151 | 2092 | ||
@@ -2197,9 +2138,7 @@ snd_korg1212_free(korg1212_t *korg1212) | |||
2197 | static int snd_korg1212_dev_free(snd_device_t *device) | 2138 | static int snd_korg1212_dev_free(snd_device_t *device) |
2198 | { | 2139 | { |
2199 | korg1212_t *korg1212 = device->device_data; | 2140 | korg1212_t *korg1212 = device->device_data; |
2200 | #if K1212_DEBUG_LEVEL > 0 | ||
2201 | K1212_DEBUG_PRINTK("K1212_DEBUG: Freeing device\n"); | 2141 | K1212_DEBUG_PRINTK("K1212_DEBUG: Freeing device\n"); |
2202 | #endif | ||
2203 | return snd_korg1212_free(korg1212); | 2142 | return snd_korg1212_free(korg1212); |
2204 | } | 2143 | } |
2205 | 2144 | ||
@@ -2207,7 +2146,7 @@ static int __devinit snd_korg1212_create(snd_card_t * card, struct pci_dev *pci, | |||
2207 | korg1212_t ** rchip) | 2146 | korg1212_t ** rchip) |
2208 | 2147 | ||
2209 | { | 2148 | { |
2210 | int err; | 2149 | int err, rc; |
2211 | unsigned int i; | 2150 | unsigned int i; |
2212 | unsigned ioport_size, iomem_size, iomem2_size; | 2151 | unsigned ioport_size, iomem_size, iomem2_size; |
2213 | korg1212_t * korg1212; | 2152 | korg1212_t * korg1212; |
@@ -2270,7 +2209,6 @@ static int __devinit snd_korg1212_create(snd_card_t * card, struct pci_dev *pci, | |||
2270 | ioport_size = pci_resource_len(korg1212->pci, 1); | 2209 | ioport_size = pci_resource_len(korg1212->pci, 1); |
2271 | iomem2_size = pci_resource_len(korg1212->pci, 2); | 2210 | iomem2_size = pci_resource_len(korg1212->pci, 2); |
2272 | 2211 | ||
2273 | #if K1212_DEBUG_LEVEL > 0 | ||
2274 | K1212_DEBUG_PRINTK("K1212_DEBUG: resources:\n" | 2212 | K1212_DEBUG_PRINTK("K1212_DEBUG: resources:\n" |
2275 | " iomem = 0x%lx (%d)\n" | 2213 | " iomem = 0x%lx (%d)\n" |
2276 | " ioport = 0x%lx (%d)\n" | 2214 | " ioport = 0x%lx (%d)\n" |
@@ -2280,7 +2218,6 @@ static int __devinit snd_korg1212_create(snd_card_t * card, struct pci_dev *pci, | |||
2280 | korg1212->ioport, ioport_size, | 2218 | korg1212->ioport, ioport_size, |
2281 | korg1212->iomem2, iomem2_size, | 2219 | korg1212->iomem2, iomem2_size, |
2282 | stateName[korg1212->cardState]); | 2220 | stateName[korg1212->cardState]); |
2283 | #endif | ||
2284 | 2221 | ||
2285 | if ((korg1212->iobase = ioremap(korg1212->iomem, iomem_size)) == NULL) { | 2222 | if ((korg1212->iobase = ioremap(korg1212->iomem, iomem_size)) == NULL) { |
2286 | snd_printk(KERN_ERR "korg1212: unable to remap memory region 0x%lx-0x%lx\n", korg1212->iomem, | 2223 | snd_printk(KERN_ERR "korg1212: unable to remap memory region 0x%lx-0x%lx\n", korg1212->iomem, |
@@ -2291,7 +2228,7 @@ static int __devinit snd_korg1212_create(snd_card_t * card, struct pci_dev *pci, | |||
2291 | 2228 | ||
2292 | err = request_irq(pci->irq, snd_korg1212_interrupt, | 2229 | err = request_irq(pci->irq, snd_korg1212_interrupt, |
2293 | SA_INTERRUPT|SA_SHIRQ, | 2230 | SA_INTERRUPT|SA_SHIRQ, |
2294 | "korg1212", (void *) korg1212); | 2231 | "korg1212", korg1212); |
2295 | 2232 | ||
2296 | if (err) { | 2233 | if (err) { |
2297 | snd_printk(KERN_ERR "korg1212: unable to grab IRQ %d\n", pci->irq); | 2234 | snd_printk(KERN_ERR "korg1212: unable to grab IRQ %d\n", pci->irq); |
@@ -2314,7 +2251,6 @@ static int __devinit snd_korg1212_create(snd_card_t * card, struct pci_dev *pci, | |||
2314 | korg1212->sensRegPtr = (u16 __iomem *) (korg1212->iobase + SENS_CONTROL_OFFSET); | 2251 | korg1212->sensRegPtr = (u16 __iomem *) (korg1212->iobase + SENS_CONTROL_OFFSET); |
2315 | korg1212->idRegPtr = (u32 __iomem *) (korg1212->iobase + DEV_VEND_ID_OFFSET); | 2252 | korg1212->idRegPtr = (u32 __iomem *) (korg1212->iobase + DEV_VEND_ID_OFFSET); |
2316 | 2253 | ||
2317 | #if K1212_DEBUG_LEVEL > 0 | ||
2318 | K1212_DEBUG_PRINTK("K1212_DEBUG: card registers:\n" | 2254 | K1212_DEBUG_PRINTK("K1212_DEBUG: card registers:\n" |
2319 | " Status register = 0x%p\n" | 2255 | " Status register = 0x%p\n" |
2320 | " OutDoorbell = 0x%p\n" | 2256 | " OutDoorbell = 0x%p\n" |
@@ -2338,7 +2274,6 @@ static int __devinit snd_korg1212_create(snd_card_t * card, struct pci_dev *pci, | |||
2338 | korg1212->sensRegPtr, | 2274 | korg1212->sensRegPtr, |
2339 | korg1212->idRegPtr, | 2275 | korg1212->idRegPtr, |
2340 | stateName[korg1212->cardState]); | 2276 | stateName[korg1212->cardState]); |
2341 | #endif | ||
2342 | 2277 | ||
2343 | if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci), | 2278 | if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci), |
2344 | sizeof(KorgSharedBuffer), &korg1212->dma_shared) < 0) { | 2279 | sizeof(KorgSharedBuffer), &korg1212->dma_shared) < 0) { |
@@ -2349,9 +2284,7 @@ static int __devinit snd_korg1212_create(snd_card_t * card, struct pci_dev *pci, | |||
2349 | korg1212->sharedBufferPtr = (KorgSharedBuffer *)korg1212->dma_shared.area; | 2284 | korg1212->sharedBufferPtr = (KorgSharedBuffer *)korg1212->dma_shared.area; |
2350 | korg1212->sharedBufferPhy = korg1212->dma_shared.addr; | 2285 | korg1212->sharedBufferPhy = korg1212->dma_shared.addr; |
2351 | 2286 | ||
2352 | #if K1212_DEBUG_LEVEL > 0 | ||
2353 | K1212_DEBUG_PRINTK("K1212_DEBUG: Shared Buffer Area = 0x%p (0x%08lx), %d bytes\n", korg1212->sharedBufferPtr, korg1212->sharedBufferPhy, sizeof(KorgSharedBuffer)); | 2287 | K1212_DEBUG_PRINTK("K1212_DEBUG: Shared Buffer Area = 0x%p (0x%08lx), %d bytes\n", korg1212->sharedBufferPtr, korg1212->sharedBufferPhy, sizeof(KorgSharedBuffer)); |
2354 | #endif | ||
2355 | 2288 | ||
2356 | #ifndef K1212_LARGEALLOC | 2289 | #ifndef K1212_LARGEALLOC |
2357 | 2290 | ||
@@ -2366,10 +2299,8 @@ static int __devinit snd_korg1212_create(snd_card_t * card, struct pci_dev *pci, | |||
2366 | korg1212->playDataBufsPtr = (KorgAudioBuffer *)korg1212->dma_play.area; | 2299 | korg1212->playDataBufsPtr = (KorgAudioBuffer *)korg1212->dma_play.area; |
2367 | korg1212->PlayDataPhy = korg1212->dma_play.addr; | 2300 | korg1212->PlayDataPhy = korg1212->dma_play.addr; |
2368 | 2301 | ||
2369 | #if K1212_DEBUG_LEVEL > 0 | ||
2370 | K1212_DEBUG_PRINTK("K1212_DEBUG: Play Data Area = 0x%p (0x%08x), %d bytes\n", | 2302 | K1212_DEBUG_PRINTK("K1212_DEBUG: Play Data Area = 0x%p (0x%08x), %d bytes\n", |
2371 | korg1212->playDataBufsPtr, korg1212->PlayDataPhy, korg1212->DataBufsSize); | 2303 | korg1212->playDataBufsPtr, korg1212->PlayDataPhy, korg1212->DataBufsSize); |
2372 | #endif | ||
2373 | 2304 | ||
2374 | if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci), | 2305 | if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci), |
2375 | korg1212->DataBufsSize, &korg1212->dma_rec) < 0) { | 2306 | korg1212->DataBufsSize, &korg1212->dma_rec) < 0) { |
@@ -2380,10 +2311,8 @@ static int __devinit snd_korg1212_create(snd_card_t * card, struct pci_dev *pci, | |||
2380 | korg1212->recordDataBufsPtr = (KorgAudioBuffer *)korg1212->dma_rec.area; | 2311 | korg1212->recordDataBufsPtr = (KorgAudioBuffer *)korg1212->dma_rec.area; |
2381 | korg1212->RecDataPhy = korg1212->dma_rec.addr; | 2312 | korg1212->RecDataPhy = korg1212->dma_rec.addr; |
2382 | 2313 | ||
2383 | #if K1212_DEBUG_LEVEL > 0 | ||
2384 | K1212_DEBUG_PRINTK("K1212_DEBUG: Record Data Area = 0x%p (0x%08x), %d bytes\n", | 2314 | K1212_DEBUG_PRINTK("K1212_DEBUG: Record Data Area = 0x%p (0x%08x), %d bytes\n", |
2385 | korg1212->recordDataBufsPtr, korg1212->RecDataPhy, korg1212->DataBufsSize); | 2315 | korg1212->recordDataBufsPtr, korg1212->RecDataPhy, korg1212->DataBufsSize); |
2386 | #endif | ||
2387 | 2316 | ||
2388 | #else // K1212_LARGEALLOC | 2317 | #else // K1212_LARGEALLOC |
2389 | 2318 | ||
@@ -2410,17 +2339,14 @@ static int __devinit snd_korg1212_create(snd_card_t * card, struct pci_dev *pci, | |||
2410 | return -ENOMEM; | 2339 | return -ENOMEM; |
2411 | } | 2340 | } |
2412 | 2341 | ||
2413 | #if K1212_DEBUG_LEVEL > 0 | ||
2414 | K1212_DEBUG_PRINTK("K1212_DEBUG: DSP Code area = 0x%p (0x%08x) %d bytes [%s]\n", | 2342 | K1212_DEBUG_PRINTK("K1212_DEBUG: DSP Code area = 0x%p (0x%08x) %d bytes [%s]\n", |
2415 | korg1212->dma_dsp.area, korg1212->dma_dsp.addr, korg1212->dspCodeSize, | 2343 | korg1212->dma_dsp.area, korg1212->dma_dsp.addr, korg1212->dspCodeSize, |
2416 | stateName[korg1212->cardState]); | 2344 | stateName[korg1212->cardState]); |
2417 | #endif | ||
2418 | 2345 | ||
2419 | rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_RebootCard, 0, 0, 0, 0); | 2346 | rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_RebootCard, 0, 0, 0, 0); |
2420 | 2347 | ||
2421 | #if K1212_DEBUG_LEVEL > 0 | 2348 | if (rc) |
2422 | if (rc) K1212_DEBUG_PRINTK("K1212_DEBUG: Reboot Card - RC = %d [%s]\n", rc, stateName[korg1212->cardState]); | 2349 | K1212_DEBUG_PRINTK("K1212_DEBUG: Reboot Card - RC = %d [%s]\n", rc, stateName[korg1212->cardState]); |
2423 | #endif | ||
2424 | 2350 | ||
2425 | if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, korg1212, &ops)) < 0) { | 2351 | if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, korg1212, &ops)) < 0) { |
2426 | snd_korg1212_free(korg1212); | 2352 | snd_korg1212_free(korg1212); |
@@ -2434,8 +2360,7 @@ static int __devinit snd_korg1212_create(snd_card_t * card, struct pci_dev *pci, | |||
2434 | if (snd_korg1212_downloadDSPCode(korg1212)) | 2360 | if (snd_korg1212_downloadDSPCode(korg1212)) |
2435 | return -EBUSY; | 2361 | return -EBUSY; |
2436 | 2362 | ||
2437 | snd_printk(KERN_ERR | 2363 | K1212_DEBUG_PRINTK("korg1212: dspMemPhy = %08x U[%08x], " |
2438 | "korg1212: dspMemPhy = %08x U[%08x], " | ||
2439 | "PlayDataPhy = %08x L[%08x]\n" | 2364 | "PlayDataPhy = %08x L[%08x]\n" |
2440 | "korg1212: RecDataPhy = %08x L[%08x], " | 2365 | "korg1212: RecDataPhy = %08x L[%08x], " |
2441 | "VolumeTablePhy = %08x L[%08x]\n" | 2366 | "VolumeTablePhy = %08x L[%08x]\n" |
@@ -2461,9 +2386,6 @@ static int __devinit snd_korg1212_create(snd_card_t * card, struct pci_dev *pci, | |||
2461 | 2386 | ||
2462 | korg1212->pcm->info_flags = SNDRV_PCM_INFO_JOINT_DUPLEX; | 2387 | korg1212->pcm->info_flags = SNDRV_PCM_INFO_JOINT_DUPLEX; |
2463 | 2388 | ||
2464 | //snd_pcm_lib_preallocate_pages_for_all(korg1212->pcm, | ||
2465 | // K1212_MAX_BUF_SIZE, K1212_MAX_BUF_SIZE, GFP_KERNEL); | ||
2466 | |||
2467 | for (i = 0; i < ARRAY_SIZE(snd_korg1212_controls); i++) { | 2389 | for (i = 0; i < ARRAY_SIZE(snd_korg1212_controls); i++) { |
2468 | err = snd_ctl_add(korg1212->card, snd_ctl_new1(&snd_korg1212_controls[i], korg1212)); | 2390 | err = snd_ctl_add(korg1212->card, snd_ctl_new1(&snd_korg1212_controls[i], korg1212)); |
2469 | if (err < 0) | 2391 | if (err < 0) |
@@ -2513,9 +2435,7 @@ snd_korg1212_probe(struct pci_dev *pci, | |||
2513 | sprintf(card->longname, "%s at 0x%lx, irq %d", card->shortname, | 2435 | sprintf(card->longname, "%s at 0x%lx, irq %d", card->shortname, |
2514 | korg1212->iomem, korg1212->irq); | 2436 | korg1212->iomem, korg1212->irq); |
2515 | 2437 | ||
2516 | #if K1212_DEBUG_LEVEL > 0 | ||
2517 | K1212_DEBUG_PRINTK("K1212_DEBUG: %s\n", card->longname); | 2438 | K1212_DEBUG_PRINTK("K1212_DEBUG: %s\n", card->longname); |
2518 | #endif | ||
2519 | 2439 | ||
2520 | if ((err = snd_card_register(card)) < 0) { | 2440 | if ((err = snd_card_register(card)) < 0) { |
2521 | snd_card_free(card); | 2441 | snd_card_free(card); |