Lines Matching refs:hdspm

955 	struct hdspm *hdspm;  member
981 struct hdspm { struct
1089 struct hdspm *hdspm); argument
1091 struct hdspm *hdspm);
1093 static inline void snd_hdspm_initialize_midi_flush(struct hdspm *hdspm);
1094 static inline int hdspm_get_pll_freq(struct hdspm *hdspm);
1095 static int hdspm_update_simple_mixer_controls(struct hdspm *hdspm);
1096 static int hdspm_autosync_ref(struct hdspm *hdspm);
1097 static int hdspm_set_toggle_setting(struct hdspm *hdspm, u32 regmask, int out);
1098 static int snd_hdspm_set_defaults(struct hdspm *hdspm);
1099 static int hdspm_system_clock_mode(struct hdspm *hdspm);
1100 static void hdspm_set_channel_dma_addr(struct hdspm *hdspm,
1104 static int hdspm_aes_sync_check(struct hdspm *hdspm, int idx);
1105 static int hdspm_wc_sync_check(struct hdspm *hdspm);
1106 static int hdspm_tco_sync_check(struct hdspm *hdspm);
1107 static int hdspm_sync_in_sync_check(struct hdspm *hdspm);
1109 static int hdspm_get_aes_sample_rate(struct hdspm *hdspm, int index);
1110 static int hdspm_get_tco_sample_rate(struct hdspm *hdspm);
1111 static int hdspm_get_wc_sample_rate(struct hdspm *hdspm);
1125 static bool hdspm_is_raydat_or_aio(struct hdspm *hdspm) in hdspm_is_raydat_or_aio() argument
1127 return ((AIO == hdspm->io_type) || (RayDAT == hdspm->io_type)); in hdspm_is_raydat_or_aio()
1134 static inline void hdspm_write(struct hdspm * hdspm, unsigned int reg, in hdspm_write() argument
1137 writel(val, hdspm->iobase + reg); in hdspm_write()
1140 static inline unsigned int hdspm_read(struct hdspm * hdspm, unsigned int reg) in hdspm_read() argument
1142 return readl(hdspm->iobase + reg); in hdspm_read()
1149 static inline int hdspm_read_in_gain(struct hdspm * hdspm, unsigned int chan, in hdspm_read_in_gain() argument
1155 return hdspm->mixer->ch[chan].in[in]; in hdspm_read_in_gain()
1158 static inline int hdspm_read_pb_gain(struct hdspm * hdspm, unsigned int chan, in hdspm_read_pb_gain() argument
1163 return hdspm->mixer->ch[chan].pb[pb]; in hdspm_read_pb_gain()
1166 static int hdspm_write_in_gain(struct hdspm *hdspm, unsigned int chan, in hdspm_write_in_gain() argument
1172 hdspm_write(hdspm, in hdspm_write_in_gain()
1175 (hdspm->mixer->ch[chan].in[in] = data & 0xFFFF)); in hdspm_write_in_gain()
1179 static int hdspm_write_pb_gain(struct hdspm *hdspm, unsigned int chan, in hdspm_write_pb_gain() argument
1185 hdspm_write(hdspm, in hdspm_write_pb_gain()
1188 (hdspm->mixer->ch[chan].pb[pb] = data & 0xFFFF)); in hdspm_write_pb_gain()
1194 static inline void snd_hdspm_enable_in(struct hdspm * hdspm, int i, int v) in snd_hdspm_enable_in() argument
1196 hdspm_write(hdspm, HDSPM_inputEnableBase + (4 * i), v); in snd_hdspm_enable_in()
1199 static inline void snd_hdspm_enable_out(struct hdspm * hdspm, int i, int v) in snd_hdspm_enable_out() argument
1201 hdspm_write(hdspm, HDSPM_outputEnableBase + (4 * i), v); in snd_hdspm_enable_out()
1205 static int snd_hdspm_use_is_exclusive(struct hdspm *hdspm) in snd_hdspm_use_is_exclusive() argument
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()
1238 static int hdspm_rate_multiplier(struct hdspm *hdspm, int rate) in hdspm_rate_multiplier() argument
1241 if (hdspm->control_register & HDSPM_QuadSpeed) in hdspm_rate_multiplier()
1243 else if (hdspm->control_register & in hdspm_rate_multiplier()
1251 static int hdspm_external_sample_rate(struct hdspm *hdspm) in hdspm_external_sample_rate() argument
1256 switch (hdspm->io_type) { in hdspm_external_sample_rate()
1258 status2 = hdspm_read(hdspm, HDSPM_statusRegister2); in hdspm_external_sample_rate()
1259 status = hdspm_read(hdspm, HDSPM_statusRegister); in hdspm_external_sample_rate()
1261 syncref = hdspm_autosync_ref(hdspm); in hdspm_external_sample_rate()
1265 if (hdspm_wc_sync_check(hdspm)) in hdspm_external_sample_rate()
1266 return HDSPM_bit2freq(hdspm_get_wc_sample_rate(hdspm)); in hdspm_external_sample_rate()
1278 if (hdspm_aes_sync_check(hdspm, syncref - HDSPM_AES32_AUTOSYNC_FROM_AES1)) in hdspm_external_sample_rate()
1279 return HDSPM_bit2freq(hdspm_get_aes_sample_rate(hdspm, in hdspm_external_sample_rate()
1286 if (hdspm_tco_sync_check(hdspm)) in hdspm_external_sample_rate()
1287 return HDSPM_bit2freq(hdspm_get_tco_sample_rate(hdspm)); in hdspm_external_sample_rate()
1295 status = hdspm_read(hdspm, HDSPM_statusRegister); in hdspm_external_sample_rate()
1329 status2 = hdspm_read(hdspm, HDSPM_statusRegister2); in hdspm_external_sample_rate()
1330 status = hdspm_read(hdspm, HDSPM_statusRegister); in hdspm_external_sample_rate()
1379 return hdspm_rate_multiplier(hdspm, rate); in hdspm_external_sample_rate()
1425 syncref = hdspm_autosync_ref(hdspm); in hdspm_external_sample_rate()
1429 hdspm_tco_sync_check(hdspm)); in hdspm_external_sample_rate()
1433 hdspm_sync_in_sync_check(hdspm)); in hdspm_external_sample_rate()
1438 hdspm_get_pll_freq(hdspm)); in hdspm_external_sample_rate()
1442 rate = hdspm_rate_multiplier(hdspm, rate); in hdspm_external_sample_rate()
1451 static int hdspm_get_latency(struct hdspm *hdspm) in hdspm_get_latency() argument
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()
1471 static inline void hdspm_compute_period_size(struct hdspm *hdspm) in hdspm_compute_period_size() argument
1473 hdspm->period_bytes = 4 * hdspm_get_latency(hdspm); in hdspm_compute_period_size()
1477 static snd_pcm_uframes_t hdspm_hw_pointer(struct hdspm *hdspm) in hdspm_hw_pointer() argument
1481 position = hdspm_read(hdspm, HDSPM_statusRegister); in hdspm_hw_pointer()
1483 switch (hdspm->io_type) { in hdspm_hw_pointer()
1491 (hdspm->period_bytes / 4) : 0; in hdspm_hw_pointer()
1498 static inline void hdspm_start_audio(struct hdspm * s) in hdspm_start_audio()
1504 static inline void hdspm_stop_audio(struct hdspm * s) in hdspm_stop_audio()
1511 static void hdspm_silence_playback(struct hdspm *hdspm) in hdspm_silence_playback() argument
1514 int n = hdspm->period_bytes; in hdspm_silence_playback()
1515 void *buf = hdspm->playback_buffer; in hdspm_silence_playback()
1526 static int hdspm_set_interrupt_interval(struct hdspm *s, unsigned int frames) in hdspm_set_interrupt_interval()
1565 static u64 hdspm_calc_dds_value(struct hdspm *hdspm, u64 period) in hdspm_calc_dds_value() argument
1572 switch (hdspm->io_type) { in hdspm_calc_dds_value()
1593 static void hdspm_set_dds_value(struct hdspm *hdspm, int rate) in hdspm_set_dds_value() argument
1605 switch (hdspm->io_type) { in hdspm_set_dds_value()
1625 hdspm_write(hdspm, HDSPM_freqReg, (u32)n); in hdspm_set_dds_value()
1629 static int hdspm_set_rate(struct hdspm * hdspm, int rate, int called_internally) in hdspm_set_rate() argument
1640 if (!(hdspm->control_register & HDSPM_ClockModeMaster)) { in hdspm_set_rate()
1649 dev_warn(hdspm->card->dev, in hdspm_set_rate()
1656 hdspm_external_sample_rate(hdspm); in hdspm_set_rate()
1658 if (hdspm_autosync_ref(hdspm) == 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()
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()
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()
1748 hdspm_set_dds_value(hdspm, rate); in hdspm_set_rate()
1750 if (AES32 == hdspm->io_type && rate != current_rate) in hdspm_set_rate()
1751 hdspm_write(hdspm, HDSPM_eeprom_wr, 0); 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()
1785 static void all_in_all_mixer(struct hdspm * hdspm, int sgain) in all_in_all_mixer() argument
1799 hdspm_write_in_gain(hdspm, i, j, gain); in all_in_all_mixer()
1800 hdspm_write_pb_gain(hdspm, i, j, gain); in all_in_all_mixer()
1808 static inline unsigned char snd_hdspm_midi_read_byte (struct hdspm *hdspm, in snd_hdspm_midi_read_byte() argument
1812 return hdspm_read(hdspm, hdspm->midi[id].dataIn); in snd_hdspm_midi_read_byte()
1815 static inline void snd_hdspm_midi_write_byte (struct hdspm *hdspm, int id, in snd_hdspm_midi_write_byte() argument
1819 return hdspm_write(hdspm, hdspm->midi[id].dataOut, val); in snd_hdspm_midi_write_byte()
1822 static inline int snd_hdspm_midi_input_available (struct hdspm *hdspm, int id) in snd_hdspm_midi_input_available() argument
1824 return hdspm_read(hdspm, hdspm->midi[id].statusIn) & 0xFF; in snd_hdspm_midi_input_available()
1827 static inline int snd_hdspm_midi_output_possible (struct hdspm *hdspm, int id) in snd_hdspm_midi_output_possible() argument
1831 fifo_bytes_used = hdspm_read(hdspm, hdspm->midi[id].statusOut) & 0xFF; in snd_hdspm_midi_output_possible()
1839 static void snd_hdspm_flush_midi_input(struct hdspm *hdspm, int id) in snd_hdspm_flush_midi_input() argument
1841 while (snd_hdspm_midi_input_available (hdspm, id)) in snd_hdspm_flush_midi_input()
1842 snd_hdspm_midi_read_byte (hdspm, id); in snd_hdspm_flush_midi_input()
1858 n_pending = snd_hdspm_midi_output_possible (hmidi->hdspm, in snd_hdspm_midi_output_write()
1868 snd_hdspm_midi_write_byte (hmidi->hdspm, in snd_hdspm_midi_output_write()
1888 n_pending = snd_hdspm_midi_input_available (hmidi->hdspm, hmidi->id); in snd_hdspm_midi_input_read()
1894 buf[i] = snd_hdspm_midi_read_byte (hmidi->hdspm, in snd_hdspm_midi_input_read()
1902 snd_hdspm_midi_read_byte (hmidi->hdspm, 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()
1921 struct hdspm *hdspm; in snd_hdspm_midi_input_trigger() local
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()
1992 snd_hdspm_flush_midi_input (hmidi->hdspm, hmidi->id); in snd_hdspm_midi_input_open()
2054 struct hdspm *hdspm, int id) in snd_hdspm_create_midi() argument
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()
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()
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()
2118 } else if ((id == 2) && (MADI == hdspm->io_type)) { 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()
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()
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()
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()
2173 struct hdspm *hdspm = container_of(work, struct hdspm, midi_work); in hdspm_midi_work() local
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()
2192 static inline int hdspm_get_pll_freq(struct hdspm *hdspm) in hdspm_get_pll_freq() argument
2196 period = hdspm_read(hdspm, HDSPM_RD_PLL_FREQ); in hdspm_get_pll_freq()
2197 rate = hdspm_calc_dds_value(hdspm, period); in hdspm_get_pll_freq()
2206 static int hdspm_get_system_sample_rate(struct hdspm *hdspm) in hdspm_get_system_sample_rate() argument
2210 rate = hdspm_get_pll_freq(hdspm); in hdspm_get_system_sample_rate()
2214 if (0 == hdspm_system_clock_mode(hdspm)) { in hdspm_get_system_sample_rate()
2216 rate = hdspm->system_sample_rate; in hdspm_get_system_sample_rate()
2219 rate = hdspm_external_sample_rate(hdspm); in hdspm_get_system_sample_rate()
2221 rate = hdspm->system_sample_rate; in hdspm_get_system_sample_rate()
2256 struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); in snd_hdspm_get_system_sample_rate() local
2258 ucontrol->value.integer.value[0] = hdspm_get_system_sample_rate(hdspm); in snd_hdspm_get_system_sample_rate()
2266 struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); in snd_hdspm_put_system_sample_rate() local
2271 hdspm_set_dds_value(hdspm, ucontrol->value.integer.value[0]); in snd_hdspm_put_system_sample_rate()
2279 static int hdspm_get_wc_sample_rate(struct hdspm *hdspm) in hdspm_get_wc_sample_rate() argument
2283 switch (hdspm->io_type) { in hdspm_get_wc_sample_rate()
2286 status = hdspm_read(hdspm, HDSPM_RD_STATUS_1); in hdspm_get_wc_sample_rate()
2289 status = hdspm_read(hdspm, HDSPM_statusRegister); in hdspm_get_wc_sample_rate()
2303 static int hdspm_get_tco_sample_rate(struct hdspm *hdspm) in hdspm_get_tco_sample_rate() argument
2307 if (hdspm->tco) { in hdspm_get_tco_sample_rate()
2308 switch (hdspm->io_type) { in hdspm_get_tco_sample_rate()
2311 status = hdspm_read(hdspm, HDSPM_RD_STATUS_1); in hdspm_get_tco_sample_rate()
2314 status = hdspm_read(hdspm, HDSPM_statusRegister); in hdspm_get_tco_sample_rate()
2328 static int hdspm_get_sync_in_sample_rate(struct hdspm *hdspm) in hdspm_get_sync_in_sample_rate() argument
2332 if (hdspm->tco) { in hdspm_get_sync_in_sample_rate()
2333 switch (hdspm->io_type) { in hdspm_get_sync_in_sample_rate()
2336 status = hdspm_read(hdspm, HDSPM_RD_STATUS_2); in hdspm_get_sync_in_sample_rate()
2349 static int hdspm_get_aes_sample_rate(struct hdspm *hdspm, int index) in hdspm_get_aes_sample_rate() argument
2353 switch (hdspm->io_type) { in hdspm_get_aes_sample_rate()
2355 timecode = hdspm_read(hdspm, HDSPM_timecodeRegister); in hdspm_get_aes_sample_rate()
2367 static int hdspm_get_s1_sample_rate(struct hdspm *hdspm, unsigned int idx) in hdspm_get_s1_sample_rate() argument
2369 int status = hdspm_read(hdspm, HDSPM_RD_STATUS_2); in hdspm_get_s1_sample_rate()
2381 static int hdspm_external_rate_to_enum(struct hdspm *hdspm) in hdspm_external_rate_to_enum() argument
2383 int rate = hdspm_external_sample_rate(hdspm); in hdspm_external_rate_to_enum()
2416 struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); in snd_hdspm_get_autosync_sample_rate() local
2418 switch (hdspm->io_type) { in snd_hdspm_get_autosync_sample_rate()
2423 hdspm_get_wc_sample_rate(hdspm); in snd_hdspm_get_autosync_sample_rate()
2427 hdspm_get_tco_sample_rate(hdspm); in snd_hdspm_get_autosync_sample_rate()
2431 hdspm_get_sync_in_sample_rate(hdspm); in snd_hdspm_get_autosync_sample_rate()
2435 hdspm_get_s1_sample_rate(hdspm, in snd_hdspm_get_autosync_sample_rate()
2444 hdspm_get_wc_sample_rate(hdspm); in snd_hdspm_get_autosync_sample_rate()
2448 hdspm_get_tco_sample_rate(hdspm); in snd_hdspm_get_autosync_sample_rate()
2452 hdspm_get_sync_in_sample_rate(hdspm); in snd_hdspm_get_autosync_sample_rate()
2456 hdspm_get_s1_sample_rate(hdspm, in snd_hdspm_get_autosync_sample_rate()
2466 hdspm_get_wc_sample_rate(hdspm); in snd_hdspm_get_autosync_sample_rate()
2470 hdspm_get_tco_sample_rate(hdspm); in snd_hdspm_get_autosync_sample_rate()
2474 hdspm_get_sync_in_sample_rate(hdspm); in snd_hdspm_get_autosync_sample_rate()
2478 hdspm_external_rate_to_enum(hdspm); in snd_hdspm_get_autosync_sample_rate()
2482 hdspm_get_aes_sample_rate(hdspm, in snd_hdspm_get_autosync_sample_rate()
2492 hdspm_external_rate_to_enum(hdspm); in snd_hdspm_get_autosync_sample_rate()
2518 static int hdspm_system_clock_mode(struct hdspm *hdspm) in hdspm_system_clock_mode() argument
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()
2540 static void hdspm_set_system_clock_mode(struct hdspm *hdspm, int mode) in hdspm_set_system_clock_mode() argument
2542 hdspm_set_toggle_setting(hdspm, in hdspm_set_system_clock_mode()
2543 (hdspm_is_raydat_or_aio(hdspm)) ? in hdspm_set_system_clock_mode()
2560 struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); in snd_hdspm_get_system_clock_mode() local
2562 ucontrol->value.enumerated.item[0] = hdspm_system_clock_mode(hdspm); in snd_hdspm_get_system_clock_mode()
2569 struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); in snd_hdspm_put_system_clock_mode() local
2572 if (!snd_hdspm_use_is_exclusive(hdspm)) in snd_hdspm_put_system_clock_mode()
2581 hdspm_set_system_clock_mode(hdspm, val); in snd_hdspm_put_system_clock_mode()
2597 static int hdspm_clock_source(struct hdspm * hdspm) in hdspm_clock_source() argument
2599 switch (hdspm->system_sample_rate) { in hdspm_clock_source()
2614 static int hdspm_set_clock_source(struct hdspm * hdspm, int mode) in hdspm_set_clock_source() argument
2639 hdspm_set_rate(hdspm, rate, 1); in hdspm_set_clock_source()
2652 struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); in snd_hdspm_get_clock_source() local
2654 ucontrol->value.enumerated.item[0] = hdspm_clock_source(hdspm); in snd_hdspm_get_clock_source()
2661 struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); in snd_hdspm_put_clock_source() local
2665 if (!snd_hdspm_use_is_exclusive(hdspm)) in snd_hdspm_put_clock_source()
2672 spin_lock_irq(&hdspm->lock); in snd_hdspm_put_clock_source()
2673 if (val != hdspm_clock_source(hdspm)) in snd_hdspm_put_clock_source()
2674 change = (hdspm_set_clock_source(hdspm, val) == 0) ? 1 : 0; in snd_hdspm_put_clock_source()
2677 spin_unlock_irq(&hdspm->lock); in snd_hdspm_put_clock_source()
2699 static int hdspm_pref_sync_ref(struct hdspm * hdspm) in hdspm_pref_sync_ref() argument
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()
2802 static int hdspm_set_pref_sync_ref(struct hdspm * hdspm, int pref) in hdspm_set_pref_sync_ref() argument
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()
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()
2875 hdspm->control_register |= HDSPM_SyncRef0; in hdspm_set_pref_sync_ref()
2878 hdspm->control_register |= in hdspm_set_pref_sync_ref()
2889 if (hdspm->tco) { in hdspm_set_pref_sync_ref()
2918 if (hdspm->tco) { 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()
2952 hdspm_write(hdspm, HDSPM_controlRegister, in hdspm_set_pref_sync_ref()
2953 hdspm->control_register); in hdspm_set_pref_sync_ref()
2963 struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); in snd_hdspm_info_pref_sync_ref() local
2965 snd_ctl_enum_info(uinfo, 1, hdspm->texts_autosync_items, hdspm->texts_autosync); in snd_hdspm_info_pref_sync_ref()
2973 struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); in snd_hdspm_get_pref_sync_ref() local
2974 int psf = hdspm_pref_sync_ref(hdspm); in snd_hdspm_get_pref_sync_ref()
2987 struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); in snd_hdspm_put_pref_sync_ref() local
2990 if (!snd_hdspm_use_is_exclusive(hdspm)) 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()
3001 if (val != hdspm_pref_sync_ref(hdspm)) in snd_hdspm_put_pref_sync_ref()
3002 change = (0 == hdspm_set_pref_sync_ref(hdspm, val)) ? 1 : 0; in snd_hdspm_put_pref_sync_ref()
3004 spin_unlock_irq(&hdspm->lock); in snd_hdspm_put_pref_sync_ref()
3018 static int hdspm_autosync_ref(struct hdspm *hdspm) in hdspm_autosync_ref() argument
3021 if (AES32 == hdspm->io_type) { in hdspm_autosync_ref()
3023 unsigned int status = hdspm_read(hdspm, HDSPM_statusRegister); in hdspm_autosync_ref()
3031 } else if (MADI == hdspm->io_type) { in hdspm_autosync_ref()
3033 unsigned int status2 = hdspm_read(hdspm, HDSPM_statusRegister2); in hdspm_autosync_ref()
3057 struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); in snd_hdspm_info_autosync_ref() local
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()
3076 struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); in snd_hdspm_get_autosync_ref() local
3078 ucontrol->value.enumerated.item[0] = hdspm_autosync_ref(hdspm); in snd_hdspm_get_autosync_ref()
3107 struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); in snd_hdspm_get_tco_video_input_format() local
3108 status = hdspm_read(hdspm, HDSPM_RD_TCO + 4); in snd_hdspm_get_tco_video_input_format()
3148 static int hdspm_tco_ltc_frames(struct hdspm *hdspm) in hdspm_tco_ltc_frames() argument
3153 status = hdspm_read(hdspm, HDSPM_RD_TCO + 4); in hdspm_tco_ltc_frames()
3182 struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); in snd_hdspm_get_tco_ltc_frames() local
3184 ucontrol->value.enumerated.item[0] = hdspm_tco_ltc_frames(hdspm); in snd_hdspm_get_tco_ltc_frames()
3197 static int hdspm_toggle_setting(struct hdspm *hdspm, u32 regmask) in hdspm_toggle_setting() argument
3201 if (hdspm_is_raydat_or_aio(hdspm)) in hdspm_toggle_setting()
3202 reg = hdspm->settings_register; in hdspm_toggle_setting()
3204 reg = hdspm->control_register; in hdspm_toggle_setting()
3209 static int hdspm_set_toggle_setting(struct hdspm *hdspm, u32 regmask, int out) in hdspm_set_toggle_setting() argument
3214 if (hdspm_is_raydat_or_aio(hdspm)) { in hdspm_set_toggle_setting()
3215 reg = &(hdspm->settings_register); in hdspm_set_toggle_setting()
3218 reg = &(hdspm->control_register); in hdspm_set_toggle_setting()
3227 hdspm_write(hdspm, target_reg, *reg); in hdspm_set_toggle_setting()
3237 struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); in snd_hdspm_get_toggle_setting() local
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()
3249 struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); in snd_hdspm_put_toggle_setting() local
3254 if (!snd_hdspm_use_is_exclusive(hdspm)) in snd_hdspm_put_toggle_setting()
3257 spin_lock_irq(&hdspm->lock); in snd_hdspm_put_toggle_setting()
3258 change = (int) val != hdspm_toggle_setting(hdspm, regmask); in snd_hdspm_put_toggle_setting()
3259 hdspm_set_toggle_setting(hdspm, regmask, val); in snd_hdspm_put_toggle_setting()
3260 spin_unlock_irq(&hdspm->lock); in snd_hdspm_put_toggle_setting()
3273 static int hdspm_input_select(struct hdspm * hdspm) in hdspm_input_select() argument
3275 return (hdspm->control_register & HDSPM_InputSelect0) ? 1 : 0; in hdspm_input_select()
3278 static int hdspm_set_input_select(struct hdspm * hdspm, int out) in hdspm_set_input_select() argument
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()
3300 struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); in snd_hdspm_get_input_select() local
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()
3311 struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); in snd_hdspm_put_input_select() local
3315 if (!snd_hdspm_use_is_exclusive(hdspm)) in snd_hdspm_put_input_select()
3318 spin_lock_irq(&hdspm->lock); in snd_hdspm_put_input_select()
3319 change = (int) val != hdspm_input_select(hdspm); in snd_hdspm_put_input_select()
3320 hdspm_set_input_select(hdspm, val); in snd_hdspm_put_input_select()
3321 spin_unlock_irq(&hdspm->lock); in snd_hdspm_put_input_select()
3335 static int hdspm_ds_wire(struct hdspm * hdspm) in hdspm_ds_wire() argument
3337 return (hdspm->control_register & HDSPM_DS_DoubleWire) ? 1 : 0; in hdspm_ds_wire()
3340 static int hdspm_set_ds_wire(struct hdspm * hdspm, int ds) in hdspm_set_ds_wire() argument
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()
3362 struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); in snd_hdspm_get_ds_wire() local
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()
3373 struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); in snd_hdspm_put_ds_wire() local
3377 if (!snd_hdspm_use_is_exclusive(hdspm)) in snd_hdspm_put_ds_wire()
3380 spin_lock_irq(&hdspm->lock); in snd_hdspm_put_ds_wire()
3381 change = (int) val != hdspm_ds_wire(hdspm); in snd_hdspm_put_ds_wire()
3382 hdspm_set_ds_wire(hdspm, val); in snd_hdspm_put_ds_wire()
3383 spin_unlock_irq(&hdspm->lock); in snd_hdspm_put_ds_wire()
3397 static int hdspm_qs_wire(struct hdspm * hdspm) in hdspm_qs_wire() argument
3399 if (hdspm->control_register & HDSPM_QS_DoubleWire) in hdspm_qs_wire()
3401 if (hdspm->control_register & HDSPM_QS_QuadWire) in hdspm_qs_wire()
3406 static int hdspm_set_qs_wire(struct hdspm * hdspm, int mode) in hdspm_set_qs_wire() argument
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()
3435 struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); in snd_hdspm_get_qs_wire() local
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()
3446 struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); in snd_hdspm_put_qs_wire() local
3450 if (!snd_hdspm_use_is_exclusive(hdspm)) in snd_hdspm_put_qs_wire()
3457 spin_lock_irq(&hdspm->lock); in snd_hdspm_put_qs_wire()
3458 change = val != hdspm_qs_wire(hdspm); in snd_hdspm_put_qs_wire()
3459 hdspm_set_qs_wire(hdspm, val); in snd_hdspm_put_qs_wire()
3460 spin_unlock_irq(&hdspm->lock); in snd_hdspm_put_qs_wire()
3473 static int hdspm_tristate(struct hdspm *hdspm, u32 regmask) in hdspm_tristate() argument
3475 u32 reg = hdspm->settings_register & (regmask * 3); in hdspm_tristate()
3479 static int hdspm_set_tristate(struct hdspm *hdspm, int mode, u32 regmask) in hdspm_set_tristate() argument
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()
3510 struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); in snd_hdspm_get_tristate() local
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()
3522 struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); in snd_hdspm_put_tristate() local
3527 if (!snd_hdspm_use_is_exclusive(hdspm)) in snd_hdspm_put_tristate()
3535 spin_lock_irq(&hdspm->lock); in snd_hdspm_put_tristate()
3536 change = val != hdspm_tristate(hdspm, regmask); in snd_hdspm_put_tristate()
3537 hdspm_set_tristate(hdspm, val, regmask); in snd_hdspm_put_tristate()
3538 spin_unlock_irq(&hdspm->lock); in snd_hdspm_put_tristate()
3551 static int hdspm_madi_speedmode(struct hdspm *hdspm) in hdspm_madi_speedmode() argument
3553 if (hdspm->control_register & HDSPM_QuadSpeed) in hdspm_madi_speedmode()
3555 if (hdspm->control_register & HDSPM_DoubleSpeed) in hdspm_madi_speedmode()
3560 static int hdspm_set_madi_speedmode(struct hdspm *hdspm, int mode) in hdspm_set_madi_speedmode() argument
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()
3589 struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); in snd_hdspm_get_madi_speedmode() local
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()
3600 struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); in snd_hdspm_put_madi_speedmode() local
3604 if (!snd_hdspm_use_is_exclusive(hdspm)) in snd_hdspm_put_madi_speedmode()
3611 spin_lock_irq(&hdspm->lock); in snd_hdspm_put_madi_speedmode()
3612 change = val != hdspm_madi_speedmode(hdspm); in snd_hdspm_put_madi_speedmode()
3613 hdspm_set_madi_speedmode(hdspm, val); in snd_hdspm_put_madi_speedmode()
3614 spin_unlock_irq(&hdspm->lock); in snd_hdspm_put_madi_speedmode()
3644 struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); in snd_hdspm_get_mixer() local
3660 spin_lock_irq(&hdspm->lock); in snd_hdspm_get_mixer()
3663 hdspm_read_pb_gain(hdspm, destination, in snd_hdspm_get_mixer()
3667 hdspm_read_in_gain(hdspm, destination, source); in snd_hdspm_get_mixer()
3669 spin_unlock_irq(&hdspm->lock); in snd_hdspm_get_mixer()
3677 struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); in snd_hdspm_put_mixer() local
3683 if (!snd_hdspm_use_is_exclusive(hdspm)) in snd_hdspm_put_mixer()
3696 spin_lock_irq(&hdspm->lock); in snd_hdspm_put_mixer()
3699 change = gain != hdspm_read_pb_gain(hdspm, destination, in snd_hdspm_put_mixer()
3703 change = gain != hdspm_read_in_gain(hdspm, destination, in snd_hdspm_put_mixer()
3708 hdspm_write_pb_gain(hdspm, destination, in snd_hdspm_put_mixer()
3712 hdspm_write_in_gain(hdspm, destination, source, in snd_hdspm_put_mixer()
3715 spin_unlock_irq(&hdspm->lock); in snd_hdspm_put_mixer()
3748 struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); in snd_hdspm_get_playback_mixer() local
3756 spin_lock_irq(&hdspm->lock); in snd_hdspm_get_playback_mixer()
3758 (hdspm_read_pb_gain(hdspm, channel, channel)*64)/UNITY_GAIN; in snd_hdspm_get_playback_mixer()
3759 spin_unlock_irq(&hdspm->lock); in snd_hdspm_get_playback_mixer()
3767 struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); in snd_hdspm_put_playback_mixer() local
3772 if (!snd_hdspm_use_is_exclusive(hdspm)) in snd_hdspm_put_playback_mixer()
3782 spin_lock_irq(&hdspm->lock); in snd_hdspm_put_playback_mixer()
3784 gain != hdspm_read_pb_gain(hdspm, channel, in snd_hdspm_put_playback_mixer()
3787 hdspm_write_pb_gain(hdspm, channel, channel, in snd_hdspm_put_playback_mixer()
3789 spin_unlock_irq(&hdspm->lock); in snd_hdspm_put_playback_mixer()
3829 static int hdspm_wc_sync_check(struct hdspm *hdspm) in hdspm_wc_sync_check() argument
3833 switch (hdspm->io_type) { in hdspm_wc_sync_check()
3835 status = hdspm_read(hdspm, HDSPM_statusRegister); in hdspm_wc_sync_check()
3845 status2 = hdspm_read(hdspm, HDSPM_statusRegister2); in hdspm_wc_sync_check()
3856 status = hdspm_read(hdspm, HDSPM_statusRegister); in hdspm_wc_sync_check()
3873 static int hdspm_madi_sync_check(struct hdspm *hdspm) in hdspm_madi_sync_check() argument
3875 int status = hdspm_read(hdspm, HDSPM_statusRegister); in hdspm_madi_sync_check()
3886 static int hdspm_s1_sync_check(struct hdspm *hdspm, int idx) in hdspm_s1_sync_check() argument
3890 status = hdspm_read(hdspm, HDSPM_RD_STATUS_1); in hdspm_s1_sync_check()
3903 static int hdspm_sync_in_sync_check(struct hdspm *hdspm) in hdspm_sync_in_sync_check() argument
3907 switch (hdspm->io_type) { in hdspm_sync_in_sync_check()
3910 status = hdspm_read(hdspm, HDSPM_RD_STATUS_3); in hdspm_sync_in_sync_check()
3916 status = hdspm_read(hdspm, HDSPM_statusRegister); in hdspm_sync_in_sync_check()
3922 status = hdspm_read(hdspm, HDSPM_statusRegister2); in hdspm_sync_in_sync_check()
3939 static int hdspm_aes_sync_check(struct hdspm *hdspm, int idx) in hdspm_aes_sync_check() argument
3942 status2 = hdspm_read(hdspm, HDSPM_statusRegister2); in hdspm_aes_sync_check()
3954 static int hdspm_tco_input_check(struct hdspm *hdspm, u32 mask) in hdspm_tco_input_check() argument
3957 status = hdspm_read(hdspm, HDSPM_RD_TCO + 4); in hdspm_tco_input_check()
3963 static int hdspm_tco_sync_check(struct hdspm *hdspm) in hdspm_tco_sync_check() argument
3967 if (hdspm->tco) { in hdspm_tco_sync_check()
3968 switch (hdspm->io_type) { in hdspm_tco_sync_check()
3970 status = hdspm_read(hdspm, HDSPM_statusRegister); in hdspm_tco_sync_check()
3979 status = hdspm_read(hdspm, HDSPM_statusRegister); in hdspm_tco_sync_check()
3989 status = hdspm_read(hdspm, HDSPM_RD_STATUS_1); in hdspm_tco_sync_check()
4009 struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); in snd_hdspm_get_sync_check() local
4012 switch (hdspm->io_type) { in snd_hdspm_get_sync_check()
4016 val = hdspm_wc_sync_check(hdspm); break; in snd_hdspm_get_sync_check()
4018 val = hdspm_tco_sync_check(hdspm); break; in snd_hdspm_get_sync_check()
4020 val = hdspm_sync_in_sync_check(hdspm); break; in snd_hdspm_get_sync_check()
4022 val = hdspm_s1_sync_check(hdspm, in snd_hdspm_get_sync_check()
4030 val = hdspm_wc_sync_check(hdspm); break; in snd_hdspm_get_sync_check()
4032 val = hdspm_tco_sync_check(hdspm); break; in snd_hdspm_get_sync_check()
4034 val = hdspm_sync_in_sync_check(hdspm); break; in snd_hdspm_get_sync_check()
4036 val = hdspm_s1_sync_check(hdspm, in snd_hdspm_get_sync_check()
4044 val = hdspm_wc_sync_check(hdspm); break; in snd_hdspm_get_sync_check()
4046 val = hdspm_madi_sync_check(hdspm); break; in snd_hdspm_get_sync_check()
4048 val = hdspm_tco_sync_check(hdspm); break; in snd_hdspm_get_sync_check()
4050 val = hdspm_sync_in_sync_check(hdspm); break; in snd_hdspm_get_sync_check()
4055 val = hdspm_madi_sync_check(hdspm); /* MADI */ in snd_hdspm_get_sync_check()
4061 val = hdspm_wc_sync_check(hdspm); break; in snd_hdspm_get_sync_check()
4063 val = hdspm_tco_sync_check(hdspm); break; in snd_hdspm_get_sync_check()
4065 val = hdspm_sync_in_sync_check(hdspm); break; in snd_hdspm_get_sync_check()
4067 val = hdspm_aes_sync_check(hdspm, in snd_hdspm_get_sync_check()
4074 if (hdspm->tco) { in snd_hdspm_get_sync_check()
4078 val = hdspm_tco_input_check(hdspm, HDSPM_TCO1_TCO_lock); in snd_hdspm_get_sync_check()
4082 val = hdspm_tco_input_check(hdspm, in snd_hdspm_get_sync_check()
4102 static void hdspm_tco_write(struct hdspm *hdspm) in hdspm_tco_write() argument
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()
4184 hdspm_write(hdspm, HDSPM_WR_TCO, tc[0]); in hdspm_tco_write()
4185 hdspm_write(hdspm, HDSPM_WR_TCO+4, tc[1]); in hdspm_tco_write()
4186 hdspm_write(hdspm, HDSPM_WR_TCO+8, tc[2]); in hdspm_tco_write()
4187 hdspm_write(hdspm, HDSPM_WR_TCO+12, tc[3]); in hdspm_tco_write()
4214 struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); in snd_hdspm_get_tco_sample_rate() local
4216 ucontrol->value.enumerated.item[0] = hdspm->tco->samplerate; in snd_hdspm_get_tco_sample_rate()
4224 struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); in snd_hdspm_put_tco_sample_rate() local
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()
4229 hdspm_tco_write(hdspm); in snd_hdspm_put_tco_sample_rate()
4261 struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); in snd_hdspm_get_tco_pull() local
4263 ucontrol->value.enumerated.item[0] = hdspm->tco->pull; in snd_hdspm_get_tco_pull()
4271 struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); in snd_hdspm_put_tco_pull() local
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()
4276 hdspm_tco_write(hdspm); in snd_hdspm_put_tco_pull()
4306 struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); in snd_hdspm_get_tco_wck_conversion() local
4308 ucontrol->value.enumerated.item[0] = hdspm->tco->wordclock; in snd_hdspm_get_tco_wck_conversion()
4316 struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); in snd_hdspm_put_tco_wck_conversion() local
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()
4321 hdspm_tco_write(hdspm); in snd_hdspm_put_tco_wck_conversion()
4353 struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); in snd_hdspm_get_tco_frame_rate() local
4355 ucontrol->value.enumerated.item[0] = hdspm->tco->framerate; in snd_hdspm_get_tco_frame_rate()
4363 struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); in snd_hdspm_put_tco_frame_rate() local
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()
4368 hdspm_tco_write(hdspm); in snd_hdspm_put_tco_frame_rate()
4399 struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); in snd_hdspm_get_tco_sync_source() local
4401 ucontrol->value.enumerated.item[0] = hdspm->tco->input; in snd_hdspm_get_tco_sync_source()
4409 struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); in snd_hdspm_put_tco_sync_source() local
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()
4414 hdspm_tco_write(hdspm); in snd_hdspm_put_tco_sync_source()
4449 struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); in snd_hdspm_get_tco_word_term() local
4451 ucontrol->value.integer.value[0] = hdspm->tco->term; in snd_hdspm_get_tco_word_term()
4460 struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); in snd_hdspm_put_tco_word_term() local
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()
4465 hdspm_tco_write(hdspm); in snd_hdspm_put_tco_word_term()
4639 static int hdspm_update_simple_mixer_controls(struct hdspm * hdspm) in hdspm_update_simple_mixer_controls() argument
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()
4664 struct hdspm *hdspm) in snd_hdspm_create_controls() argument
4671 switch (hdspm->io_type) { in snd_hdspm_create_controls()
4697 snd_ctl_new1(&list[idx], hdspm)); 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()
4715 kctl = snd_ctl_new1(&snd_hdspm_playback_mixer, hdspm); 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()
4729 snd_ctl_new1(&list[idx], hdspm)); in snd_hdspm_create_controls()
4746 struct hdspm *hdspm = entry->private_data; in snd_hdspm_proc_read_tco() local
4755 status = hdspm_read(hdspm, HDSPM_statusRegister); in snd_hdspm_proc_read_tco()
4756 control = hdspm->control_register; in snd_hdspm_proc_read_tco()
4761 a = hdspm_read(hdspm, HDSPM_RD_TCO+4); in snd_hdspm_proc_read_tco()
4800 switch (hdspm->io_type) { in snd_hdspm_proc_read_tco()
4813 period = hdspm_read(hdspm, HDSPM_RD_PLL_FREQ); in snd_hdspm_proc_read_tco()
4829 ltc = hdspm_read(hdspm, HDSPM_RD_TCO); in snd_hdspm_proc_read_tco()
4858 struct hdspm *hdspm = entry->private_data; in snd_hdspm_proc_read_madi() local
4866 status = hdspm_read(hdspm, HDSPM_statusRegister); in snd_hdspm_proc_read_madi()
4867 status2 = hdspm_read(hdspm, HDSPM_statusRegister2); 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()
4877 (hdspm_read(hdspm, HDSPM_midiStatusIn1)>>8) & 0xFFFFFF, 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()
4890 hdspm->irq_count); in snd_hdspm_proc_read_madi()
4897 (2 * (int)hdspm->period_bytes), in snd_hdspm_proc_read_madi()
4899 (2 * (int)hdspm->period_bytes), in snd_hdspm_proc_read_madi()
4900 (long) hdspm_hw_pointer(hdspm) * 4); in snd_hdspm_proc_read_madi()
4904 hdspm_read(hdspm, HDSPM_midiStatusOut0) & 0xFF, in snd_hdspm_proc_read_madi()
4905 hdspm_read(hdspm, HDSPM_midiStatusOut1) & 0xFF, in snd_hdspm_proc_read_madi()
4906 hdspm_read(hdspm, HDSPM_midiStatusIn0) & 0xFF, in snd_hdspm_proc_read_madi()
4907 hdspm_read(hdspm, HDSPM_midiStatusIn1) & 0xFF); in snd_hdspm_proc_read_madi()
4910 hdspm_read(hdspm, HDSPM_midiStatusIn2) & 0xFF, in snd_hdspm_proc_read_madi()
4911 hdspm_read(hdspm, HDSPM_midiStatusOut2) & 0xFF); in snd_hdspm_proc_read_madi()
4915 hdspm->control_register, hdspm->control2_register, in snd_hdspm_proc_read_madi()
4921 x = hdspm_get_latency(hdspm); 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()
4944 switch (hdspm_pref_sync_ref(hdspm)) { in snd_hdspm_proc_read_madi()
4965 hdspm->system_sample_rate); in snd_hdspm_proc_read_madi()
4979 switch (hdspm_autosync_ref(hdspm)) { in snd_hdspm_proc_read_madi()
5001 autosync_ref, hdspm_external_sample_rate(hdspm), in snd_hdspm_proc_read_madi()
5020 struct hdspm *hdspm = entry->private_data; in snd_hdspm_proc_read_aes32() local
5029 status = hdspm_read(hdspm, HDSPM_statusRegister); in snd_hdspm_proc_read_aes32()
5030 status2 = hdspm_read(hdspm, HDSPM_statusRegister2); in snd_hdspm_proc_read_aes32()
5031 timecode = hdspm_read(hdspm, HDSPM_timecodeRegister); 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()
5047 hdspm->irq_count); in snd_hdspm_proc_read_aes32()
5054 (2 * (int)hdspm->period_bytes), in snd_hdspm_proc_read_aes32()
5056 (2 * (int)hdspm->period_bytes), in snd_hdspm_proc_read_aes32()
5057 (long) hdspm_hw_pointer(hdspm) * 4); in snd_hdspm_proc_read_aes32()
5061 hdspm_read(hdspm, HDSPM_midiStatusOut0) & 0xFF, in snd_hdspm_proc_read_aes32()
5062 hdspm_read(hdspm, HDSPM_midiStatusOut1) & 0xFF, in snd_hdspm_proc_read_aes32()
5063 hdspm_read(hdspm, HDSPM_midiStatusIn0) & 0xFF, in snd_hdspm_proc_read_aes32()
5064 hdspm_read(hdspm, HDSPM_midiStatusIn1) & 0xFF); in snd_hdspm_proc_read_aes32()
5067 hdspm_read(hdspm, HDSPM_midiStatusIn2) & 0xFF, in snd_hdspm_proc_read_aes32()
5068 hdspm_read(hdspm, HDSPM_midiStatusOut2) & 0xFF); in snd_hdspm_proc_read_aes32()
5072 hdspm->control_register, hdspm->control2_register, in snd_hdspm_proc_read_aes32()
5077 x = hdspm_get_latency(hdspm); 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()
5097 pref_syncref = hdspm_pref_sync_ref(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()
5133 switch (hdspm_autosync_ref(hdspm)) { in snd_hdspm_proc_read_aes32()
5173 struct hdspm *hdspm = entry->private_data; in snd_hdspm_proc_read_raydat() local
5177 status1 = hdspm_read(hdspm, HDSPM_RD_STATUS_1); /* s1 */ in snd_hdspm_proc_read_raydat()
5178 status2 = hdspm_read(hdspm, HDSPM_RD_STATUS_2); /* freq */ in snd_hdspm_proc_read_raydat()
5179 status3 = hdspm_read(hdspm, HDSPM_RD_STATUS_3); /* s2 */ in snd_hdspm_proc_read_raydat()
5189 (hdspm_system_clock_mode(hdspm) == 0) ? "master" : "slave"); in snd_hdspm_proc_read_raydat()
5191 hdspm_get_system_sample_rate(hdspm)); in snd_hdspm_proc_read_raydat()
5231 struct hdspm *hdspm = entry->private_data; in snd_hdspm_proc_read_debug() local
5238 snd_iprintf(buffer, "%08X ", hdspm_read(hdspm, i + j)); in snd_hdspm_proc_read_debug()
5248 struct hdspm *hdspm = entry->private_data; in snd_hdspm_proc_ports_in() local
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() local
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()
5272 static void snd_hdspm_proc_init(struct hdspm *hdspm) in snd_hdspm_proc_init() argument
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()
5310 static int snd_hdspm_set_defaults(struct hdspm * hdspm) in snd_hdspm_set_defaults() argument
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()
5358 hdspm_compute_period_size(hdspm); in snd_hdspm_set_defaults()
5362 all_in_all_mixer(hdspm, 0 * UNITY_GAIN); in snd_hdspm_set_defaults()
5364 if (hdspm_is_raydat_or_aio(hdspm)) in snd_hdspm_set_defaults()
5365 hdspm_write(hdspm, HDSPM_WR_SETTINGS, hdspm->settings_register); in snd_hdspm_set_defaults()
5368 hdspm_set_rate(hdspm, 48000, 1); in snd_hdspm_set_defaults()
5380 struct hdspm *hdspm = (struct hdspm *) dev_id; in snd_hdspm_interrupt() local
5385 status = hdspm_read(hdspm, HDSPM_statusRegister); in snd_hdspm_interrupt()
5411 hdspm_write(hdspm, HDSPM_interruptConfirmation, 0); 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()
5425 while (i < hdspm->midiPorts) { in snd_hdspm_interrupt()
5426 if ((hdspm_read(hdspm, 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()
5433 hdspm_write(hdspm, HDSPM_controlRegister, 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()
5457 struct hdspm *hdspm = snd_pcm_substream_chip(substream); in snd_hdspm_hw_pointer() local
5458 return hdspm_hw_pointer(hdspm); in snd_hdspm_hw_pointer()
5465 struct hdspm *hdspm = snd_pcm_substream_chip(substream); in snd_hdspm_reset() local
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()
5494 struct hdspm *hdspm = snd_pcm_substream_chip(substream); in snd_hdspm_hw_params() local
5500 spin_lock_irq(&hdspm->lock); 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()
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()
5533 spin_unlock_irq(&hdspm->lock); in snd_hdspm_hw_params()
5537 spin_lock_irq(&hdspm->lock); in snd_hdspm_hw_params()
5538 err = hdspm_set_rate(hdspm, params_rate(params), 0); 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()
5548 err = hdspm_set_interrupt_interval(hdspm, 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()
5576 int c = hdspm->channel_map_out[i]; in snd_hdspm_hw_params()
5580 hdspm_set_channel_dma_addr(hdspm, substream, in snd_hdspm_hw_params()
5583 snd_hdspm_enable_out(hdspm, c, 1); in snd_hdspm_hw_params()
5586 hdspm->playback_buffer = 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()
5597 hdspm_set_channel_dma_addr(hdspm, substream, in snd_hdspm_hw_params()
5600 snd_hdspm_enable_in(hdspm, c, 1); in snd_hdspm_hw_params()
5603 hdspm->capture_buffer = 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()
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()
5659 struct hdspm *hdspm = snd_pcm_substream_chip(substream); in snd_hdspm_hw_free() local
5665 snd_hdspm_enable_out(hdspm, i, 0); in snd_hdspm_hw_free()
5667 hdspm->playback_buffer = NULL; in snd_hdspm_hw_free()
5670 snd_hdspm_enable_in(hdspm, i, 0); in snd_hdspm_hw_free()
5672 hdspm->capture_buffer = NULL; in snd_hdspm_hw_free()
5684 struct hdspm *hdspm = snd_pcm_substream_chip(substream); in snd_hdspm_channel_info() local
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()
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()
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()
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()
5721 info->offset = hdspm->channel_map_in[channel] * in snd_hdspm_channel_info()
5752 struct hdspm *hdspm = snd_pcm_substream_chip(substream); in snd_hdspm_trigger() local
5756 spin_lock(&hdspm->lock); in snd_hdspm_trigger()
5757 running = hdspm->running; in snd_hdspm_trigger()
5767 spin_unlock(&hdspm->lock); in snd_hdspm_trigger()
5771 other = hdspm->capture_substream; in snd_hdspm_trigger()
5773 other = hdspm->playback_substream; in snd_hdspm_trigger()
5791 hdspm_silence_playback(hdspm); in snd_hdspm_trigger()
5795 hdspm_silence_playback(hdspm); in snd_hdspm_trigger()
5799 hdspm_silence_playback(hdspm); in snd_hdspm_trigger()
5803 if (!hdspm->running && running) in snd_hdspm_trigger()
5804 hdspm_start_audio(hdspm); in snd_hdspm_trigger()
5805 else if (hdspm->running && !running) in snd_hdspm_trigger()
5806 hdspm_stop_audio(hdspm); 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() local
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()
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()
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() local
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()
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()
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() local
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() local
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() local
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() local
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()
6049 struct hdspm *hdspm = snd_pcm_substream_chip(substream); in snd_hdspm_open() local
6053 spin_lock_irq(&hdspm->lock); in snd_hdspm_open()
6059 if (!hdspm->capture_substream) in snd_hdspm_open()
6060 hdspm_stop_audio(hdspm); 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()
6066 hdspm_stop_audio(hdspm); 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()
6106 snd_hdspm_hw_rule_rate_in_channels), hdspm, in snd_hdspm_open()
6112 snd_hdspm_hw_rule_in_channels), hdspm, in snd_hdspm_open()
6117 snd_hdspm_hw_rule_in_channels_rate), hdspm, in snd_hdspm_open()
6125 struct hdspm *hdspm = snd_pcm_substream_chip(substream); in snd_hdspm_release() local
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()
6159 struct hdspm *hdspm = hw->private_data; in snd_hdspm_hwdep_ioctl() local
6173 levels = &hdspm->peak_rms; in snd_hdspm_hwdep_ioctl()
6176 readl(hdspm->iobase + in snd_hdspm_hwdep_ioctl()
6179 readl(hdspm->iobase + in snd_hdspm_hwdep_ioctl()
6182 readl(hdspm->iobase + in snd_hdspm_hwdep_ioctl()
6186 ((uint64_t) readl(hdspm->iobase + in snd_hdspm_hwdep_ioctl()
6188 (uint64_t) readl(hdspm->iobase + in snd_hdspm_hwdep_ioctl()
6191 ((uint64_t)readl(hdspm->iobase + in snd_hdspm_hwdep_ioctl()
6193 (uint64_t)readl(hdspm->iobase + in snd_hdspm_hwdep_ioctl()
6196 ((uint64_t)readl(hdspm->iobase + in snd_hdspm_hwdep_ioctl()
6198 (uint64_t)readl(hdspm->iobase + in snd_hdspm_hwdep_ioctl()
6202 if (hdspm->system_sample_rate > 96000) { in snd_hdspm_hwdep_ioctl()
6204 } else if (hdspm->system_sample_rate > 48000) { in snd_hdspm_hwdep_ioctl()
6209 levels->status2 = hdspm_read(hdspm, HDSPM_statusRegister2); in snd_hdspm_hwdep_ioctl()
6221 ltc.ltc = hdspm_read(hdspm, HDSPM_RD_TCO); in snd_hdspm_hwdep_ioctl()
6222 i = hdspm_read(hdspm, HDSPM_RD_TCO + 4); in snd_hdspm_hwdep_ioctl()
6268 spin_lock_irq(&hdspm->lock); in snd_hdspm_hwdep_ioctl()
6269 info.pref_sync_ref = hdspm_pref_sync_ref(hdspm); in snd_hdspm_hwdep_ioctl()
6270 info.wordclock_sync_check = hdspm_wc_sync_check(hdspm); in snd_hdspm_hwdep_ioctl()
6272 info.system_sample_rate = hdspm->system_sample_rate; in snd_hdspm_hwdep_ioctl()
6274 hdspm_external_sample_rate(hdspm); in snd_hdspm_hwdep_ioctl()
6275 info.system_clock_mode = hdspm_system_clock_mode(hdspm); in snd_hdspm_hwdep_ioctl()
6276 info.clock_source = hdspm_clock_source(hdspm); in snd_hdspm_hwdep_ioctl()
6277 info.autosync_ref = hdspm_autosync_ref(hdspm); in snd_hdspm_hwdep_ioctl()
6278 info.line_out = hdspm_toggle_setting(hdspm, HDSPM_LineOut); in snd_hdspm_hwdep_ioctl()
6280 spin_unlock_irq(&hdspm->lock); in snd_hdspm_hwdep_ioctl()
6288 status.card_type = hdspm->io_type; in snd_hdspm_hwdep_ioctl()
6290 status.autosync_source = hdspm_autosync_ref(hdspm); in snd_hdspm_hwdep_ioctl()
6293 status.master_period = hdspm_read(hdspm, HDSPM_RD_PLL_FREQ); in snd_hdspm_hwdep_ioctl()
6295 switch (hdspm->io_type) { in snd_hdspm_hwdep_ioctl()
6299 hdspm_wc_sync_check(hdspm); in snd_hdspm_hwdep_ioctl()
6301 hdspm_madi_sync_check(hdspm); in snd_hdspm_hwdep_ioctl()
6303 hdspm_tco_sync_check(hdspm); in snd_hdspm_hwdep_ioctl()
6305 hdspm_sync_in_sync_check(hdspm); in snd_hdspm_hwdep_ioctl()
6308 hdspm_read(hdspm, HDSPM_statusRegister); in snd_hdspm_hwdep_ioctl()
6330 hdspm_version.card_type = hdspm->io_type; in snd_hdspm_hwdep_ioctl()
6331 strscpy(hdspm_version.cardname, hdspm->card_name, in snd_hdspm_hwdep_ioctl()
6333 hdspm_version.serial = hdspm->serial; in snd_hdspm_hwdep_ioctl()
6334 hdspm_version.firmware_rev = hdspm->firmware_rev; in snd_hdspm_hwdep_ioctl()
6336 if (hdspm->tco) in snd_hdspm_hwdep_ioctl()
6347 if (copy_to_user((void __user *)mixer.mixer, hdspm->mixer, in snd_hdspm_hwdep_ioctl()
6370 struct hdspm *hdspm) in snd_hdspm_create_hwdep() argument
6379 hdspm->hwdep = hw; in snd_hdspm_create_hwdep()
6380 hw->private_data = hdspm; in snd_hdspm_create_hwdep()
6395 static int snd_hdspm_preallocate_memory(struct hdspm *hdspm) in snd_hdspm_preallocate_memory() argument
6400 pcm = hdspm->pcm; in snd_hdspm_preallocate_memory()
6405 &hdspm->pci->dev, in snd_hdspm_preallocate_memory()
6407 dev_dbg(hdspm->card->dev, " Preallocated %zd Bytes\n", wanted); in snd_hdspm_preallocate_memory()
6413 static void hdspm_set_channel_dma_addr(struct hdspm *hdspm, in hdspm_set_channel_dma_addr() argument
6420 hdspm_write(hdspm, reg + 4 * i, in hdspm_set_channel_dma_addr()
6427 struct hdspm *hdspm) in snd_hdspm_create_pcm() argument
6432 err = snd_pcm_new(card, hdspm->card_name, 0, 1, 1, &pcm); in snd_hdspm_create_pcm()
6436 hdspm->pcm = pcm; in snd_hdspm_create_pcm()
6437 pcm->private_data = hdspm; in snd_hdspm_create_pcm()
6438 strcpy(pcm->name, hdspm->card_name); in snd_hdspm_create_pcm()
6447 err = snd_hdspm_preallocate_memory(hdspm); in snd_hdspm_create_pcm()
6454 static inline void snd_hdspm_initialize_midi_flush(struct hdspm * hdspm) in snd_hdspm_initialize_midi_flush() argument
6458 for (i = 0; i < hdspm->midiPorts; i++) in snd_hdspm_initialize_midi_flush()
6459 snd_hdspm_flush_midi_input(hdspm, i); in snd_hdspm_initialize_midi_flush()
6463 struct hdspm *hdspm) in snd_hdspm_create_alsa_devices() argument
6468 err = snd_hdspm_create_pcm(card, hdspm); in snd_hdspm_create_alsa_devices()
6473 while (i < hdspm->midiPorts) { in snd_hdspm_create_alsa_devices()
6474 err = snd_hdspm_create_midi(card, hdspm, i); in snd_hdspm_create_alsa_devices()
6481 err = snd_hdspm_create_controls(card, hdspm); in snd_hdspm_create_alsa_devices()
6485 err = snd_hdspm_create_hwdep(card, hdspm); in snd_hdspm_create_alsa_devices()
6490 snd_hdspm_proc_init(hdspm); in snd_hdspm_create_alsa_devices()
6492 hdspm->system_sample_rate = -1; in snd_hdspm_create_alsa_devices()
6493 hdspm->last_external_sample_rate = -1; in snd_hdspm_create_alsa_devices()
6494 hdspm->last_internal_sample_rate = -1; in snd_hdspm_create_alsa_devices()
6495 hdspm->playback_pid = -1; in snd_hdspm_create_alsa_devices()
6496 hdspm->capture_pid = -1; in snd_hdspm_create_alsa_devices()
6497 hdspm->capture_substream = NULL; in snd_hdspm_create_alsa_devices()
6498 hdspm->playback_substream = NULL; in snd_hdspm_create_alsa_devices()
6501 err = snd_hdspm_set_defaults(hdspm); in snd_hdspm_create_alsa_devices()
6506 hdspm_update_simple_mixer_controls(hdspm); in snd_hdspm_create_alsa_devices()
6522 struct hdspm *hdspm) in snd_hdspm_create() argument
6525 struct pci_dev *pci = hdspm->pci; in snd_hdspm_create()
6529 hdspm->irq = -1; in snd_hdspm_create()
6530 hdspm->card = card; in snd_hdspm_create()
6532 spin_lock_init(&hdspm->lock); in snd_hdspm_create()
6533 INIT_WORK(&hdspm->midi_work, hdspm_midi_work); in snd_hdspm_create()
6535 pci_read_config_word(hdspm->pci, in snd_hdspm_create()
6536 PCI_CLASS_REVISION, &hdspm->firmware_rev); in snd_hdspm_create()
6541 switch (hdspm->firmware_rev) { in snd_hdspm_create()
6543 hdspm->io_type = RayDAT; in snd_hdspm_create()
6544 hdspm->card_name = "RME RayDAT"; in snd_hdspm_create()
6545 hdspm->midiPorts = 2; in snd_hdspm_create()
6548 hdspm->io_type = AIO; in snd_hdspm_create()
6549 hdspm->card_name = "RME AIO"; in snd_hdspm_create()
6550 hdspm->midiPorts = 1; in snd_hdspm_create()
6553 hdspm->io_type = MADIface; in snd_hdspm_create()
6554 hdspm->card_name = "RME MADIface"; in snd_hdspm_create()
6555 hdspm->midiPorts = 1; in snd_hdspm_create()
6558 if ((hdspm->firmware_rev == 0xf0) || in snd_hdspm_create()
6559 ((hdspm->firmware_rev >= 0xe6) && in snd_hdspm_create()
6560 (hdspm->firmware_rev <= 0xea))) { in snd_hdspm_create()
6561 hdspm->io_type = AES32; in snd_hdspm_create()
6562 hdspm->card_name = "RME AES32"; in snd_hdspm_create()
6563 hdspm->midiPorts = 2; in snd_hdspm_create()
6564 } else if ((hdspm->firmware_rev == 0xd2) || in snd_hdspm_create()
6565 ((hdspm->firmware_rev >= 0xc8) && in snd_hdspm_create()
6566 (hdspm->firmware_rev <= 0xcf))) { in snd_hdspm_create()
6567 hdspm->io_type = MADI; in snd_hdspm_create()
6568 hdspm->card_name = "RME MADI"; in snd_hdspm_create()
6569 hdspm->midiPorts = 3; in snd_hdspm_create()
6573 hdspm->firmware_rev); in snd_hdspm_create()
6582 pci_set_master(hdspm->pci); in snd_hdspm_create()
6588 hdspm->port = pci_resource_start(pci, 0); in snd_hdspm_create()
6590 hdspm->iobase = pcim_iomap_table(pci)[0]; in snd_hdspm_create()
6592 (unsigned long)hdspm->iobase, hdspm->port, in snd_hdspm_create()
6593 hdspm->port + io_extent - 1); in snd_hdspm_create()
6596 IRQF_SHARED, KBUILD_MODNAME, hdspm)) { in snd_hdspm_create()
6603 hdspm->irq = pci->irq; in snd_hdspm_create()
6604 card->sync_irq = hdspm->irq; in snd_hdspm_create()
6607 sizeof(*hdspm->mixer)); in snd_hdspm_create()
6608 hdspm->mixer = devm_kzalloc(&pci->dev, sizeof(*hdspm->mixer), GFP_KERNEL); in snd_hdspm_create()
6609 if (!hdspm->mixer) in snd_hdspm_create()
6612 hdspm->port_names_in = NULL; in snd_hdspm_create()
6613 hdspm->port_names_out = NULL; in snd_hdspm_create()
6615 switch (hdspm->io_type) { in snd_hdspm_create()
6617 hdspm->ss_in_channels = hdspm->ss_out_channels = AES32_CHANNELS; in snd_hdspm_create()
6618 hdspm->ds_in_channels = hdspm->ds_out_channels = AES32_CHANNELS; in snd_hdspm_create()
6619 hdspm->qs_in_channels = hdspm->qs_out_channels = AES32_CHANNELS; in snd_hdspm_create()
6621 hdspm->channel_map_in_ss = hdspm->channel_map_out_ss = in snd_hdspm_create()
6623 hdspm->channel_map_in_ds = hdspm->channel_map_out_ds = in snd_hdspm_create()
6625 hdspm->channel_map_in_qs = hdspm->channel_map_out_qs = in snd_hdspm_create()
6627 hdspm->port_names_in_ss = hdspm->port_names_out_ss = in snd_hdspm_create()
6629 hdspm->port_names_in_ds = hdspm->port_names_out_ds = in snd_hdspm_create()
6631 hdspm->port_names_in_qs = hdspm->port_names_out_qs = in snd_hdspm_create()
6634 hdspm->max_channels_out = hdspm->max_channels_in = in snd_hdspm_create()
6636 hdspm->port_names_in = hdspm->port_names_out = in snd_hdspm_create()
6638 hdspm->channel_map_in = hdspm->channel_map_out = in snd_hdspm_create()
6645 hdspm->ss_in_channels = hdspm->ss_out_channels = in snd_hdspm_create()
6647 hdspm->ds_in_channels = hdspm->ds_out_channels = in snd_hdspm_create()
6649 hdspm->qs_in_channels = hdspm->qs_out_channels = in snd_hdspm_create()
6652 hdspm->channel_map_in_ss = hdspm->channel_map_out_ss = in snd_hdspm_create()
6654 hdspm->channel_map_in_ds = hdspm->channel_map_out_ds = in snd_hdspm_create()
6656 hdspm->channel_map_in_qs = hdspm->channel_map_out_qs = in snd_hdspm_create()
6659 hdspm->port_names_in_ss = hdspm->port_names_out_ss = in snd_hdspm_create()
6661 hdspm->port_names_in_ds = hdspm->port_names_out_ds = in snd_hdspm_create()
6663 hdspm->port_names_in_qs = hdspm->port_names_out_qs = in snd_hdspm_create()
6668 hdspm->ss_in_channels = AIO_IN_SS_CHANNELS; in snd_hdspm_create()
6669 hdspm->ds_in_channels = AIO_IN_DS_CHANNELS; in snd_hdspm_create()
6670 hdspm->qs_in_channels = AIO_IN_QS_CHANNELS; in snd_hdspm_create()
6671 hdspm->ss_out_channels = AIO_OUT_SS_CHANNELS; in snd_hdspm_create()
6672 hdspm->ds_out_channels = AIO_OUT_DS_CHANNELS; in snd_hdspm_create()
6673 hdspm->qs_out_channels = AIO_OUT_QS_CHANNELS; in snd_hdspm_create()
6675 if (0 == (hdspm_read(hdspm, HDSPM_statusRegister2) & HDSPM_s2_AEBI_D)) { in snd_hdspm_create()
6677 hdspm->ss_in_channels += 4; in snd_hdspm_create()
6678 hdspm->ds_in_channels += 4; in snd_hdspm_create()
6679 hdspm->qs_in_channels += 4; in snd_hdspm_create()
6682 if (0 == (hdspm_read(hdspm, HDSPM_statusRegister2) & HDSPM_s2_AEBO_D)) { in snd_hdspm_create()
6684 hdspm->ss_out_channels += 4; in snd_hdspm_create()
6685 hdspm->ds_out_channels += 4; in snd_hdspm_create()
6686 hdspm->qs_out_channels += 4; in snd_hdspm_create()
6689 hdspm->channel_map_out_ss = channel_map_aio_out_ss; in snd_hdspm_create()
6690 hdspm->channel_map_out_ds = channel_map_aio_out_ds; in snd_hdspm_create()
6691 hdspm->channel_map_out_qs = channel_map_aio_out_qs; in snd_hdspm_create()
6693 hdspm->channel_map_in_ss = channel_map_aio_in_ss; in snd_hdspm_create()
6694 hdspm->channel_map_in_ds = channel_map_aio_in_ds; in snd_hdspm_create()
6695 hdspm->channel_map_in_qs = channel_map_aio_in_qs; in snd_hdspm_create()
6697 hdspm->port_names_in_ss = texts_ports_aio_in_ss; in snd_hdspm_create()
6698 hdspm->port_names_out_ss = texts_ports_aio_out_ss; in snd_hdspm_create()
6699 hdspm->port_names_in_ds = texts_ports_aio_in_ds; in snd_hdspm_create()
6700 hdspm->port_names_out_ds = texts_ports_aio_out_ds; in snd_hdspm_create()
6701 hdspm->port_names_in_qs = texts_ports_aio_in_qs; in snd_hdspm_create()
6702 hdspm->port_names_out_qs = texts_ports_aio_out_qs; in snd_hdspm_create()
6707 hdspm->ss_in_channels = hdspm->ss_out_channels = in snd_hdspm_create()
6709 hdspm->ds_in_channels = hdspm->ds_out_channels = in snd_hdspm_create()
6711 hdspm->qs_in_channels = hdspm->qs_out_channels = in snd_hdspm_create()
6714 hdspm->max_channels_in = RAYDAT_SS_CHANNELS; in snd_hdspm_create()
6715 hdspm->max_channels_out = RAYDAT_SS_CHANNELS; in snd_hdspm_create()
6717 hdspm->channel_map_in_ss = hdspm->channel_map_out_ss = in snd_hdspm_create()
6719 hdspm->channel_map_in_ds = hdspm->channel_map_out_ds = in snd_hdspm_create()
6721 hdspm->channel_map_in_qs = hdspm->channel_map_out_qs = in snd_hdspm_create()
6723 hdspm->channel_map_in = hdspm->channel_map_out = in snd_hdspm_create()
6726 hdspm->port_names_in_ss = hdspm->port_names_out_ss = in snd_hdspm_create()
6728 hdspm->port_names_in_ds = hdspm->port_names_out_ds = in snd_hdspm_create()
6730 hdspm->port_names_in_qs = hdspm->port_names_out_qs = in snd_hdspm_create()
6739 switch (hdspm->io_type) { in snd_hdspm_create()
6742 if (hdspm_read(hdspm, HDSPM_statusRegister2) & in snd_hdspm_create()
6744 hdspm->midiPorts++; in snd_hdspm_create()
6745 hdspm->tco = kzalloc(sizeof(*hdspm->tco), GFP_KERNEL); in snd_hdspm_create()
6746 if (hdspm->tco) in snd_hdspm_create()
6747 hdspm_tco_write(hdspm); in snd_hdspm_create()
6751 hdspm->tco = NULL; in snd_hdspm_create()
6757 if (hdspm_read(hdspm, HDSPM_statusRegister) & HDSPM_tco_detect) { in snd_hdspm_create()
6758 hdspm->midiPorts++; in snd_hdspm_create()
6759 hdspm->tco = kzalloc(sizeof(*hdspm->tco), GFP_KERNEL); in snd_hdspm_create()
6760 if (hdspm->tco) in snd_hdspm_create()
6761 hdspm_tco_write(hdspm); in snd_hdspm_create()
6765 hdspm->tco = NULL; in snd_hdspm_create()
6770 hdspm->tco = NULL; in snd_hdspm_create()
6774 switch (hdspm->io_type) { in snd_hdspm_create()
6776 if (hdspm->tco) { in snd_hdspm_create()
6777 hdspm->texts_autosync = texts_autosync_aes_tco; in snd_hdspm_create()
6778 hdspm->texts_autosync_items = in snd_hdspm_create()
6781 hdspm->texts_autosync = texts_autosync_aes; in snd_hdspm_create()
6782 hdspm->texts_autosync_items = in snd_hdspm_create()
6788 if (hdspm->tco) { in snd_hdspm_create()
6789 hdspm->texts_autosync = texts_autosync_madi_tco; in snd_hdspm_create()
6790 hdspm->texts_autosync_items = 4; in snd_hdspm_create()
6792 hdspm->texts_autosync = texts_autosync_madi; in snd_hdspm_create()
6793 hdspm->texts_autosync_items = 3; in snd_hdspm_create()
6802 if (hdspm->tco) { in snd_hdspm_create()
6803 hdspm->texts_autosync = texts_autosync_raydat_tco; in snd_hdspm_create()
6804 hdspm->texts_autosync_items = 9; in snd_hdspm_create()
6806 hdspm->texts_autosync = texts_autosync_raydat; in snd_hdspm_create()
6807 hdspm->texts_autosync_items = 8; in snd_hdspm_create()
6812 if (hdspm->tco) { in snd_hdspm_create()
6813 hdspm->texts_autosync = texts_autosync_aio_tco; in snd_hdspm_create()
6814 hdspm->texts_autosync_items = 6; in snd_hdspm_create()
6816 hdspm->texts_autosync = texts_autosync_aio; in snd_hdspm_create()
6817 hdspm->texts_autosync_items = 5; in snd_hdspm_create()
6823 if (hdspm->io_type != MADIface) { in snd_hdspm_create()
6824 hdspm->serial = (hdspm_read(hdspm, in snd_hdspm_create()
6835 if (!id[hdspm->dev] && hdspm->serial != 0xFFFFFF) { in snd_hdspm_create()
6837 "HDSPMx%06x", hdspm->serial); in snd_hdspm_create()
6843 err = snd_hdspm_create_alsa_devices(card, hdspm); in snd_hdspm_create()
6847 snd_hdspm_initialize_midi_flush(hdspm); in snd_hdspm_create()
6855 struct hdspm *hdspm = card->private_data; in snd_hdspm_card_free() local
6857 if (hdspm->port) { in snd_hdspm_card_free()
6858 cancel_work_sync(&hdspm->midi_work); in snd_hdspm_card_free()
6861 hdspm->control_register &= in snd_hdspm_card_free()
6865 hdspm_write(hdspm, HDSPM_controlRegister, in snd_hdspm_card_free()
6866 hdspm->control_register); in snd_hdspm_card_free()
6875 struct hdspm *hdspm; in snd_hdspm_probe() local
6887 THIS_MODULE, sizeof(*hdspm), &card); in snd_hdspm_probe()
6891 hdspm = card->private_data; in snd_hdspm_probe()
6893 hdspm->dev = dev; in snd_hdspm_probe()
6894 hdspm->pci = pci; in snd_hdspm_probe()
6896 err = snd_hdspm_create(card, hdspm); in snd_hdspm_probe()
6900 if (hdspm->io_type != MADIface) { in snd_hdspm_probe()
6902 hdspm->card_name, hdspm->serial); in snd_hdspm_probe()
6905 hdspm->card_name, hdspm->serial, in snd_hdspm_probe()
6906 hdspm->port, hdspm->irq); in snd_hdspm_probe()
6909 hdspm->card_name); in snd_hdspm_probe()
6912 hdspm->card_name, hdspm->port, hdspm->irq); in snd_hdspm_probe()