se.c 20 KB

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