ews.c 31 KB

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