Lines Matching +full:fpga +full:- +full:slave +full:- +full:serial

1 // SPDX-License-Identifier: GPL-2.0-or-later
9 * Modified 2006-06-01 for AES32 support by Remy Bruno
12 * Modified 2009-04-13 for proper metering by Florian Faber
15 * Modified 2009-04-14 for native float support by Florian Faber
18 * Modified 2009-04-26 fixed bug in rms metering by Florian Faber
21 * Modified 2009-04-30 added hw serial number support by Florian Faber
23 * Modified 2011-01-14 added S/PDIF input on RayDATs by Adrian Knoth
25 * Modified 2011-01-25 variable period sizes on RayDAT/AIO by Adrian Knoth
27 * Modified 2019-05-23 fix AIO single speed ADAT capture and playback
35 * --------- HDSPM_controlRegister ---------
44 * : . : . : . : x. : HDSPM_ClockModeMaster - 1: Master, 0: Slave
45 * : . : . : . : .210 : HDSPM_LatencyMask - 3 Bit value for latency
94 * ------------ HDSPM_WR_SETTINGS ----------
101 * : . : . : . : . x: HDSPM_c0Master 1: Master, 0: Slave
143 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
169 /* --- Write registers. ---
170 These are defined as byte-offsets from the iobase value. */
184 #define HDSPM_outputEnableBase 512 /* 512-767 input DMA */
185 #define HDSPM_inputEnableBase 768 /* 768-1023 output DMA */
192 #define HDSPM_MADI_mixerBase 32768 /* 32768-65535 for 2x64x64 Fader */
196 /* --- Read registers. ---
197 These are defined as byte-offsets from the iobase value */
200 /* after RME Windows driver sources, status2 is 4-byte word # 48 = word at
256 /* status is data bytes in MIDI-FIFO (0-128) */
267 /* the meters are regular i/o-mapped registers, but offset
269 when read; the least-significant 4 bits are full-scale counters;
270 the actual peak value is in the most-significant 24 bits.
285 /* --- Control Register bits --------- */
313 * -- MADI ONLY
360 /* --- bit helper defines */
378 #define HDSPM_SYNC_FROM_MADI 1 /* choices - used by "pref_sync_ref" */
400 /* AutoSync References - used by "autosync_ref" control switch */
417 /* --- control2 register bits --- */
430 /* --- Status Register bits --- */ /* MADI ONLY */ /* Bits defined here and
478 /* --- status bit helpers */
568 /* HDSPM_LockAES_bit is given by HDSPM_LockAES >> (AES# - 1) */
816 -1, -1, -1, -1,
817 -1, -1, -1, -1, -1, -1, -1, -1,
818 -1, -1, -1, -1, -1, -1, -1, -1,
819 -1, -1, -1, -1, -1, -1, -1, -1,
829 -1, -1, -1, -1,
830 -1, -1, -1, -1, -1, -1, -1, -1,
831 -1, -1, -1, -1, -1, -1, -1, -1,
832 -1, -1, -1, -1, -1, -1, -1, -1,
833 -1, -1, -1, -1, -1, -1, -1, -1,
834 -1, -1, -1, -1, -1, -1, -1, -1,
844 -1, -1, -1, -1,
845 -1, -1, -1, -1, -1, -1, -1, -1,
846 -1, -1, -1, -1, -1, -1, -1, -1,
847 -1, -1, -1, -1, -1, -1, -1, -1,
848 -1, -1, -1, -1, -1, -1, -1, -1,
849 -1, -1, -1, -1, -1, -1, -1, -1,
850 -1, -1, -1, -1, -1, -1, -1, -1,
859 -1, -1, -1, -1, -1, -1,
860 -1, -1, -1, -1, -1, -1, -1, -1,
861 -1, -1, -1, -1, -1, -1, -1, -1,
862 -1, -1, -1, -1, -1, -1, -1, -1,
863 -1, -1, -1, -1, -1, -1, -1, -1,
864 -1, -1, -1, -1, -1, -1, -1, -1,
874 -1, -1, -1, -1,
875 -1, -1, -1, -1, -1, -1, -1, -1,
876 -1, -1, -1, -1, -1, -1, -1, -1,
877 -1, -1, -1, -1, -1, -1, -1, -1,
878 -1, -1, -1, -1, -1, -1, -1, -1,
879 -1, -1, -1, -1, -1, -1, -1, -1,
888 -1, -1,
889 -1, -1, -1, -1, -1, -1, -1, -1,
890 -1, -1, -1, -1, -1, -1, -1, -1,
891 -1, -1, -1, -1, -1, -1, -1, -1,
892 -1, -1, -1, -1, -1, -1, -1, -1,
893 -1, -1, -1, -1, -1, -1, -1, -1,
894 -1, -1, -1, -1, -1, -1, -1, -1
904 -1, -1, -1, -1, -1, -1, -1, -1,
905 -1, -1, -1, -1, -1, -1, -1, -1,
906 -1, -1, -1, -1, -1, -1, -1, -1,
907 -1, -1, -1, -1, -1, -1, -1, -1,
908 -1, -1, -1, -1, -1, -1, -1, -1,
909 -1, -1, -1, -1, -1, -1, -1, -1
918 -1, -1, -1, -1,
919 -1, -1, -1, -1, -1, -1, -1, -1,
920 -1, -1, -1, -1, -1, -1, -1, -1,
921 -1, -1, -1, -1, -1, -1, -1, -1,
922 -1, -1, -1, -1, -1, -1, -1, -1,
923 -1, -1, -1, -1, -1, -1, -1, -1,
924 -1, -1, -1, -1, -1, -1, -1, -1
934 -1, -1,
935 -1, -1, -1, -1, -1, -1, -1, -1,
936 -1, -1, -1, -1, -1, -1, -1, -1,
937 -1, -1, -1, -1, -1, -1, -1, -1,
938 -1, -1, -1, -1, -1, -1, -1, -1,
939 -1, -1, -1, -1, -1, -1, -1, -1,
940 -1, -1, -1, -1, -1, -1, -1, -1
946 -1, -1, -1, -1, -1, -1, -1, -1,
947 -1, -1, -1, -1, -1, -1, -1, -1,
948 -1, -1, -1, -1, -1, -1, -1, -1,
949 -1, -1, -1, -1, -1, -1, -1, -1,
950 -1, -1, -1, -1, -1, -1, -1, -1,
951 -1, -1, -1, -1, -1, -1, -1, -1
975 int wordclock; /* 0=1:1, 1=44.1->48, 2=48->44.1 */
977 int pull; /* 0=0, 1=+0.1%, 2=-0.1%, 3=+4%, 4=-4%*/
996 u32 settings_register; /* cached value for AIO / RayDat (sync reference, master/slave) */
1057 /* full mixer accessible over mixer ioctl or hwdep-device */
1067 unsigned int serial; member
1127 return ((AIO == hdspm->io_type) || (RayDAT == hdspm->io_type)); in hdspm_is_raydat_or_aio()
1137 writel(val, hdspm->iobase + reg); in hdspm_write()
1142 return readl(hdspm->iobase + reg); in hdspm_read()
1155 return hdspm->mixer->ch[chan].in[in]; in hdspm_read_in_gain()
1163 return hdspm->mixer->ch[chan].pb[pb]; in hdspm_read_pb_gain()
1170 return -1; in hdspm_write_in_gain()
1175 (hdspm->mixer->ch[chan].in[in] = data & 0xFFFF)); in hdspm_write_in_gain()
1183 return -1; in hdspm_write_pb_gain()
1188 (hdspm->mixer->ch[chan].pb[pb] = data & 0xFFFF)); in hdspm_write_pb_gain()
1193 /* enable DMA for specific channels, now available for DSP-MADI */
1210 spin_lock_irqsave(&hdspm->lock, flags); in snd_hdspm_use_is_exclusive()
1211 if ((hdspm->playback_pid != hdspm->capture_pid) && in snd_hdspm_use_is_exclusive()
1212 (hdspm->playback_pid >= 0) && (hdspm->capture_pid >= 0)) { in snd_hdspm_use_is_exclusive()
1215 spin_unlock_irqrestore(&hdspm->lock, flags); in snd_hdspm_use_is_exclusive()
1235 * user-provided DS/QS bits in the control register
1241 if (hdspm->control_register & HDSPM_QuadSpeed) in hdspm_rate_multiplier()
1243 else if (hdspm->control_register & in hdspm_rate_multiplier()
1256 switch (hdspm->io_type) { in hdspm_external_sample_rate()
1278 if (hdspm_aes_sync_check(hdspm, syncref - HDSPM_AES32_AUTOSYNC_FROM_AES1)) in hdspm_external_sample_rate()
1280 syncref - HDSPM_AES32_AUTOSYNC_FROM_AES1)); in hdspm_external_sample_rate()
1455 n = hdspm_decode_latency(hdspm->control_register); in hdspm_get_latency()
1464 if ((7 == n) && (RayDAT == hdspm->io_type || AIO == hdspm->io_type)) in hdspm_get_latency()
1465 n = -1; in hdspm_get_latency()
1473 hdspm->period_bytes = 4 * hdspm_get_latency(hdspm); in hdspm_compute_period_size()
1483 switch (hdspm->io_type) { in hdspm_hw_pointer()
1491 (hdspm->period_bytes / 4) : 0; in hdspm_hw_pointer()
1500 s->control_register |= (HDSPM_AudioInterruptEnable | HDSPM_Start); in hdspm_start_audio()
1501 hdspm_write(s, HDSPM_controlRegister, s->control_register); in hdspm_start_audio()
1506 s->control_register &= ~(HDSPM_Start | HDSPM_AudioInterruptEnable); in hdspm_stop_audio()
1507 hdspm_write(s, HDSPM_controlRegister, s->control_register); in hdspm_stop_audio()
1514 int n = hdspm->period_bytes; in hdspm_silence_playback()
1515 void *buf = hdspm->playback_buffer; in hdspm_silence_playback()
1530 spin_lock_irq(&s->lock); in hdspm_set_interrupt_interval()
1553 s->control_register &= ~HDSPM_LatencyMask; in hdspm_set_interrupt_interval()
1554 s->control_register |= hdspm_encode_latency(n); in hdspm_set_interrupt_interval()
1556 hdspm_write(s, HDSPM_controlRegister, s->control_register); in hdspm_set_interrupt_interval()
1560 spin_unlock_irq(&s->lock); in hdspm_set_interrupt_interval()
1572 switch (hdspm->io_type) { in hdspm_calc_dds_value()
1605 switch (hdspm->io_type) { in hdspm_set_dds_value()
1636 /* ASSUMPTION: hdspm->lock is either set, or there is no need for in hdspm_set_rate()
1640 if (!(hdspm->control_register & HDSPM_ClockModeMaster)) { in hdspm_set_rate()
1642 /* SLAVE --- */ in hdspm_set_rate()
1649 dev_warn(hdspm->card->dev, in hdspm_set_rate()
1661 dev_warn(hdspm->card->dev, in hdspm_set_rate()
1667 dev_warn(hdspm->card->dev, in hdspm_set_rate()
1674 current_rate = hdspm->system_sample_rate; in hdspm_set_rate()
1682 externally-driven rate changes. All we can do is to flag rate in hdspm_set_rate()
1729 return -EINVAL; in hdspm_set_rate()
1733 && (hdspm->capture_pid >= 0 || hdspm->playback_pid >= 0)) { in hdspm_set_rate()
1734 dev_err(hdspm->card->dev, in hdspm_set_rate()
1738 hdspm->capture_pid, hdspm->playback_pid); in hdspm_set_rate()
1739 return -EBUSY; in hdspm_set_rate()
1742 hdspm->control_register &= ~HDSPM_FrequencyMask; in hdspm_set_rate()
1743 hdspm->control_register |= rate_bits; in hdspm_set_rate()
1744 hdspm_write(hdspm, HDSPM_controlRegister, hdspm->control_register); in hdspm_set_rate()
1750 if (AES32 == hdspm->io_type && rate != current_rate) in hdspm_set_rate()
1753 hdspm->system_sample_rate = rate; in hdspm_set_rate()
1756 hdspm->channel_map_in = hdspm->channel_map_in_ss; in hdspm_set_rate()
1757 hdspm->channel_map_out = hdspm->channel_map_out_ss; in hdspm_set_rate()
1758 hdspm->max_channels_in = hdspm->ss_in_channels; in hdspm_set_rate()
1759 hdspm->max_channels_out = hdspm->ss_out_channels; in hdspm_set_rate()
1760 hdspm->port_names_in = hdspm->port_names_in_ss; in hdspm_set_rate()
1761 hdspm->port_names_out = hdspm->port_names_out_ss; in hdspm_set_rate()
1763 hdspm->channel_map_in = hdspm->channel_map_in_ds; in hdspm_set_rate()
1764 hdspm->channel_map_out = hdspm->channel_map_out_ds; in hdspm_set_rate()
1765 hdspm->max_channels_in = hdspm->ds_in_channels; in hdspm_set_rate()
1766 hdspm->max_channels_out = hdspm->ds_out_channels; in hdspm_set_rate()
1767 hdspm->port_names_in = hdspm->port_names_in_ds; in hdspm_set_rate()
1768 hdspm->port_names_out = hdspm->port_names_out_ds; in hdspm_set_rate()
1770 hdspm->channel_map_in = hdspm->channel_map_in_qs; in hdspm_set_rate()
1771 hdspm->channel_map_out = hdspm->channel_map_out_qs; in hdspm_set_rate()
1772 hdspm->max_channels_in = hdspm->qs_in_channels; in hdspm_set_rate()
1773 hdspm->max_channels_out = hdspm->qs_out_channels; in hdspm_set_rate()
1774 hdspm->port_names_in = hdspm->port_names_in_qs; in hdspm_set_rate()
1775 hdspm->port_names_out = hdspm->port_names_out_qs; in hdspm_set_rate()
1779 return -1; in hdspm_set_rate()
1804 /*----------------------------------------------------------------------------
1806 ----------------------------------------------------------------------------*/
1811 /* the hardware already does the relevant bit-mask with 0xff */ in snd_hdspm_midi_read_byte()
1812 return hdspm_read(hdspm, hdspm->midi[id].dataIn); in snd_hdspm_midi_read_byte()
1818 /* the hardware already does the relevant bit-mask with 0xff */ in snd_hdspm_midi_write_byte()
1819 return hdspm_write(hdspm, hdspm->midi[id].dataOut, val); in snd_hdspm_midi_write_byte()
1824 return hdspm_read(hdspm, hdspm->midi[id].statusIn) & 0xFF; in snd_hdspm_midi_input_available()
1831 fifo_bytes_used = hdspm_read(hdspm, hdspm->midi[id].statusOut) & 0xFF; in snd_hdspm_midi_output_possible()
1834 return 128 - fifo_bytes_used; in snd_hdspm_midi_output_possible()
1843 while (snd_hdspm_midi_input_available(hdspm, id) && --count) in snd_hdspm_flush_midi_input()
1857 spin_lock_irqsave (&hmidi->lock, flags); in snd_hdspm_midi_output_write()
1858 if (hmidi->output && in snd_hdspm_midi_output_write()
1859 !snd_rawmidi_transmit_empty (hmidi->output)) { in snd_hdspm_midi_output_write()
1860 n_pending = snd_hdspm_midi_output_possible (hmidi->hdspm, in snd_hdspm_midi_output_write()
1861 hmidi->id); in snd_hdspm_midi_output_write()
1866 to_write = snd_rawmidi_transmit (hmidi->output, buf, in snd_hdspm_midi_output_write()
1870 snd_hdspm_midi_write_byte (hmidi->hdspm, in snd_hdspm_midi_output_write()
1871 hmidi->id, in snd_hdspm_midi_output_write()
1876 spin_unlock_irqrestore (&hmidi->lock, flags); in snd_hdspm_midi_output_write()
1889 spin_lock_irqsave (&hmidi->lock, flags); in snd_hdspm_midi_input_read()
1890 n_pending = snd_hdspm_midi_input_available (hmidi->hdspm, hmidi->id); in snd_hdspm_midi_input_read()
1892 if (hmidi->input) { in snd_hdspm_midi_input_read()
1896 buf[i] = snd_hdspm_midi_read_byte (hmidi->hdspm, in snd_hdspm_midi_input_read()
1897 hmidi->id); in snd_hdspm_midi_input_read()
1899 snd_rawmidi_receive (hmidi->input, buf, in snd_hdspm_midi_input_read()
1903 while (n_pending--) in snd_hdspm_midi_input_read()
1904 snd_hdspm_midi_read_byte (hmidi->hdspm, in snd_hdspm_midi_input_read()
1905 hmidi->id); in snd_hdspm_midi_input_read()
1908 hmidi->pending = 0; in snd_hdspm_midi_input_read()
1909 spin_unlock_irqrestore(&hmidi->lock, flags); in snd_hdspm_midi_input_read()
1911 spin_lock_irqsave(&hmidi->hdspm->lock, flags); in snd_hdspm_midi_input_read()
1912 hmidi->hdspm->control_register |= hmidi->ie; in snd_hdspm_midi_input_read()
1913 hdspm_write(hmidi->hdspm, HDSPM_controlRegister, in snd_hdspm_midi_input_read()
1914 hmidi->hdspm->control_register); in snd_hdspm_midi_input_read()
1915 spin_unlock_irqrestore(&hmidi->hdspm->lock, flags); in snd_hdspm_midi_input_read()
1927 hmidi = substream->rmidi->private_data; in snd_hdspm_midi_input_trigger()
1928 hdspm = hmidi->hdspm; in snd_hdspm_midi_input_trigger()
1930 spin_lock_irqsave (&hdspm->lock, flags); in snd_hdspm_midi_input_trigger()
1932 if (!(hdspm->control_register & hmidi->ie)) { in snd_hdspm_midi_input_trigger()
1933 snd_hdspm_flush_midi_input (hdspm, hmidi->id); in snd_hdspm_midi_input_trigger()
1934 hdspm->control_register |= hmidi->ie; in snd_hdspm_midi_input_trigger()
1937 hdspm->control_register &= ~hmidi->ie; in snd_hdspm_midi_input_trigger()
1940 hdspm_write(hdspm, HDSPM_controlRegister, hdspm->control_register); in snd_hdspm_midi_input_trigger()
1941 spin_unlock_irqrestore (&hdspm->lock, flags); in snd_hdspm_midi_input_trigger()
1950 spin_lock_irqsave (&hmidi->lock, flags); in snd_hdspm_midi_output_timer()
1952 /* this does not bump hmidi->istimer, because the in snd_hdspm_midi_output_timer()
1958 if (hmidi->istimer) in snd_hdspm_midi_output_timer()
1959 mod_timer(&hmidi->timer, 1 + jiffies); in snd_hdspm_midi_output_timer()
1961 spin_unlock_irqrestore (&hmidi->lock, flags); in snd_hdspm_midi_output_timer()
1970 hmidi = substream->rmidi->private_data; in snd_hdspm_midi_output_trigger()
1971 spin_lock_irqsave (&hmidi->lock, flags); in snd_hdspm_midi_output_trigger()
1973 if (!hmidi->istimer) { in snd_hdspm_midi_output_trigger()
1974 timer_setup(&hmidi->timer, in snd_hdspm_midi_output_trigger()
1976 mod_timer(&hmidi->timer, 1 + jiffies); in snd_hdspm_midi_output_trigger()
1977 hmidi->istimer++; in snd_hdspm_midi_output_trigger()
1980 if (hmidi->istimer && --hmidi->istimer <= 0) in snd_hdspm_midi_output_trigger()
1981 del_timer (&hmidi->timer); in snd_hdspm_midi_output_trigger()
1983 spin_unlock_irqrestore (&hmidi->lock, flags); in snd_hdspm_midi_output_trigger()
1992 hmidi = substream->rmidi->private_data; in snd_hdspm_midi_input_open()
1993 spin_lock_irq (&hmidi->lock); in snd_hdspm_midi_input_open()
1994 snd_hdspm_flush_midi_input (hmidi->hdspm, hmidi->id); in snd_hdspm_midi_input_open()
1995 hmidi->input = substream; in snd_hdspm_midi_input_open()
1996 spin_unlock_irq (&hmidi->lock); in snd_hdspm_midi_input_open()
2005 hmidi = substream->rmidi->private_data; in snd_hdspm_midi_output_open()
2006 spin_lock_irq (&hmidi->lock); in snd_hdspm_midi_output_open()
2007 hmidi->output = substream; in snd_hdspm_midi_output_open()
2008 spin_unlock_irq (&hmidi->lock); in snd_hdspm_midi_output_open()
2019 hmidi = substream->rmidi->private_data; in snd_hdspm_midi_input_close()
2020 spin_lock_irq (&hmidi->lock); in snd_hdspm_midi_input_close()
2021 hmidi->input = NULL; in snd_hdspm_midi_input_close()
2022 spin_unlock_irq (&hmidi->lock); in snd_hdspm_midi_input_close()
2033 hmidi = substream->rmidi->private_data; in snd_hdspm_midi_output_close()
2034 spin_lock_irq (&hmidi->lock); in snd_hdspm_midi_output_close()
2035 hmidi->output = NULL; in snd_hdspm_midi_output_close()
2036 spin_unlock_irq (&hmidi->lock); in snd_hdspm_midi_output_close()
2061 hdspm->midi[id].id = id; in snd_hdspm_create_midi()
2062 hdspm->midi[id].hdspm = hdspm; in snd_hdspm_create_midi()
2063 spin_lock_init (&hdspm->midi[id].lock); in snd_hdspm_create_midi()
2066 if (MADIface == hdspm->io_type) { in snd_hdspm_create_midi()
2067 /* MIDI-over-MADI on HDSPe MADIface */ in snd_hdspm_create_midi()
2068 hdspm->midi[0].dataIn = HDSPM_midiDataIn2; in snd_hdspm_create_midi()
2069 hdspm->midi[0].statusIn = HDSPM_midiStatusIn2; in snd_hdspm_create_midi()
2070 hdspm->midi[0].dataOut = HDSPM_midiDataOut2; in snd_hdspm_create_midi()
2071 hdspm->midi[0].statusOut = HDSPM_midiStatusOut2; in snd_hdspm_create_midi()
2072 hdspm->midi[0].ie = HDSPM_Midi2InterruptEnable; in snd_hdspm_create_midi()
2073 hdspm->midi[0].irq = HDSPM_midi2IRQPending; in snd_hdspm_create_midi()
2075 hdspm->midi[0].dataIn = HDSPM_midiDataIn0; in snd_hdspm_create_midi()
2076 hdspm->midi[0].statusIn = HDSPM_midiStatusIn0; in snd_hdspm_create_midi()
2077 hdspm->midi[0].dataOut = HDSPM_midiDataOut0; in snd_hdspm_create_midi()
2078 hdspm->midi[0].statusOut = HDSPM_midiStatusOut0; in snd_hdspm_create_midi()
2079 hdspm->midi[0].ie = HDSPM_Midi0InterruptEnable; in snd_hdspm_create_midi()
2080 hdspm->midi[0].irq = HDSPM_midi0IRQPending; in snd_hdspm_create_midi()
2083 hdspm->midi[1].dataIn = HDSPM_midiDataIn1; in snd_hdspm_create_midi()
2084 hdspm->midi[1].statusIn = HDSPM_midiStatusIn1; in snd_hdspm_create_midi()
2085 hdspm->midi[1].dataOut = HDSPM_midiDataOut1; in snd_hdspm_create_midi()
2086 hdspm->midi[1].statusOut = HDSPM_midiStatusOut1; in snd_hdspm_create_midi()
2087 hdspm->midi[1].ie = HDSPM_Midi1InterruptEnable; in snd_hdspm_create_midi()
2088 hdspm->midi[1].irq = HDSPM_midi1IRQPending; in snd_hdspm_create_midi()
2089 } else if ((2 == id) && (MADI == hdspm->io_type)) { in snd_hdspm_create_midi()
2090 /* MIDI-over-MADI on HDSPe MADI */ in snd_hdspm_create_midi()
2091 hdspm->midi[2].dataIn = HDSPM_midiDataIn2; in snd_hdspm_create_midi()
2092 hdspm->midi[2].statusIn = HDSPM_midiStatusIn2; in snd_hdspm_create_midi()
2093 hdspm->midi[2].dataOut = HDSPM_midiDataOut2; in snd_hdspm_create_midi()
2094 hdspm->midi[2].statusOut = HDSPM_midiStatusOut2; in snd_hdspm_create_midi()
2095 hdspm->midi[2].ie = HDSPM_Midi2InterruptEnable; in snd_hdspm_create_midi()
2096 hdspm->midi[2].irq = HDSPM_midi2IRQPending; in snd_hdspm_create_midi()
2099 hdspm->midi[2].dataIn = HDSPM_midiDataIn2; in snd_hdspm_create_midi()
2100 hdspm->midi[2].statusIn = HDSPM_midiStatusIn2; in snd_hdspm_create_midi()
2101 hdspm->midi[2].dataOut = -1; in snd_hdspm_create_midi()
2102 hdspm->midi[2].statusOut = -1; in snd_hdspm_create_midi()
2103 hdspm->midi[2].ie = HDSPM_Midi2InterruptEnable; in snd_hdspm_create_midi()
2104 hdspm->midi[2].irq = HDSPM_midi2IRQPendingAES; in snd_hdspm_create_midi()
2107 hdspm->midi[3].dataIn = HDSPM_midiDataIn3; in snd_hdspm_create_midi()
2108 hdspm->midi[3].statusIn = HDSPM_midiStatusIn3; in snd_hdspm_create_midi()
2109 hdspm->midi[3].dataOut = -1; in snd_hdspm_create_midi()
2110 hdspm->midi[3].statusOut = -1; in snd_hdspm_create_midi()
2111 hdspm->midi[3].ie = HDSPM_Midi3InterruptEnable; in snd_hdspm_create_midi()
2112 hdspm->midi[3].irq = HDSPM_midi3IRQPending; in snd_hdspm_create_midi()
2115 if ((id < 2) || ((2 == id) && ((MADI == hdspm->io_type) || in snd_hdspm_create_midi()
2116 (MADIface == hdspm->io_type)))) { in snd_hdspm_create_midi()
2117 if ((id == 0) && (MADIface == hdspm->io_type)) { in snd_hdspm_create_midi()
2119 card->shortname); in snd_hdspm_create_midi()
2120 } else if ((id == 2) && (MADI == hdspm->io_type)) { in snd_hdspm_create_midi()
2122 card->shortname); in snd_hdspm_create_midi()
2125 card->shortname, id+1); in snd_hdspm_create_midi()
2128 &hdspm->midi[id].rmidi); in snd_hdspm_create_midi()
2132 snprintf(hdspm->midi[id].rmidi->name, in snd_hdspm_create_midi()
2133 sizeof(hdspm->midi[id].rmidi->name), in snd_hdspm_create_midi()
2134 "%s MIDI %d", card->id, id+1); in snd_hdspm_create_midi()
2135 hdspm->midi[id].rmidi->private_data = &hdspm->midi[id]; in snd_hdspm_create_midi()
2137 snd_rawmidi_set_ops(hdspm->midi[id].rmidi, in snd_hdspm_create_midi()
2140 snd_rawmidi_set_ops(hdspm->midi[id].rmidi, in snd_hdspm_create_midi()
2144 hdspm->midi[id].rmidi->info_flags |= in snd_hdspm_create_midi()
2151 card->shortname, id+1); in snd_hdspm_create_midi()
2153 &hdspm->midi[id].rmidi); in snd_hdspm_create_midi()
2157 snprintf(hdspm->midi[id].rmidi->name, in snd_hdspm_create_midi()
2158 sizeof(hdspm->midi[id].rmidi->name), in snd_hdspm_create_midi()
2159 "%s MTC %d", card->id, id+1); in snd_hdspm_create_midi()
2160 hdspm->midi[id].rmidi->private_data = &hdspm->midi[id]; in snd_hdspm_create_midi()
2162 snd_rawmidi_set_ops(hdspm->midi[id].rmidi, in snd_hdspm_create_midi()
2166 hdspm->midi[id].rmidi->info_flags |= SNDRV_RAWMIDI_INFO_INPUT; in snd_hdspm_create_midi()
2178 while (i < hdspm->midiPorts) { in hdspm_midi_work()
2179 if (hdspm->midi[i].pending) in hdspm_midi_work()
2180 snd_hdspm_midi_input_read(&hdspm->midi[i]); in hdspm_midi_work()
2187 /*-----------------------------------------------------------------------------
2189 ----------------------------------------------------------------------------*/
2218 rate = hdspm->system_sample_rate; in hdspm_get_system_sample_rate()
2220 /* slave mode, return external sample rate */ in hdspm_get_system_sample_rate()
2223 rate = hdspm->system_sample_rate; in hdspm_get_system_sample_rate()
2245 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in snd_hdspm_info_system_sample_rate()
2246 uinfo->count = 1; in snd_hdspm_info_system_sample_rate()
2247 uinfo->value.integer.min = 27000; in snd_hdspm_info_system_sample_rate()
2248 uinfo->value.integer.max = 207000; in snd_hdspm_info_system_sample_rate()
2249 uinfo->value.integer.step = 1; in snd_hdspm_info_system_sample_rate()
2260 ucontrol->value.integer.value[0] = hdspm_get_system_sample_rate(hdspm); in snd_hdspm_get_system_sample_rate()
2269 int rate = ucontrol->value.integer.value[0]; in snd_hdspm_put_system_sample_rate()
2272 return -EINVAL; in snd_hdspm_put_system_sample_rate()
2273 hdspm_set_dds_value(hdspm, ucontrol->value.integer.value[0]); in snd_hdspm_put_system_sample_rate()
2285 switch (hdspm->io_type) { in hdspm_get_wc_sample_rate()
2309 if (hdspm->tco) { in hdspm_get_tco_sample_rate()
2310 switch (hdspm->io_type) { in hdspm_get_tco_sample_rate()
2334 if (hdspm->tco) { in hdspm_get_sync_in_sample_rate()
2335 switch (hdspm->io_type) { in hdspm_get_sync_in_sample_rate()
2355 switch (hdspm->io_type) { in hdspm_get_aes_sample_rate()
2420 switch (hdspm->io_type) { in snd_hdspm_get_autosync_sample_rate()
2422 switch (kcontrol->private_value) { in snd_hdspm_get_autosync_sample_rate()
2424 ucontrol->value.enumerated.item[0] = in snd_hdspm_get_autosync_sample_rate()
2428 ucontrol->value.enumerated.item[0] = in snd_hdspm_get_autosync_sample_rate()
2432 ucontrol->value.enumerated.item[0] = in snd_hdspm_get_autosync_sample_rate()
2436 ucontrol->value.enumerated.item[0] = in snd_hdspm_get_autosync_sample_rate()
2438 kcontrol->private_value-1); in snd_hdspm_get_autosync_sample_rate()
2443 switch (kcontrol->private_value) { in snd_hdspm_get_autosync_sample_rate()
2445 ucontrol->value.enumerated.item[0] = in snd_hdspm_get_autosync_sample_rate()
2449 ucontrol->value.enumerated.item[0] = in snd_hdspm_get_autosync_sample_rate()
2453 ucontrol->value.enumerated.item[0] = in snd_hdspm_get_autosync_sample_rate()
2457 ucontrol->value.enumerated.item[0] = in snd_hdspm_get_autosync_sample_rate()
2459 kcontrol->private_value-1); in snd_hdspm_get_autosync_sample_rate()
2465 switch (kcontrol->private_value) { in snd_hdspm_get_autosync_sample_rate()
2467 ucontrol->value.enumerated.item[0] = in snd_hdspm_get_autosync_sample_rate()
2471 ucontrol->value.enumerated.item[0] = in snd_hdspm_get_autosync_sample_rate()
2475 ucontrol->value.enumerated.item[0] = in snd_hdspm_get_autosync_sample_rate()
2479 ucontrol->value.enumerated.item[0] = in snd_hdspm_get_autosync_sample_rate()
2483 ucontrol->value.enumerated.item[0] = in snd_hdspm_get_autosync_sample_rate()
2485 kcontrol->private_value - in snd_hdspm_get_autosync_sample_rate()
2493 ucontrol->value.enumerated.item[0] = in snd_hdspm_get_autosync_sample_rate()
2518 * @returns 0 - master, 1 - slave
2522 switch (hdspm->io_type) { in hdspm_system_clock_mode()
2525 if (hdspm->settings_register & HDSPM_c0Master) in hdspm_system_clock_mode()
2530 if (hdspm->control_register & HDSPM_ClockModeMaster) in hdspm_system_clock_mode()
2540 * @param mode 0 - master, 1 - slave
2564 ucontrol->value.enumerated.item[0] = hdspm_system_clock_mode(hdspm); in snd_hdspm_get_system_clock_mode()
2575 return -EBUSY; in snd_hdspm_put_system_clock_mode()
2577 val = ucontrol->value.enumerated.item[0]; in snd_hdspm_put_system_clock_mode()
2601 switch (hdspm->system_sample_rate) { in hdspm_clock_source()
2613 return -1; in hdspm_clock_source()
2656 ucontrol->value.enumerated.item[0] = hdspm_clock_source(hdspm); in snd_hdspm_get_clock_source()
2668 return -EBUSY; in snd_hdspm_put_clock_source()
2669 val = ucontrol->value.enumerated.item[0]; in snd_hdspm_put_clock_source()
2674 spin_lock_irq(&hdspm->lock); in snd_hdspm_put_clock_source()
2679 spin_unlock_irq(&hdspm->lock); in snd_hdspm_put_clock_source()
2703 switch (hdspm->io_type) { in hdspm_pref_sync_ref()
2705 switch (hdspm->control_register & HDSPM_SyncRefMask) { in hdspm_pref_sync_ref()
2722 if (hdspm->tco) { in hdspm_pref_sync_ref()
2723 switch (hdspm->control_register & HDSPM_SyncRefMask) { in hdspm_pref_sync_ref()
2731 switch (hdspm->control_register & HDSPM_SyncRefMask) { in hdspm_pref_sync_ref()
2741 if (hdspm->tco) { in hdspm_pref_sync_ref()
2742 switch ((hdspm->settings_register & in hdspm_pref_sync_ref()
2755 switch ((hdspm->settings_register & in hdspm_pref_sync_ref()
2771 if (hdspm->tco) { in hdspm_pref_sync_ref()
2772 switch ((hdspm->settings_register & in hdspm_pref_sync_ref()
2782 switch ((hdspm->settings_register & in hdspm_pref_sync_ref()
2795 return -1; in hdspm_pref_sync_ref()
2808 switch (hdspm->io_type) { in hdspm_set_pref_sync_ref()
2810 hdspm->control_register &= ~HDSPM_SyncRefMask; in hdspm_set_pref_sync_ref()
2815 hdspm->control_register |= HDSPM_SyncRef0; in hdspm_set_pref_sync_ref()
2818 hdspm->control_register |= HDSPM_SyncRef1; in hdspm_set_pref_sync_ref()
2821 hdspm->control_register |= in hdspm_set_pref_sync_ref()
2825 hdspm->control_register |= HDSPM_SyncRef2; in hdspm_set_pref_sync_ref()
2828 hdspm->control_register |= in hdspm_set_pref_sync_ref()
2832 hdspm->control_register |= in hdspm_set_pref_sync_ref()
2836 hdspm->control_register |= in hdspm_set_pref_sync_ref()
2840 hdspm->control_register |= HDSPM_SyncRef3; in hdspm_set_pref_sync_ref()
2843 hdspm->control_register |= in hdspm_set_pref_sync_ref()
2847 return -1; in hdspm_set_pref_sync_ref()
2854 hdspm->control_register &= ~HDSPM_SyncRefMask; in hdspm_set_pref_sync_ref()
2855 if (hdspm->tco) { in hdspm_set_pref_sync_ref()
2860 hdspm->control_register |= HDSPM_SyncRef0; in hdspm_set_pref_sync_ref()
2863 hdspm->control_register |= HDSPM_SyncRef1; in hdspm_set_pref_sync_ref()
2866 hdspm->control_register |= in hdspm_set_pref_sync_ref()
2870 return -1; in hdspm_set_pref_sync_ref()
2877 hdspm->control_register |= HDSPM_SyncRef0; in hdspm_set_pref_sync_ref()
2880 hdspm->control_register |= in hdspm_set_pref_sync_ref()
2884 return -1; in hdspm_set_pref_sync_ref()
2891 if (hdspm->tco) { in hdspm_set_pref_sync_ref()
2902 default: return -1; in hdspm_set_pref_sync_ref()
2914 default: return -1; in hdspm_set_pref_sync_ref()
2920 if (hdspm->tco) { in hdspm_set_pref_sync_ref()
2928 default: return -1; in hdspm_set_pref_sync_ref()
2937 default: return -1; in hdspm_set_pref_sync_ref()
2943 switch (hdspm->io_type) { in hdspm_set_pref_sync_ref()
2946 hdspm->settings_register &= ~HDSPM_c0_SyncRefMask; in hdspm_set_pref_sync_ref()
2947 hdspm->settings_register |= HDSPM_c0_SyncRef0 * p; in hdspm_set_pref_sync_ref()
2948 hdspm_write(hdspm, HDSPM_WR_SETTINGS, hdspm->settings_register); in hdspm_set_pref_sync_ref()
2955 hdspm->control_register); in hdspm_set_pref_sync_ref()
2967 snd_ctl_enum_info(uinfo, 1, hdspm->texts_autosync_items, hdspm->texts_autosync); in snd_hdspm_info_pref_sync_ref()
2979 ucontrol->value.enumerated.item[0] = psf; in snd_hdspm_get_pref_sync_ref()
2983 return -1; in snd_hdspm_get_pref_sync_ref()
2993 return -EBUSY; in snd_hdspm_put_pref_sync_ref()
2995 val = ucontrol->value.enumerated.item[0]; in snd_hdspm_put_pref_sync_ref()
2999 else if (val >= hdspm->texts_autosync_items) in snd_hdspm_put_pref_sync_ref()
3000 val = hdspm->texts_autosync_items-1; in snd_hdspm_put_pref_sync_ref()
3002 spin_lock_irq(&hdspm->lock); in snd_hdspm_put_pref_sync_ref()
3006 spin_unlock_irq(&hdspm->lock); in snd_hdspm_put_pref_sync_ref()
3023 if (AES32 == hdspm->io_type) { in hdspm_autosync_ref()
3033 } else if (MADI == hdspm->io_type) { in hdspm_autosync_ref()
3061 if (AES32 == hdspm->io_type) { in snd_hdspm_info_autosync_ref()
3066 } else if (MADI == hdspm->io_type) { in snd_hdspm_info_autosync_ref()
3080 ucontrol->value.enumerated.item[0] = hdspm_autosync_ref(hdspm); in snd_hdspm_get_autosync_ref()
3126 ucontrol->value.enumerated.item[0] = ret; in snd_hdspm_get_tco_video_input_format()
3186 ucontrol->value.enumerated.item[0] = hdspm_tco_ltc_frames(hdspm); in snd_hdspm_get_tco_ltc_frames()
3204 reg = hdspm->settings_register; in hdspm_toggle_setting()
3206 reg = hdspm->control_register; in hdspm_toggle_setting()
3217 reg = &(hdspm->settings_register); in hdspm_set_toggle_setting()
3220 reg = &(hdspm->control_register); in hdspm_set_toggle_setting()
3240 u32 regmask = kcontrol->private_value; in snd_hdspm_get_toggle_setting()
3242 spin_lock_irq(&hdspm->lock); in snd_hdspm_get_toggle_setting()
3243 ucontrol->value.integer.value[0] = hdspm_toggle_setting(hdspm, regmask); in snd_hdspm_get_toggle_setting()
3244 spin_unlock_irq(&hdspm->lock); in snd_hdspm_get_toggle_setting()
3252 u32 regmask = kcontrol->private_value; in snd_hdspm_put_toggle_setting()
3257 return -EBUSY; in snd_hdspm_put_toggle_setting()
3258 val = ucontrol->value.integer.value[0] & 1; in snd_hdspm_put_toggle_setting()
3259 spin_lock_irq(&hdspm->lock); in snd_hdspm_put_toggle_setting()
3262 spin_unlock_irq(&hdspm->lock); in snd_hdspm_put_toggle_setting()
3277 return (hdspm->control_register & HDSPM_InputSelect0) ? 1 : 0; in hdspm_input_select()
3283 hdspm->control_register |= HDSPM_InputSelect0; in hdspm_set_input_select()
3285 hdspm->control_register &= ~HDSPM_InputSelect0; in hdspm_set_input_select()
3286 hdspm_write(hdspm, HDSPM_controlRegister, hdspm->control_register); in hdspm_set_input_select()
3304 spin_lock_irq(&hdspm->lock); in snd_hdspm_get_input_select()
3305 ucontrol->value.enumerated.item[0] = hdspm_input_select(hdspm); in snd_hdspm_get_input_select()
3306 spin_unlock_irq(&hdspm->lock); in snd_hdspm_get_input_select()
3318 return -EBUSY; in snd_hdspm_put_input_select()
3319 val = ucontrol->value.integer.value[0] & 1; in snd_hdspm_put_input_select()
3320 spin_lock_irq(&hdspm->lock); in snd_hdspm_put_input_select()
3323 spin_unlock_irq(&hdspm->lock); in snd_hdspm_put_input_select()
3339 return (hdspm->control_register & HDSPM_DS_DoubleWire) ? 1 : 0; in hdspm_ds_wire()
3345 hdspm->control_register |= HDSPM_DS_DoubleWire; in hdspm_set_ds_wire()
3347 hdspm->control_register &= ~HDSPM_DS_DoubleWire; in hdspm_set_ds_wire()
3348 hdspm_write(hdspm, HDSPM_controlRegister, hdspm->control_register); in hdspm_set_ds_wire()
3366 spin_lock_irq(&hdspm->lock); in snd_hdspm_get_ds_wire()
3367 ucontrol->value.enumerated.item[0] = hdspm_ds_wire(hdspm); in snd_hdspm_get_ds_wire()
3368 spin_unlock_irq(&hdspm->lock); in snd_hdspm_get_ds_wire()
3380 return -EBUSY; in snd_hdspm_put_ds_wire()
3381 val = ucontrol->value.integer.value[0] & 1; in snd_hdspm_put_ds_wire()
3382 spin_lock_irq(&hdspm->lock); in snd_hdspm_put_ds_wire()
3385 spin_unlock_irq(&hdspm->lock); in snd_hdspm_put_ds_wire()
3401 if (hdspm->control_register & HDSPM_QS_DoubleWire) in hdspm_qs_wire()
3403 if (hdspm->control_register & HDSPM_QS_QuadWire) in hdspm_qs_wire()
3410 hdspm->control_register &= ~(HDSPM_QS_DoubleWire | HDSPM_QS_QuadWire); in hdspm_set_qs_wire()
3415 hdspm->control_register |= HDSPM_QS_DoubleWire; in hdspm_set_qs_wire()
3418 hdspm->control_register |= HDSPM_QS_QuadWire; in hdspm_set_qs_wire()
3421 hdspm_write(hdspm, HDSPM_controlRegister, hdspm->control_register); in hdspm_set_qs_wire()
3439 spin_lock_irq(&hdspm->lock); in snd_hdspm_get_qs_wire()
3440 ucontrol->value.enumerated.item[0] = hdspm_qs_wire(hdspm); in snd_hdspm_get_qs_wire()
3441 spin_unlock_irq(&hdspm->lock); in snd_hdspm_get_qs_wire()
3453 return -EBUSY; in snd_hdspm_put_qs_wire()
3454 val = ucontrol->value.integer.value[0]; in snd_hdspm_put_qs_wire()
3459 spin_lock_irq(&hdspm->lock); in snd_hdspm_put_qs_wire()
3462 spin_unlock_irq(&hdspm->lock); in snd_hdspm_put_qs_wire()
3477 u32 reg = hdspm->settings_register & (regmask * 3); in hdspm_tristate()
3483 hdspm->settings_register &= ~(regmask * 3); in hdspm_set_tristate()
3484 hdspm->settings_register |= (regmask * mode); in hdspm_set_tristate()
3485 hdspm_write(hdspm, HDSPM_WR_SETTINGS, hdspm->settings_register); in hdspm_set_tristate()
3493 u32 regmask = kcontrol->private_value; in snd_hdspm_info_tristate()
3496 static const char *const texts_levels[] = { "Hi Gain", "+4 dBu", "-10 dBV" }; in snd_hdspm_info_tristate()
3513 u32 regmask = kcontrol->private_value; in snd_hdspm_get_tristate()
3515 spin_lock_irq(&hdspm->lock); in snd_hdspm_get_tristate()
3516 ucontrol->value.enumerated.item[0] = hdspm_tristate(hdspm, regmask); in snd_hdspm_get_tristate()
3517 spin_unlock_irq(&hdspm->lock); in snd_hdspm_get_tristate()
3525 u32 regmask = kcontrol->private_value; in snd_hdspm_put_tristate()
3530 return -EBUSY; in snd_hdspm_put_tristate()
3531 val = ucontrol->value.integer.value[0]; in snd_hdspm_put_tristate()
3537 spin_lock_irq(&hdspm->lock); in snd_hdspm_put_tristate()
3540 spin_unlock_irq(&hdspm->lock); in snd_hdspm_put_tristate()
3555 if (hdspm->control_register & HDSPM_QuadSpeed) in hdspm_madi_speedmode()
3557 if (hdspm->control_register & HDSPM_DoubleSpeed) in hdspm_madi_speedmode()
3564 hdspm->control_register &= ~(HDSPM_DoubleSpeed | HDSPM_QuadSpeed); in hdspm_set_madi_speedmode()
3569 hdspm->control_register |= HDSPM_DoubleSpeed; in hdspm_set_madi_speedmode()
3572 hdspm->control_register |= HDSPM_QuadSpeed; in hdspm_set_madi_speedmode()
3575 hdspm_write(hdspm, HDSPM_controlRegister, hdspm->control_register); in hdspm_set_madi_speedmode()
3593 spin_lock_irq(&hdspm->lock); in snd_hdspm_get_madi_speedmode()
3594 ucontrol->value.enumerated.item[0] = hdspm_madi_speedmode(hdspm); in snd_hdspm_get_madi_speedmode()
3595 spin_unlock_irq(&hdspm->lock); in snd_hdspm_get_madi_speedmode()
3607 return -EBUSY; in snd_hdspm_put_madi_speedmode()
3608 val = ucontrol->value.integer.value[0]; in snd_hdspm_put_madi_speedmode()
3613 spin_lock_irq(&hdspm->lock); in snd_hdspm_put_madi_speedmode()
3616 spin_unlock_irq(&hdspm->lock); in snd_hdspm_put_madi_speedmode()
3635 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in snd_hdspm_info_mixer()
3636 uinfo->count = 3; in snd_hdspm_info_mixer()
3637 uinfo->value.integer.min = 0; in snd_hdspm_info_mixer()
3638 uinfo->value.integer.max = 65535; in snd_hdspm_info_mixer()
3639 uinfo->value.integer.step = 1; in snd_hdspm_info_mixer()
3650 source = ucontrol->value.integer.value[0]; in snd_hdspm_get_mixer()
3654 source = 2 * HDSPM_MAX_CHANNELS - 1; in snd_hdspm_get_mixer()
3656 destination = ucontrol->value.integer.value[1]; in snd_hdspm_get_mixer()
3660 destination = HDSPM_MAX_CHANNELS - 1; in snd_hdspm_get_mixer()
3662 spin_lock_irq(&hdspm->lock); in snd_hdspm_get_mixer()
3664 ucontrol->value.integer.value[2] = in snd_hdspm_get_mixer()
3666 source - HDSPM_MAX_CHANNELS); in snd_hdspm_get_mixer()
3668 ucontrol->value.integer.value[2] = in snd_hdspm_get_mixer()
3671 spin_unlock_irq(&hdspm->lock); in snd_hdspm_get_mixer()
3686 return -EBUSY; in snd_hdspm_put_mixer()
3688 source = ucontrol->value.integer.value[0]; in snd_hdspm_put_mixer()
3689 destination = ucontrol->value.integer.value[1]; in snd_hdspm_put_mixer()
3692 return -1; in snd_hdspm_put_mixer()
3694 return -1; in snd_hdspm_put_mixer()
3696 gain = ucontrol->value.integer.value[2]; in snd_hdspm_put_mixer()
3698 spin_lock_irq(&hdspm->lock); in snd_hdspm_put_mixer()
3702 source - in snd_hdspm_put_mixer()
3711 source - HDSPM_MAX_CHANNELS, in snd_hdspm_put_mixer()
3717 spin_unlock_irq(&hdspm->lock); in snd_hdspm_put_mixer()
3739 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in snd_hdspm_info_playback_mixer()
3740 uinfo->count = 1; in snd_hdspm_info_playback_mixer()
3741 uinfo->value.integer.min = 0; in snd_hdspm_info_playback_mixer()
3742 uinfo->value.integer.max = 64; in snd_hdspm_info_playback_mixer()
3743 uinfo->value.integer.step = 1; in snd_hdspm_info_playback_mixer()
3753 channel = ucontrol->id.index - 1; in snd_hdspm_get_playback_mixer()
3756 return -EINVAL; in snd_hdspm_get_playback_mixer()
3758 spin_lock_irq(&hdspm->lock); in snd_hdspm_get_playback_mixer()
3759 ucontrol->value.integer.value[0] = in snd_hdspm_get_playback_mixer()
3761 spin_unlock_irq(&hdspm->lock); in snd_hdspm_get_playback_mixer()
3775 return -EBUSY; in snd_hdspm_put_playback_mixer()
3777 channel = ucontrol->id.index - 1; in snd_hdspm_put_playback_mixer()
3780 return -EINVAL; in snd_hdspm_put_playback_mixer()
3782 gain = ucontrol->value.integer.value[0]*UNITY_GAIN/64; in snd_hdspm_put_playback_mixer()
3784 spin_lock_irq(&hdspm->lock); in snd_hdspm_put_playback_mixer()
3791 spin_unlock_irq(&hdspm->lock); in snd_hdspm_put_playback_mixer()
3835 switch (hdspm->io_type) { in hdspm_wc_sync_check()
3909 switch (hdspm->io_type) { in hdspm_sync_in_sync_check()
3969 if (hdspm->tco) { in hdspm_tco_sync_check()
3970 switch (hdspm->io_type) { in hdspm_tco_sync_check()
4012 int val = -1; in snd_hdspm_get_sync_check()
4014 switch (hdspm->io_type) { in snd_hdspm_get_sync_check()
4016 switch (kcontrol->private_value) { in snd_hdspm_get_sync_check()
4025 kcontrol->private_value-1); in snd_hdspm_get_sync_check()
4030 switch (kcontrol->private_value) { in snd_hdspm_get_sync_check()
4039 kcontrol->private_value-1); in snd_hdspm_get_sync_check()
4044 switch (kcontrol->private_value) { in snd_hdspm_get_sync_check()
4061 switch (kcontrol->private_value) { in snd_hdspm_get_sync_check()
4070 kcontrol->private_value-1); in snd_hdspm_get_sync_check()
4076 if (hdspm->tco) { in snd_hdspm_get_sync_check()
4077 switch (kcontrol->private_value) { in snd_hdspm_get_sync_check()
4092 if (-1 == val) in snd_hdspm_get_sync_check()
4095 ucontrol->value.enumerated.item[0] = val; in snd_hdspm_get_sync_check()
4108 switch (hdspm->tco->input) { in hdspm_tco_write()
4119 switch (hdspm->tco->framerate) { in hdspm_tco_write()
4143 switch (hdspm->tco->wordclock) { in hdspm_tco_write()
4154 switch (hdspm->tco->samplerate) { in hdspm_tco_write()
4165 switch (hdspm->tco->pull) { in hdspm_tco_write()
4182 if (1 == hdspm->tco->term) { in hdspm_tco_write()
4207 /* TODO freq from app could be supported here, see tco->samplerate */ in snd_hdspm_info_tco_sample_rate()
4218 ucontrol->value.enumerated.item[0] = hdspm->tco->samplerate; in snd_hdspm_get_tco_sample_rate()
4228 if (hdspm->tco->samplerate != ucontrol->value.enumerated.item[0]) { in snd_hdspm_put_tco_sample_rate()
4229 hdspm->tco->samplerate = ucontrol->value.enumerated.item[0]; in snd_hdspm_put_tco_sample_rate()
4254 static const char *const texts[] = { "0", "+ 0.1 %", "- 0.1 %", in snd_hdspm_info_tco_pull()
4255 "+ 4 %", "- 4 %" }; in snd_hdspm_info_tco_pull()
4265 ucontrol->value.enumerated.item[0] = hdspm->tco->pull; in snd_hdspm_get_tco_pull()
4275 if (hdspm->tco->pull != ucontrol->value.enumerated.item[0]) { in snd_hdspm_put_tco_pull()
4276 hdspm->tco->pull = ucontrol->value.enumerated.item[0]; in snd_hdspm_put_tco_pull()
4300 static const char *const texts[] = { "1:1", "44.1 -> 48", "48 -> 44.1" }; in snd_hdspm_info_tco_wck_conversion()
4310 ucontrol->value.enumerated.item[0] = hdspm->tco->wordclock; in snd_hdspm_get_tco_wck_conversion()
4320 if (hdspm->tco->wordclock != ucontrol->value.enumerated.item[0]) { in snd_hdspm_put_tco_wck_conversion()
4321 hdspm->tco->wordclock = ucontrol->value.enumerated.item[0]; in snd_hdspm_put_tco_wck_conversion()
4357 ucontrol->value.enumerated.item[0] = hdspm->tco->framerate; in snd_hdspm_get_tco_frame_rate()
4367 if (hdspm->tco->framerate != ucontrol->value.enumerated.item[0]) { in snd_hdspm_put_tco_frame_rate()
4368 hdspm->tco->framerate = ucontrol->value.enumerated.item[0]; in snd_hdspm_put_tco_frame_rate()
4403 ucontrol->value.enumerated.item[0] = hdspm->tco->input; in snd_hdspm_get_tco_sync_source()
4413 if (hdspm->tco->input != ucontrol->value.enumerated.item[0]) { in snd_hdspm_put_tco_sync_source()
4414 hdspm->tco->input = ucontrol->value.enumerated.item[0]; in snd_hdspm_put_tco_sync_source()
4439 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; in snd_hdspm_info_tco_word_term()
4440 uinfo->count = 1; in snd_hdspm_info_tco_word_term()
4441 uinfo->value.integer.min = 0; in snd_hdspm_info_tco_word_term()
4442 uinfo->value.integer.max = 1; in snd_hdspm_info_tco_word_term()
4453 ucontrol->value.integer.value[0] = hdspm->tco->term; in snd_hdspm_get_tco_word_term()
4464 if (hdspm->tco->term != ucontrol->value.integer.value[0]) { in snd_hdspm_put_tco_word_term()
4465 hdspm->tco->term = ucontrol->value.integer.value[0]; in snd_hdspm_put_tco_word_term()
4645 for (i = hdspm->ds_out_channels; i < hdspm->ss_out_channels; ++i) { in hdspm_update_simple_mixer_controls()
4646 if (hdspm->system_sample_rate > 48000) { in hdspm_update_simple_mixer_controls()
4647 hdspm->playback_mixer_ctls[i]->vd[0].access = in hdspm_update_simple_mixer_controls()
4652 hdspm->playback_mixer_ctls[i]->vd[0].access = in hdspm_update_simple_mixer_controls()
4656 snd_ctl_notify(hdspm->card, SNDRV_CTL_EVENT_MASK_VALUE | in hdspm_update_simple_mixer_controls()
4658 &hdspm->playback_mixer_ctls[i]->id); in hdspm_update_simple_mixer_controls()
4673 switch (hdspm->io_type) { in snd_hdspm_create_controls()
4708 if (hdspm->system_sample_rate >= 128000) { in snd_hdspm_create_controls()
4709 limit = hdspm->qs_out_channels; in snd_hdspm_create_controls()
4710 } else if (hdspm->system_sample_rate >= 64000) { in snd_hdspm_create_controls()
4711 limit = hdspm->ds_out_channels; in snd_hdspm_create_controls()
4713 limit = hdspm->ss_out_channels; in snd_hdspm_create_controls()
4721 hdspm->playback_mixer_ctls[idx] = kctl; in snd_hdspm_create_controls()
4725 if (hdspm->tco) { in snd_hdspm_create_controls()
4740 /*------------------------------------------------------------
4742 ------------------------------------------------------------*/
4748 struct hdspm *hdspm = entry->private_data; in snd_hdspm_proc_read_tco()
4755 snd_iprintf(buffer, "--- TCO ---\n"); in snd_hdspm_proc_read_tco()
4758 control = hdspm->control_register; in snd_hdspm_proc_read_tco()
4802 switch (hdspm->io_type) { in snd_hdspm_proc_read_tco()
4860 struct hdspm *hdspm = entry->private_data; in snd_hdspm_proc_read_madi()
4872 hdspm->card_name, hdspm->card->number + 1, in snd_hdspm_proc_read_madi()
4873 hdspm->firmware_rev, in snd_hdspm_proc_read_madi()
4878 snd_iprintf(buffer, "HW Serial: 0x%06x%06x\n", in snd_hdspm_proc_read_madi()
4880 hdspm->serial); in snd_hdspm_proc_read_madi()
4883 hdspm->irq, hdspm->port, (unsigned long)hdspm->iobase); in snd_hdspm_proc_read_madi()
4885 snd_iprintf(buffer, "--- System ---\n"); in snd_hdspm_proc_read_madi()
4892 hdspm->irq_count); in snd_hdspm_proc_read_madi()
4894 "HW pointer: id = %d, rawptr = %d (%d->%d) " in snd_hdspm_proc_read_madi()
4899 (2 * (int)hdspm->period_bytes), in snd_hdspm_proc_read_madi()
4900 ((status & HDSPM_BufferPositionMask) - 64) % in snd_hdspm_proc_read_madi()
4901 (2 * (int)hdspm->period_bytes), in snd_hdspm_proc_read_madi()
4917 hdspm->control_register, hdspm->control2_register, in snd_hdspm_proc_read_madi()
4921 snd_iprintf(buffer, "--- Settings ---\n"); in snd_hdspm_proc_read_madi()
4927 x, (unsigned long) hdspm->period_bytes); in snd_hdspm_proc_read_madi()
4930 (hdspm->control_register & HDSPM_LineOut) ? "on " : "off"); in snd_hdspm_proc_read_madi()
4935 (hdspm->control_register & HDSPM_clr_tms) ? "on" : "off", in snd_hdspm_proc_read_madi()
4936 (hdspm->control_register & HDSPM_TX_64ch) ? "64" : "56", in snd_hdspm_proc_read_madi()
4937 (hdspm->control_register & HDSPM_AutoInp) ? "on" : "off"); in snd_hdspm_proc_read_madi()
4940 if (!(hdspm->control_register & HDSPM_ClockModeMaster)) in snd_hdspm_proc_read_madi()
4967 hdspm->system_sample_rate); in snd_hdspm_proc_read_madi()
4970 snd_iprintf(buffer, "--- Status:\n"); in snd_hdspm_proc_read_madi()
4998 autosync_ref = "---"; in snd_hdspm_proc_read_madi()
5022 struct hdspm *hdspm = entry->private_data; in snd_hdspm_proc_read_aes32()
5036 hdspm->card_name, hdspm->card->number + 1, in snd_hdspm_proc_read_aes32()
5037 hdspm->firmware_rev); in snd_hdspm_proc_read_aes32()
5040 hdspm->irq, hdspm->port, (unsigned long)hdspm->iobase); in snd_hdspm_proc_read_aes32()
5042 snd_iprintf(buffer, "--- System ---\n"); in snd_hdspm_proc_read_aes32()
5049 hdspm->irq_count); in snd_hdspm_proc_read_aes32()
5051 "HW pointer: id = %d, rawptr = %d (%d->%d) " in snd_hdspm_proc_read_aes32()
5056 (2 * (int)hdspm->period_bytes), in snd_hdspm_proc_read_aes32()
5057 ((status & HDSPM_BufferPositionMask) - 64) % in snd_hdspm_proc_read_aes32()
5058 (2 * (int)hdspm->period_bytes), in snd_hdspm_proc_read_aes32()
5074 hdspm->control_register, hdspm->control2_register, in snd_hdspm_proc_read_aes32()
5077 snd_iprintf(buffer, "--- Settings ---\n"); in snd_hdspm_proc_read_aes32()
5083 x, (unsigned long) hdspm->period_bytes); in snd_hdspm_proc_read_aes32()
5086 (hdspm-> in snd_hdspm_proc_read_aes32()
5091 (hdspm-> in snd_hdspm_proc_read_aes32()
5093 (hdspm-> in snd_hdspm_proc_read_aes32()
5095 (hdspm-> in snd_hdspm_proc_read_aes32()
5107 hdspm->system_sample_rate); in snd_hdspm_proc_read_aes32()
5110 hdspm->control_register & HDSPM_DS_DoubleWire? in snd_hdspm_proc_read_aes32()
5113 hdspm->control_register & HDSPM_QS_DoubleWire? in snd_hdspm_proc_read_aes32()
5115 hdspm->control_register & HDSPM_QS_QuadWire? in snd_hdspm_proc_read_aes32()
5118 snd_iprintf(buffer, "--- Status:\n"); in snd_hdspm_proc_read_aes32()
5161 autosync_ref = "---"; break; in snd_hdspm_proc_read_aes32()
5175 struct hdspm *hdspm = entry->private_data; in snd_hdspm_proc_read_raydat()
5191 (hdspm_system_clock_mode(hdspm) == 0) ? "master" : "slave"); in snd_hdspm_proc_read_raydat()
5233 struct hdspm *hdspm = entry->private_data; in snd_hdspm_proc_read_debug()
5250 struct hdspm *hdspm = entry->private_data; in snd_hdspm_proc_ports_in()
5255 for (i = 0; i < hdspm->max_channels_in; i++) { in snd_hdspm_proc_ports_in()
5256 snd_iprintf(buffer, "%d=%s\n", i+1, hdspm->port_names_in[i]); in snd_hdspm_proc_ports_in()
5263 struct hdspm *hdspm = entry->private_data; in snd_hdspm_proc_ports_out()
5268 for (i = 0; i < hdspm->max_channels_out; i++) { in snd_hdspm_proc_ports_out()
5269 snd_iprintf(buffer, "%d=%s\n", i+1, hdspm->port_names_out[i]); in snd_hdspm_proc_ports_out()
5278 switch (hdspm->io_type) { in snd_hdspm_proc_init()
5295 snd_card_ro_proc_new(hdspm->card, "hdspm", hdspm, read); in snd_hdspm_proc_init()
5296 snd_card_ro_proc_new(hdspm->card, "ports.in", hdspm, in snd_hdspm_proc_init()
5298 snd_card_ro_proc_new(hdspm->card, "ports.out", hdspm, in snd_hdspm_proc_init()
5303 snd_card_ro_proc_new(hdspm->card, "debug", hdspm, in snd_hdspm_proc_init()
5308 /*------------------------------------------------------------
5310 ------------------------------------------------------------*/
5314 /* ASSUMPTION: hdspm->lock is either held, or there is no need to in snd_hdspm_set_defaults()
5320 hdspm->settings_register = 0; in snd_hdspm_set_defaults()
5322 switch (hdspm->io_type) { in snd_hdspm_set_defaults()
5325 hdspm->control_register = in snd_hdspm_set_defaults()
5331 hdspm->settings_register = 0x1 + 0x1000; in snd_hdspm_set_defaults()
5334 hdspm->control_register = in snd_hdspm_set_defaults()
5339 hdspm->control_register = in snd_hdspm_set_defaults()
5348 hdspm_write(hdspm, HDSPM_controlRegister, hdspm->control_register); in snd_hdspm_set_defaults()
5350 if (AES32 == hdspm->io_type) { in snd_hdspm_set_defaults()
5353 hdspm->control2_register = HDSPM_BIGENDIAN_MODE; in snd_hdspm_set_defaults()
5355 hdspm->control2_register = 0; in snd_hdspm_set_defaults()
5358 hdspm_write(hdspm, HDSPM_control2Reg, hdspm->control2_register); in snd_hdspm_set_defaults()
5367 hdspm_write(hdspm, HDSPM_WR_SETTINGS, hdspm->settings_register); in snd_hdspm_set_defaults()
5376 /*------------------------------------------------------------
5378 ------------------------------------------------------------*/
5405 dev_info(hdspm->card->dev, "snd_hdspm_interrupt %llu @ %llx\n", in snd_hdspm_interrupt()
5406 now-hdspm->last_interrupt, status & 0xFFC0); in snd_hdspm_interrupt()
5407 hdspm->last_interrupt = now; in snd_hdspm_interrupt()
5414 hdspm->irq_count++; in snd_hdspm_interrupt()
5418 if (hdspm->capture_substream) in snd_hdspm_interrupt()
5419 snd_pcm_period_elapsed(hdspm->capture_substream); in snd_hdspm_interrupt()
5421 if (hdspm->playback_substream) in snd_hdspm_interrupt()
5422 snd_pcm_period_elapsed(hdspm->playback_substream); in snd_hdspm_interrupt()
5427 while (i < hdspm->midiPorts) { in snd_hdspm_interrupt()
5429 hdspm->midi[i].statusIn) & 0xff) && in snd_hdspm_interrupt()
5430 (status & hdspm->midi[i].irq)) { in snd_hdspm_interrupt()
5434 hdspm->control_register &= ~hdspm->midi[i].ie; in snd_hdspm_interrupt()
5436 hdspm->control_register); in snd_hdspm_interrupt()
5437 hdspm->midi[i].pending = 1; in snd_hdspm_interrupt()
5445 queue_work(system_highpri_wq, &hdspm->midi_work); in snd_hdspm_interrupt()
5451 /*------------------------------------------------------------
5453 ------------------------------------------------------------*/
5466 struct snd_pcm_runtime *runtime = substream->runtime; in snd_hdspm_reset()
5470 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) in snd_hdspm_reset()
5471 other = hdspm->capture_substream; in snd_hdspm_reset()
5473 other = hdspm->playback_substream; in snd_hdspm_reset()
5475 if (hdspm->running) in snd_hdspm_reset()
5476 runtime->status->hw_ptr = hdspm_hw_pointer(hdspm); in snd_hdspm_reset()
5478 runtime->status->hw_ptr = 0; in snd_hdspm_reset()
5481 struct snd_pcm_runtime *oruntime = other->runtime; in snd_hdspm_reset()
5484 oruntime->status->hw_ptr = in snd_hdspm_reset()
5485 runtime->status->hw_ptr; in snd_hdspm_reset()
5502 spin_lock_irq(&hdspm->lock); in snd_hdspm_hw_params()
5504 if (substream->pstr->stream == SNDRV_PCM_STREAM_PLAYBACK) { in snd_hdspm_hw_params()
5505 this_pid = hdspm->playback_pid; in snd_hdspm_hw_params()
5506 other_pid = hdspm->capture_pid; in snd_hdspm_hw_params()
5508 this_pid = hdspm->capture_pid; in snd_hdspm_hw_params()
5509 other_pid = hdspm->playback_pid; in snd_hdspm_hw_params()
5519 if (params_rate(params) != hdspm->system_sample_rate) { in snd_hdspm_hw_params()
5520 spin_unlock_irq(&hdspm->lock); in snd_hdspm_hw_params()
5523 return -EBUSY; in snd_hdspm_hw_params()
5526 if (params_period_size(params) != hdspm->period_bytes / 4) { in snd_hdspm_hw_params()
5527 spin_unlock_irq(&hdspm->lock); in snd_hdspm_hw_params()
5530 return -EBUSY; in snd_hdspm_hw_params()
5535 spin_unlock_irq(&hdspm->lock); in snd_hdspm_hw_params()
5537 /* how to make sure that the rate matches an externally-set one ? */ in snd_hdspm_hw_params()
5539 spin_lock_irq(&hdspm->lock); in snd_hdspm_hw_params()
5542 dev_info(hdspm->card->dev, "err on hdspm_set_rate: %d\n", err); in snd_hdspm_hw_params()
5543 spin_unlock_irq(&hdspm->lock); in snd_hdspm_hw_params()
5548 spin_unlock_irq(&hdspm->lock); in snd_hdspm_hw_params()
5553 dev_info(hdspm->card->dev, in snd_hdspm_hw_params()
5570 dev_info(hdspm->card->dev, in snd_hdspm_hw_params()
5575 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { in snd_hdspm_hw_params()
5578 int c = hdspm->channel_map_out[i]; in snd_hdspm_hw_params()
5588 hdspm->playback_buffer = in snd_hdspm_hw_params()
5589 (unsigned char *) substream->runtime->dma_area; in snd_hdspm_hw_params()
5590 dev_dbg(hdspm->card->dev, in snd_hdspm_hw_params()
5592 hdspm->playback_buffer); in snd_hdspm_hw_params()
5595 int c = hdspm->channel_map_in[i]; in snd_hdspm_hw_params()
5605 hdspm->capture_buffer = in snd_hdspm_hw_params()
5606 (unsigned char *) substream->runtime->dma_area; in snd_hdspm_hw_params()
5607 dev_dbg(hdspm->card->dev, in snd_hdspm_hw_params()
5609 hdspm->capture_buffer); in snd_hdspm_hw_params()
5613 dev_dbg(hdspm->card->dev, in snd_hdspm_hw_params()
5615 snd_pcm_direction_name(substream->stream), in snd_hdspm_hw_params()
5619 dev_dbg(hdspm->card->dev, in snd_hdspm_hw_params()
5621 snd_pcm_direction_name(substream->stream), in snd_hdspm_hw_params()
5632 if (hdspm->io_type == AES32) { in snd_hdspm_hw_params()
5639 if (!(hdspm->control_register & HDSPe_FLOAT_FORMAT)) in snd_hdspm_hw_params()
5640 dev_info(hdspm->card->dev, in snd_hdspm_hw_params()
5643 hdspm->control_register |= HDSPe_FLOAT_FORMAT; in snd_hdspm_hw_params()
5645 if (hdspm->control_register & HDSPe_FLOAT_FORMAT) in snd_hdspm_hw_params()
5646 dev_info(hdspm->card->dev, in snd_hdspm_hw_params()
5649 hdspm->control_register &= ~HDSPe_FLOAT_FORMAT; in snd_hdspm_hw_params()
5651 hdspm_write(hdspm, HDSPM_controlRegister, hdspm->control_register); in snd_hdspm_hw_params()
5661 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { in snd_hdspm_hw_free()
5667 hdspm->playback_buffer = NULL; in snd_hdspm_hw_free()
5672 hdspm->capture_buffer = NULL; in snd_hdspm_hw_free()
5685 unsigned int channel = info->channel; in snd_hdspm_channel_info()
5687 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { in snd_hdspm_channel_info()
5688 if (snd_BUG_ON(channel >= hdspm->max_channels_out)) { in snd_hdspm_channel_info()
5689 dev_info(hdspm->card->dev, in snd_hdspm_channel_info()
5692 return -EINVAL; in snd_hdspm_channel_info()
5695 channel = array_index_nospec(channel, hdspm->max_channels_out); in snd_hdspm_channel_info()
5696 if (hdspm->channel_map_out[channel] < 0) { in snd_hdspm_channel_info()
5697 dev_info(hdspm->card->dev, in snd_hdspm_channel_info()
5700 return -EINVAL; in snd_hdspm_channel_info()
5703 info->offset = hdspm->channel_map_out[channel] * in snd_hdspm_channel_info()
5706 if (snd_BUG_ON(channel >= hdspm->max_channels_in)) { in snd_hdspm_channel_info()
5707 dev_info(hdspm->card->dev, in snd_hdspm_channel_info()
5710 return -EINVAL; in snd_hdspm_channel_info()
5713 channel = array_index_nospec(channel, hdspm->max_channels_in); in snd_hdspm_channel_info()
5714 if (hdspm->channel_map_in[channel] < 0) { in snd_hdspm_channel_info()
5715 dev_info(hdspm->card->dev, in snd_hdspm_channel_info()
5718 return -EINVAL; in snd_hdspm_channel_info()
5721 info->offset = hdspm->channel_map_in[channel] * in snd_hdspm_channel_info()
5725 info->first = 0; in snd_hdspm_channel_info()
5726 info->step = 32; in snd_hdspm_channel_info()
5756 spin_lock(&hdspm->lock); in snd_hdspm_trigger()
5757 running = hdspm->running; in snd_hdspm_trigger()
5760 running |= 1 << substream->stream; in snd_hdspm_trigger()
5763 running &= ~(1 << substream->stream); in snd_hdspm_trigger()
5767 spin_unlock(&hdspm->lock); in snd_hdspm_trigger()
5768 return -EINVAL; in snd_hdspm_trigger()
5770 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) in snd_hdspm_trigger()
5771 other = hdspm->capture_substream; in snd_hdspm_trigger()
5773 other = hdspm->playback_substream; in snd_hdspm_trigger()
5781 running |= 1 << s->stream; in snd_hdspm_trigger()
5783 running &= ~(1 << s->stream); in snd_hdspm_trigger()
5789 && substream->stream == in snd_hdspm_trigger()
5794 substream->stream == SNDRV_PCM_STREAM_PLAYBACK) in snd_hdspm_trigger()
5798 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) in snd_hdspm_trigger()
5803 if (!hdspm->running && running) in snd_hdspm_trigger()
5805 else if (hdspm->running && !running) in snd_hdspm_trigger()
5807 hdspm->running = running; in snd_hdspm_trigger()
5808 spin_unlock(&hdspm->lock); in snd_hdspm_trigger()
5871 struct hdspm *hdspm = rule->private; in snd_hdspm_hw_rule_in_channels_rate()
5877 if (r->min > 96000 && r->max <= 192000) { in snd_hdspm_hw_rule_in_channels_rate()
5879 .min = hdspm->qs_in_channels, in snd_hdspm_hw_rule_in_channels_rate()
5880 .max = hdspm->qs_in_channels, in snd_hdspm_hw_rule_in_channels_rate()
5884 } else if (r->min > 48000 && r->max <= 96000) { in snd_hdspm_hw_rule_in_channels_rate()
5886 .min = hdspm->ds_in_channels, in snd_hdspm_hw_rule_in_channels_rate()
5887 .max = hdspm->ds_in_channels, in snd_hdspm_hw_rule_in_channels_rate()
5891 } else if (r->max < 64000) { in snd_hdspm_hw_rule_in_channels_rate()
5893 .min = hdspm->ss_in_channels, in snd_hdspm_hw_rule_in_channels_rate()
5894 .max = hdspm->ss_in_channels, in snd_hdspm_hw_rule_in_channels_rate()
5906 struct hdspm *hdspm = rule->private; in snd_hdspm_hw_rule_out_channels_rate()
5912 if (r->min > 96000 && r->max <= 192000) { in snd_hdspm_hw_rule_out_channels_rate()
5914 .min = hdspm->qs_out_channels, in snd_hdspm_hw_rule_out_channels_rate()
5915 .max = hdspm->qs_out_channels, in snd_hdspm_hw_rule_out_channels_rate()
5919 } else if (r->min > 48000 && r->max <= 96000) { in snd_hdspm_hw_rule_out_channels_rate()
5921 .min = hdspm->ds_out_channels, in snd_hdspm_hw_rule_out_channels_rate()
5922 .max = hdspm->ds_out_channels, in snd_hdspm_hw_rule_out_channels_rate()
5926 } else if (r->max < 64000) { in snd_hdspm_hw_rule_out_channels_rate()
5928 .min = hdspm->ss_out_channels, in snd_hdspm_hw_rule_out_channels_rate()
5929 .max = hdspm->ss_out_channels, in snd_hdspm_hw_rule_out_channels_rate()
5941 struct hdspm *hdspm = rule->private; in snd_hdspm_hw_rule_rate_in_channels()
5947 if (c->min >= hdspm->ss_in_channels) { in snd_hdspm_hw_rule_rate_in_channels()
5954 } else if (c->max <= hdspm->qs_in_channels) { in snd_hdspm_hw_rule_rate_in_channels()
5961 } else if (c->max <= hdspm->ds_in_channels) { in snd_hdspm_hw_rule_rate_in_channels()
5975 struct hdspm *hdspm = rule->private; in snd_hdspm_hw_rule_rate_out_channels()
5981 if (c->min >= hdspm->ss_out_channels) { in snd_hdspm_hw_rule_rate_out_channels()
5988 } else if (c->max <= hdspm->qs_out_channels) { in snd_hdspm_hw_rule_rate_out_channels()
5995 } else if (c->max <= hdspm->ds_out_channels) { in snd_hdspm_hw_rule_rate_out_channels()
6011 struct hdspm *hdspm = rule->private; in snd_hdspm_hw_rule_in_channels()
6015 list[0] = hdspm->qs_in_channels; in snd_hdspm_hw_rule_in_channels()
6016 list[1] = hdspm->ds_in_channels; in snd_hdspm_hw_rule_in_channels()
6017 list[2] = hdspm->ss_in_channels; in snd_hdspm_hw_rule_in_channels()
6025 struct hdspm *hdspm = rule->private; in snd_hdspm_hw_rule_out_channels()
6029 list[0] = hdspm->qs_out_channels; in snd_hdspm_hw_rule_out_channels()
6030 list[1] = hdspm->ds_out_channels; in snd_hdspm_hw_rule_out_channels()
6031 list[2] = hdspm->ss_out_channels; in snd_hdspm_hw_rule_out_channels()
6038 struct snd_pcm_runtime *runtime = substream->runtime; in snd_hdspm_open()
6039 bool playback = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK); in snd_hdspm_open()
6041 spin_lock_irq(&hdspm->lock); in snd_hdspm_open()
6043 runtime->hw = (playback) ? snd_hdspm_playback_subinfo : in snd_hdspm_open()
6047 if (!hdspm->capture_substream) in snd_hdspm_open()
6050 hdspm->playback_pid = current->pid; in snd_hdspm_open()
6051 hdspm->playback_substream = substream; in snd_hdspm_open()
6053 if (!hdspm->playback_substream) in snd_hdspm_open()
6056 hdspm->capture_pid = current->pid; in snd_hdspm_open()
6057 hdspm->capture_substream = substream; in snd_hdspm_open()
6060 spin_unlock_irq(&hdspm->lock); in snd_hdspm_open()
6065 switch (hdspm->io_type) { in snd_hdspm_open()
6086 if (AES32 == hdspm->io_type) { in snd_hdspm_open()
6087 runtime->hw.rates |= SNDRV_PCM_RATE_128000; in snd_hdspm_open()
6093 SNDRV_PCM_HW_PARAM_CHANNELS, -1); in snd_hdspm_open()
6099 SNDRV_PCM_HW_PARAM_CHANNELS, -1); in snd_hdspm_open()
6104 SNDRV_PCM_HW_PARAM_RATE, -1); in snd_hdspm_open()
6112 bool playback = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK); in snd_hdspm_release()
6114 spin_lock_irq(&hdspm->lock); in snd_hdspm_release()
6117 hdspm->playback_pid = -1; in snd_hdspm_release()
6118 hdspm->playback_substream = NULL; in snd_hdspm_release()
6120 hdspm->capture_pid = -1; in snd_hdspm_release()
6121 hdspm->capture_substream = NULL; in snd_hdspm_release()
6124 spin_unlock_irq(&hdspm->lock); in snd_hdspm_release()
6139 struct hdspm *hdspm = hw->private_data; in snd_hdspm_hwdep_ioctl()
6153 levels = &hdspm->peak_rms; in snd_hdspm_hwdep_ioctl()
6155 levels->input_peaks[i] = in snd_hdspm_hwdep_ioctl()
6156 readl(hdspm->iobase + in snd_hdspm_hwdep_ioctl()
6158 levels->playback_peaks[i] = in snd_hdspm_hwdep_ioctl()
6159 readl(hdspm->iobase + in snd_hdspm_hwdep_ioctl()
6161 levels->output_peaks[i] = in snd_hdspm_hwdep_ioctl()
6162 readl(hdspm->iobase + in snd_hdspm_hwdep_ioctl()
6165 levels->input_rms[i] = in snd_hdspm_hwdep_ioctl()
6166 ((uint64_t) readl(hdspm->iobase + in snd_hdspm_hwdep_ioctl()
6168 (uint64_t) readl(hdspm->iobase + in snd_hdspm_hwdep_ioctl()
6170 levels->playback_rms[i] = in snd_hdspm_hwdep_ioctl()
6171 ((uint64_t)readl(hdspm->iobase + in snd_hdspm_hwdep_ioctl()
6173 (uint64_t)readl(hdspm->iobase + in snd_hdspm_hwdep_ioctl()
6175 levels->output_rms[i] = in snd_hdspm_hwdep_ioctl()
6176 ((uint64_t)readl(hdspm->iobase + in snd_hdspm_hwdep_ioctl()
6178 (uint64_t)readl(hdspm->iobase + in snd_hdspm_hwdep_ioctl()
6182 if (hdspm->system_sample_rate > 96000) { in snd_hdspm_hwdep_ioctl()
6183 levels->speed = qs; in snd_hdspm_hwdep_ioctl()
6184 } else if (hdspm->system_sample_rate > 48000) { in snd_hdspm_hwdep_ioctl()
6185 levels->speed = ds; in snd_hdspm_hwdep_ioctl()
6187 levels->speed = ss; in snd_hdspm_hwdep_ioctl()
6189 levels->status2 = hdspm_read(hdspm, HDSPM_statusRegister2); in snd_hdspm_hwdep_ioctl()
6193 /* dev_err(hdspm->card->dev, "copy_to_user(.., .., %lu): %lu in snd_hdspm_hwdep_ioctl()
6196 return -EFAULT; in snd_hdspm_hwdep_ioctl()
6239 …dev_err(hdspm->card->dev, "copy_to_user(.., .., %lu): %lu [LTC]\n", sizeof(struct hdspm_ltc), s); … in snd_hdspm_hwdep_ioctl()
6240 return -EFAULT; in snd_hdspm_hwdep_ioctl()
6248 spin_lock_irq(&hdspm->lock); in snd_hdspm_hwdep_ioctl()
6252 info.system_sample_rate = hdspm->system_sample_rate; in snd_hdspm_hwdep_ioctl()
6260 spin_unlock_irq(&hdspm->lock); in snd_hdspm_hwdep_ioctl()
6262 return -EFAULT; in snd_hdspm_hwdep_ioctl()
6268 status.card_type = hdspm->io_type; in snd_hdspm_hwdep_ioctl()
6275 switch (hdspm->io_type) { in snd_hdspm_hwdep_ioctl()
6302 return -EFAULT; in snd_hdspm_hwdep_ioctl()
6310 hdspm_version.card_type = hdspm->io_type; in snd_hdspm_hwdep_ioctl()
6311 strscpy(hdspm_version.cardname, hdspm->card_name, in snd_hdspm_hwdep_ioctl()
6313 hdspm_version.serial = hdspm->serial; in snd_hdspm_hwdep_ioctl()
6314 hdspm_version.firmware_rev = hdspm->firmware_rev; in snd_hdspm_hwdep_ioctl()
6316 if (hdspm->tco) in snd_hdspm_hwdep_ioctl()
6321 return -EFAULT; in snd_hdspm_hwdep_ioctl()
6326 return -EFAULT; in snd_hdspm_hwdep_ioctl()
6327 if (copy_to_user((void __user *)mixer.mixer, hdspm->mixer, in snd_hdspm_hwdep_ioctl()
6329 return -EFAULT; in snd_hdspm_hwdep_ioctl()
6333 return -EINVAL; in snd_hdspm_hwdep_ioctl()
6359 hdspm->hwdep = hw; in snd_hdspm_create_hwdep()
6360 hw->private_data = hdspm; in snd_hdspm_create_hwdep()
6361 strcpy(hw->name, "HDSPM hwdep interface"); in snd_hdspm_create_hwdep()
6363 hw->ops.open = snd_hdspm_hwdep_dummy_op; in snd_hdspm_create_hwdep()
6364 hw->ops.ioctl = snd_hdspm_hwdep_ioctl; in snd_hdspm_create_hwdep()
6365 hw->ops.ioctl_compat = snd_hdspm_hwdep_ioctl; in snd_hdspm_create_hwdep()
6366 hw->ops.release = snd_hdspm_hwdep_dummy_op; in snd_hdspm_create_hwdep()
6372 /*------------------------------------------------------------
6374 ------------------------------------------------------------*/
6380 pcm = hdspm->pcm; in snd_hdspm_preallocate_memory()
6385 &hdspm->pci->dev, in snd_hdspm_preallocate_memory()
6387 dev_dbg(hdspm->card->dev, " Preallocated %zd Bytes\n", wanted); in snd_hdspm_preallocate_memory()
6405 /* ------------- ALSA Devices ---------------------------- */
6412 err = snd_pcm_new(card, hdspm->card_name, 0, 1, 1, &pcm); in snd_hdspm_create_pcm()
6416 hdspm->pcm = pcm; in snd_hdspm_create_pcm()
6417 pcm->private_data = hdspm; in snd_hdspm_create_pcm()
6418 strcpy(pcm->name, hdspm->card_name); in snd_hdspm_create_pcm()
6425 pcm->info_flags = SNDRV_PCM_INFO_JOINT_DUPLEX; in snd_hdspm_create_pcm()
6438 for (i = 0; i < hdspm->midiPorts; i++) in snd_hdspm_initialize_midi_flush()
6447 dev_dbg(card->dev, "Create card...\n"); in snd_hdspm_create_alsa_devices()
6453 while (i < hdspm->midiPorts) { in snd_hdspm_create_alsa_devices()
6469 dev_dbg(card->dev, "proc init...\n"); in snd_hdspm_create_alsa_devices()
6472 hdspm->system_sample_rate = -1; in snd_hdspm_create_alsa_devices()
6473 hdspm->last_external_sample_rate = -1; in snd_hdspm_create_alsa_devices()
6474 hdspm->last_internal_sample_rate = -1; in snd_hdspm_create_alsa_devices()
6475 hdspm->playback_pid = -1; in snd_hdspm_create_alsa_devices()
6476 hdspm->capture_pid = -1; in snd_hdspm_create_alsa_devices()
6477 hdspm->capture_substream = NULL; in snd_hdspm_create_alsa_devices()
6478 hdspm->playback_substream = NULL; in snd_hdspm_create_alsa_devices()
6480 dev_dbg(card->dev, "Set defaults...\n"); in snd_hdspm_create_alsa_devices()
6485 dev_dbg(card->dev, "Update mixer controls...\n"); in snd_hdspm_create_alsa_devices()
6488 dev_dbg(card->dev, "Initializing complete?\n"); in snd_hdspm_create_alsa_devices()
6492 dev_err(card->dev, "error registering card\n"); in snd_hdspm_create_alsa_devices()
6496 dev_dbg(card->dev, "... yes now\n"); in snd_hdspm_create_alsa_devices()
6505 struct pci_dev *pci = hdspm->pci; in snd_hdspm_create()
6509 hdspm->irq = -1; in snd_hdspm_create()
6510 hdspm->card = card; in snd_hdspm_create()
6512 spin_lock_init(&hdspm->lock); in snd_hdspm_create()
6513 INIT_WORK(&hdspm->midi_work, hdspm_midi_work); in snd_hdspm_create()
6515 pci_read_config_word(hdspm->pci, in snd_hdspm_create()
6516 PCI_CLASS_REVISION, &hdspm->firmware_rev); in snd_hdspm_create()
6518 strcpy(card->mixername, "Xilinx FPGA"); in snd_hdspm_create()
6519 strcpy(card->driver, "HDSPM"); in snd_hdspm_create()
6521 switch (hdspm->firmware_rev) { in snd_hdspm_create()
6523 hdspm->io_type = RayDAT; in snd_hdspm_create()
6524 hdspm->card_name = "RME RayDAT"; in snd_hdspm_create()
6525 hdspm->midiPorts = 2; in snd_hdspm_create()
6528 hdspm->io_type = AIO; in snd_hdspm_create()
6529 hdspm->card_name = "RME AIO"; in snd_hdspm_create()
6530 hdspm->midiPorts = 1; in snd_hdspm_create()
6533 hdspm->io_type = MADIface; in snd_hdspm_create()
6534 hdspm->card_name = "RME MADIface"; in snd_hdspm_create()
6535 hdspm->midiPorts = 1; in snd_hdspm_create()
6538 if ((hdspm->firmware_rev == 0xf0) || in snd_hdspm_create()
6539 ((hdspm->firmware_rev >= 0xe6) && in snd_hdspm_create()
6540 (hdspm->firmware_rev <= 0xea))) { in snd_hdspm_create()
6541 hdspm->io_type = AES32; in snd_hdspm_create()
6542 hdspm->card_name = "RME AES32"; in snd_hdspm_create()
6543 hdspm->midiPorts = 2; in snd_hdspm_create()
6544 } else if ((hdspm->firmware_rev == 0xd2) || in snd_hdspm_create()
6545 ((hdspm->firmware_rev >= 0xc8) && in snd_hdspm_create()
6546 (hdspm->firmware_rev <= 0xcf))) { in snd_hdspm_create()
6547 hdspm->io_type = MADI; in snd_hdspm_create()
6548 hdspm->card_name = "RME MADI"; in snd_hdspm_create()
6549 hdspm->midiPorts = 3; in snd_hdspm_create()
6551 dev_err(card->dev, in snd_hdspm_create()
6553 hdspm->firmware_rev); in snd_hdspm_create()
6554 return -ENODEV; in snd_hdspm_create()
6562 pci_set_master(hdspm->pci); in snd_hdspm_create()
6568 hdspm->port = pci_resource_start(pci, 0); in snd_hdspm_create()
6570 hdspm->iobase = pcim_iomap_table(pci)[0]; in snd_hdspm_create()
6571 dev_dbg(card->dev, "remapped region (0x%lx) 0x%lx-0x%lx\n", in snd_hdspm_create()
6572 (unsigned long)hdspm->iobase, hdspm->port, in snd_hdspm_create()
6573 hdspm->port + io_extent - 1); in snd_hdspm_create()
6575 if (devm_request_irq(&pci->dev, pci->irq, snd_hdspm_interrupt, in snd_hdspm_create()
6577 dev_err(card->dev, "unable to use IRQ %d\n", pci->irq); in snd_hdspm_create()
6578 return -EBUSY; in snd_hdspm_create()
6581 dev_dbg(card->dev, "use IRQ %d\n", pci->irq); in snd_hdspm_create()
6583 hdspm->irq = pci->irq; in snd_hdspm_create()
6584 card->sync_irq = hdspm->irq; in snd_hdspm_create()
6586 dev_dbg(card->dev, "kmalloc Mixer memory of %zd Bytes\n", in snd_hdspm_create()
6587 sizeof(*hdspm->mixer)); in snd_hdspm_create()
6588 hdspm->mixer = devm_kzalloc(&pci->dev, sizeof(*hdspm->mixer), GFP_KERNEL); in snd_hdspm_create()
6589 if (!hdspm->mixer) in snd_hdspm_create()
6590 return -ENOMEM; in snd_hdspm_create()
6592 hdspm->port_names_in = NULL; in snd_hdspm_create()
6593 hdspm->port_names_out = NULL; in snd_hdspm_create()
6595 switch (hdspm->io_type) { in snd_hdspm_create()
6597 hdspm->ss_in_channels = hdspm->ss_out_channels = AES32_CHANNELS; in snd_hdspm_create()
6598 hdspm->ds_in_channels = hdspm->ds_out_channels = AES32_CHANNELS; in snd_hdspm_create()
6599 hdspm->qs_in_channels = hdspm->qs_out_channels = AES32_CHANNELS; in snd_hdspm_create()
6601 hdspm->channel_map_in_ss = hdspm->channel_map_out_ss = in snd_hdspm_create()
6603 hdspm->channel_map_in_ds = hdspm->channel_map_out_ds = in snd_hdspm_create()
6605 hdspm->channel_map_in_qs = hdspm->channel_map_out_qs = in snd_hdspm_create()
6607 hdspm->port_names_in_ss = hdspm->port_names_out_ss = in snd_hdspm_create()
6609 hdspm->port_names_in_ds = hdspm->port_names_out_ds = in snd_hdspm_create()
6611 hdspm->port_names_in_qs = hdspm->port_names_out_qs = in snd_hdspm_create()
6614 hdspm->max_channels_out = hdspm->max_channels_in = in snd_hdspm_create()
6616 hdspm->port_names_in = hdspm->port_names_out = in snd_hdspm_create()
6618 hdspm->channel_map_in = hdspm->channel_map_out = in snd_hdspm_create()
6625 hdspm->ss_in_channels = hdspm->ss_out_channels = in snd_hdspm_create()
6627 hdspm->ds_in_channels = hdspm->ds_out_channels = in snd_hdspm_create()
6629 hdspm->qs_in_channels = hdspm->qs_out_channels = in snd_hdspm_create()
6632 hdspm->channel_map_in_ss = hdspm->channel_map_out_ss = in snd_hdspm_create()
6634 hdspm->channel_map_in_ds = hdspm->channel_map_out_ds = in snd_hdspm_create()
6636 hdspm->channel_map_in_qs = hdspm->channel_map_out_qs = in snd_hdspm_create()
6639 hdspm->port_names_in_ss = hdspm->port_names_out_ss = in snd_hdspm_create()
6641 hdspm->port_names_in_ds = hdspm->port_names_out_ds = in snd_hdspm_create()
6643 hdspm->port_names_in_qs = hdspm->port_names_out_qs = in snd_hdspm_create()
6648 hdspm->ss_in_channels = AIO_IN_SS_CHANNELS; in snd_hdspm_create()
6649 hdspm->ds_in_channels = AIO_IN_DS_CHANNELS; in snd_hdspm_create()
6650 hdspm->qs_in_channels = AIO_IN_QS_CHANNELS; in snd_hdspm_create()
6651 hdspm->ss_out_channels = AIO_OUT_SS_CHANNELS; in snd_hdspm_create()
6652 hdspm->ds_out_channels = AIO_OUT_DS_CHANNELS; in snd_hdspm_create()
6653 hdspm->qs_out_channels = AIO_OUT_QS_CHANNELS; in snd_hdspm_create()
6656 dev_info(card->dev, "AEB input board found\n"); in snd_hdspm_create()
6657 hdspm->ss_in_channels += 4; in snd_hdspm_create()
6658 hdspm->ds_in_channels += 4; in snd_hdspm_create()
6659 hdspm->qs_in_channels += 4; in snd_hdspm_create()
6663 dev_info(card->dev, "AEB output board found\n"); in snd_hdspm_create()
6664 hdspm->ss_out_channels += 4; in snd_hdspm_create()
6665 hdspm->ds_out_channels += 4; in snd_hdspm_create()
6666 hdspm->qs_out_channels += 4; in snd_hdspm_create()
6669 hdspm->channel_map_out_ss = channel_map_aio_out_ss; in snd_hdspm_create()
6670 hdspm->channel_map_out_ds = channel_map_aio_out_ds; in snd_hdspm_create()
6671 hdspm->channel_map_out_qs = channel_map_aio_out_qs; in snd_hdspm_create()
6673 hdspm->channel_map_in_ss = channel_map_aio_in_ss; in snd_hdspm_create()
6674 hdspm->channel_map_in_ds = channel_map_aio_in_ds; in snd_hdspm_create()
6675 hdspm->channel_map_in_qs = channel_map_aio_in_qs; in snd_hdspm_create()
6677 hdspm->port_names_in_ss = texts_ports_aio_in_ss; in snd_hdspm_create()
6678 hdspm->port_names_out_ss = texts_ports_aio_out_ss; in snd_hdspm_create()
6679 hdspm->port_names_in_ds = texts_ports_aio_in_ds; in snd_hdspm_create()
6680 hdspm->port_names_out_ds = texts_ports_aio_out_ds; in snd_hdspm_create()
6681 hdspm->port_names_in_qs = texts_ports_aio_in_qs; in snd_hdspm_create()
6682 hdspm->port_names_out_qs = texts_ports_aio_out_qs; in snd_hdspm_create()
6687 hdspm->ss_in_channels = hdspm->ss_out_channels = in snd_hdspm_create()
6689 hdspm->ds_in_channels = hdspm->ds_out_channels = in snd_hdspm_create()
6691 hdspm->qs_in_channels = hdspm->qs_out_channels = in snd_hdspm_create()
6694 hdspm->max_channels_in = RAYDAT_SS_CHANNELS; in snd_hdspm_create()
6695 hdspm->max_channels_out = RAYDAT_SS_CHANNELS; in snd_hdspm_create()
6697 hdspm->channel_map_in_ss = hdspm->channel_map_out_ss = in snd_hdspm_create()
6699 hdspm->channel_map_in_ds = hdspm->channel_map_out_ds = in snd_hdspm_create()
6701 hdspm->channel_map_in_qs = hdspm->channel_map_out_qs = in snd_hdspm_create()
6703 hdspm->channel_map_in = hdspm->channel_map_out = in snd_hdspm_create()
6706 hdspm->port_names_in_ss = hdspm->port_names_out_ss = in snd_hdspm_create()
6708 hdspm->port_names_in_ds = hdspm->port_names_out_ds = in snd_hdspm_create()
6710 hdspm->port_names_in_qs = hdspm->port_names_out_qs = in snd_hdspm_create()
6719 switch (hdspm->io_type) { in snd_hdspm_create()
6724 hdspm->midiPorts++; in snd_hdspm_create()
6725 hdspm->tco = kzalloc(sizeof(*hdspm->tco), GFP_KERNEL); in snd_hdspm_create()
6726 if (hdspm->tco) in snd_hdspm_create()
6729 dev_info(card->dev, "AIO/RayDAT TCO module found\n"); in snd_hdspm_create()
6731 hdspm->tco = NULL; in snd_hdspm_create()
6738 hdspm->midiPorts++; in snd_hdspm_create()
6739 hdspm->tco = kzalloc(sizeof(*hdspm->tco), GFP_KERNEL); in snd_hdspm_create()
6740 if (hdspm->tco) in snd_hdspm_create()
6743 dev_info(card->dev, "MADI/AES TCO module found\n"); in snd_hdspm_create()
6745 hdspm->tco = NULL; in snd_hdspm_create()
6750 hdspm->tco = NULL; in snd_hdspm_create()
6754 switch (hdspm->io_type) { in snd_hdspm_create()
6756 if (hdspm->tco) { in snd_hdspm_create()
6757 hdspm->texts_autosync = texts_autosync_aes_tco; in snd_hdspm_create()
6758 hdspm->texts_autosync_items = in snd_hdspm_create()
6761 hdspm->texts_autosync = texts_autosync_aes; in snd_hdspm_create()
6762 hdspm->texts_autosync_items = in snd_hdspm_create()
6768 if (hdspm->tco) { in snd_hdspm_create()
6769 hdspm->texts_autosync = texts_autosync_madi_tco; in snd_hdspm_create()
6770 hdspm->texts_autosync_items = 4; in snd_hdspm_create()
6772 hdspm->texts_autosync = texts_autosync_madi; in snd_hdspm_create()
6773 hdspm->texts_autosync_items = 3; in snd_hdspm_create()
6782 if (hdspm->tco) { in snd_hdspm_create()
6783 hdspm->texts_autosync = texts_autosync_raydat_tco; in snd_hdspm_create()
6784 hdspm->texts_autosync_items = 9; in snd_hdspm_create()
6786 hdspm->texts_autosync = texts_autosync_raydat; in snd_hdspm_create()
6787 hdspm->texts_autosync_items = 8; in snd_hdspm_create()
6792 if (hdspm->tco) { in snd_hdspm_create()
6793 hdspm->texts_autosync = texts_autosync_aio_tco; in snd_hdspm_create()
6794 hdspm->texts_autosync_items = 6; in snd_hdspm_create()
6796 hdspm->texts_autosync = texts_autosync_aio; in snd_hdspm_create()
6797 hdspm->texts_autosync_items = 5; in snd_hdspm_create()
6803 if (hdspm->io_type != MADIface) { in snd_hdspm_create()
6804 hdspm->serial = (hdspm_read(hdspm, in snd_hdspm_create()
6806 /* id contains either a user-provided value or the default in snd_hdspm_create()
6808 * fill card->id with the serial number. in snd_hdspm_create()
6810 * If the serial number is 0xFFFFFF, then we're dealing with in snd_hdspm_create()
6812 * this case, we don't set card->id to avoid collisions in snd_hdspm_create()
6815 if (!id[hdspm->dev] && hdspm->serial != 0xFFFFFF) { in snd_hdspm_create()
6816 snprintf(card->id, sizeof(card->id), in snd_hdspm_create()
6817 "HDSPMx%06x", hdspm->serial); in snd_hdspm_create()
6818 snd_card_set_id(card, card->id); in snd_hdspm_create()
6822 dev_dbg(card->dev, "create alsa devices.\n"); in snd_hdspm_create()
6835 struct hdspm *hdspm = card->private_data; in snd_hdspm_card_free()
6837 if (hdspm->port) { in snd_hdspm_card_free()
6838 cancel_work_sync(&hdspm->midi_work); in snd_hdspm_card_free()
6841 hdspm->control_register &= in snd_hdspm_card_free()
6846 hdspm->control_register); in snd_hdspm_card_free()
6860 return -ENODEV; in snd_hdspm_probe()
6863 return -ENOENT; in snd_hdspm_probe()
6866 err = snd_devm_card_new(&pci->dev, index[dev], id[dev], in snd_hdspm_probe()
6871 hdspm = card->private_data; in snd_hdspm_probe()
6872 card->private_free = snd_hdspm_card_free; in snd_hdspm_probe()
6873 hdspm->dev = dev; in snd_hdspm_probe()
6874 hdspm->pci = pci; in snd_hdspm_probe()
6880 if (hdspm->io_type != MADIface) { in snd_hdspm_probe()
6881 snprintf(card->shortname, sizeof(card->shortname), "%s_%x", in snd_hdspm_probe()
6882 hdspm->card_name, hdspm->serial); in snd_hdspm_probe()
6883 snprintf(card->longname, sizeof(card->longname), in snd_hdspm_probe()
6885 hdspm->card_name, hdspm->serial, in snd_hdspm_probe()
6886 hdspm->port, hdspm->irq); in snd_hdspm_probe()
6888 snprintf(card->shortname, sizeof(card->shortname), "%s", in snd_hdspm_probe()
6889 hdspm->card_name); in snd_hdspm_probe()
6890 snprintf(card->longname, sizeof(card->longname), in snd_hdspm_probe()
6892 hdspm->card_name, hdspm->port, hdspm->irq); in snd_hdspm_probe()