aboutsummaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2009-03-23 19:36:10 -0400
committerTakashi Iwai <tiwai@suse.de>2009-03-23 19:36:10 -0400
commit593aff6c506ba0399a80720d4c5d7e80d8854f9a (patch)
tree17edc11da6e2f2c0b7889270fb3ecdb3b12de651 /sound
parente7bfbb0215ee9b2fc976f7f51e20a8ae02b1d839 (diff)
parentc2503cd3be9eacb1dd06ec5b6fba8bb06aac12a8 (diff)
Merge branch 'topic/hdsp' into for-linus
Diffstat (limited to 'sound')
-rw-r--r--sound/pci/rme9652/hdsp.c506
1 files changed, 265 insertions, 241 deletions
diff --git a/sound/pci/rme9652/hdsp.c b/sound/pci/rme9652/hdsp.c
index bacfdd12619b..314e73531bd1 100644
--- a/sound/pci/rme9652/hdsp.c
+++ b/sound/pci/rme9652/hdsp.c
@@ -113,7 +113,7 @@ MODULE_FIRMWARE("digiface_firmware_rev11.bin");
113 113
114/* the meters are regular i/o-mapped registers, but offset 114/* the meters are regular i/o-mapped registers, but offset
115 considerably from the rest. the peak registers are reset 115 considerably from the rest. the peak registers are reset
116 when read; the least-significant 4 bits are full-scale counters; 116 when read; the least-significant 4 bits are full-scale counters;
117 the actual peak value is in the most-significant 24 bits. 117 the actual peak value is in the most-significant 24 bits.
118*/ 118*/
119 119
@@ -131,7 +131,7 @@ MODULE_FIRMWARE("digiface_firmware_rev11.bin");
131 26*3 values are read in ss mode 131 26*3 values are read in ss mode
132 14*3 in ds mode, with no gap between values 132 14*3 in ds mode, with no gap between values
133*/ 133*/
134#define HDSP_9652_peakBase 7164 134#define HDSP_9652_peakBase 7164
135#define HDSP_9652_rmsBase 4096 135#define HDSP_9652_rmsBase 4096
136 136
137/* c.f. the hdsp_9632_meters_t struct */ 137/* c.f. the hdsp_9632_meters_t struct */
@@ -173,12 +173,12 @@ MODULE_FIRMWARE("digiface_firmware_rev11.bin");
173#define HDSP_SPDIFEmphasis (1<<10) /* 0=none, 1=on */ 173#define HDSP_SPDIFEmphasis (1<<10) /* 0=none, 1=on */
174#define HDSP_SPDIFNonAudio (1<<11) /* 0=off, 1=on */ 174#define HDSP_SPDIFNonAudio (1<<11) /* 0=off, 1=on */
175#define HDSP_SPDIFOpticalOut (1<<12) /* 1=use 1st ADAT connector for SPDIF, 0=do not */ 175#define HDSP_SPDIFOpticalOut (1<<12) /* 1=use 1st ADAT connector for SPDIF, 0=do not */
176#define HDSP_SyncRef2 (1<<13) 176#define HDSP_SyncRef2 (1<<13)
177#define HDSP_SPDIFInputSelect0 (1<<14) 177#define HDSP_SPDIFInputSelect0 (1<<14)
178#define HDSP_SPDIFInputSelect1 (1<<15) 178#define HDSP_SPDIFInputSelect1 (1<<15)
179#define HDSP_SyncRef0 (1<<16) 179#define HDSP_SyncRef0 (1<<16)
180#define HDSP_SyncRef1 (1<<17) 180#define HDSP_SyncRef1 (1<<17)
181#define HDSP_AnalogExtensionBoard (1<<18) /* For H9632 cards */ 181#define HDSP_AnalogExtensionBoard (1<<18) /* For H9632 cards */
182#define HDSP_XLRBreakoutCable (1<<20) /* For H9632 cards */ 182#define HDSP_XLRBreakoutCable (1<<20) /* For H9632 cards */
183#define HDSP_Midi0InterruptEnable (1<<22) 183#define HDSP_Midi0InterruptEnable (1<<22)
184#define HDSP_Midi1InterruptEnable (1<<23) 184#define HDSP_Midi1InterruptEnable (1<<23)
@@ -314,7 +314,7 @@ MODULE_FIRMWARE("digiface_firmware_rev11.bin");
314#define HDSP_TimecodeSync (1<<27) 314#define HDSP_TimecodeSync (1<<27)
315#define HDSP_AEBO (1<<28) /* H9632 specific Analog Extension Boards */ 315#define HDSP_AEBO (1<<28) /* H9632 specific Analog Extension Boards */
316#define HDSP_AEBI (1<<29) /* 0 = present, 1 = absent */ 316#define HDSP_AEBI (1<<29) /* 0 = present, 1 = absent */
317#define HDSP_midi0IRQPending (1<<30) 317#define HDSP_midi0IRQPending (1<<30)
318#define HDSP_midi1IRQPending (1<<31) 318#define HDSP_midi1IRQPending (1<<31)
319 319
320#define HDSP_spdifFrequencyMask (HDSP_spdifFrequency0|HDSP_spdifFrequency1|HDSP_spdifFrequency2) 320#define HDSP_spdifFrequencyMask (HDSP_spdifFrequency0|HDSP_spdifFrequency1|HDSP_spdifFrequency2)
@@ -391,7 +391,7 @@ MODULE_FIRMWARE("digiface_firmware_rev11.bin");
391#define HDSP_CHANNEL_BUFFER_BYTES (4*HDSP_CHANNEL_BUFFER_SAMPLES) 391#define HDSP_CHANNEL_BUFFER_BYTES (4*HDSP_CHANNEL_BUFFER_SAMPLES)
392 392
393/* the size of the area we need to allocate for DMA transfers. the 393/* the size of the area we need to allocate for DMA transfers. the
394 size is the same regardless of the number of channels - the 394 size is the same regardless of the number of channels - the
395 Multiface still uses the same memory area. 395 Multiface still uses the same memory area.
396 396
397 Note that we allocate 1 more channel than is apparently needed 397 Note that we allocate 1 more channel than is apparently needed
@@ -460,7 +460,7 @@ struct hdsp {
460 unsigned char qs_in_channels; /* quad speed mode for H9632 */ 460 unsigned char qs_in_channels; /* quad speed mode for H9632 */
461 unsigned char ds_in_channels; 461 unsigned char ds_in_channels;
462 unsigned char ss_in_channels; /* different for multiface/digiface */ 462 unsigned char ss_in_channels; /* different for multiface/digiface */
463 unsigned char qs_out_channels; 463 unsigned char qs_out_channels;
464 unsigned char ds_out_channels; 464 unsigned char ds_out_channels;
465 unsigned char ss_out_channels; 465 unsigned char ss_out_channels;
466 466
@@ -502,9 +502,9 @@ static char channel_map_df_ss[HDSP_MAX_CHANNELS] = {
502 502
503static char channel_map_mf_ss[HDSP_MAX_CHANNELS] = { /* Multiface */ 503static char channel_map_mf_ss[HDSP_MAX_CHANNELS] = { /* Multiface */
504 /* Analog */ 504 /* Analog */
505 0, 1, 2, 3, 4, 5, 6, 7, 505 0, 1, 2, 3, 4, 5, 6, 7,
506 /* ADAT 2 */ 506 /* ADAT 2 */
507 16, 17, 18, 19, 20, 21, 22, 23, 507 16, 17, 18, 19, 20, 21, 22, 23,
508 /* SPDIF */ 508 /* SPDIF */
509 24, 25, 509 24, 25,
510 -1, -1, -1, -1, -1, -1, -1, -1 510 -1, -1, -1, -1, -1, -1, -1, -1
@@ -525,11 +525,11 @@ static char channel_map_H9632_ss[HDSP_MAX_CHANNELS] = {
525 /* SPDIF */ 525 /* SPDIF */
526 8, 9, 526 8, 9,
527 /* Analog */ 527 /* Analog */
528 10, 11, 528 10, 11,
529 /* AO4S-192 and AI4S-192 extension boards */ 529 /* AO4S-192 and AI4S-192 extension boards */
530 12, 13, 14, 15, 530 12, 13, 14, 15,
531 /* others don't exist */ 531 /* others don't exist */
532 -1, -1, -1, -1, -1, -1, -1, -1, 532 -1, -1, -1, -1, -1, -1, -1, -1,
533 -1, -1 533 -1, -1
534}; 534};
535 535
@@ -539,7 +539,7 @@ static char channel_map_H9632_ds[HDSP_MAX_CHANNELS] = {
539 /* SPDIF */ 539 /* SPDIF */
540 8, 9, 540 8, 9,
541 /* Analog */ 541 /* Analog */
542 10, 11, 542 10, 11,
543 /* AO4S-192 and AI4S-192 extension boards */ 543 /* AO4S-192 and AI4S-192 extension boards */
544 12, 13, 14, 15, 544 12, 13, 14, 15,
545 /* others don't exist */ 545 /* others don't exist */
@@ -587,7 +587,7 @@ static void snd_hammerfall_free_buffer(struct snd_dma_buffer *dmab, struct pci_d
587static struct pci_device_id snd_hdsp_ids[] = { 587static struct pci_device_id snd_hdsp_ids[] = {
588 { 588 {
589 .vendor = PCI_VENDOR_ID_XILINX, 589 .vendor = PCI_VENDOR_ID_XILINX,
590 .device = PCI_DEVICE_ID_XILINX_HAMMERFALL_DSP, 590 .device = PCI_DEVICE_ID_XILINX_HAMMERFALL_DSP,
591 .subvendor = PCI_ANY_ID, 591 .subvendor = PCI_ANY_ID,
592 .subdevice = PCI_ANY_ID, 592 .subdevice = PCI_ANY_ID,
593 }, /* RME Hammerfall-DSP */ 593 }, /* RME Hammerfall-DSP */
@@ -653,7 +653,6 @@ static unsigned int hdsp_read(struct hdsp *hdsp, int reg)
653 653
654static int hdsp_check_for_iobox (struct hdsp *hdsp) 654static int hdsp_check_for_iobox (struct hdsp *hdsp)
655{ 655{
656
657 if (hdsp->io_type == H9652 || hdsp->io_type == H9632) return 0; 656 if (hdsp->io_type == H9652 || hdsp->io_type == H9632) return 0;
658 if (hdsp_read (hdsp, HDSP_statusRegister) & HDSP_ConfigError) { 657 if (hdsp_read (hdsp, HDSP_statusRegister) & HDSP_ConfigError) {
659 snd_printk ("Hammerfall-DSP: no Digiface or Multiface connected!\n"); 658 snd_printk ("Hammerfall-DSP: no Digiface or Multiface connected!\n");
@@ -661,7 +660,29 @@ static int hdsp_check_for_iobox (struct hdsp *hdsp)
661 return -EIO; 660 return -EIO;
662 } 661 }
663 return 0; 662 return 0;
663}
664
665static int hdsp_wait_for_iobox(struct hdsp *hdsp, unsigned int loops,
666 unsigned int delay)
667{
668 unsigned int i;
669
670 if (hdsp->io_type == H9652 || hdsp->io_type == H9632)
671 return 0;
664 672
673 for (i = 0; i != loops; ++i) {
674 if (hdsp_read(hdsp, HDSP_statusRegister) & HDSP_ConfigError)
675 msleep(delay);
676 else {
677 snd_printd("Hammerfall-DSP: iobox found after %ums!\n",
678 i * delay);
679 return 0;
680 }
681 }
682
683 snd_printk("Hammerfall-DSP: no Digiface or Multiface connected!\n");
684 hdsp->state &= ~HDSP_FirmwareLoaded;
685 return -EIO;
665} 686}
666 687
667static int snd_hdsp_load_firmware_from_cache(struct hdsp *hdsp) { 688static int snd_hdsp_load_firmware_from_cache(struct hdsp *hdsp) {
@@ -670,19 +691,19 @@ static int snd_hdsp_load_firmware_from_cache(struct hdsp *hdsp) {
670 unsigned long flags; 691 unsigned long flags;
671 692
672 if ((hdsp_read (hdsp, HDSP_statusRegister) & HDSP_DllError) != 0) { 693 if ((hdsp_read (hdsp, HDSP_statusRegister) & HDSP_DllError) != 0) {
673 694
674 snd_printk ("Hammerfall-DSP: loading firmware\n"); 695 snd_printk ("Hammerfall-DSP: loading firmware\n");
675 696
676 hdsp_write (hdsp, HDSP_control2Reg, HDSP_S_PROGRAM); 697 hdsp_write (hdsp, HDSP_control2Reg, HDSP_S_PROGRAM);
677 hdsp_write (hdsp, HDSP_fifoData, 0); 698 hdsp_write (hdsp, HDSP_fifoData, 0);
678 699
679 if (hdsp_fifo_wait (hdsp, 0, HDSP_LONG_WAIT)) { 700 if (hdsp_fifo_wait (hdsp, 0, HDSP_LONG_WAIT)) {
680 snd_printk ("Hammerfall-DSP: timeout waiting for download preparation\n"); 701 snd_printk ("Hammerfall-DSP: timeout waiting for download preparation\n");
681 return -EIO; 702 return -EIO;
682 } 703 }
683 704
684 hdsp_write (hdsp, HDSP_control2Reg, HDSP_S_LOAD); 705 hdsp_write (hdsp, HDSP_control2Reg, HDSP_S_LOAD);
685 706
686 for (i = 0; i < 24413; ++i) { 707 for (i = 0; i < 24413; ++i) {
687 hdsp_write(hdsp, HDSP_fifoData, hdsp->firmware_cache[i]); 708 hdsp_write(hdsp, HDSP_fifoData, hdsp->firmware_cache[i]);
688 if (hdsp_fifo_wait (hdsp, 127, HDSP_LONG_WAIT)) { 709 if (hdsp_fifo_wait (hdsp, 127, HDSP_LONG_WAIT)) {
@@ -692,7 +713,7 @@ static int snd_hdsp_load_firmware_from_cache(struct hdsp *hdsp) {
692 } 713 }
693 714
694 ssleep(3); 715 ssleep(3);
695 716
696 if (hdsp_fifo_wait (hdsp, 0, HDSP_LONG_WAIT)) { 717 if (hdsp_fifo_wait (hdsp, 0, HDSP_LONG_WAIT)) {
697 snd_printk ("Hammerfall-DSP: timeout at end of firmware loading\n"); 718 snd_printk ("Hammerfall-DSP: timeout at end of firmware loading\n");
698 return -EIO; 719 return -EIO;
@@ -705,15 +726,15 @@ static int snd_hdsp_load_firmware_from_cache(struct hdsp *hdsp) {
705#endif 726#endif
706 hdsp_write (hdsp, HDSP_control2Reg, hdsp->control2_register); 727 hdsp_write (hdsp, HDSP_control2Reg, hdsp->control2_register);
707 snd_printk ("Hammerfall-DSP: finished firmware loading\n"); 728 snd_printk ("Hammerfall-DSP: finished firmware loading\n");
708 729
709 } 730 }
710 if (hdsp->state & HDSP_InitializationComplete) { 731 if (hdsp->state & HDSP_InitializationComplete) {
711 snd_printk(KERN_INFO "Hammerfall-DSP: firmware loaded from cache, restoring defaults\n"); 732 snd_printk(KERN_INFO "Hammerfall-DSP: firmware loaded from cache, restoring defaults\n");
712 spin_lock_irqsave(&hdsp->lock, flags); 733 spin_lock_irqsave(&hdsp->lock, flags);
713 snd_hdsp_set_defaults(hdsp); 734 snd_hdsp_set_defaults(hdsp);
714 spin_unlock_irqrestore(&hdsp->lock, flags); 735 spin_unlock_irqrestore(&hdsp->lock, flags);
715 } 736 }
716 737
717 hdsp->state |= HDSP_FirmwareLoaded; 738 hdsp->state |= HDSP_FirmwareLoaded;
718 739
719 return 0; 740 return 0;
@@ -722,7 +743,7 @@ static int snd_hdsp_load_firmware_from_cache(struct hdsp *hdsp) {
722static int hdsp_get_iobox_version (struct hdsp *hdsp) 743static int hdsp_get_iobox_version (struct hdsp *hdsp)
723{ 744{
724 if ((hdsp_read (hdsp, HDSP_statusRegister) & HDSP_DllError) != 0) { 745 if ((hdsp_read (hdsp, HDSP_statusRegister) & HDSP_DllError) != 0) {
725 746
726 hdsp_write (hdsp, HDSP_control2Reg, HDSP_PROGRAM); 747 hdsp_write (hdsp, HDSP_control2Reg, HDSP_PROGRAM);
727 hdsp_write (hdsp, HDSP_fifoData, 0); 748 hdsp_write (hdsp, HDSP_fifoData, 0);
728 if (hdsp_fifo_wait (hdsp, 0, HDSP_SHORT_WAIT) < 0) 749 if (hdsp_fifo_wait (hdsp, 0, HDSP_SHORT_WAIT) < 0)
@@ -738,7 +759,7 @@ static int hdsp_get_iobox_version (struct hdsp *hdsp)
738 hdsp_fifo_wait (hdsp, 0, HDSP_SHORT_WAIT); 759 hdsp_fifo_wait (hdsp, 0, HDSP_SHORT_WAIT);
739 } else { 760 } else {
740 hdsp->io_type = Digiface; 761 hdsp->io_type = Digiface;
741 } 762 }
742 } else { 763 } else {
743 /* firmware was already loaded, get iobox type */ 764 /* firmware was already loaded, get iobox type */
744 if (hdsp_read(hdsp, HDSP_status2Register) & HDSP_version1) 765 if (hdsp_read(hdsp, HDSP_status2Register) & HDSP_version1)
@@ -786,13 +807,13 @@ static int hdsp_check_for_firmware (struct hdsp *hdsp, int load_on_demand)
786 807
787 808
788static int hdsp_fifo_wait(struct hdsp *hdsp, int count, int timeout) 809static int hdsp_fifo_wait(struct hdsp *hdsp, int count, int timeout)
789{ 810{
790 int i; 811 int i;
791 812
792 /* the fifoStatus registers reports on how many words 813 /* the fifoStatus registers reports on how many words
793 are available in the command FIFO. 814 are available in the command FIFO.
794 */ 815 */
795 816
796 for (i = 0; i < timeout; i++) { 817 for (i = 0; i < timeout; i++) {
797 818
798 if ((int)(hdsp_read (hdsp, HDSP_fifoStatus) & 0xff) <= count) 819 if ((int)(hdsp_read (hdsp, HDSP_fifoStatus) & 0xff) <= count)
@@ -824,11 +845,11 @@ static int hdsp_write_gain(struct hdsp *hdsp, unsigned int addr, unsigned short
824 845
825 if (addr >= HDSP_MATRIX_MIXER_SIZE) 846 if (addr >= HDSP_MATRIX_MIXER_SIZE)
826 return -1; 847 return -1;
827 848
828 if (hdsp->io_type == H9652 || hdsp->io_type == H9632) { 849 if (hdsp->io_type == H9652 || hdsp->io_type == H9632) {
829 850
830 /* from martin bjornsen: 851 /* from martin bjornsen:
831 852
832 "You can only write dwords to the 853 "You can only write dwords to the
833 mixer memory which contain two 854 mixer memory which contain two
834 mixer values in the low and high 855 mixer values in the low and high
@@ -847,7 +868,7 @@ static int hdsp_write_gain(struct hdsp *hdsp, unsigned int addr, unsigned short
847 868
848 hdsp->mixer_matrix[addr] = data; 869 hdsp->mixer_matrix[addr] = data;
849 870
850 871
851 /* `addr' addresses a 16-bit wide address, but 872 /* `addr' addresses a 16-bit wide address, but
852 the address space accessed via hdsp_write 873 the address space accessed via hdsp_write
853 uses byte offsets. put another way, addr 874 uses byte offsets. put another way, addr
@@ -856,17 +877,17 @@ static int hdsp_write_gain(struct hdsp *hdsp, unsigned int addr, unsigned short
856 to access 0 to 2703 ... 877 to access 0 to 2703 ...
857 */ 878 */
858 ad = addr/2; 879 ad = addr/2;
859 880
860 hdsp_write (hdsp, 4096 + (ad*4), 881 hdsp_write (hdsp, 4096 + (ad*4),
861 (hdsp->mixer_matrix[(addr&0x7fe)+1] << 16) + 882 (hdsp->mixer_matrix[(addr&0x7fe)+1] << 16) +
862 hdsp->mixer_matrix[addr&0x7fe]); 883 hdsp->mixer_matrix[addr&0x7fe]);
863 884
864 return 0; 885 return 0;
865 886
866 } else { 887 } else {
867 888
868 ad = (addr << 16) + data; 889 ad = (addr << 16) + data;
869 890
870 if (hdsp_fifo_wait(hdsp, 127, HDSP_LONG_WAIT)) 891 if (hdsp_fifo_wait(hdsp, 127, HDSP_LONG_WAIT))
871 return -1; 892 return -1;
872 893
@@ -902,7 +923,7 @@ static int hdsp_spdif_sample_rate(struct hdsp *hdsp)
902 923
903 if (status & HDSP_SPDIFErrorFlag) 924 if (status & HDSP_SPDIFErrorFlag)
904 return 0; 925 return 0;
905 926
906 switch (rate_bits) { 927 switch (rate_bits) {
907 case HDSP_spdifFrequency32KHz: return 32000; 928 case HDSP_spdifFrequency32KHz: return 32000;
908 case HDSP_spdifFrequency44_1KHz: return 44100; 929 case HDSP_spdifFrequency44_1KHz: return 44100;
@@ -910,13 +931,13 @@ static int hdsp_spdif_sample_rate(struct hdsp *hdsp)
910 case HDSP_spdifFrequency64KHz: return 64000; 931 case HDSP_spdifFrequency64KHz: return 64000;
911 case HDSP_spdifFrequency88_2KHz: return 88200; 932 case HDSP_spdifFrequency88_2KHz: return 88200;
912 case HDSP_spdifFrequency96KHz: return 96000; 933 case HDSP_spdifFrequency96KHz: return 96000;
913 case HDSP_spdifFrequency128KHz: 934 case HDSP_spdifFrequency128KHz:
914 if (hdsp->io_type == H9632) return 128000; 935 if (hdsp->io_type == H9632) return 128000;
915 break; 936 break;
916 case HDSP_spdifFrequency176_4KHz: 937 case HDSP_spdifFrequency176_4KHz:
917 if (hdsp->io_type == H9632) return 176400; 938 if (hdsp->io_type == H9632) return 176400;
918 break; 939 break;
919 case HDSP_spdifFrequency192KHz: 940 case HDSP_spdifFrequency192KHz:
920 if (hdsp->io_type == H9632) return 192000; 941 if (hdsp->io_type == H9632) return 192000;
921 break; 942 break;
922 default: 943 default:
@@ -1027,7 +1048,7 @@ static void hdsp_set_dds_value(struct hdsp *hdsp, int rate)
1027{ 1048{
1028 u64 n; 1049 u64 n;
1029 u32 r; 1050 u32 r;
1030 1051
1031 if (rate >= 112000) 1052 if (rate >= 112000)
1032 rate /= 4; 1053 rate /= 4;
1033 else if (rate >= 56000) 1054 else if (rate >= 56000)
@@ -1053,35 +1074,35 @@ static int hdsp_set_rate(struct hdsp *hdsp, int rate, int called_internally)
1053 there is no need for it (e.g. during module 1074 there is no need for it (e.g. during module
1054 initialization). 1075 initialization).
1055 */ 1076 */
1056 1077
1057 if (!(hdsp->control_register & HDSP_ClockModeMaster)) { 1078 if (!(hdsp->control_register & HDSP_ClockModeMaster)) {
1058 if (called_internally) { 1079 if (called_internally) {
1059 /* request from ctl or card initialization */ 1080 /* request from ctl or card initialization */
1060 snd_printk(KERN_ERR "Hammerfall-DSP: device is not running as a clock master: cannot set sample rate.\n"); 1081 snd_printk(KERN_ERR "Hammerfall-DSP: device is not running as a clock master: cannot set sample rate.\n");
1061 return -1; 1082 return -1;
1062 } else { 1083 } else {
1063 /* hw_param request while in AutoSync mode */ 1084 /* hw_param request while in AutoSync mode */
1064 int external_freq = hdsp_external_sample_rate(hdsp); 1085 int external_freq = hdsp_external_sample_rate(hdsp);
1065 int spdif_freq = hdsp_spdif_sample_rate(hdsp); 1086 int spdif_freq = hdsp_spdif_sample_rate(hdsp);
1066 1087
1067 if ((spdif_freq == external_freq*2) && (hdsp_autosync_ref(hdsp) >= HDSP_AUTOSYNC_FROM_ADAT1)) 1088 if ((spdif_freq == external_freq*2) && (hdsp_autosync_ref(hdsp) >= HDSP_AUTOSYNC_FROM_ADAT1))
1068 snd_printk(KERN_INFO "Hammerfall-DSP: Detected ADAT in double speed mode\n"); 1089 snd_printk(KERN_INFO "Hammerfall-DSP: Detected ADAT in double speed mode\n");
1069 else if (hdsp->io_type == H9632 && (spdif_freq == external_freq*4) && (hdsp_autosync_ref(hdsp) >= HDSP_AUTOSYNC_FROM_ADAT1)) 1090 else if (hdsp->io_type == H9632 && (spdif_freq == external_freq*4) && (hdsp_autosync_ref(hdsp) >= HDSP_AUTOSYNC_FROM_ADAT1))
1070 snd_printk(KERN_INFO "Hammerfall-DSP: Detected ADAT in quad speed mode\n"); 1091 snd_printk(KERN_INFO "Hammerfall-DSP: Detected ADAT in quad speed mode\n");
1071 else if (rate != external_freq) { 1092 else if (rate != external_freq) {
1072 snd_printk(KERN_INFO "Hammerfall-DSP: No AutoSync source for requested rate\n"); 1093 snd_printk(KERN_INFO "Hammerfall-DSP: No AutoSync source for requested rate\n");
1073 return -1; 1094 return -1;
1074 } 1095 }
1075 } 1096 }
1076 } 1097 }
1077 1098
1078 current_rate = hdsp->system_sample_rate; 1099 current_rate = hdsp->system_sample_rate;
1079 1100
1080 /* Changing from a "single speed" to a "double speed" rate is 1101 /* Changing from a "single speed" to a "double speed" rate is
1081 not allowed if any substreams are open. This is because 1102 not allowed if any substreams are open. This is because
1082 such a change causes a shift in the location of 1103 such a change causes a shift in the location of
1083 the DMA buffers and a reduction in the number of available 1104 the DMA buffers and a reduction in the number of available
1084 buffers. 1105 buffers.
1085 1106
1086 Note that a similar but essentially insoluble problem 1107 Note that a similar but essentially insoluble problem
1087 exists for externally-driven rate changes. All we can do 1108 exists for externally-driven rate changes. All we can do
@@ -1089,7 +1110,7 @@ static int hdsp_set_rate(struct hdsp *hdsp, int rate, int called_internally)
1089 1110
1090 if (rate > 96000 && hdsp->io_type != H9632) 1111 if (rate > 96000 && hdsp->io_type != H9632)
1091 return -EINVAL; 1112 return -EINVAL;
1092 1113
1093 switch (rate) { 1114 switch (rate) {
1094 case 32000: 1115 case 32000:
1095 if (current_rate > 48000) 1116 if (current_rate > 48000)
@@ -1179,7 +1200,7 @@ static int hdsp_set_rate(struct hdsp *hdsp, int rate, int called_internally)
1179 break; 1200 break;
1180 } 1201 }
1181 } 1202 }
1182 1203
1183 hdsp->system_sample_rate = rate; 1204 hdsp->system_sample_rate = rate;
1184 1205
1185 return 0; 1206 return 0;
@@ -1245,16 +1266,16 @@ static int snd_hdsp_midi_output_write (struct hdsp_midi *hmidi)
1245 unsigned char buf[128]; 1266 unsigned char buf[128];
1246 1267
1247 /* Output is not interrupt driven */ 1268 /* Output is not interrupt driven */
1248 1269
1249 spin_lock_irqsave (&hmidi->lock, flags); 1270 spin_lock_irqsave (&hmidi->lock, flags);
1250 if (hmidi->output) { 1271 if (hmidi->output) {
1251 if (!snd_rawmidi_transmit_empty (hmidi->output)) { 1272 if (!snd_rawmidi_transmit_empty (hmidi->output)) {
1252 if ((n_pending = snd_hdsp_midi_output_possible (hmidi->hdsp, hmidi->id)) > 0) { 1273 if ((n_pending = snd_hdsp_midi_output_possible (hmidi->hdsp, hmidi->id)) > 0) {
1253 if (n_pending > (int)sizeof (buf)) 1274 if (n_pending > (int)sizeof (buf))
1254 n_pending = sizeof (buf); 1275 n_pending = sizeof (buf);
1255 1276
1256 if ((to_write = snd_rawmidi_transmit (hmidi->output, buf, n_pending)) > 0) { 1277 if ((to_write = snd_rawmidi_transmit (hmidi->output, buf, n_pending)) > 0) {
1257 for (i = 0; i < to_write; ++i) 1278 for (i = 0; i < to_write; ++i)
1258 snd_hdsp_midi_write_byte (hmidi->hdsp, hmidi->id, buf[i]); 1279 snd_hdsp_midi_write_byte (hmidi->hdsp, hmidi->id, buf[i]);
1259 } 1280 }
1260 } 1281 }
@@ -1325,14 +1346,14 @@ static void snd_hdsp_midi_output_timer(unsigned long data)
1325{ 1346{
1326 struct hdsp_midi *hmidi = (struct hdsp_midi *) data; 1347 struct hdsp_midi *hmidi = (struct hdsp_midi *) data;
1327 unsigned long flags; 1348 unsigned long flags;
1328 1349
1329 snd_hdsp_midi_output_write(hmidi); 1350 snd_hdsp_midi_output_write(hmidi);
1330 spin_lock_irqsave (&hmidi->lock, flags); 1351 spin_lock_irqsave (&hmidi->lock, flags);
1331 1352
1332 /* this does not bump hmidi->istimer, because the 1353 /* this does not bump hmidi->istimer, because the
1333 kernel automatically removed the timer when it 1354 kernel automatically removed the timer when it
1334 expired, and we are now adding it back, thus 1355 expired, and we are now adding it back, thus
1335 leaving istimer wherever it was set before. 1356 leaving istimer wherever it was set before.
1336 */ 1357 */
1337 1358
1338 if (hmidi->istimer) { 1359 if (hmidi->istimer) {
@@ -1501,7 +1522,7 @@ static int snd_hdsp_control_spdif_info(struct snd_kcontrol *kcontrol, struct snd
1501static int snd_hdsp_control_spdif_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 1522static int snd_hdsp_control_spdif_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1502{ 1523{
1503 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); 1524 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
1504 1525
1505 snd_hdsp_convert_to_aes(&ucontrol->value.iec958, hdsp->creg_spdif); 1526 snd_hdsp_convert_to_aes(&ucontrol->value.iec958, hdsp->creg_spdif);
1506 return 0; 1527 return 0;
1507} 1528}
@@ -1511,7 +1532,7 @@ static int snd_hdsp_control_spdif_put(struct snd_kcontrol *kcontrol, struct snd_
1511 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); 1532 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
1512 int change; 1533 int change;
1513 u32 val; 1534 u32 val;
1514 1535
1515 val = snd_hdsp_convert_from_aes(&ucontrol->value.iec958); 1536 val = snd_hdsp_convert_from_aes(&ucontrol->value.iec958);
1516 spin_lock_irq(&hdsp->lock); 1537 spin_lock_irq(&hdsp->lock);
1517 change = val != hdsp->creg_spdif; 1538 change = val != hdsp->creg_spdif;
@@ -1530,7 +1551,7 @@ static int snd_hdsp_control_spdif_stream_info(struct snd_kcontrol *kcontrol, str
1530static int snd_hdsp_control_spdif_stream_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 1551static int snd_hdsp_control_spdif_stream_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1531{ 1552{
1532 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); 1553 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
1533 1554
1534 snd_hdsp_convert_to_aes(&ucontrol->value.iec958, hdsp->creg_spdif_stream); 1555 snd_hdsp_convert_to_aes(&ucontrol->value.iec958, hdsp->creg_spdif_stream);
1535 return 0; 1556 return 0;
1536} 1557}
@@ -1540,7 +1561,7 @@ static int snd_hdsp_control_spdif_stream_put(struct snd_kcontrol *kcontrol, stru
1540 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); 1561 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
1541 int change; 1562 int change;
1542 u32 val; 1563 u32 val;
1543 1564
1544 val = snd_hdsp_convert_from_aes(&ucontrol->value.iec958); 1565 val = snd_hdsp_convert_from_aes(&ucontrol->value.iec958);
1545 spin_lock_irq(&hdsp->lock); 1566 spin_lock_irq(&hdsp->lock);
1546 change = val != hdsp->creg_spdif_stream; 1567 change = val != hdsp->creg_spdif_stream;
@@ -1602,7 +1623,7 @@ static int snd_hdsp_info_spdif_in(struct snd_kcontrol *kcontrol, struct snd_ctl_
1602static int snd_hdsp_get_spdif_in(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 1623static int snd_hdsp_get_spdif_in(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1603{ 1624{
1604 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); 1625 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
1605 1626
1606 ucontrol->value.enumerated.item[0] = hdsp_spdif_in(hdsp); 1627 ucontrol->value.enumerated.item[0] = hdsp_spdif_in(hdsp);
1607 return 0; 1628 return 0;
1608} 1629}
@@ -1612,7 +1633,7 @@ static int snd_hdsp_put_spdif_in(struct snd_kcontrol *kcontrol, struct snd_ctl_e
1612 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); 1633 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
1613 int change; 1634 int change;
1614 unsigned int val; 1635 unsigned int val;
1615 1636
1616 if (!snd_hdsp_use_is_exclusive(hdsp)) 1637 if (!snd_hdsp_use_is_exclusive(hdsp))
1617 return -EBUSY; 1638 return -EBUSY;
1618 val = ucontrol->value.enumerated.item[0] % ((hdsp->io_type == H9632) ? 4 : 3); 1639 val = ucontrol->value.enumerated.item[0] % ((hdsp->io_type == H9632) ? 4 : 3);
@@ -1649,7 +1670,7 @@ static int hdsp_set_spdif_output(struct hdsp *hdsp, int out)
1649static int snd_hdsp_get_spdif_out(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 1670static int snd_hdsp_get_spdif_out(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1650{ 1671{
1651 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); 1672 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
1652 1673
1653 ucontrol->value.integer.value[0] = hdsp_spdif_out(hdsp); 1674 ucontrol->value.integer.value[0] = hdsp_spdif_out(hdsp);
1654 return 0; 1675 return 0;
1655} 1676}
@@ -1659,7 +1680,7 @@ static int snd_hdsp_put_spdif_out(struct snd_kcontrol *kcontrol, struct snd_ctl_
1659 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); 1680 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
1660 int change; 1681 int change;
1661 unsigned int val; 1682 unsigned int val;
1662 1683
1663 if (!snd_hdsp_use_is_exclusive(hdsp)) 1684 if (!snd_hdsp_use_is_exclusive(hdsp))
1664 return -EBUSY; 1685 return -EBUSY;
1665 val = ucontrol->value.integer.value[0] & 1; 1686 val = ucontrol->value.integer.value[0] & 1;
@@ -1693,7 +1714,7 @@ static int hdsp_set_spdif_professional(struct hdsp *hdsp, int val)
1693static int snd_hdsp_get_spdif_professional(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 1714static int snd_hdsp_get_spdif_professional(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1694{ 1715{
1695 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); 1716 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
1696 1717
1697 ucontrol->value.integer.value[0] = hdsp_spdif_professional(hdsp); 1718 ucontrol->value.integer.value[0] = hdsp_spdif_professional(hdsp);
1698 return 0; 1719 return 0;
1699} 1720}
@@ -1703,7 +1724,7 @@ static int snd_hdsp_put_spdif_professional(struct snd_kcontrol *kcontrol, struct
1703 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); 1724 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
1704 int change; 1725 int change;
1705 unsigned int val; 1726 unsigned int val;
1706 1727
1707 if (!snd_hdsp_use_is_exclusive(hdsp)) 1728 if (!snd_hdsp_use_is_exclusive(hdsp))
1708 return -EBUSY; 1729 return -EBUSY;
1709 val = ucontrol->value.integer.value[0] & 1; 1730 val = ucontrol->value.integer.value[0] & 1;
@@ -1737,7 +1758,7 @@ static int hdsp_set_spdif_emphasis(struct hdsp *hdsp, int val)
1737static int snd_hdsp_get_spdif_emphasis(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 1758static int snd_hdsp_get_spdif_emphasis(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1738{ 1759{
1739 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); 1760 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
1740 1761
1741 ucontrol->value.integer.value[0] = hdsp_spdif_emphasis(hdsp); 1762 ucontrol->value.integer.value[0] = hdsp_spdif_emphasis(hdsp);
1742 return 0; 1763 return 0;
1743} 1764}
@@ -1747,7 +1768,7 @@ static int snd_hdsp_put_spdif_emphasis(struct snd_kcontrol *kcontrol, struct snd
1747 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); 1768 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
1748 int change; 1769 int change;
1749 unsigned int val; 1770 unsigned int val;
1750 1771
1751 if (!snd_hdsp_use_is_exclusive(hdsp)) 1772 if (!snd_hdsp_use_is_exclusive(hdsp))
1752 return -EBUSY; 1773 return -EBUSY;
1753 val = ucontrol->value.integer.value[0] & 1; 1774 val = ucontrol->value.integer.value[0] & 1;
@@ -1781,7 +1802,7 @@ static int hdsp_set_spdif_nonaudio(struct hdsp *hdsp, int val)
1781static int snd_hdsp_get_spdif_nonaudio(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 1802static int snd_hdsp_get_spdif_nonaudio(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1782{ 1803{
1783 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); 1804 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
1784 1805
1785 ucontrol->value.integer.value[0] = hdsp_spdif_nonaudio(hdsp); 1806 ucontrol->value.integer.value[0] = hdsp_spdif_nonaudio(hdsp);
1786 return 0; 1807 return 0;
1787} 1808}
@@ -1791,7 +1812,7 @@ static int snd_hdsp_put_spdif_nonaudio(struct snd_kcontrol *kcontrol, struct snd
1791 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); 1812 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
1792 int change; 1813 int change;
1793 unsigned int val; 1814 unsigned int val;
1794 1815
1795 if (!snd_hdsp_use_is_exclusive(hdsp)) 1816 if (!snd_hdsp_use_is_exclusive(hdsp))
1796 return -EBUSY; 1817 return -EBUSY;
1797 val = ucontrol->value.integer.value[0] & 1; 1818 val = ucontrol->value.integer.value[0] & 1;
@@ -1828,7 +1849,7 @@ static int snd_hdsp_info_spdif_sample_rate(struct snd_kcontrol *kcontrol, struct
1828static int snd_hdsp_get_spdif_sample_rate(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 1849static int snd_hdsp_get_spdif_sample_rate(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1829{ 1850{
1830 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); 1851 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
1831 1852
1832 switch (hdsp_spdif_sample_rate(hdsp)) { 1853 switch (hdsp_spdif_sample_rate(hdsp)) {
1833 case 32000: 1854 case 32000:
1834 ucontrol->value.enumerated.item[0] = 0; 1855 ucontrol->value.enumerated.item[0] = 0;
@@ -1858,7 +1879,7 @@ static int snd_hdsp_get_spdif_sample_rate(struct snd_kcontrol *kcontrol, struct
1858 ucontrol->value.enumerated.item[0] = 9; 1879 ucontrol->value.enumerated.item[0] = 9;
1859 break; 1880 break;
1860 default: 1881 default:
1861 ucontrol->value.enumerated.item[0] = 6; 1882 ucontrol->value.enumerated.item[0] = 6;
1862 } 1883 }
1863 return 0; 1884 return 0;
1864} 1885}
@@ -1882,7 +1903,7 @@ static int snd_hdsp_info_system_sample_rate(struct snd_kcontrol *kcontrol, struc
1882static int snd_hdsp_get_system_sample_rate(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 1903static int snd_hdsp_get_system_sample_rate(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1883{ 1904{
1884 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); 1905 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
1885 1906
1886 ucontrol->value.enumerated.item[0] = hdsp->system_sample_rate; 1907 ucontrol->value.enumerated.item[0] = hdsp->system_sample_rate;
1887 return 0; 1908 return 0;
1888} 1909}
@@ -1899,7 +1920,7 @@ static int snd_hdsp_get_system_sample_rate(struct snd_kcontrol *kcontrol, struct
1899static int snd_hdsp_info_autosync_sample_rate(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 1920static int snd_hdsp_info_autosync_sample_rate(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
1900{ 1921{
1901 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); 1922 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
1902 static char *texts[] = {"32000", "44100", "48000", "64000", "88200", "96000", "None", "128000", "176400", "192000"}; 1923 static char *texts[] = {"32000", "44100", "48000", "64000", "88200", "96000", "None", "128000", "176400", "192000"};
1903 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 1924 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1904 uinfo->count = 1; 1925 uinfo->count = 1;
1905 uinfo->value.enumerated.items = (hdsp->io_type == H9632) ? 10 : 7 ; 1926 uinfo->value.enumerated.items = (hdsp->io_type == H9632) ? 10 : 7 ;
@@ -1912,7 +1933,7 @@ static int snd_hdsp_info_autosync_sample_rate(struct snd_kcontrol *kcontrol, str
1912static int snd_hdsp_get_autosync_sample_rate(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 1933static int snd_hdsp_get_autosync_sample_rate(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1913{ 1934{
1914 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); 1935 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
1915 1936
1916 switch (hdsp_external_sample_rate(hdsp)) { 1937 switch (hdsp_external_sample_rate(hdsp)) {
1917 case 32000: 1938 case 32000:
1918 ucontrol->value.enumerated.item[0] = 0; 1939 ucontrol->value.enumerated.item[0] = 0;
@@ -1940,9 +1961,9 @@ static int snd_hdsp_get_autosync_sample_rate(struct snd_kcontrol *kcontrol, stru
1940 break; 1961 break;
1941 case 192000: 1962 case 192000:
1942 ucontrol->value.enumerated.item[0] = 9; 1963 ucontrol->value.enumerated.item[0] = 9;
1943 break; 1964 break;
1944 default: 1965 default:
1945 ucontrol->value.enumerated.item[0] = 6; 1966 ucontrol->value.enumerated.item[0] = 6;
1946 } 1967 }
1947 return 0; 1968 return 0;
1948} 1969}
@@ -1968,7 +1989,7 @@ static int hdsp_system_clock_mode(struct hdsp *hdsp)
1968static int snd_hdsp_info_system_clock_mode(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 1989static int snd_hdsp_info_system_clock_mode(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
1969{ 1990{
1970 static char *texts[] = {"Master", "Slave" }; 1991 static char *texts[] = {"Master", "Slave" };
1971 1992
1972 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 1993 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1973 uinfo->count = 1; 1994 uinfo->count = 1;
1974 uinfo->value.enumerated.items = 2; 1995 uinfo->value.enumerated.items = 2;
@@ -1981,7 +2002,7 @@ static int snd_hdsp_info_system_clock_mode(struct snd_kcontrol *kcontrol, struct
1981static int snd_hdsp_get_system_clock_mode(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 2002static int snd_hdsp_get_system_clock_mode(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1982{ 2003{
1983 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); 2004 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
1984 2005
1985 ucontrol->value.enumerated.item[0] = hdsp_system_clock_mode(hdsp); 2006 ucontrol->value.enumerated.item[0] = hdsp_system_clock_mode(hdsp);
1986 return 0; 2007 return 0;
1987} 2008}
@@ -2018,7 +2039,7 @@ static int hdsp_clock_source(struct hdsp *hdsp)
2018 case 192000: 2039 case 192000:
2019 return 9; 2040 return 9;
2020 default: 2041 default:
2021 return 3; 2042 return 3;
2022 } 2043 }
2023 } else { 2044 } else {
2024 return 0; 2045 return 0;
@@ -2032,7 +2053,7 @@ static int hdsp_set_clock_source(struct hdsp *hdsp, int mode)
2032 case HDSP_CLOCK_SOURCE_AUTOSYNC: 2053 case HDSP_CLOCK_SOURCE_AUTOSYNC:
2033 if (hdsp_external_sample_rate(hdsp) != 0) { 2054 if (hdsp_external_sample_rate(hdsp) != 0) {
2034 if (!hdsp_set_rate(hdsp, hdsp_external_sample_rate(hdsp), 1)) { 2055 if (!hdsp_set_rate(hdsp, hdsp_external_sample_rate(hdsp), 1)) {
2035 hdsp->control_register &= ~HDSP_ClockModeMaster; 2056 hdsp->control_register &= ~HDSP_ClockModeMaster;
2036 hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register); 2057 hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register);
2037 return 0; 2058 return 0;
2038 } 2059 }
@@ -2043,7 +2064,7 @@ static int hdsp_set_clock_source(struct hdsp *hdsp, int mode)
2043 break; 2064 break;
2044 case HDSP_CLOCK_SOURCE_INTERNAL_44_1KHZ: 2065 case HDSP_CLOCK_SOURCE_INTERNAL_44_1KHZ:
2045 rate = 44100; 2066 rate = 44100;
2046 break; 2067 break;
2047 case HDSP_CLOCK_SOURCE_INTERNAL_48KHZ: 2068 case HDSP_CLOCK_SOURCE_INTERNAL_48KHZ:
2048 rate = 48000; 2069 rate = 48000;
2049 break; 2070 break;
@@ -2078,13 +2099,13 @@ static int snd_hdsp_info_clock_source(struct snd_kcontrol *kcontrol, struct snd_
2078{ 2099{
2079 static char *texts[] = {"AutoSync", "Internal 32.0 kHz", "Internal 44.1 kHz", "Internal 48.0 kHz", "Internal 64.0 kHz", "Internal 88.2 kHz", "Internal 96.0 kHz", "Internal 128 kHz", "Internal 176.4 kHz", "Internal 192.0 KHz" }; 2100 static char *texts[] = {"AutoSync", "Internal 32.0 kHz", "Internal 44.1 kHz", "Internal 48.0 kHz", "Internal 64.0 kHz", "Internal 88.2 kHz", "Internal 96.0 kHz", "Internal 128 kHz", "Internal 176.4 kHz", "Internal 192.0 KHz" };
2080 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); 2101 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
2081 2102
2082 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 2103 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2083 uinfo->count = 1; 2104 uinfo->count = 1;
2084 if (hdsp->io_type == H9632) 2105 if (hdsp->io_type == H9632)
2085 uinfo->value.enumerated.items = 10; 2106 uinfo->value.enumerated.items = 10;
2086 else 2107 else
2087 uinfo->value.enumerated.items = 7; 2108 uinfo->value.enumerated.items = 7;
2088 if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) 2109 if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
2089 uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1; 2110 uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1;
2090 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); 2111 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
@@ -2094,7 +2115,7 @@ static int snd_hdsp_info_clock_source(struct snd_kcontrol *kcontrol, struct snd_
2094static int snd_hdsp_get_clock_source(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 2115static int snd_hdsp_get_clock_source(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2095{ 2116{
2096 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); 2117 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
2097 2118
2098 ucontrol->value.enumerated.item[0] = hdsp_clock_source(hdsp); 2119 ucontrol->value.enumerated.item[0] = hdsp_clock_source(hdsp);
2099 return 0; 2120 return 0;
2100} 2121}
@@ -2104,7 +2125,7 @@ static int snd_hdsp_put_clock_source(struct snd_kcontrol *kcontrol, struct snd_c
2104 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); 2125 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
2105 int change; 2126 int change;
2106 int val; 2127 int val;
2107 2128
2108 if (!snd_hdsp_use_is_exclusive(hdsp)) 2129 if (!snd_hdsp_use_is_exclusive(hdsp))
2109 return -EBUSY; 2130 return -EBUSY;
2110 val = ucontrol->value.enumerated.item[0]; 2131 val = ucontrol->value.enumerated.item[0];
@@ -2130,7 +2151,7 @@ static int snd_hdsp_put_clock_source(struct snd_kcontrol *kcontrol, struct snd_c
2130static int snd_hdsp_get_clock_source_lock(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 2151static int snd_hdsp_get_clock_source_lock(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2131{ 2152{
2132 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); 2153 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
2133 2154
2134 ucontrol->value.integer.value[0] = hdsp->clock_source_locked; 2155 ucontrol->value.integer.value[0] = hdsp->clock_source_locked;
2135 return 0; 2156 return 0;
2136} 2157}
@@ -2165,7 +2186,7 @@ static int hdsp_da_gain(struct hdsp *hdsp)
2165 case HDSP_DAGainMinus10dBV: 2186 case HDSP_DAGainMinus10dBV:
2166 return 2; 2187 return 2;
2167 default: 2188 default:
2168 return 1; 2189 return 1;
2169 } 2190 }
2170} 2191}
2171 2192
@@ -2180,8 +2201,8 @@ static int hdsp_set_da_gain(struct hdsp *hdsp, int mode)
2180 hdsp->control_register |= HDSP_DAGainPlus4dBu; 2201 hdsp->control_register |= HDSP_DAGainPlus4dBu;
2181 break; 2202 break;
2182 case 2: 2203 case 2:
2183 hdsp->control_register |= HDSP_DAGainMinus10dBV; 2204 hdsp->control_register |= HDSP_DAGainMinus10dBV;
2184 break; 2205 break;
2185 default: 2206 default:
2186 return -1; 2207 return -1;
2187 2208
@@ -2193,7 +2214,7 @@ static int hdsp_set_da_gain(struct hdsp *hdsp, int mode)
2193static int snd_hdsp_info_da_gain(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 2214static int snd_hdsp_info_da_gain(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
2194{ 2215{
2195 static char *texts[] = {"Hi Gain", "+4 dBu", "-10 dbV"}; 2216 static char *texts[] = {"Hi Gain", "+4 dBu", "-10 dbV"};
2196 2217
2197 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 2218 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2198 uinfo->count = 1; 2219 uinfo->count = 1;
2199 uinfo->value.enumerated.items = 3; 2220 uinfo->value.enumerated.items = 3;
@@ -2206,7 +2227,7 @@ static int snd_hdsp_info_da_gain(struct snd_kcontrol *kcontrol, struct snd_ctl_e
2206static int snd_hdsp_get_da_gain(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 2227static int snd_hdsp_get_da_gain(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2207{ 2228{
2208 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); 2229 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
2209 2230
2210 ucontrol->value.enumerated.item[0] = hdsp_da_gain(hdsp); 2231 ucontrol->value.enumerated.item[0] = hdsp_da_gain(hdsp);
2211 return 0; 2232 return 0;
2212} 2233}
@@ -2216,7 +2237,7 @@ static int snd_hdsp_put_da_gain(struct snd_kcontrol *kcontrol, struct snd_ctl_el
2216 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); 2237 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
2217 int change; 2238 int change;
2218 int val; 2239 int val;
2219 2240
2220 if (!snd_hdsp_use_is_exclusive(hdsp)) 2241 if (!snd_hdsp_use_is_exclusive(hdsp))
2221 return -EBUSY; 2242 return -EBUSY;
2222 val = ucontrol->value.enumerated.item[0]; 2243 val = ucontrol->value.enumerated.item[0];
@@ -2250,7 +2271,7 @@ static int hdsp_ad_gain(struct hdsp *hdsp)
2250 case HDSP_ADGainLowGain: 2271 case HDSP_ADGainLowGain:
2251 return 2; 2272 return 2;
2252 default: 2273 default:
2253 return 1; 2274 return 1;
2254 } 2275 }
2255} 2276}
2256 2277
@@ -2262,11 +2283,11 @@ static int hdsp_set_ad_gain(struct hdsp *hdsp, int mode)
2262 hdsp->control_register |= HDSP_ADGainMinus10dBV; 2283 hdsp->control_register |= HDSP_ADGainMinus10dBV;
2263 break; 2284 break;
2264 case 1: 2285 case 1:
2265 hdsp->control_register |= HDSP_ADGainPlus4dBu; 2286 hdsp->control_register |= HDSP_ADGainPlus4dBu;
2266 break; 2287 break;
2267 case 2: 2288 case 2:
2268 hdsp->control_register |= HDSP_ADGainLowGain; 2289 hdsp->control_register |= HDSP_ADGainLowGain;
2269 break; 2290 break;
2270 default: 2291 default:
2271 return -1; 2292 return -1;
2272 2293
@@ -2278,7 +2299,7 @@ static int hdsp_set_ad_gain(struct hdsp *hdsp, int mode)
2278static int snd_hdsp_info_ad_gain(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 2299static int snd_hdsp_info_ad_gain(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
2279{ 2300{
2280 static char *texts[] = {"-10 dBV", "+4 dBu", "Lo Gain"}; 2301 static char *texts[] = {"-10 dBV", "+4 dBu", "Lo Gain"};
2281 2302
2282 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 2303 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2283 uinfo->count = 1; 2304 uinfo->count = 1;
2284 uinfo->value.enumerated.items = 3; 2305 uinfo->value.enumerated.items = 3;
@@ -2291,7 +2312,7 @@ static int snd_hdsp_info_ad_gain(struct snd_kcontrol *kcontrol, struct snd_ctl_e
2291static int snd_hdsp_get_ad_gain(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 2312static int snd_hdsp_get_ad_gain(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2292{ 2313{
2293 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); 2314 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
2294 2315
2295 ucontrol->value.enumerated.item[0] = hdsp_ad_gain(hdsp); 2316 ucontrol->value.enumerated.item[0] = hdsp_ad_gain(hdsp);
2296 return 0; 2317 return 0;
2297} 2318}
@@ -2301,7 +2322,7 @@ static int snd_hdsp_put_ad_gain(struct snd_kcontrol *kcontrol, struct snd_ctl_el
2301 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); 2322 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
2302 int change; 2323 int change;
2303 int val; 2324 int val;
2304 2325
2305 if (!snd_hdsp_use_is_exclusive(hdsp)) 2326 if (!snd_hdsp_use_is_exclusive(hdsp))
2306 return -EBUSY; 2327 return -EBUSY;
2307 val = ucontrol->value.enumerated.item[0]; 2328 val = ucontrol->value.enumerated.item[0];
@@ -2335,7 +2356,7 @@ static int hdsp_phone_gain(struct hdsp *hdsp)
2335 case HDSP_PhoneGainMinus12dB: 2356 case HDSP_PhoneGainMinus12dB:
2336 return 2; 2357 return 2;
2337 default: 2358 default:
2338 return 0; 2359 return 0;
2339 } 2360 }
2340} 2361}
2341 2362
@@ -2347,11 +2368,11 @@ static int hdsp_set_phone_gain(struct hdsp *hdsp, int mode)
2347 hdsp->control_register |= HDSP_PhoneGain0dB; 2368 hdsp->control_register |= HDSP_PhoneGain0dB;
2348 break; 2369 break;
2349 case 1: 2370 case 1:
2350 hdsp->control_register |= HDSP_PhoneGainMinus6dB; 2371 hdsp->control_register |= HDSP_PhoneGainMinus6dB;
2351 break; 2372 break;
2352 case 2: 2373 case 2:
2353 hdsp->control_register |= HDSP_PhoneGainMinus12dB; 2374 hdsp->control_register |= HDSP_PhoneGainMinus12dB;
2354 break; 2375 break;
2355 default: 2376 default:
2356 return -1; 2377 return -1;
2357 2378
@@ -2363,7 +2384,7 @@ static int hdsp_set_phone_gain(struct hdsp *hdsp, int mode)
2363static int snd_hdsp_info_phone_gain(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 2384static int snd_hdsp_info_phone_gain(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
2364{ 2385{
2365 static char *texts[] = {"0 dB", "-6 dB", "-12 dB"}; 2386 static char *texts[] = {"0 dB", "-6 dB", "-12 dB"};
2366 2387
2367 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 2388 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2368 uinfo->count = 1; 2389 uinfo->count = 1;
2369 uinfo->value.enumerated.items = 3; 2390 uinfo->value.enumerated.items = 3;
@@ -2376,7 +2397,7 @@ static int snd_hdsp_info_phone_gain(struct snd_kcontrol *kcontrol, struct snd_ct
2376static int snd_hdsp_get_phone_gain(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 2397static int snd_hdsp_get_phone_gain(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2377{ 2398{
2378 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); 2399 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
2379 2400
2380 ucontrol->value.enumerated.item[0] = hdsp_phone_gain(hdsp); 2401 ucontrol->value.enumerated.item[0] = hdsp_phone_gain(hdsp);
2381 return 0; 2402 return 0;
2382} 2403}
@@ -2386,7 +2407,7 @@ static int snd_hdsp_put_phone_gain(struct snd_kcontrol *kcontrol, struct snd_ctl
2386 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); 2407 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
2387 int change; 2408 int change;
2388 int val; 2409 int val;
2389 2410
2390 if (!snd_hdsp_use_is_exclusive(hdsp)) 2411 if (!snd_hdsp_use_is_exclusive(hdsp))
2391 return -EBUSY; 2412 return -EBUSY;
2392 val = ucontrol->value.enumerated.item[0]; 2413 val = ucontrol->value.enumerated.item[0];
@@ -2432,7 +2453,7 @@ static int hdsp_set_xlr_breakout_cable(struct hdsp *hdsp, int mode)
2432static int snd_hdsp_get_xlr_breakout_cable(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 2453static int snd_hdsp_get_xlr_breakout_cable(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2433{ 2454{
2434 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); 2455 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
2435 2456
2436 ucontrol->value.enumerated.item[0] = hdsp_xlr_breakout_cable(hdsp); 2457 ucontrol->value.enumerated.item[0] = hdsp_xlr_breakout_cable(hdsp);
2437 return 0; 2458 return 0;
2438} 2459}
@@ -2442,7 +2463,7 @@ static int snd_hdsp_put_xlr_breakout_cable(struct snd_kcontrol *kcontrol, struct
2442 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); 2463 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
2443 int change; 2464 int change;
2444 int val; 2465 int val;
2445 2466
2446 if (!snd_hdsp_use_is_exclusive(hdsp)) 2467 if (!snd_hdsp_use_is_exclusive(hdsp))
2447 return -EBUSY; 2468 return -EBUSY;
2448 val = ucontrol->value.integer.value[0] & 1; 2469 val = ucontrol->value.integer.value[0] & 1;
@@ -2488,7 +2509,7 @@ static int hdsp_set_aeb(struct hdsp *hdsp, int mode)
2488static int snd_hdsp_get_aeb(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 2509static int snd_hdsp_get_aeb(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2489{ 2510{
2490 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); 2511 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
2491 2512
2492 ucontrol->value.enumerated.item[0] = hdsp_aeb(hdsp); 2513 ucontrol->value.enumerated.item[0] = hdsp_aeb(hdsp);
2493 return 0; 2514 return 0;
2494} 2515}
@@ -2498,7 +2519,7 @@ static int snd_hdsp_put_aeb(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_v
2498 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); 2519 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
2499 int change; 2520 int change;
2500 int val; 2521 int val;
2501 2522
2502 if (!snd_hdsp_use_is_exclusive(hdsp)) 2523 if (!snd_hdsp_use_is_exclusive(hdsp))
2503 return -EBUSY; 2524 return -EBUSY;
2504 val = ucontrol->value.integer.value[0] & 1; 2525 val = ucontrol->value.integer.value[0] & 1;
@@ -2576,7 +2597,7 @@ static int snd_hdsp_info_pref_sync_ref(struct snd_kcontrol *kcontrol, struct snd
2576{ 2597{
2577 static char *texts[] = {"Word", "IEC958", "ADAT1", "ADAT Sync", "ADAT2", "ADAT3" }; 2598 static char *texts[] = {"Word", "IEC958", "ADAT1", "ADAT Sync", "ADAT2", "ADAT3" };
2578 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); 2599 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
2579 2600
2580 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 2601 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2581 uinfo->count = 1; 2602 uinfo->count = 1;
2582 2603
@@ -2595,7 +2616,7 @@ static int snd_hdsp_info_pref_sync_ref(struct snd_kcontrol *kcontrol, struct snd
2595 uinfo->value.enumerated.items = 0; 2616 uinfo->value.enumerated.items = 0;
2596 break; 2617 break;
2597 } 2618 }
2598 2619
2599 if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) 2620 if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
2600 uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1; 2621 uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1;
2601 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); 2622 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
@@ -2605,7 +2626,7 @@ static int snd_hdsp_info_pref_sync_ref(struct snd_kcontrol *kcontrol, struct snd
2605static int snd_hdsp_get_pref_sync_ref(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 2626static int snd_hdsp_get_pref_sync_ref(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2606{ 2627{
2607 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); 2628 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
2608 2629
2609 ucontrol->value.enumerated.item[0] = hdsp_pref_sync_ref(hdsp); 2630 ucontrol->value.enumerated.item[0] = hdsp_pref_sync_ref(hdsp);
2610 return 0; 2631 return 0;
2611} 2632}
@@ -2615,7 +2636,7 @@ static int snd_hdsp_put_pref_sync_ref(struct snd_kcontrol *kcontrol, struct snd_
2615 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); 2636 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
2616 int change, max; 2637 int change, max;
2617 unsigned int val; 2638 unsigned int val;
2618 2639
2619 if (!snd_hdsp_use_is_exclusive(hdsp)) 2640 if (!snd_hdsp_use_is_exclusive(hdsp))
2620 return -EBUSY; 2641 return -EBUSY;
2621 2642
@@ -2664,7 +2685,7 @@ static int hdsp_autosync_ref(struct hdsp *hdsp)
2664 case HDSP_SelSyncRef_SPDIF: 2685 case HDSP_SelSyncRef_SPDIF:
2665 return HDSP_AUTOSYNC_FROM_SPDIF; 2686 return HDSP_AUTOSYNC_FROM_SPDIF;
2666 case HDSP_SelSyncRefMask: 2687 case HDSP_SelSyncRefMask:
2667 return HDSP_AUTOSYNC_FROM_NONE; 2688 return HDSP_AUTOSYNC_FROM_NONE;
2668 case HDSP_SelSyncRef_ADAT1: 2689 case HDSP_SelSyncRef_ADAT1:
2669 return HDSP_AUTOSYNC_FROM_ADAT1; 2690 return HDSP_AUTOSYNC_FROM_ADAT1;
2670 case HDSP_SelSyncRef_ADAT2: 2691 case HDSP_SelSyncRef_ADAT2:
@@ -2680,7 +2701,7 @@ static int hdsp_autosync_ref(struct hdsp *hdsp)
2680static int snd_hdsp_info_autosync_ref(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 2701static int snd_hdsp_info_autosync_ref(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
2681{ 2702{
2682 static char *texts[] = {"Word", "ADAT Sync", "IEC958", "None", "ADAT1", "ADAT2", "ADAT3" }; 2703 static char *texts[] = {"Word", "ADAT Sync", "IEC958", "None", "ADAT1", "ADAT2", "ADAT3" };
2683 2704
2684 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 2705 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2685 uinfo->count = 1; 2706 uinfo->count = 1;
2686 uinfo->value.enumerated.items = 7; 2707 uinfo->value.enumerated.items = 7;
@@ -2693,7 +2714,7 @@ static int snd_hdsp_info_autosync_ref(struct snd_kcontrol *kcontrol, struct snd_
2693static int snd_hdsp_get_autosync_ref(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 2714static int snd_hdsp_get_autosync_ref(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2694{ 2715{
2695 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); 2716 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
2696 2717
2697 ucontrol->value.enumerated.item[0] = hdsp_autosync_ref(hdsp); 2718 ucontrol->value.enumerated.item[0] = hdsp_autosync_ref(hdsp);
2698 return 0; 2719 return 0;
2699} 2720}
@@ -2727,7 +2748,7 @@ static int hdsp_set_line_output(struct hdsp *hdsp, int out)
2727static int snd_hdsp_get_line_out(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 2748static int snd_hdsp_get_line_out(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2728{ 2749{
2729 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); 2750 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
2730 2751
2731 spin_lock_irq(&hdsp->lock); 2752 spin_lock_irq(&hdsp->lock);
2732 ucontrol->value.integer.value[0] = hdsp_line_out(hdsp); 2753 ucontrol->value.integer.value[0] = hdsp_line_out(hdsp);
2733 spin_unlock_irq(&hdsp->lock); 2754 spin_unlock_irq(&hdsp->lock);
@@ -2739,7 +2760,7 @@ static int snd_hdsp_put_line_out(struct snd_kcontrol *kcontrol, struct snd_ctl_e
2739 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); 2760 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
2740 int change; 2761 int change;
2741 unsigned int val; 2762 unsigned int val;
2742 2763
2743 if (!snd_hdsp_use_is_exclusive(hdsp)) 2764 if (!snd_hdsp_use_is_exclusive(hdsp))
2744 return -EBUSY; 2765 return -EBUSY;
2745 val = ucontrol->value.integer.value[0] & 1; 2766 val = ucontrol->value.integer.value[0] & 1;
@@ -2773,7 +2794,7 @@ static int hdsp_set_precise_pointer(struct hdsp *hdsp, int precise)
2773static int snd_hdsp_get_precise_pointer(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 2794static int snd_hdsp_get_precise_pointer(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2774{ 2795{
2775 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); 2796 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
2776 2797
2777 spin_lock_irq(&hdsp->lock); 2798 spin_lock_irq(&hdsp->lock);
2778 ucontrol->value.integer.value[0] = hdsp->precise_ptr; 2799 ucontrol->value.integer.value[0] = hdsp->precise_ptr;
2779 spin_unlock_irq(&hdsp->lock); 2800 spin_unlock_irq(&hdsp->lock);
@@ -2785,7 +2806,7 @@ static int snd_hdsp_put_precise_pointer(struct snd_kcontrol *kcontrol, struct sn
2785 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); 2806 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
2786 int change; 2807 int change;
2787 unsigned int val; 2808 unsigned int val;
2788 2809
2789 if (!snd_hdsp_use_is_exclusive(hdsp)) 2810 if (!snd_hdsp_use_is_exclusive(hdsp))
2790 return -EBUSY; 2811 return -EBUSY;
2791 val = ucontrol->value.integer.value[0] & 1; 2812 val = ucontrol->value.integer.value[0] & 1;
@@ -2819,7 +2840,7 @@ static int hdsp_set_use_midi_tasklet(struct hdsp *hdsp, int use_tasklet)
2819static int snd_hdsp_get_use_midi_tasklet(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 2840static int snd_hdsp_get_use_midi_tasklet(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2820{ 2841{
2821 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); 2842 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
2822 2843
2823 spin_lock_irq(&hdsp->lock); 2844 spin_lock_irq(&hdsp->lock);
2824 ucontrol->value.integer.value[0] = hdsp->use_midi_tasklet; 2845 ucontrol->value.integer.value[0] = hdsp->use_midi_tasklet;
2825 spin_unlock_irq(&hdsp->lock); 2846 spin_unlock_irq(&hdsp->lock);
@@ -2831,7 +2852,7 @@ static int snd_hdsp_put_use_midi_tasklet(struct snd_kcontrol *kcontrol, struct s
2831 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); 2852 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
2832 int change; 2853 int change;
2833 unsigned int val; 2854 unsigned int val;
2834 2855
2835 if (!snd_hdsp_use_is_exclusive(hdsp)) 2856 if (!snd_hdsp_use_is_exclusive(hdsp))
2836 return -EBUSY; 2857 return -EBUSY;
2837 val = ucontrol->value.integer.value[0] & 1; 2858 val = ucontrol->value.integer.value[0] & 1;
@@ -2873,12 +2894,12 @@ static int snd_hdsp_get_mixer(struct snd_kcontrol *kcontrol, struct snd_ctl_elem
2873 2894
2874 source = ucontrol->value.integer.value[0]; 2895 source = ucontrol->value.integer.value[0];
2875 destination = ucontrol->value.integer.value[1]; 2896 destination = ucontrol->value.integer.value[1];
2876 2897
2877 if (source >= hdsp->max_channels) 2898 if (source >= hdsp->max_channels)
2878 addr = hdsp_playback_to_output_key(hdsp,source-hdsp->max_channels,destination); 2899 addr = hdsp_playback_to_output_key(hdsp,source-hdsp->max_channels,destination);
2879 else 2900 else
2880 addr = hdsp_input_to_output_key(hdsp,source, destination); 2901 addr = hdsp_input_to_output_key(hdsp,source, destination);
2881 2902
2882 spin_lock_irq(&hdsp->lock); 2903 spin_lock_irq(&hdsp->lock);
2883 ucontrol->value.integer.value[2] = hdsp_read_gain (hdsp, addr); 2904 ucontrol->value.integer.value[2] = hdsp_read_gain (hdsp, addr);
2884 spin_unlock_irq(&hdsp->lock); 2905 spin_unlock_irq(&hdsp->lock);
@@ -2926,7 +2947,7 @@ static int snd_hdsp_put_mixer(struct snd_kcontrol *kcontrol, struct snd_ctl_elem
2926 2947
2927static int snd_hdsp_info_sync_check(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 2948static int snd_hdsp_info_sync_check(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
2928{ 2949{
2929 static char *texts[] = {"No Lock", "Lock", "Sync" }; 2950 static char *texts[] = {"No Lock", "Lock", "Sync" };
2930 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 2951 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2931 uinfo->count = 1; 2952 uinfo->count = 1;
2932 uinfo->value.enumerated.items = 3; 2953 uinfo->value.enumerated.items = 3;
@@ -2971,7 +2992,7 @@ static int hdsp_spdif_sync_check(struct hdsp *hdsp)
2971 int status = hdsp_read(hdsp, HDSP_statusRegister); 2992 int status = hdsp_read(hdsp, HDSP_statusRegister);
2972 if (status & HDSP_SPDIFErrorFlag) 2993 if (status & HDSP_SPDIFErrorFlag)
2973 return 0; 2994 return 0;
2974 else { 2995 else {
2975 if (status & HDSP_SPDIFSync) 2996 if (status & HDSP_SPDIFSync)
2976 return 2; 2997 return 2;
2977 else 2998 else
@@ -3007,7 +3028,7 @@ static int hdsp_adatsync_sync_check(struct hdsp *hdsp)
3007 return 1; 3028 return 1;
3008 } else 3029 } else
3009 return 0; 3030 return 0;
3010} 3031}
3011 3032
3012static int snd_hdsp_get_adatsync_sync_check(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 3033static int snd_hdsp_get_adatsync_sync_check(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
3013{ 3034{
@@ -3025,17 +3046,17 @@ static int snd_hdsp_get_adatsync_sync_check(struct snd_kcontrol *kcontrol, struc
3025} 3046}
3026 3047
3027static int hdsp_adat_sync_check(struct hdsp *hdsp, int idx) 3048static int hdsp_adat_sync_check(struct hdsp *hdsp, int idx)
3028{ 3049{
3029 int status = hdsp_read(hdsp, HDSP_statusRegister); 3050 int status = hdsp_read(hdsp, HDSP_statusRegister);
3030 3051
3031 if (status & (HDSP_Lock0>>idx)) { 3052 if (status & (HDSP_Lock0>>idx)) {
3032 if (status & (HDSP_Sync0>>idx)) 3053 if (status & (HDSP_Sync0>>idx))
3033 return 2; 3054 return 2;
3034 else 3055 else
3035 return 1; 3056 return 1;
3036 } else 3057 } else
3037 return 0; 3058 return 0;
3038} 3059}
3039 3060
3040static int snd_hdsp_get_adat_sync_check(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 3061static int snd_hdsp_get_adat_sync_check(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
3041{ 3062{
@@ -3053,7 +3074,7 @@ static int snd_hdsp_get_adat_sync_check(struct snd_kcontrol *kcontrol, struct sn
3053 break; 3074 break;
3054 case Multiface: 3075 case Multiface:
3055 case H9632: 3076 case H9632:
3056 if (offset >= 1) 3077 if (offset >= 1)
3057 return -EINVAL; 3078 return -EINVAL;
3058 break; 3079 break;
3059 default: 3080 default:
@@ -3115,7 +3136,7 @@ static int snd_hdsp_info_dds_offset(struct snd_kcontrol *kcontrol, struct snd_ct
3115static int snd_hdsp_get_dds_offset(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 3136static int snd_hdsp_get_dds_offset(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
3116{ 3137{
3117 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); 3138 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
3118 3139
3119 ucontrol->value.enumerated.item[0] = hdsp_dds_offset(hdsp); 3140 ucontrol->value.enumerated.item[0] = hdsp_dds_offset(hdsp);
3120 return 0; 3141 return 0;
3121} 3142}
@@ -3125,7 +3146,7 @@ static int snd_hdsp_put_dds_offset(struct snd_kcontrol *kcontrol, struct snd_ctl
3125 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); 3146 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
3126 int change; 3147 int change;
3127 int val; 3148 int val;
3128 3149
3129 if (!snd_hdsp_use_is_exclusive(hdsp)) 3150 if (!snd_hdsp_use_is_exclusive(hdsp))
3130 return -EBUSY; 3151 return -EBUSY;
3131 val = ucontrol->value.enumerated.item[0]; 3152 val = ucontrol->value.enumerated.item[0];
@@ -3170,7 +3191,7 @@ static struct snd_kcontrol_new snd_hdsp_controls[] = {
3170 .get = snd_hdsp_control_spdif_mask_get, 3191 .get = snd_hdsp_control_spdif_mask_get,
3171 .private_value = IEC958_AES0_NONAUDIO | 3192 .private_value = IEC958_AES0_NONAUDIO |
3172 IEC958_AES0_PROFESSIONAL | 3193 IEC958_AES0_PROFESSIONAL |
3173 IEC958_AES0_CON_EMPHASIS, 3194 IEC958_AES0_CON_EMPHASIS,
3174}, 3195},
3175{ 3196{
3176 .access = SNDRV_CTL_ELEM_ACCESS_READ, 3197 .access = SNDRV_CTL_ELEM_ACCESS_READ,
@@ -3188,7 +3209,7 @@ HDSP_SPDIF_OUT("IEC958 Output also on ADAT1", 0),
3188HDSP_SPDIF_PROFESSIONAL("IEC958 Professional Bit", 0), 3209HDSP_SPDIF_PROFESSIONAL("IEC958 Professional Bit", 0),
3189HDSP_SPDIF_EMPHASIS("IEC958 Emphasis Bit", 0), 3210HDSP_SPDIF_EMPHASIS("IEC958 Emphasis Bit", 0),
3190HDSP_SPDIF_NON_AUDIO("IEC958 Non-audio Bit", 0), 3211HDSP_SPDIF_NON_AUDIO("IEC958 Non-audio Bit", 0),
3191/* 'Sample Clock Source' complies with the alsa control naming scheme */ 3212/* 'Sample Clock Source' complies with the alsa control naming scheme */
3192HDSP_CLOCK_SOURCE("Sample Clock Source", 0), 3213HDSP_CLOCK_SOURCE("Sample Clock Source", 0),
3193{ 3214{
3194 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 3215 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
@@ -3240,7 +3261,7 @@ static int snd_hdsp_create_controls(struct snd_card *card, struct hdsp *hdsp)
3240 return err; 3261 return err;
3241 } 3262 }
3242 } 3263 }
3243 3264
3244 /* DA, AD and Phone gain and XLR breakout cable controls for H9632 cards */ 3265 /* DA, AD and Phone gain and XLR breakout cable controls for H9632 cards */
3245 if (hdsp->io_type == H9632) { 3266 if (hdsp->io_type == H9632) {
3246 for (idx = 0; idx < ARRAY_SIZE(snd_hdsp_9632_controls); idx++) { 3267 for (idx = 0; idx < ARRAY_SIZE(snd_hdsp_9632_controls); idx++) {
@@ -3259,7 +3280,7 @@ static int snd_hdsp_create_controls(struct snd_card *card, struct hdsp *hdsp)
3259} 3280}
3260 3281
3261/*------------------------------------------------------------ 3282/*------------------------------------------------------------
3262 /proc interface 3283 /proc interface
3263 ------------------------------------------------------------*/ 3284 ------------------------------------------------------------*/
3264 3285
3265static void 3286static void
@@ -3298,7 +3319,7 @@ snd_hdsp_proc_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer)
3298 } 3319 }
3299 } 3320 }
3300 } 3321 }
3301 3322
3302 status = hdsp_read(hdsp, HDSP_statusRegister); 3323 status = hdsp_read(hdsp, HDSP_statusRegister);
3303 status2 = hdsp_read(hdsp, HDSP_status2Register); 3324 status2 = hdsp_read(hdsp, HDSP_status2Register);
3304 3325
@@ -3362,17 +3383,17 @@ snd_hdsp_proc_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer)
3362 break; 3383 break;
3363 case HDSP_CLOCK_SOURCE_INTERNAL_192KHZ: 3384 case HDSP_CLOCK_SOURCE_INTERNAL_192KHZ:
3364 clock_source = "Internal 192 kHz"; 3385 clock_source = "Internal 192 kHz";
3365 break; 3386 break;
3366 default: 3387 default:
3367 clock_source = "Error"; 3388 clock_source = "Error";
3368 } 3389 }
3369 snd_iprintf (buffer, "Sample Clock Source: %s\n", clock_source); 3390 snd_iprintf (buffer, "Sample Clock Source: %s\n", clock_source);
3370 3391
3371 if (hdsp_system_clock_mode(hdsp)) 3392 if (hdsp_system_clock_mode(hdsp))
3372 system_clock_mode = "Slave"; 3393 system_clock_mode = "Slave";
3373 else 3394 else
3374 system_clock_mode = "Master"; 3395 system_clock_mode = "Master";
3375 3396
3376 switch (hdsp_pref_sync_ref (hdsp)) { 3397 switch (hdsp_pref_sync_ref (hdsp)) {
3377 case HDSP_SYNC_FROM_WORD: 3398 case HDSP_SYNC_FROM_WORD:
3378 pref_sync_ref = "Word Clock"; 3399 pref_sync_ref = "Word Clock";
@@ -3397,7 +3418,7 @@ snd_hdsp_proc_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer)
3397 break; 3418 break;
3398 } 3419 }
3399 snd_iprintf (buffer, "Preferred Sync Reference: %s\n", pref_sync_ref); 3420 snd_iprintf (buffer, "Preferred Sync Reference: %s\n", pref_sync_ref);
3400 3421
3401 switch (hdsp_autosync_ref (hdsp)) { 3422 switch (hdsp_autosync_ref (hdsp)) {
3402 case HDSP_AUTOSYNC_FROM_WORD: 3423 case HDSP_AUTOSYNC_FROM_WORD:
3403 autosync_ref = "Word Clock"; 3424 autosync_ref = "Word Clock";
@@ -3410,7 +3431,7 @@ snd_hdsp_proc_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer)
3410 break; 3431 break;
3411 case HDSP_AUTOSYNC_FROM_NONE: 3432 case HDSP_AUTOSYNC_FROM_NONE:
3412 autosync_ref = "None"; 3433 autosync_ref = "None";
3413 break; 3434 break;
3414 case HDSP_AUTOSYNC_FROM_ADAT1: 3435 case HDSP_AUTOSYNC_FROM_ADAT1:
3415 autosync_ref = "ADAT1"; 3436 autosync_ref = "ADAT1";
3416 break; 3437 break;
@@ -3425,14 +3446,14 @@ snd_hdsp_proc_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer)
3425 break; 3446 break;
3426 } 3447 }
3427 snd_iprintf (buffer, "AutoSync Reference: %s\n", autosync_ref); 3448 snd_iprintf (buffer, "AutoSync Reference: %s\n", autosync_ref);
3428 3449
3429 snd_iprintf (buffer, "AutoSync Frequency: %d\n", hdsp_external_sample_rate(hdsp)); 3450 snd_iprintf (buffer, "AutoSync Frequency: %d\n", hdsp_external_sample_rate(hdsp));
3430 3451
3431 snd_iprintf (buffer, "System Clock Mode: %s\n", system_clock_mode); 3452 snd_iprintf (buffer, "System Clock Mode: %s\n", system_clock_mode);
3432 3453
3433 snd_iprintf (buffer, "System Clock Frequency: %d\n", hdsp->system_sample_rate); 3454 snd_iprintf (buffer, "System Clock Frequency: %d\n", hdsp->system_sample_rate);
3434 snd_iprintf (buffer, "System Clock Locked: %s\n", hdsp->clock_source_locked ? "Yes" : "No"); 3455 snd_iprintf (buffer, "System Clock Locked: %s\n", hdsp->clock_source_locked ? "Yes" : "No");
3435 3456
3436 snd_iprintf(buffer, "\n"); 3457 snd_iprintf(buffer, "\n");
3437 3458
3438 switch (hdsp_spdif_in(hdsp)) { 3459 switch (hdsp_spdif_in(hdsp)) {
@@ -3452,7 +3473,7 @@ snd_hdsp_proc_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer)
3452 snd_iprintf(buffer, "IEC958 input: ???\n"); 3473 snd_iprintf(buffer, "IEC958 input: ???\n");
3453 break; 3474 break;
3454 } 3475 }
3455 3476
3456 if (hdsp->control_register & HDSP_SPDIFOpticalOut) 3477 if (hdsp->control_register & HDSP_SPDIFOpticalOut)
3457 snd_iprintf(buffer, "IEC958 output: Coaxial & ADAT1\n"); 3478 snd_iprintf(buffer, "IEC958 output: Coaxial & ADAT1\n");
3458 else 3479 else
@@ -3510,13 +3531,13 @@ snd_hdsp_proc_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer)
3510 snd_iprintf (buffer, "SPDIF: No Lock\n"); 3531 snd_iprintf (buffer, "SPDIF: No Lock\n");
3511 else 3532 else
3512 snd_iprintf (buffer, "SPDIF: %s\n", x ? "Sync" : "Lock"); 3533 snd_iprintf (buffer, "SPDIF: %s\n", x ? "Sync" : "Lock");
3513 3534
3514 x = status2 & HDSP_wc_sync; 3535 x = status2 & HDSP_wc_sync;
3515 if (status2 & HDSP_wc_lock) 3536 if (status2 & HDSP_wc_lock)
3516 snd_iprintf (buffer, "Word Clock: %s\n", x ? "Sync" : "Lock"); 3537 snd_iprintf (buffer, "Word Clock: %s\n", x ? "Sync" : "Lock");
3517 else 3538 else
3518 snd_iprintf (buffer, "Word Clock: No Lock\n"); 3539 snd_iprintf (buffer, "Word Clock: No Lock\n");
3519 3540
3520 x = status & HDSP_TimecodeSync; 3541 x = status & HDSP_TimecodeSync;
3521 if (status & HDSP_TimecodeLock) 3542 if (status & HDSP_TimecodeLock)
3522 snd_iprintf(buffer, "ADAT Sync: %s\n", x ? "Sync" : "Lock"); 3543 snd_iprintf(buffer, "ADAT Sync: %s\n", x ? "Sync" : "Lock");
@@ -3524,11 +3545,11 @@ snd_hdsp_proc_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer)
3524 snd_iprintf(buffer, "ADAT Sync: No Lock\n"); 3545 snd_iprintf(buffer, "ADAT Sync: No Lock\n");
3525 3546
3526 snd_iprintf(buffer, "\n"); 3547 snd_iprintf(buffer, "\n");
3527 3548
3528 /* Informations about H9632 specific controls */ 3549 /* Informations about H9632 specific controls */
3529 if (hdsp->io_type == H9632) { 3550 if (hdsp->io_type == H9632) {
3530 char *tmp; 3551 char *tmp;
3531 3552
3532 switch (hdsp_ad_gain(hdsp)) { 3553 switch (hdsp_ad_gain(hdsp)) {
3533 case 0: 3554 case 0:
3534 tmp = "-10 dBV"; 3555 tmp = "-10 dBV";
@@ -3554,7 +3575,7 @@ snd_hdsp_proc_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer)
3554 break; 3575 break;
3555 } 3576 }
3556 snd_iprintf(buffer, "DA Gain : %s\n", tmp); 3577 snd_iprintf(buffer, "DA Gain : %s\n", tmp);
3557 3578
3558 switch (hdsp_phone_gain(hdsp)) { 3579 switch (hdsp_phone_gain(hdsp)) {
3559 case 0: 3580 case 0:
3560 tmp = "0 dB"; 3581 tmp = "0 dB";
@@ -3568,8 +3589,8 @@ snd_hdsp_proc_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer)
3568 } 3589 }
3569 snd_iprintf(buffer, "Phones Gain : %s\n", tmp); 3590 snd_iprintf(buffer, "Phones Gain : %s\n", tmp);
3570 3591
3571 snd_iprintf(buffer, "XLR Breakout Cable : %s\n", hdsp_xlr_breakout_cable(hdsp) ? "yes" : "no"); 3592 snd_iprintf(buffer, "XLR Breakout Cable : %s\n", hdsp_xlr_breakout_cable(hdsp) ? "yes" : "no");
3572 3593
3573 if (hdsp->control_register & HDSP_AnalogExtensionBoard) 3594 if (hdsp->control_register & HDSP_AnalogExtensionBoard)
3574 snd_iprintf(buffer, "AEB : on (ADAT1 internal)\n"); 3595 snd_iprintf(buffer, "AEB : on (ADAT1 internal)\n");
3575 else 3596 else
@@ -3632,18 +3653,18 @@ static int snd_hdsp_set_defaults(struct hdsp *hdsp)
3632 3653
3633 /* set defaults: 3654 /* set defaults:
3634 3655
3635 SPDIF Input via Coax 3656 SPDIF Input via Coax
3636 Master clock mode 3657 Master clock mode
3637 maximum latency (7 => 2^7 = 8192 samples, 64Kbyte buffer, 3658 maximum latency (7 => 2^7 = 8192 samples, 64Kbyte buffer,
3638 which implies 2 4096 sample, 32Kbyte periods). 3659 which implies 2 4096 sample, 32Kbyte periods).
3639 Enable line out. 3660 Enable line out.
3640 */ 3661 */
3641 3662
3642 hdsp->control_register = HDSP_ClockModeMaster | 3663 hdsp->control_register = HDSP_ClockModeMaster |
3643 HDSP_SPDIFInputCoaxial | 3664 HDSP_SPDIFInputCoaxial |
3644 hdsp_encode_latency(7) | 3665 hdsp_encode_latency(7) |
3645 HDSP_LineOut; 3666 HDSP_LineOut;
3646 3667
3647 3668
3648 hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register); 3669 hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register);
3649 3670
@@ -3661,7 +3682,7 @@ static int snd_hdsp_set_defaults(struct hdsp *hdsp)
3661 hdsp_compute_period_size(hdsp); 3682 hdsp_compute_period_size(hdsp);
3662 3683
3663 /* silence everything */ 3684 /* silence everything */
3664 3685
3665 for (i = 0; i < HDSP_MATRIX_MIXER_SIZE; ++i) 3686 for (i = 0; i < HDSP_MATRIX_MIXER_SIZE; ++i)
3666 hdsp->mixer_matrix[i] = MINUS_INFINITY_GAIN; 3687 hdsp->mixer_matrix[i] = MINUS_INFINITY_GAIN;
3667 3688
@@ -3669,7 +3690,7 @@ static int snd_hdsp_set_defaults(struct hdsp *hdsp)
3669 if (hdsp_write_gain (hdsp, i, MINUS_INFINITY_GAIN)) 3690 if (hdsp_write_gain (hdsp, i, MINUS_INFINITY_GAIN))
3670 return -EIO; 3691 return -EIO;
3671 } 3692 }
3672 3693
3673 /* H9632 specific defaults */ 3694 /* H9632 specific defaults */
3674 if (hdsp->io_type == H9632) { 3695 if (hdsp->io_type == H9632) {
3675 hdsp->control_register |= (HDSP_DAGainPlus4dBu | HDSP_ADGainPlus4dBu | HDSP_PhoneGain0dB); 3696 hdsp->control_register |= (HDSP_DAGainPlus4dBu | HDSP_ADGainPlus4dBu | HDSP_PhoneGain0dB);
@@ -3687,12 +3708,12 @@ static int snd_hdsp_set_defaults(struct hdsp *hdsp)
3687static void hdsp_midi_tasklet(unsigned long arg) 3708static void hdsp_midi_tasklet(unsigned long arg)
3688{ 3709{
3689 struct hdsp *hdsp = (struct hdsp *)arg; 3710 struct hdsp *hdsp = (struct hdsp *)arg;
3690 3711
3691 if (hdsp->midi[0].pending) 3712 if (hdsp->midi[0].pending)
3692 snd_hdsp_midi_input_read (&hdsp->midi[0]); 3713 snd_hdsp_midi_input_read (&hdsp->midi[0]);
3693 if (hdsp->midi[1].pending) 3714 if (hdsp->midi[1].pending)
3694 snd_hdsp_midi_input_read (&hdsp->midi[1]); 3715 snd_hdsp_midi_input_read (&hdsp->midi[1]);
3695} 3716}
3696 3717
3697static irqreturn_t snd_hdsp_interrupt(int irq, void *dev_id) 3718static irqreturn_t snd_hdsp_interrupt(int irq, void *dev_id)
3698{ 3719{
@@ -3704,7 +3725,7 @@ static irqreturn_t snd_hdsp_interrupt(int irq, void *dev_id)
3704 unsigned int midi0status; 3725 unsigned int midi0status;
3705 unsigned int midi1status; 3726 unsigned int midi1status;
3706 int schedule = 0; 3727 int schedule = 0;
3707 3728
3708 status = hdsp_read(hdsp, HDSP_statusRegister); 3729 status = hdsp_read(hdsp, HDSP_statusRegister);
3709 3730
3710 audio = status & HDSP_audioIRQPending; 3731 audio = status & HDSP_audioIRQPending;
@@ -3718,15 +3739,18 @@ static irqreturn_t snd_hdsp_interrupt(int irq, void *dev_id)
3718 3739
3719 midi0status = hdsp_read (hdsp, HDSP_midiStatusIn0) & 0xff; 3740 midi0status = hdsp_read (hdsp, HDSP_midiStatusIn0) & 0xff;
3720 midi1status = hdsp_read (hdsp, HDSP_midiStatusIn1) & 0xff; 3741 midi1status = hdsp_read (hdsp, HDSP_midiStatusIn1) & 0xff;
3721 3742
3743 if (!(hdsp->state & HDSP_InitializationComplete))
3744 return IRQ_HANDLED;
3745
3722 if (audio) { 3746 if (audio) {
3723 if (hdsp->capture_substream) 3747 if (hdsp->capture_substream)
3724 snd_pcm_period_elapsed(hdsp->pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream); 3748 snd_pcm_period_elapsed(hdsp->pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream);
3725 3749
3726 if (hdsp->playback_substream) 3750 if (hdsp->playback_substream)
3727 snd_pcm_period_elapsed(hdsp->pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream); 3751 snd_pcm_period_elapsed(hdsp->pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream);
3728 } 3752 }
3729 3753
3730 if (midi0 && midi0status) { 3754 if (midi0 && midi0status) {
3731 if (hdsp->use_midi_tasklet) { 3755 if (hdsp->use_midi_tasklet) {
3732 /* we disable interrupts for this input until processing is done */ 3756 /* we disable interrupts for this input until processing is done */
@@ -3769,10 +3793,10 @@ static char *hdsp_channel_buffer_location(struct hdsp *hdsp,
3769 3793
3770 if (snd_BUG_ON(channel < 0 || channel >= hdsp->max_channels)) 3794 if (snd_BUG_ON(channel < 0 || channel >= hdsp->max_channels))
3771 return NULL; 3795 return NULL;
3772 3796
3773 if ((mapped_channel = hdsp->channel_map[channel]) < 0) 3797 if ((mapped_channel = hdsp->channel_map[channel]) < 0)
3774 return NULL; 3798 return NULL;
3775 3799
3776 if (stream == SNDRV_PCM_STREAM_CAPTURE) 3800 if (stream == SNDRV_PCM_STREAM_CAPTURE)
3777 return hdsp->capture_buffer + (mapped_channel * HDSP_CHANNEL_BUFFER_BYTES); 3801 return hdsp->capture_buffer + (mapped_channel * HDSP_CHANNEL_BUFFER_BYTES);
3778 else 3802 else
@@ -3965,7 +3989,7 @@ static int snd_hdsp_trigger(struct snd_pcm_substream *substream, int cmd)
3965 struct hdsp *hdsp = snd_pcm_substream_chip(substream); 3989 struct hdsp *hdsp = snd_pcm_substream_chip(substream);
3966 struct snd_pcm_substream *other; 3990 struct snd_pcm_substream *other;
3967 int running; 3991 int running;
3968 3992
3969 if (hdsp_check_for_iobox (hdsp)) 3993 if (hdsp_check_for_iobox (hdsp))
3970 return -EIO; 3994 return -EIO;
3971 3995
@@ -4059,10 +4083,10 @@ static struct snd_pcm_hardware snd_hdsp_playback_subinfo =
4059 .formats = SNDRV_PCM_FMTBIT_S32_LE, 4083 .formats = SNDRV_PCM_FMTBIT_S32_LE,
4060#endif 4084#endif
4061 .rates = (SNDRV_PCM_RATE_32000 | 4085 .rates = (SNDRV_PCM_RATE_32000 |
4062 SNDRV_PCM_RATE_44100 | 4086 SNDRV_PCM_RATE_44100 |
4063 SNDRV_PCM_RATE_48000 | 4087 SNDRV_PCM_RATE_48000 |
4064 SNDRV_PCM_RATE_64000 | 4088 SNDRV_PCM_RATE_64000 |
4065 SNDRV_PCM_RATE_88200 | 4089 SNDRV_PCM_RATE_88200 |
4066 SNDRV_PCM_RATE_96000), 4090 SNDRV_PCM_RATE_96000),
4067 .rate_min = 32000, 4091 .rate_min = 32000,
4068 .rate_max = 96000, 4092 .rate_max = 96000,
@@ -4088,10 +4112,10 @@ static struct snd_pcm_hardware snd_hdsp_capture_subinfo =
4088 .formats = SNDRV_PCM_FMTBIT_S32_LE, 4112 .formats = SNDRV_PCM_FMTBIT_S32_LE,
4089#endif 4113#endif
4090 .rates = (SNDRV_PCM_RATE_32000 | 4114 .rates = (SNDRV_PCM_RATE_32000 |
4091 SNDRV_PCM_RATE_44100 | 4115 SNDRV_PCM_RATE_44100 |
4092 SNDRV_PCM_RATE_48000 | 4116 SNDRV_PCM_RATE_48000 |
4093 SNDRV_PCM_RATE_64000 | 4117 SNDRV_PCM_RATE_64000 |
4094 SNDRV_PCM_RATE_88200 | 4118 SNDRV_PCM_RATE_88200 |
4095 SNDRV_PCM_RATE_96000), 4119 SNDRV_PCM_RATE_96000),
4096 .rate_min = 32000, 4120 .rate_min = 32000,
4097 .rate_max = 96000, 4121 .rate_max = 96000,
@@ -4170,7 +4194,7 @@ static int snd_hdsp_hw_rule_in_channels_rate(struct snd_pcm_hw_params *params,
4170 .max = hdsp->qs_in_channels, 4194 .max = hdsp->qs_in_channels,
4171 .integer = 1, 4195 .integer = 1,
4172 }; 4196 };
4173 return snd_interval_refine(c, &t); 4197 return snd_interval_refine(c, &t);
4174 } else if (r->min > 48000 && r->max <= 96000) { 4198 } else if (r->min > 48000 && r->max <= 96000) {
4175 struct snd_interval t = { 4199 struct snd_interval t = {
4176 .min = hdsp->ds_in_channels, 4200 .min = hdsp->ds_in_channels,
@@ -4201,7 +4225,7 @@ static int snd_hdsp_hw_rule_out_channels_rate(struct snd_pcm_hw_params *params,
4201 .max = hdsp->qs_out_channels, 4225 .max = hdsp->qs_out_channels,
4202 .integer = 1, 4226 .integer = 1,
4203 }; 4227 };
4204 return snd_interval_refine(c, &t); 4228 return snd_interval_refine(c, &t);
4205 } else if (r->min > 48000 && r->max <= 96000) { 4229 } else if (r->min > 48000 && r->max <= 96000) {
4206 struct snd_interval t = { 4230 struct snd_interval t = {
4207 .min = hdsp->ds_out_channels, 4231 .min = hdsp->ds_out_channels,
@@ -4318,8 +4342,8 @@ static int snd_hdsp_playback_open(struct snd_pcm_substream *substream)
4318 if (hdsp->io_type == H9632) { 4342 if (hdsp->io_type == H9632) {
4319 runtime->hw.channels_min = hdsp->qs_out_channels; 4343 runtime->hw.channels_min = hdsp->qs_out_channels;
4320 runtime->hw.channels_max = hdsp->ss_out_channels; 4344 runtime->hw.channels_max = hdsp->ss_out_channels;
4321 } 4345 }
4322 4346
4323 snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, 4347 snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
4324 snd_hdsp_hw_rule_out_channels, hdsp, 4348 snd_hdsp_hw_rule_out_channels, hdsp,
4325 SNDRV_PCM_HW_PARAM_CHANNELS, -1); 4349 SNDRV_PCM_HW_PARAM_CHANNELS, -1);
@@ -4529,7 +4553,7 @@ static int hdsp_get_peak(struct hdsp *hdsp, struct hdsp_peak_rms __user *peak_rm
4529 hdsp->iobase + HDSP_playbackRmsLevel + i * 8 + 4, 4553 hdsp->iobase + HDSP_playbackRmsLevel + i * 8 + 4,
4530 hdsp->iobase + HDSP_playbackRmsLevel + i * 8)) 4554 hdsp->iobase + HDSP_playbackRmsLevel + i * 8))
4531 return -EFAULT; 4555 return -EFAULT;
4532 if (copy_u64_le(&peak_rms->input_rms[i], 4556 if (copy_u64_le(&peak_rms->input_rms[i],
4533 hdsp->iobase + HDSP_inputRmsLevel + i * 8 + 4, 4557 hdsp->iobase + HDSP_inputRmsLevel + i * 8 + 4,
4534 hdsp->iobase + HDSP_inputRmsLevel + i * 8)) 4558 hdsp->iobase + HDSP_inputRmsLevel + i * 8))
4535 return -EFAULT; 4559 return -EFAULT;
@@ -4539,7 +4563,7 @@ static int hdsp_get_peak(struct hdsp *hdsp, struct hdsp_peak_rms __user *peak_rm
4539 4563
4540static int snd_hdsp_hwdep_ioctl(struct snd_hwdep *hw, struct file *file, unsigned int cmd, unsigned long arg) 4564static int snd_hdsp_hwdep_ioctl(struct snd_hwdep *hw, struct file *file, unsigned int cmd, unsigned long arg)
4541{ 4565{
4542 struct hdsp *hdsp = (struct hdsp *)hw->private_data; 4566 struct hdsp *hdsp = (struct hdsp *)hw->private_data;
4543 void __user *argp = (void __user *)arg; 4567 void __user *argp = (void __user *)arg;
4544 int err; 4568 int err;
4545 4569
@@ -4573,7 +4597,7 @@ static int snd_hdsp_hwdep_ioctl(struct snd_hwdep *hw, struct file *file, unsigne
4573 struct hdsp_config_info info; 4597 struct hdsp_config_info info;
4574 unsigned long flags; 4598 unsigned long flags;
4575 int i; 4599 int i;
4576 4600
4577 err = hdsp_check_for_iobox(hdsp); 4601 err = hdsp_check_for_iobox(hdsp);
4578 if (err < 0) 4602 if (err < 0)
4579 return err; 4603 return err;
@@ -4607,7 +4631,7 @@ static int snd_hdsp_hwdep_ioctl(struct snd_hwdep *hw, struct file *file, unsigne
4607 info.ad_gain = (unsigned char)hdsp_ad_gain(hdsp); 4631 info.ad_gain = (unsigned char)hdsp_ad_gain(hdsp);
4608 info.phone_gain = (unsigned char)hdsp_phone_gain(hdsp); 4632 info.phone_gain = (unsigned char)hdsp_phone_gain(hdsp);
4609 info.xlr_breakout_cable = (unsigned char)hdsp_xlr_breakout_cable(hdsp); 4633 info.xlr_breakout_cable = (unsigned char)hdsp_xlr_breakout_cable(hdsp);
4610 4634
4611 } 4635 }
4612 if (hdsp->io_type == H9632 || hdsp->io_type == H9652) 4636 if (hdsp->io_type == H9632 || hdsp->io_type == H9652)
4613 info.analog_extension_board = (unsigned char)hdsp_aeb(hdsp); 4637 info.analog_extension_board = (unsigned char)hdsp_aeb(hdsp);
@@ -4618,7 +4642,7 @@ static int snd_hdsp_hwdep_ioctl(struct snd_hwdep *hw, struct file *file, unsigne
4618 } 4642 }
4619 case SNDRV_HDSP_IOCTL_GET_9632_AEB: { 4643 case SNDRV_HDSP_IOCTL_GET_9632_AEB: {
4620 struct hdsp_9632_aeb h9632_aeb; 4644 struct hdsp_9632_aeb h9632_aeb;
4621 4645
4622 if (hdsp->io_type != H9632) return -EINVAL; 4646 if (hdsp->io_type != H9632) return -EINVAL;
4623 h9632_aeb.aebi = hdsp->ss_in_channels - H9632_SS_CHANNELS; 4647 h9632_aeb.aebi = hdsp->ss_in_channels - H9632_SS_CHANNELS;
4624 h9632_aeb.aebo = hdsp->ss_out_channels - H9632_SS_CHANNELS; 4648 h9632_aeb.aebo = hdsp->ss_out_channels - H9632_SS_CHANNELS;
@@ -4629,7 +4653,7 @@ static int snd_hdsp_hwdep_ioctl(struct snd_hwdep *hw, struct file *file, unsigne
4629 case SNDRV_HDSP_IOCTL_GET_VERSION: { 4653 case SNDRV_HDSP_IOCTL_GET_VERSION: {
4630 struct hdsp_version hdsp_version; 4654 struct hdsp_version hdsp_version;
4631 int err; 4655 int err;
4632 4656
4633 if (hdsp->io_type == H9652 || hdsp->io_type == H9632) return -EINVAL; 4657 if (hdsp->io_type == H9652 || hdsp->io_type == H9632) return -EINVAL;
4634 if (hdsp->io_type == Undefined) { 4658 if (hdsp->io_type == Undefined) {
4635 if ((err = hdsp_get_iobox_version(hdsp)) < 0) 4659 if ((err = hdsp_get_iobox_version(hdsp)) < 0)
@@ -4645,7 +4669,7 @@ static int snd_hdsp_hwdep_ioctl(struct snd_hwdep *hw, struct file *file, unsigne
4645 struct hdsp_firmware __user *firmware; 4669 struct hdsp_firmware __user *firmware;
4646 u32 __user *firmware_data; 4670 u32 __user *firmware_data;
4647 int err; 4671 int err;
4648 4672
4649 if (hdsp->io_type == H9652 || hdsp->io_type == H9632) return -EINVAL; 4673 if (hdsp->io_type == H9652 || hdsp->io_type == H9632) return -EINVAL;
4650 /* SNDRV_HDSP_IOCTL_GET_VERSION must have been called */ 4674 /* SNDRV_HDSP_IOCTL_GET_VERSION must have been called */
4651 if (hdsp->io_type == Undefined) return -EINVAL; 4675 if (hdsp->io_type == Undefined) return -EINVAL;
@@ -4658,25 +4682,25 @@ static int snd_hdsp_hwdep_ioctl(struct snd_hwdep *hw, struct file *file, unsigne
4658 4682
4659 if (get_user(firmware_data, &firmware->firmware_data)) 4683 if (get_user(firmware_data, &firmware->firmware_data))
4660 return -EFAULT; 4684 return -EFAULT;
4661 4685
4662 if (hdsp_check_for_iobox (hdsp)) 4686 if (hdsp_check_for_iobox (hdsp))
4663 return -EIO; 4687 return -EIO;
4664 4688
4665 if (copy_from_user(hdsp->firmware_cache, firmware_data, sizeof(hdsp->firmware_cache)) != 0) 4689 if (copy_from_user(hdsp->firmware_cache, firmware_data, sizeof(hdsp->firmware_cache)) != 0)
4666 return -EFAULT; 4690 return -EFAULT;
4667 4691
4668 hdsp->state |= HDSP_FirmwareCached; 4692 hdsp->state |= HDSP_FirmwareCached;
4669 4693
4670 if ((err = snd_hdsp_load_firmware_from_cache(hdsp)) < 0) 4694 if ((err = snd_hdsp_load_firmware_from_cache(hdsp)) < 0)
4671 return err; 4695 return err;
4672 4696
4673 if (!(hdsp->state & HDSP_InitializationComplete)) { 4697 if (!(hdsp->state & HDSP_InitializationComplete)) {
4674 if ((err = snd_hdsp_enable_io(hdsp)) < 0) 4698 if ((err = snd_hdsp_enable_io(hdsp)) < 0)
4675 return err; 4699 return err;
4676 4700
4677 snd_hdsp_initialize_channels(hdsp); 4701 snd_hdsp_initialize_channels(hdsp);
4678 snd_hdsp_initialize_midi_flush(hdsp); 4702 snd_hdsp_initialize_midi_flush(hdsp);
4679 4703
4680 if ((err = snd_hdsp_create_alsa_devices(hdsp->card, hdsp)) < 0) { 4704 if ((err = snd_hdsp_create_alsa_devices(hdsp->card, hdsp)) < 0) {
4681 snd_printk(KERN_ERR "Hammerfall-DSP: error creating alsa devices\n"); 4705 snd_printk(KERN_ERR "Hammerfall-DSP: error creating alsa devices\n");
4682 return err; 4706 return err;
@@ -4723,16 +4747,16 @@ static int snd_hdsp_create_hwdep(struct snd_card *card, struct hdsp *hdsp)
4723{ 4747{
4724 struct snd_hwdep *hw; 4748 struct snd_hwdep *hw;
4725 int err; 4749 int err;
4726 4750
4727 if ((err = snd_hwdep_new(card, "HDSP hwdep", 0, &hw)) < 0) 4751 if ((err = snd_hwdep_new(card, "HDSP hwdep", 0, &hw)) < 0)
4728 return err; 4752 return err;
4729 4753
4730 hdsp->hwdep = hw; 4754 hdsp->hwdep = hw;
4731 hw->private_data = hdsp; 4755 hw->private_data = hdsp;
4732 strcpy(hw->name, "HDSP hwdep interface"); 4756 strcpy(hw->name, "HDSP hwdep interface");
4733 4757
4734 hw->ops.ioctl = snd_hdsp_hwdep_ioctl; 4758 hw->ops.ioctl = snd_hdsp_hwdep_ioctl;
4735 4759
4736 return 0; 4760 return 0;
4737} 4761}
4738 4762
@@ -4765,24 +4789,24 @@ static void snd_hdsp_9652_enable_mixer (struct hdsp *hdsp)
4765static int snd_hdsp_enable_io (struct hdsp *hdsp) 4789static int snd_hdsp_enable_io (struct hdsp *hdsp)
4766{ 4790{
4767 int i; 4791 int i;
4768 4792
4769 if (hdsp_fifo_wait (hdsp, 0, 100)) { 4793 if (hdsp_fifo_wait (hdsp, 0, 100)) {
4770 snd_printk(KERN_ERR "Hammerfall-DSP: enable_io fifo_wait failed\n"); 4794 snd_printk(KERN_ERR "Hammerfall-DSP: enable_io fifo_wait failed\n");
4771 return -EIO; 4795 return -EIO;
4772 } 4796 }
4773 4797
4774 for (i = 0; i < hdsp->max_channels; ++i) { 4798 for (i = 0; i < hdsp->max_channels; ++i) {
4775 hdsp_write (hdsp, HDSP_inputEnable + (4 * i), 1); 4799 hdsp_write (hdsp, HDSP_inputEnable + (4 * i), 1);
4776 hdsp_write (hdsp, HDSP_outputEnable + (4 * i), 1); 4800 hdsp_write (hdsp, HDSP_outputEnable + (4 * i), 1);
4777 } 4801 }
4778 4802
4779 return 0; 4803 return 0;
4780} 4804}
4781 4805
4782static void snd_hdsp_initialize_channels(struct hdsp *hdsp) 4806static void snd_hdsp_initialize_channels(struct hdsp *hdsp)
4783{ 4807{
4784 int status, aebi_channels, aebo_channels; 4808 int status, aebi_channels, aebo_channels;
4785 4809
4786 switch (hdsp->io_type) { 4810 switch (hdsp->io_type) {
4787 case Digiface: 4811 case Digiface:
4788 hdsp->card_name = "RME Hammerfall DSP + Digiface"; 4812 hdsp->card_name = "RME Hammerfall DSP + Digiface";
@@ -4795,7 +4819,7 @@ static void snd_hdsp_initialize_channels(struct hdsp *hdsp)
4795 hdsp->ss_in_channels = hdsp->ss_out_channels = H9652_SS_CHANNELS; 4819 hdsp->ss_in_channels = hdsp->ss_out_channels = H9652_SS_CHANNELS;
4796 hdsp->ds_in_channels = hdsp->ds_out_channels = H9652_DS_CHANNELS; 4820 hdsp->ds_in_channels = hdsp->ds_out_channels = H9652_DS_CHANNELS;
4797 break; 4821 break;
4798 4822
4799 case H9632: 4823 case H9632:
4800 status = hdsp_read(hdsp, HDSP_statusRegister); 4824 status = hdsp_read(hdsp, HDSP_statusRegister);
4801 /* HDSP_AEBx bits are low when AEB are connected */ 4825 /* HDSP_AEBx bits are low when AEB are connected */
@@ -4815,7 +4839,7 @@ static void snd_hdsp_initialize_channels(struct hdsp *hdsp)
4815 hdsp->ss_in_channels = hdsp->ss_out_channels = MULTIFACE_SS_CHANNELS; 4839 hdsp->ss_in_channels = hdsp->ss_out_channels = MULTIFACE_SS_CHANNELS;
4816 hdsp->ds_in_channels = hdsp->ds_out_channels = MULTIFACE_DS_CHANNELS; 4840 hdsp->ds_in_channels = hdsp->ds_out_channels = MULTIFACE_DS_CHANNELS;
4817 break; 4841 break;
4818 4842
4819 default: 4843 default:
4820 /* should never get here */ 4844 /* should never get here */
4821 break; 4845 break;
@@ -4831,12 +4855,12 @@ static void snd_hdsp_initialize_midi_flush (struct hdsp *hdsp)
4831static int snd_hdsp_create_alsa_devices(struct snd_card *card, struct hdsp *hdsp) 4855static int snd_hdsp_create_alsa_devices(struct snd_card *card, struct hdsp *hdsp)
4832{ 4856{
4833 int err; 4857 int err;
4834 4858
4835 if ((err = snd_hdsp_create_pcm(card, hdsp)) < 0) { 4859 if ((err = snd_hdsp_create_pcm(card, hdsp)) < 0) {
4836 snd_printk(KERN_ERR "Hammerfall-DSP: Error creating pcm interface\n"); 4860 snd_printk(KERN_ERR "Hammerfall-DSP: Error creating pcm interface\n");
4837 return err; 4861 return err;
4838 } 4862 }
4839 4863
4840 4864
4841 if ((err = snd_hdsp_create_midi(card, hdsp, 0)) < 0) { 4865 if ((err = snd_hdsp_create_midi(card, hdsp, 0)) < 0) {
4842 snd_printk(KERN_ERR "Hammerfall-DSP: Error creating first midi interface\n"); 4866 snd_printk(KERN_ERR "Hammerfall-DSP: Error creating first midi interface\n");
@@ -4867,19 +4891,19 @@ static int snd_hdsp_create_alsa_devices(struct snd_card *card, struct hdsp *hdsp
4867 snd_printk(KERN_ERR "Hammerfall-DSP: Error setting default values\n"); 4891 snd_printk(KERN_ERR "Hammerfall-DSP: Error setting default values\n");
4868 return err; 4892 return err;
4869 } 4893 }
4870 4894
4871 if (!(hdsp->state & HDSP_InitializationComplete)) { 4895 if (!(hdsp->state & HDSP_InitializationComplete)) {
4872 strcpy(card->shortname, "Hammerfall DSP"); 4896 strcpy(card->shortname, "Hammerfall DSP");
4873 sprintf(card->longname, "%s at 0x%lx, irq %d", hdsp->card_name, 4897 sprintf(card->longname, "%s at 0x%lx, irq %d", hdsp->card_name,
4874 hdsp->port, hdsp->irq); 4898 hdsp->port, hdsp->irq);
4875 4899
4876 if ((err = snd_card_register(card)) < 0) { 4900 if ((err = snd_card_register(card)) < 0) {
4877 snd_printk(KERN_ERR "Hammerfall-DSP: error registering card\n"); 4901 snd_printk(KERN_ERR "Hammerfall-DSP: error registering card\n");
4878 return err; 4902 return err;
4879 } 4903 }
4880 hdsp->state |= HDSP_InitializationComplete; 4904 hdsp->state |= HDSP_InitializationComplete;
4881 } 4905 }
4882 4906
4883 return 0; 4907 return 0;
4884} 4908}
4885 4909
@@ -4890,7 +4914,7 @@ static int hdsp_request_fw_loader(struct hdsp *hdsp)
4890 const char *fwfile; 4914 const char *fwfile;
4891 const struct firmware *fw; 4915 const struct firmware *fw;
4892 int err; 4916 int err;
4893 4917
4894 if (hdsp->io_type == H9652 || hdsp->io_type == H9632) 4918 if (hdsp->io_type == H9652 || hdsp->io_type == H9632)
4895 return 0; 4919 return 0;
4896 if (hdsp->io_type == Undefined) { 4920 if (hdsp->io_type == Undefined) {
@@ -4899,7 +4923,7 @@ static int hdsp_request_fw_loader(struct hdsp *hdsp)
4899 if (hdsp->io_type == H9652 || hdsp->io_type == H9632) 4923 if (hdsp->io_type == H9652 || hdsp->io_type == H9632)
4900 return 0; 4924 return 0;
4901 } 4925 }
4902 4926
4903 /* caution: max length of firmware filename is 30! */ 4927 /* caution: max length of firmware filename is 30! */
4904 switch (hdsp->io_type) { 4928 switch (hdsp->io_type) {
4905 case Multiface: 4929 case Multiface:
@@ -4933,12 +4957,12 @@ static int hdsp_request_fw_loader(struct hdsp *hdsp)
4933 memcpy(hdsp->firmware_cache, fw->data, sizeof(hdsp->firmware_cache)); 4957 memcpy(hdsp->firmware_cache, fw->data, sizeof(hdsp->firmware_cache));
4934 4958
4935 release_firmware(fw); 4959 release_firmware(fw);
4936 4960
4937 hdsp->state |= HDSP_FirmwareCached; 4961 hdsp->state |= HDSP_FirmwareCached;
4938 4962
4939 if ((err = snd_hdsp_load_firmware_from_cache(hdsp)) < 0) 4963 if ((err = snd_hdsp_load_firmware_from_cache(hdsp)) < 0)
4940 return err; 4964 return err;
4941 4965
4942 if (!(hdsp->state & HDSP_InitializationComplete)) { 4966 if (!(hdsp->state & HDSP_InitializationComplete)) {
4943 if ((err = snd_hdsp_enable_io(hdsp)) < 0) 4967 if ((err = snd_hdsp_enable_io(hdsp)) < 0)
4944 return err; 4968 return err;
@@ -4985,14 +5009,14 @@ static int __devinit snd_hdsp_create(struct snd_card *card,
4985 hdsp->max_channels = 26; 5009 hdsp->max_channels = 26;
4986 5010
4987 hdsp->card = card; 5011 hdsp->card = card;
4988 5012
4989 spin_lock_init(&hdsp->lock); 5013 spin_lock_init(&hdsp->lock);
4990 5014
4991 tasklet_init(&hdsp->midi_tasklet, hdsp_midi_tasklet, (unsigned long)hdsp); 5015 tasklet_init(&hdsp->midi_tasklet, hdsp_midi_tasklet, (unsigned long)hdsp);
4992 5016
4993 pci_read_config_word(hdsp->pci, PCI_CLASS_REVISION, &hdsp->firmware_rev); 5017 pci_read_config_word(hdsp->pci, PCI_CLASS_REVISION, &hdsp->firmware_rev);
4994 hdsp->firmware_rev &= 0xff; 5018 hdsp->firmware_rev &= 0xff;
4995 5019
4996 /* From Martin Bjoernsen : 5020 /* From Martin Bjoernsen :
4997 "It is important that the card's latency timer register in 5021 "It is important that the card's latency timer register in
4998 the PCI configuration space is set to a value much larger 5022 the PCI configuration space is set to a value much larger
@@ -5001,7 +5025,7 @@ static int __devinit snd_hdsp_create(struct snd_card *card,
5001 to its maximum 255 to avoid problems with some computers." 5025 to its maximum 255 to avoid problems with some computers."
5002 */ 5026 */
5003 pci_write_config_byte(hdsp->pci, PCI_LATENCY_TIMER, 0xFF); 5027 pci_write_config_byte(hdsp->pci, PCI_LATENCY_TIMER, 0xFF);
5004 5028
5005 strcpy(card->driver, "H-DSP"); 5029 strcpy(card->driver, "H-DSP");
5006 strcpy(card->mixername, "Xilinx FPGA"); 5030 strcpy(card->mixername, "Xilinx FPGA");
5007 5031
@@ -5015,7 +5039,7 @@ static int __devinit snd_hdsp_create(struct snd_card *card,
5015 } else { 5039 } else {
5016 hdsp->card_name = "RME HDSP 9632"; 5040 hdsp->card_name = "RME HDSP 9632";
5017 hdsp->max_channels = 16; 5041 hdsp->max_channels = 16;
5018 is_9632 = 1; 5042 is_9632 = 1;
5019 } 5043 }
5020 5044
5021 if ((err = pci_enable_device(pci)) < 0) 5045 if ((err = pci_enable_device(pci)) < 0)
@@ -5044,12 +5068,12 @@ static int __devinit snd_hdsp_create(struct snd_card *card,
5044 5068
5045 if ((err = snd_hdsp_initialize_memory(hdsp)) < 0) 5069 if ((err = snd_hdsp_initialize_memory(hdsp)) < 0)
5046 return err; 5070 return err;
5047 5071
5048 if (!is_9652 && !is_9632) { 5072 if (!is_9652 && !is_9632) {
5049 /* we wait 2 seconds to let freshly inserted cardbus cards do their hardware init */ 5073 /* we wait a maximum of 10 seconds to let freshly
5050 ssleep(2); 5074 * inserted cardbus cards do their hardware init */
5075 err = hdsp_wait_for_iobox(hdsp, 1000, 10);
5051 5076
5052 err = hdsp_check_for_iobox(hdsp);
5053 if (err < 0) 5077 if (err < 0)
5054 return err; 5078 return err;
5055 5079
@@ -5071,35 +5095,35 @@ static int __devinit snd_hdsp_create(struct snd_card *card,
5071 return err; 5095 return err;
5072 return 0; 5096 return 0;
5073 } else { 5097 } else {
5074 snd_printk(KERN_INFO "Hammerfall-DSP: Firmware already present, initializing card.\n"); 5098 snd_printk(KERN_INFO "Hammerfall-DSP: Firmware already present, initializing card.\n");
5075 if (hdsp_read(hdsp, HDSP_status2Register) & HDSP_version1) 5099 if (hdsp_read(hdsp, HDSP_status2Register) & HDSP_version1)
5076 hdsp->io_type = Multiface; 5100 hdsp->io_type = Multiface;
5077 else 5101 else
5078 hdsp->io_type = Digiface; 5102 hdsp->io_type = Digiface;
5079 } 5103 }
5080 } 5104 }
5081 5105
5082 if ((err = snd_hdsp_enable_io(hdsp)) != 0) 5106 if ((err = snd_hdsp_enable_io(hdsp)) != 0)
5083 return err; 5107 return err;
5084 5108
5085 if (is_9652) 5109 if (is_9652)
5086 hdsp->io_type = H9652; 5110 hdsp->io_type = H9652;
5087 5111
5088 if (is_9632) 5112 if (is_9632)
5089 hdsp->io_type = H9632; 5113 hdsp->io_type = H9632;
5090 5114
5091 if ((err = snd_hdsp_create_hwdep(card, hdsp)) < 0) 5115 if ((err = snd_hdsp_create_hwdep(card, hdsp)) < 0)
5092 return err; 5116 return err;
5093 5117
5094 snd_hdsp_initialize_channels(hdsp); 5118 snd_hdsp_initialize_channels(hdsp);
5095 snd_hdsp_initialize_midi_flush(hdsp); 5119 snd_hdsp_initialize_midi_flush(hdsp);
5096 5120
5097 hdsp->state |= HDSP_FirmwareLoaded; 5121 hdsp->state |= HDSP_FirmwareLoaded;
5098 5122
5099 if ((err = snd_hdsp_create_alsa_devices(card, hdsp)) < 0) 5123 if ((err = snd_hdsp_create_alsa_devices(card, hdsp)) < 0)
5100 return err; 5124 return err;
5101 5125
5102 return 0; 5126 return 0;
5103} 5127}
5104 5128
5105static int snd_hdsp_free(struct hdsp *hdsp) 5129static int snd_hdsp_free(struct hdsp *hdsp)
@@ -5115,13 +5139,13 @@ static int snd_hdsp_free(struct hdsp *hdsp)
5115 free_irq(hdsp->irq, (void *)hdsp); 5139 free_irq(hdsp->irq, (void *)hdsp);
5116 5140
5117 snd_hdsp_free_buffers(hdsp); 5141 snd_hdsp_free_buffers(hdsp);
5118 5142
5119 if (hdsp->iobase) 5143 if (hdsp->iobase)
5120 iounmap(hdsp->iobase); 5144 iounmap(hdsp->iobase);
5121 5145
5122 if (hdsp->port) 5146 if (hdsp->port)
5123 pci_release_regions(hdsp->pci); 5147 pci_release_regions(hdsp->pci);
5124 5148
5125 pci_disable_device(hdsp->pci); 5149 pci_disable_device(hdsp->pci);
5126 return 0; 5150 return 0;
5127} 5151}
@@ -5166,7 +5190,7 @@ static int __devinit snd_hdsp_probe(struct pci_dev *pci,
5166 } 5190 }
5167 5191
5168 strcpy(card->shortname, "Hammerfall DSP"); 5192 strcpy(card->shortname, "Hammerfall DSP");
5169 sprintf(card->longname, "%s at 0x%lx, irq %d", hdsp->card_name, 5193 sprintf(card->longname, "%s at 0x%lx, irq %d", hdsp->card_name,
5170 hdsp->port, hdsp->irq); 5194 hdsp->port, hdsp->irq);
5171 5195
5172 if ((err = snd_card_register(card)) < 0) { 5196 if ((err = snd_card_register(card)) < 0) {