ews.c 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086
  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 <linux/delay.h>
  25. #include <linux/interrupt.h>
  26. #include <linux/init.h>
  27. #include <linux/slab.h>
  28. #include <sound/core.h>
  29. #include <sound/cs8427.h>
  30. #include <sound/asoundef.h>
  31. #include "ice1712.h"
  32. #include "ews.h"
  33. #define SND_CS8404
  34. #include <sound/cs8403.h>
  35. enum {
  36. EWS_I2C_CS8404 = 0, EWS_I2C_PCF1, EWS_I2C_PCF2,
  37. EWS_I2C_88D = 0,
  38. EWS_I2C_6FIRE = 0
  39. };
  40. /* additional i2c devices for EWS boards */
  41. struct ews_spec {
  42. struct snd_i2c_device *i2cdevs[3];
  43. };
  44. /*
  45. * access via i2c mode (for EWX 24/96, EWS 88MT&D)
  46. */
  47. /* send SDA and SCL */
  48. static void ewx_i2c_setlines(struct snd_i2c_bus *bus, int clk, int data)
  49. {
  50. struct snd_ice1712 *ice = bus->private_data;
  51. unsigned char tmp = 0;
  52. if (clk)
  53. tmp |= ICE1712_EWX2496_SERIAL_CLOCK;
  54. if (data)
  55. tmp |= ICE1712_EWX2496_SERIAL_DATA;
  56. snd_ice1712_write(ice, ICE1712_IREG_GPIO_DATA, tmp);
  57. udelay(5);
  58. }
  59. static int ewx_i2c_getclock(struct snd_i2c_bus *bus)
  60. {
  61. struct snd_ice1712 *ice = bus->private_data;
  62. return snd_ice1712_read(ice, ICE1712_IREG_GPIO_DATA) & ICE1712_EWX2496_SERIAL_CLOCK ? 1 : 0;
  63. }
  64. static int ewx_i2c_getdata(struct snd_i2c_bus *bus, int ack)
  65. {
  66. struct snd_ice1712 *ice = bus->private_data;
  67. int bit;
  68. /* set RW pin to low */
  69. snd_ice1712_write(ice, ICE1712_IREG_GPIO_WRITE_MASK, ~ICE1712_EWX2496_RW);
  70. snd_ice1712_write(ice, ICE1712_IREG_GPIO_DATA, 0);
  71. if (ack)
  72. udelay(5);
  73. bit = snd_ice1712_read(ice, ICE1712_IREG_GPIO_DATA) & ICE1712_EWX2496_SERIAL_DATA ? 1 : 0;
  74. /* set RW pin to high */
  75. snd_ice1712_write(ice, ICE1712_IREG_GPIO_DATA, ICE1712_EWX2496_RW);
  76. /* reset write mask */
  77. snd_ice1712_write(ice, ICE1712_IREG_GPIO_WRITE_MASK, ~ICE1712_EWX2496_SERIAL_CLOCK);
  78. return bit;
  79. }
  80. static void ewx_i2c_start(struct snd_i2c_bus *bus)
  81. {
  82. struct snd_ice1712 *ice = bus->private_data;
  83. unsigned char mask;
  84. snd_ice1712_save_gpio_status(ice);
  85. /* set RW high */
  86. mask = ICE1712_EWX2496_RW;
  87. switch (ice->eeprom.subvendor) {
  88. case ICE1712_SUBDEVICE_EWX2496:
  89. mask |= ICE1712_EWX2496_AK4524_CS; /* CS high also */
  90. break;
  91. case ICE1712_SUBDEVICE_DMX6FIRE:
  92. mask |= ICE1712_6FIRE_AK4524_CS_MASK; /* CS high also */
  93. break;
  94. }
  95. snd_ice1712_gpio_write_bits(ice, mask, mask);
  96. }
  97. static void ewx_i2c_stop(struct snd_i2c_bus *bus)
  98. {
  99. struct snd_ice1712 *ice = bus->private_data;
  100. snd_ice1712_restore_gpio_status(ice);
  101. }
  102. static void ewx_i2c_direction(struct snd_i2c_bus *bus, int clock, int data)
  103. {
  104. struct snd_ice1712 *ice = bus->private_data;
  105. unsigned char mask = 0;
  106. if (clock)
  107. mask |= ICE1712_EWX2496_SERIAL_CLOCK; /* write SCL */
  108. if (data)
  109. mask |= ICE1712_EWX2496_SERIAL_DATA; /* write SDA */
  110. ice->gpio.direction &= ~(ICE1712_EWX2496_SERIAL_CLOCK|ICE1712_EWX2496_SERIAL_DATA);
  111. ice->gpio.direction |= mask;
  112. snd_ice1712_write(ice, ICE1712_IREG_GPIO_DIRECTION, ice->gpio.direction);
  113. snd_ice1712_write(ice, ICE1712_IREG_GPIO_WRITE_MASK, ~mask);
  114. }
  115. static struct snd_i2c_bit_ops snd_ice1712_ewx_cs8427_bit_ops = {
  116. .start = ewx_i2c_start,
  117. .stop = ewx_i2c_stop,
  118. .direction = ewx_i2c_direction,
  119. .setlines = ewx_i2c_setlines,
  120. .getclock = ewx_i2c_getclock,
  121. .getdata = ewx_i2c_getdata,
  122. };
  123. /*
  124. * AK4524 access
  125. */
  126. /* AK4524 chip select; address 0x48 bit 0-3 */
  127. static int snd_ice1712_ews88mt_chip_select(struct snd_ice1712 *ice, int chip_mask)
  128. {
  129. struct ews_spec *spec = ice->spec;
  130. unsigned char data, ndata;
  131. if (snd_BUG_ON(chip_mask < 0 || chip_mask > 0x0f))
  132. 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 = {
  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 = {
  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 = {
  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 = {
  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 = {
  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 = {
  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 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 const char * const 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[] = {
  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. if (snd_BUG_ON(channel < 0 || channel > 7))
  614. return 0;
  615. snd_i2c_lock(ice->i2c);
  616. if (snd_i2c_readbytes(spec->i2cdevs[EWS_I2C_PCF1], &data, 1) != 1) {
  617. snd_i2c_unlock(ice->i2c);
  618. return -EIO;
  619. }
  620. /* reversed; high = +4dBu, low = -10dBV */
  621. ucontrol->value.enumerated.item[0] = data & (1 << channel) ? 0 : 1;
  622. snd_i2c_unlock(ice->i2c);
  623. return 0;
  624. }
  625. /* analog output sensitivity; address 0x46 */
  626. static int snd_ice1712_ews88mt_input_sense_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  627. {
  628. struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
  629. struct ews_spec *spec = ice->spec;
  630. int channel = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  631. unsigned char data, ndata;
  632. if (snd_BUG_ON(channel < 0 || channel > 7))
  633. return 0;
  634. snd_i2c_lock(ice->i2c);
  635. if (snd_i2c_readbytes(spec->i2cdevs[EWS_I2C_PCF1], &data, 1) != 1) {
  636. snd_i2c_unlock(ice->i2c);
  637. return -EIO;
  638. }
  639. ndata = (data & ~(1 << channel)) | (ucontrol->value.enumerated.item[0] ? 0 : (1 << channel));
  640. if (ndata != data && snd_i2c_sendbytes(spec->i2cdevs[EWS_I2C_PCF1],
  641. &ndata, 1) != 1) {
  642. snd_i2c_unlock(ice->i2c);
  643. return -EIO;
  644. }
  645. snd_i2c_unlock(ice->i2c);
  646. return ndata != data;
  647. }
  648. static struct snd_kcontrol_new snd_ice1712_ews88mt_input_sense = {
  649. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  650. .name = "Input Sensitivity Switch",
  651. .info = snd_ice1712_ewx_io_sense_info,
  652. .get = snd_ice1712_ews88mt_input_sense_get,
  653. .put = snd_ice1712_ews88mt_input_sense_put,
  654. .count = 8,
  655. };
  656. static struct snd_kcontrol_new snd_ice1712_ews88mt_output_sense = {
  657. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  658. .name = "Output Sensitivity Switch",
  659. .info = snd_ice1712_ewx_io_sense_info,
  660. .get = snd_ice1712_ews88mt_output_sense_get,
  661. .put = snd_ice1712_ews88mt_output_sense_put,
  662. };
  663. /*
  664. * EWS88D specific controls
  665. */
  666. #define snd_ice1712_ews88d_control_info snd_ctl_boolean_mono_info
  667. static int snd_ice1712_ews88d_control_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  668. {
  669. struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
  670. struct ews_spec *spec = ice->spec;
  671. int shift = kcontrol->private_value & 0xff;
  672. int invert = (kcontrol->private_value >> 8) & 1;
  673. unsigned char data[2];
  674. snd_i2c_lock(ice->i2c);
  675. if (snd_i2c_readbytes(spec->i2cdevs[EWS_I2C_88D], data, 2) != 2) {
  676. snd_i2c_unlock(ice->i2c);
  677. return -EIO;
  678. }
  679. snd_i2c_unlock(ice->i2c);
  680. data[0] = (data[shift >> 3] >> (shift & 7)) & 0x01;
  681. if (invert)
  682. data[0] ^= 0x01;
  683. ucontrol->value.integer.value[0] = data[0];
  684. return 0;
  685. }
  686. static int snd_ice1712_ews88d_control_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  687. {
  688. struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
  689. struct ews_spec *spec = ice->spec;
  690. int shift = kcontrol->private_value & 0xff;
  691. int invert = (kcontrol->private_value >> 8) & 1;
  692. unsigned char data[2], ndata[2];
  693. int change;
  694. snd_i2c_lock(ice->i2c);
  695. if (snd_i2c_readbytes(spec->i2cdevs[EWS_I2C_88D], data, 2) != 2) {
  696. snd_i2c_unlock(ice->i2c);
  697. return -EIO;
  698. }
  699. ndata[shift >> 3] = data[shift >> 3] & ~(1 << (shift & 7));
  700. if (invert) {
  701. if (! ucontrol->value.integer.value[0])
  702. ndata[shift >> 3] |= (1 << (shift & 7));
  703. } else {
  704. if (ucontrol->value.integer.value[0])
  705. ndata[shift >> 3] |= (1 << (shift & 7));
  706. }
  707. change = (data[shift >> 3] != ndata[shift >> 3]);
  708. if (change &&
  709. snd_i2c_sendbytes(spec->i2cdevs[EWS_I2C_88D], data, 2) != 2) {
  710. snd_i2c_unlock(ice->i2c);
  711. return -EIO;
  712. }
  713. snd_i2c_unlock(ice->i2c);
  714. return change;
  715. }
  716. #define EWS88D_CONTROL(xiface, xname, xshift, xinvert, xaccess) \
  717. { .iface = xiface,\
  718. .name = xname,\
  719. .access = xaccess,\
  720. .info = snd_ice1712_ews88d_control_info,\
  721. .get = snd_ice1712_ews88d_control_get,\
  722. .put = snd_ice1712_ews88d_control_put,\
  723. .private_value = xshift | (xinvert << 8),\
  724. }
  725. static struct snd_kcontrol_new snd_ice1712_ews88d_controls[] = {
  726. EWS88D_CONTROL(SNDRV_CTL_ELEM_IFACE_MIXER, "IEC958 Input Optical", 0, 1, 0), /* inverted */
  727. EWS88D_CONTROL(SNDRV_CTL_ELEM_IFACE_MIXER, "ADAT Output Optical", 1, 0, 0),
  728. EWS88D_CONTROL(SNDRV_CTL_ELEM_IFACE_MIXER, "ADAT External Master Clock", 2, 0, 0),
  729. EWS88D_CONTROL(SNDRV_CTL_ELEM_IFACE_MIXER, "Enable ADAT", 3, 0, 0),
  730. EWS88D_CONTROL(SNDRV_CTL_ELEM_IFACE_MIXER, "ADAT Through", 4, 1, 0),
  731. };
  732. /*
  733. * DMX 6Fire specific controls
  734. */
  735. static int snd_ice1712_6fire_read_pca(struct snd_ice1712 *ice, unsigned char reg)
  736. {
  737. unsigned char byte;
  738. struct ews_spec *spec = ice->spec;
  739. snd_i2c_lock(ice->i2c);
  740. byte = reg;
  741. snd_i2c_sendbytes(spec->i2cdevs[EWS_I2C_6FIRE], &byte, 1);
  742. byte = 0;
  743. if (snd_i2c_readbytes(spec->i2cdevs[EWS_I2C_6FIRE], &byte, 1) != 1) {
  744. snd_i2c_unlock(ice->i2c);
  745. printk(KERN_ERR "cannot read pca\n");
  746. return -EIO;
  747. }
  748. snd_i2c_unlock(ice->i2c);
  749. return byte;
  750. }
  751. static int snd_ice1712_6fire_write_pca(struct snd_ice1712 *ice, unsigned char reg, unsigned char data)
  752. {
  753. unsigned char bytes[2];
  754. struct ews_spec *spec = ice->spec;
  755. snd_i2c_lock(ice->i2c);
  756. bytes[0] = reg;
  757. bytes[1] = data;
  758. if (snd_i2c_sendbytes(spec->i2cdevs[EWS_I2C_6FIRE], bytes, 2) != 2) {
  759. snd_i2c_unlock(ice->i2c);
  760. return -EIO;
  761. }
  762. snd_i2c_unlock(ice->i2c);
  763. return 0;
  764. }
  765. #define snd_ice1712_6fire_control_info snd_ctl_boolean_mono_info
  766. static int snd_ice1712_6fire_control_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  767. {
  768. struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
  769. int shift = kcontrol->private_value & 0xff;
  770. int invert = (kcontrol->private_value >> 8) & 1;
  771. int data;
  772. if ((data = snd_ice1712_6fire_read_pca(ice, PCF9554_REG_OUTPUT)) < 0)
  773. return data;
  774. data = (data >> shift) & 1;
  775. if (invert)
  776. data ^= 1;
  777. ucontrol->value.integer.value[0] = data;
  778. return 0;
  779. }
  780. static int snd_ice1712_6fire_control_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  781. {
  782. struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
  783. int shift = kcontrol->private_value & 0xff;
  784. int invert = (kcontrol->private_value >> 8) & 1;
  785. int data, ndata;
  786. if ((data = snd_ice1712_6fire_read_pca(ice, PCF9554_REG_OUTPUT)) < 0)
  787. return data;
  788. ndata = data & ~(1 << shift);
  789. if (ucontrol->value.integer.value[0])
  790. ndata |= (1 << shift);
  791. if (invert)
  792. ndata ^= (1 << shift);
  793. if (data != ndata) {
  794. snd_ice1712_6fire_write_pca(ice, PCF9554_REG_OUTPUT, (unsigned char)ndata);
  795. return 1;
  796. }
  797. return 0;
  798. }
  799. static int snd_ice1712_6fire_select_input_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
  800. {
  801. static const char * const texts[4] = {
  802. "Internal", "Front Input", "Rear Input", "Wave Table"
  803. };
  804. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  805. uinfo->count = 1;
  806. uinfo->value.enumerated.items = 4;
  807. if (uinfo->value.enumerated.item >= 4)
  808. uinfo->value.enumerated.item = 1;
  809. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  810. return 0;
  811. }
  812. static int snd_ice1712_6fire_select_input_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  813. {
  814. struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
  815. int data;
  816. if ((data = snd_ice1712_6fire_read_pca(ice, PCF9554_REG_OUTPUT)) < 0)
  817. return data;
  818. ucontrol->value.integer.value[0] = data & 3;
  819. return 0;
  820. }
  821. static int snd_ice1712_6fire_select_input_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  822. {
  823. struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
  824. int data, ndata;
  825. if ((data = snd_ice1712_6fire_read_pca(ice, PCF9554_REG_OUTPUT)) < 0)
  826. return data;
  827. ndata = data & ~3;
  828. ndata |= (ucontrol->value.integer.value[0] & 3);
  829. if (data != ndata) {
  830. snd_ice1712_6fire_write_pca(ice, PCF9554_REG_OUTPUT, (unsigned char)ndata);
  831. return 1;
  832. }
  833. return 0;
  834. }
  835. #define DMX6FIRE_CONTROL(xname, xshift, xinvert) \
  836. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER,\
  837. .name = xname,\
  838. .info = snd_ice1712_6fire_control_info,\
  839. .get = snd_ice1712_6fire_control_get,\
  840. .put = snd_ice1712_6fire_control_put,\
  841. .private_value = xshift | (xinvert << 8),\
  842. }
  843. static struct snd_kcontrol_new snd_ice1712_6fire_controls[] = {
  844. {
  845. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  846. .name = "Analog Input Select",
  847. .info = snd_ice1712_6fire_select_input_info,
  848. .get = snd_ice1712_6fire_select_input_get,
  849. .put = snd_ice1712_6fire_select_input_put,
  850. },
  851. DMX6FIRE_CONTROL("Front Digital Input Switch", 2, 1),
  852. // DMX6FIRE_CONTROL("Master Clock Select", 3, 0),
  853. DMX6FIRE_CONTROL("Optical Digital Input Switch", 4, 0),
  854. DMX6FIRE_CONTROL("Phono Analog Input Switch", 5, 0),
  855. DMX6FIRE_CONTROL("Breakbox LED", 6, 0),
  856. };
  857. static int snd_ice1712_ews_add_controls(struct snd_ice1712 *ice)
  858. {
  859. unsigned int idx;
  860. int err;
  861. /* all terratec cards have spdif, but cs8427 module builds it's own controls */
  862. if (ice->cs8427 == NULL) {
  863. err = snd_ice1712_spdif_build_controls(ice);
  864. if (err < 0)
  865. return err;
  866. }
  867. /* ak4524 controls */
  868. switch (ice->eeprom.subvendor) {
  869. case ICE1712_SUBDEVICE_EWX2496:
  870. case ICE1712_SUBDEVICE_EWS88MT:
  871. case ICE1712_SUBDEVICE_EWS88MT_NEW:
  872. case ICE1712_SUBDEVICE_PHASE88:
  873. case ICE1712_SUBDEVICE_TS88:
  874. case ICE1712_SUBDEVICE_DMX6FIRE:
  875. err = snd_ice1712_akm4xxx_build_controls(ice);
  876. if (err < 0)
  877. return err;
  878. break;
  879. }
  880. /* card specific controls */
  881. switch (ice->eeprom.subvendor) {
  882. case ICE1712_SUBDEVICE_EWX2496:
  883. for (idx = 0; idx < ARRAY_SIZE(snd_ice1712_ewx2496_controls); idx++) {
  884. err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_ice1712_ewx2496_controls[idx], ice));
  885. if (err < 0)
  886. return err;
  887. }
  888. break;
  889. case ICE1712_SUBDEVICE_EWS88MT:
  890. case ICE1712_SUBDEVICE_EWS88MT_NEW:
  891. case ICE1712_SUBDEVICE_PHASE88:
  892. case ICE1712_SUBDEVICE_TS88:
  893. err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_ice1712_ews88mt_input_sense, ice));
  894. if (err < 0)
  895. return err;
  896. err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_ice1712_ews88mt_output_sense, ice));
  897. if (err < 0)
  898. return err;
  899. break;
  900. case ICE1712_SUBDEVICE_EWS88D:
  901. for (idx = 0; idx < ARRAY_SIZE(snd_ice1712_ews88d_controls); idx++) {
  902. err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_ice1712_ews88d_controls[idx], ice));
  903. if (err < 0)
  904. return err;
  905. }
  906. break;
  907. case ICE1712_SUBDEVICE_DMX6FIRE:
  908. for (idx = 0; idx < ARRAY_SIZE(snd_ice1712_6fire_controls); idx++) {
  909. err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_ice1712_6fire_controls[idx], ice));
  910. if (err < 0)
  911. return err;
  912. }
  913. break;
  914. }
  915. return 0;
  916. }
  917. /* entry point */
  918. struct snd_ice1712_card_info snd_ice1712_ews_cards[] = {
  919. {
  920. .subvendor = ICE1712_SUBDEVICE_EWX2496,
  921. .name = "TerraTec EWX24/96",
  922. .model = "ewx2496",
  923. .chip_init = snd_ice1712_ews_init,
  924. .build_controls = snd_ice1712_ews_add_controls,
  925. },
  926. {
  927. .subvendor = ICE1712_SUBDEVICE_EWS88MT,
  928. .name = "TerraTec EWS88MT",
  929. .model = "ews88mt",
  930. .chip_init = snd_ice1712_ews_init,
  931. .build_controls = snd_ice1712_ews_add_controls,
  932. },
  933. {
  934. .subvendor = ICE1712_SUBDEVICE_EWS88MT_NEW,
  935. .name = "TerraTec EWS88MT",
  936. .model = "ews88mt_new",
  937. .chip_init = snd_ice1712_ews_init,
  938. .build_controls = snd_ice1712_ews_add_controls,
  939. },
  940. {
  941. .subvendor = ICE1712_SUBDEVICE_PHASE88,
  942. .name = "TerraTec Phase88",
  943. .model = "phase88",
  944. .chip_init = snd_ice1712_ews_init,
  945. .build_controls = snd_ice1712_ews_add_controls,
  946. },
  947. {
  948. .subvendor = ICE1712_SUBDEVICE_TS88,
  949. .name = "terrasoniq TS88",
  950. .model = "phase88",
  951. .chip_init = snd_ice1712_ews_init,
  952. .build_controls = snd_ice1712_ews_add_controls,
  953. },
  954. {
  955. .subvendor = ICE1712_SUBDEVICE_EWS88D,
  956. .name = "TerraTec EWS88D",
  957. .model = "ews88d",
  958. .chip_init = snd_ice1712_ews_init,
  959. .build_controls = snd_ice1712_ews_add_controls,
  960. },
  961. {
  962. .subvendor = ICE1712_SUBDEVICE_DMX6FIRE,
  963. .name = "TerraTec DMX6Fire",
  964. .model = "dmx6fire",
  965. .chip_init = snd_ice1712_ews_init,
  966. .build_controls = snd_ice1712_ews_add_controls,
  967. .mpu401_1_name = "MIDI-Front DMX6fire",
  968. .mpu401_2_name = "Wavetable DMX6fire",
  969. .mpu401_2_info_flags = MPU401_INFO_OUTPUT,
  970. },
  971. { } /* terminator */
  972. };