Lines Matching refs:hdspm

967 	struct hdspm *hdspm;  member
993 struct hdspm { struct
1097 struct hdspm *hdspm); argument
1099 struct hdspm *hdspm);
1101 static inline void snd_hdspm_initialize_midi_flush(struct hdspm *hdspm);
1102 static inline int hdspm_get_pll_freq(struct hdspm *hdspm);
1103 static int hdspm_update_simple_mixer_controls(struct hdspm *hdspm);
1104 static int hdspm_autosync_ref(struct hdspm *hdspm);
1105 static int hdspm_set_toggle_setting(struct hdspm *hdspm, u32 regmask, int out);
1106 static int snd_hdspm_set_defaults(struct hdspm *hdspm);
1107 static int hdspm_system_clock_mode(struct hdspm *hdspm);
1108 static void hdspm_set_sgbuf(struct hdspm *hdspm,
1112 static int hdspm_aes_sync_check(struct hdspm *hdspm, int idx);
1113 static int hdspm_wc_sync_check(struct hdspm *hdspm);
1114 static int hdspm_tco_sync_check(struct hdspm *hdspm);
1115 static int hdspm_sync_in_sync_check(struct hdspm *hdspm);
1117 static int hdspm_get_aes_sample_rate(struct hdspm *hdspm, int index);
1118 static int hdspm_get_tco_sample_rate(struct hdspm *hdspm);
1119 static int hdspm_get_wc_sample_rate(struct hdspm *hdspm);
1133 static bool hdspm_is_raydat_or_aio(struct hdspm *hdspm) in hdspm_is_raydat_or_aio() argument
1135 return ((AIO == hdspm->io_type) || (RayDAT == hdspm->io_type)); in hdspm_is_raydat_or_aio()
1142 static inline void hdspm_write(struct hdspm * hdspm, unsigned int reg, in hdspm_write() argument
1145 writel(val, hdspm->iobase + reg); in hdspm_write()
1148 static inline unsigned int hdspm_read(struct hdspm * hdspm, unsigned int reg) in hdspm_read() argument
1150 return readl(hdspm->iobase + reg); in hdspm_read()
1157 static inline int hdspm_read_in_gain(struct hdspm * hdspm, unsigned int chan, in hdspm_read_in_gain() argument
1163 return hdspm->mixer->ch[chan].in[in]; in hdspm_read_in_gain()
1166 static inline int hdspm_read_pb_gain(struct hdspm * hdspm, unsigned int chan, in hdspm_read_pb_gain() argument
1171 return hdspm->mixer->ch[chan].pb[pb]; in hdspm_read_pb_gain()
1174 static int hdspm_write_in_gain(struct hdspm *hdspm, unsigned int chan, in hdspm_write_in_gain() argument
1180 hdspm_write(hdspm, in hdspm_write_in_gain()
1183 (hdspm->mixer->ch[chan].in[in] = data & 0xFFFF)); in hdspm_write_in_gain()
1187 static int hdspm_write_pb_gain(struct hdspm *hdspm, unsigned int chan, in hdspm_write_pb_gain() argument
1193 hdspm_write(hdspm, in hdspm_write_pb_gain()
1196 (hdspm->mixer->ch[chan].pb[pb] = data & 0xFFFF)); in hdspm_write_pb_gain()
1202 static inline void snd_hdspm_enable_in(struct hdspm * hdspm, int i, int v) in snd_hdspm_enable_in() argument
1204 hdspm_write(hdspm, HDSPM_inputEnableBase + (4 * i), v); in snd_hdspm_enable_in()
1207 static inline void snd_hdspm_enable_out(struct hdspm * hdspm, int i, int v) in snd_hdspm_enable_out() argument
1209 hdspm_write(hdspm, HDSPM_outputEnableBase + (4 * i), v); in snd_hdspm_enable_out()
1213 static int snd_hdspm_use_is_exclusive(struct hdspm *hdspm) in snd_hdspm_use_is_exclusive() argument
1218 spin_lock_irqsave(&hdspm->lock, flags); in snd_hdspm_use_is_exclusive()
1219 if ((hdspm->playback_pid != hdspm->capture_pid) && in snd_hdspm_use_is_exclusive()
1220 (hdspm->playback_pid >= 0) && (hdspm->capture_pid >= 0)) { in snd_hdspm_use_is_exclusive()
1223 spin_unlock_irqrestore(&hdspm->lock, flags); in snd_hdspm_use_is_exclusive()
1246 static int hdspm_rate_multiplier(struct hdspm *hdspm, int rate) in hdspm_rate_multiplier() argument
1249 if (hdspm->control_register & HDSPM_QuadSpeed) in hdspm_rate_multiplier()
1251 else if (hdspm->control_register & in hdspm_rate_multiplier()
1259 static int hdspm_external_sample_rate(struct hdspm *hdspm) in hdspm_external_sample_rate() argument
1264 switch (hdspm->io_type) { in hdspm_external_sample_rate()
1266 status2 = hdspm_read(hdspm, HDSPM_statusRegister2); in hdspm_external_sample_rate()
1267 status = hdspm_read(hdspm, HDSPM_statusRegister); in hdspm_external_sample_rate()
1269 syncref = hdspm_autosync_ref(hdspm); in hdspm_external_sample_rate()
1273 if (hdspm_wc_sync_check(hdspm)) in hdspm_external_sample_rate()
1274 return HDSPM_bit2freq(hdspm_get_wc_sample_rate(hdspm)); in hdspm_external_sample_rate()
1286 if (hdspm_aes_sync_check(hdspm, syncref - HDSPM_AES32_AUTOSYNC_FROM_AES1)) in hdspm_external_sample_rate()
1287 return HDSPM_bit2freq(hdspm_get_aes_sample_rate(hdspm, in hdspm_external_sample_rate()
1294 if (hdspm_tco_sync_check(hdspm)) in hdspm_external_sample_rate()
1295 return HDSPM_bit2freq(hdspm_get_tco_sample_rate(hdspm)); in hdspm_external_sample_rate()
1303 status = hdspm_read(hdspm, HDSPM_statusRegister); in hdspm_external_sample_rate()
1337 status2 = hdspm_read(hdspm, HDSPM_statusRegister2); in hdspm_external_sample_rate()
1338 status = hdspm_read(hdspm, HDSPM_statusRegister); in hdspm_external_sample_rate()
1387 return hdspm_rate_multiplier(hdspm, rate); in hdspm_external_sample_rate()
1433 syncref = hdspm_autosync_ref(hdspm); in hdspm_external_sample_rate()
1437 hdspm_tco_sync_check(hdspm)); in hdspm_external_sample_rate()
1441 hdspm_sync_in_sync_check(hdspm)); in hdspm_external_sample_rate()
1446 hdspm_get_pll_freq(hdspm)); in hdspm_external_sample_rate()
1450 rate = hdspm_rate_multiplier(hdspm, rate); in hdspm_external_sample_rate()
1459 static int hdspm_get_latency(struct hdspm *hdspm) in hdspm_get_latency() argument
1463 n = hdspm_decode_latency(hdspm->control_register); in hdspm_get_latency()
1472 if ((7 == n) && (RayDAT == hdspm->io_type || AIO == hdspm->io_type)) in hdspm_get_latency()
1479 static inline void hdspm_compute_period_size(struct hdspm *hdspm) in hdspm_compute_period_size() argument
1481 hdspm->period_bytes = 4 * hdspm_get_latency(hdspm); in hdspm_compute_period_size()
1485 static snd_pcm_uframes_t hdspm_hw_pointer(struct hdspm *hdspm) in hdspm_hw_pointer() argument
1489 position = hdspm_read(hdspm, HDSPM_statusRegister); in hdspm_hw_pointer()
1491 switch (hdspm->io_type) { in hdspm_hw_pointer()
1499 (hdspm->period_bytes / 4) : 0; in hdspm_hw_pointer()
1506 static inline void hdspm_start_audio(struct hdspm * s) in hdspm_start_audio()
1512 static inline void hdspm_stop_audio(struct hdspm * s) in hdspm_stop_audio()
1519 static void hdspm_silence_playback(struct hdspm *hdspm) in hdspm_silence_playback() argument
1522 int n = hdspm->period_bytes; in hdspm_silence_playback()
1523 void *buf = hdspm->playback_buffer; in hdspm_silence_playback()
1534 static int hdspm_set_interrupt_interval(struct hdspm *s, unsigned int frames) in hdspm_set_interrupt_interval()
1573 static u64 hdspm_calc_dds_value(struct hdspm *hdspm, u64 period) in hdspm_calc_dds_value() argument
1580 switch (hdspm->io_type) { in hdspm_calc_dds_value()
1601 static void hdspm_set_dds_value(struct hdspm *hdspm, int rate) in hdspm_set_dds_value() argument
1613 switch (hdspm->io_type) { in hdspm_set_dds_value()
1633 hdspm_write(hdspm, HDSPM_freqReg, (u32)n); in hdspm_set_dds_value()
1637 static int hdspm_set_rate(struct hdspm * hdspm, int rate, int called_internally) in hdspm_set_rate() argument
1648 if (!(hdspm->control_register & HDSPM_ClockModeMaster)) { in hdspm_set_rate()
1657 dev_warn(hdspm->card->dev, in hdspm_set_rate()
1664 hdspm_external_sample_rate(hdspm); in hdspm_set_rate()
1666 if (hdspm_autosync_ref(hdspm) == in hdspm_set_rate()
1669 dev_warn(hdspm->card->dev, in hdspm_set_rate()
1675 dev_warn(hdspm->card->dev, in hdspm_set_rate()
1682 current_rate = hdspm->system_sample_rate; in hdspm_set_rate()
1741 && (hdspm->capture_pid >= 0 || hdspm->playback_pid >= 0)) { in hdspm_set_rate()
1742 dev_err(hdspm->card->dev, in hdspm_set_rate()
1746 hdspm->capture_pid, hdspm->playback_pid); in hdspm_set_rate()
1750 hdspm->control_register &= ~HDSPM_FrequencyMask; in hdspm_set_rate()
1751 hdspm->control_register |= rate_bits; in hdspm_set_rate()
1752 hdspm_write(hdspm, HDSPM_controlRegister, hdspm->control_register); in hdspm_set_rate()
1756 hdspm_set_dds_value(hdspm, rate); in hdspm_set_rate()
1758 if (AES32 == hdspm->io_type && rate != current_rate) in hdspm_set_rate()
1759 hdspm_write(hdspm, HDSPM_eeprom_wr, 0); in hdspm_set_rate()
1761 hdspm->system_sample_rate = rate; in hdspm_set_rate()
1764 hdspm->channel_map_in = hdspm->channel_map_in_ss; in hdspm_set_rate()
1765 hdspm->channel_map_out = hdspm->channel_map_out_ss; in hdspm_set_rate()
1766 hdspm->max_channels_in = hdspm->ss_in_channels; in hdspm_set_rate()
1767 hdspm->max_channels_out = hdspm->ss_out_channels; in hdspm_set_rate()
1768 hdspm->port_names_in = hdspm->port_names_in_ss; in hdspm_set_rate()
1769 hdspm->port_names_out = hdspm->port_names_out_ss; in hdspm_set_rate()
1771 hdspm->channel_map_in = hdspm->channel_map_in_ds; in hdspm_set_rate()
1772 hdspm->channel_map_out = hdspm->channel_map_out_ds; in hdspm_set_rate()
1773 hdspm->max_channels_in = hdspm->ds_in_channels; in hdspm_set_rate()
1774 hdspm->max_channels_out = hdspm->ds_out_channels; in hdspm_set_rate()
1775 hdspm->port_names_in = hdspm->port_names_in_ds; in hdspm_set_rate()
1776 hdspm->port_names_out = hdspm->port_names_out_ds; in hdspm_set_rate()
1778 hdspm->channel_map_in = hdspm->channel_map_in_qs; in hdspm_set_rate()
1779 hdspm->channel_map_out = hdspm->channel_map_out_qs; in hdspm_set_rate()
1780 hdspm->max_channels_in = hdspm->qs_in_channels; in hdspm_set_rate()
1781 hdspm->max_channels_out = hdspm->qs_out_channels; in hdspm_set_rate()
1782 hdspm->port_names_in = hdspm->port_names_in_qs; in hdspm_set_rate()
1783 hdspm->port_names_out = hdspm->port_names_out_qs; in hdspm_set_rate()
1793 static void all_in_all_mixer(struct hdspm * hdspm, int sgain) in all_in_all_mixer() argument
1807 hdspm_write_in_gain(hdspm, i, j, gain); in all_in_all_mixer()
1808 hdspm_write_pb_gain(hdspm, i, j, gain); in all_in_all_mixer()
1816 static inline unsigned char snd_hdspm_midi_read_byte (struct hdspm *hdspm, in snd_hdspm_midi_read_byte() argument
1820 return hdspm_read(hdspm, hdspm->midi[id].dataIn); in snd_hdspm_midi_read_byte()
1823 static inline void snd_hdspm_midi_write_byte (struct hdspm *hdspm, int id, in snd_hdspm_midi_write_byte() argument
1827 return hdspm_write(hdspm, hdspm->midi[id].dataOut, val); in snd_hdspm_midi_write_byte()
1830 static inline int snd_hdspm_midi_input_available (struct hdspm *hdspm, int id) in snd_hdspm_midi_input_available() argument
1832 return hdspm_read(hdspm, hdspm->midi[id].statusIn) & 0xFF; in snd_hdspm_midi_input_available()
1835 static inline int snd_hdspm_midi_output_possible (struct hdspm *hdspm, int id) in snd_hdspm_midi_output_possible() argument
1839 fifo_bytes_used = hdspm_read(hdspm, hdspm->midi[id].statusOut) & 0xFF; in snd_hdspm_midi_output_possible()
1847 static void snd_hdspm_flush_midi_input(struct hdspm *hdspm, int id) in snd_hdspm_flush_midi_input() argument
1849 while (snd_hdspm_midi_input_available (hdspm, id)) in snd_hdspm_flush_midi_input()
1850 snd_hdspm_midi_read_byte (hdspm, id); in snd_hdspm_flush_midi_input()
1866 n_pending = snd_hdspm_midi_output_possible (hmidi->hdspm, in snd_hdspm_midi_output_write()
1876 snd_hdspm_midi_write_byte (hmidi->hdspm, in snd_hdspm_midi_output_write()
1896 n_pending = snd_hdspm_midi_input_available (hmidi->hdspm, hmidi->id); in snd_hdspm_midi_input_read()
1902 buf[i] = snd_hdspm_midi_read_byte (hmidi->hdspm, in snd_hdspm_midi_input_read()
1910 snd_hdspm_midi_read_byte (hmidi->hdspm, in snd_hdspm_midi_input_read()
1917 spin_lock_irqsave(&hmidi->hdspm->lock, flags); in snd_hdspm_midi_input_read()
1918 hmidi->hdspm->control_register |= hmidi->ie; in snd_hdspm_midi_input_read()
1919 hdspm_write(hmidi->hdspm, HDSPM_controlRegister, in snd_hdspm_midi_input_read()
1920 hmidi->hdspm->control_register); in snd_hdspm_midi_input_read()
1921 spin_unlock_irqrestore(&hmidi->hdspm->lock, flags); in snd_hdspm_midi_input_read()
1929 struct hdspm *hdspm; in snd_hdspm_midi_input_trigger() local
1934 hdspm = hmidi->hdspm; in snd_hdspm_midi_input_trigger()
1936 spin_lock_irqsave (&hdspm->lock, flags); in snd_hdspm_midi_input_trigger()
1938 if (!(hdspm->control_register & hmidi->ie)) { in snd_hdspm_midi_input_trigger()
1939 snd_hdspm_flush_midi_input (hdspm, hmidi->id); in snd_hdspm_midi_input_trigger()
1940 hdspm->control_register |= hmidi->ie; in snd_hdspm_midi_input_trigger()
1943 hdspm->control_register &= ~hmidi->ie; in snd_hdspm_midi_input_trigger()
1946 hdspm_write(hdspm, HDSPM_controlRegister, hdspm->control_register); in snd_hdspm_midi_input_trigger()
1947 spin_unlock_irqrestore (&hdspm->lock, flags); in snd_hdspm_midi_input_trigger()
2000 snd_hdspm_flush_midi_input (hmidi->hdspm, hmidi->id); in snd_hdspm_midi_input_open()
2062 struct hdspm *hdspm, int id) in snd_hdspm_create_midi() argument
2067 hdspm->midi[id].id = id; in snd_hdspm_create_midi()
2068 hdspm->midi[id].hdspm = hdspm; in snd_hdspm_create_midi()
2069 spin_lock_init (&hdspm->midi[id].lock); in snd_hdspm_create_midi()
2072 if (MADIface == hdspm->io_type) { in snd_hdspm_create_midi()
2074 hdspm->midi[0].dataIn = HDSPM_midiDataIn2; in snd_hdspm_create_midi()
2075 hdspm->midi[0].statusIn = HDSPM_midiStatusIn2; in snd_hdspm_create_midi()
2076 hdspm->midi[0].dataOut = HDSPM_midiDataOut2; in snd_hdspm_create_midi()
2077 hdspm->midi[0].statusOut = HDSPM_midiStatusOut2; in snd_hdspm_create_midi()
2078 hdspm->midi[0].ie = HDSPM_Midi2InterruptEnable; in snd_hdspm_create_midi()
2079 hdspm->midi[0].irq = HDSPM_midi2IRQPending; in snd_hdspm_create_midi()
2081 hdspm->midi[0].dataIn = HDSPM_midiDataIn0; in snd_hdspm_create_midi()
2082 hdspm->midi[0].statusIn = HDSPM_midiStatusIn0; in snd_hdspm_create_midi()
2083 hdspm->midi[0].dataOut = HDSPM_midiDataOut0; in snd_hdspm_create_midi()
2084 hdspm->midi[0].statusOut = HDSPM_midiStatusOut0; in snd_hdspm_create_midi()
2085 hdspm->midi[0].ie = HDSPM_Midi0InterruptEnable; in snd_hdspm_create_midi()
2086 hdspm->midi[0].irq = HDSPM_midi0IRQPending; in snd_hdspm_create_midi()
2089 hdspm->midi[1].dataIn = HDSPM_midiDataIn1; in snd_hdspm_create_midi()
2090 hdspm->midi[1].statusIn = HDSPM_midiStatusIn1; in snd_hdspm_create_midi()
2091 hdspm->midi[1].dataOut = HDSPM_midiDataOut1; in snd_hdspm_create_midi()
2092 hdspm->midi[1].statusOut = HDSPM_midiStatusOut1; in snd_hdspm_create_midi()
2093 hdspm->midi[1].ie = HDSPM_Midi1InterruptEnable; in snd_hdspm_create_midi()
2094 hdspm->midi[1].irq = HDSPM_midi1IRQPending; in snd_hdspm_create_midi()
2095 } else if ((2 == id) && (MADI == hdspm->io_type)) { 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 = HDSPM_midiDataOut2; in snd_hdspm_create_midi()
2100 hdspm->midi[2].statusOut = HDSPM_midiStatusOut2; in snd_hdspm_create_midi()
2101 hdspm->midi[2].ie = HDSPM_Midi2InterruptEnable; in snd_hdspm_create_midi()
2102 hdspm->midi[2].irq = HDSPM_midi2IRQPending; in snd_hdspm_create_midi()
2105 hdspm->midi[2].dataIn = HDSPM_midiDataIn2; in snd_hdspm_create_midi()
2106 hdspm->midi[2].statusIn = HDSPM_midiStatusIn2; in snd_hdspm_create_midi()
2107 hdspm->midi[2].dataOut = -1; in snd_hdspm_create_midi()
2108 hdspm->midi[2].statusOut = -1; in snd_hdspm_create_midi()
2109 hdspm->midi[2].ie = HDSPM_Midi2InterruptEnable; in snd_hdspm_create_midi()
2110 hdspm->midi[2].irq = HDSPM_midi2IRQPendingAES; in snd_hdspm_create_midi()
2113 hdspm->midi[3].dataIn = HDSPM_midiDataIn3; in snd_hdspm_create_midi()
2114 hdspm->midi[3].statusIn = HDSPM_midiStatusIn3; in snd_hdspm_create_midi()
2115 hdspm->midi[3].dataOut = -1; in snd_hdspm_create_midi()
2116 hdspm->midi[3].statusOut = -1; in snd_hdspm_create_midi()
2117 hdspm->midi[3].ie = HDSPM_Midi3InterruptEnable; in snd_hdspm_create_midi()
2118 hdspm->midi[3].irq = HDSPM_midi3IRQPending; in snd_hdspm_create_midi()
2121 if ((id < 2) || ((2 == id) && ((MADI == hdspm->io_type) || in snd_hdspm_create_midi()
2122 (MADIface == hdspm->io_type)))) { in snd_hdspm_create_midi()
2123 if ((id == 0) && (MADIface == hdspm->io_type)) { in snd_hdspm_create_midi()
2126 } else if ((id == 2) && (MADI == hdspm->io_type)) { in snd_hdspm_create_midi()
2134 &hdspm->midi[id].rmidi); in snd_hdspm_create_midi()
2138 snprintf(hdspm->midi[id].rmidi->name, in snd_hdspm_create_midi()
2139 sizeof(hdspm->midi[id].rmidi->name), in snd_hdspm_create_midi()
2141 hdspm->midi[id].rmidi->private_data = &hdspm->midi[id]; in snd_hdspm_create_midi()
2143 snd_rawmidi_set_ops(hdspm->midi[id].rmidi, in snd_hdspm_create_midi()
2146 snd_rawmidi_set_ops(hdspm->midi[id].rmidi, in snd_hdspm_create_midi()
2150 hdspm->midi[id].rmidi->info_flags |= in snd_hdspm_create_midi()
2159 &hdspm->midi[id].rmidi); in snd_hdspm_create_midi()
2163 snprintf(hdspm->midi[id].rmidi->name, in snd_hdspm_create_midi()
2164 sizeof(hdspm->midi[id].rmidi->name), in snd_hdspm_create_midi()
2166 hdspm->midi[id].rmidi->private_data = &hdspm->midi[id]; in snd_hdspm_create_midi()
2168 snd_rawmidi_set_ops(hdspm->midi[id].rmidi, in snd_hdspm_create_midi()
2172 hdspm->midi[id].rmidi->info_flags |= SNDRV_RAWMIDI_INFO_INPUT; in snd_hdspm_create_midi()
2181 struct hdspm *hdspm = (struct hdspm *)arg; in hdspm_midi_tasklet() local
2184 while (i < hdspm->midiPorts) { in hdspm_midi_tasklet()
2185 if (hdspm->midi[i].pending) in hdspm_midi_tasklet()
2186 snd_hdspm_midi_input_read(&hdspm->midi[i]); in hdspm_midi_tasklet()
2200 static inline int hdspm_get_pll_freq(struct hdspm *hdspm) in hdspm_get_pll_freq() argument
2204 period = hdspm_read(hdspm, HDSPM_RD_PLL_FREQ); in hdspm_get_pll_freq()
2205 rate = hdspm_calc_dds_value(hdspm, period); in hdspm_get_pll_freq()
2214 static int hdspm_get_system_sample_rate(struct hdspm *hdspm) in hdspm_get_system_sample_rate() argument
2218 rate = hdspm_get_pll_freq(hdspm); in hdspm_get_system_sample_rate()
2222 if (0 == hdspm_system_clock_mode(hdspm)) { in hdspm_get_system_sample_rate()
2224 rate = hdspm->system_sample_rate; in hdspm_get_system_sample_rate()
2227 rate = hdspm_external_sample_rate(hdspm); in hdspm_get_system_sample_rate()
2229 rate = hdspm->system_sample_rate; in hdspm_get_system_sample_rate()
2264 struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); in snd_hdspm_get_system_sample_rate() local
2266 ucontrol->value.integer.value[0] = hdspm_get_system_sample_rate(hdspm); in snd_hdspm_get_system_sample_rate()
2274 struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); in snd_hdspm_put_system_sample_rate() local
2279 hdspm_set_dds_value(hdspm, ucontrol->value.integer.value[0]); in snd_hdspm_put_system_sample_rate()
2287 static int hdspm_get_wc_sample_rate(struct hdspm *hdspm) in hdspm_get_wc_sample_rate() argument
2291 switch (hdspm->io_type) { in hdspm_get_wc_sample_rate()
2294 status = hdspm_read(hdspm, HDSPM_RD_STATUS_1); in hdspm_get_wc_sample_rate()
2298 status = hdspm_read(hdspm, HDSPM_statusRegister); in hdspm_get_wc_sample_rate()
2312 static int hdspm_get_tco_sample_rate(struct hdspm *hdspm) in hdspm_get_tco_sample_rate() argument
2316 if (hdspm->tco) { in hdspm_get_tco_sample_rate()
2317 switch (hdspm->io_type) { in hdspm_get_tco_sample_rate()
2320 status = hdspm_read(hdspm, HDSPM_RD_STATUS_1); in hdspm_get_tco_sample_rate()
2324 status = hdspm_read(hdspm, HDSPM_statusRegister); in hdspm_get_tco_sample_rate()
2338 static int hdspm_get_sync_in_sample_rate(struct hdspm *hdspm) in hdspm_get_sync_in_sample_rate() argument
2342 if (hdspm->tco) { in hdspm_get_sync_in_sample_rate()
2343 switch (hdspm->io_type) { in hdspm_get_sync_in_sample_rate()
2346 status = hdspm_read(hdspm, HDSPM_RD_STATUS_2); in hdspm_get_sync_in_sample_rate()
2360 static int hdspm_get_aes_sample_rate(struct hdspm *hdspm, int index) in hdspm_get_aes_sample_rate() argument
2364 switch (hdspm->io_type) { in hdspm_get_aes_sample_rate()
2366 timecode = hdspm_read(hdspm, HDSPM_timecodeRegister); in hdspm_get_aes_sample_rate()
2379 static int hdspm_get_s1_sample_rate(struct hdspm *hdspm, unsigned int idx) in hdspm_get_s1_sample_rate() argument
2381 int status = hdspm_read(hdspm, HDSPM_RD_STATUS_2); in hdspm_get_s1_sample_rate()
2393 static int hdspm_external_rate_to_enum(struct hdspm *hdspm) in hdspm_external_rate_to_enum() argument
2395 int rate = hdspm_external_sample_rate(hdspm); in hdspm_external_rate_to_enum()
2428 struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); in snd_hdspm_get_autosync_sample_rate() local
2430 switch (hdspm->io_type) { in snd_hdspm_get_autosync_sample_rate()
2435 hdspm_get_wc_sample_rate(hdspm); in snd_hdspm_get_autosync_sample_rate()
2439 hdspm_get_tco_sample_rate(hdspm); in snd_hdspm_get_autosync_sample_rate()
2443 hdspm_get_sync_in_sample_rate(hdspm); in snd_hdspm_get_autosync_sample_rate()
2447 hdspm_get_s1_sample_rate(hdspm, in snd_hdspm_get_autosync_sample_rate()
2456 hdspm_get_wc_sample_rate(hdspm); in snd_hdspm_get_autosync_sample_rate()
2460 hdspm_get_tco_sample_rate(hdspm); in snd_hdspm_get_autosync_sample_rate()
2464 hdspm_get_sync_in_sample_rate(hdspm); in snd_hdspm_get_autosync_sample_rate()
2468 hdspm_get_s1_sample_rate(hdspm, in snd_hdspm_get_autosync_sample_rate()
2478 hdspm_get_wc_sample_rate(hdspm); in snd_hdspm_get_autosync_sample_rate()
2482 hdspm_get_tco_sample_rate(hdspm); in snd_hdspm_get_autosync_sample_rate()
2486 hdspm_get_sync_in_sample_rate(hdspm); in snd_hdspm_get_autosync_sample_rate()
2490 hdspm_external_rate_to_enum(hdspm); in snd_hdspm_get_autosync_sample_rate()
2494 hdspm_get_aes_sample_rate(hdspm, in snd_hdspm_get_autosync_sample_rate()
2504 hdspm_external_rate_to_enum(hdspm); in snd_hdspm_get_autosync_sample_rate()
2530 static int hdspm_system_clock_mode(struct hdspm *hdspm) in hdspm_system_clock_mode() argument
2532 switch (hdspm->io_type) { in hdspm_system_clock_mode()
2535 if (hdspm->settings_register & HDSPM_c0Master) in hdspm_system_clock_mode()
2540 if (hdspm->control_register & HDSPM_ClockModeMaster) in hdspm_system_clock_mode()
2552 static void hdspm_set_system_clock_mode(struct hdspm *hdspm, int mode) in hdspm_set_system_clock_mode() argument
2554 hdspm_set_toggle_setting(hdspm, in hdspm_set_system_clock_mode()
2555 (hdspm_is_raydat_or_aio(hdspm)) ? in hdspm_set_system_clock_mode()
2572 struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); in snd_hdspm_get_system_clock_mode() local
2574 ucontrol->value.enumerated.item[0] = hdspm_system_clock_mode(hdspm); in snd_hdspm_get_system_clock_mode()
2581 struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); in snd_hdspm_put_system_clock_mode() local
2584 if (!snd_hdspm_use_is_exclusive(hdspm)) in snd_hdspm_put_system_clock_mode()
2593 hdspm_set_system_clock_mode(hdspm, val); in snd_hdspm_put_system_clock_mode()
2609 static int hdspm_clock_source(struct hdspm * hdspm) in hdspm_clock_source() argument
2611 switch (hdspm->system_sample_rate) { in hdspm_clock_source()
2626 static int hdspm_set_clock_source(struct hdspm * hdspm, int mode) in hdspm_set_clock_source() argument
2651 hdspm_set_rate(hdspm, rate, 1); in hdspm_set_clock_source()
2664 struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); in snd_hdspm_get_clock_source() local
2666 ucontrol->value.enumerated.item[0] = hdspm_clock_source(hdspm); in snd_hdspm_get_clock_source()
2673 struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); in snd_hdspm_put_clock_source() local
2677 if (!snd_hdspm_use_is_exclusive(hdspm)) in snd_hdspm_put_clock_source()
2684 spin_lock_irq(&hdspm->lock); in snd_hdspm_put_clock_source()
2685 if (val != hdspm_clock_source(hdspm)) in snd_hdspm_put_clock_source()
2686 change = (hdspm_set_clock_source(hdspm, val) == 0) ? 1 : 0; in snd_hdspm_put_clock_source()
2689 spin_unlock_irq(&hdspm->lock); in snd_hdspm_put_clock_source()
2711 static int hdspm_pref_sync_ref(struct hdspm * hdspm) in hdspm_pref_sync_ref() argument
2713 switch (hdspm->io_type) { in hdspm_pref_sync_ref()
2715 switch (hdspm->control_register & HDSPM_SyncRefMask) { in hdspm_pref_sync_ref()
2732 if (hdspm->tco) { in hdspm_pref_sync_ref()
2733 switch (hdspm->control_register & HDSPM_SyncRefMask) { in hdspm_pref_sync_ref()
2741 switch (hdspm->control_register & HDSPM_SyncRefMask) { in hdspm_pref_sync_ref()
2751 if (hdspm->tco) { in hdspm_pref_sync_ref()
2752 switch ((hdspm->settings_register & in hdspm_pref_sync_ref()
2765 switch ((hdspm->settings_register & in hdspm_pref_sync_ref()
2781 if (hdspm->tco) { in hdspm_pref_sync_ref()
2782 switch ((hdspm->settings_register & in hdspm_pref_sync_ref()
2792 switch ((hdspm->settings_register & in hdspm_pref_sync_ref()
2814 static int hdspm_set_pref_sync_ref(struct hdspm * hdspm, int pref) in hdspm_set_pref_sync_ref() argument
2818 switch (hdspm->io_type) { in hdspm_set_pref_sync_ref()
2820 hdspm->control_register &= ~HDSPM_SyncRefMask; in hdspm_set_pref_sync_ref()
2825 hdspm->control_register |= HDSPM_SyncRef0; in hdspm_set_pref_sync_ref()
2828 hdspm->control_register |= HDSPM_SyncRef1; in hdspm_set_pref_sync_ref()
2831 hdspm->control_register |= in hdspm_set_pref_sync_ref()
2835 hdspm->control_register |= HDSPM_SyncRef2; in hdspm_set_pref_sync_ref()
2838 hdspm->control_register |= in hdspm_set_pref_sync_ref()
2842 hdspm->control_register |= in hdspm_set_pref_sync_ref()
2846 hdspm->control_register |= in hdspm_set_pref_sync_ref()
2850 hdspm->control_register |= HDSPM_SyncRef3; in hdspm_set_pref_sync_ref()
2853 hdspm->control_register |= in hdspm_set_pref_sync_ref()
2864 hdspm->control_register &= ~HDSPM_SyncRefMask; in hdspm_set_pref_sync_ref()
2865 if (hdspm->tco) { in hdspm_set_pref_sync_ref()
2870 hdspm->control_register |= HDSPM_SyncRef0; in hdspm_set_pref_sync_ref()
2873 hdspm->control_register |= HDSPM_SyncRef1; in hdspm_set_pref_sync_ref()
2876 hdspm->control_register |= in hdspm_set_pref_sync_ref()
2887 hdspm->control_register |= HDSPM_SyncRef0; in hdspm_set_pref_sync_ref()
2890 hdspm->control_register |= in hdspm_set_pref_sync_ref()
2901 if (hdspm->tco) { in hdspm_set_pref_sync_ref()
2930 if (hdspm->tco) { in hdspm_set_pref_sync_ref()
2953 switch (hdspm->io_type) { in hdspm_set_pref_sync_ref()
2956 hdspm->settings_register &= ~HDSPM_c0_SyncRefMask; in hdspm_set_pref_sync_ref()
2957 hdspm->settings_register |= HDSPM_c0_SyncRef0 * p; in hdspm_set_pref_sync_ref()
2958 hdspm_write(hdspm, HDSPM_WR_SETTINGS, hdspm->settings_register); in hdspm_set_pref_sync_ref()
2964 hdspm_write(hdspm, HDSPM_controlRegister, in hdspm_set_pref_sync_ref()
2965 hdspm->control_register); in hdspm_set_pref_sync_ref()
2975 struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); in snd_hdspm_info_pref_sync_ref() local
2977 snd_ctl_enum_info(uinfo, 1, hdspm->texts_autosync_items, hdspm->texts_autosync); in snd_hdspm_info_pref_sync_ref()
2985 struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); in snd_hdspm_get_pref_sync_ref() local
2986 int psf = hdspm_pref_sync_ref(hdspm); in snd_hdspm_get_pref_sync_ref()
2999 struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); in snd_hdspm_put_pref_sync_ref() local
3002 if (!snd_hdspm_use_is_exclusive(hdspm)) in snd_hdspm_put_pref_sync_ref()
3009 else if (val >= hdspm->texts_autosync_items) in snd_hdspm_put_pref_sync_ref()
3010 val = hdspm->texts_autosync_items-1; in snd_hdspm_put_pref_sync_ref()
3012 spin_lock_irq(&hdspm->lock); in snd_hdspm_put_pref_sync_ref()
3013 if (val != hdspm_pref_sync_ref(hdspm)) in snd_hdspm_put_pref_sync_ref()
3014 change = (0 == hdspm_set_pref_sync_ref(hdspm, val)) ? 1 : 0; in snd_hdspm_put_pref_sync_ref()
3016 spin_unlock_irq(&hdspm->lock); in snd_hdspm_put_pref_sync_ref()
3030 static int hdspm_autosync_ref(struct hdspm *hdspm) in hdspm_autosync_ref() argument
3033 if (AES32 == hdspm->io_type) { in hdspm_autosync_ref()
3035 unsigned int status = hdspm_read(hdspm, HDSPM_statusRegister); in hdspm_autosync_ref()
3043 } else if (MADI == hdspm->io_type) { in hdspm_autosync_ref()
3045 unsigned int status2 = hdspm_read(hdspm, HDSPM_statusRegister2); in hdspm_autosync_ref()
3069 struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); in snd_hdspm_info_autosync_ref() local
3071 if (AES32 == hdspm->io_type) { in snd_hdspm_info_autosync_ref()
3076 } else if (MADI == hdspm->io_type) { in snd_hdspm_info_autosync_ref()
3088 struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); in snd_hdspm_get_autosync_ref() local
3090 ucontrol->value.enumerated.item[0] = hdspm_autosync_ref(hdspm); in snd_hdspm_get_autosync_ref()
3119 struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); in snd_hdspm_get_tco_video_input_format() local
3120 status = hdspm_read(hdspm, HDSPM_RD_TCO + 4); in snd_hdspm_get_tco_video_input_format()
3160 static int hdspm_tco_ltc_frames(struct hdspm *hdspm) in hdspm_tco_ltc_frames() argument
3165 status = hdspm_read(hdspm, HDSPM_RD_TCO + 4); in hdspm_tco_ltc_frames()
3194 struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); in snd_hdspm_get_tco_ltc_frames() local
3196 ucontrol->value.enumerated.item[0] = hdspm_tco_ltc_frames(hdspm); in snd_hdspm_get_tco_ltc_frames()
3209 static int hdspm_toggle_setting(struct hdspm *hdspm, u32 regmask) in hdspm_toggle_setting() argument
3213 if (hdspm_is_raydat_or_aio(hdspm)) in hdspm_toggle_setting()
3214 reg = hdspm->settings_register; in hdspm_toggle_setting()
3216 reg = hdspm->control_register; in hdspm_toggle_setting()
3221 static int hdspm_set_toggle_setting(struct hdspm *hdspm, u32 regmask, int out) in hdspm_set_toggle_setting() argument
3226 if (hdspm_is_raydat_or_aio(hdspm)) { in hdspm_set_toggle_setting()
3227 reg = &(hdspm->settings_register); in hdspm_set_toggle_setting()
3230 reg = &(hdspm->control_register); in hdspm_set_toggle_setting()
3239 hdspm_write(hdspm, target_reg, *reg); in hdspm_set_toggle_setting()
3249 struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); in snd_hdspm_get_toggle_setting() local
3252 spin_lock_irq(&hdspm->lock); in snd_hdspm_get_toggle_setting()
3253 ucontrol->value.integer.value[0] = hdspm_toggle_setting(hdspm, regmask); in snd_hdspm_get_toggle_setting()
3254 spin_unlock_irq(&hdspm->lock); in snd_hdspm_get_toggle_setting()
3261 struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); in snd_hdspm_put_toggle_setting() local
3266 if (!snd_hdspm_use_is_exclusive(hdspm)) in snd_hdspm_put_toggle_setting()
3269 spin_lock_irq(&hdspm->lock); in snd_hdspm_put_toggle_setting()
3270 change = (int) val != hdspm_toggle_setting(hdspm, regmask); in snd_hdspm_put_toggle_setting()
3271 hdspm_set_toggle_setting(hdspm, regmask, val); in snd_hdspm_put_toggle_setting()
3272 spin_unlock_irq(&hdspm->lock); in snd_hdspm_put_toggle_setting()
3285 static int hdspm_input_select(struct hdspm * hdspm) in hdspm_input_select() argument
3287 return (hdspm->control_register & HDSPM_InputSelect0) ? 1 : 0; in hdspm_input_select()
3290 static int hdspm_set_input_select(struct hdspm * hdspm, int out) in hdspm_set_input_select() argument
3293 hdspm->control_register |= HDSPM_InputSelect0; in hdspm_set_input_select()
3295 hdspm->control_register &= ~HDSPM_InputSelect0; in hdspm_set_input_select()
3296 hdspm_write(hdspm, HDSPM_controlRegister, hdspm->control_register); in hdspm_set_input_select()
3312 struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); in snd_hdspm_get_input_select() local
3314 spin_lock_irq(&hdspm->lock); in snd_hdspm_get_input_select()
3315 ucontrol->value.enumerated.item[0] = hdspm_input_select(hdspm); in snd_hdspm_get_input_select()
3316 spin_unlock_irq(&hdspm->lock); in snd_hdspm_get_input_select()
3323 struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); in snd_hdspm_put_input_select() local
3327 if (!snd_hdspm_use_is_exclusive(hdspm)) in snd_hdspm_put_input_select()
3330 spin_lock_irq(&hdspm->lock); in snd_hdspm_put_input_select()
3331 change = (int) val != hdspm_input_select(hdspm); in snd_hdspm_put_input_select()
3332 hdspm_set_input_select(hdspm, val); in snd_hdspm_put_input_select()
3333 spin_unlock_irq(&hdspm->lock); in snd_hdspm_put_input_select()
3347 static int hdspm_ds_wire(struct hdspm * hdspm) in hdspm_ds_wire() argument
3349 return (hdspm->control_register & HDSPM_DS_DoubleWire) ? 1 : 0; in hdspm_ds_wire()
3352 static int hdspm_set_ds_wire(struct hdspm * hdspm, int ds) in hdspm_set_ds_wire() argument
3355 hdspm->control_register |= HDSPM_DS_DoubleWire; in hdspm_set_ds_wire()
3357 hdspm->control_register &= ~HDSPM_DS_DoubleWire; in hdspm_set_ds_wire()
3358 hdspm_write(hdspm, HDSPM_controlRegister, hdspm->control_register); in hdspm_set_ds_wire()
3374 struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); in snd_hdspm_get_ds_wire() local
3376 spin_lock_irq(&hdspm->lock); in snd_hdspm_get_ds_wire()
3377 ucontrol->value.enumerated.item[0] = hdspm_ds_wire(hdspm); in snd_hdspm_get_ds_wire()
3378 spin_unlock_irq(&hdspm->lock); in snd_hdspm_get_ds_wire()
3385 struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); in snd_hdspm_put_ds_wire() local
3389 if (!snd_hdspm_use_is_exclusive(hdspm)) in snd_hdspm_put_ds_wire()
3392 spin_lock_irq(&hdspm->lock); in snd_hdspm_put_ds_wire()
3393 change = (int) val != hdspm_ds_wire(hdspm); in snd_hdspm_put_ds_wire()
3394 hdspm_set_ds_wire(hdspm, val); in snd_hdspm_put_ds_wire()
3395 spin_unlock_irq(&hdspm->lock); in snd_hdspm_put_ds_wire()
3409 static int hdspm_qs_wire(struct hdspm * hdspm) in hdspm_qs_wire() argument
3411 if (hdspm->control_register & HDSPM_QS_DoubleWire) in hdspm_qs_wire()
3413 if (hdspm->control_register & HDSPM_QS_QuadWire) in hdspm_qs_wire()
3418 static int hdspm_set_qs_wire(struct hdspm * hdspm, int mode) in hdspm_set_qs_wire() argument
3420 hdspm->control_register &= ~(HDSPM_QS_DoubleWire | HDSPM_QS_QuadWire); in hdspm_set_qs_wire()
3425 hdspm->control_register |= HDSPM_QS_DoubleWire; in hdspm_set_qs_wire()
3428 hdspm->control_register |= HDSPM_QS_QuadWire; in hdspm_set_qs_wire()
3431 hdspm_write(hdspm, HDSPM_controlRegister, hdspm->control_register); in hdspm_set_qs_wire()
3447 struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); in snd_hdspm_get_qs_wire() local
3449 spin_lock_irq(&hdspm->lock); in snd_hdspm_get_qs_wire()
3450 ucontrol->value.enumerated.item[0] = hdspm_qs_wire(hdspm); in snd_hdspm_get_qs_wire()
3451 spin_unlock_irq(&hdspm->lock); in snd_hdspm_get_qs_wire()
3458 struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); in snd_hdspm_put_qs_wire() local
3462 if (!snd_hdspm_use_is_exclusive(hdspm)) in snd_hdspm_put_qs_wire()
3469 spin_lock_irq(&hdspm->lock); in snd_hdspm_put_qs_wire()
3470 change = val != hdspm_qs_wire(hdspm); in snd_hdspm_put_qs_wire()
3471 hdspm_set_qs_wire(hdspm, val); in snd_hdspm_put_qs_wire()
3472 spin_unlock_irq(&hdspm->lock); in snd_hdspm_put_qs_wire()
3485 static int hdspm_tristate(struct hdspm *hdspm, u32 regmask) in hdspm_tristate() argument
3487 u32 reg = hdspm->settings_register & (regmask * 3); in hdspm_tristate()
3491 static int hdspm_set_tristate(struct hdspm *hdspm, int mode, u32 regmask) in hdspm_set_tristate() argument
3493 hdspm->settings_register &= ~(regmask * 3); in hdspm_set_tristate()
3494 hdspm->settings_register |= (regmask * mode); in hdspm_set_tristate()
3495 hdspm_write(hdspm, HDSPM_WR_SETTINGS, hdspm->settings_register); in hdspm_set_tristate()
3522 struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); in snd_hdspm_get_tristate() local
3525 spin_lock_irq(&hdspm->lock); in snd_hdspm_get_tristate()
3526 ucontrol->value.enumerated.item[0] = hdspm_tristate(hdspm, regmask); in snd_hdspm_get_tristate()
3527 spin_unlock_irq(&hdspm->lock); in snd_hdspm_get_tristate()
3534 struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); in snd_hdspm_put_tristate() local
3539 if (!snd_hdspm_use_is_exclusive(hdspm)) in snd_hdspm_put_tristate()
3547 spin_lock_irq(&hdspm->lock); in snd_hdspm_put_tristate()
3548 change = val != hdspm_tristate(hdspm, regmask); in snd_hdspm_put_tristate()
3549 hdspm_set_tristate(hdspm, val, regmask); in snd_hdspm_put_tristate()
3550 spin_unlock_irq(&hdspm->lock); in snd_hdspm_put_tristate()
3563 static int hdspm_madi_speedmode(struct hdspm *hdspm) in hdspm_madi_speedmode() argument
3565 if (hdspm->control_register & HDSPM_QuadSpeed) in hdspm_madi_speedmode()
3567 if (hdspm->control_register & HDSPM_DoubleSpeed) in hdspm_madi_speedmode()
3572 static int hdspm_set_madi_speedmode(struct hdspm *hdspm, int mode) in hdspm_set_madi_speedmode() argument
3574 hdspm->control_register &= ~(HDSPM_DoubleSpeed | HDSPM_QuadSpeed); in hdspm_set_madi_speedmode()
3579 hdspm->control_register |= HDSPM_DoubleSpeed; in hdspm_set_madi_speedmode()
3582 hdspm->control_register |= HDSPM_QuadSpeed; in hdspm_set_madi_speedmode()
3585 hdspm_write(hdspm, HDSPM_controlRegister, hdspm->control_register); in hdspm_set_madi_speedmode()
3601 struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); in snd_hdspm_get_madi_speedmode() local
3603 spin_lock_irq(&hdspm->lock); in snd_hdspm_get_madi_speedmode()
3604 ucontrol->value.enumerated.item[0] = hdspm_madi_speedmode(hdspm); in snd_hdspm_get_madi_speedmode()
3605 spin_unlock_irq(&hdspm->lock); in snd_hdspm_get_madi_speedmode()
3612 struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); in snd_hdspm_put_madi_speedmode() local
3616 if (!snd_hdspm_use_is_exclusive(hdspm)) in snd_hdspm_put_madi_speedmode()
3623 spin_lock_irq(&hdspm->lock); in snd_hdspm_put_madi_speedmode()
3624 change = val != hdspm_madi_speedmode(hdspm); in snd_hdspm_put_madi_speedmode()
3625 hdspm_set_madi_speedmode(hdspm, val); in snd_hdspm_put_madi_speedmode()
3626 spin_unlock_irq(&hdspm->lock); in snd_hdspm_put_madi_speedmode()
3656 struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); in snd_hdspm_get_mixer() local
3672 spin_lock_irq(&hdspm->lock); in snd_hdspm_get_mixer()
3675 hdspm_read_pb_gain(hdspm, destination, in snd_hdspm_get_mixer()
3679 hdspm_read_in_gain(hdspm, destination, source); in snd_hdspm_get_mixer()
3681 spin_unlock_irq(&hdspm->lock); in snd_hdspm_get_mixer()
3689 struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); in snd_hdspm_put_mixer() local
3695 if (!snd_hdspm_use_is_exclusive(hdspm)) in snd_hdspm_put_mixer()
3708 spin_lock_irq(&hdspm->lock); in snd_hdspm_put_mixer()
3711 change = gain != hdspm_read_pb_gain(hdspm, destination, in snd_hdspm_put_mixer()
3715 change = gain != hdspm_read_in_gain(hdspm, destination, in snd_hdspm_put_mixer()
3720 hdspm_write_pb_gain(hdspm, destination, in snd_hdspm_put_mixer()
3724 hdspm_write_in_gain(hdspm, destination, source, in snd_hdspm_put_mixer()
3727 spin_unlock_irq(&hdspm->lock); in snd_hdspm_put_mixer()
3760 struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); in snd_hdspm_get_playback_mixer() local
3768 spin_lock_irq(&hdspm->lock); in snd_hdspm_get_playback_mixer()
3770 (hdspm_read_pb_gain(hdspm, channel, channel)*64)/UNITY_GAIN; in snd_hdspm_get_playback_mixer()
3771 spin_unlock_irq(&hdspm->lock); in snd_hdspm_get_playback_mixer()
3779 struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); in snd_hdspm_put_playback_mixer() local
3784 if (!snd_hdspm_use_is_exclusive(hdspm)) in snd_hdspm_put_playback_mixer()
3794 spin_lock_irq(&hdspm->lock); in snd_hdspm_put_playback_mixer()
3796 gain != hdspm_read_pb_gain(hdspm, channel, in snd_hdspm_put_playback_mixer()
3799 hdspm_write_pb_gain(hdspm, channel, channel, in snd_hdspm_put_playback_mixer()
3801 spin_unlock_irq(&hdspm->lock); in snd_hdspm_put_playback_mixer()
3841 static int hdspm_wc_sync_check(struct hdspm *hdspm) in hdspm_wc_sync_check() argument
3845 switch (hdspm->io_type) { in hdspm_wc_sync_check()
3847 status = hdspm_read(hdspm, HDSPM_statusRegister); in hdspm_wc_sync_check()
3858 status2 = hdspm_read(hdspm, HDSPM_statusRegister2); in hdspm_wc_sync_check()
3870 status = hdspm_read(hdspm, HDSPM_statusRegister); in hdspm_wc_sync_check()
3889 static int hdspm_madi_sync_check(struct hdspm *hdspm) in hdspm_madi_sync_check() argument
3891 int status = hdspm_read(hdspm, HDSPM_statusRegister); in hdspm_madi_sync_check()
3902 static int hdspm_s1_sync_check(struct hdspm *hdspm, int idx) in hdspm_s1_sync_check() argument
3906 status = hdspm_read(hdspm, HDSPM_RD_STATUS_1); in hdspm_s1_sync_check()
3919 static int hdspm_sync_in_sync_check(struct hdspm *hdspm) in hdspm_sync_in_sync_check() argument
3923 switch (hdspm->io_type) { in hdspm_sync_in_sync_check()
3926 status = hdspm_read(hdspm, HDSPM_RD_STATUS_3); in hdspm_sync_in_sync_check()
3932 status = hdspm_read(hdspm, HDSPM_statusRegister); in hdspm_sync_in_sync_check()
3938 status = hdspm_read(hdspm, HDSPM_statusRegister2); in hdspm_sync_in_sync_check()
3955 static int hdspm_aes_sync_check(struct hdspm *hdspm, int idx) in hdspm_aes_sync_check() argument
3958 status2 = hdspm_read(hdspm, HDSPM_statusRegister2); in hdspm_aes_sync_check()
3970 static int hdspm_tco_input_check(struct hdspm *hdspm, u32 mask) in hdspm_tco_input_check() argument
3973 status = hdspm_read(hdspm, HDSPM_RD_TCO + 4); in hdspm_tco_input_check()
3979 static int hdspm_tco_sync_check(struct hdspm *hdspm) in hdspm_tco_sync_check() argument
3983 if (hdspm->tco) { in hdspm_tco_sync_check()
3984 switch (hdspm->io_type) { in hdspm_tco_sync_check()
3986 status = hdspm_read(hdspm, HDSPM_statusRegister); in hdspm_tco_sync_check()
3995 status = hdspm_read(hdspm, HDSPM_statusRegister); in hdspm_tco_sync_check()
4005 status = hdspm_read(hdspm, HDSPM_RD_STATUS_1); in hdspm_tco_sync_check()
4025 struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); in snd_hdspm_get_sync_check() local
4028 switch (hdspm->io_type) { in snd_hdspm_get_sync_check()
4032 val = hdspm_wc_sync_check(hdspm); break; in snd_hdspm_get_sync_check()
4034 val = hdspm_tco_sync_check(hdspm); break; in snd_hdspm_get_sync_check()
4036 val = hdspm_sync_in_sync_check(hdspm); break; in snd_hdspm_get_sync_check()
4038 val = hdspm_s1_sync_check(hdspm, in snd_hdspm_get_sync_check()
4046 val = hdspm_wc_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()
4052 val = hdspm_s1_sync_check(hdspm, in snd_hdspm_get_sync_check()
4060 val = hdspm_wc_sync_check(hdspm); break; in snd_hdspm_get_sync_check()
4062 val = hdspm_madi_sync_check(hdspm); break; in snd_hdspm_get_sync_check()
4064 val = hdspm_tco_sync_check(hdspm); break; in snd_hdspm_get_sync_check()
4066 val = hdspm_sync_in_sync_check(hdspm); break; in snd_hdspm_get_sync_check()
4071 val = hdspm_madi_sync_check(hdspm); /* MADI */ in snd_hdspm_get_sync_check()
4077 val = hdspm_wc_sync_check(hdspm); break; in snd_hdspm_get_sync_check()
4079 val = hdspm_tco_sync_check(hdspm); break; in snd_hdspm_get_sync_check()
4081 val = hdspm_sync_in_sync_check(hdspm); break; in snd_hdspm_get_sync_check()
4083 val = hdspm_aes_sync_check(hdspm, in snd_hdspm_get_sync_check()
4090 if (hdspm->tco) { in snd_hdspm_get_sync_check()
4094 val = hdspm_tco_input_check(hdspm, HDSPM_TCO1_TCO_lock); in snd_hdspm_get_sync_check()
4098 val = hdspm_tco_input_check(hdspm, in snd_hdspm_get_sync_check()
4118 static void hdspm_tco_write(struct hdspm *hdspm) in hdspm_tco_write() argument
4122 switch (hdspm->tco->input) { in hdspm_tco_write()
4133 switch (hdspm->tco->framerate) { in hdspm_tco_write()
4157 switch (hdspm->tco->wordclock) { in hdspm_tco_write()
4168 switch (hdspm->tco->samplerate) { in hdspm_tco_write()
4179 switch (hdspm->tco->pull) { in hdspm_tco_write()
4196 if (1 == hdspm->tco->term) { in hdspm_tco_write()
4200 hdspm_write(hdspm, HDSPM_WR_TCO, tc[0]); in hdspm_tco_write()
4201 hdspm_write(hdspm, HDSPM_WR_TCO+4, tc[1]); in hdspm_tco_write()
4202 hdspm_write(hdspm, HDSPM_WR_TCO+8, tc[2]); in hdspm_tco_write()
4203 hdspm_write(hdspm, HDSPM_WR_TCO+12, tc[3]); in hdspm_tco_write()
4230 struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); in snd_hdspm_get_tco_sample_rate() local
4232 ucontrol->value.enumerated.item[0] = hdspm->tco->samplerate; in snd_hdspm_get_tco_sample_rate()
4240 struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); in snd_hdspm_put_tco_sample_rate() local
4242 if (hdspm->tco->samplerate != ucontrol->value.enumerated.item[0]) { in snd_hdspm_put_tco_sample_rate()
4243 hdspm->tco->samplerate = ucontrol->value.enumerated.item[0]; in snd_hdspm_put_tco_sample_rate()
4245 hdspm_tco_write(hdspm); in snd_hdspm_put_tco_sample_rate()
4277 struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); in snd_hdspm_get_tco_pull() local
4279 ucontrol->value.enumerated.item[0] = hdspm->tco->pull; in snd_hdspm_get_tco_pull()
4287 struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); in snd_hdspm_put_tco_pull() local
4289 if (hdspm->tco->pull != ucontrol->value.enumerated.item[0]) { in snd_hdspm_put_tco_pull()
4290 hdspm->tco->pull = ucontrol->value.enumerated.item[0]; in snd_hdspm_put_tco_pull()
4292 hdspm_tco_write(hdspm); in snd_hdspm_put_tco_pull()
4322 struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); in snd_hdspm_get_tco_wck_conversion() local
4324 ucontrol->value.enumerated.item[0] = hdspm->tco->wordclock; in snd_hdspm_get_tco_wck_conversion()
4332 struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); in snd_hdspm_put_tco_wck_conversion() local
4334 if (hdspm->tco->wordclock != ucontrol->value.enumerated.item[0]) { in snd_hdspm_put_tco_wck_conversion()
4335 hdspm->tco->wordclock = ucontrol->value.enumerated.item[0]; in snd_hdspm_put_tco_wck_conversion()
4337 hdspm_tco_write(hdspm); in snd_hdspm_put_tco_wck_conversion()
4369 struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); in snd_hdspm_get_tco_frame_rate() local
4371 ucontrol->value.enumerated.item[0] = hdspm->tco->framerate; in snd_hdspm_get_tco_frame_rate()
4379 struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); in snd_hdspm_put_tco_frame_rate() local
4381 if (hdspm->tco->framerate != ucontrol->value.enumerated.item[0]) { in snd_hdspm_put_tco_frame_rate()
4382 hdspm->tco->framerate = ucontrol->value.enumerated.item[0]; in snd_hdspm_put_tco_frame_rate()
4384 hdspm_tco_write(hdspm); in snd_hdspm_put_tco_frame_rate()
4415 struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); in snd_hdspm_get_tco_sync_source() local
4417 ucontrol->value.enumerated.item[0] = hdspm->tco->input; in snd_hdspm_get_tco_sync_source()
4425 struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); in snd_hdspm_put_tco_sync_source() local
4427 if (hdspm->tco->input != ucontrol->value.enumerated.item[0]) { in snd_hdspm_put_tco_sync_source()
4428 hdspm->tco->input = ucontrol->value.enumerated.item[0]; in snd_hdspm_put_tco_sync_source()
4430 hdspm_tco_write(hdspm); in snd_hdspm_put_tco_sync_source()
4465 struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); in snd_hdspm_get_tco_word_term() local
4467 ucontrol->value.integer.value[0] = hdspm->tco->term; in snd_hdspm_get_tco_word_term()
4476 struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); in snd_hdspm_put_tco_word_term() local
4478 if (hdspm->tco->term != ucontrol->value.integer.value[0]) { in snd_hdspm_put_tco_word_term()
4479 hdspm->tco->term = ucontrol->value.integer.value[0]; in snd_hdspm_put_tco_word_term()
4481 hdspm_tco_write(hdspm); in snd_hdspm_put_tco_word_term()
4655 static int hdspm_update_simple_mixer_controls(struct hdspm * hdspm) in hdspm_update_simple_mixer_controls() argument
4659 for (i = hdspm->ds_out_channels; i < hdspm->ss_out_channels; ++i) { in hdspm_update_simple_mixer_controls()
4660 if (hdspm->system_sample_rate > 48000) { in hdspm_update_simple_mixer_controls()
4661 hdspm->playback_mixer_ctls[i]->vd[0].access = in hdspm_update_simple_mixer_controls()
4666 hdspm->playback_mixer_ctls[i]->vd[0].access = in hdspm_update_simple_mixer_controls()
4670 snd_ctl_notify(hdspm->card, SNDRV_CTL_EVENT_MASK_VALUE | in hdspm_update_simple_mixer_controls()
4672 &hdspm->playback_mixer_ctls[i]->id); in hdspm_update_simple_mixer_controls()
4680 struct hdspm *hdspm) in snd_hdspm_create_controls() argument
4687 switch (hdspm->io_type) { in snd_hdspm_create_controls()
4713 snd_ctl_new1(&list[idx], hdspm)); in snd_hdspm_create_controls()
4722 if (hdspm->system_sample_rate >= 128000) { in snd_hdspm_create_controls()
4723 limit = hdspm->qs_out_channels; in snd_hdspm_create_controls()
4724 } else if (hdspm->system_sample_rate >= 64000) { in snd_hdspm_create_controls()
4725 limit = hdspm->ds_out_channels; in snd_hdspm_create_controls()
4727 limit = hdspm->ss_out_channels; in snd_hdspm_create_controls()
4731 kctl = snd_ctl_new1(&snd_hdspm_playback_mixer, hdspm); in snd_hdspm_create_controls()
4735 hdspm->playback_mixer_ctls[idx] = kctl; in snd_hdspm_create_controls()
4739 if (hdspm->tco) { in snd_hdspm_create_controls()
4745 snd_ctl_new1(&list[idx], hdspm)); in snd_hdspm_create_controls()
4762 struct hdspm *hdspm = entry->private_data; in snd_hdspm_proc_read_tco() local
4771 status = hdspm_read(hdspm, HDSPM_statusRegister); in snd_hdspm_proc_read_tco()
4772 control = hdspm->control_register; in snd_hdspm_proc_read_tco()
4777 a = hdspm_read(hdspm, HDSPM_RD_TCO+4); in snd_hdspm_proc_read_tco()
4816 switch (hdspm->io_type) { in snd_hdspm_proc_read_tco()
4829 period = hdspm_read(hdspm, HDSPM_RD_PLL_FREQ); in snd_hdspm_proc_read_tco()
4845 ltc = hdspm_read(hdspm, HDSPM_RD_TCO); in snd_hdspm_proc_read_tco()
4874 struct hdspm *hdspm = entry->private_data; in snd_hdspm_proc_read_madi() local
4882 status = hdspm_read(hdspm, HDSPM_statusRegister); in snd_hdspm_proc_read_madi()
4883 status2 = hdspm_read(hdspm, HDSPM_statusRegister2); in snd_hdspm_proc_read_madi()
4886 hdspm->card_name, hdspm->card->number + 1, in snd_hdspm_proc_read_madi()
4887 hdspm->firmware_rev, in snd_hdspm_proc_read_madi()
4893 (hdspm_read(hdspm, HDSPM_midiStatusIn1)>>8) & 0xFFFFFF, in snd_hdspm_proc_read_madi()
4894 hdspm->serial); in snd_hdspm_proc_read_madi()
4897 hdspm->irq, hdspm->port, (unsigned long)hdspm->iobase); in snd_hdspm_proc_read_madi()
4906 hdspm->irq_count); in snd_hdspm_proc_read_madi()
4913 (2 * (int)hdspm->period_bytes), in snd_hdspm_proc_read_madi()
4915 (2 * (int)hdspm->period_bytes), in snd_hdspm_proc_read_madi()
4916 (long) hdspm_hw_pointer(hdspm) * 4); in snd_hdspm_proc_read_madi()
4920 hdspm_read(hdspm, HDSPM_midiStatusOut0) & 0xFF, in snd_hdspm_proc_read_madi()
4921 hdspm_read(hdspm, HDSPM_midiStatusOut1) & 0xFF, in snd_hdspm_proc_read_madi()
4922 hdspm_read(hdspm, HDSPM_midiStatusIn0) & 0xFF, in snd_hdspm_proc_read_madi()
4923 hdspm_read(hdspm, HDSPM_midiStatusIn1) & 0xFF); in snd_hdspm_proc_read_madi()
4926 hdspm_read(hdspm, HDSPM_midiStatusIn2) & 0xFF, in snd_hdspm_proc_read_madi()
4927 hdspm_read(hdspm, HDSPM_midiStatusOut2) & 0xFF); in snd_hdspm_proc_read_madi()
4931 hdspm->control_register, hdspm->control2_register, in snd_hdspm_proc_read_madi()
4937 x = hdspm_get_latency(hdspm); in snd_hdspm_proc_read_madi()
4941 x, (unsigned long) hdspm->period_bytes); in snd_hdspm_proc_read_madi()
4944 (hdspm->control_register & HDSPM_LineOut) ? "on " : "off"); in snd_hdspm_proc_read_madi()
4949 (hdspm->control_register & HDSPM_clr_tms) ? "on" : "off", in snd_hdspm_proc_read_madi()
4950 (hdspm->control_register & HDSPM_TX_64ch) ? "64" : "56", in snd_hdspm_proc_read_madi()
4951 (hdspm->control_register & HDSPM_AutoInp) ? "on" : "off"); in snd_hdspm_proc_read_madi()
4954 if (!(hdspm->control_register & HDSPM_ClockModeMaster)) in snd_hdspm_proc_read_madi()
4960 switch (hdspm_pref_sync_ref(hdspm)) { in snd_hdspm_proc_read_madi()
4981 hdspm->system_sample_rate); in snd_hdspm_proc_read_madi()
4995 switch (hdspm_autosync_ref(hdspm)) { in snd_hdspm_proc_read_madi()
5017 autosync_ref, hdspm_external_sample_rate(hdspm), in snd_hdspm_proc_read_madi()
5036 struct hdspm *hdspm = entry->private_data; in snd_hdspm_proc_read_aes32() local
5045 status = hdspm_read(hdspm, HDSPM_statusRegister); in snd_hdspm_proc_read_aes32()
5046 status2 = hdspm_read(hdspm, HDSPM_statusRegister2); in snd_hdspm_proc_read_aes32()
5047 timecode = hdspm_read(hdspm, HDSPM_timecodeRegister); in snd_hdspm_proc_read_aes32()
5050 hdspm->card_name, hdspm->card->number + 1, in snd_hdspm_proc_read_aes32()
5051 hdspm->firmware_rev); in snd_hdspm_proc_read_aes32()
5054 hdspm->irq, hdspm->port, (unsigned long)hdspm->iobase); in snd_hdspm_proc_read_aes32()
5063 hdspm->irq_count); in snd_hdspm_proc_read_aes32()
5070 (2 * (int)hdspm->period_bytes), in snd_hdspm_proc_read_aes32()
5072 (2 * (int)hdspm->period_bytes), in snd_hdspm_proc_read_aes32()
5073 (long) hdspm_hw_pointer(hdspm) * 4); in snd_hdspm_proc_read_aes32()
5077 hdspm_read(hdspm, HDSPM_midiStatusOut0) & 0xFF, in snd_hdspm_proc_read_aes32()
5078 hdspm_read(hdspm, HDSPM_midiStatusOut1) & 0xFF, in snd_hdspm_proc_read_aes32()
5079 hdspm_read(hdspm, HDSPM_midiStatusIn0) & 0xFF, in snd_hdspm_proc_read_aes32()
5080 hdspm_read(hdspm, HDSPM_midiStatusIn1) & 0xFF); in snd_hdspm_proc_read_aes32()
5083 hdspm_read(hdspm, HDSPM_midiStatusIn2) & 0xFF, in snd_hdspm_proc_read_aes32()
5084 hdspm_read(hdspm, HDSPM_midiStatusOut2) & 0xFF); in snd_hdspm_proc_read_aes32()
5088 hdspm->control_register, hdspm->control2_register, in snd_hdspm_proc_read_aes32()
5093 x = hdspm_get_latency(hdspm); in snd_hdspm_proc_read_aes32()
5097 x, (unsigned long) hdspm->period_bytes); in snd_hdspm_proc_read_aes32()
5100 (hdspm-> in snd_hdspm_proc_read_aes32()
5105 (hdspm-> in snd_hdspm_proc_read_aes32()
5107 (hdspm-> in snd_hdspm_proc_read_aes32()
5109 (hdspm-> in snd_hdspm_proc_read_aes32()
5113 pref_syncref = hdspm_pref_sync_ref(hdspm); in snd_hdspm_proc_read_aes32()
5121 hdspm->system_sample_rate); in snd_hdspm_proc_read_aes32()
5124 hdspm->control_register & HDSPM_DS_DoubleWire? in snd_hdspm_proc_read_aes32()
5127 hdspm->control_register & HDSPM_QS_DoubleWire? in snd_hdspm_proc_read_aes32()
5129 hdspm->control_register & HDSPM_QS_QuadWire? in snd_hdspm_proc_read_aes32()
5149 switch (hdspm_autosync_ref(hdspm)) { in snd_hdspm_proc_read_aes32()
5189 struct hdspm *hdspm = entry->private_data; in snd_hdspm_proc_read_raydat() local
5193 status1 = hdspm_read(hdspm, HDSPM_RD_STATUS_1); /* s1 */ in snd_hdspm_proc_read_raydat()
5194 status2 = hdspm_read(hdspm, HDSPM_RD_STATUS_2); /* freq */ in snd_hdspm_proc_read_raydat()
5195 status3 = hdspm_read(hdspm, HDSPM_RD_STATUS_3); /* s2 */ in snd_hdspm_proc_read_raydat()
5205 (hdspm_system_clock_mode(hdspm) == 0) ? "master" : "slave"); in snd_hdspm_proc_read_raydat()
5207 hdspm_get_system_sample_rate(hdspm)); in snd_hdspm_proc_read_raydat()
5247 struct hdspm *hdspm = entry->private_data; in snd_hdspm_proc_read_debug() local
5254 snd_iprintf(buffer, "%08X ", hdspm_read(hdspm, i + j)); in snd_hdspm_proc_read_debug()
5264 struct hdspm *hdspm = entry->private_data; in snd_hdspm_proc_ports_in() local
5269 for (i = 0; i < hdspm->max_channels_in; i++) { in snd_hdspm_proc_ports_in()
5270 snd_iprintf(buffer, "%d=%s\n", i+1, hdspm->port_names_in[i]); in snd_hdspm_proc_ports_in()
5277 struct hdspm *hdspm = entry->private_data; in snd_hdspm_proc_ports_out() local
5282 for (i = 0; i < hdspm->max_channels_out; i++) { in snd_hdspm_proc_ports_out()
5283 snd_iprintf(buffer, "%d=%s\n", i+1, hdspm->port_names_out[i]); in snd_hdspm_proc_ports_out()
5288 static void snd_hdspm_proc_init(struct hdspm *hdspm) in snd_hdspm_proc_init() argument
5292 if (!snd_card_proc_new(hdspm->card, "hdspm", &entry)) { in snd_hdspm_proc_init()
5293 switch (hdspm->io_type) { in snd_hdspm_proc_init()
5295 snd_info_set_text_ops(entry, hdspm, in snd_hdspm_proc_init()
5299 snd_info_set_text_ops(entry, hdspm, in snd_hdspm_proc_init()
5307 snd_info_set_text_ops(entry, hdspm, in snd_hdspm_proc_init()
5315 if (!snd_card_proc_new(hdspm->card, "ports.in", &entry)) { in snd_hdspm_proc_init()
5316 snd_info_set_text_ops(entry, hdspm, snd_hdspm_proc_ports_in); in snd_hdspm_proc_init()
5319 if (!snd_card_proc_new(hdspm->card, "ports.out", &entry)) { in snd_hdspm_proc_init()
5320 snd_info_set_text_ops(entry, hdspm, snd_hdspm_proc_ports_out); in snd_hdspm_proc_init()
5325 if (!snd_card_proc_new(hdspm->card, "debug", &entry)) in snd_hdspm_proc_init()
5326 snd_info_set_text_ops(entry, hdspm, in snd_hdspm_proc_init()
5335 static int snd_hdspm_set_defaults(struct hdspm * hdspm) in snd_hdspm_set_defaults() argument
5343 hdspm->settings_register = 0; in snd_hdspm_set_defaults()
5345 switch (hdspm->io_type) { in snd_hdspm_set_defaults()
5348 hdspm->control_register = in snd_hdspm_set_defaults()
5354 hdspm->settings_register = 0x1 + 0x1000; in snd_hdspm_set_defaults()
5357 hdspm->control_register = in snd_hdspm_set_defaults()
5362 hdspm->control_register = in snd_hdspm_set_defaults()
5371 hdspm_write(hdspm, HDSPM_controlRegister, hdspm->control_register); in snd_hdspm_set_defaults()
5373 if (AES32 == hdspm->io_type) { in snd_hdspm_set_defaults()
5376 hdspm->control2_register = HDSPM_BIGENDIAN_MODE; in snd_hdspm_set_defaults()
5378 hdspm->control2_register = 0; in snd_hdspm_set_defaults()
5381 hdspm_write(hdspm, HDSPM_control2Reg, hdspm->control2_register); in snd_hdspm_set_defaults()
5383 hdspm_compute_period_size(hdspm); in snd_hdspm_set_defaults()
5387 all_in_all_mixer(hdspm, 0 * UNITY_GAIN); in snd_hdspm_set_defaults()
5389 if (hdspm_is_raydat_or_aio(hdspm)) in snd_hdspm_set_defaults()
5390 hdspm_write(hdspm, HDSPM_WR_SETTINGS, hdspm->settings_register); in snd_hdspm_set_defaults()
5393 hdspm_set_rate(hdspm, 48000, 1); in snd_hdspm_set_defaults()
5405 struct hdspm *hdspm = (struct hdspm *) dev_id; in snd_hdspm_interrupt() local
5410 status = hdspm_read(hdspm, HDSPM_statusRegister); in snd_hdspm_interrupt()
5436 hdspm_write(hdspm, HDSPM_interruptConfirmation, 0); in snd_hdspm_interrupt()
5437 hdspm->irq_count++; in snd_hdspm_interrupt()
5441 if (hdspm->capture_substream) in snd_hdspm_interrupt()
5442 snd_pcm_period_elapsed(hdspm->capture_substream); in snd_hdspm_interrupt()
5444 if (hdspm->playback_substream) in snd_hdspm_interrupt()
5445 snd_pcm_period_elapsed(hdspm->playback_substream); in snd_hdspm_interrupt()
5450 while (i < hdspm->midiPorts) { in snd_hdspm_interrupt()
5451 if ((hdspm_read(hdspm, in snd_hdspm_interrupt()
5452 hdspm->midi[i].statusIn) & 0xff) && in snd_hdspm_interrupt()
5453 (status & hdspm->midi[i].irq)) { in snd_hdspm_interrupt()
5457 hdspm->control_register &= ~hdspm->midi[i].ie; in snd_hdspm_interrupt()
5458 hdspm_write(hdspm, HDSPM_controlRegister, in snd_hdspm_interrupt()
5459 hdspm->control_register); in snd_hdspm_interrupt()
5460 hdspm->midi[i].pending = 1; in snd_hdspm_interrupt()
5468 tasklet_hi_schedule(&hdspm->midi_tasklet); in snd_hdspm_interrupt()
5482 struct hdspm *hdspm = snd_pcm_substream_chip(substream); in snd_hdspm_hw_pointer() local
5483 return hdspm_hw_pointer(hdspm); in snd_hdspm_hw_pointer()
5490 struct hdspm *hdspm = snd_pcm_substream_chip(substream); in snd_hdspm_reset() local
5494 other = hdspm->capture_substream; in snd_hdspm_reset()
5496 other = hdspm->playback_substream; in snd_hdspm_reset()
5498 if (hdspm->running) in snd_hdspm_reset()
5499 runtime->status->hw_ptr = hdspm_hw_pointer(hdspm); in snd_hdspm_reset()
5519 struct hdspm *hdspm = snd_pcm_substream_chip(substream); in snd_hdspm_hw_params() local
5525 spin_lock_irq(&hdspm->lock); in snd_hdspm_hw_params()
5528 this_pid = hdspm->playback_pid; in snd_hdspm_hw_params()
5529 other_pid = hdspm->capture_pid; in snd_hdspm_hw_params()
5531 this_pid = hdspm->capture_pid; in snd_hdspm_hw_params()
5532 other_pid = hdspm->playback_pid; in snd_hdspm_hw_params()
5542 if (params_rate(params) != hdspm->system_sample_rate) { in snd_hdspm_hw_params()
5543 spin_unlock_irq(&hdspm->lock); in snd_hdspm_hw_params()
5549 if (params_period_size(params) != hdspm->period_bytes / 4) { in snd_hdspm_hw_params()
5550 spin_unlock_irq(&hdspm->lock); in snd_hdspm_hw_params()
5558 spin_unlock_irq(&hdspm->lock); in snd_hdspm_hw_params()
5562 spin_lock_irq(&hdspm->lock); in snd_hdspm_hw_params()
5563 err = hdspm_set_rate(hdspm, params_rate(params), 0); in snd_hdspm_hw_params()
5565 dev_info(hdspm->card->dev, "err on hdspm_set_rate: %d\n", err); in snd_hdspm_hw_params()
5566 spin_unlock_irq(&hdspm->lock); in snd_hdspm_hw_params()
5571 spin_unlock_irq(&hdspm->lock); in snd_hdspm_hw_params()
5573 err = hdspm_set_interrupt_interval(hdspm, in snd_hdspm_hw_params()
5576 dev_info(hdspm->card->dev, in snd_hdspm_hw_params()
5593 dev_info(hdspm->card->dev, in snd_hdspm_hw_params()
5600 hdspm_set_sgbuf(hdspm, substream, HDSPM_pageAddressBufferOut, in snd_hdspm_hw_params()
5604 snd_hdspm_enable_out(hdspm, i, 1); in snd_hdspm_hw_params()
5606 hdspm->playback_buffer = in snd_hdspm_hw_params()
5608 dev_dbg(hdspm->card->dev, in snd_hdspm_hw_params()
5610 hdspm->playback_buffer); in snd_hdspm_hw_params()
5612 hdspm_set_sgbuf(hdspm, substream, HDSPM_pageAddressBufferIn, in snd_hdspm_hw_params()
5616 snd_hdspm_enable_in(hdspm, i, 1); in snd_hdspm_hw_params()
5618 hdspm->capture_buffer = in snd_hdspm_hw_params()
5620 dev_dbg(hdspm->card->dev, in snd_hdspm_hw_params()
5622 hdspm->capture_buffer); in snd_hdspm_hw_params()
5647 if (hdspm->io_type == AES32) { in snd_hdspm_hw_params()
5654 if (!(hdspm->control_register & HDSPe_FLOAT_FORMAT)) in snd_hdspm_hw_params()
5655 dev_info(hdspm->card->dev, in snd_hdspm_hw_params()
5658 hdspm->control_register |= HDSPe_FLOAT_FORMAT; in snd_hdspm_hw_params()
5660 if (hdspm->control_register & HDSPe_FLOAT_FORMAT) in snd_hdspm_hw_params()
5661 dev_info(hdspm->card->dev, in snd_hdspm_hw_params()
5664 hdspm->control_register &= ~HDSPe_FLOAT_FORMAT; in snd_hdspm_hw_params()
5666 hdspm_write(hdspm, HDSPM_controlRegister, hdspm->control_register); in snd_hdspm_hw_params()
5674 struct hdspm *hdspm = snd_pcm_substream_chip(substream); in snd_hdspm_hw_free() local
5680 for (i = 0; i < hdspm->max_channels_out; ++i) in snd_hdspm_hw_free()
5681 snd_hdspm_enable_out(hdspm, i, 0); in snd_hdspm_hw_free()
5683 hdspm->playback_buffer = NULL; in snd_hdspm_hw_free()
5685 for (i = 0; i < hdspm->max_channels_in; ++i) in snd_hdspm_hw_free()
5686 snd_hdspm_enable_in(hdspm, i, 0); in snd_hdspm_hw_free()
5688 hdspm->capture_buffer = NULL; in snd_hdspm_hw_free()
5701 struct hdspm *hdspm = snd_pcm_substream_chip(substream); in snd_hdspm_channel_info() local
5705 if (snd_BUG_ON(channel >= hdspm->max_channels_out)) { in snd_hdspm_channel_info()
5706 dev_info(hdspm->card->dev, in snd_hdspm_channel_info()
5712 channel = array_index_nospec(channel, hdspm->max_channels_out); in snd_hdspm_channel_info()
5713 if (hdspm->channel_map_out[channel] < 0) { in snd_hdspm_channel_info()
5714 dev_info(hdspm->card->dev, in snd_hdspm_channel_info()
5720 info->offset = hdspm->channel_map_out[channel] * in snd_hdspm_channel_info()
5723 if (snd_BUG_ON(channel >= hdspm->max_channels_in)) { in snd_hdspm_channel_info()
5724 dev_info(hdspm->card->dev, in snd_hdspm_channel_info()
5730 channel = array_index_nospec(channel, hdspm->max_channels_in); in snd_hdspm_channel_info()
5731 if (hdspm->channel_map_in[channel] < 0) { in snd_hdspm_channel_info()
5732 dev_info(hdspm->card->dev, in snd_hdspm_channel_info()
5738 info->offset = hdspm->channel_map_in[channel] * in snd_hdspm_channel_info()
5769 struct hdspm *hdspm = snd_pcm_substream_chip(substream); in snd_hdspm_trigger() local
5773 spin_lock(&hdspm->lock); in snd_hdspm_trigger()
5774 running = hdspm->running; in snd_hdspm_trigger()
5784 spin_unlock(&hdspm->lock); in snd_hdspm_trigger()
5788 other = hdspm->capture_substream; in snd_hdspm_trigger()
5790 other = hdspm->playback_substream; in snd_hdspm_trigger()
5808 hdspm_silence_playback(hdspm); in snd_hdspm_trigger()
5812 hdspm_silence_playback(hdspm); in snd_hdspm_trigger()
5816 hdspm_silence_playback(hdspm); in snd_hdspm_trigger()
5820 if (!hdspm->running && running) in snd_hdspm_trigger()
5821 hdspm_start_audio(hdspm); in snd_hdspm_trigger()
5822 else if (hdspm->running && !running) in snd_hdspm_trigger()
5823 hdspm_stop_audio(hdspm); in snd_hdspm_trigger()
5824 hdspm->running = running; in snd_hdspm_trigger()
5825 spin_unlock(&hdspm->lock); in snd_hdspm_trigger()
5888 struct hdspm *hdspm = rule->private; in snd_hdspm_hw_rule_in_channels_rate() local
5896 .min = hdspm->qs_in_channels, in snd_hdspm_hw_rule_in_channels_rate()
5897 .max = hdspm->qs_in_channels, in snd_hdspm_hw_rule_in_channels_rate()
5903 .min = hdspm->ds_in_channels, in snd_hdspm_hw_rule_in_channels_rate()
5904 .max = hdspm->ds_in_channels, in snd_hdspm_hw_rule_in_channels_rate()
5910 .min = hdspm->ss_in_channels, in snd_hdspm_hw_rule_in_channels_rate()
5911 .max = hdspm->ss_in_channels, in snd_hdspm_hw_rule_in_channels_rate()
5923 struct hdspm *hdspm = rule->private; in snd_hdspm_hw_rule_out_channels_rate() local
5931 .min = hdspm->qs_out_channels, in snd_hdspm_hw_rule_out_channels_rate()
5932 .max = hdspm->qs_out_channels, in snd_hdspm_hw_rule_out_channels_rate()
5938 .min = hdspm->ds_out_channels, in snd_hdspm_hw_rule_out_channels_rate()
5939 .max = hdspm->ds_out_channels, in snd_hdspm_hw_rule_out_channels_rate()
5945 .min = hdspm->ss_out_channels, in snd_hdspm_hw_rule_out_channels_rate()
5946 .max = hdspm->ss_out_channels, in snd_hdspm_hw_rule_out_channels_rate()
5958 struct hdspm *hdspm = rule->private; in snd_hdspm_hw_rule_rate_in_channels() local
5964 if (c->min >= hdspm->ss_in_channels) { in snd_hdspm_hw_rule_rate_in_channels()
5971 } else if (c->max <= hdspm->qs_in_channels) { in snd_hdspm_hw_rule_rate_in_channels()
5978 } else if (c->max <= hdspm->ds_in_channels) { in snd_hdspm_hw_rule_rate_in_channels()
5992 struct hdspm *hdspm = rule->private; in snd_hdspm_hw_rule_rate_out_channels() local
5998 if (c->min >= hdspm->ss_out_channels) { in snd_hdspm_hw_rule_rate_out_channels()
6005 } else if (c->max <= hdspm->qs_out_channels) { in snd_hdspm_hw_rule_rate_out_channels()
6012 } else if (c->max <= hdspm->ds_out_channels) { in snd_hdspm_hw_rule_rate_out_channels()
6028 struct hdspm *hdspm = rule->private; in snd_hdspm_hw_rule_in_channels() local
6032 list[0] = hdspm->qs_in_channels; in snd_hdspm_hw_rule_in_channels()
6033 list[1] = hdspm->ds_in_channels; in snd_hdspm_hw_rule_in_channels()
6034 list[2] = hdspm->ss_in_channels; in snd_hdspm_hw_rule_in_channels()
6042 struct hdspm *hdspm = rule->private; in snd_hdspm_hw_rule_out_channels() local
6046 list[0] = hdspm->qs_out_channels; in snd_hdspm_hw_rule_out_channels()
6047 list[1] = hdspm->ds_out_channels; in snd_hdspm_hw_rule_out_channels()
6048 list[2] = hdspm->ss_out_channels; in snd_hdspm_hw_rule_out_channels()
6066 struct hdspm *hdspm = snd_pcm_substream_chip(substream); in snd_hdspm_open() local
6070 spin_lock_irq(&hdspm->lock); in snd_hdspm_open()
6076 if (!hdspm->capture_substream) in snd_hdspm_open()
6077 hdspm_stop_audio(hdspm); in snd_hdspm_open()
6079 hdspm->playback_pid = current->pid; in snd_hdspm_open()
6080 hdspm->playback_substream = substream; in snd_hdspm_open()
6082 if (!hdspm->playback_substream) in snd_hdspm_open()
6083 hdspm_stop_audio(hdspm); in snd_hdspm_open()
6085 hdspm->capture_pid = current->pid; in snd_hdspm_open()
6086 hdspm->capture_substream = substream; in snd_hdspm_open()
6089 spin_unlock_irq(&hdspm->lock); in snd_hdspm_open()
6094 switch (hdspm->io_type) { in snd_hdspm_open()
6115 if (AES32 == hdspm->io_type) { in snd_hdspm_open()
6123 snd_hdspm_hw_rule_rate_in_channels), hdspm, in snd_hdspm_open()
6129 snd_hdspm_hw_rule_in_channels), hdspm, in snd_hdspm_open()
6134 snd_hdspm_hw_rule_in_channels_rate), hdspm, in snd_hdspm_open()
6142 struct hdspm *hdspm = snd_pcm_substream_chip(substream); in snd_hdspm_release() local
6145 spin_lock_irq(&hdspm->lock); in snd_hdspm_release()
6148 hdspm->playback_pid = -1; in snd_hdspm_release()
6149 hdspm->playback_substream = NULL; in snd_hdspm_release()
6151 hdspm->capture_pid = -1; in snd_hdspm_release()
6152 hdspm->capture_substream = NULL; in snd_hdspm_release()
6155 spin_unlock_irq(&hdspm->lock); in snd_hdspm_release()
6176 struct hdspm *hdspm = hw->private_data; in snd_hdspm_hwdep_ioctl() local
6190 levels = &hdspm->peak_rms; in snd_hdspm_hwdep_ioctl()
6193 readl(hdspm->iobase + in snd_hdspm_hwdep_ioctl()
6196 readl(hdspm->iobase + in snd_hdspm_hwdep_ioctl()
6199 readl(hdspm->iobase + in snd_hdspm_hwdep_ioctl()
6203 ((uint64_t) readl(hdspm->iobase + in snd_hdspm_hwdep_ioctl()
6205 (uint64_t) readl(hdspm->iobase + in snd_hdspm_hwdep_ioctl()
6208 ((uint64_t)readl(hdspm->iobase + in snd_hdspm_hwdep_ioctl()
6210 (uint64_t)readl(hdspm->iobase + in snd_hdspm_hwdep_ioctl()
6213 ((uint64_t)readl(hdspm->iobase + in snd_hdspm_hwdep_ioctl()
6215 (uint64_t)readl(hdspm->iobase + in snd_hdspm_hwdep_ioctl()
6219 if (hdspm->system_sample_rate > 96000) { in snd_hdspm_hwdep_ioctl()
6221 } else if (hdspm->system_sample_rate > 48000) { in snd_hdspm_hwdep_ioctl()
6226 levels->status2 = hdspm_read(hdspm, HDSPM_statusRegister2); in snd_hdspm_hwdep_ioctl()
6238 ltc.ltc = hdspm_read(hdspm, HDSPM_RD_TCO); in snd_hdspm_hwdep_ioctl()
6239 i = hdspm_read(hdspm, HDSPM_RD_TCO + 4); in snd_hdspm_hwdep_ioctl()
6285 spin_lock_irq(&hdspm->lock); in snd_hdspm_hwdep_ioctl()
6286 info.pref_sync_ref = hdspm_pref_sync_ref(hdspm); in snd_hdspm_hwdep_ioctl()
6287 info.wordclock_sync_check = hdspm_wc_sync_check(hdspm); in snd_hdspm_hwdep_ioctl()
6289 info.system_sample_rate = hdspm->system_sample_rate; in snd_hdspm_hwdep_ioctl()
6291 hdspm_external_sample_rate(hdspm); in snd_hdspm_hwdep_ioctl()
6292 info.system_clock_mode = hdspm_system_clock_mode(hdspm); in snd_hdspm_hwdep_ioctl()
6293 info.clock_source = hdspm_clock_source(hdspm); in snd_hdspm_hwdep_ioctl()
6294 info.autosync_ref = hdspm_autosync_ref(hdspm); in snd_hdspm_hwdep_ioctl()
6295 info.line_out = hdspm_toggle_setting(hdspm, HDSPM_LineOut); in snd_hdspm_hwdep_ioctl()
6297 spin_unlock_irq(&hdspm->lock); in snd_hdspm_hwdep_ioctl()
6305 status.card_type = hdspm->io_type; in snd_hdspm_hwdep_ioctl()
6307 status.autosync_source = hdspm_autosync_ref(hdspm); in snd_hdspm_hwdep_ioctl()
6310 status.master_period = hdspm_read(hdspm, HDSPM_RD_PLL_FREQ); in snd_hdspm_hwdep_ioctl()
6312 switch (hdspm->io_type) { in snd_hdspm_hwdep_ioctl()
6316 hdspm_wc_sync_check(hdspm); in snd_hdspm_hwdep_ioctl()
6318 hdspm_madi_sync_check(hdspm); in snd_hdspm_hwdep_ioctl()
6320 hdspm_tco_sync_check(hdspm); in snd_hdspm_hwdep_ioctl()
6322 hdspm_sync_in_sync_check(hdspm); in snd_hdspm_hwdep_ioctl()
6325 hdspm_read(hdspm, HDSPM_statusRegister); in snd_hdspm_hwdep_ioctl()
6346 hdspm_version.card_type = hdspm->io_type; in snd_hdspm_hwdep_ioctl()
6347 strlcpy(hdspm_version.cardname, hdspm->card_name, in snd_hdspm_hwdep_ioctl()
6349 hdspm_version.serial = hdspm->serial; in snd_hdspm_hwdep_ioctl()
6350 hdspm_version.firmware_rev = hdspm->firmware_rev; in snd_hdspm_hwdep_ioctl()
6352 if (hdspm->tco) in snd_hdspm_hwdep_ioctl()
6363 if (copy_to_user((void __user *)mixer.mixer, hdspm->mixer, in snd_hdspm_hwdep_ioctl()
6387 struct hdspm *hdspm) in snd_hdspm_create_hwdep() argument
6396 hdspm->hwdep = hw; in snd_hdspm_create_hwdep()
6397 hw->private_data = hdspm; in snd_hdspm_create_hwdep()
6412 static int snd_hdspm_preallocate_memory(struct hdspm *hdspm) in snd_hdspm_preallocate_memory() argument
6418 pcm = hdspm->pcm; in snd_hdspm_preallocate_memory()
6425 snd_dma_pci_data(hdspm->pci), in snd_hdspm_preallocate_memory()
6429 dev_dbg(hdspm->card->dev, in snd_hdspm_preallocate_memory()
6434 dev_dbg(hdspm->card->dev, in snd_hdspm_preallocate_memory()
6441 static void hdspm_set_sgbuf(struct hdspm *hdspm, in hdspm_set_sgbuf() argument
6449 hdspm_write(hdspm, reg + 4 * i, in hdspm_set_sgbuf()
6456 struct hdspm *hdspm) in snd_hdspm_create_pcm() argument
6461 err = snd_pcm_new(card, hdspm->card_name, 0, 1, 1, &pcm); in snd_hdspm_create_pcm()
6465 hdspm->pcm = pcm; in snd_hdspm_create_pcm()
6466 pcm->private_data = hdspm; in snd_hdspm_create_pcm()
6467 strcpy(pcm->name, hdspm->card_name); in snd_hdspm_create_pcm()
6476 err = snd_hdspm_preallocate_memory(hdspm); in snd_hdspm_create_pcm()
6483 static inline void snd_hdspm_initialize_midi_flush(struct hdspm * hdspm) in snd_hdspm_initialize_midi_flush() argument
6487 for (i = 0; i < hdspm->midiPorts; i++) in snd_hdspm_initialize_midi_flush()
6488 snd_hdspm_flush_midi_input(hdspm, i); in snd_hdspm_initialize_midi_flush()
6492 struct hdspm *hdspm) in snd_hdspm_create_alsa_devices() argument
6497 err = snd_hdspm_create_pcm(card, hdspm); in snd_hdspm_create_alsa_devices()
6502 while (i < hdspm->midiPorts) { in snd_hdspm_create_alsa_devices()
6503 err = snd_hdspm_create_midi(card, hdspm, i); in snd_hdspm_create_alsa_devices()
6510 err = snd_hdspm_create_controls(card, hdspm); in snd_hdspm_create_alsa_devices()
6514 err = snd_hdspm_create_hwdep(card, hdspm); in snd_hdspm_create_alsa_devices()
6519 snd_hdspm_proc_init(hdspm); in snd_hdspm_create_alsa_devices()
6521 hdspm->system_sample_rate = -1; in snd_hdspm_create_alsa_devices()
6522 hdspm->last_external_sample_rate = -1; in snd_hdspm_create_alsa_devices()
6523 hdspm->last_internal_sample_rate = -1; in snd_hdspm_create_alsa_devices()
6524 hdspm->playback_pid = -1; in snd_hdspm_create_alsa_devices()
6525 hdspm->capture_pid = -1; in snd_hdspm_create_alsa_devices()
6526 hdspm->capture_substream = NULL; in snd_hdspm_create_alsa_devices()
6527 hdspm->playback_substream = NULL; in snd_hdspm_create_alsa_devices()
6530 err = snd_hdspm_set_defaults(hdspm); in snd_hdspm_create_alsa_devices()
6535 hdspm_update_simple_mixer_controls(hdspm); in snd_hdspm_create_alsa_devices()
6551 struct hdspm *hdspm) in snd_hdspm_create() argument
6554 struct pci_dev *pci = hdspm->pci; in snd_hdspm_create()
6558 hdspm->irq = -1; in snd_hdspm_create()
6559 hdspm->card = card; in snd_hdspm_create()
6561 spin_lock_init(&hdspm->lock); in snd_hdspm_create()
6563 pci_read_config_word(hdspm->pci, in snd_hdspm_create()
6564 PCI_CLASS_REVISION, &hdspm->firmware_rev); in snd_hdspm_create()
6569 switch (hdspm->firmware_rev) { in snd_hdspm_create()
6571 hdspm->io_type = RayDAT; in snd_hdspm_create()
6572 hdspm->card_name = "RME RayDAT"; in snd_hdspm_create()
6573 hdspm->midiPorts = 2; in snd_hdspm_create()
6576 hdspm->io_type = AIO; in snd_hdspm_create()
6577 hdspm->card_name = "RME AIO"; in snd_hdspm_create()
6578 hdspm->midiPorts = 1; in snd_hdspm_create()
6581 hdspm->io_type = MADIface; in snd_hdspm_create()
6582 hdspm->card_name = "RME MADIface"; in snd_hdspm_create()
6583 hdspm->midiPorts = 1; in snd_hdspm_create()
6586 if ((hdspm->firmware_rev == 0xf0) || in snd_hdspm_create()
6587 ((hdspm->firmware_rev >= 0xe6) && in snd_hdspm_create()
6588 (hdspm->firmware_rev <= 0xea))) { in snd_hdspm_create()
6589 hdspm->io_type = AES32; in snd_hdspm_create()
6590 hdspm->card_name = "RME AES32"; in snd_hdspm_create()
6591 hdspm->midiPorts = 2; in snd_hdspm_create()
6592 } else if ((hdspm->firmware_rev == 0xd2) || in snd_hdspm_create()
6593 ((hdspm->firmware_rev >= 0xc8) && in snd_hdspm_create()
6594 (hdspm->firmware_rev <= 0xcf))) { in snd_hdspm_create()
6595 hdspm->io_type = MADI; in snd_hdspm_create()
6596 hdspm->card_name = "RME MADI"; in snd_hdspm_create()
6597 hdspm->midiPorts = 3; in snd_hdspm_create()
6601 hdspm->firmware_rev); in snd_hdspm_create()
6610 pci_set_master(hdspm->pci); in snd_hdspm_create()
6616 hdspm->port = pci_resource_start(pci, 0); in snd_hdspm_create()
6620 hdspm->port, hdspm->port + io_extent - 1); in snd_hdspm_create()
6622 hdspm->iobase = ioremap_nocache(hdspm->port, io_extent); in snd_hdspm_create()
6623 if (!hdspm->iobase) { in snd_hdspm_create()
6625 hdspm->port, hdspm->port + io_extent - 1); in snd_hdspm_create()
6629 (unsigned long)hdspm->iobase, hdspm->port, in snd_hdspm_create()
6630 hdspm->port + io_extent - 1); in snd_hdspm_create()
6633 IRQF_SHARED, KBUILD_MODNAME, hdspm)) { in snd_hdspm_create()
6640 hdspm->irq = pci->irq; in snd_hdspm_create()
6643 sizeof(*hdspm->mixer)); in snd_hdspm_create()
6644 hdspm->mixer = kzalloc(sizeof(*hdspm->mixer), GFP_KERNEL); in snd_hdspm_create()
6645 if (!hdspm->mixer) in snd_hdspm_create()
6648 hdspm->port_names_in = NULL; in snd_hdspm_create()
6649 hdspm->port_names_out = NULL; in snd_hdspm_create()
6651 switch (hdspm->io_type) { in snd_hdspm_create()
6653 hdspm->ss_in_channels = hdspm->ss_out_channels = AES32_CHANNELS; in snd_hdspm_create()
6654 hdspm->ds_in_channels = hdspm->ds_out_channels = AES32_CHANNELS; in snd_hdspm_create()
6655 hdspm->qs_in_channels = hdspm->qs_out_channels = AES32_CHANNELS; in snd_hdspm_create()
6657 hdspm->channel_map_in_ss = hdspm->channel_map_out_ss = in snd_hdspm_create()
6659 hdspm->channel_map_in_ds = hdspm->channel_map_out_ds = in snd_hdspm_create()
6661 hdspm->channel_map_in_qs = hdspm->channel_map_out_qs = in snd_hdspm_create()
6663 hdspm->port_names_in_ss = hdspm->port_names_out_ss = in snd_hdspm_create()
6665 hdspm->port_names_in_ds = hdspm->port_names_out_ds = in snd_hdspm_create()
6667 hdspm->port_names_in_qs = hdspm->port_names_out_qs = in snd_hdspm_create()
6670 hdspm->max_channels_out = hdspm->max_channels_in = in snd_hdspm_create()
6672 hdspm->port_names_in = hdspm->port_names_out = in snd_hdspm_create()
6674 hdspm->channel_map_in = hdspm->channel_map_out = in snd_hdspm_create()
6681 hdspm->ss_in_channels = hdspm->ss_out_channels = in snd_hdspm_create()
6683 hdspm->ds_in_channels = hdspm->ds_out_channels = in snd_hdspm_create()
6685 hdspm->qs_in_channels = hdspm->qs_out_channels = in snd_hdspm_create()
6688 hdspm->channel_map_in_ss = hdspm->channel_map_out_ss = in snd_hdspm_create()
6690 hdspm->channel_map_in_ds = hdspm->channel_map_out_ds = in snd_hdspm_create()
6692 hdspm->channel_map_in_qs = hdspm->channel_map_out_qs = in snd_hdspm_create()
6695 hdspm->port_names_in_ss = hdspm->port_names_out_ss = in snd_hdspm_create()
6697 hdspm->port_names_in_ds = hdspm->port_names_out_ds = in snd_hdspm_create()
6699 hdspm->port_names_in_qs = hdspm->port_names_out_qs = in snd_hdspm_create()
6704 hdspm->ss_in_channels = AIO_IN_SS_CHANNELS; in snd_hdspm_create()
6705 hdspm->ds_in_channels = AIO_IN_DS_CHANNELS; in snd_hdspm_create()
6706 hdspm->qs_in_channels = AIO_IN_QS_CHANNELS; in snd_hdspm_create()
6707 hdspm->ss_out_channels = AIO_OUT_SS_CHANNELS; in snd_hdspm_create()
6708 hdspm->ds_out_channels = AIO_OUT_DS_CHANNELS; in snd_hdspm_create()
6709 hdspm->qs_out_channels = AIO_OUT_QS_CHANNELS; in snd_hdspm_create()
6711 if (0 == (hdspm_read(hdspm, HDSPM_statusRegister2) & HDSPM_s2_AEBI_D)) { in snd_hdspm_create()
6713 hdspm->ss_in_channels += 4; in snd_hdspm_create()
6714 hdspm->ds_in_channels += 4; in snd_hdspm_create()
6715 hdspm->qs_in_channels += 4; in snd_hdspm_create()
6718 if (0 == (hdspm_read(hdspm, HDSPM_statusRegister2) & HDSPM_s2_AEBO_D)) { in snd_hdspm_create()
6720 hdspm->ss_out_channels += 4; in snd_hdspm_create()
6721 hdspm->ds_out_channels += 4; in snd_hdspm_create()
6722 hdspm->qs_out_channels += 4; in snd_hdspm_create()
6725 hdspm->channel_map_out_ss = channel_map_aio_out_ss; in snd_hdspm_create()
6726 hdspm->channel_map_out_ds = channel_map_aio_out_ds; in snd_hdspm_create()
6727 hdspm->channel_map_out_qs = channel_map_aio_out_qs; in snd_hdspm_create()
6729 hdspm->channel_map_in_ss = channel_map_aio_in_ss; in snd_hdspm_create()
6730 hdspm->channel_map_in_ds = channel_map_aio_in_ds; in snd_hdspm_create()
6731 hdspm->channel_map_in_qs = channel_map_aio_in_qs; in snd_hdspm_create()
6733 hdspm->port_names_in_ss = texts_ports_aio_in_ss; in snd_hdspm_create()
6734 hdspm->port_names_out_ss = texts_ports_aio_out_ss; in snd_hdspm_create()
6735 hdspm->port_names_in_ds = texts_ports_aio_in_ds; in snd_hdspm_create()
6736 hdspm->port_names_out_ds = texts_ports_aio_out_ds; in snd_hdspm_create()
6737 hdspm->port_names_in_qs = texts_ports_aio_in_qs; in snd_hdspm_create()
6738 hdspm->port_names_out_qs = texts_ports_aio_out_qs; in snd_hdspm_create()
6743 hdspm->ss_in_channels = hdspm->ss_out_channels = in snd_hdspm_create()
6745 hdspm->ds_in_channels = hdspm->ds_out_channels = in snd_hdspm_create()
6747 hdspm->qs_in_channels = hdspm->qs_out_channels = in snd_hdspm_create()
6750 hdspm->max_channels_in = RAYDAT_SS_CHANNELS; in snd_hdspm_create()
6751 hdspm->max_channels_out = RAYDAT_SS_CHANNELS; in snd_hdspm_create()
6753 hdspm->channel_map_in_ss = hdspm->channel_map_out_ss = in snd_hdspm_create()
6755 hdspm->channel_map_in_ds = hdspm->channel_map_out_ds = in snd_hdspm_create()
6757 hdspm->channel_map_in_qs = hdspm->channel_map_out_qs = in snd_hdspm_create()
6759 hdspm->channel_map_in = hdspm->channel_map_out = in snd_hdspm_create()
6762 hdspm->port_names_in_ss = hdspm->port_names_out_ss = in snd_hdspm_create()
6764 hdspm->port_names_in_ds = hdspm->port_names_out_ds = in snd_hdspm_create()
6766 hdspm->port_names_in_qs = hdspm->port_names_out_qs = in snd_hdspm_create()
6775 switch (hdspm->io_type) { in snd_hdspm_create()
6778 if (hdspm_read(hdspm, HDSPM_statusRegister2) & in snd_hdspm_create()
6780 hdspm->midiPorts++; in snd_hdspm_create()
6781 hdspm->tco = kzalloc(sizeof(*hdspm->tco), GFP_KERNEL); in snd_hdspm_create()
6782 if (hdspm->tco) in snd_hdspm_create()
6783 hdspm_tco_write(hdspm); in snd_hdspm_create()
6787 hdspm->tco = NULL; in snd_hdspm_create()
6793 if (hdspm_read(hdspm, HDSPM_statusRegister) & HDSPM_tco_detect) { in snd_hdspm_create()
6794 hdspm->midiPorts++; in snd_hdspm_create()
6795 hdspm->tco = kzalloc(sizeof(*hdspm->tco), GFP_KERNEL); in snd_hdspm_create()
6796 if (hdspm->tco) in snd_hdspm_create()
6797 hdspm_tco_write(hdspm); in snd_hdspm_create()
6801 hdspm->tco = NULL; in snd_hdspm_create()
6806 hdspm->tco = NULL; in snd_hdspm_create()
6810 switch (hdspm->io_type) { in snd_hdspm_create()
6812 if (hdspm->tco) { in snd_hdspm_create()
6813 hdspm->texts_autosync = texts_autosync_aes_tco; in snd_hdspm_create()
6814 hdspm->texts_autosync_items = in snd_hdspm_create()
6817 hdspm->texts_autosync = texts_autosync_aes; in snd_hdspm_create()
6818 hdspm->texts_autosync_items = in snd_hdspm_create()
6824 if (hdspm->tco) { in snd_hdspm_create()
6825 hdspm->texts_autosync = texts_autosync_madi_tco; in snd_hdspm_create()
6826 hdspm->texts_autosync_items = 4; in snd_hdspm_create()
6828 hdspm->texts_autosync = texts_autosync_madi; in snd_hdspm_create()
6829 hdspm->texts_autosync_items = 3; in snd_hdspm_create()
6838 if (hdspm->tco) { in snd_hdspm_create()
6839 hdspm->texts_autosync = texts_autosync_raydat_tco; in snd_hdspm_create()
6840 hdspm->texts_autosync_items = 9; in snd_hdspm_create()
6842 hdspm->texts_autosync = texts_autosync_raydat; in snd_hdspm_create()
6843 hdspm->texts_autosync_items = 8; in snd_hdspm_create()
6848 if (hdspm->tco) { in snd_hdspm_create()
6849 hdspm->texts_autosync = texts_autosync_aio_tco; in snd_hdspm_create()
6850 hdspm->texts_autosync_items = 6; in snd_hdspm_create()
6852 hdspm->texts_autosync = texts_autosync_aio; in snd_hdspm_create()
6853 hdspm->texts_autosync_items = 5; in snd_hdspm_create()
6859 tasklet_init(&hdspm->midi_tasklet, in snd_hdspm_create()
6860 hdspm_midi_tasklet, (unsigned long) hdspm); in snd_hdspm_create()
6863 if (hdspm->io_type != MADIface) { in snd_hdspm_create()
6864 hdspm->serial = (hdspm_read(hdspm, in snd_hdspm_create()
6875 if (!id[hdspm->dev] && hdspm->serial != 0xFFFFFF) { in snd_hdspm_create()
6877 "HDSPMx%06x", hdspm->serial); in snd_hdspm_create()
6883 err = snd_hdspm_create_alsa_devices(card, hdspm); in snd_hdspm_create()
6887 snd_hdspm_initialize_midi_flush(hdspm); in snd_hdspm_create()
6893 static int snd_hdspm_free(struct hdspm * hdspm) in snd_hdspm_free() argument
6896 if (hdspm->port) { in snd_hdspm_free()
6899 hdspm->control_register &= in snd_hdspm_free()
6903 hdspm_write(hdspm, HDSPM_controlRegister, in snd_hdspm_free()
6904 hdspm->control_register); in snd_hdspm_free()
6907 if (hdspm->irq >= 0) in snd_hdspm_free()
6908 free_irq(hdspm->irq, (void *) hdspm); in snd_hdspm_free()
6910 kfree(hdspm->mixer); in snd_hdspm_free()
6911 iounmap(hdspm->iobase); in snd_hdspm_free()
6913 if (hdspm->port) in snd_hdspm_free()
6914 pci_release_regions(hdspm->pci); in snd_hdspm_free()
6916 pci_disable_device(hdspm->pci); in snd_hdspm_free()
6923 struct hdspm *hdspm = card->private_data; in snd_hdspm_card_free() local
6925 if (hdspm) in snd_hdspm_card_free()
6926 snd_hdspm_free(hdspm); in snd_hdspm_card_free()
6934 struct hdspm *hdspm; in snd_hdspm_probe() local
6946 THIS_MODULE, sizeof(*hdspm), &card); in snd_hdspm_probe()
6950 hdspm = card->private_data; in snd_hdspm_probe()
6952 hdspm->dev = dev; in snd_hdspm_probe()
6953 hdspm->pci = pci; in snd_hdspm_probe()
6955 err = snd_hdspm_create(card, hdspm); in snd_hdspm_probe()
6959 if (hdspm->io_type != MADIface) { in snd_hdspm_probe()
6961 hdspm->card_name, hdspm->serial); in snd_hdspm_probe()
6964 hdspm->card_name, hdspm->serial, in snd_hdspm_probe()
6965 hdspm->port, hdspm->irq); in snd_hdspm_probe()
6968 hdspm->card_name); in snd_hdspm_probe()
6971 hdspm->card_name, hdspm->port, hdspm->irq); in snd_hdspm_probe()