32 #include <linux/pci.h>
35 #include <linux/slab.h>
36 #include <linux/time.h>
37 #include <linux/wait.h>
38 #include <linux/module.h>
53 #if defined CONFIG_SND_DEBUG_VERBOSE
62 #define snd_printddd(format, args...) \
63 __snd_printk(3, __FILE__, __LINE__, format, ##args)
65 #define snd_printddd(format, args...) do { } while (0)
71 static bool enable_hpi_hwdep = 1;
84 "ALSA enable HPI hwdep for AudioScience soundcard ");
87 #ifdef KERNEL_ALSA_BUILD
88 static char *build_info =
"Built using headers from kernel source";
92 static char *build_info =
"Built within ALSA source";
98 static const int mixer_dump;
100 #define DEFAULT_SAMPLERATE 44100
104 #define PERIODS_MIN 2
105 #define PERIOD_BYTES_MIN 2048
106 #define BUFFER_BYTES_MAX (512 * 1024)
108 #define MAX_CLOCKSOURCES (HPI_SAMPLECLOCK_SOURCE_LAST + 1 + 7)
162 static u16 hpi_stream_host_buffer_attach(
182 hm.u.d.u.buffer.buffer_size = size_in_bytes;
183 hm.u.d.u.buffer.pci_address = pci_address;
189 static u16 hpi_stream_host_buffer_detach(
u32 h_stream)
210 static inline u16 hpi_stream_start(
u32 h_stream)
218 static inline u16 hpi_stream_stop(
u32 h_stream)
226 static inline u16 hpi_stream_get_info_ex(
230 u32 *pdata_in_buffer,
238 pbuffer_size, pdata_in_buffer,
239 psample_count, pauxiliary_data);
242 pbuffer_size, pdata_in_buffer,
243 psample_count, pauxiliary_data);
247 static inline u16 hpi_stream_group_add(
257 static inline u16 hpi_stream_group_reset(
u32 h_stream)
265 static inline u16 hpi_stream_group_get_map(
278 "in file %s, line %d: HPI error %d\n",
279 filename, line, err);
283 #define hpi_handle_error(x) handle_error(x, __LINE__, __FILE__)
291 snd_pcm_debug_name(substream, name,
sizeof(name));
298 snd_printd(
" period %d B\n", params_period_bytes(p));
312 SNDRV_PCM_FORMAT_S16,
321 SNDRV_PCM_FORMAT_S32,
324 SNDRV_PCM_FORMAT_FLOAT,
343 if (hpi_to_alsa_formats[format] == alsa_format) {
355 static void snd_card_asihpi_pcm_samplerates(
struct snd_card_asihpi *asihpi,
362 unsigned int rate_min = 200000;
363 unsigned int rate_max = 0;
364 unsigned int rates = 0;
379 "No local sampleclock, err %d\n", err);
382 for (idx = -1; idx < 100; idx++) {
388 idx, &sample_rate)) {
392 rate_min =
min(rate_min, sample_rate);
393 rate_max =
max(rate_max, sample_rate);
395 switch (sample_rate) {
441 pcmhw->
rates = rates;
455 unsigned int bytes_per_sec;
457 print_hwparams(substream, params);
461 err = snd_card_asihpi_format_alsa2hpi(
params_format(params), &format);
480 err = hpi_stream_host_buffer_attach(dpcm->
h_stream,
484 "stream_host_buffer_attach succeeded %u %lu\n",
488 snd_printd(
"stream_host_buffer_attach error %d\n",
497 snd_printdd(
"stream_host_buffer_attach status 0x%x\n",
503 bytes_per_sec *=
width;
505 if (width < 0 || bytes_per_sec == 0)
521 hpi_stream_host_buffer_detach(dpcm->
h_stream);
527 static void snd_card_asihpi_runtime_free(
struct snd_pcm_runtime *runtime)
542 expiry =
max(expiry, 1);
566 snd_pcm_debug_name(substream, name,
sizeof(name));
602 e = hpi_stream_group_add(
606 snd_pcm_trigger_done(s, substream);
616 snd_card_asihpi_pcm_timer_start(substream);
623 snd_card_asihpi_pcm_timer_stop(substream);
637 snd_pcm_trigger_done(s, substream);
656 snd_card_asihpi_pcm_timer_start(substream);
660 snd_card_asihpi_pcm_timer_stop(substream);
702 static inline unsigned int modulo_min(
unsigned int a,
unsigned int b,
706 if (((a-b) % modulus) < (modulus/2))
716 static void snd_card_asihpi_timer_function(
unsigned long data)
723 unsigned int newdata = 0;
724 unsigned int pcm_buf_dma_ofs, min_buf_pos = 0;
725 unsigned int remdata, xfercount, next_jiffies;
732 snd_pcm_debug_name(substream, name,
sizeof(name));
734 snd_printdd(
"%s snd_card_asihpi_timer_function\n", name);
750 &buffer_size, &bytes_avail,
751 &samples_played, &on_card_bytes));
754 runtime->
delay = on_card_bytes;
757 on_card_bytes = bytes_avail;
762 if (bytes_avail == 0) {
788 modulo_min(min_buf_pos, pcm_buf_dma_ofs,
UINT_MAX+1L);
795 (
unsigned long)frames_to_bytes(runtime,
797 (
unsigned long)frames_to_bytes(runtime,
801 "rw=0x%04X, dma=0x%04X, left=0x%04X, "
802 "aux=0x%04X space=0x%04X\n",
806 (
int)on_card_bytes, buffer_size-bytes_avail);
809 pcm_buf_dma_ofs = min_buf_pos;
812 xfercount = newdata - remdata;
822 next_jiffies =
max(next_jiffies, 1
U);
824 snd_printdd(
"jif %d buf pos 0x%04X newdata 0x%04X xfer 0x%04X\n",
825 next_jiffies, pcm_buf_dma_ofs, newdata, xfercount);
844 unsigned int xfer1, xfer2;
845 char *
pd = &s->
runtime->dma_area[buf_ofs];
852 xfer2 = xfercount - xfer1;
857 s->
number, xfer1, buf_ofs);
868 xfercount - xfer1, buf_ofs);
904 unsigned int cmd,
void *
arg)
907 snd_pcm_debug_name(substream, name,
sizeof(name));
934 snd_pcm_debug_name(substream, name,
sizeof(name));
937 snd_printddd(
"%s pointer = 0x%04lx\n", name, (
unsigned long)ptr);
944 struct hpi_format hpi_format;
948 u32 sample_rate = 48000;
965 format, sample_rate, 128000, 0);
968 if (!err && (hpi_to_alsa_formats[format] != -1))
969 formats |= (1ULL << hpi_to_alsa_formats[
format]);
1002 dpcm->
timer.data = (
unsigned long) dpcm;
1003 dpcm->
timer.function = snd_card_asihpi_timer_function;
1008 memset(&snd_card_asihpi_playback, 0,
sizeof(snd_card_asihpi_playback));
1014 snd_card_asihpi_playback.periods_min =
PERIODS_MIN;
1017 snd_card_asihpi_playback.channels_max = card->
out_max_chans;
1018 snd_card_asihpi_playback.channels_min = card->
out_min_chans;
1019 snd_card_asihpi_playback.formats =
1020 snd_card_asihpi_playback_formats(card, dpcm->
h_stream);
1022 snd_card_asihpi_pcm_samplerates(card, &snd_card_asihpi_playback);
1038 runtime->
hw = snd_card_asihpi_playback;
1068 static struct snd_pcm_ops snd_card_asihpi_playback_mmap_ops = {
1069 .open = snd_card_asihpi_playback_open,
1070 .close = snd_card_asihpi_playback_close,
1071 .ioctl = snd_card_asihpi_playback_ioctl,
1072 .hw_params = snd_card_asihpi_pcm_hw_params,
1073 .hw_free = snd_card_asihpi_hw_free,
1074 .prepare = snd_card_asihpi_playback_prepare,
1075 .trigger = snd_card_asihpi_trigger,
1076 .pointer = snd_card_asihpi_playback_pointer,
1096 unsigned int cmd,
void *arg)
1120 struct hpi_format hpi_format;
1124 u32 sample_rate = 48000;
1141 format, sample_rate, 128000, 0);
1145 formats |= (1ULL << hpi_to_alsa_formats[
format]);
1162 snd_printdd(
"capture open adapter %d stream %d\n",
1163 card->
hpi->adapter->index, substream->
number);
1176 dpcm->
timer.data = (
unsigned long) dpcm;
1177 dpcm->
timer.function = snd_card_asihpi_timer_function;
1182 memset(&snd_card_asihpi_capture, 0,
sizeof(snd_card_asihpi_capture));
1186 snd_card_asihpi_capture.periods_min =
PERIODS_MIN;
1189 snd_card_asihpi_capture.channels_max = card->
in_max_chans;
1190 snd_card_asihpi_capture.channels_min = card->
in_min_chans;
1191 snd_card_asihpi_capture.formats =
1192 snd_card_asihpi_capture_formats(card, dpcm->
h_stream);
1193 snd_card_asihpi_pcm_samplerates(card, &snd_card_asihpi_capture);
1201 runtime->
hw = snd_card_asihpi_capture;
1227 static struct snd_pcm_ops snd_card_asihpi_capture_mmap_ops = {
1228 .open = snd_card_asihpi_capture_open,
1229 .close = snd_card_asihpi_capture_close,
1230 .ioctl = snd_card_asihpi_capture_ioctl,
1231 .hw_params = snd_card_asihpi_pcm_hw_params,
1232 .hw_free = snd_card_asihpi_hw_free,
1233 .prepare = snd_card_asihpi_capture_prepare,
1234 .trigger = snd_card_asihpi_trigger,
1235 .pointer = snd_card_asihpi_capture_pointer,
1238 static int __devinit snd_card_asihpi_pcm_new(
1243 u16 num_instreams, num_outstreams, x16;
1247 &num_outstreams, &num_instreams,
1251 num_outstreams, num_instreams, &pcm);
1256 &snd_card_asihpi_playback_mmap_ops);
1258 &snd_card_asihpi_capture_mmap_ops);
1285 static const char *
const asihpi_tuner_band_names[] = {
1301 assert_tuner_band_names_size);
1303 static const char *
const asihpi_src_names[] = {
1323 assert_src_names_size);
1325 static const char *
const asihpi_dst_names[] = {
1340 assert_dst_names_size);
1350 else if (mixer_dump)
1362 memset(snd_control, 0,
sizeof(*snd_control));
1366 snd_control->
index = 0;
1378 dir =
"Monitor Playback ";
1407 #define VOL_STEP_mB 1
1408 static int snd_asihpi_volume_info(
struct snd_kcontrol *kcontrol,
1420 &min_gain_mB, &max_gain_mB, &step_gain_mB);
1423 min_gain_mB = -10000;
1439 static int snd_asihpi_volume_get(
struct snd_kcontrol *kcontrol,
1452 static int snd_asihpi_volume_put(
struct snd_kcontrol *kcontrol,
1473 #define snd_asihpi_volume_mute_info snd_ctl_boolean_mono_info
1475 static int snd_asihpi_volume_mute_get(
struct snd_kcontrol *kcontrol,
1482 ucontrol->
value.integer.value[0] = mute ? 0 : 1;
1487 static int snd_asihpi_volume_mute_put(
struct snd_kcontrol *kcontrol,
1508 asihpi_ctl_init(&snd_control, hpi_ctl,
"Volume");
1511 snd_control.
info = snd_asihpi_volume_info;
1512 snd_control.
get = snd_asihpi_volume_get;
1513 snd_control.
put = snd_asihpi_volume_put;
1514 snd_control.
tlv.
p = db_scale_100;
1516 err = ctl_add(card, &snd_control, asihpi);
1521 asihpi_ctl_init(&snd_control, hpi_ctl,
"Switch");
1524 snd_control.
get = snd_asihpi_volume_mute_get;
1525 snd_control.
put = snd_asihpi_volume_mute_put;
1526 err = ctl_add(card, &snd_control, asihpi);
1534 static int snd_asihpi_level_info(
struct snd_kcontrol *kcontrol,
1545 &max_gain_mB, &step_gain_mB);
1548 min_gain_mB = -1000;
1560 static int snd_asihpi_level_get(
struct snd_kcontrol *kcontrol,
1567 ucontrol->
value.integer.value[0] =
1569 ucontrol->
value.integer.value[1] =
1575 static int snd_asihpi_level_put(
struct snd_kcontrol *kcontrol,
1603 asihpi_ctl_init(&snd_control, hpi_ctl,
"Level");
1606 snd_control.
info = snd_asihpi_level_info;
1607 snd_control.
get = snd_asihpi_level_get;
1608 snd_control.
put = snd_asihpi_level_put;
1609 snd_control.
tlv.
p = db_scale_level;
1611 return ctl_add(card, &snd_control, asihpi);
1619 static const char *
const asihpi_aesebu_format_names[] = {
1620 "N/A",
"S/PDIF",
"AES/EBU" };
1622 static int snd_asihpi_aesebu_format_info(
struct snd_kcontrol *kcontrol,
1639 static int snd_asihpi_aesebu_format_get(
struct snd_kcontrol *kcontrol,
1646 err =
func(h_control, &source);
1649 ucontrol->
value.enumerated.item[0] = 0;
1654 ucontrol->
value.enumerated.item[0] = 1;
1656 ucontrol->
value.enumerated.item[0] = 2;
1661 static int snd_asihpi_aesebu_format_put(
struct snd_kcontrol *kcontrol,
1670 if (ucontrol->
value.enumerated.item[0] == 1)
1672 if (ucontrol->
value.enumerated.item[0] == 2)
1675 if (
func(h_control, source) != 0)
1681 static int snd_asihpi_aesebu_rx_format_get(
struct snd_kcontrol *kcontrol,
1683 return snd_asihpi_aesebu_format_get(kcontrol, ucontrol,
1687 static int snd_asihpi_aesebu_rx_format_put(
struct snd_kcontrol *kcontrol,
1689 return snd_asihpi_aesebu_format_put(kcontrol, ucontrol,
1693 static int snd_asihpi_aesebu_rxstatus_info(
struct snd_kcontrol *kcontrol,
1706 static int snd_asihpi_aesebu_rxstatus_get(
struct snd_kcontrol *kcontrol,
1713 h_control, &status));
1724 asihpi_ctl_init(&snd_control, hpi_ctl,
"Format");
1726 snd_control.
info = snd_asihpi_aesebu_format_info;
1727 snd_control.
get = snd_asihpi_aesebu_rx_format_get;
1728 snd_control.
put = snd_asihpi_aesebu_rx_format_put;
1731 if (ctl_add(card, &snd_control, asihpi) < 0)
1734 asihpi_ctl_init(&snd_control, hpi_ctl,
"Status");
1737 snd_control.
info = snd_asihpi_aesebu_rxstatus_info;
1738 snd_control.
get = snd_asihpi_aesebu_rxstatus_get;
1740 return ctl_add(card, &snd_control, asihpi);
1743 static int snd_asihpi_aesebu_tx_format_get(
struct snd_kcontrol *kcontrol,
1745 return snd_asihpi_aesebu_format_get(kcontrol, ucontrol,
1749 static int snd_asihpi_aesebu_tx_format_put(
struct snd_kcontrol *kcontrol,
1751 return snd_asihpi_aesebu_format_put(kcontrol, ucontrol,
1762 asihpi_ctl_init(&snd_control, hpi_ctl,
"Format");
1764 snd_control.
info = snd_asihpi_aesebu_format_info;
1765 snd_control.
get = snd_asihpi_aesebu_tx_format_get;
1766 snd_control.
put = snd_asihpi_aesebu_tx_format_put;
1768 return ctl_add(card, &snd_control, asihpi);
1777 static int snd_asihpi_tuner_gain_info(
struct snd_kcontrol *kcontrol,
1785 for (idx = 0; idx < 3; idx++) {
1787 idx, &gain_range[idx]);
1800 static int snd_asihpi_tuner_gain_get(
struct snd_kcontrol *kcontrol,
1815 static int snd_asihpi_tuner_gain_put(
struct snd_kcontrol *kcontrol,
1832 static int asihpi_tuner_band_query(
struct snd_kcontrol *kcontrol,
1833 u16 *band_list,
u32 len) {
1838 for (i = 0; i < len; i++) {
1840 h_control, i, &band_list[i]);
1851 static int snd_asihpi_tuner_band_info(
struct snd_kcontrol *kcontrol,
1857 num_bands = asihpi_tuner_band_query(kcontrol, tuner_bands,
1867 if (num_bands > 0) {
1874 asihpi_tuner_band_names[
1881 static int snd_asihpi_tuner_band_get(
struct snd_kcontrol *kcontrol,
1892 num_bands = asihpi_tuner_band_query(kcontrol, tuner_bands,
1897 ucontrol->
value.enumerated.item[0] = -1;
1899 if (tuner_bands[idx] == band) {
1900 ucontrol->
value.enumerated.item[0] =
idx;
1907 static int snd_asihpi_tuner_band_put(
struct snd_kcontrol *kcontrol,
1918 num_bands = asihpi_tuner_band_query(kcontrol, tuner_bands,
1919 HPI_TUNER_BAND_LAST);
1921 band = tuner_bands[ucontrol->
value.enumerated.item[0]];
1929 static int snd_asihpi_tuner_freq_info(
struct snd_kcontrol *kcontrol,
1935 u16 num_bands = 0, band_iter,
idx;
1936 u32 freq_range[3], temp_freq_range[3];
1938 num_bands = asihpi_tuner_band_query(kcontrol, tuner_bands,
1939 HPI_TUNER_BAND_LAST);
1945 for (band_iter = 0; band_iter < num_bands; band_iter++) {
1946 for (idx = 0; idx < 3; idx++) {
1948 idx, tuner_bands[band_iter],
1949 &temp_freq_range[idx]);
1955 if (temp_freq_range[2] <= 0)
1958 if (temp_freq_range[0] < freq_range[0])
1959 freq_range[0] = temp_freq_range[0];
1960 if (temp_freq_range[1] > freq_range[1])
1961 freq_range[1] = temp_freq_range[1];
1962 if (temp_freq_range[2] < freq_range[2])
1963 freq_range[2] = temp_freq_range[2];
1974 static int snd_asihpi_tuner_freq_get(
struct snd_kcontrol *kcontrol,
1981 ucontrol->
value.integer.value[0] =
freq;
1986 static int snd_asihpi_tuner_freq_put(
struct snd_kcontrol *kcontrol,
1992 freq = ucontrol->
value.integer.value[0];
2009 asihpi_ctl_init(&snd_control, hpi_ctl,
"Gain");
2010 snd_control.
info = snd_asihpi_tuner_gain_info;
2011 snd_control.
get = snd_asihpi_tuner_gain_get;
2012 snd_control.
put = snd_asihpi_tuner_gain_put;
2014 if (ctl_add(card, &snd_control, asihpi) < 0)
2018 asihpi_ctl_init(&snd_control, hpi_ctl,
"Band");
2019 snd_control.
info = snd_asihpi_tuner_band_info;
2020 snd_control.
get = snd_asihpi_tuner_band_get;
2021 snd_control.
put = snd_asihpi_tuner_band_put;
2023 if (ctl_add(card, &snd_control, asihpi) < 0)
2026 asihpi_ctl_init(&snd_control, hpi_ctl,
"Freq");
2027 snd_control.
info = snd_asihpi_tuner_freq_info;
2028 snd_control.
get = snd_asihpi_tuner_freq_get;
2029 snd_control.
put = snd_asihpi_tuner_freq_put;
2031 return ctl_add(card, &snd_control, asihpi);
2037 static int snd_asihpi_meter_info(
struct snd_kcontrol *kcontrol,
2055 static int log2lin[] = {
2077 static int snd_asihpi_meter_get(
struct snd_kcontrol *kcontrol,
2088 ucontrol->
value.integer.value[
i] = 0;
2089 }
else if (an_gain_mB[i] >= 0) {
2090 ucontrol->
value.integer.value[
i] =
2091 an_gain_mB[
i] << 16;
2096 ucontrol->
value.integer.value[
i] =
2097 log2lin[an_gain_mB[
i] / -1000];
2109 asihpi_ctl_init(&snd_control, hpi_ctl,
"Meter");
2112 snd_control.
info = snd_asihpi_meter_info;
2113 snd_control.
get = snd_asihpi_meter_get;
2115 snd_control.
index = subidx;
2117 return ctl_add(card, &snd_control, asihpi);
2123 static int snd_card_asihpi_mux_count_sources(
struct snd_kcontrol *snd_control)
2128 for (s = 0; s < 32; s++) {
2140 static int snd_asihpi_mux_info(
struct snd_kcontrol *kcontrol,
2150 snd_card_asihpi_mux_count_sources(kcontrol);
2159 &src_node_type, &src_node_index);
2167 static int snd_asihpi_mux_get(
struct snd_kcontrol *kcontrol,
2171 u16 source_type, source_index;
2176 &source_type, &source_index));
2178 for (s = 0; s < 256; s++) {
2180 &src_node_type, &src_node_index))
2183 if ((source_type == src_node_type)
2184 && (source_index == src_node_index)) {
2185 ucontrol->
value.enumerated.item[0] =
s;
2190 "Control %x failed to match mux source %hu %hu\n",
2191 h_control, source_type, source_index);
2192 ucontrol->
value.enumerated.item[0] = 0;
2196 static int snd_asihpi_mux_put(
struct snd_kcontrol *kcontrol,
2201 u16 source_type, source_index;
2207 ucontrol->
value.enumerated.item[0],
2208 &source_type, &source_index);
2212 source_type, source_index));
2223 asihpi_ctl_init(&snd_control, hpi_ctl,
"Route");
2225 snd_control.
info = snd_asihpi_mux_info;
2226 snd_control.
get = snd_asihpi_mux_get;
2227 snd_control.
put = snd_asihpi_mux_put;
2229 return ctl_add(card, &snd_control, asihpi);
2236 static int snd_asihpi_cmode_info(
struct snd_kcontrol *kcontrol,
2242 "From Left",
"From Right",
2243 "To Left",
"To Right"
2250 int valid_modes = 0;
2257 h_control, i, &mode)) {
2258 mode_map[valid_modes] =
mode;
2278 static int snd_asihpi_cmode_get(
struct snd_kcontrol *kcontrol,
2287 ucontrol->
value.enumerated.item[0] = mode - 1;
2292 static int snd_asihpi_cmode_put(
struct snd_kcontrol *kcontrol,
2301 ucontrol->
value.enumerated.item[0] + 1));
2312 asihpi_ctl_init(&snd_control, hpi_ctl,
"Mode");
2314 snd_control.
info = snd_asihpi_cmode_info;
2315 snd_control.
get = snd_asihpi_cmode_get;
2316 snd_control.
put = snd_asihpi_cmode_put;
2318 return ctl_add(card, &snd_control, asihpi);
2325 "N/A",
"Local PLL",
"Digital Sync",
"Word External",
"Word Header",
2326 "SMPTE",
"Digital1",
"Auto",
"Network",
"Invalid",
2328 "Digital2",
"Digital3",
"Digital4",
"Digital5",
2329 "Digital6",
"Digital7",
"Digital8"};
2331 static int snd_asihpi_clksrc_info(
struct snd_kcontrol *kcontrol,
2350 static int snd_asihpi_clksrc_get(
struct snd_kcontrol *kcontrol,
2360 ucontrol->
value.enumerated.item[0] = 0;
2368 for (i = 0; i < clkcache->
count; i++)
2369 if ((clkcache->
s[i].source == source) &&
2370 (clkcache->
s[
i].index == srcindex))
2373 ucontrol->
value.enumerated.item[0] =
i;
2378 static int snd_asihpi_clksrc_put(
struct snd_kcontrol *kcontrol,
2388 item = ucontrol->
value.enumerated.item[0];
2389 if (item >= clkcache->
count)
2390 item = clkcache->
count-1;
2393 h_control, clkcache->
s[item].source));
2397 h_control, clkcache->
s[item].index));
2405 static int snd_asihpi_clklocal_info(
struct snd_kcontrol *kcontrol,
2417 static int snd_asihpi_clklocal_get(
struct snd_kcontrol *kcontrol,
2426 ucontrol->
value.integer.value[0] =
rate;
2428 ucontrol->
value.integer.value[0] = 0;
2432 static int snd_asihpi_clklocal_put(
struct snd_kcontrol *kcontrol,
2443 ucontrol->
value.integer.value[0]));
2447 static int snd_asihpi_clkrate_info(
struct snd_kcontrol *kcontrol,
2459 static int snd_asihpi_clkrate_get(
struct snd_kcontrol *kcontrol,
2468 ucontrol->
value.integer.value[0] =
rate;
2470 ucontrol->
value.integer.value[0] = 0;
2495 clkcache->
s[
i].index = 0;
2496 clkcache->
s[
i].name = sampleclock_sources[
source];
2504 for (j = 1; j < 8; j++) {
2509 clkcache->
s[
i].source =
2511 clkcache->
s[
i].index =
j;
2512 clkcache->
s[
i].name = sampleclock_sources[
2518 asihpi_ctl_init(&snd_control, hpi_ctl,
"Source");
2520 snd_control.
info = snd_asihpi_clksrc_info;
2521 snd_control.
get = snd_asihpi_clksrc_get;
2522 snd_control.
put = snd_asihpi_clksrc_put;
2523 if (ctl_add(card, &snd_control, asihpi) < 0)
2528 asihpi_ctl_init(&snd_control, hpi_ctl,
"Localrate");
2530 snd_control.
info = snd_asihpi_clklocal_info;
2531 snd_control.
get = snd_asihpi_clklocal_get;
2532 snd_control.
put = snd_asihpi_clklocal_put;
2535 if (ctl_add(card, &snd_control, asihpi) < 0)
2539 asihpi_ctl_init(&snd_control, hpi_ctl,
"Rate");
2540 snd_control.access =
2542 snd_control.
info = snd_asihpi_clkrate_info;
2543 snd_control.
get = snd_asihpi_clkrate_get;
2545 return ctl_add(card, &snd_control, asihpi);
2554 unsigned int idx = 0;
2555 unsigned int subindex = 0;
2570 memset(&prev_ctl, 0,
sizeof(prev_ctl));
2571 prev_ctl.control_type = -1;
2573 for (idx = 0; idx < 2000; idx++) {
2587 "Disabled HPI Control(%d)\n",
2615 err = snd_asihpi_volume_add(asihpi, &hpi_ctl);
2618 err = snd_asihpi_level_add(asihpi, &hpi_ctl);
2621 err = snd_asihpi_mux_add(asihpi, &hpi_ctl);
2624 err = snd_asihpi_cmode_add(asihpi, &hpi_ctl);
2627 err = snd_asihpi_meter_add(asihpi, &hpi_ctl, subindex);
2630 err = snd_asihpi_sampleclock_add(
2636 err = snd_asihpi_tuner_add(asihpi, &hpi_ctl);
2639 err = snd_asihpi_aesebu_tx_add(asihpi, &hpi_ctl);
2642 err = snd_asihpi_aesebu_rx_add(asihpi, &hpi_ctl);
2652 "Untranslated HPI Control"
2653 "(%d) %d %d %d %d %d\n",
2694 snd_iprintf(buffer,
"ASIHPI driver proc file\n");
2697 &num_outstreams, &num_instreams,
2698 &version, &serial_number, &type));
2701 "Adapter type ASI%4X\nHardware Index %d\n"
2702 "%d outstreams\n%d instreams\n",
2703 type, asihpi->
hpi->adapter->index,
2704 num_outstreams, num_instreams);
2707 "Serial#%d\nHardware version %c%d\nDSP code version %03d\n",
2708 serial_number, ((version >> 3) & 0xf) +
'A', version & 0x7,
2709 ((version >> 13) * 100) + ((version >> 7) & 0x3f));
2720 snd_iprintf(buffer,
"Sample Clock %dHz, source %s\n",
2721 rate, sampleclock_sources[source]);
2729 if (!snd_card_proc_new(asihpi->
card,
"info", &entry))
2730 snd_info_set_text_ops(entry, asihpi, snd_asihpi_proc_read);
2739 if (enable_hpi_hwdep)
2746 static int snd_asihpi_hpi_release(
struct snd_hwdep *hw,
struct file *file)
2748 if (enable_hpi_hwdep)
2754 static int snd_asihpi_hpi_ioctl(
struct snd_hwdep *hw,
struct file *file,
2755 unsigned int cmd,
unsigned long arg)
2757 if (enable_hpi_hwdep)
2780 hw->
ops.open = snd_asihpi_hpi_open;
2781 hw->
ops.ioctl = snd_asihpi_hpi_ioctl;
2782 hw->
ops.release = snd_asihpi_hpi_release;
2819 hpi = pci_get_drvdata(pci_dev);
2820 adapter_index = hpi->
adapter->index;
2836 "**** WARNING **** Adapter index %d->ALSA index %d\n",
2837 adapter_index, card->
number);
2848 asihpi->
hpi->adapter->type, adapter_index);
2902 err = snd_card_asihpi_pcm_new(asihpi, 0);
2907 err = snd_card_asihpi_mixer_new(asihpi);
2919 h_control, adapter_fs);
2921 snd_asihpi_proc_init(asihpi);
2925 snd_asihpi_hpi_new(asihpi, 0,
NULL);
2930 asihpi->
hpi->adapter->type);
2947 static void __devexit snd_asihpi_remove(
struct pci_dev *pci_dev)
2949 struct hpi_adapter *hpi = pci_get_drvdata(pci_dev);
2967 .name = KBUILD_MODNAME,
2968 .id_table = asihpi_pci_tbl,
2969 .probe = snd_asihpi_probe,
2971 #ifdef CONFIG_PM_SLEEP
2977 static int __init snd_asihpi_init(
void)
2980 return pci_register_driver(&driver);
2983 static void __exit snd_asihpi_exit(
void)