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()
1855 spin_lock_irqsave (&hmidi->lock, flags); in snd_hdspm_midi_output_write()
1856 if (hmidi->output && in snd_hdspm_midi_output_write()
1857 !snd_rawmidi_transmit_empty (hmidi->output)) { in snd_hdspm_midi_output_write()
1858 n_pending = snd_hdspm_midi_output_possible (hmidi->hdspm, in snd_hdspm_midi_output_write()
1859 hmidi->id); in snd_hdspm_midi_output_write()
1864 to_write = snd_rawmidi_transmit (hmidi->output, buf, in snd_hdspm_midi_output_write()
1868 snd_hdspm_midi_write_byte (hmidi->hdspm, in snd_hdspm_midi_output_write()
1869 hmidi->id, in snd_hdspm_midi_output_write()
1874 spin_unlock_irqrestore (&hmidi->lock, flags); in snd_hdspm_midi_output_write()
1880 unsigned char buf[128]; /* this buffer is designed to match the MIDI in snd_hdspm_midi_input_read()
1887 spin_lock_irqsave (&hmidi->lock, flags); in snd_hdspm_midi_input_read()
1888 n_pending = snd_hdspm_midi_input_available (hmidi->hdspm, hmidi->id); in snd_hdspm_midi_input_read()
1890 if (hmidi->input) { in snd_hdspm_midi_input_read()
1894 buf[i] = snd_hdspm_midi_read_byte (hmidi->hdspm, in snd_hdspm_midi_input_read()
1895 hmidi->id); in snd_hdspm_midi_input_read()
1897 snd_rawmidi_receive (hmidi->input, buf, in snd_hdspm_midi_input_read()
1900 /* flush the MIDI input FIFO */ in snd_hdspm_midi_input_read()
1901 while (n_pending--) in snd_hdspm_midi_input_read()
1902 snd_hdspm_midi_read_byte (hmidi->hdspm, in snd_hdspm_midi_input_read()
1903 hmidi->id); in snd_hdspm_midi_input_read()
1906 hmidi->pending = 0; in snd_hdspm_midi_input_read()
1907 spin_unlock_irqrestore(&hmidi->lock, flags); in snd_hdspm_midi_input_read()
1909 spin_lock_irqsave(&hmidi->hdspm->lock, flags); in snd_hdspm_midi_input_read()
1910 hmidi->hdspm->control_register |= hmidi->ie; in snd_hdspm_midi_input_read()
1911 hdspm_write(hmidi->hdspm, HDSPM_controlRegister, in snd_hdspm_midi_input_read()
1912 hmidi->hdspm->control_register); in snd_hdspm_midi_input_read()
1913 spin_unlock_irqrestore(&hmidi->hdspm->lock, flags); in snd_hdspm_midi_input_read()
1925 hmidi = substream->rmidi->private_data; in snd_hdspm_midi_input_trigger()
1926 hdspm = hmidi->hdspm; in snd_hdspm_midi_input_trigger()
1928 spin_lock_irqsave (&hdspm->lock, flags); in snd_hdspm_midi_input_trigger()
1930 if (!(hdspm->control_register & hmidi->ie)) { in snd_hdspm_midi_input_trigger()
1931 snd_hdspm_flush_midi_input (hdspm, hmidi->id); in snd_hdspm_midi_input_trigger()
1932 hdspm->control_register |= hmidi->ie; in snd_hdspm_midi_input_trigger()
1935 hdspm->control_register &= ~hmidi->ie; in snd_hdspm_midi_input_trigger()
1938 hdspm_write(hdspm, HDSPM_controlRegister, hdspm->control_register); in snd_hdspm_midi_input_trigger()
1939 spin_unlock_irqrestore (&hdspm->lock, flags); in snd_hdspm_midi_input_trigger()
1948 spin_lock_irqsave (&hmidi->lock, flags); in snd_hdspm_midi_output_timer()
1950 /* this does not bump hmidi->istimer, because the in snd_hdspm_midi_output_timer()
1956 if (hmidi->istimer) in snd_hdspm_midi_output_timer()
1957 mod_timer(&hmidi->timer, 1 + jiffies); in snd_hdspm_midi_output_timer()
1959 spin_unlock_irqrestore (&hmidi->lock, flags); in snd_hdspm_midi_output_timer()
1968 hmidi = substream->rmidi->private_data; in snd_hdspm_midi_output_trigger()
1969 spin_lock_irqsave (&hmidi->lock, flags); in snd_hdspm_midi_output_trigger()
1971 if (!hmidi->istimer) { in snd_hdspm_midi_output_trigger()
1972 timer_setup(&hmidi->timer, in snd_hdspm_midi_output_trigger()
1974 mod_timer(&hmidi->timer, 1 + jiffies); in snd_hdspm_midi_output_trigger()
1975 hmidi->istimer++; in snd_hdspm_midi_output_trigger()
1978 if (hmidi->istimer && --hmidi->istimer <= 0) in snd_hdspm_midi_output_trigger()
1979 del_timer (&hmidi->timer); in snd_hdspm_midi_output_trigger()
1981 spin_unlock_irqrestore (&hmidi->lock, flags); in snd_hdspm_midi_output_trigger()
1990 hmidi = substream->rmidi->private_data; in snd_hdspm_midi_input_open()
1991 spin_lock_irq (&hmidi->lock); in snd_hdspm_midi_input_open()
1992 snd_hdspm_flush_midi_input (hmidi->hdspm, hmidi->id); in snd_hdspm_midi_input_open()
1993 hmidi->input = substream; in snd_hdspm_midi_input_open()
1994 spin_unlock_irq (&hmidi->lock); in snd_hdspm_midi_input_open()
2003 hmidi = substream->rmidi->private_data; in snd_hdspm_midi_output_open()
2004 spin_lock_irq (&hmidi->lock); in snd_hdspm_midi_output_open()
2005 hmidi->output = substream; in snd_hdspm_midi_output_open()
2006 spin_unlock_irq (&hmidi->lock); in snd_hdspm_midi_output_open()
2017 hmidi = substream->rmidi->private_data; in snd_hdspm_midi_input_close()
2018 spin_lock_irq (&hmidi->lock); in snd_hdspm_midi_input_close()
2019 hmidi->input = NULL; in snd_hdspm_midi_input_close()
2020 spin_unlock_irq (&hmidi->lock); in snd_hdspm_midi_input_close()
2031 hmidi = substream->rmidi->private_data; in snd_hdspm_midi_output_close()
2032 spin_lock_irq (&hmidi->lock); in snd_hdspm_midi_output_close()
2033 hmidi->output = NULL; in snd_hdspm_midi_output_close()
2034 spin_unlock_irq (&hmidi->lock); in snd_hdspm_midi_output_close()
2059 hdspm->midi[id].id = id; in snd_hdspm_create_midi()
2060 hdspm->midi[id].hdspm = hdspm; in snd_hdspm_create_midi()
2061 spin_lock_init (&hdspm->midi[id].lock); in snd_hdspm_create_midi()
2064 if (MADIface == hdspm->io_type) { in snd_hdspm_create_midi()
2065 /* MIDI-over-MADI on HDSPe MADIface */ in snd_hdspm_create_midi()
2066 hdspm->midi[0].dataIn = HDSPM_midiDataIn2; in snd_hdspm_create_midi()
2067 hdspm->midi[0].statusIn = HDSPM_midiStatusIn2; in snd_hdspm_create_midi()
2068 hdspm->midi[0].dataOut = HDSPM_midiDataOut2; in snd_hdspm_create_midi()
2069 hdspm->midi[0].statusOut = HDSPM_midiStatusOut2; in snd_hdspm_create_midi()
2070 hdspm->midi[0].ie = HDSPM_Midi2InterruptEnable; in snd_hdspm_create_midi()
2071 hdspm->midi[0].irq = HDSPM_midi2IRQPending; in snd_hdspm_create_midi()
2073 hdspm->midi[0].dataIn = HDSPM_midiDataIn0; in snd_hdspm_create_midi()
2074 hdspm->midi[0].statusIn = HDSPM_midiStatusIn0; in snd_hdspm_create_midi()
2075 hdspm->midi[0].dataOut = HDSPM_midiDataOut0; in snd_hdspm_create_midi()
2076 hdspm->midi[0].statusOut = HDSPM_midiStatusOut0; in snd_hdspm_create_midi()
2077 hdspm->midi[0].ie = HDSPM_Midi0InterruptEnable; in snd_hdspm_create_midi()
2078 hdspm->midi[0].irq = HDSPM_midi0IRQPending; in snd_hdspm_create_midi()
2081 hdspm->midi[1].dataIn = HDSPM_midiDataIn1; in snd_hdspm_create_midi()
2082 hdspm->midi[1].statusIn = HDSPM_midiStatusIn1; in snd_hdspm_create_midi()
2083 hdspm->midi[1].dataOut = HDSPM_midiDataOut1; in snd_hdspm_create_midi()
2084 hdspm->midi[1].statusOut = HDSPM_midiStatusOut1; in snd_hdspm_create_midi()
2085 hdspm->midi[1].ie = HDSPM_Midi1InterruptEnable; in snd_hdspm_create_midi()
2086 hdspm->midi[1].irq = HDSPM_midi1IRQPending; in snd_hdspm_create_midi()
2087 } else if ((2 == id) && (MADI == hdspm->io_type)) { in snd_hdspm_create_midi()
2088 /* MIDI-over-MADI on HDSPe MADI */ in snd_hdspm_create_midi()
2089 hdspm->midi[2].dataIn = HDSPM_midiDataIn2; in snd_hdspm_create_midi()
2090 hdspm->midi[2].statusIn = HDSPM_midiStatusIn2; in snd_hdspm_create_midi()
2091 hdspm->midi[2].dataOut = HDSPM_midiDataOut2; in snd_hdspm_create_midi()
2092 hdspm->midi[2].statusOut = HDSPM_midiStatusOut2; in snd_hdspm_create_midi()
2093 hdspm->midi[2].ie = HDSPM_Midi2InterruptEnable; in snd_hdspm_create_midi()
2094 hdspm->midi[2].irq = HDSPM_midi2IRQPending; in snd_hdspm_create_midi()
2097 hdspm->midi[2].dataIn = HDSPM_midiDataIn2; in snd_hdspm_create_midi()
2098 hdspm->midi[2].statusIn = HDSPM_midiStatusIn2; in snd_hdspm_create_midi()
2099 hdspm->midi[2].dataOut = -1; in snd_hdspm_create_midi()
2100 hdspm->midi[2].statusOut = -1; in snd_hdspm_create_midi()
2101 hdspm->midi[2].ie = HDSPM_Midi2InterruptEnable; in snd_hdspm_create_midi()
2102 hdspm->midi[2].irq = HDSPM_midi2IRQPendingAES; in snd_hdspm_create_midi()
2105 hdspm->midi[3].dataIn = HDSPM_midiDataIn3; in snd_hdspm_create_midi()
2106 hdspm->midi[3].statusIn = HDSPM_midiStatusIn3; in snd_hdspm_create_midi()
2107 hdspm->midi[3].dataOut = -1; in snd_hdspm_create_midi()
2108 hdspm->midi[3].statusOut = -1; in snd_hdspm_create_midi()
2109 hdspm->midi[3].ie = HDSPM_Midi3InterruptEnable; in snd_hdspm_create_midi()
2110 hdspm->midi[3].irq = HDSPM_midi3IRQPending; in snd_hdspm_create_midi()
2113 if ((id < 2) || ((2 == id) && ((MADI == hdspm->io_type) || in snd_hdspm_create_midi()
2114 (MADIface == hdspm->io_type)))) { in snd_hdspm_create_midi()
2115 if ((id == 0) && (MADIface == hdspm->io_type)) { in snd_hdspm_create_midi()
2117 card->shortname); in snd_hdspm_create_midi()
2118 } else if ((id == 2) && (MADI == hdspm->io_type)) { in snd_hdspm_create_midi()
2120 card->shortname); in snd_hdspm_create_midi()
2122 snprintf(buf, sizeof(buf), "%s MIDI %d", in snd_hdspm_create_midi()
2123 card->shortname, id+1); in snd_hdspm_create_midi()
2126 &hdspm->midi[id].rmidi); in snd_hdspm_create_midi()
2130 snprintf(hdspm->midi[id].rmidi->name, in snd_hdspm_create_midi()
2131 sizeof(hdspm->midi[id].rmidi->name), in snd_hdspm_create_midi()
2132 "%s MIDI %d", card->id, id+1); in snd_hdspm_create_midi()
2133 hdspm->midi[id].rmidi->private_data = &hdspm->midi[id]; in snd_hdspm_create_midi()
2135 snd_rawmidi_set_ops(hdspm->midi[id].rmidi, in snd_hdspm_create_midi()
2138 snd_rawmidi_set_ops(hdspm->midi[id].rmidi, in snd_hdspm_create_midi()
2142 hdspm->midi[id].rmidi->info_flags |= in snd_hdspm_create_midi()
2149 card->shortname, id+1); in snd_hdspm_create_midi()
2151 &hdspm->midi[id].rmidi); in snd_hdspm_create_midi()
2155 snprintf(hdspm->midi[id].rmidi->name, in snd_hdspm_create_midi()
2156 sizeof(hdspm->midi[id].rmidi->name), in snd_hdspm_create_midi()
2157 "%s MTC %d", card->id, id+1); in snd_hdspm_create_midi()
2158 hdspm->midi[id].rmidi->private_data = &hdspm->midi[id]; in snd_hdspm_create_midi()
2160 snd_rawmidi_set_ops(hdspm->midi[id].rmidi, in snd_hdspm_create_midi()
2164 hdspm->midi[id].rmidi->info_flags |= SNDRV_RAWMIDI_INFO_INPUT; in snd_hdspm_create_midi()
2176 while (i < hdspm->midiPorts) { in hdspm_midi_work()
2177 if (hdspm->midi[i].pending) in hdspm_midi_work()
2178 snd_hdspm_midi_input_read(&hdspm->midi[i]); in hdspm_midi_work()
2185 /*-----------------------------------------------------------------------------
2187 ----------------------------------------------------------------------------*/
2216 rate = hdspm->system_sample_rate; in hdspm_get_system_sample_rate()
2221 rate = hdspm->system_sample_rate; in hdspm_get_system_sample_rate()
2243 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in snd_hdspm_info_system_sample_rate()
2244 uinfo->count = 1; in snd_hdspm_info_system_sample_rate()
2245 uinfo->value.integer.min = 27000; in snd_hdspm_info_system_sample_rate()
2246 uinfo->value.integer.max = 207000; in snd_hdspm_info_system_sample_rate()
2247 uinfo->value.integer.step = 1; in snd_hdspm_info_system_sample_rate()
2258 ucontrol->value.integer.value[0] = hdspm_get_system_sample_rate(hdspm); in snd_hdspm_get_system_sample_rate()
2267 int rate = ucontrol->value.integer.value[0]; in snd_hdspm_put_system_sample_rate()
2270 return -EINVAL; in snd_hdspm_put_system_sample_rate()
2271 hdspm_set_dds_value(hdspm, ucontrol->value.integer.value[0]); in snd_hdspm_put_system_sample_rate()
2283 switch (hdspm->io_type) { in hdspm_get_wc_sample_rate()
2307 if (hdspm->tco) { in hdspm_get_tco_sample_rate()
2308 switch (hdspm->io_type) { in hdspm_get_tco_sample_rate()
2332 if (hdspm->tco) { in hdspm_get_sync_in_sample_rate()
2333 switch (hdspm->io_type) { in hdspm_get_sync_in_sample_rate()
2353 switch (hdspm->io_type) { in hdspm_get_aes_sample_rate()
2418 switch (hdspm->io_type) { in snd_hdspm_get_autosync_sample_rate()
2420 switch (kcontrol->private_value) { in snd_hdspm_get_autosync_sample_rate()
2422 ucontrol->value.enumerated.item[0] = in snd_hdspm_get_autosync_sample_rate()
2426 ucontrol->value.enumerated.item[0] = in snd_hdspm_get_autosync_sample_rate()
2430 ucontrol->value.enumerated.item[0] = in snd_hdspm_get_autosync_sample_rate()
2434 ucontrol->value.enumerated.item[0] = in snd_hdspm_get_autosync_sample_rate()
2436 kcontrol->private_value-1); in snd_hdspm_get_autosync_sample_rate()
2441 switch (kcontrol->private_value) { in snd_hdspm_get_autosync_sample_rate()
2443 ucontrol->value.enumerated.item[0] = in snd_hdspm_get_autosync_sample_rate()
2447 ucontrol->value.enumerated.item[0] = in snd_hdspm_get_autosync_sample_rate()
2451 ucontrol->value.enumerated.item[0] = in snd_hdspm_get_autosync_sample_rate()
2455 ucontrol->value.enumerated.item[0] = in snd_hdspm_get_autosync_sample_rate()
2457 kcontrol->private_value-1); in snd_hdspm_get_autosync_sample_rate()
2463 switch (kcontrol->private_value) { in snd_hdspm_get_autosync_sample_rate()
2465 ucontrol->value.enumerated.item[0] = in snd_hdspm_get_autosync_sample_rate()
2469 ucontrol->value.enumerated.item[0] = in snd_hdspm_get_autosync_sample_rate()
2473 ucontrol->value.enumerated.item[0] = in snd_hdspm_get_autosync_sample_rate()
2477 ucontrol->value.enumerated.item[0] = in snd_hdspm_get_autosync_sample_rate()
2481 ucontrol->value.enumerated.item[0] = in snd_hdspm_get_autosync_sample_rate()
2483 kcontrol->private_value - in snd_hdspm_get_autosync_sample_rate()
2491 ucontrol->value.enumerated.item[0] = in snd_hdspm_get_autosync_sample_rate()
2516 * @returns 0 - master, 1 - slave
2520 switch (hdspm->io_type) { in hdspm_system_clock_mode()
2523 if (hdspm->settings_register & HDSPM_c0Master) in hdspm_system_clock_mode()
2528 if (hdspm->control_register & HDSPM_ClockModeMaster) in hdspm_system_clock_mode()
2538 * @param mode 0 - master, 1 - slave
2562 ucontrol->value.enumerated.item[0] = hdspm_system_clock_mode(hdspm); in snd_hdspm_get_system_clock_mode()
2573 return -EBUSY; in snd_hdspm_put_system_clock_mode()
2575 val = ucontrol->value.enumerated.item[0]; in snd_hdspm_put_system_clock_mode()
2599 switch (hdspm->system_sample_rate) { in hdspm_clock_source()
2611 return -1; in hdspm_clock_source()
2654 ucontrol->value.enumerated.item[0] = hdspm_clock_source(hdspm); in snd_hdspm_get_clock_source()
2666 return -EBUSY; in snd_hdspm_put_clock_source()
2667 val = ucontrol->value.enumerated.item[0]; in snd_hdspm_put_clock_source()
2672 spin_lock_irq(&hdspm->lock); in snd_hdspm_put_clock_source()
2677 spin_unlock_irq(&hdspm->lock); in snd_hdspm_put_clock_source()
2701 switch (hdspm->io_type) { in hdspm_pref_sync_ref()
2703 switch (hdspm->control_register & HDSPM_SyncRefMask) { in hdspm_pref_sync_ref()
2720 if (hdspm->tco) { in hdspm_pref_sync_ref()
2721 switch (hdspm->control_register & HDSPM_SyncRefMask) { in hdspm_pref_sync_ref()
2729 switch (hdspm->control_register & HDSPM_SyncRefMask) { in hdspm_pref_sync_ref()
2739 if (hdspm->tco) { in hdspm_pref_sync_ref()
2740 switch ((hdspm->settings_register & in hdspm_pref_sync_ref()
2753 switch ((hdspm->settings_register & in hdspm_pref_sync_ref()
2769 if (hdspm->tco) { in hdspm_pref_sync_ref()
2770 switch ((hdspm->settings_register & in hdspm_pref_sync_ref()
2780 switch ((hdspm->settings_register & in hdspm_pref_sync_ref()
2793 return -1; in hdspm_pref_sync_ref()
2806 switch (hdspm->io_type) { in hdspm_set_pref_sync_ref()
2808 hdspm->control_register &= ~HDSPM_SyncRefMask; in hdspm_set_pref_sync_ref()
2813 hdspm->control_register |= HDSPM_SyncRef0; in hdspm_set_pref_sync_ref()
2816 hdspm->control_register |= HDSPM_SyncRef1; in hdspm_set_pref_sync_ref()
2819 hdspm->control_register |= in hdspm_set_pref_sync_ref()
2823 hdspm->control_register |= HDSPM_SyncRef2; in hdspm_set_pref_sync_ref()
2826 hdspm->control_register |= in hdspm_set_pref_sync_ref()
2830 hdspm->control_register |= in hdspm_set_pref_sync_ref()
2834 hdspm->control_register |= in hdspm_set_pref_sync_ref()
2838 hdspm->control_register |= HDSPM_SyncRef3; in hdspm_set_pref_sync_ref()
2841 hdspm->control_register |= in hdspm_set_pref_sync_ref()
2845 return -1; in hdspm_set_pref_sync_ref()
2852 hdspm->control_register &= ~HDSPM_SyncRefMask; in hdspm_set_pref_sync_ref()
2853 if (hdspm->tco) { in hdspm_set_pref_sync_ref()
2858 hdspm->control_register |= HDSPM_SyncRef0; in hdspm_set_pref_sync_ref()
2861 hdspm->control_register |= HDSPM_SyncRef1; in hdspm_set_pref_sync_ref()
2864 hdspm->control_register |= in hdspm_set_pref_sync_ref()
2868 return -1; in hdspm_set_pref_sync_ref()
2875 hdspm->control_register |= HDSPM_SyncRef0; in hdspm_set_pref_sync_ref()
2878 hdspm->control_register |= in hdspm_set_pref_sync_ref()
2882 return -1; in hdspm_set_pref_sync_ref()
2889 if (hdspm->tco) { in hdspm_set_pref_sync_ref()
2900 default: return -1; in hdspm_set_pref_sync_ref()
2912 default: return -1; in hdspm_set_pref_sync_ref()
2918 if (hdspm->tco) { in hdspm_set_pref_sync_ref()
2926 default: return -1; in hdspm_set_pref_sync_ref()
2935 default: return -1; in hdspm_set_pref_sync_ref()
2941 switch (hdspm->io_type) { in hdspm_set_pref_sync_ref()
2944 hdspm->settings_register &= ~HDSPM_c0_SyncRefMask; in hdspm_set_pref_sync_ref()
2945 hdspm->settings_register |= HDSPM_c0_SyncRef0 * p; in hdspm_set_pref_sync_ref()
2946 hdspm_write(hdspm, HDSPM_WR_SETTINGS, hdspm->settings_register); in hdspm_set_pref_sync_ref()
2953 hdspm->control_register); in hdspm_set_pref_sync_ref()
2965 snd_ctl_enum_info(uinfo, 1, hdspm->texts_autosync_items, hdspm->texts_autosync); in snd_hdspm_info_pref_sync_ref()
2977 ucontrol->value.enumerated.item[0] = psf; in snd_hdspm_get_pref_sync_ref()
2981 return -1; in snd_hdspm_get_pref_sync_ref()
2991 return -EBUSY; in snd_hdspm_put_pref_sync_ref()
2993 val = ucontrol->value.enumerated.item[0]; in snd_hdspm_put_pref_sync_ref()
2997 else if (val >= hdspm->texts_autosync_items) in snd_hdspm_put_pref_sync_ref()
2998 val = hdspm->texts_autosync_items-1; in snd_hdspm_put_pref_sync_ref()
3000 spin_lock_irq(&hdspm->lock); in snd_hdspm_put_pref_sync_ref()
3004 spin_unlock_irq(&hdspm->lock); in snd_hdspm_put_pref_sync_ref()
3021 if (AES32 == hdspm->io_type) { in hdspm_autosync_ref()
3031 } else if (MADI == hdspm->io_type) { in hdspm_autosync_ref()
3059 if (AES32 == hdspm->io_type) { in snd_hdspm_info_autosync_ref()
3064 } else if (MADI == hdspm->io_type) { in snd_hdspm_info_autosync_ref()
3078 ucontrol->value.enumerated.item[0] = hdspm_autosync_ref(hdspm); in snd_hdspm_get_autosync_ref()
3124 ucontrol->value.enumerated.item[0] = ret; in snd_hdspm_get_tco_video_input_format()
3184 ucontrol->value.enumerated.item[0] = hdspm_tco_ltc_frames(hdspm); in snd_hdspm_get_tco_ltc_frames()
3202 reg = hdspm->settings_register; in hdspm_toggle_setting()
3204 reg = hdspm->control_register; in hdspm_toggle_setting()
3215 reg = &(hdspm->settings_register); in hdspm_set_toggle_setting()
3218 reg = &(hdspm->control_register); in hdspm_set_toggle_setting()
3238 u32 regmask = kcontrol->private_value; in snd_hdspm_get_toggle_setting()
3240 spin_lock_irq(&hdspm->lock); in snd_hdspm_get_toggle_setting()
3241 ucontrol->value.integer.value[0] = hdspm_toggle_setting(hdspm, regmask); in snd_hdspm_get_toggle_setting()
3242 spin_unlock_irq(&hdspm->lock); in snd_hdspm_get_toggle_setting()
3250 u32 regmask = kcontrol->private_value; in snd_hdspm_put_toggle_setting()
3255 return -EBUSY; in snd_hdspm_put_toggle_setting()
3256 val = ucontrol->value.integer.value[0] & 1; in snd_hdspm_put_toggle_setting()
3257 spin_lock_irq(&hdspm->lock); in snd_hdspm_put_toggle_setting()
3260 spin_unlock_irq(&hdspm->lock); in snd_hdspm_put_toggle_setting()
3275 return (hdspm->control_register & HDSPM_InputSelect0) ? 1 : 0; in hdspm_input_select()
3281 hdspm->control_register |= HDSPM_InputSelect0; in hdspm_set_input_select()
3283 hdspm->control_register &= ~HDSPM_InputSelect0; in hdspm_set_input_select()
3284 hdspm_write(hdspm, HDSPM_controlRegister, hdspm->control_register); in hdspm_set_input_select()
3302 spin_lock_irq(&hdspm->lock); in snd_hdspm_get_input_select()
3303 ucontrol->value.enumerated.item[0] = hdspm_input_select(hdspm); in snd_hdspm_get_input_select()
3304 spin_unlock_irq(&hdspm->lock); in snd_hdspm_get_input_select()
3316 return -EBUSY; in snd_hdspm_put_input_select()
3317 val = ucontrol->value.integer.value[0] & 1; in snd_hdspm_put_input_select()
3318 spin_lock_irq(&hdspm->lock); in snd_hdspm_put_input_select()
3321 spin_unlock_irq(&hdspm->lock); in snd_hdspm_put_input_select()
3337 return (hdspm->control_register & HDSPM_DS_DoubleWire) ? 1 : 0; in hdspm_ds_wire()
3343 hdspm->control_register |= HDSPM_DS_DoubleWire; in hdspm_set_ds_wire()
3345 hdspm->control_register &= ~HDSPM_DS_DoubleWire; in hdspm_set_ds_wire()
3346 hdspm_write(hdspm, HDSPM_controlRegister, hdspm->control_register); in hdspm_set_ds_wire()
3364 spin_lock_irq(&hdspm->lock); in snd_hdspm_get_ds_wire()
3365 ucontrol->value.enumerated.item[0] = hdspm_ds_wire(hdspm); in snd_hdspm_get_ds_wire()
3366 spin_unlock_irq(&hdspm->lock); in snd_hdspm_get_ds_wire()
3378 return -EBUSY; in snd_hdspm_put_ds_wire()
3379 val = ucontrol->value.integer.value[0] & 1; in snd_hdspm_put_ds_wire()
3380 spin_lock_irq(&hdspm->lock); in snd_hdspm_put_ds_wire()
3383 spin_unlock_irq(&hdspm->lock); in snd_hdspm_put_ds_wire()
3399 if (hdspm->control_register & HDSPM_QS_DoubleWire) in hdspm_qs_wire()
3401 if (hdspm->control_register & HDSPM_QS_QuadWire) in hdspm_qs_wire()
3408 hdspm->control_register &= ~(HDSPM_QS_DoubleWire | HDSPM_QS_QuadWire); in hdspm_set_qs_wire()
3413 hdspm->control_register |= HDSPM_QS_DoubleWire; in hdspm_set_qs_wire()
3416 hdspm->control_register |= HDSPM_QS_QuadWire; in hdspm_set_qs_wire()
3419 hdspm_write(hdspm, HDSPM_controlRegister, hdspm->control_register); in hdspm_set_qs_wire()
3437 spin_lock_irq(&hdspm->lock); in snd_hdspm_get_qs_wire()
3438 ucontrol->value.enumerated.item[0] = hdspm_qs_wire(hdspm); in snd_hdspm_get_qs_wire()
3439 spin_unlock_irq(&hdspm->lock); in snd_hdspm_get_qs_wire()
3451 return -EBUSY; in snd_hdspm_put_qs_wire()
3452 val = ucontrol->value.integer.value[0]; in snd_hdspm_put_qs_wire()
3457 spin_lock_irq(&hdspm->lock); in snd_hdspm_put_qs_wire()
3460 spin_unlock_irq(&hdspm->lock); in snd_hdspm_put_qs_wire()
3475 u32 reg = hdspm->settings_register & (regmask * 3); in hdspm_tristate()
3481 hdspm->settings_register &= ~(regmask * 3); in hdspm_set_tristate()
3482 hdspm->settings_register |= (regmask * mode); in hdspm_set_tristate()
3483 hdspm_write(hdspm, HDSPM_WR_SETTINGS, hdspm->settings_register); in hdspm_set_tristate()
3491 u32 regmask = kcontrol->private_value; in snd_hdspm_info_tristate()
3494 static const char *const texts_levels[] = { "Hi Gain", "+4 dBu", "-10 dBV" }; in snd_hdspm_info_tristate()
3511 u32 regmask = kcontrol->private_value; in snd_hdspm_get_tristate()
3513 spin_lock_irq(&hdspm->lock); in snd_hdspm_get_tristate()
3514 ucontrol->value.enumerated.item[0] = hdspm_tristate(hdspm, regmask); in snd_hdspm_get_tristate()
3515 spin_unlock_irq(&hdspm->lock); in snd_hdspm_get_tristate()
3523 u32 regmask = kcontrol->private_value; in snd_hdspm_put_tristate()
3528 return -EBUSY; in snd_hdspm_put_tristate()
3529 val = ucontrol->value.integer.value[0]; in snd_hdspm_put_tristate()
3535 spin_lock_irq(&hdspm->lock); in snd_hdspm_put_tristate()
3538 spin_unlock_irq(&hdspm->lock); in snd_hdspm_put_tristate()
3553 if (hdspm->control_register & HDSPM_QuadSpeed) in hdspm_madi_speedmode()
3555 if (hdspm->control_register & HDSPM_DoubleSpeed) in hdspm_madi_speedmode()
3562 hdspm->control_register &= ~(HDSPM_DoubleSpeed | HDSPM_QuadSpeed); in hdspm_set_madi_speedmode()
3567 hdspm->control_register |= HDSPM_DoubleSpeed; in hdspm_set_madi_speedmode()
3570 hdspm->control_register |= HDSPM_QuadSpeed; in hdspm_set_madi_speedmode()
3573 hdspm_write(hdspm, HDSPM_controlRegister, hdspm->control_register); in hdspm_set_madi_speedmode()
3591 spin_lock_irq(&hdspm->lock); in snd_hdspm_get_madi_speedmode()
3592 ucontrol->value.enumerated.item[0] = hdspm_madi_speedmode(hdspm); in snd_hdspm_get_madi_speedmode()
3593 spin_unlock_irq(&hdspm->lock); in snd_hdspm_get_madi_speedmode()
3605 return -EBUSY; in snd_hdspm_put_madi_speedmode()
3606 val = ucontrol->value.integer.value[0]; in snd_hdspm_put_madi_speedmode()
3611 spin_lock_irq(&hdspm->lock); in snd_hdspm_put_madi_speedmode()
3614 spin_unlock_irq(&hdspm->lock); in snd_hdspm_put_madi_speedmode()
3633 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in snd_hdspm_info_mixer()
3634 uinfo->count = 3; in snd_hdspm_info_mixer()
3635 uinfo->value.integer.min = 0; in snd_hdspm_info_mixer()
3636 uinfo->value.integer.max = 65535; in snd_hdspm_info_mixer()
3637 uinfo->value.integer.step = 1; in snd_hdspm_info_mixer()
3648 source = ucontrol->value.integer.value[0]; in snd_hdspm_get_mixer()
3652 source = 2 * HDSPM_MAX_CHANNELS - 1; in snd_hdspm_get_mixer()
3654 destination = ucontrol->value.integer.value[1]; in snd_hdspm_get_mixer()
3658 destination = HDSPM_MAX_CHANNELS - 1; in snd_hdspm_get_mixer()
3660 spin_lock_irq(&hdspm->lock); in snd_hdspm_get_mixer()
3662 ucontrol->value.integer.value[2] = in snd_hdspm_get_mixer()
3664 source - HDSPM_MAX_CHANNELS); in snd_hdspm_get_mixer()
3666 ucontrol->value.integer.value[2] = in snd_hdspm_get_mixer()
3669 spin_unlock_irq(&hdspm->lock); in snd_hdspm_get_mixer()
3684 return -EBUSY; in snd_hdspm_put_mixer()
3686 source = ucontrol->value.integer.value[0]; in snd_hdspm_put_mixer()
3687 destination = ucontrol->value.integer.value[1]; in snd_hdspm_put_mixer()
3690 return -1; in snd_hdspm_put_mixer()
3692 return -1; in snd_hdspm_put_mixer()
3694 gain = ucontrol->value.integer.value[2]; in snd_hdspm_put_mixer()
3696 spin_lock_irq(&hdspm->lock); in snd_hdspm_put_mixer()
3700 source - in snd_hdspm_put_mixer()
3709 source - HDSPM_MAX_CHANNELS, in snd_hdspm_put_mixer()
3715 spin_unlock_irq(&hdspm->lock); in snd_hdspm_put_mixer()
3737 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in snd_hdspm_info_playback_mixer()
3738 uinfo->count = 1; in snd_hdspm_info_playback_mixer()
3739 uinfo->value.integer.min = 0; in snd_hdspm_info_playback_mixer()
3740 uinfo->value.integer.max = 64; in snd_hdspm_info_playback_mixer()
3741 uinfo->value.integer.step = 1; in snd_hdspm_info_playback_mixer()
3751 channel = ucontrol->id.index - 1; in snd_hdspm_get_playback_mixer()
3754 return -EINVAL; in snd_hdspm_get_playback_mixer()
3756 spin_lock_irq(&hdspm->lock); in snd_hdspm_get_playback_mixer()
3757 ucontrol->value.integer.value[0] = in snd_hdspm_get_playback_mixer()
3759 spin_unlock_irq(&hdspm->lock); in snd_hdspm_get_playback_mixer()
3773 return -EBUSY; in snd_hdspm_put_playback_mixer()
3775 channel = ucontrol->id.index - 1; in snd_hdspm_put_playback_mixer()
3778 return -EINVAL; in snd_hdspm_put_playback_mixer()
3780 gain = ucontrol->value.integer.value[0]*UNITY_GAIN/64; in snd_hdspm_put_playback_mixer()
3782 spin_lock_irq(&hdspm->lock); in snd_hdspm_put_playback_mixer()
3789 spin_unlock_irq(&hdspm->lock); in snd_hdspm_put_playback_mixer()
3833 switch (hdspm->io_type) { in hdspm_wc_sync_check()
3907 switch (hdspm->io_type) { in hdspm_sync_in_sync_check()
3967 if (hdspm->tco) { in hdspm_tco_sync_check()
3968 switch (hdspm->io_type) { in hdspm_tco_sync_check()
4010 int val = -1; in snd_hdspm_get_sync_check()
4012 switch (hdspm->io_type) { in snd_hdspm_get_sync_check()
4014 switch (kcontrol->private_value) { in snd_hdspm_get_sync_check()
4023 kcontrol->private_value-1); in snd_hdspm_get_sync_check()
4028 switch (kcontrol->private_value) { in snd_hdspm_get_sync_check()
4037 kcontrol->private_value-1); in snd_hdspm_get_sync_check()
4042 switch (kcontrol->private_value) { in snd_hdspm_get_sync_check()
4059 switch (kcontrol->private_value) { in snd_hdspm_get_sync_check()
4068 kcontrol->private_value-1); in snd_hdspm_get_sync_check()
4074 if (hdspm->tco) { in snd_hdspm_get_sync_check()
4075 switch (kcontrol->private_value) { in snd_hdspm_get_sync_check()
4090 if (-1 == val) in snd_hdspm_get_sync_check()
4093 ucontrol->value.enumerated.item[0] = val; in snd_hdspm_get_sync_check()
4106 switch (hdspm->tco->input) { in hdspm_tco_write()
4117 switch (hdspm->tco->framerate) { in hdspm_tco_write()
4141 switch (hdspm->tco->wordclock) { in hdspm_tco_write()
4152 switch (hdspm->tco->samplerate) { in hdspm_tco_write()
4163 switch (hdspm->tco->pull) { in hdspm_tco_write()
4180 if (1 == hdspm->tco->term) { in hdspm_tco_write()
4205 /* TODO freq from app could be supported here, see tco->samplerate */ in snd_hdspm_info_tco_sample_rate()
4216 ucontrol->value.enumerated.item[0] = hdspm->tco->samplerate; in snd_hdspm_get_tco_sample_rate()
4226 if (hdspm->tco->samplerate != ucontrol->value.enumerated.item[0]) { in snd_hdspm_put_tco_sample_rate()
4227 hdspm->tco->samplerate = ucontrol->value.enumerated.item[0]; in snd_hdspm_put_tco_sample_rate()
4252 static const char *const texts[] = { "0", "+ 0.1 %", "- 0.1 %", in snd_hdspm_info_tco_pull()
4253 "+ 4 %", "- 4 %" }; in snd_hdspm_info_tco_pull()
4263 ucontrol->value.enumerated.item[0] = hdspm->tco->pull; in snd_hdspm_get_tco_pull()
4273 if (hdspm->tco->pull != ucontrol->value.enumerated.item[0]) { in snd_hdspm_put_tco_pull()
4274 hdspm->tco->pull = ucontrol->value.enumerated.item[0]; in snd_hdspm_put_tco_pull()
4298 static const char *const texts[] = { "1:1", "44.1 -> 48", "48 -> 44.1" }; in snd_hdspm_info_tco_wck_conversion()
4308 ucontrol->value.enumerated.item[0] = hdspm->tco->wordclock; in snd_hdspm_get_tco_wck_conversion()
4318 if (hdspm->tco->wordclock != ucontrol->value.enumerated.item[0]) { in snd_hdspm_put_tco_wck_conversion()
4319 hdspm->tco->wordclock = ucontrol->value.enumerated.item[0]; in snd_hdspm_put_tco_wck_conversion()
4355 ucontrol->value.enumerated.item[0] = hdspm->tco->framerate; in snd_hdspm_get_tco_frame_rate()
4365 if (hdspm->tco->framerate != ucontrol->value.enumerated.item[0]) { in snd_hdspm_put_tco_frame_rate()
4366 hdspm->tco->framerate = ucontrol->value.enumerated.item[0]; in snd_hdspm_put_tco_frame_rate()
4401 ucontrol->value.enumerated.item[0] = hdspm->tco->input; in snd_hdspm_get_tco_sync_source()
4411 if (hdspm->tco->input != ucontrol->value.enumerated.item[0]) { in snd_hdspm_put_tco_sync_source()
4412 hdspm->tco->input = ucontrol->value.enumerated.item[0]; in snd_hdspm_put_tco_sync_source()
4437 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; in snd_hdspm_info_tco_word_term()
4438 uinfo->count = 1; in snd_hdspm_info_tco_word_term()
4439 uinfo->value.integer.min = 0; in snd_hdspm_info_tco_word_term()
4440 uinfo->value.integer.max = 1; in snd_hdspm_info_tco_word_term()
4451 ucontrol->value.integer.value[0] = hdspm->tco->term; in snd_hdspm_get_tco_word_term()
4462 if (hdspm->tco->term != ucontrol->value.integer.value[0]) { in snd_hdspm_put_tco_word_term()
4463 hdspm->tco->term = ucontrol->value.integer.value[0]; in snd_hdspm_put_tco_word_term()
4643 for (i = hdspm->ds_out_channels; i < hdspm->ss_out_channels; ++i) { in hdspm_update_simple_mixer_controls()
4644 if (hdspm->system_sample_rate > 48000) { in hdspm_update_simple_mixer_controls()
4645 hdspm->playback_mixer_ctls[i]->vd[0].access = in hdspm_update_simple_mixer_controls()
4650 hdspm->playback_mixer_ctls[i]->vd[0].access = in hdspm_update_simple_mixer_controls()
4654 snd_ctl_notify(hdspm->card, SNDRV_CTL_EVENT_MASK_VALUE | in hdspm_update_simple_mixer_controls()
4656 &hdspm->playback_mixer_ctls[i]->id); in hdspm_update_simple_mixer_controls()
4671 switch (hdspm->io_type) { in snd_hdspm_create_controls()
4706 if (hdspm->system_sample_rate >= 128000) { in snd_hdspm_create_controls()
4707 limit = hdspm->qs_out_channels; in snd_hdspm_create_controls()
4708 } else if (hdspm->system_sample_rate >= 64000) { in snd_hdspm_create_controls()
4709 limit = hdspm->ds_out_channels; in snd_hdspm_create_controls()
4711 limit = hdspm->ss_out_channels; in snd_hdspm_create_controls()
4719 hdspm->playback_mixer_ctls[idx] = kctl; in snd_hdspm_create_controls()
4723 if (hdspm->tco) { in snd_hdspm_create_controls()
4738 /*------------------------------------------------------------
4740 ------------------------------------------------------------*/
4746 struct hdspm *hdspm = entry->private_data; in snd_hdspm_proc_read_tco()
4753 snd_iprintf(buffer, "--- TCO ---\n"); in snd_hdspm_proc_read_tco()
4756 control = hdspm->control_register; in snd_hdspm_proc_read_tco()
4800 switch (hdspm->io_type) { in snd_hdspm_proc_read_tco()
4858 struct hdspm *hdspm = entry->private_data; in snd_hdspm_proc_read_madi()
4870 hdspm->card_name, hdspm->card->number + 1, in snd_hdspm_proc_read_madi()
4871 hdspm->firmware_rev, in snd_hdspm_proc_read_madi()
4876 snd_iprintf(buffer, "HW Serial: 0x%06x%06x\n", in snd_hdspm_proc_read_madi()
4878 hdspm->serial); in snd_hdspm_proc_read_madi()
4881 hdspm->irq, hdspm->port, (unsigned long)hdspm->iobase); in snd_hdspm_proc_read_madi()
4883 snd_iprintf(buffer, "--- System ---\n"); in snd_hdspm_proc_read_madi()
4890 hdspm->irq_count); in snd_hdspm_proc_read_madi()
4892 "HW pointer: id = %d, rawptr = %d (%d->%d) " in snd_hdspm_proc_read_madi()
4897 (2 * (int)hdspm->period_bytes), in snd_hdspm_proc_read_madi()
4898 ((status & HDSPM_BufferPositionMask) - 64) % in snd_hdspm_proc_read_madi()
4899 (2 * (int)hdspm->period_bytes), in snd_hdspm_proc_read_madi()
4903 "MIDI FIFO: Out1=0x%x, Out2=0x%x, In1=0x%x, In2=0x%x \n", in snd_hdspm_proc_read_madi()
4915 hdspm->control_register, hdspm->control2_register, in snd_hdspm_proc_read_madi()
4919 snd_iprintf(buffer, "--- Settings ---\n"); in snd_hdspm_proc_read_madi()
4925 x, (unsigned long) hdspm->period_bytes); in snd_hdspm_proc_read_madi()
4928 (hdspm->control_register & HDSPM_LineOut) ? "on " : "off"); in snd_hdspm_proc_read_madi()
4933 (hdspm->control_register & HDSPM_clr_tms) ? "on" : "off", in snd_hdspm_proc_read_madi()
4934 (hdspm->control_register & HDSPM_TX_64ch) ? "64" : "56", in snd_hdspm_proc_read_madi()
4935 (hdspm->control_register & HDSPM_AutoInp) ? "on" : "off"); in snd_hdspm_proc_read_madi()
4938 if (!(hdspm->control_register & HDSPM_ClockModeMaster)) in snd_hdspm_proc_read_madi()
4965 hdspm->system_sample_rate); in snd_hdspm_proc_read_madi()
4968 snd_iprintf(buffer, "--- Status:\n"); in snd_hdspm_proc_read_madi()
4996 autosync_ref = "---"; in snd_hdspm_proc_read_madi()
5020 struct hdspm *hdspm = entry->private_data; in snd_hdspm_proc_read_aes32()
5034 hdspm->card_name, hdspm->card->number + 1, in snd_hdspm_proc_read_aes32()
5035 hdspm->firmware_rev); in snd_hdspm_proc_read_aes32()
5038 hdspm->irq, hdspm->port, (unsigned long)hdspm->iobase); in snd_hdspm_proc_read_aes32()
5040 snd_iprintf(buffer, "--- System ---\n"); in snd_hdspm_proc_read_aes32()
5047 hdspm->irq_count); in snd_hdspm_proc_read_aes32()
5049 "HW pointer: id = %d, rawptr = %d (%d->%d) " in snd_hdspm_proc_read_aes32()
5054 (2 * (int)hdspm->period_bytes), in snd_hdspm_proc_read_aes32()
5055 ((status & HDSPM_BufferPositionMask) - 64) % in snd_hdspm_proc_read_aes32()
5056 (2 * (int)hdspm->period_bytes), in snd_hdspm_proc_read_aes32()
5060 "MIDI FIFO: Out1=0x%x, Out2=0x%x, In1=0x%x, In2=0x%x \n", in snd_hdspm_proc_read_aes32()
5072 hdspm->control_register, hdspm->control2_register, in snd_hdspm_proc_read_aes32()
5075 snd_iprintf(buffer, "--- Settings ---\n"); in snd_hdspm_proc_read_aes32()
5081 x, (unsigned long) hdspm->period_bytes); in snd_hdspm_proc_read_aes32()
5084 (hdspm-> in snd_hdspm_proc_read_aes32()
5089 (hdspm-> in snd_hdspm_proc_read_aes32()
5091 (hdspm-> in snd_hdspm_proc_read_aes32()
5093 (hdspm-> in snd_hdspm_proc_read_aes32()
5105 hdspm->system_sample_rate); in snd_hdspm_proc_read_aes32()
5108 hdspm->control_register & HDSPM_DS_DoubleWire? in snd_hdspm_proc_read_aes32()
5111 hdspm->control_register & HDSPM_QS_DoubleWire? in snd_hdspm_proc_read_aes32()
5113 hdspm->control_register & HDSPM_QS_QuadWire? in snd_hdspm_proc_read_aes32()
5116 snd_iprintf(buffer, "--- Status:\n"); in snd_hdspm_proc_read_aes32()
5159 autosync_ref = "---"; break; in snd_hdspm_proc_read_aes32()
5173 struct hdspm *hdspm = entry->private_data; in snd_hdspm_proc_read_raydat()
5231 struct hdspm *hdspm = entry->private_data; in snd_hdspm_proc_read_debug()
5248 struct hdspm *hdspm = entry->private_data; in snd_hdspm_proc_ports_in()
5253 for (i = 0; i < hdspm->max_channels_in; i++) { in snd_hdspm_proc_ports_in()
5254 snd_iprintf(buffer, "%d=%s\n", i+1, hdspm->port_names_in[i]); in snd_hdspm_proc_ports_in()
5261 struct hdspm *hdspm = entry->private_data; in snd_hdspm_proc_ports_out()
5266 for (i = 0; i < hdspm->max_channels_out; i++) { in snd_hdspm_proc_ports_out()
5267 snd_iprintf(buffer, "%d=%s\n", i+1, hdspm->port_names_out[i]); in snd_hdspm_proc_ports_out()
5276 switch (hdspm->io_type) { in snd_hdspm_proc_init()
5293 snd_card_ro_proc_new(hdspm->card, "hdspm", hdspm, read); in snd_hdspm_proc_init()
5294 snd_card_ro_proc_new(hdspm->card, "ports.in", hdspm, in snd_hdspm_proc_init()
5296 snd_card_ro_proc_new(hdspm->card, "ports.out", hdspm, in snd_hdspm_proc_init()
5301 snd_card_ro_proc_new(hdspm->card, "debug", hdspm, in snd_hdspm_proc_init()
5306 /*------------------------------------------------------------
5308 ------------------------------------------------------------*/
5312 /* ASSUMPTION: hdspm->lock is either held, or there is no need to in snd_hdspm_set_defaults()
5318 hdspm->settings_register = 0; in snd_hdspm_set_defaults()
5320 switch (hdspm->io_type) { in snd_hdspm_set_defaults()
5323 hdspm->control_register = in snd_hdspm_set_defaults()
5329 hdspm->settings_register = 0x1 + 0x1000; in snd_hdspm_set_defaults()
5332 hdspm->control_register = in snd_hdspm_set_defaults()
5337 hdspm->control_register = in snd_hdspm_set_defaults()
5346 hdspm_write(hdspm, HDSPM_controlRegister, hdspm->control_register); in snd_hdspm_set_defaults()
5348 if (AES32 == hdspm->io_type) { in snd_hdspm_set_defaults()
5351 hdspm->control2_register = HDSPM_BIGENDIAN_MODE; in snd_hdspm_set_defaults()
5353 hdspm->control2_register = 0; in snd_hdspm_set_defaults()
5356 hdspm_write(hdspm, HDSPM_control2Reg, hdspm->control2_register); in snd_hdspm_set_defaults()
5365 hdspm_write(hdspm, HDSPM_WR_SETTINGS, hdspm->settings_register); in snd_hdspm_set_defaults()
5374 /*------------------------------------------------------------
5376 ------------------------------------------------------------*/
5382 int i, audio, midi, schedule = 0; in snd_hdspm_interrupt() local
5388 midi = status & (HDSPM_midi0IRQPending | HDSPM_midi1IRQPending | in snd_hdspm_interrupt()
5403 dev_info(hdspm->card->dev, "snd_hdspm_interrupt %llu @ %llx\n", in snd_hdspm_interrupt()
5404 now-hdspm->last_interrupt, status & 0xFFC0); in snd_hdspm_interrupt()
5405 hdspm->last_interrupt = now; in snd_hdspm_interrupt()
5408 if (!audio && !midi) in snd_hdspm_interrupt()
5412 hdspm->irq_count++; in snd_hdspm_interrupt()
5416 if (hdspm->capture_substream) in snd_hdspm_interrupt()
5417 snd_pcm_period_elapsed(hdspm->capture_substream); in snd_hdspm_interrupt()
5419 if (hdspm->playback_substream) in snd_hdspm_interrupt()
5420 snd_pcm_period_elapsed(hdspm->playback_substream); in snd_hdspm_interrupt()
5423 if (midi) { in snd_hdspm_interrupt()
5425 while (i < hdspm->midiPorts) { in snd_hdspm_interrupt()
5427 hdspm->midi[i].statusIn) & 0xff) && in snd_hdspm_interrupt()
5428 (status & hdspm->midi[i].irq)) { in snd_hdspm_interrupt()
5432 hdspm->control_register &= ~hdspm->midi[i].ie; in snd_hdspm_interrupt()
5434 hdspm->control_register); in snd_hdspm_interrupt()
5435 hdspm->midi[i].pending = 1; in snd_hdspm_interrupt()
5443 queue_work(system_highpri_wq, &hdspm->midi_work); in snd_hdspm_interrupt()
5449 /*------------------------------------------------------------
5451 ------------------------------------------------------------*/
5464 struct snd_pcm_runtime *runtime = substream->runtime; in snd_hdspm_reset()
5468 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) in snd_hdspm_reset()
5469 other = hdspm->capture_substream; in snd_hdspm_reset()
5471 other = hdspm->playback_substream; in snd_hdspm_reset()
5473 if (hdspm->running) in snd_hdspm_reset()
5474 runtime->status->hw_ptr = hdspm_hw_pointer(hdspm); in snd_hdspm_reset()
5476 runtime->status->hw_ptr = 0; in snd_hdspm_reset()
5479 struct snd_pcm_runtime *oruntime = other->runtime; in snd_hdspm_reset()
5482 oruntime->status->hw_ptr = in snd_hdspm_reset()
5483 runtime->status->hw_ptr; in snd_hdspm_reset()
5500 spin_lock_irq(&hdspm->lock); in snd_hdspm_hw_params()
5502 if (substream->pstr->stream == SNDRV_PCM_STREAM_PLAYBACK) { in snd_hdspm_hw_params()
5503 this_pid = hdspm->playback_pid; in snd_hdspm_hw_params()
5504 other_pid = hdspm->capture_pid; in snd_hdspm_hw_params()
5506 this_pid = hdspm->capture_pid; in snd_hdspm_hw_params()
5507 other_pid = hdspm->playback_pid; in snd_hdspm_hw_params()
5517 if (params_rate(params) != hdspm->system_sample_rate) { in snd_hdspm_hw_params()
5518 spin_unlock_irq(&hdspm->lock); in snd_hdspm_hw_params()
5521 return -EBUSY; in snd_hdspm_hw_params()
5524 if (params_period_size(params) != hdspm->period_bytes / 4) { in snd_hdspm_hw_params()
5525 spin_unlock_irq(&hdspm->lock); in snd_hdspm_hw_params()
5528 return -EBUSY; in snd_hdspm_hw_params()
5533 spin_unlock_irq(&hdspm->lock); in snd_hdspm_hw_params()
5535 /* how to make sure that the rate matches an externally-set one ? */ in snd_hdspm_hw_params()
5537 spin_lock_irq(&hdspm->lock); in snd_hdspm_hw_params()
5540 dev_info(hdspm->card->dev, "err on hdspm_set_rate: %d\n", err); in snd_hdspm_hw_params()
5541 spin_unlock_irq(&hdspm->lock); in snd_hdspm_hw_params()
5546 spin_unlock_irq(&hdspm->lock); in snd_hdspm_hw_params()
5551 dev_info(hdspm->card->dev, in snd_hdspm_hw_params()
5568 dev_info(hdspm->card->dev, in snd_hdspm_hw_params()
5573 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { in snd_hdspm_hw_params()
5576 int c = hdspm->channel_map_out[i]; in snd_hdspm_hw_params()
5586 hdspm->playback_buffer = in snd_hdspm_hw_params()
5587 (unsigned char *) substream->runtime->dma_area; in snd_hdspm_hw_params()
5588 dev_dbg(hdspm->card->dev, in snd_hdspm_hw_params()
5590 hdspm->playback_buffer); in snd_hdspm_hw_params()
5593 int c = hdspm->channel_map_in[i]; in snd_hdspm_hw_params()
5603 hdspm->capture_buffer = in snd_hdspm_hw_params()
5604 (unsigned char *) substream->runtime->dma_area; in snd_hdspm_hw_params()
5605 dev_dbg(hdspm->card->dev, in snd_hdspm_hw_params()
5607 hdspm->capture_buffer); in snd_hdspm_hw_params()
5611 dev_dbg(hdspm->card->dev, in snd_hdspm_hw_params()
5613 substream->stream == SNDRV_PCM_STREAM_PLAYBACK ? in snd_hdspm_hw_params()
5618 dev_dbg(hdspm->card->dev, in snd_hdspm_hw_params()
5620 substream->stream == SNDRV_PCM_STREAM_PLAYBACK ? 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()
6050 struct snd_pcm_runtime *runtime = substream->runtime; in snd_hdspm_open()
6051 bool playback = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK); in snd_hdspm_open()
6053 spin_lock_irq(&hdspm->lock); in snd_hdspm_open()
6055 runtime->hw = (playback) ? snd_hdspm_playback_subinfo : in snd_hdspm_open()
6059 if (!hdspm->capture_substream) in snd_hdspm_open()
6062 hdspm->playback_pid = current->pid; in snd_hdspm_open()
6063 hdspm->playback_substream = substream; in snd_hdspm_open()
6065 if (!hdspm->playback_substream) in snd_hdspm_open()
6068 hdspm->capture_pid = current->pid; in snd_hdspm_open()
6069 hdspm->capture_substream = substream; in snd_hdspm_open()
6072 spin_unlock_irq(&hdspm->lock); in snd_hdspm_open()
6077 switch (hdspm->io_type) { in snd_hdspm_open()
6098 if (AES32 == hdspm->io_type) { in snd_hdspm_open()
6099 runtime->hw.rates |= SNDRV_PCM_RATE_KNOT; in snd_hdspm_open()
6107 SNDRV_PCM_HW_PARAM_CHANNELS, -1); in snd_hdspm_open()
6113 SNDRV_PCM_HW_PARAM_CHANNELS, -1); in snd_hdspm_open()
6118 SNDRV_PCM_HW_PARAM_RATE, -1); in snd_hdspm_open()
6126 bool playback = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK); in snd_hdspm_release()
6128 spin_lock_irq(&hdspm->lock); in snd_hdspm_release()
6131 hdspm->playback_pid = -1; in snd_hdspm_release()
6132 hdspm->playback_substream = NULL; in snd_hdspm_release()
6134 hdspm->capture_pid = -1; in snd_hdspm_release()
6135 hdspm->capture_substream = NULL; in snd_hdspm_release()
6138 spin_unlock_irq(&hdspm->lock); in snd_hdspm_release()
6153 struct hdspm *hdspm = hw->private_data; in snd_hdspm_hwdep_ioctl()
6167 levels = &hdspm->peak_rms; in snd_hdspm_hwdep_ioctl()
6169 levels->input_peaks[i] = in snd_hdspm_hwdep_ioctl()
6170 readl(hdspm->iobase + in snd_hdspm_hwdep_ioctl()
6172 levels->playback_peaks[i] = in snd_hdspm_hwdep_ioctl()
6173 readl(hdspm->iobase + in snd_hdspm_hwdep_ioctl()
6175 levels->output_peaks[i] = in snd_hdspm_hwdep_ioctl()
6176 readl(hdspm->iobase + in snd_hdspm_hwdep_ioctl()
6179 levels->input_rms[i] = in snd_hdspm_hwdep_ioctl()
6180 ((uint64_t) readl(hdspm->iobase + in snd_hdspm_hwdep_ioctl()
6182 (uint64_t) readl(hdspm->iobase + in snd_hdspm_hwdep_ioctl()
6184 levels->playback_rms[i] = in snd_hdspm_hwdep_ioctl()
6185 ((uint64_t)readl(hdspm->iobase + in snd_hdspm_hwdep_ioctl()
6187 (uint64_t)readl(hdspm->iobase + in snd_hdspm_hwdep_ioctl()
6189 levels->output_rms[i] = in snd_hdspm_hwdep_ioctl()
6190 ((uint64_t)readl(hdspm->iobase + in snd_hdspm_hwdep_ioctl()
6192 (uint64_t)readl(hdspm->iobase + in snd_hdspm_hwdep_ioctl()
6196 if (hdspm->system_sample_rate > 96000) { in snd_hdspm_hwdep_ioctl()
6197 levels->speed = qs; in snd_hdspm_hwdep_ioctl()
6198 } else if (hdspm->system_sample_rate > 48000) { in snd_hdspm_hwdep_ioctl()
6199 levels->speed = ds; in snd_hdspm_hwdep_ioctl()
6201 levels->speed = ss; in snd_hdspm_hwdep_ioctl()
6203 levels->status2 = hdspm_read(hdspm, HDSPM_statusRegister2); in snd_hdspm_hwdep_ioctl()
6207 /* dev_err(hdspm->card->dev, "copy_to_user(.., .., %lu): %lu in snd_hdspm_hwdep_ioctl()
6210 return -EFAULT; in snd_hdspm_hwdep_ioctl()
6253 …dev_err(hdspm->card->dev, "copy_to_user(.., .., %lu): %lu [LTC]\n", sizeof(struct hdspm_ltc), s); … in snd_hdspm_hwdep_ioctl()
6254 return -EFAULT; in snd_hdspm_hwdep_ioctl()
6262 spin_lock_irq(&hdspm->lock); in snd_hdspm_hwdep_ioctl()
6266 info.system_sample_rate = hdspm->system_sample_rate; in snd_hdspm_hwdep_ioctl()
6274 spin_unlock_irq(&hdspm->lock); in snd_hdspm_hwdep_ioctl()
6276 return -EFAULT; in snd_hdspm_hwdep_ioctl()
6282 status.card_type = hdspm->io_type; in snd_hdspm_hwdep_ioctl()
6289 switch (hdspm->io_type) { in snd_hdspm_hwdep_ioctl()
6316 return -EFAULT; in snd_hdspm_hwdep_ioctl()
6324 hdspm_version.card_type = hdspm->io_type; in snd_hdspm_hwdep_ioctl()
6325 strscpy(hdspm_version.cardname, hdspm->card_name, in snd_hdspm_hwdep_ioctl()
6327 hdspm_version.serial = hdspm->serial; in snd_hdspm_hwdep_ioctl()
6328 hdspm_version.firmware_rev = hdspm->firmware_rev; in snd_hdspm_hwdep_ioctl()
6330 if (hdspm->tco) in snd_hdspm_hwdep_ioctl()
6335 return -EFAULT; in snd_hdspm_hwdep_ioctl()
6340 return -EFAULT; in snd_hdspm_hwdep_ioctl()
6341 if (copy_to_user((void __user *)mixer.mixer, hdspm->mixer, in snd_hdspm_hwdep_ioctl()
6343 return -EFAULT; in snd_hdspm_hwdep_ioctl()
6347 return -EINVAL; in snd_hdspm_hwdep_ioctl()
6373 hdspm->hwdep = hw; in snd_hdspm_create_hwdep()
6374 hw->private_data = hdspm; in snd_hdspm_create_hwdep()
6375 strcpy(hw->name, "HDSPM hwdep interface"); in snd_hdspm_create_hwdep()
6377 hw->ops.open = snd_hdspm_hwdep_dummy_op; in snd_hdspm_create_hwdep()
6378 hw->ops.ioctl = snd_hdspm_hwdep_ioctl; in snd_hdspm_create_hwdep()
6379 hw->ops.ioctl_compat = snd_hdspm_hwdep_ioctl; in snd_hdspm_create_hwdep()
6380 hw->ops.release = snd_hdspm_hwdep_dummy_op; in snd_hdspm_create_hwdep()
6386 /*------------------------------------------------------------
6388 ------------------------------------------------------------*/
6394 pcm = hdspm->pcm; in snd_hdspm_preallocate_memory()
6399 &hdspm->pci->dev, in snd_hdspm_preallocate_memory()
6401 dev_dbg(hdspm->card->dev, " Preallocated %zd Bytes\n", wanted); in snd_hdspm_preallocate_memory()
6419 /* ------------- ALSA Devices ---------------------------- */
6426 err = snd_pcm_new(card, hdspm->card_name, 0, 1, 1, &pcm); in snd_hdspm_create_pcm()
6430 hdspm->pcm = pcm; in snd_hdspm_create_pcm()
6431 pcm->private_data = hdspm; in snd_hdspm_create_pcm()
6432 strcpy(pcm->name, hdspm->card_name); in snd_hdspm_create_pcm()
6439 pcm->info_flags = SNDRV_PCM_INFO_JOINT_DUPLEX; in snd_hdspm_create_pcm()
6452 for (i = 0; i < hdspm->midiPorts; i++) in snd_hdspm_initialize_midi_flush()
6461 dev_dbg(card->dev, "Create card...\n"); in snd_hdspm_create_alsa_devices()
6467 while (i < hdspm->midiPorts) { in snd_hdspm_create_alsa_devices()
6483 dev_dbg(card->dev, "proc init...\n"); in snd_hdspm_create_alsa_devices()
6486 hdspm->system_sample_rate = -1; in snd_hdspm_create_alsa_devices()
6487 hdspm->last_external_sample_rate = -1; in snd_hdspm_create_alsa_devices()
6488 hdspm->last_internal_sample_rate = -1; in snd_hdspm_create_alsa_devices()
6489 hdspm->playback_pid = -1; in snd_hdspm_create_alsa_devices()
6490 hdspm->capture_pid = -1; in snd_hdspm_create_alsa_devices()
6491 hdspm->capture_substream = NULL; in snd_hdspm_create_alsa_devices()
6492 hdspm->playback_substream = NULL; in snd_hdspm_create_alsa_devices()
6494 dev_dbg(card->dev, "Set defaults...\n"); in snd_hdspm_create_alsa_devices()
6499 dev_dbg(card->dev, "Update mixer controls...\n"); in snd_hdspm_create_alsa_devices()
6502 dev_dbg(card->dev, "Initializing complete?\n"); in snd_hdspm_create_alsa_devices()
6506 dev_err(card->dev, "error registering card\n"); in snd_hdspm_create_alsa_devices()
6510 dev_dbg(card->dev, "... yes now\n"); in snd_hdspm_create_alsa_devices()
6519 struct pci_dev *pci = hdspm->pci; in snd_hdspm_create()
6523 hdspm->irq = -1; in snd_hdspm_create()
6524 hdspm->card = card; in snd_hdspm_create()
6526 spin_lock_init(&hdspm->lock); in snd_hdspm_create()
6527 INIT_WORK(&hdspm->midi_work, hdspm_midi_work); in snd_hdspm_create()
6529 pci_read_config_word(hdspm->pci, in snd_hdspm_create()
6530 PCI_CLASS_REVISION, &hdspm->firmware_rev); in snd_hdspm_create()
6532 strcpy(card->mixername, "Xilinx FPGA"); in snd_hdspm_create()
6533 strcpy(card->driver, "HDSPM"); in snd_hdspm_create()
6535 switch (hdspm->firmware_rev) { in snd_hdspm_create()
6537 hdspm->io_type = RayDAT; in snd_hdspm_create()
6538 hdspm->card_name = "RME RayDAT"; in snd_hdspm_create()
6539 hdspm->midiPorts = 2; in snd_hdspm_create()
6542 hdspm->io_type = AIO; in snd_hdspm_create()
6543 hdspm->card_name = "RME AIO"; in snd_hdspm_create()
6544 hdspm->midiPorts = 1; in snd_hdspm_create()
6547 hdspm->io_type = MADIface; in snd_hdspm_create()
6548 hdspm->card_name = "RME MADIface"; in snd_hdspm_create()
6549 hdspm->midiPorts = 1; in snd_hdspm_create()
6552 if ((hdspm->firmware_rev == 0xf0) || in snd_hdspm_create()
6553 ((hdspm->firmware_rev >= 0xe6) && in snd_hdspm_create()
6554 (hdspm->firmware_rev <= 0xea))) { in snd_hdspm_create()
6555 hdspm->io_type = AES32; in snd_hdspm_create()
6556 hdspm->card_name = "RME AES32"; in snd_hdspm_create()
6557 hdspm->midiPorts = 2; in snd_hdspm_create()
6558 } else if ((hdspm->firmware_rev == 0xd2) || in snd_hdspm_create()
6559 ((hdspm->firmware_rev >= 0xc8) && in snd_hdspm_create()
6560 (hdspm->firmware_rev <= 0xcf))) { in snd_hdspm_create()
6561 hdspm->io_type = MADI; in snd_hdspm_create()
6562 hdspm->card_name = "RME MADI"; in snd_hdspm_create()
6563 hdspm->midiPorts = 3; in snd_hdspm_create()
6565 dev_err(card->dev, in snd_hdspm_create()
6567 hdspm->firmware_rev); in snd_hdspm_create()
6568 return -ENODEV; in snd_hdspm_create()
6576 pci_set_master(hdspm->pci); in snd_hdspm_create()
6582 hdspm->port = pci_resource_start(pci, 0); in snd_hdspm_create()
6584 hdspm->iobase = pcim_iomap_table(pci)[0]; in snd_hdspm_create()
6585 dev_dbg(card->dev, "remapped region (0x%lx) 0x%lx-0x%lx\n", in snd_hdspm_create()
6586 (unsigned long)hdspm->iobase, hdspm->port, in snd_hdspm_create()
6587 hdspm->port + io_extent - 1); in snd_hdspm_create()
6589 if (devm_request_irq(&pci->dev, pci->irq, snd_hdspm_interrupt, in snd_hdspm_create()
6591 dev_err(card->dev, "unable to use IRQ %d\n", pci->irq); in snd_hdspm_create()
6592 return -EBUSY; in snd_hdspm_create()
6595 dev_dbg(card->dev, "use IRQ %d\n", pci->irq); in snd_hdspm_create()
6597 hdspm->irq = pci->irq; in snd_hdspm_create()
6598 card->sync_irq = hdspm->irq; in snd_hdspm_create()
6600 dev_dbg(card->dev, "kmalloc Mixer memory of %zd Bytes\n", in snd_hdspm_create()
6601 sizeof(*hdspm->mixer)); in snd_hdspm_create()
6602 hdspm->mixer = devm_kzalloc(&pci->dev, sizeof(*hdspm->mixer), GFP_KERNEL); in snd_hdspm_create()
6603 if (!hdspm->mixer) in snd_hdspm_create()
6604 return -ENOMEM; in snd_hdspm_create()
6606 hdspm->port_names_in = NULL; in snd_hdspm_create()
6607 hdspm->port_names_out = NULL; in snd_hdspm_create()
6609 switch (hdspm->io_type) { in snd_hdspm_create()
6611 hdspm->ss_in_channels = hdspm->ss_out_channels = AES32_CHANNELS; in snd_hdspm_create()
6612 hdspm->ds_in_channels = hdspm->ds_out_channels = AES32_CHANNELS; in snd_hdspm_create()
6613 hdspm->qs_in_channels = hdspm->qs_out_channels = AES32_CHANNELS; in snd_hdspm_create()
6615 hdspm->channel_map_in_ss = hdspm->channel_map_out_ss = in snd_hdspm_create()
6617 hdspm->channel_map_in_ds = hdspm->channel_map_out_ds = in snd_hdspm_create()
6619 hdspm->channel_map_in_qs = hdspm->channel_map_out_qs = in snd_hdspm_create()
6621 hdspm->port_names_in_ss = hdspm->port_names_out_ss = in snd_hdspm_create()
6623 hdspm->port_names_in_ds = hdspm->port_names_out_ds = in snd_hdspm_create()
6625 hdspm->port_names_in_qs = hdspm->port_names_out_qs = in snd_hdspm_create()
6628 hdspm->max_channels_out = hdspm->max_channels_in = in snd_hdspm_create()
6630 hdspm->port_names_in = hdspm->port_names_out = in snd_hdspm_create()
6632 hdspm->channel_map_in = hdspm->channel_map_out = in snd_hdspm_create()
6639 hdspm->ss_in_channels = hdspm->ss_out_channels = in snd_hdspm_create()
6641 hdspm->ds_in_channels = hdspm->ds_out_channels = in snd_hdspm_create()
6643 hdspm->qs_in_channels = hdspm->qs_out_channels = in snd_hdspm_create()
6646 hdspm->channel_map_in_ss = hdspm->channel_map_out_ss = in snd_hdspm_create()
6648 hdspm->channel_map_in_ds = hdspm->channel_map_out_ds = in snd_hdspm_create()
6650 hdspm->channel_map_in_qs = hdspm->channel_map_out_qs = in snd_hdspm_create()
6653 hdspm->port_names_in_ss = hdspm->port_names_out_ss = in snd_hdspm_create()
6655 hdspm->port_names_in_ds = hdspm->port_names_out_ds = in snd_hdspm_create()
6657 hdspm->port_names_in_qs = hdspm->port_names_out_qs = in snd_hdspm_create()
6662 hdspm->ss_in_channels = AIO_IN_SS_CHANNELS; in snd_hdspm_create()
6663 hdspm->ds_in_channels = AIO_IN_DS_CHANNELS; in snd_hdspm_create()
6664 hdspm->qs_in_channels = AIO_IN_QS_CHANNELS; in snd_hdspm_create()
6665 hdspm->ss_out_channels = AIO_OUT_SS_CHANNELS; in snd_hdspm_create()
6666 hdspm->ds_out_channels = AIO_OUT_DS_CHANNELS; in snd_hdspm_create()
6667 hdspm->qs_out_channels = AIO_OUT_QS_CHANNELS; in snd_hdspm_create()
6670 dev_info(card->dev, "AEB input board found\n"); in snd_hdspm_create()
6671 hdspm->ss_in_channels += 4; in snd_hdspm_create()
6672 hdspm->ds_in_channels += 4; in snd_hdspm_create()
6673 hdspm->qs_in_channels += 4; in snd_hdspm_create()
6677 dev_info(card->dev, "AEB output board found\n"); in snd_hdspm_create()
6678 hdspm->ss_out_channels += 4; in snd_hdspm_create()
6679 hdspm->ds_out_channels += 4; in snd_hdspm_create()
6680 hdspm->qs_out_channels += 4; in snd_hdspm_create()
6683 hdspm->channel_map_out_ss = channel_map_aio_out_ss; in snd_hdspm_create()
6684 hdspm->channel_map_out_ds = channel_map_aio_out_ds; in snd_hdspm_create()
6685 hdspm->channel_map_out_qs = channel_map_aio_out_qs; in snd_hdspm_create()
6687 hdspm->channel_map_in_ss = channel_map_aio_in_ss; in snd_hdspm_create()
6688 hdspm->channel_map_in_ds = channel_map_aio_in_ds; in snd_hdspm_create()
6689 hdspm->channel_map_in_qs = channel_map_aio_in_qs; in snd_hdspm_create()
6691 hdspm->port_names_in_ss = texts_ports_aio_in_ss; in snd_hdspm_create()
6692 hdspm->port_names_out_ss = texts_ports_aio_out_ss; in snd_hdspm_create()
6693 hdspm->port_names_in_ds = texts_ports_aio_in_ds; in snd_hdspm_create()
6694 hdspm->port_names_out_ds = texts_ports_aio_out_ds; in snd_hdspm_create()
6695 hdspm->port_names_in_qs = texts_ports_aio_in_qs; in snd_hdspm_create()
6696 hdspm->port_names_out_qs = texts_ports_aio_out_qs; in snd_hdspm_create()
6701 hdspm->ss_in_channels = hdspm->ss_out_channels = in snd_hdspm_create()
6703 hdspm->ds_in_channels = hdspm->ds_out_channels = in snd_hdspm_create()
6705 hdspm->qs_in_channels = hdspm->qs_out_channels = in snd_hdspm_create()
6708 hdspm->max_channels_in = RAYDAT_SS_CHANNELS; in snd_hdspm_create()
6709 hdspm->max_channels_out = RAYDAT_SS_CHANNELS; in snd_hdspm_create()
6711 hdspm->channel_map_in_ss = hdspm->channel_map_out_ss = in snd_hdspm_create()
6713 hdspm->channel_map_in_ds = hdspm->channel_map_out_ds = in snd_hdspm_create()
6715 hdspm->channel_map_in_qs = hdspm->channel_map_out_qs = in snd_hdspm_create()
6717 hdspm->channel_map_in = hdspm->channel_map_out = in snd_hdspm_create()
6720 hdspm->port_names_in_ss = hdspm->port_names_out_ss = in snd_hdspm_create()
6722 hdspm->port_names_in_ds = hdspm->port_names_out_ds = in snd_hdspm_create()
6724 hdspm->port_names_in_qs = hdspm->port_names_out_qs = in snd_hdspm_create()
6733 switch (hdspm->io_type) { 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, "AIO/RayDAT TCO module found\n"); in snd_hdspm_create()
6745 hdspm->tco = NULL; in snd_hdspm_create()
6752 hdspm->midiPorts++; in snd_hdspm_create()
6753 hdspm->tco = kzalloc(sizeof(*hdspm->tco), GFP_KERNEL); in snd_hdspm_create()
6754 if (hdspm->tco) in snd_hdspm_create()
6757 dev_info(card->dev, "MADI/AES TCO module found\n"); in snd_hdspm_create()
6759 hdspm->tco = NULL; in snd_hdspm_create()
6764 hdspm->tco = NULL; in snd_hdspm_create()
6768 switch (hdspm->io_type) { in snd_hdspm_create()
6770 if (hdspm->tco) { in snd_hdspm_create()
6771 hdspm->texts_autosync = texts_autosync_aes_tco; in snd_hdspm_create()
6772 hdspm->texts_autosync_items = in snd_hdspm_create()
6775 hdspm->texts_autosync = texts_autosync_aes; in snd_hdspm_create()
6776 hdspm->texts_autosync_items = in snd_hdspm_create()
6782 if (hdspm->tco) { in snd_hdspm_create()
6783 hdspm->texts_autosync = texts_autosync_madi_tco; in snd_hdspm_create()
6784 hdspm->texts_autosync_items = 4; in snd_hdspm_create()
6786 hdspm->texts_autosync = texts_autosync_madi; in snd_hdspm_create()
6787 hdspm->texts_autosync_items = 3; in snd_hdspm_create()
6796 if (hdspm->tco) { in snd_hdspm_create()
6797 hdspm->texts_autosync = texts_autosync_raydat_tco; in snd_hdspm_create()
6798 hdspm->texts_autosync_items = 9; in snd_hdspm_create()
6800 hdspm->texts_autosync = texts_autosync_raydat; in snd_hdspm_create()
6801 hdspm->texts_autosync_items = 8; in snd_hdspm_create()
6806 if (hdspm->tco) { in snd_hdspm_create()
6807 hdspm->texts_autosync = texts_autosync_aio_tco; in snd_hdspm_create()
6808 hdspm->texts_autosync_items = 6; in snd_hdspm_create()
6810 hdspm->texts_autosync = texts_autosync_aio; in snd_hdspm_create()
6811 hdspm->texts_autosync_items = 5; in snd_hdspm_create()
6817 if (hdspm->io_type != MADIface) { in snd_hdspm_create()
6818 hdspm->serial = (hdspm_read(hdspm, in snd_hdspm_create()
6820 /* id contains either a user-provided value or the default in snd_hdspm_create()
6822 * fill card->id with the serial number. in snd_hdspm_create()
6824 * If the serial number is 0xFFFFFF, then we're dealing with in snd_hdspm_create()
6826 * this case, we don't set card->id to avoid collisions in snd_hdspm_create()
6829 if (!id[hdspm->dev] && hdspm->serial != 0xFFFFFF) { in snd_hdspm_create()
6830 snprintf(card->id, sizeof(card->id), in snd_hdspm_create()
6831 "HDSPMx%06x", hdspm->serial); in snd_hdspm_create()
6832 snd_card_set_id(card, card->id); in snd_hdspm_create()
6836 dev_dbg(card->dev, "create alsa devices.\n"); in snd_hdspm_create()
6849 struct hdspm *hdspm = card->private_data; in snd_hdspm_card_free()
6851 if (hdspm->port) { in snd_hdspm_card_free()
6852 cancel_work_sync(&hdspm->midi_work); in snd_hdspm_card_free()
6855 hdspm->control_register &= in snd_hdspm_card_free()
6860 hdspm->control_register); in snd_hdspm_card_free()
6874 return -ENODEV; in snd_hdspm_probe()
6877 return -ENOENT; in snd_hdspm_probe()
6880 err = snd_devm_card_new(&pci->dev, index[dev], id[dev], in snd_hdspm_probe()
6885 hdspm = card->private_data; in snd_hdspm_probe()
6886 card->private_free = snd_hdspm_card_free; in snd_hdspm_probe()
6887 hdspm->dev = dev; in snd_hdspm_probe()
6888 hdspm->pci = pci; in snd_hdspm_probe()
6894 if (hdspm->io_type != MADIface) { in snd_hdspm_probe()
6895 snprintf(card->shortname, sizeof(card->shortname), "%s_%x", in snd_hdspm_probe()
6896 hdspm->card_name, hdspm->serial); in snd_hdspm_probe()
6897 snprintf(card->longname, sizeof(card->longname), in snd_hdspm_probe()
6899 hdspm->card_name, hdspm->serial, in snd_hdspm_probe()
6900 hdspm->port, hdspm->irq); in snd_hdspm_probe()
6902 snprintf(card->shortname, sizeof(card->shortname), "%s", in snd_hdspm_probe()
6903 hdspm->card_name); in snd_hdspm_probe()
6904 snprintf(card->longname, sizeof(card->longname), in snd_hdspm_probe()
6906 hdspm->card_name, hdspm->port, hdspm->irq); in snd_hdspm_probe()