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 <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. if (snd_BUG_ON(chip_mask < 0 || chip_mask > 0x0f))
  133. return -EINVAL;
  134. snd_i2c_lock(ice->i2c);
  135. if (snd_i2c_readbytes(spec->i2cdevs[EWS_I2C_PCF2], &data, 1) != 1)
  136. goto __error;
  137. ndata = (data & 0xf0) | chip_mask;
  138. if (ndata != data)
  139. if (snd_i2c_sendbytes(spec->i2cdevs[EWS_I2C_PCF2], &ndata, 1)
  140. != 1)
  141. goto __error;
  142. snd_i2c_unlock(ice->i2c);
  143. return 0;
  144. __error:
  145. snd_i2c_unlock(ice->i2c);
  146. snd_printk(KERN_ERR "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. snd_printk(KERN_ERR "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 __devinitdata = {
  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 __devinitdata = {
  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 __devinitdata = {
  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 __devinitdata = {
  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 __devinitdata = {
  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 __devinitdata = {
  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 __devinit 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. snd_printk(KERN_ERR "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. snd_printk(KERN_ERR "PCF9554 initialization failed\n");
  420. return err;
  421. }
  422. snd_ice1712_6fire_write_pca(ice, PCF9554_REG_CONFIG, 0x80);
  423. break;
  424. case ICE1712_SUBDEVICE_EWS88MT:
  425. case ICE1712_SUBDEVICE_EWS88MT_NEW:
  426. case ICE1712_SUBDEVICE_PHASE88:
  427. case ICE1712_SUBDEVICE_TS88:
  428. err = snd_i2c_device_create(ice->i2c, "CS8404",
  429. ICE1712_EWS88MT_CS8404_ADDR,
  430. &spec->i2cdevs[EWS_I2C_CS8404]);
  431. if (err < 0)
  432. return err;
  433. err = snd_i2c_device_create(ice->i2c, "PCF8574 (1st)",
  434. ICE1712_EWS88MT_INPUT_ADDR,
  435. &spec->i2cdevs[EWS_I2C_PCF1]);
  436. if (err < 0)
  437. return err;
  438. err = snd_i2c_device_create(ice->i2c, "PCF8574 (2nd)",
  439. ICE1712_EWS88MT_OUTPUT_ADDR,
  440. &spec->i2cdevs[EWS_I2C_PCF2]);
  441. if (err < 0)
  442. return err;
  443. /* Check if the front module is connected */
  444. if ((err = snd_ice1712_ews88mt_chip_select(ice, 0x0f)) < 0)
  445. return err;
  446. break;
  447. case ICE1712_SUBDEVICE_EWS88D:
  448. err = snd_i2c_device_create(ice->i2c, "PCF8575",
  449. ICE1712_EWS88D_PCF_ADDR,
  450. &spec->i2cdevs[EWS_I2C_88D]);
  451. if (err < 0)
  452. return err;
  453. break;
  454. }
  455. /* set up SPDIF interface */
  456. switch (ice->eeprom.subvendor) {
  457. case ICE1712_SUBDEVICE_EWX2496:
  458. if ((err = snd_ice1712_init_cs8427(ice, CS8427_BASE_ADDR)) < 0)
  459. return err;
  460. snd_cs8427_reg_write(ice->cs8427, CS8427_REG_RECVERRMASK, CS8427_UNLOCK | CS8427_CONF | CS8427_BIP | CS8427_PAR);
  461. break;
  462. case ICE1712_SUBDEVICE_DMX6FIRE:
  463. if ((err = snd_ice1712_init_cs8427(ice, ICE1712_6FIRE_CS8427_ADDR)) < 0)
  464. return err;
  465. snd_cs8427_reg_write(ice->cs8427, CS8427_REG_RECVERRMASK, CS8427_UNLOCK | CS8427_CONF | CS8427_BIP | CS8427_PAR);
  466. break;
  467. case ICE1712_SUBDEVICE_EWS88MT:
  468. case ICE1712_SUBDEVICE_EWS88MT_NEW:
  469. case ICE1712_SUBDEVICE_PHASE88:
  470. case ICE1712_SUBDEVICE_TS88:
  471. case ICE1712_SUBDEVICE_EWS88D:
  472. /* set up CS8404 */
  473. ice->spdif.ops.open = ews88_open_spdif;
  474. ice->spdif.ops.setup_rate = ews88_setup_spdif;
  475. ice->spdif.ops.default_get = ews88_spdif_default_get;
  476. ice->spdif.ops.default_put = ews88_spdif_default_put;
  477. ice->spdif.ops.stream_get = ews88_spdif_stream_get;
  478. ice->spdif.ops.stream_put = ews88_spdif_stream_put;
  479. /* Set spdif defaults */
  480. snd_ice1712_ews_cs8404_spdif_write(ice, ice->spdif.cs8403_bits);
  481. break;
  482. }
  483. /* no analog? */
  484. switch (ice->eeprom.subvendor) {
  485. case ICE1712_SUBDEVICE_EWS88D:
  486. return 0;
  487. }
  488. /* analog section */
  489. ak = ice->akm = kzalloc(sizeof(struct snd_akm4xxx), GFP_KERNEL);
  490. if (! ak)
  491. return -ENOMEM;
  492. ice->akm_codecs = 1;
  493. switch (ice->eeprom.subvendor) {
  494. case ICE1712_SUBDEVICE_EWS88MT:
  495. case ICE1712_SUBDEVICE_EWS88MT_NEW:
  496. case ICE1712_SUBDEVICE_PHASE88:
  497. case ICE1712_SUBDEVICE_TS88:
  498. err = snd_ice1712_akm4xxx_init(ak, &akm_ews88mt, &akm_ews88mt_priv, ice);
  499. break;
  500. case ICE1712_SUBDEVICE_EWX2496:
  501. err = snd_ice1712_akm4xxx_init(ak, &akm_ewx2496, &akm_ewx2496_priv, ice);
  502. break;
  503. case ICE1712_SUBDEVICE_DMX6FIRE:
  504. err = snd_ice1712_akm4xxx_init(ak, &akm_6fire, &akm_6fire_priv, ice);
  505. break;
  506. default:
  507. err = 0;
  508. }
  509. return err;
  510. }
  511. /*
  512. * EWX 24/96 specific controls
  513. */
  514. /* i/o sensitivity - this callback is shared among other devices, too */
  515. static int snd_ice1712_ewx_io_sense_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo){
  516. static char *texts[2] = {
  517. "+4dBu", "-10dBV",
  518. };
  519. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  520. uinfo->count = 1;
  521. uinfo->value.enumerated.items = 2;
  522. if (uinfo->value.enumerated.item >= 2)
  523. uinfo->value.enumerated.item = 1;
  524. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  525. return 0;
  526. }
  527. static int snd_ice1712_ewx_io_sense_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  528. {
  529. struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
  530. unsigned char mask = kcontrol->private_value & 0xff;
  531. snd_ice1712_save_gpio_status(ice);
  532. ucontrol->value.enumerated.item[0] = snd_ice1712_read(ice, ICE1712_IREG_GPIO_DATA) & mask ? 1 : 0;
  533. snd_ice1712_restore_gpio_status(ice);
  534. return 0;
  535. }
  536. static int snd_ice1712_ewx_io_sense_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  537. {
  538. struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
  539. unsigned char mask = kcontrol->private_value & 0xff;
  540. int val, nval;
  541. if (kcontrol->private_value & (1 << 31))
  542. return -EPERM;
  543. nval = ucontrol->value.enumerated.item[0] ? mask : 0;
  544. snd_ice1712_save_gpio_status(ice);
  545. val = snd_ice1712_read(ice, ICE1712_IREG_GPIO_DATA);
  546. nval |= val & ~mask;
  547. snd_ice1712_write(ice, ICE1712_IREG_GPIO_DATA, nval);
  548. snd_ice1712_restore_gpio_status(ice);
  549. return val != nval;
  550. }
  551. static struct snd_kcontrol_new snd_ice1712_ewx2496_controls[] __devinitdata = {
  552. {
  553. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  554. .name = "Input Sensitivity Switch",
  555. .info = snd_ice1712_ewx_io_sense_info,
  556. .get = snd_ice1712_ewx_io_sense_get,
  557. .put = snd_ice1712_ewx_io_sense_put,
  558. .private_value = ICE1712_EWX2496_AIN_SEL,
  559. },
  560. {
  561. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  562. .name = "Output Sensitivity Switch",
  563. .info = snd_ice1712_ewx_io_sense_info,
  564. .get = snd_ice1712_ewx_io_sense_get,
  565. .put = snd_ice1712_ewx_io_sense_put,
  566. .private_value = ICE1712_EWX2496_AOUT_SEL,
  567. },
  568. };
  569. /*
  570. * EWS88MT specific controls
  571. */
  572. /* analog output sensitivity;; address 0x48 bit 6 */
  573. static int snd_ice1712_ews88mt_output_sense_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  574. {
  575. struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
  576. struct ews_spec *spec = ice->spec;
  577. unsigned char data;
  578. snd_i2c_lock(ice->i2c);
  579. if (snd_i2c_readbytes(spec->i2cdevs[EWS_I2C_PCF2], &data, 1) != 1) {
  580. snd_i2c_unlock(ice->i2c);
  581. return -EIO;
  582. }
  583. snd_i2c_unlock(ice->i2c);
  584. ucontrol->value.enumerated.item[0] = data & ICE1712_EWS88MT_OUTPUT_SENSE ? 1 : 0; /* high = -10dBV, low = +4dBu */
  585. return 0;
  586. }
  587. /* analog output sensitivity;; address 0x48 bit 6 */
  588. static int snd_ice1712_ews88mt_output_sense_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  589. {
  590. struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
  591. struct ews_spec *spec = ice->spec;
  592. unsigned char data, ndata;
  593. snd_i2c_lock(ice->i2c);
  594. if (snd_i2c_readbytes(spec->i2cdevs[EWS_I2C_PCF2], &data, 1) != 1) {
  595. snd_i2c_unlock(ice->i2c);
  596. return -EIO;
  597. }
  598. ndata = (data & ~ICE1712_EWS88MT_OUTPUT_SENSE) | (ucontrol->value.enumerated.item[0] ? ICE1712_EWS88MT_OUTPUT_SENSE : 0);
  599. if (ndata != data && snd_i2c_sendbytes(spec->i2cdevs[EWS_I2C_PCF2],
  600. &ndata, 1) != 1) {
  601. snd_i2c_unlock(ice->i2c);
  602. return -EIO;
  603. }
  604. snd_i2c_unlock(ice->i2c);
  605. return ndata != data;
  606. }
  607. /* analog input sensitivity; address 0x46 */
  608. static int snd_ice1712_ews88mt_input_sense_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  609. {
  610. struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
  611. struct ews_spec *spec = ice->spec;
  612. int channel = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  613. unsigned char data;
  614. if (snd_BUG_ON(channel < 0 || channel > 7))
  615. return 0;
  616. snd_i2c_lock(ice->i2c);
  617. if (snd_i2c_readbytes(spec->i2cdevs[EWS_I2C_PCF1], &data, 1) != 1) {
  618. snd_i2c_unlock(ice->i2c);
  619. return -EIO;
  620. }
  621. /* reversed; high = +4dBu, low = -10dBV */
  622. ucontrol->value.enumerated.item[0] = data & (1 << channel) ? 0 : 1;
  623. snd_i2c_unlock(ice->i2c);
  624. return 0;
  625. }
  626. /* analog output sensitivity; address 0x46 */
  627. static int snd_ice1712_ews88mt_input_sense_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  628. {
  629. struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
  630. struct ews_spec *spec = ice->spec;
  631. int channel = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  632. unsigned char data, ndata;
  633. if (snd_BUG_ON(channel < 0 || channel > 7))
  634. return 0;
  635. snd_i2c_lock(ice->i2c);
  636. if (snd_i2c_readbytes(spec->i2cdevs[EWS_I2C_PCF1], &data, 1) != 1) {
  637. snd_i2c_unlock(ice->i2c);
  638. return -EIO;
  639. }
  640. ndata = (data & ~(1 << channel)) | (ucontrol->value.enumerated.item[0] ? 0 : (1 << channel));
  641. if (ndata != data && snd_i2c_sendbytes(spec->i2cdevs[EWS_I2C_PCF1],
  642. &ndata, 1) != 1) {
  643. snd_i2c_unlock(ice->i2c);
  644. return -EIO;
  645. }
  646. snd_i2c_unlock(ice->i2c);
  647. return ndata != data;
  648. }
  649. static struct snd_kcontrol_new snd_ice1712_ews88mt_input_sense __devinitdata = {
  650. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  651. .name = "Input Sensitivity Switch",
  652. .info = snd_ice1712_ewx_io_sense_info,
  653. .get = snd_ice1712_ews88mt_input_sense_get,
  654. .put = snd_ice1712_ews88mt_input_sense_put,
  655. .count = 8,
  656. };
  657. static struct snd_kcontrol_new snd_ice1712_ews88mt_output_sense __devinitdata = {
  658. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  659. .name = "Output Sensitivity Switch",
  660. .info = snd_ice1712_ewx_io_sense_info,
  661. .get = snd_ice1712_ews88mt_output_sense_get,
  662. .put = snd_ice1712_ews88mt_output_sense_put,
  663. };
  664. /*
  665. * EWS88D specific controls
  666. */
  667. #define snd_ice1712_ews88d_control_info snd_ctl_boolean_mono_info
  668. static int snd_ice1712_ews88d_control_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  669. {
  670. struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
  671. struct ews_spec *spec = ice->spec;
  672. int shift = kcontrol->private_value & 0xff;
  673. int invert = (kcontrol->private_value >> 8) & 1;
  674. unsigned char data[2];
  675. snd_i2c_lock(ice->i2c);
  676. if (snd_i2c_readbytes(spec->i2cdevs[EWS_I2C_88D], data, 2) != 2) {
  677. snd_i2c_unlock(ice->i2c);
  678. return -EIO;
  679. }
  680. snd_i2c_unlock(ice->i2c);
  681. data[0] = (data[shift >> 3] >> (shift & 7)) & 0x01;
  682. if (invert)
  683. data[0] ^= 0x01;
  684. ucontrol->value.integer.value[0] = data[0];
  685. return 0;
  686. }
  687. static int snd_ice1712_ews88d_control_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  688. {
  689. struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
  690. struct ews_spec *spec = ice->spec;
  691. int shift = kcontrol->private_value & 0xff;
  692. int invert = (kcontrol->private_value >> 8) & 1;
  693. unsigned char data[2], ndata[2];
  694. int change;
  695. snd_i2c_lock(ice->i2c);
  696. if (snd_i2c_readbytes(spec->i2cdevs[EWS_I2C_88D], data, 2) != 2) {
  697. snd_i2c_unlock(ice->i2c);
  698. return -EIO;
  699. }
  700. ndata[shift >> 3] = data[shift >> 3] & ~(1 << (shift & 7));
  701. if (invert) {
  702. if (! ucontrol->value.integer.value[0])
  703. ndata[shift >> 3] |= (1 << (shift & 7));
  704. } else {
  705. if (ucontrol->value.integer.value[0])
  706. ndata[shift >> 3] |= (1 << (shift & 7));
  707. }
  708. change = (data[shift >> 3] != ndata[shift >> 3]);
  709. if (change &&
  710. snd_i2c_sendbytes(spec->i2cdevs[EWS_I2C_88D], data, 2) != 2) {
  711. snd_i2c_unlock(ice->i2c);
  712. return -EIO;
  713. }
  714. snd_i2c_unlock(ice->i2c);
  715. return change;
  716. }
  717. #define EWS88D_CONTROL(xiface, xname, xshift, xinvert, xaccess) \
  718. { .iface = xiface,\
  719. .name = xname,\
  720. .access = xaccess,\
  721. .info = snd_ice1712_ews88d_control_info,\
  722. .get = snd_ice1712_ews88d_control_get,\
  723. .put = snd_ice1712_ews88d_control_put,\
  724. .private_value = xshift | (xinvert << 8),\
  725. }
  726. static struct snd_kcontrol_new snd_ice1712_ews88d_controls[] __devinitdata = {
  727. EWS88D_CONTROL(SNDRV_CTL_ELEM_IFACE_MIXER, "IEC958 Input Optical", 0, 1, 0), /* inverted */
  728. EWS88D_CONTROL(SNDRV_CTL_ELEM_IFACE_MIXER, "ADAT Output Optical", 1, 0, 0),
  729. EWS88D_CONTROL(SNDRV_CTL_ELEM_IFACE_MIXER, "ADAT External Master Clock", 2, 0, 0),
  730. EWS88D_CONTROL(SNDRV_CTL_ELEM_IFACE_MIXER, "Enable ADAT", 3, 0, 0),
  731. EWS88D_CONTROL(SNDRV_CTL_ELEM_IFACE_MIXER, "ADAT Through", 4, 1, 0),
  732. };
  733. /*
  734. * DMX 6Fire specific controls
  735. */
  736. static int snd_ice1712_6fire_read_pca(struct snd_ice1712 *ice, unsigned char reg)
  737. {
  738. unsigned char byte;
  739. struct ews_spec *spec = ice->spec;
  740. snd_i2c_lock(ice->i2c);
  741. byte = reg;
  742. snd_i2c_sendbytes(spec->i2cdevs[EWS_I2C_6FIRE], &byte, 1);
  743. byte = 0;
  744. if (snd_i2c_readbytes(spec->i2cdevs[EWS_I2C_6FIRE], &byte, 1) != 1) {
  745. snd_i2c_unlock(ice->i2c);
  746. printk(KERN_ERR "cannot read pca\n");
  747. return -EIO;
  748. }
  749. snd_i2c_unlock(ice->i2c);
  750. return byte;
  751. }
  752. static int snd_ice1712_6fire_write_pca(struct snd_ice1712 *ice, unsigned char reg, unsigned char data)
  753. {
  754. unsigned char bytes[2];
  755. struct ews_spec *spec = ice->spec;
  756. snd_i2c_lock(ice->i2c);
  757. bytes[0] = reg;
  758. bytes[1] = data;
  759. if (snd_i2c_sendbytes(spec->i2cdevs[EWS_I2C_6FIRE], bytes, 2) != 2) {
  760. snd_i2c_unlock(ice->i2c);
  761. return -EIO;
  762. }
  763. snd_i2c_unlock(ice->i2c);
  764. return 0;
  765. }
  766. #define snd_ice1712_6fire_control_info snd_ctl_boolean_mono_info
  767. static int snd_ice1712_6fire_control_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  768. {
  769. struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
  770. int shift = kcontrol->private_value & 0xff;
  771. int invert = (kcontrol->private_value >> 8) & 1;
  772. int data;
  773. if ((data = snd_ice1712_6fire_read_pca(ice, PCF9554_REG_OUTPUT)) < 0)
  774. return data;
  775. data = (data >> shift) & 1;
  776. if (invert)
  777. data ^= 1;
  778. ucontrol->value.integer.value[0] = data;
  779. return 0;
  780. }
  781. static int snd_ice1712_6fire_control_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  782. {
  783. struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
  784. int shift = kcontrol->private_value & 0xff;
  785. int invert = (kcontrol->private_value >> 8) & 1;
  786. int data, ndata;
  787. if ((data = snd_ice1712_6fire_read_pca(ice, PCF9554_REG_OUTPUT)) < 0)
  788. return data;
  789. ndata = data & ~(1 << shift);
  790. if (ucontrol->value.integer.value[0])
  791. ndata |= (1 << shift);
  792. if (invert)
  793. ndata ^= (1 << shift);
  794. if (data != ndata) {
  795. snd_ice1712_6fire_write_pca(ice, PCF9554_REG_OUTPUT, (unsigned char)ndata);
  796. return 1;
  797. }
  798. return 0;
  799. }
  800. static int snd_ice1712_6fire_select_input_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
  801. {
  802. static char *texts[4] = {
  803. "Internal", "Front Input", "Rear Input", "Wave Table"
  804. };
  805. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  806. uinfo->count = 1;
  807. uinfo->value.enumerated.items = 4;
  808. if (uinfo->value.enumerated.item >= 4)
  809. uinfo->value.enumerated.item = 1;
  810. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  811. return 0;
  812. }
  813. static int snd_ice1712_6fire_select_input_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  814. {
  815. struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
  816. int data;
  817. if ((data = snd_ice1712_6fire_read_pca(ice, PCF9554_REG_OUTPUT)) < 0)
  818. return data;
  819. ucontrol->value.integer.value[0] = data & 3;
  820. return 0;
  821. }
  822. static int snd_ice1712_6fire_select_input_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  823. {
  824. struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
  825. int data, ndata;
  826. if ((data = snd_ice1712_6fire_read_pca(ice, PCF9554_REG_OUTPUT)) < 0)
  827. return data;
  828. ndata = data & ~3;
  829. ndata |= (ucontrol->value.integer.value[0] & 3);
  830. if (data != ndata) {
  831. snd_ice1712_6fire_write_pca(ice, PCF9554_REG_OUTPUT, (unsigned char)ndata);
  832. return 1;
  833. }
  834. return 0;
  835. }
  836. #define DMX6FIRE_CONTROL(xname, xshift, xinvert) \
  837. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER,\
  838. .name = xname,\
  839. .info = snd_ice1712_6fire_control_info,\
  840. .get = snd_ice1712_6fire_control_get,\
  841. .put = snd_ice1712_6fire_control_put,\
  842. .private_value = xshift | (xinvert << 8),\
  843. }
  844. static struct snd_kcontrol_new snd_ice1712_6fire_controls[] __devinitdata = {
  845. {
  846. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  847. .name = "Analog Input Select",
  848. .info = snd_ice1712_6fire_select_input_info,
  849. .get = snd_ice1712_6fire_select_input_get,
  850. .put = snd_ice1712_6fire_select_input_put,
  851. },
  852. DMX6FIRE_CONTROL("Front Digital Input Switch", 2, 1),
  853. // DMX6FIRE_CONTROL("Master Clock Select", 3, 0),
  854. DMX6FIRE_CONTROL("Optical Digital Input Switch", 4, 0),
  855. DMX6FIRE_CONTROL("Phono Analog Input Switch", 5, 0),
  856. DMX6FIRE_CONTROL("Breakbox LED", 6, 0),
  857. };
  858. static int __devinit snd_ice1712_ews_add_controls(struct snd_ice1712 *ice)
  859. {
  860. unsigned int idx;
  861. int err;
  862. /* all terratec cards have spdif, but cs8427 module builds it's own controls */
  863. if (ice->cs8427 == NULL) {
  864. err = snd_ice1712_spdif_build_controls(ice);
  865. if (err < 0)
  866. return err;
  867. }
  868. /* ak4524 controls */
  869. switch (ice->eeprom.subvendor) {
  870. case ICE1712_SUBDEVICE_EWX2496:
  871. case ICE1712_SUBDEVICE_EWS88MT:
  872. case ICE1712_SUBDEVICE_EWS88MT_NEW:
  873. case ICE1712_SUBDEVICE_PHASE88:
  874. case ICE1712_SUBDEVICE_TS88:
  875. case ICE1712_SUBDEVICE_DMX6FIRE:
  876. err = snd_ice1712_akm4xxx_build_controls(ice);
  877. if (err < 0)
  878. return err;
  879. break;
  880. }
  881. /* card specific controls */
  882. switch (ice->eeprom.subvendor) {
  883. case ICE1712_SUBDEVICE_EWX2496:
  884. for (idx = 0; idx < ARRAY_SIZE(snd_ice1712_ewx2496_controls); idx++) {
  885. err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_ice1712_ewx2496_controls[idx], ice));
  886. if (err < 0)
  887. return err;
  888. }
  889. break;
  890. case ICE1712_SUBDEVICE_EWS88MT:
  891. case ICE1712_SUBDEVICE_EWS88MT_NEW:
  892. case ICE1712_SUBDEVICE_PHASE88:
  893. case ICE1712_SUBDEVICE_TS88:
  894. err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_ice1712_ews88mt_input_sense, ice));
  895. if (err < 0)
  896. return err;
  897. err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_ice1712_ews88mt_output_sense, ice));
  898. if (err < 0)
  899. return err;
  900. break;
  901. case ICE1712_SUBDEVICE_EWS88D:
  902. for (idx = 0; idx < ARRAY_SIZE(snd_ice1712_ews88d_controls); idx++) {
  903. err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_ice1712_ews88d_controls[idx], ice));
  904. if (err < 0)
  905. return err;
  906. }
  907. break;
  908. case ICE1712_SUBDEVICE_DMX6FIRE:
  909. for (idx = 0; idx < ARRAY_SIZE(snd_ice1712_6fire_controls); idx++) {
  910. err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_ice1712_6fire_controls[idx], ice));
  911. if (err < 0)
  912. return err;
  913. }
  914. break;
  915. }
  916. return 0;
  917. }
  918. /* entry point */
  919. struct snd_ice1712_card_info snd_ice1712_ews_cards[] __devinitdata = {
  920. {
  921. .subvendor = ICE1712_SUBDEVICE_EWX2496,
  922. .name = "TerraTec EWX24/96",
  923. .model = "ewx2496",
  924. .chip_init = snd_ice1712_ews_init,
  925. .build_controls = snd_ice1712_ews_add_controls,
  926. },
  927. {
  928. .subvendor = ICE1712_SUBDEVICE_EWS88MT,
  929. .name = "TerraTec EWS88MT",
  930. .model = "ews88mt",
  931. .chip_init = snd_ice1712_ews_init,
  932. .build_controls = snd_ice1712_ews_add_controls,
  933. },
  934. {
  935. .subvendor = ICE1712_SUBDEVICE_EWS88MT_NEW,
  936. .name = "TerraTec EWS88MT",
  937. .model = "ews88mt_new",
  938. .chip_init = snd_ice1712_ews_init,
  939. .build_controls = snd_ice1712_ews_add_controls,
  940. },
  941. {
  942. .subvendor = ICE1712_SUBDEVICE_PHASE88,
  943. .name = "TerraTec Phase88",
  944. .model = "phase88",
  945. .chip_init = snd_ice1712_ews_init,
  946. .build_controls = snd_ice1712_ews_add_controls,
  947. },
  948. {
  949. .subvendor = ICE1712_SUBDEVICE_TS88,
  950. .name = "terrasoniq TS88",
  951. .model = "phase88",
  952. .chip_init = snd_ice1712_ews_init,
  953. .build_controls = snd_ice1712_ews_add_controls,
  954. },
  955. {
  956. .subvendor = ICE1712_SUBDEVICE_EWS88D,
  957. .name = "TerraTec EWS88D",
  958. .model = "ews88d",
  959. .chip_init = snd_ice1712_ews_init,
  960. .build_controls = snd_ice1712_ews_add_controls,
  961. },
  962. {
  963. .subvendor = ICE1712_SUBDEVICE_DMX6FIRE,
  964. .name = "TerraTec DMX6Fire",
  965. .model = "dmx6fire",
  966. .chip_init = snd_ice1712_ews_init,
  967. .build_controls = snd_ice1712_ews_add_controls,
  968. .mpu401_1_name = "MIDI-Front DMX6fire",
  969. .mpu401_2_name = "Wavetable DMX6fire",
  970. .mpu401_2_info_flags = MPU401_INFO_OUTPUT,
  971. },
  972. { } /* terminator */
  973. };