se.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775
  1. /*
  2. * ALSA driver for ICEnsemble VT1724 (Envy24HT)
  3. *
  4. * Lowlevel functions for ONKYO WAVIO SE-90PCI and SE-200PCI
  5. *
  6. * Copyright (c) 2007 Shin-ya Okada sh_okada(at)d4.dion.ne.jp
  7. * (at) -> @
  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/tlv.h>
  31. #include "ice1712.h"
  32. #include "envy24ht.h"
  33. #include "se.h"
  34. struct se_spec {
  35. struct {
  36. unsigned char ch1, ch2;
  37. } vol[8];
  38. };
  39. /****************************************************************************/
  40. /* ONKYO WAVIO SE-200PCI */
  41. /****************************************************************************/
  42. /*
  43. * system configuration ICE_EEP2_SYSCONF=0x4b
  44. * XIN1 49.152MHz
  45. * not have UART
  46. * one stereo ADC and a S/PDIF receiver connected
  47. * four stereo DACs connected
  48. *
  49. * AC-Link configuration ICE_EEP2_ACLINK=0x80
  50. * use I2C, not use AC97
  51. *
  52. * I2S converters feature ICE_EEP2_I2S=0x78
  53. * I2S codec has no volume/mute control feature
  54. * I2S codec supports 96KHz and 192KHz
  55. * I2S codec 24bits
  56. *
  57. * S/PDIF configuration ICE_EEP2_SPDIF=0xc3
  58. * Enable integrated S/PDIF transmitter
  59. * internal S/PDIF out implemented
  60. * S/PDIF is stereo
  61. * External S/PDIF out implemented
  62. *
  63. *
  64. * ** connected chips **
  65. *
  66. * WM8740
  67. * A 2ch-DAC of main outputs.
  68. * It setuped as I2S mode by wire, so no way to setup from software.
  69. * The sample-rate are automatically changed.
  70. * ML/I2S (28pin) --------+
  71. * MC/DM1 (27pin) -- 5V |
  72. * MD/DM0 (26pin) -- GND |
  73. * MUTEB (25pin) -- NC |
  74. * MODE (24pin) -- GND |
  75. * CSBIW (23pin) --------+
  76. * |
  77. * RSTB (22pin) --R(1K)-+
  78. * Probably it reduce the noise from the control line.
  79. *
  80. * WM8766
  81. * A 6ch-DAC for surrounds.
  82. * It's control wire was connected to GPIOxx (3-wire serial interface)
  83. * ML/I2S (11pin) -- GPIO18
  84. * MC/IWL (12pin) -- GPIO17
  85. * MD/DM (13pin) -- GPIO16
  86. * MUTE (14pin) -- GPIO01
  87. *
  88. * WM8776
  89. * A 2ch-ADC(with 10ch-selector) plus 2ch-DAC.
  90. * It's control wire was connected to SDA/SCLK (2-wire serial interface)
  91. * MODE (16pin) -- R(1K) -- GND
  92. * CE (17pin) -- R(1K) -- GND 2-wire mode (address=0x34)
  93. * DI (18pin) -- SDA
  94. * CL (19pin) -- SCLK
  95. *
  96. *
  97. * ** output pins and device names **
  98. *
  99. * 7.1ch name -- output connector color -- device (-D option)
  100. *
  101. * FRONT 2ch -- green -- plughw:0,0
  102. * CENTER(Lch) SUBWOOFER(Rch) -- black -- plughw:0,2,0
  103. * SURROUND 2ch -- orange -- plughw:0,2,1
  104. * SURROUND BACK 2ch -- white -- plughw:0,2,2
  105. *
  106. */
  107. /****************************************************************************/
  108. /* WM8740 interface */
  109. /****************************************************************************/
  110. static void __devinit se200pci_WM8740_init(struct snd_ice1712 *ice)
  111. {
  112. /* nothing to do */
  113. }
  114. static void se200pci_WM8740_set_pro_rate(struct snd_ice1712 *ice,
  115. unsigned int rate)
  116. {
  117. /* nothing to do */
  118. }
  119. /****************************************************************************/
  120. /* WM8766 interface */
  121. /****************************************************************************/
  122. static void se200pci_WM8766_write(struct snd_ice1712 *ice,
  123. unsigned int addr, unsigned int data)
  124. {
  125. unsigned int st;
  126. unsigned int bits;
  127. int i;
  128. const unsigned int DATA = 0x010000;
  129. const unsigned int CLOCK = 0x020000;
  130. const unsigned int LOAD = 0x040000;
  131. const unsigned int ALL_MASK = (DATA | CLOCK | LOAD);
  132. snd_ice1712_save_gpio_status(ice);
  133. st = ((addr & 0x7f) << 9) | (data & 0x1ff);
  134. snd_ice1712_gpio_set_dir(ice, ice->gpio.direction | ALL_MASK);
  135. snd_ice1712_gpio_set_mask(ice, ice->gpio.write_mask & ~ALL_MASK);
  136. bits = snd_ice1712_gpio_read(ice) & ~ALL_MASK;
  137. snd_ice1712_gpio_write(ice, bits);
  138. for (i = 0; i < 16; i++) {
  139. udelay(1);
  140. bits &= ~CLOCK;
  141. st = (st << 1);
  142. if (st & 0x10000)
  143. bits |= DATA;
  144. else
  145. bits &= ~DATA;
  146. snd_ice1712_gpio_write(ice, bits);
  147. udelay(1);
  148. bits |= CLOCK;
  149. snd_ice1712_gpio_write(ice, bits);
  150. }
  151. udelay(1);
  152. bits |= LOAD;
  153. snd_ice1712_gpio_write(ice, bits);
  154. udelay(1);
  155. bits |= (DATA | CLOCK);
  156. snd_ice1712_gpio_write(ice, bits);
  157. snd_ice1712_restore_gpio_status(ice);
  158. }
  159. static void se200pci_WM8766_set_volume(struct snd_ice1712 *ice, int ch,
  160. unsigned int vol1, unsigned int vol2)
  161. {
  162. switch (ch) {
  163. case 0:
  164. se200pci_WM8766_write(ice, 0x000, vol1);
  165. se200pci_WM8766_write(ice, 0x001, vol2 | 0x100);
  166. break;
  167. case 1:
  168. se200pci_WM8766_write(ice, 0x004, vol1);
  169. se200pci_WM8766_write(ice, 0x005, vol2 | 0x100);
  170. break;
  171. case 2:
  172. se200pci_WM8766_write(ice, 0x006, vol1);
  173. se200pci_WM8766_write(ice, 0x007, vol2 | 0x100);
  174. break;
  175. }
  176. }
  177. static void __devinit se200pci_WM8766_init(struct snd_ice1712 *ice)
  178. {
  179. se200pci_WM8766_write(ice, 0x1f, 0x000); /* RESET ALL */
  180. udelay(10);
  181. se200pci_WM8766_set_volume(ice, 0, 0, 0); /* volume L=0 R=0 */
  182. se200pci_WM8766_set_volume(ice, 1, 0, 0); /* volume L=0 R=0 */
  183. se200pci_WM8766_set_volume(ice, 2, 0, 0); /* volume L=0 R=0 */
  184. se200pci_WM8766_write(ice, 0x03, 0x022); /* serial mode I2S-24bits */
  185. se200pci_WM8766_write(ice, 0x0a, 0x080); /* MCLK=256fs */
  186. se200pci_WM8766_write(ice, 0x12, 0x000); /* MDP=0 */
  187. se200pci_WM8766_write(ice, 0x15, 0x000); /* MDP=0 */
  188. se200pci_WM8766_write(ice, 0x09, 0x000); /* demp=off mute=off */
  189. se200pci_WM8766_write(ice, 0x02, 0x124); /* ch-assign L=L R=R RESET */
  190. se200pci_WM8766_write(ice, 0x02, 0x120); /* ch-assign L=L R=R */
  191. }
  192. static void se200pci_WM8766_set_pro_rate(struct snd_ice1712 *ice,
  193. unsigned int rate)
  194. {
  195. if (rate > 96000)
  196. se200pci_WM8766_write(ice, 0x0a, 0x000); /* MCLK=128fs */
  197. else
  198. se200pci_WM8766_write(ice, 0x0a, 0x080); /* MCLK=256fs */
  199. }
  200. /****************************************************************************/
  201. /* WM8776 interface */
  202. /****************************************************************************/
  203. static void se200pci_WM8776_write(struct snd_ice1712 *ice,
  204. unsigned int addr, unsigned int data)
  205. {
  206. unsigned int val;
  207. val = (addr << 9) | data;
  208. snd_vt1724_write_i2c(ice, 0x34, val >> 8, val & 0xff);
  209. }
  210. static void se200pci_WM8776_set_output_volume(struct snd_ice1712 *ice,
  211. unsigned int vol1, unsigned int vol2)
  212. {
  213. se200pci_WM8776_write(ice, 0x03, vol1);
  214. se200pci_WM8776_write(ice, 0x04, vol2 | 0x100);
  215. }
  216. static void se200pci_WM8776_set_input_volume(struct snd_ice1712 *ice,
  217. unsigned int vol1, unsigned int vol2)
  218. {
  219. se200pci_WM8776_write(ice, 0x0e, vol1);
  220. se200pci_WM8776_write(ice, 0x0f, vol2 | 0x100);
  221. }
  222. static const char *se200pci_sel[] = {
  223. "LINE-IN", "CD-IN", "MIC-IN", "ALL-MIX", NULL
  224. };
  225. static void se200pci_WM8776_set_input_selector(struct snd_ice1712 *ice,
  226. unsigned int sel)
  227. {
  228. static unsigned char vals[] = {
  229. /* LINE, CD, MIC, ALL, GND */
  230. 0x10, 0x04, 0x08, 0x1c, 0x03
  231. };
  232. if (sel > 4)
  233. sel = 4;
  234. se200pci_WM8776_write(ice, 0x15, vals[sel]);
  235. }
  236. static void se200pci_WM8776_set_afl(struct snd_ice1712 *ice, unsigned int afl)
  237. {
  238. /* AFL -- After Fader Listening */
  239. if (afl)
  240. se200pci_WM8776_write(ice, 0x16, 0x005);
  241. else
  242. se200pci_WM8776_write(ice, 0x16, 0x001);
  243. }
  244. static const char *se200pci_agc[] = {
  245. "Off", "LimiterMode", "ALCMode", NULL
  246. };
  247. static void se200pci_WM8776_set_agc(struct snd_ice1712 *ice, unsigned int agc)
  248. {
  249. /* AGC -- Auto Gain Control of the input */
  250. switch (agc) {
  251. case 0:
  252. se200pci_WM8776_write(ice, 0x11, 0x000); /* Off */
  253. break;
  254. case 1:
  255. se200pci_WM8776_write(ice, 0x10, 0x07b);
  256. se200pci_WM8776_write(ice, 0x11, 0x100); /* LimiterMode */
  257. break;
  258. case 2:
  259. se200pci_WM8776_write(ice, 0x10, 0x1fb);
  260. se200pci_WM8776_write(ice, 0x11, 0x100); /* ALCMode */
  261. break;
  262. }
  263. }
  264. static void __devinit se200pci_WM8776_init(struct snd_ice1712 *ice)
  265. {
  266. int i;
  267. static unsigned short __devinitdata default_values[] = {
  268. 0x100, 0x100, 0x100,
  269. 0x100, 0x100, 0x100,
  270. 0x000, 0x090, 0x000, 0x000,
  271. 0x022, 0x022, 0x022,
  272. 0x008, 0x0cf, 0x0cf, 0x07b, 0x000,
  273. 0x032, 0x000, 0x0a6, 0x001, 0x001
  274. };
  275. se200pci_WM8776_write(ice, 0x17, 0x000); /* reset all */
  276. /* ADC and DAC interface is I2S 24bits mode */
  277. /* The sample-rate are automatically changed */
  278. udelay(10);
  279. /* BUT my board can not do reset all, so I load all by manually. */
  280. for (i = 0; i < ARRAY_SIZE(default_values); i++)
  281. se200pci_WM8776_write(ice, i, default_values[i]);
  282. se200pci_WM8776_set_input_selector(ice, 0);
  283. se200pci_WM8776_set_afl(ice, 0);
  284. se200pci_WM8776_set_agc(ice, 0);
  285. se200pci_WM8776_set_input_volume(ice, 0, 0);
  286. se200pci_WM8776_set_output_volume(ice, 0, 0);
  287. /* head phone mute and power down */
  288. se200pci_WM8776_write(ice, 0x00, 0);
  289. se200pci_WM8776_write(ice, 0x01, 0);
  290. se200pci_WM8776_write(ice, 0x02, 0x100);
  291. se200pci_WM8776_write(ice, 0x0d, 0x080);
  292. }
  293. static void se200pci_WM8776_set_pro_rate(struct snd_ice1712 *ice,
  294. unsigned int rate)
  295. {
  296. /* nothing to do */
  297. }
  298. /****************************************************************************/
  299. /* runtime interface */
  300. /****************************************************************************/
  301. static void se200pci_set_pro_rate(struct snd_ice1712 *ice, unsigned int rate)
  302. {
  303. se200pci_WM8740_set_pro_rate(ice, rate);
  304. se200pci_WM8766_set_pro_rate(ice, rate);
  305. se200pci_WM8776_set_pro_rate(ice, rate);
  306. }
  307. struct se200pci_control {
  308. char *name;
  309. enum {
  310. WM8766,
  311. WM8776in,
  312. WM8776out,
  313. WM8776sel,
  314. WM8776agc,
  315. WM8776afl
  316. } target;
  317. enum { VOLUME1, VOLUME2, BOOLEAN, ENUM } type;
  318. int ch;
  319. const char **member;
  320. const char *comment;
  321. };
  322. static const struct se200pci_control se200pci_cont[] = {
  323. {
  324. .name = "Front Playback Volume",
  325. .target = WM8776out,
  326. .type = VOLUME1,
  327. .comment = "Front(green)"
  328. },
  329. {
  330. .name = "Side Playback Volume",
  331. .target = WM8766,
  332. .type = VOLUME1,
  333. .ch = 1,
  334. .comment = "Surround(orange)"
  335. },
  336. {
  337. .name = "Surround Playback Volume",
  338. .target = WM8766,
  339. .type = VOLUME1,
  340. .ch = 2,
  341. .comment = "SurroundBack(white)"
  342. },
  343. {
  344. .name = "CLFE Playback Volume",
  345. .target = WM8766,
  346. .type = VOLUME1,
  347. .ch = 0,
  348. .comment = "Center(Lch)&SubWoofer(Rch)(black)"
  349. },
  350. {
  351. .name = "Capture Volume",
  352. .target = WM8776in,
  353. .type = VOLUME2
  354. },
  355. {
  356. .name = "Capture Select",
  357. .target = WM8776sel,
  358. .type = ENUM,
  359. .member = se200pci_sel
  360. },
  361. {
  362. .name = "AGC Capture Mode",
  363. .target = WM8776agc,
  364. .type = ENUM,
  365. .member = se200pci_agc
  366. },
  367. {
  368. .name = "AFL Bypass Playback Switch",
  369. .target = WM8776afl,
  370. .type = BOOLEAN
  371. }
  372. };
  373. static int se200pci_get_enum_count(int n)
  374. {
  375. const char **member;
  376. int c;
  377. member = se200pci_cont[n].member;
  378. if (!member)
  379. return 0;
  380. for (c = 0; member[c]; c++)
  381. ;
  382. return c;
  383. }
  384. static int se200pci_cont_volume_info(struct snd_kcontrol *kc,
  385. struct snd_ctl_elem_info *uinfo)
  386. {
  387. uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
  388. uinfo->count = 2;
  389. uinfo->value.integer.min = 0; /* mute */
  390. uinfo->value.integer.max = 0xff; /* 0dB */
  391. return 0;
  392. }
  393. #define se200pci_cont_boolean_info snd_ctl_boolean_mono_info
  394. static int se200pci_cont_enum_info(struct snd_kcontrol *kc,
  395. struct snd_ctl_elem_info *uinfo)
  396. {
  397. int n, c;
  398. n = kc->private_value;
  399. c = se200pci_get_enum_count(n);
  400. if (!c)
  401. return -EINVAL;
  402. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  403. uinfo->count = 1;
  404. uinfo->value.enumerated.items = c;
  405. if (uinfo->value.enumerated.item >= c)
  406. uinfo->value.enumerated.item = c - 1;
  407. strcpy(uinfo->value.enumerated.name,
  408. se200pci_cont[n].member[uinfo->value.enumerated.item]);
  409. return 0;
  410. }
  411. static int se200pci_cont_volume_get(struct snd_kcontrol *kc,
  412. struct snd_ctl_elem_value *uc)
  413. {
  414. struct snd_ice1712 *ice = snd_kcontrol_chip(kc);
  415. struct se_spec *spec = ice->spec;
  416. int n = kc->private_value;
  417. uc->value.integer.value[0] = spec->vol[n].ch1;
  418. uc->value.integer.value[1] = spec->vol[n].ch2;
  419. return 0;
  420. }
  421. static int se200pci_cont_boolean_get(struct snd_kcontrol *kc,
  422. struct snd_ctl_elem_value *uc)
  423. {
  424. struct snd_ice1712 *ice = snd_kcontrol_chip(kc);
  425. struct se_spec *spec = ice->spec;
  426. int n = kc->private_value;
  427. uc->value.integer.value[0] = spec->vol[n].ch1;
  428. return 0;
  429. }
  430. static int se200pci_cont_enum_get(struct snd_kcontrol *kc,
  431. struct snd_ctl_elem_value *uc)
  432. {
  433. struct snd_ice1712 *ice = snd_kcontrol_chip(kc);
  434. struct se_spec *spec = ice->spec;
  435. int n = kc->private_value;
  436. uc->value.enumerated.item[0] = spec->vol[n].ch1;
  437. return 0;
  438. }
  439. static void se200pci_cont_update(struct snd_ice1712 *ice, int n)
  440. {
  441. struct se_spec *spec = ice->spec;
  442. switch (se200pci_cont[n].target) {
  443. case WM8766:
  444. se200pci_WM8766_set_volume(ice,
  445. se200pci_cont[n].ch,
  446. spec->vol[n].ch1,
  447. spec->vol[n].ch2);
  448. break;
  449. case WM8776in:
  450. se200pci_WM8776_set_input_volume(ice,
  451. spec->vol[n].ch1,
  452. spec->vol[n].ch2);
  453. break;
  454. case WM8776out:
  455. se200pci_WM8776_set_output_volume(ice,
  456. spec->vol[n].ch1,
  457. spec->vol[n].ch2);
  458. break;
  459. case WM8776sel:
  460. se200pci_WM8776_set_input_selector(ice,
  461. spec->vol[n].ch1);
  462. break;
  463. case WM8776agc:
  464. se200pci_WM8776_set_agc(ice, spec->vol[n].ch1);
  465. break;
  466. case WM8776afl:
  467. se200pci_WM8776_set_afl(ice, spec->vol[n].ch1);
  468. break;
  469. default:
  470. break;
  471. }
  472. }
  473. static int se200pci_cont_volume_put(struct snd_kcontrol *kc,
  474. struct snd_ctl_elem_value *uc)
  475. {
  476. struct snd_ice1712 *ice = snd_kcontrol_chip(kc);
  477. struct se_spec *spec = ice->spec;
  478. int n = kc->private_value;
  479. unsigned int vol1, vol2;
  480. int changed;
  481. changed = 0;
  482. vol1 = uc->value.integer.value[0] & 0xff;
  483. vol2 = uc->value.integer.value[1] & 0xff;
  484. if (spec->vol[n].ch1 != vol1) {
  485. spec->vol[n].ch1 = vol1;
  486. changed = 1;
  487. }
  488. if (spec->vol[n].ch2 != vol2) {
  489. spec->vol[n].ch2 = vol2;
  490. changed = 1;
  491. }
  492. if (changed)
  493. se200pci_cont_update(ice, n);
  494. return changed;
  495. }
  496. static int se200pci_cont_boolean_put(struct snd_kcontrol *kc,
  497. struct snd_ctl_elem_value *uc)
  498. {
  499. struct snd_ice1712 *ice = snd_kcontrol_chip(kc);
  500. struct se_spec *spec = ice->spec;
  501. int n = kc->private_value;
  502. unsigned int vol1;
  503. vol1 = !!uc->value.integer.value[0];
  504. if (spec->vol[n].ch1 != vol1) {
  505. spec->vol[n].ch1 = vol1;
  506. se200pci_cont_update(ice, n);
  507. return 1;
  508. }
  509. return 0;
  510. }
  511. static int se200pci_cont_enum_put(struct snd_kcontrol *kc,
  512. struct snd_ctl_elem_value *uc)
  513. {
  514. struct snd_ice1712 *ice = snd_kcontrol_chip(kc);
  515. struct se_spec *spec = ice->spec;
  516. int n = kc->private_value;
  517. unsigned int vol1;
  518. vol1 = uc->value.enumerated.item[0];
  519. if (vol1 >= se200pci_get_enum_count(n))
  520. return -EINVAL;
  521. if (spec->vol[n].ch1 != vol1) {
  522. spec->vol[n].ch1 = vol1;
  523. se200pci_cont_update(ice, n);
  524. return 1;
  525. }
  526. return 0;
  527. }
  528. static const DECLARE_TLV_DB_SCALE(db_scale_gain1, -12750, 50, 1);
  529. static const DECLARE_TLV_DB_SCALE(db_scale_gain2, -10350, 50, 1);
  530. static int __devinit se200pci_add_controls(struct snd_ice1712 *ice)
  531. {
  532. int i;
  533. struct snd_kcontrol_new cont;
  534. int err;
  535. memset(&cont, 0, sizeof(cont));
  536. cont.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
  537. for (i = 0; i < ARRAY_SIZE(se200pci_cont); i++) {
  538. cont.private_value = i;
  539. cont.name = se200pci_cont[i].name;
  540. cont.access = SNDRV_CTL_ELEM_ACCESS_READWRITE;
  541. cont.tlv.p = NULL;
  542. switch (se200pci_cont[i].type) {
  543. case VOLUME1:
  544. case VOLUME2:
  545. cont.info = se200pci_cont_volume_info;
  546. cont.get = se200pci_cont_volume_get;
  547. cont.put = se200pci_cont_volume_put;
  548. cont.access |= SNDRV_CTL_ELEM_ACCESS_TLV_READ;
  549. if (se200pci_cont[i].type == VOLUME1)
  550. cont.tlv.p = db_scale_gain1;
  551. else
  552. cont.tlv.p = db_scale_gain2;
  553. break;
  554. case BOOLEAN:
  555. cont.info = se200pci_cont_boolean_info;
  556. cont.get = se200pci_cont_boolean_get;
  557. cont.put = se200pci_cont_boolean_put;
  558. break;
  559. case ENUM:
  560. cont.info = se200pci_cont_enum_info;
  561. cont.get = se200pci_cont_enum_get;
  562. cont.put = se200pci_cont_enum_put;
  563. break;
  564. default:
  565. snd_BUG();
  566. return -EINVAL;
  567. }
  568. err = snd_ctl_add(ice->card, snd_ctl_new1(&cont, ice));
  569. if (err < 0)
  570. return err;
  571. }
  572. return 0;
  573. }
  574. /****************************************************************************/
  575. /* ONKYO WAVIO SE-90PCI */
  576. /****************************************************************************/
  577. /*
  578. * system configuration ICE_EEP2_SYSCONF=0x4b
  579. * AC-Link configuration ICE_EEP2_ACLINK=0x80
  580. * I2S converters feature ICE_EEP2_I2S=0x78
  581. * S/PDIF configuration ICE_EEP2_SPDIF=0xc3
  582. *
  583. * ** connected chip **
  584. *
  585. * WM8716
  586. * A 2ch-DAC of main outputs.
  587. * It setuped as I2S mode by wire, so no way to setup from software.
  588. * ML/I2S (28pin) -- +5V
  589. * MC/DM1 (27pin) -- GND
  590. * MC/DM0 (26pin) -- GND
  591. * MUTEB (25pin) -- open (internal pull-up)
  592. * MODE (24pin) -- GND
  593. * CSBIWO (23pin) -- +5V
  594. *
  595. */
  596. /* Nothing to do for this chip. */
  597. /****************************************************************************/
  598. /* probe/initialize/setup */
  599. /****************************************************************************/
  600. static int __devinit se_init(struct snd_ice1712 *ice)
  601. {
  602. struct se_spec *spec;
  603. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  604. if (!spec)
  605. return -ENOMEM;
  606. ice->spec = spec;
  607. if (ice->eeprom.subvendor == VT1724_SUBDEVICE_SE90PCI) {
  608. ice->num_total_dacs = 2;
  609. ice->num_total_adcs = 0;
  610. ice->vt1720 = 1;
  611. return 0;
  612. } else if (ice->eeprom.subvendor == VT1724_SUBDEVICE_SE200PCI) {
  613. ice->num_total_dacs = 8;
  614. ice->num_total_adcs = 2;
  615. se200pci_WM8740_init(ice);
  616. se200pci_WM8766_init(ice);
  617. se200pci_WM8776_init(ice);
  618. ice->gpio.set_pro_rate = se200pci_set_pro_rate;
  619. return 0;
  620. }
  621. return -ENOENT;
  622. }
  623. static int __devinit se_add_controls(struct snd_ice1712 *ice)
  624. {
  625. int err;
  626. err = 0;
  627. /* nothing to do for VT1724_SUBDEVICE_SE90PCI */
  628. if (ice->eeprom.subvendor == VT1724_SUBDEVICE_SE200PCI)
  629. err = se200pci_add_controls(ice);
  630. return err;
  631. }
  632. /****************************************************************************/
  633. /* entry point */
  634. /****************************************************************************/
  635. static unsigned char se200pci_eeprom[] __devinitdata = {
  636. [ICE_EEP2_SYSCONF] = 0x4b, /* 49.152Hz, spdif-in/ADC, 4DACs */
  637. [ICE_EEP2_ACLINK] = 0x80, /* I2S */
  638. [ICE_EEP2_I2S] = 0x78, /* 96k-ok, 24bit, 192k-ok */
  639. [ICE_EEP2_SPDIF] = 0xc3, /* out-en, out-int, spdif-in */
  640. [ICE_EEP2_GPIO_DIR] = 0x02, /* WM8766 mute 1=output */
  641. [ICE_EEP2_GPIO_DIR1] = 0x00, /* not used */
  642. [ICE_EEP2_GPIO_DIR2] = 0x07, /* WM8766 ML/MC/MD 1=output */
  643. [ICE_EEP2_GPIO_MASK] = 0x00, /* 0=writable */
  644. [ICE_EEP2_GPIO_MASK1] = 0x00, /* 0=writable */
  645. [ICE_EEP2_GPIO_MASK2] = 0x00, /* 0=writable */
  646. [ICE_EEP2_GPIO_STATE] = 0x00, /* WM8766 mute=0 */
  647. [ICE_EEP2_GPIO_STATE1] = 0x00, /* not used */
  648. [ICE_EEP2_GPIO_STATE2] = 0x07, /* WM8766 ML/MC/MD */
  649. };
  650. static unsigned char se90pci_eeprom[] __devinitdata = {
  651. [ICE_EEP2_SYSCONF] = 0x4b, /* 49.152Hz, spdif-in/ADC, 4DACs */
  652. [ICE_EEP2_ACLINK] = 0x80, /* I2S */
  653. [ICE_EEP2_I2S] = 0x78, /* 96k-ok, 24bit, 192k-ok */
  654. [ICE_EEP2_SPDIF] = 0xc3, /* out-en, out-int, spdif-in */
  655. /* ALL GPIO bits are in input mode */
  656. };
  657. struct snd_ice1712_card_info snd_vt1724_se_cards[] __devinitdata = {
  658. {
  659. .subvendor = VT1724_SUBDEVICE_SE200PCI,
  660. .name = "ONKYO SE200PCI",
  661. .model = "se200pci",
  662. .chip_init = se_init,
  663. .build_controls = se_add_controls,
  664. .eeprom_size = sizeof(se200pci_eeprom),
  665. .eeprom_data = se200pci_eeprom,
  666. },
  667. {
  668. .subvendor = VT1724_SUBDEVICE_SE90PCI,
  669. .name = "ONKYO SE90PCI",
  670. .model = "se90pci",
  671. .chip_init = se_init,
  672. .build_controls = se_add_controls,
  673. .eeprom_size = sizeof(se90pci_eeprom),
  674. .eeprom_data = se90pci_eeprom,
  675. },
  676. {} /*terminator*/
  677. };