ews.c 31 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084
  1. /*
  2. * ALSA driver for ICEnsemble ICE1712 (Envy24)
  3. *
  4. * Lowlevel functions for Terratec EWS88MT/D, EWX24/96, DMX 6Fire
  5. *
  6. * Copyright (c) 2000 Jaroslav Kysela <perex@perex.cz>
  7. * 2002 Takashi Iwai <tiwai@suse.de>
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 2 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  22. *
  23. */
  24. #include <asm/io.h>
  25. #include <linux/delay.h>
  26. #include <linux/interrupt.h>
  27. #include <linux/init.h>
  28. #include <linux/slab.h>
  29. #include <sound/core.h>
  30. #include <sound/cs8427.h>
  31. #include <sound/asoundef.h>
  32. #include "ice1712.h"
  33. #include "ews.h"
  34. #define SND_CS8404
  35. #include <sound/cs8403.h>
  36. enum {
  37. EWS_I2C_CS8404 = 0, EWS_I2C_PCF1, EWS_I2C_PCF2,
  38. EWS_I2C_88D = 0,
  39. EWS_I2C_6FIRE = 0
  40. };
  41. /* additional i2c devices for EWS boards */
  42. struct ews_spec {
  43. struct snd_i2c_device *i2cdevs[3];
  44. };
  45. /*
  46. * access via i2c mode (for EWX 24/96, EWS 88MT&D)
  47. */
  48. /* send SDA and SCL */
  49. static void ewx_i2c_setlines(struct snd_i2c_bus *bus, int clk, int data)
  50. {
  51. struct snd_ice1712 *ice = bus->private_data;
  52. unsigned char tmp = 0;
  53. if (clk)
  54. tmp |= ICE1712_EWX2496_SERIAL_CLOCK;
  55. if (data)
  56. tmp |= ICE1712_EWX2496_SERIAL_DATA;
  57. snd_ice1712_write(ice, ICE1712_IREG_GPIO_DATA, tmp);
  58. udelay(5);
  59. }
  60. static int ewx_i2c_getclock(struct snd_i2c_bus *bus)
  61. {
  62. struct snd_ice1712 *ice = bus->private_data;
  63. return snd_ice1712_read(ice, ICE1712_IREG_GPIO_DATA) & ICE1712_EWX2496_SERIAL_CLOCK ? 1 : 0;
  64. }
  65. static int ewx_i2c_getdata(struct snd_i2c_bus *bus, int ack)
  66. {
  67. struct snd_ice1712 *ice = bus->private_data;
  68. int bit;
  69. /* set RW pin to low */
  70. snd_ice1712_write(ice, ICE1712_IREG_GPIO_WRITE_MASK, ~ICE1712_EWX2496_RW);
  71. snd_ice1712_write(ice, ICE1712_IREG_GPIO_DATA, 0);
  72. if (ack)
  73. udelay(5);
  74. bit = snd_ice1712_read(ice, ICE1712_IREG_GPIO_DATA) & ICE1712_EWX2496_SERIAL_DATA ? 1 : 0;
  75. /* set RW pin to high */
  76. snd_ice1712_write(ice, ICE1712_IREG_GPIO_DATA, ICE1712_EWX2496_RW);
  77. /* reset write mask */
  78. snd_ice1712_write(ice, ICE1712_IREG_GPIO_WRITE_MASK, ~ICE1712_EWX2496_SERIAL_CLOCK);
  79. return bit;
  80. }
  81. static void ewx_i2c_start(struct snd_i2c_bus *bus)
  82. {
  83. struct snd_ice1712 *ice = bus->private_data;
  84. unsigned char mask;
  85. snd_ice1712_save_gpio_status(ice);
  86. /* set RW high */
  87. mask = ICE1712_EWX2496_RW;
  88. switch (ice->eeprom.subvendor) {
  89. case ICE1712_SUBDEVICE_EWX2496:
  90. mask |= ICE1712_EWX2496_AK4524_CS; /* CS high also */
  91. break;
  92. case ICE1712_SUBDEVICE_DMX6FIRE:
  93. mask |= ICE1712_6FIRE_AK4524_CS_MASK; /* CS high also */
  94. break;
  95. }
  96. snd_ice1712_gpio_write_bits(ice, mask, mask);
  97. }
  98. static void ewx_i2c_stop(struct snd_i2c_bus *bus)
  99. {
  100. struct snd_ice1712 *ice = bus->private_data;
  101. snd_ice1712_restore_gpio_status(ice);
  102. }
  103. static void ewx_i2c_direction(struct snd_i2c_bus *bus, int clock, int data)
  104. {
  105. struct snd_ice1712 *ice = bus->private_data;
  106. unsigned char mask = 0;
  107. if (clock)
  108. mask |= ICE1712_EWX2496_SERIAL_CLOCK; /* write SCL */
  109. if (data)
  110. mask |= ICE1712_EWX2496_SERIAL_DATA; /* write SDA */
  111. ice->gpio.direction &= ~(ICE1712_EWX2496_SERIAL_CLOCK|ICE1712_EWX2496_SERIAL_DATA);
  112. ice->gpio.direction |= mask;
  113. snd_ice1712_write(ice, ICE1712_IREG_GPIO_DIRECTION, ice->gpio.direction);
  114. snd_ice1712_write(ice, ICE1712_IREG_GPIO_WRITE_MASK, ~mask);
  115. }
  116. static struct snd_i2c_bit_ops snd_ice1712_ewx_cs8427_bit_ops = {
  117. .start = ewx_i2c_start,
  118. .stop = ewx_i2c_stop,
  119. .direction = ewx_i2c_direction,
  120. .setlines = ewx_i2c_setlines,
  121. .getclock = ewx_i2c_getclock,
  122. .getdata = ewx_i2c_getdata,
  123. };
  124. /*
  125. * AK4524 access
  126. */
  127. /* AK4524 chip select; address 0x48 bit 0-3 */
  128. static int snd_ice1712_ews88mt_chip_select(struct snd_ice1712 *ice, int chip_mask)
  129. {
  130. struct ews_spec *spec = ice->spec;
  131. unsigned char data, ndata;
  132. snd_assert(chip_mask >= 0 && chip_mask <= 0x0f, return -EINVAL);
  133. snd_i2c_lock(ice->i2c);
  134. if (snd_i2c_readbytes(spec->i2cdevs[EWS_I2C_PCF2], &data, 1) != 1)
  135. goto __error;
  136. ndata = (data & 0xf0) | chip_mask;
  137. if (ndata != data)
  138. if (snd_i2c_sendbytes(spec->i2cdevs[EWS_I2C_PCF2], &ndata, 1)
  139. != 1)
  140. goto __error;
  141. snd_i2c_unlock(ice->i2c);
  142. return 0;
  143. __error:
  144. snd_i2c_unlock(ice->i2c);
  145. snd_printk(KERN_ERR "AK4524 chip select failed, check cable to the front module\n");
  146. return -EIO;
  147. }
  148. /* start callback for EWS88MT, needs to select a certain chip mask */
  149. static void ews88mt_ak4524_lock(struct snd_akm4xxx *ak, int chip)
  150. {
  151. struct snd_ice1712 *ice = ak->private_data[0];
  152. unsigned char tmp;
  153. /* assert AK4524 CS */
  154. if (snd_ice1712_ews88mt_chip_select(ice, ~(1 << chip) & 0x0f) < 0)
  155. snd_printk(KERN_ERR "fatal error (ews88mt chip select)\n");
  156. snd_ice1712_save_gpio_status(ice);
  157. tmp = ICE1712_EWS88_SERIAL_DATA |
  158. ICE1712_EWS88_SERIAL_CLOCK |
  159. ICE1712_EWS88_RW;
  160. snd_ice1712_write(ice, ICE1712_IREG_GPIO_DIRECTION,
  161. ice->gpio.direction | tmp);
  162. snd_ice1712_write(ice, ICE1712_IREG_GPIO_WRITE_MASK, ~tmp);
  163. }
  164. /* stop callback for EWS88MT, needs to deselect chip mask */
  165. static void ews88mt_ak4524_unlock(struct snd_akm4xxx *ak, int chip)
  166. {
  167. struct snd_ice1712 *ice = ak->private_data[0];
  168. snd_ice1712_restore_gpio_status(ice);
  169. udelay(1);
  170. snd_ice1712_ews88mt_chip_select(ice, 0x0f);
  171. }
  172. /* start callback for EWX24/96 */
  173. static void ewx2496_ak4524_lock(struct snd_akm4xxx *ak, int chip)
  174. {
  175. struct snd_ice1712 *ice = ak->private_data[0];
  176. unsigned char tmp;
  177. snd_ice1712_save_gpio_status(ice);
  178. tmp = ICE1712_EWX2496_SERIAL_DATA |
  179. ICE1712_EWX2496_SERIAL_CLOCK |
  180. ICE1712_EWX2496_AK4524_CS |
  181. ICE1712_EWX2496_RW;
  182. snd_ice1712_write(ice, ICE1712_IREG_GPIO_DIRECTION,
  183. ice->gpio.direction | tmp);
  184. snd_ice1712_write(ice, ICE1712_IREG_GPIO_WRITE_MASK, ~tmp);
  185. }
  186. /* start callback for DMX 6fire */
  187. static void dmx6fire_ak4524_lock(struct snd_akm4xxx *ak, int chip)
  188. {
  189. struct snd_ak4xxx_private *priv = (void *)ak->private_value[0];
  190. struct snd_ice1712 *ice = ak->private_data[0];
  191. unsigned char tmp;
  192. snd_ice1712_save_gpio_status(ice);
  193. tmp = priv->cs_mask = priv->cs_addr = (1 << chip) & ICE1712_6FIRE_AK4524_CS_MASK;
  194. tmp |= ICE1712_6FIRE_SERIAL_DATA |
  195. ICE1712_6FIRE_SERIAL_CLOCK |
  196. ICE1712_6FIRE_RW;
  197. snd_ice1712_write(ice, ICE1712_IREG_GPIO_DIRECTION,
  198. ice->gpio.direction | tmp);
  199. snd_ice1712_write(ice, ICE1712_IREG_GPIO_WRITE_MASK, ~tmp);
  200. }
  201. /*
  202. * CS8404 interface on EWS88MT/D
  203. */
  204. static void snd_ice1712_ews_cs8404_spdif_write(struct snd_ice1712 *ice, unsigned char bits)
  205. {
  206. struct ews_spec *spec = ice->spec;
  207. unsigned char bytes[2];
  208. snd_i2c_lock(ice->i2c);
  209. switch (ice->eeprom.subvendor) {
  210. case ICE1712_SUBDEVICE_EWS88MT:
  211. case ICE1712_SUBDEVICE_EWS88MT_NEW:
  212. case ICE1712_SUBDEVICE_PHASE88:
  213. case ICE1712_SUBDEVICE_TS88:
  214. if (snd_i2c_sendbytes(spec->i2cdevs[EWS_I2C_CS8404], &bits, 1)
  215. != 1)
  216. goto _error;
  217. break;
  218. case ICE1712_SUBDEVICE_EWS88D:
  219. if (snd_i2c_readbytes(spec->i2cdevs[EWS_I2C_88D], bytes, 2)
  220. != 2)
  221. goto _error;
  222. if (bits != bytes[1]) {
  223. bytes[1] = bits;
  224. if (snd_i2c_sendbytes(spec->i2cdevs[EWS_I2C_88D],
  225. bytes, 2) != 2)
  226. goto _error;
  227. }
  228. break;
  229. }
  230. _error:
  231. snd_i2c_unlock(ice->i2c);
  232. }
  233. /*
  234. */
  235. static void ews88_spdif_default_get(struct snd_ice1712 *ice, struct snd_ctl_elem_value *ucontrol)
  236. {
  237. snd_cs8404_decode_spdif_bits(&ucontrol->value.iec958, ice->spdif.cs8403_bits);
  238. }
  239. static int ews88_spdif_default_put(struct snd_ice1712 *ice, struct snd_ctl_elem_value *ucontrol)
  240. {
  241. unsigned int val;
  242. int change;
  243. val = snd_cs8404_encode_spdif_bits(&ucontrol->value.iec958);
  244. spin_lock_irq(&ice->reg_lock);
  245. change = ice->spdif.cs8403_bits != val;
  246. ice->spdif.cs8403_bits = val;
  247. if (change && ice->playback_pro_substream == NULL) {
  248. spin_unlock_irq(&ice->reg_lock);
  249. snd_ice1712_ews_cs8404_spdif_write(ice, val);
  250. } else {
  251. spin_unlock_irq(&ice->reg_lock);
  252. }
  253. return change;
  254. }
  255. static void ews88_spdif_stream_get(struct snd_ice1712 *ice, struct snd_ctl_elem_value *ucontrol)
  256. {
  257. snd_cs8404_decode_spdif_bits(&ucontrol->value.iec958, ice->spdif.cs8403_stream_bits);
  258. }
  259. static int ews88_spdif_stream_put(struct snd_ice1712 *ice, struct snd_ctl_elem_value *ucontrol)
  260. {
  261. unsigned int val;
  262. int change;
  263. val = snd_cs8404_encode_spdif_bits(&ucontrol->value.iec958);
  264. spin_lock_irq(&ice->reg_lock);
  265. change = ice->spdif.cs8403_stream_bits != val;
  266. ice->spdif.cs8403_stream_bits = val;
  267. if (change && ice->playback_pro_substream != NULL) {
  268. spin_unlock_irq(&ice->reg_lock);
  269. snd_ice1712_ews_cs8404_spdif_write(ice, val);
  270. } else {
  271. spin_unlock_irq(&ice->reg_lock);
  272. }
  273. return change;
  274. }
  275. /* open callback */
  276. static void ews88_open_spdif(struct snd_ice1712 *ice, struct snd_pcm_substream *substream)
  277. {
  278. ice->spdif.cs8403_stream_bits = ice->spdif.cs8403_bits;
  279. }
  280. /* set up SPDIF for EWS88MT / EWS88D */
  281. static void ews88_setup_spdif(struct snd_ice1712 *ice, int rate)
  282. {
  283. unsigned long flags;
  284. unsigned char tmp;
  285. int change;
  286. spin_lock_irqsave(&ice->reg_lock, flags);
  287. tmp = ice->spdif.cs8403_stream_bits;
  288. if (tmp & 0x10) /* consumer */
  289. tmp &= (tmp & 0x01) ? ~0x06 : ~0x60;
  290. switch (rate) {
  291. case 32000: tmp |= (tmp & 0x01) ? 0x02 : 0x00; break;
  292. case 44100: tmp |= (tmp & 0x01) ? 0x06 : 0x40; break;
  293. case 48000: tmp |= (tmp & 0x01) ? 0x04 : 0x20; break;
  294. default: tmp |= (tmp & 0x01) ? 0x06 : 0x40; break;
  295. }
  296. change = ice->spdif.cs8403_stream_bits != tmp;
  297. ice->spdif.cs8403_stream_bits = tmp;
  298. spin_unlock_irqrestore(&ice->reg_lock, flags);
  299. if (change)
  300. snd_ctl_notify(ice->card, SNDRV_CTL_EVENT_MASK_VALUE, &ice->spdif.stream_ctl->id);
  301. snd_ice1712_ews_cs8404_spdif_write(ice, tmp);
  302. }
  303. /*
  304. */
  305. static struct snd_akm4xxx akm_ews88mt __devinitdata = {
  306. .num_adcs = 8,
  307. .num_dacs = 8,
  308. .type = SND_AK4524,
  309. .ops = {
  310. .lock = ews88mt_ak4524_lock,
  311. .unlock = ews88mt_ak4524_unlock
  312. }
  313. };
  314. static struct snd_ak4xxx_private akm_ews88mt_priv __devinitdata = {
  315. .caddr = 2,
  316. .cif = 1, /* CIF high */
  317. .data_mask = ICE1712_EWS88_SERIAL_DATA,
  318. .clk_mask = ICE1712_EWS88_SERIAL_CLOCK,
  319. .cs_mask = 0,
  320. .cs_addr = 0,
  321. .cs_none = 0, /* no chip select on gpio */
  322. .add_flags = ICE1712_EWS88_RW, /* set rw bit high */
  323. .mask_flags = 0,
  324. };
  325. static struct snd_akm4xxx akm_ewx2496 __devinitdata = {
  326. .num_adcs = 2,
  327. .num_dacs = 2,
  328. .type = SND_AK4524,
  329. .ops = {
  330. .lock = ewx2496_ak4524_lock
  331. }
  332. };
  333. static struct snd_ak4xxx_private akm_ewx2496_priv __devinitdata = {
  334. .caddr = 2,
  335. .cif = 1, /* CIF high */
  336. .data_mask = ICE1712_EWS88_SERIAL_DATA,
  337. .clk_mask = ICE1712_EWS88_SERIAL_CLOCK,
  338. .cs_mask = ICE1712_EWX2496_AK4524_CS,
  339. .cs_addr = ICE1712_EWX2496_AK4524_CS,
  340. .cs_none = 0,
  341. .add_flags = ICE1712_EWS88_RW, /* set rw bit high */
  342. .mask_flags = 0,
  343. };
  344. static struct snd_akm4xxx akm_6fire __devinitdata = {
  345. .num_adcs = 6,
  346. .num_dacs = 6,
  347. .type = SND_AK4524,
  348. .ops = {
  349. .lock = dmx6fire_ak4524_lock
  350. }
  351. };
  352. static struct snd_ak4xxx_private akm_6fire_priv __devinitdata = {
  353. .caddr = 2,
  354. .cif = 1, /* CIF high */
  355. .data_mask = ICE1712_6FIRE_SERIAL_DATA,
  356. .clk_mask = ICE1712_6FIRE_SERIAL_CLOCK,
  357. .cs_mask = 0,
  358. .cs_addr = 0, /* set later */
  359. .cs_none = 0,
  360. .add_flags = ICE1712_6FIRE_RW, /* set rw bit high */
  361. .mask_flags = 0,
  362. };
  363. /*
  364. * initialize the chip
  365. */
  366. /* 6fire specific */
  367. #define PCF9554_REG_INPUT 0
  368. #define PCF9554_REG_OUTPUT 1
  369. #define PCF9554_REG_POLARITY 2
  370. #define PCF9554_REG_CONFIG 3
  371. static int snd_ice1712_6fire_write_pca(struct snd_ice1712 *ice, unsigned char reg, unsigned char data);
  372. static int __devinit snd_ice1712_ews_init(struct snd_ice1712 *ice)
  373. {
  374. int err;
  375. struct snd_akm4xxx *ak;
  376. struct ews_spec *spec;
  377. /* set the analog DACs */
  378. switch (ice->eeprom.subvendor) {
  379. case ICE1712_SUBDEVICE_EWX2496:
  380. ice->num_total_dacs = 2;
  381. ice->num_total_adcs = 2;
  382. break;
  383. case ICE1712_SUBDEVICE_EWS88MT:
  384. case ICE1712_SUBDEVICE_EWS88MT_NEW:
  385. case ICE1712_SUBDEVICE_PHASE88:
  386. case ICE1712_SUBDEVICE_TS88:
  387. ice->num_total_dacs = 8;
  388. ice->num_total_adcs = 8;
  389. break;
  390. case ICE1712_SUBDEVICE_EWS88D:
  391. /* Note: not analog but ADAT I/O */
  392. ice->num_total_dacs = 8;
  393. ice->num_total_adcs = 8;
  394. break;
  395. case ICE1712_SUBDEVICE_DMX6FIRE:
  396. ice->num_total_dacs = 6;
  397. ice->num_total_adcs = 6;
  398. break;
  399. }
  400. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  401. if (!spec)
  402. return -ENOMEM;
  403. ice->spec = spec;
  404. /* create i2c */
  405. if ((err = snd_i2c_bus_create(ice->card, "ICE1712 GPIO 1", NULL, &ice->i2c)) < 0) {
  406. snd_printk(KERN_ERR "unable to create I2C bus\n");
  407. return err;
  408. }
  409. ice->i2c->private_data = ice;
  410. ice->i2c->hw_ops.bit = &snd_ice1712_ewx_cs8427_bit_ops;
  411. /* create i2c devices */
  412. switch (ice->eeprom.subvendor) {
  413. case ICE1712_SUBDEVICE_DMX6FIRE:
  414. err = snd_i2c_device_create(ice->i2c, "PCF9554",
  415. ICE1712_6FIRE_PCF9554_ADDR,
  416. &spec->i2cdevs[EWS_I2C_6FIRE]);
  417. if (err < 0) {
  418. snd_printk(KERN_ERR "PCF9554 initialization failed\n");
  419. return err;
  420. }
  421. snd_ice1712_6fire_write_pca(ice, PCF9554_REG_CONFIG, 0x80);
  422. break;
  423. case ICE1712_SUBDEVICE_EWS88MT:
  424. case ICE1712_SUBDEVICE_EWS88MT_NEW:
  425. case ICE1712_SUBDEVICE_PHASE88:
  426. case ICE1712_SUBDEVICE_TS88:
  427. err = snd_i2c_device_create(ice->i2c, "CS8404",
  428. ICE1712_EWS88MT_CS8404_ADDR,
  429. &spec->i2cdevs[EWS_I2C_CS8404]);
  430. if (err < 0)
  431. return err;
  432. err = snd_i2c_device_create(ice->i2c, "PCF8574 (1st)",
  433. ICE1712_EWS88MT_INPUT_ADDR,
  434. &spec->i2cdevs[EWS_I2C_PCF1]);
  435. if (err < 0)
  436. return err;
  437. err = snd_i2c_device_create(ice->i2c, "PCF8574 (2nd)",
  438. ICE1712_EWS88MT_OUTPUT_ADDR,
  439. &spec->i2cdevs[EWS_I2C_PCF2]);
  440. if (err < 0)
  441. return err;
  442. /* Check if the front module is connected */
  443. if ((err = snd_ice1712_ews88mt_chip_select(ice, 0x0f)) < 0)
  444. return err;
  445. break;
  446. case ICE1712_SUBDEVICE_EWS88D:
  447. err = snd_i2c_device_create(ice->i2c, "PCF8575",
  448. ICE1712_EWS88D_PCF_ADDR,
  449. &spec->i2cdevs[EWS_I2C_88D]);
  450. if (err < 0)
  451. return err;
  452. break;
  453. }
  454. /* set up SPDIF interface */
  455. switch (ice->eeprom.subvendor) {
  456. case ICE1712_SUBDEVICE_EWX2496:
  457. if ((err = snd_ice1712_init_cs8427(ice, CS8427_BASE_ADDR)) < 0)
  458. return err;
  459. snd_cs8427_reg_write(ice->cs8427, CS8427_REG_RECVERRMASK, CS8427_UNLOCK | CS8427_CONF | CS8427_BIP | CS8427_PAR);
  460. break;
  461. case ICE1712_SUBDEVICE_DMX6FIRE:
  462. if ((err = snd_ice1712_init_cs8427(ice, ICE1712_6FIRE_CS8427_ADDR)) < 0)
  463. return err;
  464. snd_cs8427_reg_write(ice->cs8427, CS8427_REG_RECVERRMASK, CS8427_UNLOCK | CS8427_CONF | CS8427_BIP | CS8427_PAR);
  465. break;
  466. case ICE1712_SUBDEVICE_EWS88MT:
  467. case ICE1712_SUBDEVICE_EWS88MT_NEW:
  468. case ICE1712_SUBDEVICE_PHASE88:
  469. case ICE1712_SUBDEVICE_TS88:
  470. case ICE1712_SUBDEVICE_EWS88D:
  471. /* set up CS8404 */
  472. ice->spdif.ops.open = ews88_open_spdif;
  473. ice->spdif.ops.setup_rate = ews88_setup_spdif;
  474. ice->spdif.ops.default_get = ews88_spdif_default_get;
  475. ice->spdif.ops.default_put = ews88_spdif_default_put;
  476. ice->spdif.ops.stream_get = ews88_spdif_stream_get;
  477. ice->spdif.ops.stream_put = ews88_spdif_stream_put;
  478. /* Set spdif defaults */
  479. snd_ice1712_ews_cs8404_spdif_write(ice, ice->spdif.cs8403_bits);
  480. break;
  481. }
  482. /* no analog? */
  483. switch (ice->eeprom.subvendor) {
  484. case ICE1712_SUBDEVICE_EWS88D:
  485. return 0;
  486. }
  487. /* analog section */
  488. ak = ice->akm = kzalloc(sizeof(struct snd_akm4xxx), GFP_KERNEL);
  489. if (! ak)
  490. return -ENOMEM;
  491. ice->akm_codecs = 1;
  492. switch (ice->eeprom.subvendor) {
  493. case ICE1712_SUBDEVICE_EWS88MT:
  494. case ICE1712_SUBDEVICE_EWS88MT_NEW:
  495. case ICE1712_SUBDEVICE_PHASE88:
  496. case ICE1712_SUBDEVICE_TS88:
  497. err = snd_ice1712_akm4xxx_init(ak, &akm_ews88mt, &akm_ews88mt_priv, ice);
  498. break;
  499. case ICE1712_SUBDEVICE_EWX2496:
  500. err = snd_ice1712_akm4xxx_init(ak, &akm_ewx2496, &akm_ewx2496_priv, ice);
  501. break;
  502. case ICE1712_SUBDEVICE_DMX6FIRE:
  503. err = snd_ice1712_akm4xxx_init(ak, &akm_6fire, &akm_6fire_priv, ice);
  504. break;
  505. default:
  506. err = 0;
  507. }
  508. return err;
  509. }
  510. /*
  511. * EWX 24/96 specific controls
  512. */
  513. /* i/o sensitivity - this callback is shared among other devices, too */
  514. static int snd_ice1712_ewx_io_sense_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo){
  515. static char *texts[2] = {
  516. "+4dBu", "-10dBV",
  517. };
  518. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  519. uinfo->count = 1;
  520. uinfo->value.enumerated.items = 2;
  521. if (uinfo->value.enumerated.item >= 2)
  522. uinfo->value.enumerated.item = 1;
  523. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  524. return 0;
  525. }
  526. static int snd_ice1712_ewx_io_sense_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  527. {
  528. struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
  529. unsigned char mask = kcontrol->private_value & 0xff;
  530. snd_ice1712_save_gpio_status(ice);
  531. ucontrol->value.enumerated.item[0] = snd_ice1712_read(ice, ICE1712_IREG_GPIO_DATA) & mask ? 1 : 0;
  532. snd_ice1712_restore_gpio_status(ice);
  533. return 0;
  534. }
  535. static int snd_ice1712_ewx_io_sense_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  536. {
  537. struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
  538. unsigned char mask = kcontrol->private_value & 0xff;
  539. int val, nval;
  540. if (kcontrol->private_value & (1 << 31))
  541. return -EPERM;
  542. nval = ucontrol->value.enumerated.item[0] ? mask : 0;
  543. snd_ice1712_save_gpio_status(ice);
  544. val = snd_ice1712_read(ice, ICE1712_IREG_GPIO_DATA);
  545. nval |= val & ~mask;
  546. snd_ice1712_write(ice, ICE1712_IREG_GPIO_DATA, nval);
  547. snd_ice1712_restore_gpio_status(ice);
  548. return val != nval;
  549. }
  550. static struct snd_kcontrol_new snd_ice1712_ewx2496_controls[] __devinitdata = {
  551. {
  552. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  553. .name = "Input Sensitivity Switch",
  554. .info = snd_ice1712_ewx_io_sense_info,
  555. .get = snd_ice1712_ewx_io_sense_get,
  556. .put = snd_ice1712_ewx_io_sense_put,
  557. .private_value = ICE1712_EWX2496_AIN_SEL,
  558. },
  559. {
  560. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  561. .name = "Output Sensitivity Switch",
  562. .info = snd_ice1712_ewx_io_sense_info,
  563. .get = snd_ice1712_ewx_io_sense_get,
  564. .put = snd_ice1712_ewx_io_sense_put,
  565. .private_value = ICE1712_EWX2496_AOUT_SEL,
  566. },
  567. };
  568. /*
  569. * EWS88MT specific controls
  570. */
  571. /* analog output sensitivity;; address 0x48 bit 6 */
  572. static int snd_ice1712_ews88mt_output_sense_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  573. {
  574. struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
  575. struct ews_spec *spec = ice->spec;
  576. unsigned char data;
  577. snd_i2c_lock(ice->i2c);
  578. if (snd_i2c_readbytes(spec->i2cdevs[EWS_I2C_PCF2], &data, 1) != 1) {
  579. snd_i2c_unlock(ice->i2c);
  580. return -EIO;
  581. }
  582. snd_i2c_unlock(ice->i2c);
  583. ucontrol->value.enumerated.item[0] = data & ICE1712_EWS88MT_OUTPUT_SENSE ? 1 : 0; /* high = -10dBV, low = +4dBu */
  584. return 0;
  585. }
  586. /* analog output sensitivity;; address 0x48 bit 6 */
  587. static int snd_ice1712_ews88mt_output_sense_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  588. {
  589. struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
  590. struct ews_spec *spec = ice->spec;
  591. unsigned char data, ndata;
  592. snd_i2c_lock(ice->i2c);
  593. if (snd_i2c_readbytes(spec->i2cdevs[EWS_I2C_PCF2], &data, 1) != 1) {
  594. snd_i2c_unlock(ice->i2c);
  595. return -EIO;
  596. }
  597. ndata = (data & ~ICE1712_EWS88MT_OUTPUT_SENSE) | (ucontrol->value.enumerated.item[0] ? ICE1712_EWS88MT_OUTPUT_SENSE : 0);
  598. if (ndata != data && snd_i2c_sendbytes(spec->i2cdevs[EWS_I2C_PCF2],
  599. &ndata, 1) != 1) {
  600. snd_i2c_unlock(ice->i2c);
  601. return -EIO;
  602. }
  603. snd_i2c_unlock(ice->i2c);
  604. return ndata != data;
  605. }
  606. /* analog input sensitivity; address 0x46 */
  607. static int snd_ice1712_ews88mt_input_sense_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  608. {
  609. struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
  610. struct ews_spec *spec = ice->spec;
  611. int channel = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  612. unsigned char data;
  613. snd_assert(channel >= 0 && channel <= 7, return 0);
  614. snd_i2c_lock(ice->i2c);
  615. if (snd_i2c_readbytes(spec->i2cdevs[EWS_I2C_PCF1], &data, 1) != 1) {
  616. snd_i2c_unlock(ice->i2c);
  617. return -EIO;
  618. }
  619. /* reversed; high = +4dBu, low = -10dBV */
  620. ucontrol->value.enumerated.item[0] = data & (1 << channel) ? 0 : 1;
  621. snd_i2c_unlock(ice->i2c);
  622. return 0;
  623. }
  624. /* analog output sensitivity; address 0x46 */
  625. static int snd_ice1712_ews88mt_input_sense_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  626. {
  627. struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
  628. struct ews_spec *spec = ice->spec;
  629. int channel = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  630. unsigned char data, ndata;
  631. snd_assert(channel >= 0 && channel <= 7, return 0);
  632. snd_i2c_lock(ice->i2c);
  633. if (snd_i2c_readbytes(spec->i2cdevs[EWS_I2C_PCF1], &data, 1) != 1) {
  634. snd_i2c_unlock(ice->i2c);
  635. return -EIO;
  636. }
  637. ndata = (data & ~(1 << channel)) | (ucontrol->value.enumerated.item[0] ? 0 : (1 << channel));
  638. if (ndata != data && snd_i2c_sendbytes(spec->i2cdevs[EWS_I2C_PCF1],
  639. &ndata, 1) != 1) {
  640. snd_i2c_unlock(ice->i2c);
  641. return -EIO;
  642. }
  643. snd_i2c_unlock(ice->i2c);
  644. return ndata != data;
  645. }
  646. static struct snd_kcontrol_new snd_ice1712_ews88mt_input_sense __devinitdata = {
  647. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  648. .name = "Input Sensitivity Switch",
  649. .info = snd_ice1712_ewx_io_sense_info,
  650. .get = snd_ice1712_ews88mt_input_sense_get,
  651. .put = snd_ice1712_ews88mt_input_sense_put,
  652. .count = 8,
  653. };
  654. static struct snd_kcontrol_new snd_ice1712_ews88mt_output_sense __devinitdata = {
  655. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  656. .name = "Output Sensitivity Switch",
  657. .info = snd_ice1712_ewx_io_sense_info,
  658. .get = snd_ice1712_ews88mt_output_sense_get,
  659. .put = snd_ice1712_ews88mt_output_sense_put,
  660. };
  661. /*
  662. * EWS88D specific controls
  663. */
  664. #define snd_ice1712_ews88d_control_info snd_ctl_boolean_mono_info
  665. static int snd_ice1712_ews88d_control_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  666. {
  667. struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
  668. struct ews_spec *spec = ice->spec;
  669. int shift = kcontrol->private_value & 0xff;
  670. int invert = (kcontrol->private_value >> 8) & 1;
  671. unsigned char data[2];
  672. snd_i2c_lock(ice->i2c);
  673. if (snd_i2c_readbytes(spec->i2cdevs[EWS_I2C_88D], data, 2) != 2) {
  674. snd_i2c_unlock(ice->i2c);
  675. return -EIO;
  676. }
  677. snd_i2c_unlock(ice->i2c);
  678. data[0] = (data[shift >> 3] >> (shift & 7)) & 0x01;
  679. if (invert)
  680. data[0] ^= 0x01;
  681. ucontrol->value.integer.value[0] = data[0];
  682. return 0;
  683. }
  684. static int snd_ice1712_ews88d_control_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  685. {
  686. struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
  687. struct ews_spec *spec = ice->spec;
  688. int shift = kcontrol->private_value & 0xff;
  689. int invert = (kcontrol->private_value >> 8) & 1;
  690. unsigned char data[2], ndata[2];
  691. int change;
  692. snd_i2c_lock(ice->i2c);
  693. if (snd_i2c_readbytes(spec->i2cdevs[EWS_I2C_88D], data, 2) != 2) {
  694. snd_i2c_unlock(ice->i2c);
  695. return -EIO;
  696. }
  697. ndata[shift >> 3] = data[shift >> 3] & ~(1 << (shift & 7));
  698. if (invert) {
  699. if (! ucontrol->value.integer.value[0])
  700. ndata[shift >> 3] |= (1 << (shift & 7));
  701. } else {
  702. if (ucontrol->value.integer.value[0])
  703. ndata[shift >> 3] |= (1 << (shift & 7));
  704. }
  705. change = (data[shift >> 3] != ndata[shift >> 3]);
  706. if (change &&
  707. snd_i2c_sendbytes(spec->i2cdevs[EWS_I2C_88D], data, 2) != 2) {
  708. snd_i2c_unlock(ice->i2c);
  709. return -EIO;
  710. }
  711. snd_i2c_unlock(ice->i2c);
  712. return change;
  713. }
  714. #define EWS88D_CONTROL(xiface, xname, xshift, xinvert, xaccess) \
  715. { .iface = xiface,\
  716. .name = xname,\
  717. .access = xaccess,\
  718. .info = snd_ice1712_ews88d_control_info,\
  719. .get = snd_ice1712_ews88d_control_get,\
  720. .put = snd_ice1712_ews88d_control_put,\
  721. .private_value = xshift | (xinvert << 8),\
  722. }
  723. static struct snd_kcontrol_new snd_ice1712_ews88d_controls[] __devinitdata = {
  724. EWS88D_CONTROL(SNDRV_CTL_ELEM_IFACE_MIXER, "IEC958 Input Optical", 0, 1, 0), /* inverted */
  725. EWS88D_CONTROL(SNDRV_CTL_ELEM_IFACE_MIXER, "ADAT Output Optical", 1, 0, 0),
  726. EWS88D_CONTROL(SNDRV_CTL_ELEM_IFACE_MIXER, "ADAT External Master Clock", 2, 0, 0),
  727. EWS88D_CONTROL(SNDRV_CTL_ELEM_IFACE_MIXER, "Enable ADAT", 3, 0, 0),
  728. EWS88D_CONTROL(SNDRV_CTL_ELEM_IFACE_MIXER, "ADAT Through", 4, 1, 0),
  729. };
  730. /*
  731. * DMX 6Fire specific controls
  732. */
  733. static int snd_ice1712_6fire_read_pca(struct snd_ice1712 *ice, unsigned char reg)
  734. {
  735. unsigned char byte;
  736. struct ews_spec *spec = ice->spec;
  737. snd_i2c_lock(ice->i2c);
  738. byte = reg;
  739. snd_i2c_sendbytes(spec->i2cdevs[EWS_I2C_6FIRE], &byte, 1);
  740. byte = 0;
  741. if (snd_i2c_readbytes(spec->i2cdevs[EWS_I2C_6FIRE], &byte, 1) != 1) {
  742. snd_i2c_unlock(ice->i2c);
  743. printk(KERN_ERR "cannot read pca\n");
  744. return -EIO;
  745. }
  746. snd_i2c_unlock(ice->i2c);
  747. return byte;
  748. }
  749. static int snd_ice1712_6fire_write_pca(struct snd_ice1712 *ice, unsigned char reg, unsigned char data)
  750. {
  751. unsigned char bytes[2];
  752. struct ews_spec *spec = ice->spec;
  753. snd_i2c_lock(ice->i2c);
  754. bytes[0] = reg;
  755. bytes[1] = data;
  756. if (snd_i2c_sendbytes(spec->i2cdevs[EWS_I2C_6FIRE], bytes, 2) != 2) {
  757. snd_i2c_unlock(ice->i2c);
  758. return -EIO;
  759. }
  760. snd_i2c_unlock(ice->i2c);
  761. return 0;
  762. }
  763. #define snd_ice1712_6fire_control_info snd_ctl_boolean_mono_info
  764. static int snd_ice1712_6fire_control_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  765. {
  766. struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
  767. int shift = kcontrol->private_value & 0xff;
  768. int invert = (kcontrol->private_value >> 8) & 1;
  769. int data;
  770. if ((data = snd_ice1712_6fire_read_pca(ice, PCF9554_REG_OUTPUT)) < 0)
  771. return data;
  772. data = (data >> shift) & 1;
  773. if (invert)
  774. data ^= 1;
  775. ucontrol->value.integer.value[0] = data;
  776. return 0;
  777. }
  778. static int snd_ice1712_6fire_control_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  779. {
  780. struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
  781. int shift = kcontrol->private_value & 0xff;
  782. int invert = (kcontrol->private_value >> 8) & 1;
  783. int data, ndata;
  784. if ((data = snd_ice1712_6fire_read_pca(ice, PCF9554_REG_OUTPUT)) < 0)
  785. return data;
  786. ndata = data & ~(1 << shift);
  787. if (ucontrol->value.integer.value[0])
  788. ndata |= (1 << shift);
  789. if (invert)
  790. ndata ^= (1 << shift);
  791. if (data != ndata) {
  792. snd_ice1712_6fire_write_pca(ice, PCF9554_REG_OUTPUT, (unsigned char)ndata);
  793. return 1;
  794. }
  795. return 0;
  796. }
  797. static int snd_ice1712_6fire_select_input_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
  798. {
  799. static char *texts[4] = {
  800. "Internal", "Front Input", "Rear Input", "Wave Table"
  801. };
  802. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  803. uinfo->count = 1;
  804. uinfo->value.enumerated.items = 4;
  805. if (uinfo->value.enumerated.item >= 4)
  806. uinfo->value.enumerated.item = 1;
  807. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  808. return 0;
  809. }
  810. static int snd_ice1712_6fire_select_input_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  811. {
  812. struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
  813. int data;
  814. if ((data = snd_ice1712_6fire_read_pca(ice, PCF9554_REG_OUTPUT)) < 0)
  815. return data;
  816. ucontrol->value.integer.value[0] = data & 3;
  817. return 0;
  818. }
  819. static int snd_ice1712_6fire_select_input_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  820. {
  821. struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
  822. int data, ndata;
  823. if ((data = snd_ice1712_6fire_read_pca(ice, PCF9554_REG_OUTPUT)) < 0)
  824. return data;
  825. ndata = data & ~3;
  826. ndata |= (ucontrol->value.integer.value[0] & 3);
  827. if (data != ndata) {
  828. snd_ice1712_6fire_write_pca(ice, PCF9554_REG_OUTPUT, (unsigned char)ndata);
  829. return 1;
  830. }
  831. return 0;
  832. }
  833. #define DMX6FIRE_CONTROL(xname, xshift, xinvert) \
  834. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER,\
  835. .name = xname,\
  836. .info = snd_ice1712_6fire_control_info,\
  837. .get = snd_ice1712_6fire_control_get,\
  838. .put = snd_ice1712_6fire_control_put,\
  839. .private_value = xshift | (xinvert << 8),\
  840. }
  841. static struct snd_kcontrol_new snd_ice1712_6fire_controls[] __devinitdata = {
  842. {
  843. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  844. .name = "Analog Input Select",
  845. .info = snd_ice1712_6fire_select_input_info,
  846. .get = snd_ice1712_6fire_select_input_get,
  847. .put = snd_ice1712_6fire_select_input_put,
  848. },
  849. DMX6FIRE_CONTROL("Front Digital Input Switch", 2, 1),
  850. // DMX6FIRE_CONTROL("Master Clock Select", 3, 0),
  851. DMX6FIRE_CONTROL("Optical Digital Input Switch", 4, 0),
  852. DMX6FIRE_CONTROL("Phono Analog Input Switch", 5, 0),
  853. DMX6FIRE_CONTROL("Breakbox LED", 6, 0),
  854. };
  855. static int __devinit snd_ice1712_ews_add_controls(struct snd_ice1712 *ice)
  856. {
  857. unsigned int idx;
  858. int err;
  859. /* all terratec cards have spdif, but cs8427 module builds it's own controls */
  860. if (ice->cs8427 == NULL) {
  861. err = snd_ice1712_spdif_build_controls(ice);
  862. if (err < 0)
  863. return err;
  864. }
  865. /* ak4524 controls */
  866. switch (ice->eeprom.subvendor) {
  867. case ICE1712_SUBDEVICE_EWX2496:
  868. case ICE1712_SUBDEVICE_EWS88MT:
  869. case ICE1712_SUBDEVICE_EWS88MT_NEW:
  870. case ICE1712_SUBDEVICE_PHASE88:
  871. case ICE1712_SUBDEVICE_TS88:
  872. case ICE1712_SUBDEVICE_DMX6FIRE:
  873. err = snd_ice1712_akm4xxx_build_controls(ice);
  874. if (err < 0)
  875. return err;
  876. break;
  877. }
  878. /* card specific controls */
  879. switch (ice->eeprom.subvendor) {
  880. case ICE1712_SUBDEVICE_EWX2496:
  881. for (idx = 0; idx < ARRAY_SIZE(snd_ice1712_ewx2496_controls); idx++) {
  882. err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_ice1712_ewx2496_controls[idx], ice));
  883. if (err < 0)
  884. return err;
  885. }
  886. break;
  887. case ICE1712_SUBDEVICE_EWS88MT:
  888. case ICE1712_SUBDEVICE_EWS88MT_NEW:
  889. case ICE1712_SUBDEVICE_PHASE88:
  890. case ICE1712_SUBDEVICE_TS88:
  891. err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_ice1712_ews88mt_input_sense, ice));
  892. if (err < 0)
  893. return err;
  894. err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_ice1712_ews88mt_output_sense, ice));
  895. if (err < 0)
  896. return err;
  897. break;
  898. case ICE1712_SUBDEVICE_EWS88D:
  899. for (idx = 0; idx < ARRAY_SIZE(snd_ice1712_ews88d_controls); idx++) {
  900. err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_ice1712_ews88d_controls[idx], ice));
  901. if (err < 0)
  902. return err;
  903. }
  904. break;
  905. case ICE1712_SUBDEVICE_DMX6FIRE:
  906. for (idx = 0; idx < ARRAY_SIZE(snd_ice1712_6fire_controls); idx++) {
  907. err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_ice1712_6fire_controls[idx], ice));
  908. if (err < 0)
  909. return err;
  910. }
  911. break;
  912. }
  913. return 0;
  914. }
  915. /* entry point */
  916. struct snd_ice1712_card_info snd_ice1712_ews_cards[] __devinitdata = {
  917. {
  918. .subvendor = ICE1712_SUBDEVICE_EWX2496,
  919. .name = "TerraTec EWX24/96",
  920. .model = "ewx2496",
  921. .chip_init = snd_ice1712_ews_init,
  922. .build_controls = snd_ice1712_ews_add_controls,
  923. },
  924. {
  925. .subvendor = ICE1712_SUBDEVICE_EWS88MT,
  926. .name = "TerraTec EWS88MT",
  927. .model = "ews88mt",
  928. .chip_init = snd_ice1712_ews_init,
  929. .build_controls = snd_ice1712_ews_add_controls,
  930. },
  931. {
  932. .subvendor = ICE1712_SUBDEVICE_EWS88MT_NEW,
  933. .name = "TerraTec EWS88MT",
  934. .model = "ews88mt_new",
  935. .chip_init = snd_ice1712_ews_init,
  936. .build_controls = snd_ice1712_ews_add_controls,
  937. },
  938. {
  939. .subvendor = ICE1712_SUBDEVICE_PHASE88,
  940. .name = "TerraTec Phase88",
  941. .model = "phase88",
  942. .chip_init = snd_ice1712_ews_init,
  943. .build_controls = snd_ice1712_ews_add_controls,
  944. },
  945. {
  946. .subvendor = ICE1712_SUBDEVICE_TS88,
  947. .name = "terrasoniq TS88",
  948. .model = "phase88",
  949. .chip_init = snd_ice1712_ews_init,
  950. .build_controls = snd_ice1712_ews_add_controls,
  951. },
  952. {
  953. .subvendor = ICE1712_SUBDEVICE_EWS88D,
  954. .name = "TerraTec EWS88D",
  955. .model = "ews88d",
  956. .chip_init = snd_ice1712_ews_init,
  957. .build_controls = snd_ice1712_ews_add_controls,
  958. },
  959. {
  960. .subvendor = ICE1712_SUBDEVICE_DMX6FIRE,
  961. .name = "TerraTec DMX6Fire",
  962. .model = "dmx6fire",
  963. .chip_init = snd_ice1712_ews_init,
  964. .build_controls = snd_ice1712_ews_add_controls,
  965. .mpu401_1_name = "MIDI-Front DMX6fire",
  966. .mpu401_2_name = "Wavetable DMX6fire",
  967. .mpu401_2_info_flags = MPU401_INFO_OUTPUT,
  968. },
  969. { } /* terminator */
  970. };