54 #include <linux/pci.h>
56 #include <linux/slab.h>
57 #include <linux/module.h>
82 "{ICEnsemble,Generic ICE1712},"
83 "{ICEnsemble,Generic Envy24}}");
102 MODULE_PARM_DESC(cs8427_timeout,
"Define reset timeout for cs8427 chip in msec resolution.");
116 static int snd_ice1712_build_pro_mixer(
struct snd_ice1712 *ice);
117 static int snd_ice1712_build_controls(
struct snd_ice1712 *ice);
119 static int PRO_RATE_LOCKED;
120 static int PRO_RATE_RESET = 1;
121 static unsigned int PRO_RATE_DEFAULT = 44100;
128 static inline int is_spdif_master(
struct snd_ice1712 *ice)
133 static inline int is_pro_rate_locked(
struct snd_ice1712 *ice)
135 return is_spdif_master(ice) || PRO_RATE_LOCKED;
150 static void snd_ice1712_ac97_write(
struct snd_ac97 *ac97,
156 unsigned char old_cmd = 0;
158 for (tm = 0; tm < 0x10000; tm++) {
170 for (tm = 0; tm < 0x10000; tm++)
175 static unsigned short snd_ice1712_ac97_read(
struct snd_ac97 *ac97,
180 unsigned char old_cmd = 0;
182 for (tm = 0; tm < 0x10000; tm++) {
192 for (tm = 0; tm < 0x10000; tm++)
204 static void snd_ice1712_pro_ac97_write(
struct snd_ac97 *ac97,
210 unsigned char old_cmd = 0;
212 for (tm = 0; tm < 0x10000; tm++) {
213 old_cmd =
inb(
ICEMT(ice, AC97_CMD));
224 for (tm = 0; tm < 0x10000; tm++)
230 static unsigned short snd_ice1712_pro_ac97_read(
struct snd_ac97 *ac97,
235 unsigned char old_cmd = 0;
237 for (tm = 0; tm < 0x10000; tm++) {
238 old_cmd =
inb(
ICEMT(ice, AC97_CMD));
246 outb(old_cmd | ICE1712_AC97_READ,
ICEMT(ice, AC97_CMD));
247 for (tm = 0; tm < 0x10000; tm++)
248 if ((
inb(
ICEMT(ice, AC97_CMD)) & ICE1712_AC97_READ) == 0)
258 #define snd_ice1712_digmix_route_ac97_info snd_ctl_boolean_mono_info
271 unsigned char val, nval;
274 val =
inb(
ICEMT(ice, MONITOR_ROUTECTRL));
276 if (ucontrol->
value.integer.value[0])
278 outb(nval,
ICEMT(ice, MONITOR_ROUTECTRL));
285 .name =
"Digital Mixer To AC97",
287 .get = snd_ice1712_digmix_route_ac97_get,
288 .put = snd_ice1712_digmix_route_ac97_put,
295 static void snd_ice1712_set_gpio_dir(
struct snd_ice1712 *ice,
unsigned int data)
301 static unsigned int snd_ice1712_get_gpio_dir(
struct snd_ice1712 *ice)
306 static unsigned int snd_ice1712_get_gpio_mask(
struct snd_ice1712 *ice)
311 static void snd_ice1712_set_gpio_mask(
struct snd_ice1712 *ice,
unsigned int data)
317 static unsigned int snd_ice1712_get_gpio_data(
struct snd_ice1712 *ice)
322 static void snd_ice1712_set_gpio_data(
struct snd_ice1712 *ice,
unsigned int val)
338 static int snd_ice1712_cs8427_set_input_clock(
struct snd_ice1712 *ice,
int spdif_clock)
340 unsigned char reg[2] = { 0x80 | 4, 0 };
341 unsigned char val, nval;
344 snd_i2c_lock(ice->
i2c);
346 snd_i2c_unlock(ice->
i2c);
350 snd_i2c_unlock(ice->
i2c);
366 snd_i2c_unlock(ice->
i2c);
401 ice->
spdif.ops.open = open_cs8427;
402 ice->
spdif.ops.close = close_cs8427;
403 ice->
spdif.ops.setup_rate = setup_cs8427;
407 static void snd_ice1712_set_input_clock_source(
struct snd_ice1712 *ice,
int spdif_is_master)
411 snd_ice1712_cs8427_set_input_clock(ice, spdif_is_master);
413 if (spdif_is_master) {
416 if (ice->
akm[i].ops.set_rate_val)
417 ice->
akm[
i].ops.set_rate_val(&ice->
akm[i], 0);
441 status &= ~ICE1712_IRQ_MPU1;
449 status &= ~ICE1712_IRQ_MPU2;
472 for (idx = 0; idx < 6; idx++) {
473 if ((pbkstatus & (3 << (idx * 2))) == 0)
476 if (substream !=
NULL)
593 period_size = (snd_pcm_lib_period_bytes(substream) >> 2) - 1;
594 buf_size = snd_pcm_lib_buffer_bytes(substream) - 1;
600 rate = (runtime->
rate * 8192) / 375;
601 if (rate > 0x000fffff)
626 period_size = snd_pcm_lib_period_bytes(substream) - 1;
627 buf_size = snd_pcm_lib_buffer_bytes(substream) - 1;
633 rate = (runtime->
rate * 8192) / 375;
634 if (rate > 0x000fffff)
638 chn = substream->
number * 2;
662 period_size = (snd_pcm_lib_period_bytes(substream) >> 2) - 1;
663 buf_size = snd_pcm_lib_buffer_bytes(substream) - 1;
691 return bytes_to_frames(substream->
runtime, ptr);
706 ptr = snd_ice1712_ds_read(ice, substream->
number * 2, addr) -
708 if (ptr == substream->
runtime->buffer_size)
710 return bytes_to_frames(substream->
runtime, ptr);
721 if (ptr == substream->
runtime->buffer_size)
723 return bytes_to_frames(substream->
runtime, ptr);
738 .period_bytes_min = 64,
739 .period_bytes_max = (64*1024),
757 .period_bytes_min = 64,
758 .period_bytes_max = (128*1024),
775 .period_bytes_min = 64,
776 .period_bytes_max = (64*1024),
788 runtime->
hw = snd_ice1712_playback;
799 runtime->
hw = snd_ice1712_playback_ds;
813 runtime->
hw = snd_ice1712_capture;
816 runtime->
hw.rate_min = 48000;
849 static struct snd_pcm_ops snd_ice1712_playback_ops = {
850 .open = snd_ice1712_playback_open,
851 .close = snd_ice1712_playback_close,
853 .hw_params = snd_ice1712_hw_params,
854 .hw_free = snd_ice1712_hw_free,
855 .prepare = snd_ice1712_playback_prepare,
856 .trigger = snd_ice1712_playback_trigger,
857 .pointer = snd_ice1712_playback_pointer,
860 static struct snd_pcm_ops snd_ice1712_playback_ds_ops = {
861 .open = snd_ice1712_playback_ds_open,
862 .close = snd_ice1712_playback_ds_close,
864 .hw_params = snd_ice1712_hw_params,
865 .hw_free = snd_ice1712_hw_free,
866 .prepare = snd_ice1712_playback_ds_prepare,
867 .trigger = snd_ice1712_playback_ds_trigger,
868 .pointer = snd_ice1712_playback_ds_pointer,
871 static struct snd_pcm_ops snd_ice1712_capture_ops = {
872 .open = snd_ice1712_capture_open,
873 .close = snd_ice1712_capture_close,
875 .hw_params = snd_ice1712_hw_params,
876 .hw_free = snd_ice1712_hw_free,
877 .prepare = snd_ice1712_capture_prepare,
878 .trigger = snd_ice1712_capture_trigger,
879 .pointer = snd_ice1712_capture_pointer,
919 err =
snd_pcm_new(ice->
card,
"ICE1712 consumer (DS)", device, 6, 0, &pcm);
943 static unsigned int rates[] = { 8000, 9600, 11025, 12000, 16000, 22050, 24000,
944 32000, 44100, 48000, 64000, 88200, 96000 };
965 snd_pcm_trigger_done(substream, substream);
979 unsigned int what = 0;
986 snd_pcm_trigger_done(s, substream);
989 snd_pcm_trigger_done(s, substream);
1010 static void snd_ice1712_set_pro_rate(
struct snd_ice1712 *ice,
unsigned int rate,
int force)
1012 unsigned long flags;
1013 unsigned char val, old;
1017 case 8000: val = 6;
break;
1018 case 9600: val = 3;
break;
1019 case 11025: val = 10;
break;
1020 case 12000: val = 2;
break;
1021 case 16000: val = 5;
break;
1022 case 22050: val = 9;
break;
1023 case 24000: val = 1;
break;
1024 case 32000: val = 4;
break;
1025 case 44100: val = 8;
break;
1026 case 48000: val = 0;
break;
1027 case 64000: val = 15;
break;
1028 case 88200: val = 11;
break;
1029 case 96000: val = 7;
break;
1042 spin_unlock_irqrestore(&ice->
reg_lock, flags);
1045 if (!force && is_pro_rate_locked(ice))
1049 if (!force && old == val)
1052 spin_unlock_irqrestore(&ice->
reg_lock, flags);
1054 if (ice->
gpio.set_pro_rate)
1055 ice->
gpio.set_pro_rate(ice, rate);
1057 if (ice->
akm[i].ops.set_rate_val)
1058 ice->
akm[
i].ops.set_rate_val(&ice->
akm[i], rate);
1060 if (ice->
spdif.ops.setup_rate)
1061 ice->
spdif.ops.setup_rate(ice, rate);
1064 static int snd_ice1712_playback_pro_prepare(
struct snd_pcm_substream *substream)
1072 outw((snd_pcm_lib_period_bytes(substream) >> 2) - 1,
ICEMT(ice, PLAYBACK_COUNT));
1078 static int snd_ice1712_playback_pro_hw_params(
struct snd_pcm_substream *substream,
1083 snd_ice1712_set_pro_rate(ice,
params_rate(hw_params), 0);
1095 outw((snd_pcm_lib_period_bytes(substream) >> 2) - 1,
ICEMT(ice, CAPTURE_COUNT));
1100 static int snd_ice1712_capture_pro_hw_params(
struct snd_pcm_substream *substream,
1105 snd_ice1712_set_pro_rate(ice,
params_rate(hw_params), 0);
1117 if (ptr == substream->
runtime->buffer_size)
1119 return bytes_to_frames(substream->
runtime, ptr);
1130 if (ptr == substream->
runtime->buffer_size)
1132 return bytes_to_frames(substream->
runtime, ptr);
1147 .period_bytes_min = 10 * 4 * 2,
1148 .period_bytes_max = 131040,
1150 .periods_max = 1024,
1166 .period_bytes_min = 12 * 4 * 2,
1167 .period_bytes_max = 131040,
1169 .periods_max = 1024,
1179 runtime->
hw = snd_ice1712_playback_pro;
1183 if (is_pro_rate_locked(ice)) {
1184 runtime->
hw.rate_min = PRO_RATE_DEFAULT;
1185 runtime->
hw.rate_max = PRO_RATE_DEFAULT;
1188 if (ice->
spdif.ops.open)
1189 ice->
spdif.ops.open(ice, substream);
1200 runtime->
hw = snd_ice1712_capture_pro;
1204 if (is_pro_rate_locked(ice)) {
1205 runtime->
hw.rate_min = PRO_RATE_DEFAULT;
1206 runtime->
hw.rate_max = PRO_RATE_DEFAULT;
1217 snd_ice1712_set_pro_rate(ice, PRO_RATE_DEFAULT, 0);
1219 if (ice->
spdif.ops.close)
1220 ice->
spdif.ops.close(ice, substream);
1230 snd_ice1712_set_pro_rate(ice, PRO_RATE_DEFAULT, 0);
1235 static struct snd_pcm_ops snd_ice1712_playback_pro_ops = {
1236 .open = snd_ice1712_playback_pro_open,
1237 .close = snd_ice1712_playback_pro_close,
1239 .hw_params = snd_ice1712_playback_pro_hw_params,
1240 .hw_free = snd_ice1712_hw_free,
1241 .prepare = snd_ice1712_playback_pro_prepare,
1242 .trigger = snd_ice1712_pro_trigger,
1243 .pointer = snd_ice1712_playback_pro_pointer,
1246 static struct snd_pcm_ops snd_ice1712_capture_pro_ops = {
1247 .open = snd_ice1712_capture_pro_open,
1248 .close = snd_ice1712_capture_pro_close,
1250 .hw_params = snd_ice1712_capture_pro_hw_params,
1251 .hw_free = snd_ice1712_hw_free,
1252 .prepare = snd_ice1712_capture_pro_prepare,
1253 .trigger = snd_ice1712_pro_trigger,
1254 .pointer = snd_ice1712_capture_pro_pointer,
1291 err = snd_ice1712_build_pro_mixer(ice);
1304 unsigned short val = 0;
1306 val |= (vol & 0x8000) == 0 ? (96 - (vol & 0x7f)) : 0x7f;
1307 val |= ((vol & 0x80000000) == 0 ? (96 - ((vol >> 16) & 0x7f)) : 0x7f) << 8;
1312 #define snd_ice1712_pro_mixer_switch_info snd_ctl_boolean_stereo_info
1317 int priv_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->
id) +
1321 ucontrol->
value.integer.value[0] =
1323 ucontrol->
value.integer.value[1] =
1332 int priv_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->
id) +
1334 unsigned int nval, change;
1336 nval = (ucontrol->
value.integer.value[0] ? 0 : 0x00008000) |
1337 (ucontrol->
value.integer.value[1] ? 0 : 0x80000000);
1342 snd_ice1712_update_volume(ice, priv_idx);
1359 int priv_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->
id) +
1363 ucontrol->
value.integer.value[0] =
1365 ucontrol->
value.integer.value[1] =
1374 int priv_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->
id) +
1376 unsigned int nval, change;
1378 nval = (ucontrol->
value.integer.value[0] & 127) |
1379 ((ucontrol->
value.integer.value[1] & 127) << 16);
1384 snd_ice1712_update_volume(ice, priv_idx);
1391 static struct snd_kcontrol_new snd_ice1712_multi_playback_ctrls[] __devinitdata = {
1394 .name =
"Multi Playback Switch",
1396 .get = snd_ice1712_pro_mixer_switch_get,
1397 .put = snd_ice1712_pro_mixer_switch_put,
1405 .
name =
"Multi Playback Volume",
1406 .
info = snd_ice1712_pro_mixer_volume_info,
1407 .
get = snd_ice1712_pro_mixer_volume_get,
1408 .
put = snd_ice1712_pro_mixer_volume_put,
1411 .
tlv = { .p = db_scale_playback }
1415 static struct snd_kcontrol_new snd_ice1712_multi_capture_analog_switch __devinitdata = {
1417 .name =
"H/W Multi Capture Switch",
1419 .get = snd_ice1712_pro_mixer_switch_get,
1420 .put = snd_ice1712_pro_mixer_switch_put,
1421 .private_value = 10,
1424 static struct snd_kcontrol_new snd_ice1712_multi_capture_spdif_switch __devinitdata = {
1428 .get = snd_ice1712_pro_mixer_switch_get,
1429 .put = snd_ice1712_pro_mixer_switch_put,
1430 .private_value = 18,
1434 static struct snd_kcontrol_new snd_ice1712_multi_capture_analog_volume __devinitdata = {
1438 .
name =
"H/W Multi Capture Volume",
1439 .
info = snd_ice1712_pro_mixer_volume_info,
1440 .
get = snd_ice1712_pro_mixer_volume_get,
1441 .
put = snd_ice1712_pro_mixer_volume_put,
1443 .
tlv = { .p = db_scale_playback }
1446 static struct snd_kcontrol_new snd_ice1712_multi_capture_spdif_volume __devinitdata = {
1449 .info = snd_ice1712_pro_mixer_volume_info,
1450 .get = snd_ice1712_pro_mixer_volume_get,
1451 .put = snd_ice1712_pro_mixer_volume_put,
1452 .private_value = 18,
1463 for (idx = 0; idx <
ARRAY_SIZE(snd_ice1712_multi_playback_ctrls); idx++) {
1494 for (idx = 0; idx < 10; idx++) {
1496 snd_ice1712_update_volume(ice, idx);
1500 snd_ice1712_update_volume(ice, idx);
1502 for (idx = 18; idx < 20; idx++) {
1504 snd_ice1712_update_volume(ice, idx);
1509 static void snd_ice1712_mixer_free_ac97(
struct snd_ac97 *ac97)
1517 int err, bus_num = 0;
1521 .
write = snd_ice1712_ac97_write,
1522 .read = snd_ice1712_ac97_read,
1525 .
write = snd_ice1712_pro_ac97_write,
1526 .read = snd_ice1712_pro_ac97_read,
1533 memset(&ac97, 0,
sizeof(ac97));
1551 memset(&ac97, 0,
sizeof(ac97));
1561 strcat(ice->
card->mixername,
"ICE1712 - multitrack");
1569 static inline unsigned int eeprom_double(
struct snd_ice1712 *ice,
int idx)
1571 return (
unsigned int)ice->
eeprom.data[
idx] | ((
unsigned int)ice->
eeprom.data[idx + 1] << 8);
1580 snd_iprintf(buffer,
"%s\n\n", ice->
card->longname);
1581 snd_iprintf(buffer,
"EEPROM:\n");
1583 snd_iprintf(buffer,
" Subvendor : 0x%x\n", ice->
eeprom.subvendor);
1584 snd_iprintf(buffer,
" Size : %i bytes\n", ice->
eeprom.size);
1585 snd_iprintf(buffer,
" Version : %i\n", ice->
eeprom.version);
1590 snd_iprintf(buffer,
" GPIO mask : 0x%x\n", ice->
eeprom.gpiomask);
1591 snd_iprintf(buffer,
" GPIO state : 0x%x\n", ice->
eeprom.gpiostate);
1592 snd_iprintf(buffer,
" GPIO direction : 0x%x\n", ice->
eeprom.gpiodir);
1597 for (idx = 0; idx < 4; idx++)
1599 for (idx = 0; idx < 4; idx++)
1601 for (idx = 0x1c; idx < ice->
eeprom.size; idx++)
1602 snd_iprintf(buffer,
" Extra #%02i : 0x%x\n", idx, ice->
eeprom.data[idx]);
1604 snd_iprintf(buffer,
"\nRegisters:\n");
1605 snd_iprintf(buffer,
" PSDOUT03 : 0x%04x\n", (
unsigned)
inw(
ICEMT(ice, ROUTE_PSDOUT03)));
1606 snd_iprintf(buffer,
" CAPTURE : 0x%08x\n",
inl(
ICEMT(ice, ROUTE_CAPTURE)));
1607 snd_iprintf(buffer,
" SPDOUT : 0x%04x\n", (
unsigned)
inw(
ICEMT(ice, ROUTE_SPDOUT)));
1608 snd_iprintf(buffer,
" RATE : 0x%02x\n", (
unsigned)
inb(
ICEMT(ice,
RATE)));
1609 snd_iprintf(buffer,
" GPIO_DATA : 0x%02x\n", (
unsigned)snd_ice1712_get_gpio_data(ice));
1618 if (!snd_card_proc_new(ice->
card,
"ice1712", &entry))
1619 snd_info_set_text_ops(entry, ice, snd_ice1712_proc_read);
1626 static int snd_ice1712_eeprom_info(
struct snd_kcontrol *kcontrol,
1634 static int snd_ice1712_eeprom_get(
struct snd_kcontrol *kcontrol,
1645 .name =
"ICE1712 EEPROM",
1647 .info = snd_ice1712_eeprom_info,
1648 .get = snd_ice1712_eeprom_get
1653 static int snd_ice1712_spdif_info(
struct snd_kcontrol *kcontrol,
1661 static int snd_ice1712_spdif_default_get(
struct snd_kcontrol *kcontrol,
1665 if (ice->
spdif.ops.default_get)
1666 ice->
spdif.ops.default_get(ice, ucontrol);
1670 static int snd_ice1712_spdif_default_put(
struct snd_kcontrol *kcontrol,
1674 if (ice->
spdif.ops.default_put)
1675 return ice->
spdif.ops.default_put(ice, ucontrol);
1683 .info = snd_ice1712_spdif_info,
1684 .get = snd_ice1712_spdif_default_get,
1685 .put = snd_ice1712_spdif_default_put
1688 static int snd_ice1712_spdif_maskc_get(
struct snd_kcontrol *kcontrol,
1692 if (ice->
spdif.ops.default_get) {
1701 ucontrol->
value.iec958.status[0] = 0xff;
1702 ucontrol->
value.iec958.status[1] = 0xff;
1703 ucontrol->
value.iec958.status[2] = 0xff;
1704 ucontrol->
value.iec958.status[3] = 0xff;
1705 ucontrol->
value.iec958.status[4] = 0xff;
1710 static int snd_ice1712_spdif_maskp_get(
struct snd_kcontrol *kcontrol,
1714 if (ice->
spdif.ops.default_get) {
1721 ucontrol->
value.iec958.status[0] = 0xff;
1722 ucontrol->
value.iec958.status[1] = 0xff;
1723 ucontrol->
value.iec958.status[2] = 0xff;
1724 ucontrol->
value.iec958.status[3] = 0xff;
1725 ucontrol->
value.iec958.status[4] = 0xff;
1735 .info = snd_ice1712_spdif_info,
1736 .get = snd_ice1712_spdif_maskc_get,
1744 .info = snd_ice1712_spdif_info,
1745 .get = snd_ice1712_spdif_maskp_get,
1748 static int snd_ice1712_spdif_stream_get(
struct snd_kcontrol *kcontrol,
1752 if (ice->
spdif.ops.stream_get)
1753 ice->
spdif.ops.stream_get(ice, ucontrol);
1757 static int snd_ice1712_spdif_stream_put(
struct snd_kcontrol *kcontrol,
1761 if (ice->
spdif.ops.stream_put)
1762 return ice->
spdif.ops.stream_put(ice, ucontrol);
1772 .info = snd_ice1712_spdif_info,
1773 .get = snd_ice1712_spdif_stream_get,
1774 .put = snd_ice1712_spdif_stream_put
1784 snd_ice1712_save_gpio_status(ice);
1785 ucontrol->
value.integer.value[0] =
1786 (snd_ice1712_gpio_read(ice) & mask ? 1 : 0) ^ invert;
1787 snd_ice1712_restore_gpio_status(ice);
1796 int invert = (kcontrol->
private_value & (1<<24)) ? mask : 0;
1797 unsigned int val, nval;
1801 nval = (ucontrol->
value.integer.value[0] ? mask : 0) ^ invert;
1802 snd_ice1712_save_gpio_status(ice);
1803 val = snd_ice1712_gpio_read(ice);
1804 nval |= val & ~mask;
1806 snd_ice1712_gpio_write(ice, nval);
1807 snd_ice1712_restore_gpio_status(ice);
1814 static int snd_ice1712_pro_internal_clock_info(
struct snd_kcontrol *kcontrol,
1817 static const char *
const texts[] = {
1842 static int snd_ice1712_pro_internal_clock_get(
struct snd_kcontrol *kcontrol,
1846 static const unsigned char xlate[16] = {
1847 9, 6, 3, 1, 7, 4, 0, 12, 8, 5, 2, 11, 255, 255, 255, 10
1853 ucontrol->
value.enumerated.item[0] = 13;
1860 ucontrol->
value.enumerated.item[0] =
val;
1866 static int snd_ice1712_pro_internal_clock_put(
struct snd_kcontrol *kcontrol,
1870 static const unsigned int xrate[13] = {
1871 8000, 9600, 11025, 12000, 16000, 22050, 24000,
1872 32000, 44100, 48000, 64000, 88200, 96000
1879 if (ucontrol->
value.enumerated.item[0] == 13) {
1882 PRO_RATE_DEFAULT = xrate[ucontrol->
value.integer.value[0] % 13];
1884 snd_ice1712_set_pro_rate(ice, PRO_RATE_DEFAULT, 1);
1897 static struct snd_kcontrol_new snd_ice1712_pro_internal_clock __devinitdata = {
1899 .name =
"Multi Track Internal Clock",
1900 .info = snd_ice1712_pro_internal_clock_info,
1901 .get = snd_ice1712_pro_internal_clock_get,
1902 .put = snd_ice1712_pro_internal_clock_put
1905 static int snd_ice1712_pro_internal_clock_default_info(
struct snd_kcontrol *kcontrol,
1908 static const char *
const texts[] = {
1933 static int snd_ice1712_pro_internal_clock_default_get(
struct snd_kcontrol *kcontrol,
1937 static const unsigned int xrate[13] = {
1938 8000, 9600, 11025, 12000, 16000, 22050, 24000,
1939 32000, 44100, 48000, 64000, 88200, 96000
1942 for (val = 0; val < 13; val++) {
1943 if (xrate[val] == PRO_RATE_DEFAULT)
1947 ucontrol->
value.enumerated.item[0] =
val;
1951 static int snd_ice1712_pro_internal_clock_default_put(
struct snd_kcontrol *kcontrol,
1954 static const unsigned int xrate[13] = {
1955 8000, 9600, 11025, 12000, 16000, 22050, 24000,
1956 32000, 44100, 48000, 64000, 88200, 96000
1961 oval = PRO_RATE_DEFAULT;
1962 PRO_RATE_DEFAULT = xrate[ucontrol->
value.integer.value[0] % 13];
1963 change = PRO_RATE_DEFAULT != oval;
1968 static struct snd_kcontrol_new snd_ice1712_pro_internal_clock_default __devinitdata = {
1970 .name =
"Multi Track Internal Clock Default",
1971 .info = snd_ice1712_pro_internal_clock_default_info,
1972 .get = snd_ice1712_pro_internal_clock_default_get,
1973 .put = snd_ice1712_pro_internal_clock_default_put
1976 #define snd_ice1712_pro_rate_locking_info snd_ctl_boolean_mono_info
1978 static int snd_ice1712_pro_rate_locking_get(
struct snd_kcontrol *kcontrol,
1981 ucontrol->
value.integer.value[0] = PRO_RATE_LOCKED;
1985 static int snd_ice1712_pro_rate_locking_put(
struct snd_kcontrol *kcontrol,
1989 int change = 0, nval;
1991 nval = ucontrol->
value.integer.value[0] ? 1 : 0;
1993 change = PRO_RATE_LOCKED != nval;
1994 PRO_RATE_LOCKED = nval;
1999 static struct snd_kcontrol_new snd_ice1712_pro_rate_locking __devinitdata = {
2001 .name =
"Multi Track Rate Locking",
2003 .get = snd_ice1712_pro_rate_locking_get,
2004 .put = snd_ice1712_pro_rate_locking_put
2007 #define snd_ice1712_pro_rate_reset_info snd_ctl_boolean_mono_info
2009 static int snd_ice1712_pro_rate_reset_get(
struct snd_kcontrol *kcontrol,
2012 ucontrol->
value.integer.value[0] = PRO_RATE_RESET;
2016 static int snd_ice1712_pro_rate_reset_put(
struct snd_kcontrol *kcontrol,
2020 int change = 0, nval;
2022 nval = ucontrol->
value.integer.value[0] ? 1 : 0;
2024 change = PRO_RATE_RESET != nval;
2025 PRO_RATE_RESET = nval;
2030 static struct snd_kcontrol_new snd_ice1712_pro_rate_reset __devinitdata = {
2032 .name =
"Multi Track Rate Reset",
2034 .get = snd_ice1712_pro_rate_reset_get,
2035 .put = snd_ice1712_pro_rate_reset_put
2041 static int snd_ice1712_pro_route_info(
struct snd_kcontrol *kcontrol,
2044 static const char *
const texts[] = {
2046 "H/W In 0",
"H/W In 1",
"H/W In 2",
"H/W In 3",
2047 "H/W In 4",
"H/W In 5",
"H/W In 6",
"H/W In 7",
2048 "IEC958 In L",
"IEC958 In R",
2055 snd_ctl_get_ioffidx(kcontrol, &uinfo->
id) < 2 ? 12 : 11;
2062 static int snd_ice1712_pro_route_analog_get(
struct snd_kcontrol *kcontrol,
2066 int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->
id);
2067 unsigned int val, cval;
2070 val =
inw(
ICEMT(ice, ROUTE_PSDOUT03));
2071 cval =
inl(
ICEMT(ice, ROUTE_CAPTURE));
2074 val >>= ((idx % 2) * 8) + ((idx / 2) * 2);
2076 cval >>= ((idx / 2) * 8) + ((idx % 2) * 4);
2077 if (val == 1 && idx < 2)
2078 ucontrol->
value.enumerated.item[0] = 11;
2080 ucontrol->
value.enumerated.item[0] = (cval & 7) + 1;
2082 ucontrol->
value.enumerated.item[0] = ((cval >> 3) & 1) + 9;
2084 ucontrol->
value.enumerated.item[0] = 0;
2088 static int snd_ice1712_pro_route_analog_put(
struct snd_kcontrol *kcontrol,
2093 int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->
id);
2094 unsigned int val, old_val, nval;
2097 if (ucontrol->
value.enumerated.item[0] >= 11)
2098 nval = idx < 2 ? 1 : 0;
2099 else if (ucontrol->
value.enumerated.item[0] >= 9)
2101 else if (ucontrol->
value.enumerated.item[0] >= 1)
2105 shift = ((idx % 2) * 8) + ((idx / 2) * 2);
2107 val = old_val =
inw(
ICEMT(ice, ROUTE_PSDOUT03));
2108 val &= ~(0x03 << shift);
2109 val |= nval << shift;
2110 change = val != old_val;
2119 val = old_val =
inl(
ICEMT(ice, ROUTE_CAPTURE));
2120 shift = ((idx / 2) * 8) + ((idx % 2) * 4);
2122 nval = ucontrol->
value.enumerated.item[0] - 1;
2123 val &= ~(0x07 << shift);
2124 val |= nval << shift;
2126 nval = (ucontrol->
value.enumerated.item[0] - 9) << 3;
2127 val &= ~(0x08 << shift);
2128 val |= nval << shift;
2130 if (val != old_val) {
2138 static int snd_ice1712_pro_route_spdif_get(
struct snd_kcontrol *kcontrol,
2142 int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->
id);
2143 unsigned int val, cval;
2144 val =
inw(
ICEMT(ice, ROUTE_SPDOUT));
2145 cval = (val >> (idx * 4 + 8)) & 0x0f;
2146 val = (val >> (idx * 2)) & 0x03;
2148 ucontrol->
value.enumerated.item[0] = 11;
2150 ucontrol->
value.enumerated.item[0] = (cval & 7) + 1;
2152 ucontrol->
value.enumerated.item[0] = ((cval >> 3) & 1) + 9;
2154 ucontrol->
value.enumerated.item[0] = 0;
2158 static int snd_ice1712_pro_route_spdif_put(
struct snd_kcontrol *kcontrol,
2163 int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->
id);
2164 unsigned int val, old_val, nval;
2168 val = old_val =
inw(
ICEMT(ice, ROUTE_SPDOUT));
2169 if (ucontrol->
value.enumerated.item[0] >= 11)
2171 else if (ucontrol->
value.enumerated.item[0] >= 9)
2173 else if (ucontrol->
value.enumerated.item[0] >= 1)
2178 val &= ~(0x03 << shift);
2179 val |= nval << shift;
2180 shift = idx * 4 + 8;
2182 nval = ucontrol->
value.enumerated.item[0] - 1;
2183 val &= ~(0x07 << shift);
2184 val |= nval << shift;
2185 }
else if (nval == 3) {
2186 nval = (ucontrol->
value.enumerated.item[0] - 9) << 3;
2187 val &= ~(0x08 << shift);
2188 val |= nval << shift;
2190 change = val != old_val;
2197 static struct snd_kcontrol_new snd_ice1712_mixer_pro_analog_route __devinitdata = {
2199 .name =
"H/W Playback Route",
2200 .info = snd_ice1712_pro_route_info,
2201 .get = snd_ice1712_pro_route_analog_get,
2202 .put = snd_ice1712_pro_route_analog_put,
2205 static struct snd_kcontrol_new snd_ice1712_mixer_pro_spdif_route __devinitdata = {
2208 .info = snd_ice1712_pro_route_info,
2209 .get = snd_ice1712_pro_route_spdif_get,
2210 .put = snd_ice1712_pro_route_spdif_put,
2215 static int snd_ice1712_pro_volume_rate_info(
struct snd_kcontrol *kcontrol,
2225 static int snd_ice1712_pro_volume_rate_get(
struct snd_kcontrol *kcontrol,
2230 ucontrol->
value.integer.value[0] =
inb(
ICEMT(ice, MONITOR_RATE));
2234 static int snd_ice1712_pro_volume_rate_put(
struct snd_kcontrol *kcontrol,
2241 change =
inb(
ICEMT(ice, MONITOR_RATE)) != ucontrol->
value.integer.value[0];
2242 outb(ucontrol->
value.integer.value[0],
ICEMT(ice, MONITOR_RATE));
2247 static struct snd_kcontrol_new snd_ice1712_mixer_pro_volume_rate __devinitdata = {
2249 .name =
"Multi Track Volume Rate",
2250 .info = snd_ice1712_pro_volume_rate_info,
2251 .get = snd_ice1712_pro_volume_rate_get,
2252 .put = snd_ice1712_pro_volume_rate_put
2255 static int snd_ice1712_pro_peak_info(
struct snd_kcontrol *kcontrol,
2265 static int snd_ice1712_pro_peak_get(
struct snd_kcontrol *kcontrol,
2272 for (idx = 0; idx < 22; idx++) {
2273 outb(idx,
ICEMT(ice, MONITOR_PEAKINDEX));
2280 static struct snd_kcontrol_new snd_ice1712_mixer_pro_peak __devinitdata = {
2282 .name =
"Multi Track Peak",
2284 .info = snd_ice1712_pro_peak_info,
2285 .get = snd_ice1712_pro_peak_get
2315 const char *modelname)
2318 unsigned int i,
size;
2321 if (!modelname || !*modelname) {
2322 ice->
eeprom.subvendor = 0;
2324 ice->
eeprom.subvendor = (snd_ice1712_read_i2c(ice, dev, 0x00) << 0) |
2325 (snd_ice1712_read_i2c(ice, dev, 0x01) << 8) |
2326 (snd_ice1712_read_i2c(ice, dev, 0x02) << 16) |
2327 (snd_ice1712_read_i2c(ice, dev, 0x03) << 24);
2328 if (ice->
eeprom.subvendor == 0 ||
2329 ice->
eeprom.subvendor == (
unsigned int)-1) {
2335 if (ice->
eeprom.subvendor == 0 || ice->
eeprom.subvendor == (
unsigned int)-1) {
2341 for (tbl = card_tables; *tbl; tbl++) {
2362 ice->
eeprom.size = snd_ice1712_read_i2c(ice, dev, 0x04);
2363 if (ice->
eeprom.size < 6)
2365 else if (ice->
eeprom.size > 32) {
2369 ice->
eeprom.version = snd_ice1712_read_i2c(ice, dev, 0x05);
2370 if (ice->
eeprom.version != 1) {
2375 size = ice->
eeprom.size - 6;
2376 for (i = 0; i <
size; i++)
2377 ice->
eeprom.data[i] = snd_ice1712_read_i2c(ice, dev, i + 6);
2416 ice->
gpio.write_mask = 0xc0;
2417 ice->
gpio.direction = 0xff;
2431 snd_ice1712_set_pro_rate(ice, 48000, 1);
2459 ice->
spdif.stream_ctl = kctl;
2507 static int snd_ice1712_free(
struct snd_ice1712 *ice)
2528 static int snd_ice1712_dev_free(
struct snd_device *device)
2531 return snd_ice1712_free(ice);
2536 const char *modelname,
2545 .dev_free = snd_ice1712_dev_free,
2556 pci_set_consistent_dma_mask(pci,
DMA_BIT_MASK(28)) < 0) {
2567 ice->
omni = omni ? 1 : 0;
2568 if (cs8427_timeout < 1)
2570 else if (cs8427_timeout > 1000)
2571 cs8427_timeout = 1000;
2578 ice->
gpio.set_mask = snd_ice1712_set_gpio_mask;
2579 ice->
gpio.get_mask = snd_ice1712_get_gpio_mask;
2580 ice->
gpio.set_dir = snd_ice1712_set_gpio_dir;
2581 ice->
gpio.get_dir = snd_ice1712_get_gpio_dir;
2582 ice->
gpio.set_data = snd_ice1712_set_gpio_data;
2583 ice->
gpio.get_data = snd_ice1712_get_gpio_data;
2585 ice->
spdif.cs8403_bits =
2586 ice->
spdif.cs8403_stream_bits = (0x01 |
2593 pci_write_config_word(ice->
pci, 0x40, 0x807f);
2594 pci_write_config_word(ice->
pci, 0x42, 0x0006);
2595 snd_ice1712_proc_init(ice);
2610 KBUILD_MODNAME, ice)) {
2612 snd_ice1712_free(ice);
2618 if (snd_ice1712_read_eeprom(ice, modelname) < 0) {
2619 snd_ice1712_free(ice);
2622 if (snd_ice1712_chip_init(ice) < 0) {
2623 snd_ice1712_free(ice);
2629 ICE1712_IRQ_MPU2 : 0) |
2631 ICE1712_IRQ_PBKDS | ICE1712_IRQ_CONCAP | ICE1712_IRQ_CONPBK : 0),
2637 snd_ice1712_free(ice);
2679 err = snd_ice1712_create(card, pci,
model[dev], omni[dev],
2680 cs8427_timeout[dev], dxr_enable[dev], &ice);
2686 for (tbl = card_tables; *tbl; tbl++) {
2706 err = snd_ice1712_pcm_profi(ice, pcm_dev++,
NULL);
2713 err = snd_ice1712_pcm(ice, pcm_dev++,
NULL);
2720 err = snd_ice1712_ac97_mixer(ice);
2726 err = snd_ice1712_build_controls(ice);
2741 err = snd_ice1712_pcm_ds(ice, pcm_dev++,
NULL);
2753 -1, &ice->
rmidi[0]);
2761 sizeof(ice->
rmidi[0]->name),
2770 -1, &ice->
rmidi[1]);
2779 sizeof(ice->
rmidi[1]->name),
2785 snd_ice1712_set_input_clock_source(ice, 0);
2795 pci_set_drvdata(pci, card);
2803 pci_set_drvdata(pci,
NULL);
2807 .name = KBUILD_MODNAME,
2808 .id_table = snd_ice1712_ids,
2809 .probe = snd_ice1712_probe,