ews.c 31 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069
  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. if (snd_i2c_sendbytes(spec->i2cdevs[EWS_I2C_CS8404], &bits, 1)
  214. != 1)
  215. goto _error;
  216. break;
  217. case ICE1712_SUBDEVICE_EWS88D:
  218. if (snd_i2c_readbytes(spec->i2cdevs[EWS_I2C_88D], bytes, 2)
  219. != 2)
  220. goto _error;
  221. if (bits != bytes[1]) {
  222. bytes[1] = bits;
  223. if (snd_i2c_sendbytes(spec->i2cdevs[EWS_I2C_88D],
  224. bytes, 2) != 2)
  225. goto _error;
  226. }
  227. break;
  228. }
  229. _error:
  230. snd_i2c_unlock(ice->i2c);
  231. }
  232. /*
  233. */
  234. static void ews88_spdif_default_get(struct snd_ice1712 *ice, struct snd_ctl_elem_value *ucontrol)
  235. {
  236. snd_cs8404_decode_spdif_bits(&ucontrol->value.iec958, ice->spdif.cs8403_bits);
  237. }
  238. static int ews88_spdif_default_put(struct snd_ice1712 *ice, struct snd_ctl_elem_value *ucontrol)
  239. {
  240. unsigned int val;
  241. int change;
  242. val = snd_cs8404_encode_spdif_bits(&ucontrol->value.iec958);
  243. spin_lock_irq(&ice->reg_lock);
  244. change = ice->spdif.cs8403_bits != val;
  245. ice->spdif.cs8403_bits = val;
  246. if (change && ice->playback_pro_substream == NULL) {
  247. spin_unlock_irq(&ice->reg_lock);
  248. snd_ice1712_ews_cs8404_spdif_write(ice, val);
  249. } else {
  250. spin_unlock_irq(&ice->reg_lock);
  251. }
  252. return change;
  253. }
  254. static void ews88_spdif_stream_get(struct snd_ice1712 *ice, struct snd_ctl_elem_value *ucontrol)
  255. {
  256. snd_cs8404_decode_spdif_bits(&ucontrol->value.iec958, ice->spdif.cs8403_stream_bits);
  257. }
  258. static int ews88_spdif_stream_put(struct snd_ice1712 *ice, struct snd_ctl_elem_value *ucontrol)
  259. {
  260. unsigned int val;
  261. int change;
  262. val = snd_cs8404_encode_spdif_bits(&ucontrol->value.iec958);
  263. spin_lock_irq(&ice->reg_lock);
  264. change = ice->spdif.cs8403_stream_bits != val;
  265. ice->spdif.cs8403_stream_bits = val;
  266. if (change && ice->playback_pro_substream != NULL) {
  267. spin_unlock_irq(&ice->reg_lock);
  268. snd_ice1712_ews_cs8404_spdif_write(ice, val);
  269. } else {
  270. spin_unlock_irq(&ice->reg_lock);
  271. }
  272. return change;
  273. }
  274. /* open callback */
  275. static void ews88_open_spdif(struct snd_ice1712 *ice, struct snd_pcm_substream *substream)
  276. {
  277. ice->spdif.cs8403_stream_bits = ice->spdif.cs8403_bits;
  278. }
  279. /* set up SPDIF for EWS88MT / EWS88D */
  280. static void ews88_setup_spdif(struct snd_ice1712 *ice, int rate)
  281. {
  282. unsigned long flags;
  283. unsigned char tmp;
  284. int change;
  285. spin_lock_irqsave(&ice->reg_lock, flags);
  286. tmp = ice->spdif.cs8403_stream_bits;
  287. if (tmp & 0x10) /* consumer */
  288. tmp &= (tmp & 0x01) ? ~0x06 : ~0x60;
  289. switch (rate) {
  290. case 32000: tmp |= (tmp & 0x01) ? 0x02 : 0x00; break;
  291. case 44100: tmp |= (tmp & 0x01) ? 0x06 : 0x40; break;
  292. case 48000: tmp |= (tmp & 0x01) ? 0x04 : 0x20; break;
  293. default: tmp |= (tmp & 0x01) ? 0x06 : 0x40; break;
  294. }
  295. change = ice->spdif.cs8403_stream_bits != tmp;
  296. ice->spdif.cs8403_stream_bits = tmp;
  297. spin_unlock_irqrestore(&ice->reg_lock, flags);
  298. if (change)
  299. snd_ctl_notify(ice->card, SNDRV_CTL_EVENT_MASK_VALUE, &ice->spdif.stream_ctl->id);
  300. snd_ice1712_ews_cs8404_spdif_write(ice, tmp);
  301. }
  302. /*
  303. */
  304. static struct snd_akm4xxx akm_ews88mt __devinitdata = {
  305. .num_adcs = 8,
  306. .num_dacs = 8,
  307. .type = SND_AK4524,
  308. .ops = {
  309. .lock = ews88mt_ak4524_lock,
  310. .unlock = ews88mt_ak4524_unlock
  311. }
  312. };
  313. static struct snd_ak4xxx_private akm_ews88mt_priv __devinitdata = {
  314. .caddr = 2,
  315. .cif = 1, /* CIF high */
  316. .data_mask = ICE1712_EWS88_SERIAL_DATA,
  317. .clk_mask = ICE1712_EWS88_SERIAL_CLOCK,
  318. .cs_mask = 0,
  319. .cs_addr = 0,
  320. .cs_none = 0, /* no chip select on gpio */
  321. .add_flags = ICE1712_EWS88_RW, /* set rw bit high */
  322. .mask_flags = 0,
  323. };
  324. static struct snd_akm4xxx akm_ewx2496 __devinitdata = {
  325. .num_adcs = 2,
  326. .num_dacs = 2,
  327. .type = SND_AK4524,
  328. .ops = {
  329. .lock = ewx2496_ak4524_lock
  330. }
  331. };
  332. static struct snd_ak4xxx_private akm_ewx2496_priv __devinitdata = {
  333. .caddr = 2,
  334. .cif = 1, /* CIF high */
  335. .data_mask = ICE1712_EWS88_SERIAL_DATA,
  336. .clk_mask = ICE1712_EWS88_SERIAL_CLOCK,
  337. .cs_mask = ICE1712_EWX2496_AK4524_CS,
  338. .cs_addr = ICE1712_EWX2496_AK4524_CS,
  339. .cs_none = 0,
  340. .add_flags = ICE1712_EWS88_RW, /* set rw bit high */
  341. .mask_flags = 0,
  342. };
  343. static struct snd_akm4xxx akm_6fire __devinitdata = {
  344. .num_adcs = 6,
  345. .num_dacs = 6,
  346. .type = SND_AK4524,
  347. .ops = {
  348. .lock = dmx6fire_ak4524_lock
  349. }
  350. };
  351. static struct snd_ak4xxx_private akm_6fire_priv __devinitdata = {
  352. .caddr = 2,
  353. .cif = 1, /* CIF high */
  354. .data_mask = ICE1712_6FIRE_SERIAL_DATA,
  355. .clk_mask = ICE1712_6FIRE_SERIAL_CLOCK,
  356. .cs_mask = 0,
  357. .cs_addr = 0, /* set later */
  358. .cs_none = 0,
  359. .add_flags = ICE1712_6FIRE_RW, /* set rw bit high */
  360. .mask_flags = 0,
  361. };
  362. /*
  363. * initialize the chip
  364. */
  365. /* 6fire specific */
  366. #define PCF9554_REG_INPUT 0
  367. #define PCF9554_REG_OUTPUT 1
  368. #define PCF9554_REG_POLARITY 2
  369. #define PCF9554_REG_CONFIG 3
  370. static int snd_ice1712_6fire_write_pca(struct snd_ice1712 *ice, unsigned char reg, unsigned char data);
  371. static int __devinit snd_ice1712_ews_init(struct snd_ice1712 *ice)
  372. {
  373. int err;
  374. struct snd_akm4xxx *ak;
  375. struct ews_spec *spec;
  376. /* set the analog DACs */
  377. switch (ice->eeprom.subvendor) {
  378. case ICE1712_SUBDEVICE_EWX2496:
  379. ice->num_total_dacs = 2;
  380. ice->num_total_adcs = 2;
  381. break;
  382. case ICE1712_SUBDEVICE_EWS88MT:
  383. case ICE1712_SUBDEVICE_EWS88MT_NEW:
  384. case ICE1712_SUBDEVICE_PHASE88:
  385. ice->num_total_dacs = 8;
  386. ice->num_total_adcs = 8;
  387. break;
  388. case ICE1712_SUBDEVICE_EWS88D:
  389. /* Note: not analog but ADAT I/O */
  390. ice->num_total_dacs = 8;
  391. ice->num_total_adcs = 8;
  392. break;
  393. case ICE1712_SUBDEVICE_DMX6FIRE:
  394. ice->num_total_dacs = 6;
  395. ice->num_total_adcs = 6;
  396. break;
  397. }
  398. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  399. if (!spec)
  400. return -ENOMEM;
  401. ice->spec = spec;
  402. /* create i2c */
  403. if ((err = snd_i2c_bus_create(ice->card, "ICE1712 GPIO 1", NULL, &ice->i2c)) < 0) {
  404. snd_printk(KERN_ERR "unable to create I2C bus\n");
  405. return err;
  406. }
  407. ice->i2c->private_data = ice;
  408. ice->i2c->hw_ops.bit = &snd_ice1712_ewx_cs8427_bit_ops;
  409. /* create i2c devices */
  410. switch (ice->eeprom.subvendor) {
  411. case ICE1712_SUBDEVICE_DMX6FIRE:
  412. err = snd_i2c_device_create(ice->i2c, "PCF9554",
  413. ICE1712_6FIRE_PCF9554_ADDR,
  414. &spec->i2cdevs[EWS_I2C_6FIRE]);
  415. if (err < 0) {
  416. snd_printk(KERN_ERR "PCF9554 initialization failed\n");
  417. return err;
  418. }
  419. snd_ice1712_6fire_write_pca(ice, PCF9554_REG_CONFIG, 0x80);
  420. break;
  421. case ICE1712_SUBDEVICE_EWS88MT:
  422. case ICE1712_SUBDEVICE_EWS88MT_NEW:
  423. case ICE1712_SUBDEVICE_PHASE88:
  424. err = snd_i2c_device_create(ice->i2c, "CS8404",
  425. ICE1712_EWS88MT_CS8404_ADDR,
  426. &spec->i2cdevs[EWS_I2C_CS8404]);
  427. if (err < 0)
  428. return err;
  429. err = snd_i2c_device_create(ice->i2c, "PCF8574 (1st)",
  430. ICE1712_EWS88MT_INPUT_ADDR,
  431. &spec->i2cdevs[EWS_I2C_PCF1]);
  432. if (err < 0)
  433. return err;
  434. err = snd_i2c_device_create(ice->i2c, "PCF8574 (2nd)",
  435. ICE1712_EWS88MT_OUTPUT_ADDR,
  436. &spec->i2cdevs[EWS_I2C_PCF2]);
  437. if (err < 0)
  438. return err;
  439. /* Check if the front module is connected */
  440. if ((err = snd_ice1712_ews88mt_chip_select(ice, 0x0f)) < 0)
  441. return err;
  442. break;
  443. case ICE1712_SUBDEVICE_EWS88D:
  444. err = snd_i2c_device_create(ice->i2c, "PCF8575",
  445. ICE1712_EWS88D_PCF_ADDR,
  446. &spec->i2cdevs[EWS_I2C_88D]);
  447. if (err < 0)
  448. return err;
  449. break;
  450. }
  451. /* set up SPDIF interface */
  452. switch (ice->eeprom.subvendor) {
  453. case ICE1712_SUBDEVICE_EWX2496:
  454. if ((err = snd_ice1712_init_cs8427(ice, CS8427_BASE_ADDR)) < 0)
  455. return err;
  456. snd_cs8427_reg_write(ice->cs8427, CS8427_REG_RECVERRMASK, CS8427_UNLOCK | CS8427_CONF | CS8427_BIP | CS8427_PAR);
  457. break;
  458. case ICE1712_SUBDEVICE_DMX6FIRE:
  459. if ((err = snd_ice1712_init_cs8427(ice, ICE1712_6FIRE_CS8427_ADDR)) < 0)
  460. return err;
  461. snd_cs8427_reg_write(ice->cs8427, CS8427_REG_RECVERRMASK, CS8427_UNLOCK | CS8427_CONF | CS8427_BIP | CS8427_PAR);
  462. break;
  463. case ICE1712_SUBDEVICE_EWS88MT:
  464. case ICE1712_SUBDEVICE_EWS88MT_NEW:
  465. case ICE1712_SUBDEVICE_PHASE88:
  466. case ICE1712_SUBDEVICE_EWS88D:
  467. /* set up CS8404 */
  468. ice->spdif.ops.open = ews88_open_spdif;
  469. ice->spdif.ops.setup_rate = ews88_setup_spdif;
  470. ice->spdif.ops.default_get = ews88_spdif_default_get;
  471. ice->spdif.ops.default_put = ews88_spdif_default_put;
  472. ice->spdif.ops.stream_get = ews88_spdif_stream_get;
  473. ice->spdif.ops.stream_put = ews88_spdif_stream_put;
  474. /* Set spdif defaults */
  475. snd_ice1712_ews_cs8404_spdif_write(ice, ice->spdif.cs8403_bits);
  476. break;
  477. }
  478. /* no analog? */
  479. switch (ice->eeprom.subvendor) {
  480. case ICE1712_SUBDEVICE_EWS88D:
  481. return 0;
  482. }
  483. /* analog section */
  484. ak = ice->akm = kzalloc(sizeof(struct snd_akm4xxx), GFP_KERNEL);
  485. if (! ak)
  486. return -ENOMEM;
  487. ice->akm_codecs = 1;
  488. switch (ice->eeprom.subvendor) {
  489. case ICE1712_SUBDEVICE_EWS88MT:
  490. case ICE1712_SUBDEVICE_EWS88MT_NEW:
  491. case ICE1712_SUBDEVICE_PHASE88:
  492. err = snd_ice1712_akm4xxx_init(ak, &akm_ews88mt, &akm_ews88mt_priv, ice);
  493. break;
  494. case ICE1712_SUBDEVICE_EWX2496:
  495. err = snd_ice1712_akm4xxx_init(ak, &akm_ewx2496, &akm_ewx2496_priv, ice);
  496. break;
  497. case ICE1712_SUBDEVICE_DMX6FIRE:
  498. err = snd_ice1712_akm4xxx_init(ak, &akm_6fire, &akm_6fire_priv, ice);
  499. break;
  500. default:
  501. err = 0;
  502. }
  503. return err;
  504. }
  505. /*
  506. * EWX 24/96 specific controls
  507. */
  508. /* i/o sensitivity - this callback is shared among other devices, too */
  509. static int snd_ice1712_ewx_io_sense_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo){
  510. static char *texts[2] = {
  511. "+4dBu", "-10dBV",
  512. };
  513. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  514. uinfo->count = 1;
  515. uinfo->value.enumerated.items = 2;
  516. if (uinfo->value.enumerated.item >= 2)
  517. uinfo->value.enumerated.item = 1;
  518. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  519. return 0;
  520. }
  521. static int snd_ice1712_ewx_io_sense_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  522. {
  523. struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
  524. unsigned char mask = kcontrol->private_value & 0xff;
  525. snd_ice1712_save_gpio_status(ice);
  526. ucontrol->value.enumerated.item[0] = snd_ice1712_read(ice, ICE1712_IREG_GPIO_DATA) & mask ? 1 : 0;
  527. snd_ice1712_restore_gpio_status(ice);
  528. return 0;
  529. }
  530. static int snd_ice1712_ewx_io_sense_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  531. {
  532. struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
  533. unsigned char mask = kcontrol->private_value & 0xff;
  534. int val, nval;
  535. if (kcontrol->private_value & (1 << 31))
  536. return -EPERM;
  537. nval = ucontrol->value.enumerated.item[0] ? mask : 0;
  538. snd_ice1712_save_gpio_status(ice);
  539. val = snd_ice1712_read(ice, ICE1712_IREG_GPIO_DATA);
  540. nval |= val & ~mask;
  541. snd_ice1712_write(ice, ICE1712_IREG_GPIO_DATA, nval);
  542. snd_ice1712_restore_gpio_status(ice);
  543. return val != nval;
  544. }
  545. static struct snd_kcontrol_new snd_ice1712_ewx2496_controls[] __devinitdata = {
  546. {
  547. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  548. .name = "Input Sensitivity Switch",
  549. .info = snd_ice1712_ewx_io_sense_info,
  550. .get = snd_ice1712_ewx_io_sense_get,
  551. .put = snd_ice1712_ewx_io_sense_put,
  552. .private_value = ICE1712_EWX2496_AIN_SEL,
  553. },
  554. {
  555. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  556. .name = "Output Sensitivity Switch",
  557. .info = snd_ice1712_ewx_io_sense_info,
  558. .get = snd_ice1712_ewx_io_sense_get,
  559. .put = snd_ice1712_ewx_io_sense_put,
  560. .private_value = ICE1712_EWX2496_AOUT_SEL,
  561. },
  562. };
  563. /*
  564. * EWS88MT specific controls
  565. */
  566. /* analog output sensitivity;; address 0x48 bit 6 */
  567. static int snd_ice1712_ews88mt_output_sense_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  568. {
  569. struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
  570. struct ews_spec *spec = ice->spec;
  571. unsigned char data;
  572. snd_i2c_lock(ice->i2c);
  573. if (snd_i2c_readbytes(spec->i2cdevs[EWS_I2C_PCF2], &data, 1) != 1) {
  574. snd_i2c_unlock(ice->i2c);
  575. return -EIO;
  576. }
  577. snd_i2c_unlock(ice->i2c);
  578. ucontrol->value.enumerated.item[0] = data & ICE1712_EWS88MT_OUTPUT_SENSE ? 1 : 0; /* high = -10dBV, low = +4dBu */
  579. return 0;
  580. }
  581. /* analog output sensitivity;; address 0x48 bit 6 */
  582. static int snd_ice1712_ews88mt_output_sense_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  583. {
  584. struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
  585. struct ews_spec *spec = ice->spec;
  586. unsigned char data, ndata;
  587. snd_i2c_lock(ice->i2c);
  588. if (snd_i2c_readbytes(spec->i2cdevs[EWS_I2C_PCF2], &data, 1) != 1) {
  589. snd_i2c_unlock(ice->i2c);
  590. return -EIO;
  591. }
  592. ndata = (data & ~ICE1712_EWS88MT_OUTPUT_SENSE) | (ucontrol->value.enumerated.item[0] ? ICE1712_EWS88MT_OUTPUT_SENSE : 0);
  593. if (ndata != data && snd_i2c_sendbytes(spec->i2cdevs[EWS_I2C_PCF2],
  594. &ndata, 1) != 1) {
  595. snd_i2c_unlock(ice->i2c);
  596. return -EIO;
  597. }
  598. snd_i2c_unlock(ice->i2c);
  599. return ndata != data;
  600. }
  601. /* analog input sensitivity; address 0x46 */
  602. static int snd_ice1712_ews88mt_input_sense_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  603. {
  604. struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
  605. struct ews_spec *spec = ice->spec;
  606. int channel = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  607. unsigned char data;
  608. snd_assert(channel >= 0 && channel <= 7, return 0);
  609. snd_i2c_lock(ice->i2c);
  610. if (snd_i2c_readbytes(spec->i2cdevs[EWS_I2C_PCF1], &data, 1) != 1) {
  611. snd_i2c_unlock(ice->i2c);
  612. return -EIO;
  613. }
  614. /* reversed; high = +4dBu, low = -10dBV */
  615. ucontrol->value.enumerated.item[0] = data & (1 << channel) ? 0 : 1;
  616. snd_i2c_unlock(ice->i2c);
  617. return 0;
  618. }
  619. /* analog output sensitivity; address 0x46 */
  620. static int snd_ice1712_ews88mt_input_sense_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  621. {
  622. struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
  623. struct ews_spec *spec = ice->spec;
  624. int channel = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  625. unsigned char data, ndata;
  626. snd_assert(channel >= 0 && channel <= 7, return 0);
  627. snd_i2c_lock(ice->i2c);
  628. if (snd_i2c_readbytes(spec->i2cdevs[EWS_I2C_PCF1], &data, 1) != 1) {
  629. snd_i2c_unlock(ice->i2c);
  630. return -EIO;
  631. }
  632. ndata = (data & ~(1 << channel)) | (ucontrol->value.enumerated.item[0] ? 0 : (1 << channel));
  633. if (ndata != data && snd_i2c_sendbytes(spec->i2cdevs[EWS_I2C_PCF1],
  634. &ndata, 1) != 1) {
  635. snd_i2c_unlock(ice->i2c);
  636. return -EIO;
  637. }
  638. snd_i2c_unlock(ice->i2c);
  639. return ndata != data;
  640. }
  641. static struct snd_kcontrol_new snd_ice1712_ews88mt_input_sense __devinitdata = {
  642. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  643. .name = "Input Sensitivity Switch",
  644. .info = snd_ice1712_ewx_io_sense_info,
  645. .get = snd_ice1712_ews88mt_input_sense_get,
  646. .put = snd_ice1712_ews88mt_input_sense_put,
  647. .count = 8,
  648. };
  649. static struct snd_kcontrol_new snd_ice1712_ews88mt_output_sense __devinitdata = {
  650. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  651. .name = "Output Sensitivity Switch",
  652. .info = snd_ice1712_ewx_io_sense_info,
  653. .get = snd_ice1712_ews88mt_output_sense_get,
  654. .put = snd_ice1712_ews88mt_output_sense_put,
  655. };
  656. /*
  657. * EWS88D specific controls
  658. */
  659. #define snd_ice1712_ews88d_control_info snd_ctl_boolean_mono_info
  660. static int snd_ice1712_ews88d_control_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  661. {
  662. struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
  663. struct ews_spec *spec = ice->spec;
  664. int shift = kcontrol->private_value & 0xff;
  665. int invert = (kcontrol->private_value >> 8) & 1;
  666. unsigned char data[2];
  667. snd_i2c_lock(ice->i2c);
  668. if (snd_i2c_readbytes(spec->i2cdevs[EWS_I2C_88D], data, 2) != 2) {
  669. snd_i2c_unlock(ice->i2c);
  670. return -EIO;
  671. }
  672. snd_i2c_unlock(ice->i2c);
  673. data[0] = (data[shift >> 3] >> (shift & 7)) & 0x01;
  674. if (invert)
  675. data[0] ^= 0x01;
  676. ucontrol->value.integer.value[0] = data[0];
  677. return 0;
  678. }
  679. static int snd_ice1712_ews88d_control_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  680. {
  681. struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
  682. struct ews_spec *spec = ice->spec;
  683. int shift = kcontrol->private_value & 0xff;
  684. int invert = (kcontrol->private_value >> 8) & 1;
  685. unsigned char data[2], ndata[2];
  686. int change;
  687. snd_i2c_lock(ice->i2c);
  688. if (snd_i2c_readbytes(spec->i2cdevs[EWS_I2C_88D], data, 2) != 2) {
  689. snd_i2c_unlock(ice->i2c);
  690. return -EIO;
  691. }
  692. ndata[shift >> 3] = data[shift >> 3] & ~(1 << (shift & 7));
  693. if (invert) {
  694. if (! ucontrol->value.integer.value[0])
  695. ndata[shift >> 3] |= (1 << (shift & 7));
  696. } else {
  697. if (ucontrol->value.integer.value[0])
  698. ndata[shift >> 3] |= (1 << (shift & 7));
  699. }
  700. change = (data[shift >> 3] != ndata[shift >> 3]);
  701. if (change &&
  702. snd_i2c_sendbytes(spec->i2cdevs[EWS_I2C_88D], data, 2) != 2) {
  703. snd_i2c_unlock(ice->i2c);
  704. return -EIO;
  705. }
  706. snd_i2c_unlock(ice->i2c);
  707. return change;
  708. }
  709. #define EWS88D_CONTROL(xiface, xname, xshift, xinvert, xaccess) \
  710. { .iface = xiface,\
  711. .name = xname,\
  712. .access = xaccess,\
  713. .info = snd_ice1712_ews88d_control_info,\
  714. .get = snd_ice1712_ews88d_control_get,\
  715. .put = snd_ice1712_ews88d_control_put,\
  716. .private_value = xshift | (xinvert << 8),\
  717. }
  718. static struct snd_kcontrol_new snd_ice1712_ews88d_controls[] __devinitdata = {
  719. EWS88D_CONTROL(SNDRV_CTL_ELEM_IFACE_MIXER, "IEC958 Input Optical", 0, 1, 0), /* inverted */
  720. EWS88D_CONTROL(SNDRV_CTL_ELEM_IFACE_MIXER, "ADAT Output Optical", 1, 0, 0),
  721. EWS88D_CONTROL(SNDRV_CTL_ELEM_IFACE_MIXER, "ADAT External Master Clock", 2, 0, 0),
  722. EWS88D_CONTROL(SNDRV_CTL_ELEM_IFACE_MIXER, "Enable ADAT", 3, 0, 0),
  723. EWS88D_CONTROL(SNDRV_CTL_ELEM_IFACE_MIXER, "ADAT Through", 4, 1, 0),
  724. };
  725. /*
  726. * DMX 6Fire specific controls
  727. */
  728. static int snd_ice1712_6fire_read_pca(struct snd_ice1712 *ice, unsigned char reg)
  729. {
  730. unsigned char byte;
  731. struct ews_spec *spec = ice->spec;
  732. snd_i2c_lock(ice->i2c);
  733. byte = reg;
  734. snd_i2c_sendbytes(spec->i2cdevs[EWS_I2C_6FIRE], &byte, 1);
  735. byte = 0;
  736. if (snd_i2c_readbytes(spec->i2cdevs[EWS_I2C_6FIRE], &byte, 1) != 1) {
  737. snd_i2c_unlock(ice->i2c);
  738. printk(KERN_ERR "cannot read pca\n");
  739. return -EIO;
  740. }
  741. snd_i2c_unlock(ice->i2c);
  742. return byte;
  743. }
  744. static int snd_ice1712_6fire_write_pca(struct snd_ice1712 *ice, unsigned char reg, unsigned char data)
  745. {
  746. unsigned char bytes[2];
  747. struct ews_spec *spec = ice->spec;
  748. snd_i2c_lock(ice->i2c);
  749. bytes[0] = reg;
  750. bytes[1] = data;
  751. if (snd_i2c_sendbytes(spec->i2cdevs[EWS_I2C_6FIRE], bytes, 2) != 2) {
  752. snd_i2c_unlock(ice->i2c);
  753. return -EIO;
  754. }
  755. snd_i2c_unlock(ice->i2c);
  756. return 0;
  757. }
  758. #define snd_ice1712_6fire_control_info snd_ctl_boolean_mono_info
  759. static int snd_ice1712_6fire_control_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  760. {
  761. struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
  762. int shift = kcontrol->private_value & 0xff;
  763. int invert = (kcontrol->private_value >> 8) & 1;
  764. int data;
  765. if ((data = snd_ice1712_6fire_read_pca(ice, PCF9554_REG_OUTPUT)) < 0)
  766. return data;
  767. data = (data >> shift) & 1;
  768. if (invert)
  769. data ^= 1;
  770. ucontrol->value.integer.value[0] = data;
  771. return 0;
  772. }
  773. static int snd_ice1712_6fire_control_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  774. {
  775. struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
  776. int shift = kcontrol->private_value & 0xff;
  777. int invert = (kcontrol->private_value >> 8) & 1;
  778. int data, ndata;
  779. if ((data = snd_ice1712_6fire_read_pca(ice, PCF9554_REG_OUTPUT)) < 0)
  780. return data;
  781. ndata = data & ~(1 << shift);
  782. if (ucontrol->value.integer.value[0])
  783. ndata |= (1 << shift);
  784. if (invert)
  785. ndata ^= (1 << shift);
  786. if (data != ndata) {
  787. snd_ice1712_6fire_write_pca(ice, PCF9554_REG_OUTPUT, (unsigned char)ndata);
  788. return 1;
  789. }
  790. return 0;
  791. }
  792. static int snd_ice1712_6fire_select_input_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
  793. {
  794. static char *texts[4] = {
  795. "Internal", "Front Input", "Rear Input", "Wave Table"
  796. };
  797. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  798. uinfo->count = 1;
  799. uinfo->value.enumerated.items = 4;
  800. if (uinfo->value.enumerated.item >= 4)
  801. uinfo->value.enumerated.item = 1;
  802. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  803. return 0;
  804. }
  805. static int snd_ice1712_6fire_select_input_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  806. {
  807. struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
  808. int data;
  809. if ((data = snd_ice1712_6fire_read_pca(ice, PCF9554_REG_OUTPUT)) < 0)
  810. return data;
  811. ucontrol->value.integer.value[0] = data & 3;
  812. return 0;
  813. }
  814. static int snd_ice1712_6fire_select_input_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  815. {
  816. struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
  817. int data, ndata;
  818. if ((data = snd_ice1712_6fire_read_pca(ice, PCF9554_REG_OUTPUT)) < 0)
  819. return data;
  820. ndata = data & ~3;
  821. ndata |= (ucontrol->value.integer.value[0] & 3);
  822. if (data != ndata) {
  823. snd_ice1712_6fire_write_pca(ice, PCF9554_REG_OUTPUT, (unsigned char)ndata);
  824. return 1;
  825. }
  826. return 0;
  827. }
  828. #define DMX6FIRE_CONTROL(xname, xshift, xinvert) \
  829. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER,\
  830. .name = xname,\
  831. .info = snd_ice1712_6fire_control_info,\
  832. .get = snd_ice1712_6fire_control_get,\
  833. .put = snd_ice1712_6fire_control_put,\
  834. .private_value = xshift | (xinvert << 8),\
  835. }
  836. static struct snd_kcontrol_new snd_ice1712_6fire_controls[] __devinitdata = {
  837. {
  838. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  839. .name = "Analog Input Select",
  840. .info = snd_ice1712_6fire_select_input_info,
  841. .get = snd_ice1712_6fire_select_input_get,
  842. .put = snd_ice1712_6fire_select_input_put,
  843. },
  844. DMX6FIRE_CONTROL("Front Digital Input Switch", 2, 1),
  845. // DMX6FIRE_CONTROL("Master Clock Select", 3, 0),
  846. DMX6FIRE_CONTROL("Optical Digital Input Switch", 4, 0),
  847. DMX6FIRE_CONTROL("Phono Analog Input Switch", 5, 0),
  848. DMX6FIRE_CONTROL("Breakbox LED", 6, 0),
  849. };
  850. static int __devinit snd_ice1712_ews_add_controls(struct snd_ice1712 *ice)
  851. {
  852. unsigned int idx;
  853. int err;
  854. /* all terratec cards have spdif, but cs8427 module builds it's own controls */
  855. if (ice->cs8427 == NULL) {
  856. err = snd_ice1712_spdif_build_controls(ice);
  857. if (err < 0)
  858. return err;
  859. }
  860. /* ak4524 controls */
  861. switch (ice->eeprom.subvendor) {
  862. case ICE1712_SUBDEVICE_EWX2496:
  863. case ICE1712_SUBDEVICE_EWS88MT:
  864. case ICE1712_SUBDEVICE_EWS88MT_NEW:
  865. case ICE1712_SUBDEVICE_PHASE88:
  866. case ICE1712_SUBDEVICE_DMX6FIRE:
  867. err = snd_ice1712_akm4xxx_build_controls(ice);
  868. if (err < 0)
  869. return err;
  870. break;
  871. }
  872. /* card specific controls */
  873. switch (ice->eeprom.subvendor) {
  874. case ICE1712_SUBDEVICE_EWX2496:
  875. for (idx = 0; idx < ARRAY_SIZE(snd_ice1712_ewx2496_controls); idx++) {
  876. err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_ice1712_ewx2496_controls[idx], ice));
  877. if (err < 0)
  878. return err;
  879. }
  880. break;
  881. case ICE1712_SUBDEVICE_EWS88MT:
  882. case ICE1712_SUBDEVICE_EWS88MT_NEW:
  883. case ICE1712_SUBDEVICE_PHASE88:
  884. err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_ice1712_ews88mt_input_sense, ice));
  885. if (err < 0)
  886. return err;
  887. err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_ice1712_ews88mt_output_sense, ice));
  888. if (err < 0)
  889. return err;
  890. break;
  891. case ICE1712_SUBDEVICE_EWS88D:
  892. for (idx = 0; idx < ARRAY_SIZE(snd_ice1712_ews88d_controls); idx++) {
  893. err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_ice1712_ews88d_controls[idx], ice));
  894. if (err < 0)
  895. return err;
  896. }
  897. break;
  898. case ICE1712_SUBDEVICE_DMX6FIRE:
  899. for (idx = 0; idx < ARRAY_SIZE(snd_ice1712_6fire_controls); idx++) {
  900. err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_ice1712_6fire_controls[idx], ice));
  901. if (err < 0)
  902. return err;
  903. }
  904. break;
  905. }
  906. return 0;
  907. }
  908. /* entry point */
  909. struct snd_ice1712_card_info snd_ice1712_ews_cards[] __devinitdata = {
  910. {
  911. .subvendor = ICE1712_SUBDEVICE_EWX2496,
  912. .name = "TerraTec EWX24/96",
  913. .model = "ewx2496",
  914. .chip_init = snd_ice1712_ews_init,
  915. .build_controls = snd_ice1712_ews_add_controls,
  916. },
  917. {
  918. .subvendor = ICE1712_SUBDEVICE_EWS88MT,
  919. .name = "TerraTec EWS88MT",
  920. .model = "ews88mt",
  921. .chip_init = snd_ice1712_ews_init,
  922. .build_controls = snd_ice1712_ews_add_controls,
  923. },
  924. {
  925. .subvendor = ICE1712_SUBDEVICE_EWS88MT_NEW,
  926. .name = "TerraTec EWS88MT",
  927. .model = "ews88mt_new",
  928. .chip_init = snd_ice1712_ews_init,
  929. .build_controls = snd_ice1712_ews_add_controls,
  930. },
  931. {
  932. .subvendor = ICE1712_SUBDEVICE_PHASE88,
  933. .name = "TerraTec Phase88",
  934. .model = "phase88",
  935. .chip_init = snd_ice1712_ews_init,
  936. .build_controls = snd_ice1712_ews_add_controls,
  937. },
  938. {
  939. .subvendor = ICE1712_SUBDEVICE_EWS88D,
  940. .name = "TerraTec EWS88D",
  941. .model = "ews88d",
  942. .chip_init = snd_ice1712_ews_init,
  943. .build_controls = snd_ice1712_ews_add_controls,
  944. },
  945. {
  946. .subvendor = ICE1712_SUBDEVICE_DMX6FIRE,
  947. .name = "TerraTec DMX6Fire",
  948. .model = "dmx6fire",
  949. .chip_init = snd_ice1712_ews_init,
  950. .build_controls = snd_ice1712_ews_add_controls,
  951. .mpu401_1_name = "MIDI-Front DMX6fire",
  952. .mpu401_2_name = "Wavetable DMX6fire",
  953. .mpu401_2_info_flags = MPU401_INFO_OUTPUT,
  954. },
  955. { } /* terminator */
  956. };