Lines Matching +full:serial +full:- +full:midi
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 ----------
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%*/
998 struct hdspm_midi midi[4]; member
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 /*----------------------------------------------------------------------------
1805 MIDI
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()
1882 unsigned char buf[128]; /* this buffer is designed to match the MIDI in snd_hdspm_midi_input_read()
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()
1902 /* flush the MIDI input FIFO */ 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()
2124 snprintf(buf, sizeof(buf), "%s MIDI %d", 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()
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()
4905 "MIDI FIFO: Out1=0x%x, Out2=0x%x, In1=0x%x, In2=0x%x \n", 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 str_on_off(hdspm->control_register & HDSPM_LineOut)); in snd_hdspm_proc_read_madi()
4935 str_on_off(hdspm->control_register & HDSPM_clr_tms), in snd_hdspm_proc_read_madi()
4936 (hdspm->control_register & HDSPM_TX_64ch) ? "64" : "56", in snd_hdspm_proc_read_madi()
4937 str_on_off(hdspm->control_register & HDSPM_AutoInp)); 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()
5062 "MIDI FIFO: Out1=0x%x, Out2=0x%x, In1=0x%x, In2=0x%x \n", 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 str_on_off(hdspm->control_register & HDSPM_clr_tms), in snd_hdspm_proc_read_aes32()
5092 str_on_off(hdspm->control_register & HDSPM_Emphasis), in snd_hdspm_proc_read_aes32()
5093 str_on_off(hdspm->control_register & HDSPM_Dolby)); in snd_hdspm_proc_read_aes32()
5104 hdspm->system_sample_rate); in snd_hdspm_proc_read_aes32()
5107 hdspm->control_register & HDSPM_DS_DoubleWire? in snd_hdspm_proc_read_aes32()
5110 hdspm->control_register & HDSPM_QS_DoubleWire? in snd_hdspm_proc_read_aes32()
5112 hdspm->control_register & HDSPM_QS_QuadWire? in snd_hdspm_proc_read_aes32()
5115 snd_iprintf(buffer, "--- Status:\n"); in snd_hdspm_proc_read_aes32()
5158 autosync_ref = "---"; break; in snd_hdspm_proc_read_aes32()
5172 struct hdspm *hdspm = entry->private_data; in snd_hdspm_proc_read_raydat()
5230 struct hdspm *hdspm = entry->private_data; in snd_hdspm_proc_read_debug()
5247 struct hdspm *hdspm = entry->private_data; in snd_hdspm_proc_ports_in()
5252 for (i = 0; i < hdspm->max_channels_in; i++) { in snd_hdspm_proc_ports_in()
5253 snd_iprintf(buffer, "%d=%s\n", i+1, hdspm->port_names_in[i]); in snd_hdspm_proc_ports_in()
5260 struct hdspm *hdspm = entry->private_data; in snd_hdspm_proc_ports_out()
5265 for (i = 0; i < hdspm->max_channels_out; i++) { in snd_hdspm_proc_ports_out()
5266 snd_iprintf(buffer, "%d=%s\n", i+1, hdspm->port_names_out[i]); in snd_hdspm_proc_ports_out()
5275 switch (hdspm->io_type) { in snd_hdspm_proc_init()
5292 snd_card_ro_proc_new(hdspm->card, "hdspm", hdspm, read); in snd_hdspm_proc_init()
5293 snd_card_ro_proc_new(hdspm->card, "ports.in", hdspm, in snd_hdspm_proc_init()
5295 snd_card_ro_proc_new(hdspm->card, "ports.out", hdspm, in snd_hdspm_proc_init()
5300 snd_card_ro_proc_new(hdspm->card, "debug", hdspm, in snd_hdspm_proc_init()
5305 /*------------------------------------------------------------
5307 ------------------------------------------------------------*/
5311 /* ASSUMPTION: hdspm->lock is either held, or there is no need to in snd_hdspm_set_defaults()
5317 hdspm->settings_register = 0; in snd_hdspm_set_defaults()
5319 switch (hdspm->io_type) { in snd_hdspm_set_defaults()
5322 hdspm->control_register = in snd_hdspm_set_defaults()
5328 hdspm->settings_register = 0x1 + 0x1000; in snd_hdspm_set_defaults()
5331 hdspm->control_register = in snd_hdspm_set_defaults()
5336 hdspm->control_register = in snd_hdspm_set_defaults()
5345 hdspm_write(hdspm, HDSPM_controlRegister, hdspm->control_register); in snd_hdspm_set_defaults()
5347 if (AES32 == hdspm->io_type) { in snd_hdspm_set_defaults()
5350 hdspm->control2_register = HDSPM_BIGENDIAN_MODE; in snd_hdspm_set_defaults()
5352 hdspm->control2_register = 0; in snd_hdspm_set_defaults()
5355 hdspm_write(hdspm, HDSPM_control2Reg, hdspm->control2_register); in snd_hdspm_set_defaults()
5364 hdspm_write(hdspm, HDSPM_WR_SETTINGS, hdspm->settings_register); in snd_hdspm_set_defaults()
5373 /*------------------------------------------------------------
5375 ------------------------------------------------------------*/
5381 int i, audio, midi, schedule = 0; in snd_hdspm_interrupt() local
5387 midi = status & (HDSPM_midi0IRQPending | HDSPM_midi1IRQPending | in snd_hdspm_interrupt()
5402 dev_info(hdspm->card->dev, "snd_hdspm_interrupt %llu @ %llx\n", in snd_hdspm_interrupt()
5403 now-hdspm->last_interrupt, status & 0xFFC0); in snd_hdspm_interrupt()
5404 hdspm->last_interrupt = now; in snd_hdspm_interrupt()
5407 if (!audio && !midi) in snd_hdspm_interrupt()
5411 hdspm->irq_count++; in snd_hdspm_interrupt()
5415 if (hdspm->capture_substream) in snd_hdspm_interrupt()
5416 snd_pcm_period_elapsed(hdspm->capture_substream); in snd_hdspm_interrupt()
5418 if (hdspm->playback_substream) in snd_hdspm_interrupt()
5419 snd_pcm_period_elapsed(hdspm->playback_substream); in snd_hdspm_interrupt()
5422 if (midi) { in snd_hdspm_interrupt()
5424 while (i < hdspm->midiPorts) { in snd_hdspm_interrupt()
5426 hdspm->midi[i].statusIn) & 0xff) && in snd_hdspm_interrupt()
5427 (status & hdspm->midi[i].irq)) { in snd_hdspm_interrupt()
5431 hdspm->control_register &= ~hdspm->midi[i].ie; in snd_hdspm_interrupt()
5433 hdspm->control_register); in snd_hdspm_interrupt()
5434 hdspm->midi[i].pending = 1; in snd_hdspm_interrupt()
5442 queue_work(system_highpri_wq, &hdspm->midi_work); in snd_hdspm_interrupt()
5448 /*------------------------------------------------------------
5450 ------------------------------------------------------------*/
5463 struct snd_pcm_runtime *runtime = substream->runtime; in snd_hdspm_reset()
5467 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) in snd_hdspm_reset()
5468 other = hdspm->capture_substream; in snd_hdspm_reset()
5470 other = hdspm->playback_substream; in snd_hdspm_reset()
5472 if (hdspm->running) in snd_hdspm_reset()
5473 runtime->status->hw_ptr = hdspm_hw_pointer(hdspm); in snd_hdspm_reset()
5475 runtime->status->hw_ptr = 0; in snd_hdspm_reset()
5478 struct snd_pcm_runtime *oruntime = other->runtime; in snd_hdspm_reset()
5481 oruntime->status->hw_ptr = in snd_hdspm_reset()
5482 runtime->status->hw_ptr; in snd_hdspm_reset()
5499 spin_lock_irq(&hdspm->lock); in snd_hdspm_hw_params()
5501 if (substream->pstr->stream == SNDRV_PCM_STREAM_PLAYBACK) { in snd_hdspm_hw_params()
5502 this_pid = hdspm->playback_pid; in snd_hdspm_hw_params()
5503 other_pid = hdspm->capture_pid; in snd_hdspm_hw_params()
5505 this_pid = hdspm->capture_pid; in snd_hdspm_hw_params()
5506 other_pid = hdspm->playback_pid; in snd_hdspm_hw_params()
5516 if (params_rate(params) != hdspm->system_sample_rate) { in snd_hdspm_hw_params()
5517 spin_unlock_irq(&hdspm->lock); in snd_hdspm_hw_params()
5520 return -EBUSY; in snd_hdspm_hw_params()
5523 if (params_period_size(params) != hdspm->period_bytes / 4) { in snd_hdspm_hw_params()
5524 spin_unlock_irq(&hdspm->lock); in snd_hdspm_hw_params()
5527 return -EBUSY; in snd_hdspm_hw_params()
5532 spin_unlock_irq(&hdspm->lock); in snd_hdspm_hw_params()
5534 /* how to make sure that the rate matches an externally-set one ? */ in snd_hdspm_hw_params()
5536 spin_lock_irq(&hdspm->lock); in snd_hdspm_hw_params()
5539 dev_info(hdspm->card->dev, "err on hdspm_set_rate: %d\n", err); in snd_hdspm_hw_params()
5540 spin_unlock_irq(&hdspm->lock); in snd_hdspm_hw_params()
5545 spin_unlock_irq(&hdspm->lock); in snd_hdspm_hw_params()
5550 dev_info(hdspm->card->dev, in snd_hdspm_hw_params()
5567 dev_info(hdspm->card->dev, in snd_hdspm_hw_params()
5572 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { in snd_hdspm_hw_params()
5575 int c = hdspm->channel_map_out[i]; in snd_hdspm_hw_params()
5585 hdspm->playback_buffer = in snd_hdspm_hw_params()
5586 (unsigned char *) substream->runtime->dma_area; in snd_hdspm_hw_params()
5587 dev_dbg(hdspm->card->dev, in snd_hdspm_hw_params()
5589 hdspm->playback_buffer); in snd_hdspm_hw_params()
5592 int c = hdspm->channel_map_in[i]; in snd_hdspm_hw_params()
5602 hdspm->capture_buffer = in snd_hdspm_hw_params()
5603 (unsigned char *) substream->runtime->dma_area; in snd_hdspm_hw_params()
5604 dev_dbg(hdspm->card->dev, in snd_hdspm_hw_params()
5606 hdspm->capture_buffer); in snd_hdspm_hw_params()
5610 dev_dbg(hdspm->card->dev, in snd_hdspm_hw_params()
5612 snd_pcm_direction_name(substream->stream), in snd_hdspm_hw_params()
5616 dev_dbg(hdspm->card->dev, in snd_hdspm_hw_params()
5618 snd_pcm_direction_name(substream->stream), in snd_hdspm_hw_params()
5629 if (hdspm->io_type == AES32) { in snd_hdspm_hw_params()
5636 if (!(hdspm->control_register & HDSPe_FLOAT_FORMAT)) in snd_hdspm_hw_params()
5637 dev_info(hdspm->card->dev, in snd_hdspm_hw_params()
5640 hdspm->control_register |= HDSPe_FLOAT_FORMAT; in snd_hdspm_hw_params()
5642 if (hdspm->control_register & HDSPe_FLOAT_FORMAT) in snd_hdspm_hw_params()
5643 dev_info(hdspm->card->dev, in snd_hdspm_hw_params()
5646 hdspm->control_register &= ~HDSPe_FLOAT_FORMAT; in snd_hdspm_hw_params()
5648 hdspm_write(hdspm, HDSPM_controlRegister, hdspm->control_register); in snd_hdspm_hw_params()
5658 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { in snd_hdspm_hw_free()
5664 hdspm->playback_buffer = NULL; in snd_hdspm_hw_free()
5669 hdspm->capture_buffer = NULL; in snd_hdspm_hw_free()
5682 unsigned int channel = info->channel; in snd_hdspm_channel_info()
5684 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { in snd_hdspm_channel_info()
5685 if (snd_BUG_ON(channel >= hdspm->max_channels_out)) { in snd_hdspm_channel_info()
5686 dev_info(hdspm->card->dev, in snd_hdspm_channel_info()
5689 return -EINVAL; in snd_hdspm_channel_info()
5692 channel = array_index_nospec(channel, hdspm->max_channels_out); in snd_hdspm_channel_info()
5693 if (hdspm->channel_map_out[channel] < 0) { in snd_hdspm_channel_info()
5694 dev_info(hdspm->card->dev, in snd_hdspm_channel_info()
5697 return -EINVAL; in snd_hdspm_channel_info()
5700 info->offset = hdspm->channel_map_out[channel] * in snd_hdspm_channel_info()
5703 if (snd_BUG_ON(channel >= hdspm->max_channels_in)) { in snd_hdspm_channel_info()
5704 dev_info(hdspm->card->dev, in snd_hdspm_channel_info()
5707 return -EINVAL; in snd_hdspm_channel_info()
5710 channel = array_index_nospec(channel, hdspm->max_channels_in); in snd_hdspm_channel_info()
5711 if (hdspm->channel_map_in[channel] < 0) { in snd_hdspm_channel_info()
5712 dev_info(hdspm->card->dev, in snd_hdspm_channel_info()
5715 return -EINVAL; in snd_hdspm_channel_info()
5718 info->offset = hdspm->channel_map_in[channel] * in snd_hdspm_channel_info()
5722 info->first = 0; in snd_hdspm_channel_info()
5723 info->step = 32; in snd_hdspm_channel_info()
5753 spin_lock(&hdspm->lock); in snd_hdspm_trigger()
5754 running = hdspm->running; in snd_hdspm_trigger()
5757 running |= 1 << substream->stream; in snd_hdspm_trigger()
5760 running &= ~(1 << substream->stream); in snd_hdspm_trigger()
5764 spin_unlock(&hdspm->lock); in snd_hdspm_trigger()
5765 return -EINVAL; in snd_hdspm_trigger()
5767 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) in snd_hdspm_trigger()
5768 other = hdspm->capture_substream; in snd_hdspm_trigger()
5770 other = hdspm->playback_substream; in snd_hdspm_trigger()
5778 running |= 1 << s->stream; in snd_hdspm_trigger()
5780 running &= ~(1 << s->stream); in snd_hdspm_trigger()
5786 && substream->stream == in snd_hdspm_trigger()
5791 substream->stream == SNDRV_PCM_STREAM_PLAYBACK) in snd_hdspm_trigger()
5795 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) in snd_hdspm_trigger()
5800 if (!hdspm->running && running) in snd_hdspm_trigger()
5802 else if (hdspm->running && !running) in snd_hdspm_trigger()
5804 hdspm->running = running; in snd_hdspm_trigger()
5805 spin_unlock(&hdspm->lock); in snd_hdspm_trigger()
5868 struct hdspm *hdspm = rule->private; in snd_hdspm_hw_rule_in_channels_rate()
5874 if (r->min > 96000 && r->max <= 192000) { in snd_hdspm_hw_rule_in_channels_rate()
5876 .min = hdspm->qs_in_channels, in snd_hdspm_hw_rule_in_channels_rate()
5877 .max = hdspm->qs_in_channels, in snd_hdspm_hw_rule_in_channels_rate()
5881 } else if (r->min > 48000 && r->max <= 96000) { in snd_hdspm_hw_rule_in_channels_rate()
5883 .min = hdspm->ds_in_channels, in snd_hdspm_hw_rule_in_channels_rate()
5884 .max = hdspm->ds_in_channels, in snd_hdspm_hw_rule_in_channels_rate()
5888 } else if (r->max < 64000) { in snd_hdspm_hw_rule_in_channels_rate()
5890 .min = hdspm->ss_in_channels, in snd_hdspm_hw_rule_in_channels_rate()
5891 .max = hdspm->ss_in_channels, in snd_hdspm_hw_rule_in_channels_rate()
5903 struct hdspm *hdspm = rule->private; in snd_hdspm_hw_rule_out_channels_rate()
5909 if (r->min > 96000 && r->max <= 192000) { in snd_hdspm_hw_rule_out_channels_rate()
5911 .min = hdspm->qs_out_channels, in snd_hdspm_hw_rule_out_channels_rate()
5912 .max = hdspm->qs_out_channels, in snd_hdspm_hw_rule_out_channels_rate()
5916 } else if (r->min > 48000 && r->max <= 96000) { in snd_hdspm_hw_rule_out_channels_rate()
5918 .min = hdspm->ds_out_channels, in snd_hdspm_hw_rule_out_channels_rate()
5919 .max = hdspm->ds_out_channels, in snd_hdspm_hw_rule_out_channels_rate()
5923 } else if (r->max < 64000) { in snd_hdspm_hw_rule_out_channels_rate()
5925 .min = hdspm->ss_out_channels, in snd_hdspm_hw_rule_out_channels_rate()
5926 .max = hdspm->ss_out_channels, in snd_hdspm_hw_rule_out_channels_rate()
5938 struct hdspm *hdspm = rule->private; in snd_hdspm_hw_rule_rate_in_channels()
5944 if (c->min >= hdspm->ss_in_channels) { in snd_hdspm_hw_rule_rate_in_channels()
5951 } else if (c->max <= hdspm->qs_in_channels) { in snd_hdspm_hw_rule_rate_in_channels()
5958 } else if (c->max <= hdspm->ds_in_channels) { in snd_hdspm_hw_rule_rate_in_channels()
5972 struct hdspm *hdspm = rule->private; in snd_hdspm_hw_rule_rate_out_channels()
5978 if (c->min >= hdspm->ss_out_channels) { in snd_hdspm_hw_rule_rate_out_channels()
5985 } else if (c->max <= hdspm->qs_out_channels) { in snd_hdspm_hw_rule_rate_out_channels()
5992 } else if (c->max <= hdspm->ds_out_channels) { in snd_hdspm_hw_rule_rate_out_channels()
6008 struct hdspm *hdspm = rule->private; in snd_hdspm_hw_rule_in_channels()
6012 list[0] = hdspm->qs_in_channels; in snd_hdspm_hw_rule_in_channels()
6013 list[1] = hdspm->ds_in_channels; in snd_hdspm_hw_rule_in_channels()
6014 list[2] = hdspm->ss_in_channels; in snd_hdspm_hw_rule_in_channels()
6022 struct hdspm *hdspm = rule->private; in snd_hdspm_hw_rule_out_channels()
6026 list[0] = hdspm->qs_out_channels; in snd_hdspm_hw_rule_out_channels()
6027 list[1] = hdspm->ds_out_channels; in snd_hdspm_hw_rule_out_channels()
6028 list[2] = hdspm->ss_out_channels; in snd_hdspm_hw_rule_out_channels()
6035 struct snd_pcm_runtime *runtime = substream->runtime; in snd_hdspm_open()
6036 bool playback = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK); in snd_hdspm_open()
6038 spin_lock_irq(&hdspm->lock); in snd_hdspm_open()
6040 runtime->hw = (playback) ? snd_hdspm_playback_subinfo : in snd_hdspm_open()
6044 if (!hdspm->capture_substream) in snd_hdspm_open()
6047 hdspm->playback_pid = current->pid; in snd_hdspm_open()
6048 hdspm->playback_substream = substream; in snd_hdspm_open()
6050 if (!hdspm->playback_substream) in snd_hdspm_open()
6053 hdspm->capture_pid = current->pid; in snd_hdspm_open()
6054 hdspm->capture_substream = substream; in snd_hdspm_open()
6057 spin_unlock_irq(&hdspm->lock); in snd_hdspm_open()
6062 switch (hdspm->io_type) { in snd_hdspm_open()
6083 if (AES32 == hdspm->io_type) { in snd_hdspm_open()
6084 runtime->hw.rates |= SNDRV_PCM_RATE_128000; in snd_hdspm_open()
6090 SNDRV_PCM_HW_PARAM_CHANNELS, -1); in snd_hdspm_open()
6096 SNDRV_PCM_HW_PARAM_CHANNELS, -1); in snd_hdspm_open()
6101 SNDRV_PCM_HW_PARAM_RATE, -1); in snd_hdspm_open()
6109 bool playback = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK); in snd_hdspm_release()
6111 spin_lock_irq(&hdspm->lock); in snd_hdspm_release()
6114 hdspm->playback_pid = -1; in snd_hdspm_release()
6115 hdspm->playback_substream = NULL; in snd_hdspm_release()
6117 hdspm->capture_pid = -1; in snd_hdspm_release()
6118 hdspm->capture_substream = NULL; in snd_hdspm_release()
6121 spin_unlock_irq(&hdspm->lock); in snd_hdspm_release()
6136 struct hdspm *hdspm = hw->private_data; in snd_hdspm_hwdep_ioctl()
6150 levels = &hdspm->peak_rms; in snd_hdspm_hwdep_ioctl()
6152 levels->input_peaks[i] = in snd_hdspm_hwdep_ioctl()
6153 readl(hdspm->iobase + in snd_hdspm_hwdep_ioctl()
6155 levels->playback_peaks[i] = in snd_hdspm_hwdep_ioctl()
6156 readl(hdspm->iobase + in snd_hdspm_hwdep_ioctl()
6158 levels->output_peaks[i] = in snd_hdspm_hwdep_ioctl()
6159 readl(hdspm->iobase + in snd_hdspm_hwdep_ioctl()
6162 levels->input_rms[i] = in snd_hdspm_hwdep_ioctl()
6163 ((uint64_t) readl(hdspm->iobase + in snd_hdspm_hwdep_ioctl()
6165 (uint64_t) readl(hdspm->iobase + in snd_hdspm_hwdep_ioctl()
6167 levels->playback_rms[i] = in snd_hdspm_hwdep_ioctl()
6168 ((uint64_t)readl(hdspm->iobase + in snd_hdspm_hwdep_ioctl()
6170 (uint64_t)readl(hdspm->iobase + in snd_hdspm_hwdep_ioctl()
6172 levels->output_rms[i] = in snd_hdspm_hwdep_ioctl()
6173 ((uint64_t)readl(hdspm->iobase + in snd_hdspm_hwdep_ioctl()
6175 (uint64_t)readl(hdspm->iobase + in snd_hdspm_hwdep_ioctl()
6179 if (hdspm->system_sample_rate > 96000) { in snd_hdspm_hwdep_ioctl()
6180 levels->speed = qs; in snd_hdspm_hwdep_ioctl()
6181 } else if (hdspm->system_sample_rate > 48000) { in snd_hdspm_hwdep_ioctl()
6182 levels->speed = ds; in snd_hdspm_hwdep_ioctl()
6184 levels->speed = ss; in snd_hdspm_hwdep_ioctl()
6186 levels->status2 = hdspm_read(hdspm, HDSPM_statusRegister2); in snd_hdspm_hwdep_ioctl()
6190 /* dev_err(hdspm->card->dev, "copy_to_user(.., .., %lu): %lu in snd_hdspm_hwdep_ioctl()
6193 return -EFAULT; in snd_hdspm_hwdep_ioctl()
6236 …dev_err(hdspm->card->dev, "copy_to_user(.., .., %lu): %lu [LTC]\n", sizeof(struct hdspm_ltc), s); … in snd_hdspm_hwdep_ioctl()
6237 return -EFAULT; in snd_hdspm_hwdep_ioctl()
6245 spin_lock_irq(&hdspm->lock); in snd_hdspm_hwdep_ioctl()
6249 info.system_sample_rate = hdspm->system_sample_rate; in snd_hdspm_hwdep_ioctl()
6257 spin_unlock_irq(&hdspm->lock); in snd_hdspm_hwdep_ioctl()
6259 return -EFAULT; in snd_hdspm_hwdep_ioctl()
6265 status.card_type = hdspm->io_type; in snd_hdspm_hwdep_ioctl()
6272 switch (hdspm->io_type) { in snd_hdspm_hwdep_ioctl()
6299 return -EFAULT; in snd_hdspm_hwdep_ioctl()
6307 hdspm_version.card_type = hdspm->io_type; in snd_hdspm_hwdep_ioctl()
6308 strscpy(hdspm_version.cardname, hdspm->card_name, in snd_hdspm_hwdep_ioctl()
6310 hdspm_version.serial = hdspm->serial; in snd_hdspm_hwdep_ioctl()
6311 hdspm_version.firmware_rev = hdspm->firmware_rev; in snd_hdspm_hwdep_ioctl()
6313 if (hdspm->tco) in snd_hdspm_hwdep_ioctl()
6318 return -EFAULT; in snd_hdspm_hwdep_ioctl()
6323 return -EFAULT; in snd_hdspm_hwdep_ioctl()
6324 if (copy_to_user((void __user *)mixer.mixer, hdspm->mixer, in snd_hdspm_hwdep_ioctl()
6326 return -EFAULT; in snd_hdspm_hwdep_ioctl()
6330 return -EINVAL; in snd_hdspm_hwdep_ioctl()
6356 hdspm->hwdep = hw; in snd_hdspm_create_hwdep()
6357 hw->private_data = hdspm; in snd_hdspm_create_hwdep()
6358 strcpy(hw->name, "HDSPM hwdep interface"); in snd_hdspm_create_hwdep()
6360 hw->ops.open = snd_hdspm_hwdep_dummy_op; in snd_hdspm_create_hwdep()
6361 hw->ops.ioctl = snd_hdspm_hwdep_ioctl; in snd_hdspm_create_hwdep()
6362 hw->ops.ioctl_compat = snd_hdspm_hwdep_ioctl; in snd_hdspm_create_hwdep()
6363 hw->ops.release = snd_hdspm_hwdep_dummy_op; in snd_hdspm_create_hwdep()
6369 /*------------------------------------------------------------
6371 ------------------------------------------------------------*/
6377 pcm = hdspm->pcm; in snd_hdspm_preallocate_memory()
6382 &hdspm->pci->dev, in snd_hdspm_preallocate_memory()
6384 dev_dbg(hdspm->card->dev, " Preallocated %zd Bytes\n", wanted); in snd_hdspm_preallocate_memory()
6402 /* ------------- ALSA Devices ---------------------------- */
6409 err = snd_pcm_new(card, hdspm->card_name, 0, 1, 1, &pcm); in snd_hdspm_create_pcm()
6413 hdspm->pcm = pcm; in snd_hdspm_create_pcm()
6414 pcm->private_data = hdspm; in snd_hdspm_create_pcm()
6415 strcpy(pcm->name, hdspm->card_name); in snd_hdspm_create_pcm()
6422 pcm->info_flags = SNDRV_PCM_INFO_JOINT_DUPLEX; in snd_hdspm_create_pcm()
6435 for (i = 0; i < hdspm->midiPorts; i++) in snd_hdspm_initialize_midi_flush()
6444 dev_dbg(card->dev, "Create card...\n"); in snd_hdspm_create_alsa_devices()
6450 while (i < hdspm->midiPorts) { in snd_hdspm_create_alsa_devices()
6466 dev_dbg(card->dev, "proc init...\n"); in snd_hdspm_create_alsa_devices()
6469 hdspm->system_sample_rate = -1; in snd_hdspm_create_alsa_devices()
6470 hdspm->last_external_sample_rate = -1; in snd_hdspm_create_alsa_devices()
6471 hdspm->last_internal_sample_rate = -1; in snd_hdspm_create_alsa_devices()
6472 hdspm->playback_pid = -1; in snd_hdspm_create_alsa_devices()
6473 hdspm->capture_pid = -1; in snd_hdspm_create_alsa_devices()
6474 hdspm->capture_substream = NULL; in snd_hdspm_create_alsa_devices()
6475 hdspm->playback_substream = NULL; in snd_hdspm_create_alsa_devices()
6477 dev_dbg(card->dev, "Set defaults...\n"); in snd_hdspm_create_alsa_devices()
6482 dev_dbg(card->dev, "Update mixer controls...\n"); in snd_hdspm_create_alsa_devices()
6485 dev_dbg(card->dev, "Initializing complete?\n"); in snd_hdspm_create_alsa_devices()
6489 dev_err(card->dev, "error registering card\n"); in snd_hdspm_create_alsa_devices()
6493 dev_dbg(card->dev, "... yes now\n"); in snd_hdspm_create_alsa_devices()
6502 struct pci_dev *pci = hdspm->pci; in snd_hdspm_create()
6506 hdspm->irq = -1; in snd_hdspm_create()
6507 hdspm->card = card; in snd_hdspm_create()
6509 spin_lock_init(&hdspm->lock); in snd_hdspm_create()
6510 INIT_WORK(&hdspm->midi_work, hdspm_midi_work); in snd_hdspm_create()
6512 pci_read_config_word(hdspm->pci, in snd_hdspm_create()
6513 PCI_CLASS_REVISION, &hdspm->firmware_rev); in snd_hdspm_create()
6515 strcpy(card->mixername, "Xilinx FPGA"); in snd_hdspm_create()
6516 strcpy(card->driver, "HDSPM"); in snd_hdspm_create()
6518 switch (hdspm->firmware_rev) { in snd_hdspm_create()
6520 hdspm->io_type = RayDAT; in snd_hdspm_create()
6521 hdspm->card_name = "RME RayDAT"; in snd_hdspm_create()
6522 hdspm->midiPorts = 2; in snd_hdspm_create()
6525 hdspm->io_type = AIO; in snd_hdspm_create()
6526 hdspm->card_name = "RME AIO"; in snd_hdspm_create()
6527 hdspm->midiPorts = 1; in snd_hdspm_create()
6530 hdspm->io_type = MADIface; in snd_hdspm_create()
6531 hdspm->card_name = "RME MADIface"; in snd_hdspm_create()
6532 hdspm->midiPorts = 1; in snd_hdspm_create()
6535 if ((hdspm->firmware_rev == 0xf0) || in snd_hdspm_create()
6536 ((hdspm->firmware_rev >= 0xe6) && in snd_hdspm_create()
6537 (hdspm->firmware_rev <= 0xea))) { in snd_hdspm_create()
6538 hdspm->io_type = AES32; in snd_hdspm_create()
6539 hdspm->card_name = "RME AES32"; in snd_hdspm_create()
6540 hdspm->midiPorts = 2; in snd_hdspm_create()
6541 } else if ((hdspm->firmware_rev == 0xd2) || in snd_hdspm_create()
6542 ((hdspm->firmware_rev >= 0xc8) && in snd_hdspm_create()
6543 (hdspm->firmware_rev <= 0xcf))) { in snd_hdspm_create()
6544 hdspm->io_type = MADI; in snd_hdspm_create()
6545 hdspm->card_name = "RME MADI"; in snd_hdspm_create()
6546 hdspm->midiPorts = 3; in snd_hdspm_create()
6548 dev_err(card->dev, in snd_hdspm_create()
6550 hdspm->firmware_rev); in snd_hdspm_create()
6551 return -ENODEV; in snd_hdspm_create()
6559 pci_set_master(hdspm->pci); in snd_hdspm_create()
6565 hdspm->port = pci_resource_start(pci, 0); in snd_hdspm_create()
6567 hdspm->iobase = pcim_iomap_table(pci)[0]; in snd_hdspm_create()
6568 dev_dbg(card->dev, "remapped region (0x%lx) 0x%lx-0x%lx\n", in snd_hdspm_create()
6569 (unsigned long)hdspm->iobase, hdspm->port, in snd_hdspm_create()
6570 hdspm->port + io_extent - 1); in snd_hdspm_create()
6572 if (devm_request_irq(&pci->dev, pci->irq, snd_hdspm_interrupt, in snd_hdspm_create()
6574 dev_err(card->dev, "unable to use IRQ %d\n", pci->irq); in snd_hdspm_create()
6575 return -EBUSY; in snd_hdspm_create()
6578 dev_dbg(card->dev, "use IRQ %d\n", pci->irq); in snd_hdspm_create()
6580 hdspm->irq = pci->irq; in snd_hdspm_create()
6581 card->sync_irq = hdspm->irq; in snd_hdspm_create()
6583 dev_dbg(card->dev, "kmalloc Mixer memory of %zd Bytes\n", in snd_hdspm_create()
6584 sizeof(*hdspm->mixer)); in snd_hdspm_create()
6585 hdspm->mixer = devm_kzalloc(&pci->dev, sizeof(*hdspm->mixer), GFP_KERNEL); in snd_hdspm_create()
6586 if (!hdspm->mixer) in snd_hdspm_create()
6587 return -ENOMEM; in snd_hdspm_create()
6589 hdspm->port_names_in = NULL; in snd_hdspm_create()
6590 hdspm->port_names_out = NULL; in snd_hdspm_create()
6592 switch (hdspm->io_type) { in snd_hdspm_create()
6594 hdspm->ss_in_channels = hdspm->ss_out_channels = AES32_CHANNELS; in snd_hdspm_create()
6595 hdspm->ds_in_channels = hdspm->ds_out_channels = AES32_CHANNELS; in snd_hdspm_create()
6596 hdspm->qs_in_channels = hdspm->qs_out_channels = AES32_CHANNELS; in snd_hdspm_create()
6598 hdspm->channel_map_in_ss = hdspm->channel_map_out_ss = in snd_hdspm_create()
6600 hdspm->channel_map_in_ds = hdspm->channel_map_out_ds = in snd_hdspm_create()
6602 hdspm->channel_map_in_qs = hdspm->channel_map_out_qs = in snd_hdspm_create()
6604 hdspm->port_names_in_ss = hdspm->port_names_out_ss = in snd_hdspm_create()
6606 hdspm->port_names_in_ds = hdspm->port_names_out_ds = in snd_hdspm_create()
6608 hdspm->port_names_in_qs = hdspm->port_names_out_qs = in snd_hdspm_create()
6611 hdspm->max_channels_out = hdspm->max_channels_in = in snd_hdspm_create()
6613 hdspm->port_names_in = hdspm->port_names_out = in snd_hdspm_create()
6615 hdspm->channel_map_in = hdspm->channel_map_out = in snd_hdspm_create()
6622 hdspm->ss_in_channels = hdspm->ss_out_channels = in snd_hdspm_create()
6624 hdspm->ds_in_channels = hdspm->ds_out_channels = in snd_hdspm_create()
6626 hdspm->qs_in_channels = hdspm->qs_out_channels = in snd_hdspm_create()
6629 hdspm->channel_map_in_ss = hdspm->channel_map_out_ss = in snd_hdspm_create()
6631 hdspm->channel_map_in_ds = hdspm->channel_map_out_ds = in snd_hdspm_create()
6633 hdspm->channel_map_in_qs = hdspm->channel_map_out_qs = in snd_hdspm_create()
6636 hdspm->port_names_in_ss = hdspm->port_names_out_ss = in snd_hdspm_create()
6638 hdspm->port_names_in_ds = hdspm->port_names_out_ds = in snd_hdspm_create()
6640 hdspm->port_names_in_qs = hdspm->port_names_out_qs = in snd_hdspm_create()
6645 hdspm->ss_in_channels = AIO_IN_SS_CHANNELS; in snd_hdspm_create()
6646 hdspm->ds_in_channels = AIO_IN_DS_CHANNELS; in snd_hdspm_create()
6647 hdspm->qs_in_channels = AIO_IN_QS_CHANNELS; in snd_hdspm_create()
6648 hdspm->ss_out_channels = AIO_OUT_SS_CHANNELS; in snd_hdspm_create()
6649 hdspm->ds_out_channels = AIO_OUT_DS_CHANNELS; in snd_hdspm_create()
6650 hdspm->qs_out_channels = AIO_OUT_QS_CHANNELS; in snd_hdspm_create()
6653 dev_info(card->dev, "AEB input board found\n"); in snd_hdspm_create()
6654 hdspm->ss_in_channels += 4; in snd_hdspm_create()
6655 hdspm->ds_in_channels += 4; in snd_hdspm_create()
6656 hdspm->qs_in_channels += 4; in snd_hdspm_create()
6660 dev_info(card->dev, "AEB output board found\n"); in snd_hdspm_create()
6661 hdspm->ss_out_channels += 4; in snd_hdspm_create()
6662 hdspm->ds_out_channels += 4; in snd_hdspm_create()
6663 hdspm->qs_out_channels += 4; in snd_hdspm_create()
6666 hdspm->channel_map_out_ss = channel_map_aio_out_ss; in snd_hdspm_create()
6667 hdspm->channel_map_out_ds = channel_map_aio_out_ds; in snd_hdspm_create()
6668 hdspm->channel_map_out_qs = channel_map_aio_out_qs; in snd_hdspm_create()
6670 hdspm->channel_map_in_ss = channel_map_aio_in_ss; in snd_hdspm_create()
6671 hdspm->channel_map_in_ds = channel_map_aio_in_ds; in snd_hdspm_create()
6672 hdspm->channel_map_in_qs = channel_map_aio_in_qs; in snd_hdspm_create()
6674 hdspm->port_names_in_ss = texts_ports_aio_in_ss; in snd_hdspm_create()
6675 hdspm->port_names_out_ss = texts_ports_aio_out_ss; in snd_hdspm_create()
6676 hdspm->port_names_in_ds = texts_ports_aio_in_ds; in snd_hdspm_create()
6677 hdspm->port_names_out_ds = texts_ports_aio_out_ds; in snd_hdspm_create()
6678 hdspm->port_names_in_qs = texts_ports_aio_in_qs; in snd_hdspm_create()
6679 hdspm->port_names_out_qs = texts_ports_aio_out_qs; in snd_hdspm_create()
6684 hdspm->ss_in_channels = hdspm->ss_out_channels = in snd_hdspm_create()
6686 hdspm->ds_in_channels = hdspm->ds_out_channels = in snd_hdspm_create()
6688 hdspm->qs_in_channels = hdspm->qs_out_channels = in snd_hdspm_create()
6691 hdspm->max_channels_in = RAYDAT_SS_CHANNELS; in snd_hdspm_create()
6692 hdspm->max_channels_out = RAYDAT_SS_CHANNELS; in snd_hdspm_create()
6694 hdspm->channel_map_in_ss = hdspm->channel_map_out_ss = in snd_hdspm_create()
6696 hdspm->channel_map_in_ds = hdspm->channel_map_out_ds = in snd_hdspm_create()
6698 hdspm->channel_map_in_qs = hdspm->channel_map_out_qs = in snd_hdspm_create()
6700 hdspm->channel_map_in = hdspm->channel_map_out = in snd_hdspm_create()
6703 hdspm->port_names_in_ss = hdspm->port_names_out_ss = in snd_hdspm_create()
6705 hdspm->port_names_in_ds = hdspm->port_names_out_ds = in snd_hdspm_create()
6707 hdspm->port_names_in_qs = hdspm->port_names_out_qs = in snd_hdspm_create()
6716 switch (hdspm->io_type) { in snd_hdspm_create()
6721 hdspm->midiPorts++; in snd_hdspm_create()
6722 hdspm->tco = kzalloc(sizeof(*hdspm->tco), GFP_KERNEL); in snd_hdspm_create()
6723 if (hdspm->tco) in snd_hdspm_create()
6726 dev_info(card->dev, "AIO/RayDAT TCO module found\n"); in snd_hdspm_create()
6728 hdspm->tco = NULL; in snd_hdspm_create()
6735 hdspm->midiPorts++; in snd_hdspm_create()
6736 hdspm->tco = kzalloc(sizeof(*hdspm->tco), GFP_KERNEL); in snd_hdspm_create()
6737 if (hdspm->tco) in snd_hdspm_create()
6740 dev_info(card->dev, "MADI/AES TCO module found\n"); in snd_hdspm_create()
6742 hdspm->tco = NULL; in snd_hdspm_create()
6747 hdspm->tco = NULL; in snd_hdspm_create()
6751 switch (hdspm->io_type) { in snd_hdspm_create()
6753 if (hdspm->tco) { in snd_hdspm_create()
6754 hdspm->texts_autosync = texts_autosync_aes_tco; in snd_hdspm_create()
6755 hdspm->texts_autosync_items = in snd_hdspm_create()
6758 hdspm->texts_autosync = texts_autosync_aes; in snd_hdspm_create()
6759 hdspm->texts_autosync_items = in snd_hdspm_create()
6765 if (hdspm->tco) { in snd_hdspm_create()
6766 hdspm->texts_autosync = texts_autosync_madi_tco; in snd_hdspm_create()
6767 hdspm->texts_autosync_items = 4; in snd_hdspm_create()
6769 hdspm->texts_autosync = texts_autosync_madi; in snd_hdspm_create()
6770 hdspm->texts_autosync_items = 3; in snd_hdspm_create()
6779 if (hdspm->tco) { in snd_hdspm_create()
6780 hdspm->texts_autosync = texts_autosync_raydat_tco; in snd_hdspm_create()
6781 hdspm->texts_autosync_items = 9; in snd_hdspm_create()
6783 hdspm->texts_autosync = texts_autosync_raydat; in snd_hdspm_create()
6784 hdspm->texts_autosync_items = 8; in snd_hdspm_create()
6789 if (hdspm->tco) { in snd_hdspm_create()
6790 hdspm->texts_autosync = texts_autosync_aio_tco; in snd_hdspm_create()
6791 hdspm->texts_autosync_items = 6; in snd_hdspm_create()
6793 hdspm->texts_autosync = texts_autosync_aio; in snd_hdspm_create()
6794 hdspm->texts_autosync_items = 5; in snd_hdspm_create()
6800 if (hdspm->io_type != MADIface) { in snd_hdspm_create()
6801 hdspm->serial = (hdspm_read(hdspm, in snd_hdspm_create()
6803 /* id contains either a user-provided value or the default in snd_hdspm_create()
6805 * fill card->id with the serial number. in snd_hdspm_create()
6807 * If the serial number is 0xFFFFFF, then we're dealing with in snd_hdspm_create()
6809 * this case, we don't set card->id to avoid collisions in snd_hdspm_create()
6812 if (!id[hdspm->dev] && hdspm->serial != 0xFFFFFF) { in snd_hdspm_create()
6813 snprintf(card->id, sizeof(card->id), in snd_hdspm_create()
6814 "HDSPMx%06x", hdspm->serial); in snd_hdspm_create()
6815 snd_card_set_id(card, card->id); in snd_hdspm_create()
6819 dev_dbg(card->dev, "create alsa devices.\n"); in snd_hdspm_create()
6832 struct hdspm *hdspm = card->private_data; in snd_hdspm_card_free()
6834 if (hdspm->port) { in snd_hdspm_card_free()
6835 cancel_work_sync(&hdspm->midi_work); in snd_hdspm_card_free()
6838 hdspm->control_register &= in snd_hdspm_card_free()
6843 hdspm->control_register); in snd_hdspm_card_free()
6857 return -ENODEV; in snd_hdspm_probe()
6860 return -ENOENT; in snd_hdspm_probe()
6863 err = snd_devm_card_new(&pci->dev, index[dev], id[dev], in snd_hdspm_probe()
6868 hdspm = card->private_data; in snd_hdspm_probe()
6869 card->private_free = snd_hdspm_card_free; in snd_hdspm_probe()
6870 hdspm->dev = dev; in snd_hdspm_probe()
6871 hdspm->pci = pci; in snd_hdspm_probe()
6877 if (hdspm->io_type != MADIface) { in snd_hdspm_probe()
6878 snprintf(card->shortname, sizeof(card->shortname), "%s_%x", in snd_hdspm_probe()
6879 hdspm->card_name, hdspm->serial); in snd_hdspm_probe()
6880 snprintf(card->longname, sizeof(card->longname), in snd_hdspm_probe()
6882 hdspm->card_name, hdspm->serial, in snd_hdspm_probe()
6883 hdspm->port, hdspm->irq); in snd_hdspm_probe()
6885 snprintf(card->shortname, sizeof(card->shortname), "%s", in snd_hdspm_probe()
6886 hdspm->card_name); in snd_hdspm_probe()
6887 snprintf(card->longname, sizeof(card->longname), in snd_hdspm_probe()
6889 hdspm->card_name, hdspm->port, hdspm->irq); in snd_hdspm_probe()