quartet.c 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131
  1. /*
  2. * ALSA driver for ICEnsemble VT1724 (Envy24HT)
  3. *
  4. * Lowlevel functions for Infrasonic Quartet
  5. *
  6. * Copyright (c) 2009 Pavel Hofman <pavel.hofman@ivitera.com>
  7. *
  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 <sound/info.h>
  32. #include "ice1712.h"
  33. #include "envy24ht.h"
  34. #include <sound/ak4113.h>
  35. #include "quartet.h"
  36. struct qtet_spec {
  37. struct ak4113 *ak4113;
  38. unsigned int scr; /* system control register */
  39. unsigned int mcr; /* monitoring control register */
  40. unsigned int cpld; /* cpld register */
  41. };
  42. struct qtet_kcontrol_private {
  43. unsigned int bit;
  44. void (*set_register)(struct snd_ice1712 *ice, unsigned int val);
  45. unsigned int (*get_register)(struct snd_ice1712 *ice);
  46. unsigned char *texts[2];
  47. };
  48. enum {
  49. IN12_SEL = 0,
  50. IN34_SEL,
  51. AIN34_SEL,
  52. COAX_OUT,
  53. IN12_MON12,
  54. IN12_MON34,
  55. IN34_MON12,
  56. IN34_MON34,
  57. OUT12_MON34,
  58. OUT34_MON12,
  59. };
  60. static char *ext_clock_names[3] = {"IEC958 In", "Word Clock 1xFS",
  61. "Word Clock 256xFS"};
  62. /* chip address on I2C bus */
  63. #define AK4113_ADDR 0x26 /* S/PDIF receiver */
  64. /* chip address on SPI bus */
  65. #define AK4620_ADDR 0x02 /* ADC/DAC */
  66. /*
  67. * GPIO pins
  68. */
  69. /* GPIO0 - O - DATA0, def. 0 */
  70. #define GPIO_D0 (1<<0)
  71. /* GPIO1 - I/O - DATA1, Jack Detect Input0 (0:present, 1:missing), def. 1 */
  72. #define GPIO_D1_JACKDTC0 (1<<1)
  73. /* GPIO2 - I/O - DATA2, Jack Detect Input1 (0:present, 1:missing), def. 1 */
  74. #define GPIO_D2_JACKDTC1 (1<<2)
  75. /* GPIO3 - I/O - DATA3, def. 1 */
  76. #define GPIO_D3 (1<<3)
  77. /* GPIO4 - I/O - DATA4, SPI CDTO, def. 1 */
  78. #define GPIO_D4_SPI_CDTO (1<<4)
  79. /* GPIO5 - I/O - DATA5, SPI CCLK, def. 1 */
  80. #define GPIO_D5_SPI_CCLK (1<<5)
  81. /* GPIO6 - I/O - DATA6, Cable Detect Input (0:detected, 1:not detected */
  82. #define GPIO_D6_CD (1<<6)
  83. /* GPIO7 - I/O - DATA7, Device Detect Input (0:detected, 1:not detected */
  84. #define GPIO_D7_DD (1<<7)
  85. /* GPIO8 - O - CPLD Chip Select, def. 1 */
  86. #define GPIO_CPLD_CSN (1<<8)
  87. /* GPIO9 - O - CPLD register read/write (0:write, 1:read), def. 0 */
  88. #define GPIO_CPLD_RW (1<<9)
  89. /* GPIO10 - O - SPI Chip Select for CODEC#0, def. 1 */
  90. #define GPIO_SPI_CSN0 (1<<10)
  91. /* GPIO11 - O - SPI Chip Select for CODEC#1, def. 1 */
  92. #define GPIO_SPI_CSN1 (1<<11)
  93. /* GPIO12 - O - Ex. Register Output Enable (0:enable, 1:disable), def. 1,
  94. * init 0 */
  95. #define GPIO_EX_GPIOE (1<<12)
  96. /* GPIO13 - O - Ex. Register0 Chip Select for System Control Register,
  97. * def. 1 */
  98. #define GPIO_SCR (1<<13)
  99. /* GPIO14 - O - Ex. Register1 Chip Select for Monitor Control Register,
  100. * def. 1 */
  101. #define GPIO_MCR (1<<14)
  102. #define GPIO_SPI_ALL (GPIO_D4_SPI_CDTO | GPIO_D5_SPI_CCLK |\
  103. GPIO_SPI_CSN0 | GPIO_SPI_CSN1)
  104. #define GPIO_DATA_MASK (GPIO_D0 | GPIO_D1_JACKDTC0 | \
  105. GPIO_D2_JACKDTC1 | GPIO_D3 | \
  106. GPIO_D4_SPI_CDTO | GPIO_D5_SPI_CCLK | \
  107. GPIO_D6_CD | GPIO_D7_DD)
  108. /* System Control Register GPIO_SCR data bits */
  109. /* Mic/Line select relay (0:line, 1:mic) */
  110. #define SCR_RELAY GPIO_D0
  111. /* Phantom power drive control (0:5V, 1:48V) */
  112. #define SCR_PHP_V GPIO_D1_JACKDTC0
  113. /* H/W mute control (0:Normal, 1:Mute) */
  114. #define SCR_MUTE GPIO_D2_JACKDTC1
  115. /* Phantom power control (0:Phantom on, 1:off) */
  116. #define SCR_PHP GPIO_D3
  117. /* Analog input 1/2 Source Select */
  118. #define SCR_AIN12_SEL0 GPIO_D4_SPI_CDTO
  119. #define SCR_AIN12_SEL1 GPIO_D5_SPI_CCLK
  120. /* Analog input 3/4 Source Select (0:line, 1:hi-z) */
  121. #define SCR_AIN34_SEL GPIO_D6_CD
  122. /* Codec Power Down (0:power down, 1:normal) */
  123. #define SCR_CODEC_PDN GPIO_D7_DD
  124. #define SCR_AIN12_LINE (0)
  125. #define SCR_AIN12_MIC (SCR_AIN12_SEL0)
  126. #define SCR_AIN12_LOWCUT (SCR_AIN12_SEL1 | SCR_AIN12_SEL0)
  127. /* Monitor Control Register GPIO_MCR data bits */
  128. /* Input 1/2 to Monitor 1/2 (0:off, 1:on) */
  129. #define MCR_IN12_MON12 GPIO_D0
  130. /* Input 1/2 to Monitor 3/4 (0:off, 1:on) */
  131. #define MCR_IN12_MON34 GPIO_D1_JACKDTC0
  132. /* Input 3/4 to Monitor 1/2 (0:off, 1:on) */
  133. #define MCR_IN34_MON12 GPIO_D2_JACKDTC1
  134. /* Input 3/4 to Monitor 3/4 (0:off, 1:on) */
  135. #define MCR_IN34_MON34 GPIO_D3
  136. /* Output to Monitor 1/2 (0:off, 1:on) */
  137. #define MCR_OUT34_MON12 GPIO_D4_SPI_CDTO
  138. /* Output to Monitor 3/4 (0:off, 1:on) */
  139. #define MCR_OUT12_MON34 GPIO_D5_SPI_CCLK
  140. /* CPLD Register DATA bits */
  141. /* Clock Rate Select */
  142. #define CPLD_CKS0 GPIO_D0
  143. #define CPLD_CKS1 GPIO_D1_JACKDTC0
  144. #define CPLD_CKS2 GPIO_D2_JACKDTC1
  145. /* Sync Source Select (0:Internal, 1:External) */
  146. #define CPLD_SYNC_SEL GPIO_D3
  147. /* Word Clock FS Select (0:FS, 1:256FS) */
  148. #define CPLD_WORD_SEL GPIO_D4_SPI_CDTO
  149. /* Coaxial Output Source (IS-Link) (0:SPDIF, 1:I2S) */
  150. #define CPLD_COAX_OUT GPIO_D5_SPI_CCLK
  151. /* Input 1/2 Source Select (0:Analog12, 1:An34) */
  152. #define CPLD_IN12_SEL GPIO_D6_CD
  153. /* Input 3/4 Source Select (0:Analog34, 1:Digital In) */
  154. #define CPLD_IN34_SEL GPIO_D7_DD
  155. /* internal clock (CPLD_SYNC_SEL = 0) options */
  156. #define CPLD_CKS_44100HZ (0)
  157. #define CPLD_CKS_48000HZ (CPLD_CKS0)
  158. #define CPLD_CKS_88200HZ (CPLD_CKS1)
  159. #define CPLD_CKS_96000HZ (CPLD_CKS1 | CPLD_CKS0)
  160. #define CPLD_CKS_176400HZ (CPLD_CKS2)
  161. #define CPLD_CKS_192000HZ (CPLD_CKS2 | CPLD_CKS0)
  162. #define CPLD_CKS_MASK (CPLD_CKS0 | CPLD_CKS1 | CPLD_CKS2)
  163. /* external clock (CPLD_SYNC_SEL = 1) options */
  164. /* external clock - SPDIF */
  165. #define CPLD_EXT_SPDIF (0 | CPLD_SYNC_SEL)
  166. /* external clock - WordClock 1xfs */
  167. #define CPLD_EXT_WORDCLOCK_1FS (CPLD_CKS1 | CPLD_SYNC_SEL)
  168. /* external clock - WordClock 256xfs */
  169. #define CPLD_EXT_WORDCLOCK_256FS (CPLD_CKS1 | CPLD_WORD_SEL |\
  170. CPLD_SYNC_SEL)
  171. #define EXT_SPDIF_TYPE 0
  172. #define EXT_WORDCLOCK_1FS_TYPE 1
  173. #define EXT_WORDCLOCK_256FS_TYPE 2
  174. #define AK4620_DFS0 (1<<0)
  175. #define AK4620_DFS1 (1<<1)
  176. #define AK4620_CKS0 (1<<2)
  177. #define AK4620_CKS1 (1<<3)
  178. /* Clock and Format Control register */
  179. #define AK4620_DFS_REG 0x02
  180. /* Deem and Volume Control register */
  181. #define AK4620_DEEMVOL_REG 0x03
  182. #define AK4620_SMUTE (1<<7)
  183. /*
  184. * Conversion from int value to its binary form. Used for debugging.
  185. * The output buffer must be allocated prior to calling the function.
  186. */
  187. static char *get_binary(char *buffer, int value)
  188. {
  189. int i, j, pos;
  190. pos = 0;
  191. for (i = 0; i < 4; ++i) {
  192. for (j = 0; j < 8; ++j) {
  193. if (value & (1 << (31-(i*8 + j))))
  194. buffer[pos] = '1';
  195. else
  196. buffer[pos] = '0';
  197. pos++;
  198. }
  199. if (i < 3) {
  200. buffer[pos] = ' ';
  201. pos++;
  202. }
  203. }
  204. buffer[pos] = '\0';
  205. return buffer;
  206. }
  207. /*
  208. * Initial setup of the conversion array GPIO <-> rate
  209. */
  210. static unsigned int qtet_rates[] = {
  211. 44100, 48000, 88200,
  212. 96000, 176400, 192000,
  213. };
  214. static unsigned int cks_vals[] = {
  215. CPLD_CKS_44100HZ, CPLD_CKS_48000HZ, CPLD_CKS_88200HZ,
  216. CPLD_CKS_96000HZ, CPLD_CKS_176400HZ, CPLD_CKS_192000HZ,
  217. };
  218. static struct snd_pcm_hw_constraint_list qtet_rates_info = {
  219. .count = ARRAY_SIZE(qtet_rates),
  220. .list = qtet_rates,
  221. .mask = 0,
  222. };
  223. static void qtet_ak4113_write(void *private_data, unsigned char reg,
  224. unsigned char val)
  225. {
  226. snd_vt1724_write_i2c((struct snd_ice1712 *)private_data, AK4113_ADDR,
  227. reg, val);
  228. }
  229. static unsigned char qtet_ak4113_read(void *private_data, unsigned char reg)
  230. {
  231. return snd_vt1724_read_i2c((struct snd_ice1712 *)private_data,
  232. AK4113_ADDR, reg);
  233. }
  234. /*
  235. * AK4620 section
  236. */
  237. /*
  238. * Write data to addr register of ak4620
  239. */
  240. static void qtet_akm_write(struct snd_akm4xxx *ak, int chip,
  241. unsigned char addr, unsigned char data)
  242. {
  243. unsigned int tmp, orig_dir;
  244. int idx;
  245. unsigned int addrdata;
  246. struct snd_ice1712 *ice = ak->private_data[0];
  247. if (snd_BUG_ON(chip < 0 || chip >= 4))
  248. return;
  249. /*printk(KERN_DEBUG "Writing to AK4620: chip=%d, addr=0x%x,
  250. data=0x%x\n", chip, addr, data);*/
  251. orig_dir = ice->gpio.get_dir(ice);
  252. ice->gpio.set_dir(ice, orig_dir | GPIO_SPI_ALL);
  253. /* set mask - only SPI bits */
  254. ice->gpio.set_mask(ice, ~GPIO_SPI_ALL);
  255. tmp = ice->gpio.get_data(ice);
  256. /* high all */
  257. tmp |= GPIO_SPI_ALL;
  258. ice->gpio.set_data(ice, tmp);
  259. udelay(100);
  260. /* drop chip select */
  261. if (chip)
  262. /* CODEC 1 */
  263. tmp &= ~GPIO_SPI_CSN1;
  264. else
  265. tmp &= ~GPIO_SPI_CSN0;
  266. ice->gpio.set_data(ice, tmp);
  267. udelay(100);
  268. /* build I2C address + data byte */
  269. addrdata = (AK4620_ADDR << 6) | 0x20 | (addr & 0x1f);
  270. addrdata = (addrdata << 8) | data;
  271. for (idx = 15; idx >= 0; idx--) {
  272. /* drop clock */
  273. tmp &= ~GPIO_D5_SPI_CCLK;
  274. ice->gpio.set_data(ice, tmp);
  275. udelay(100);
  276. /* set data */
  277. if (addrdata & (1 << idx))
  278. tmp |= GPIO_D4_SPI_CDTO;
  279. else
  280. tmp &= ~GPIO_D4_SPI_CDTO;
  281. ice->gpio.set_data(ice, tmp);
  282. udelay(100);
  283. /* raise clock */
  284. tmp |= GPIO_D5_SPI_CCLK;
  285. ice->gpio.set_data(ice, tmp);
  286. udelay(100);
  287. }
  288. /* all back to 1 */
  289. tmp |= GPIO_SPI_ALL;
  290. ice->gpio.set_data(ice, tmp);
  291. udelay(100);
  292. /* return all gpios to non-writable */
  293. ice->gpio.set_mask(ice, 0xffffff);
  294. /* restore GPIOs direction */
  295. ice->gpio.set_dir(ice, orig_dir);
  296. }
  297. static void qtet_akm_set_regs(struct snd_akm4xxx *ak, unsigned char addr,
  298. unsigned char mask, unsigned char value)
  299. {
  300. unsigned char tmp;
  301. int chip;
  302. for (chip = 0; chip < ak->num_chips; chip++) {
  303. tmp = snd_akm4xxx_get(ak, chip, addr);
  304. /* clear the bits */
  305. tmp &= ~mask;
  306. /* set the new bits */
  307. tmp |= value;
  308. snd_akm4xxx_write(ak, chip, addr, tmp);
  309. }
  310. }
  311. /*
  312. * change the rate of AK4620
  313. */
  314. static void qtet_akm_set_rate_val(struct snd_akm4xxx *ak, unsigned int rate)
  315. {
  316. unsigned char ak4620_dfs;
  317. if (rate == 0) /* no hint - S/PDIF input is master or the new spdif
  318. input rate undetected, simply return */
  319. return;
  320. /* adjust DFS on codecs - see datasheet */
  321. if (rate > 108000)
  322. ak4620_dfs = AK4620_DFS1 | AK4620_CKS1;
  323. else if (rate > 54000)
  324. ak4620_dfs = AK4620_DFS0 | AK4620_CKS0;
  325. else
  326. ak4620_dfs = 0;
  327. /* set new value */
  328. qtet_akm_set_regs(ak, AK4620_DFS_REG, AK4620_DFS0 | AK4620_DFS1 |
  329. AK4620_CKS0 | AK4620_CKS1, ak4620_dfs);
  330. }
  331. #define AK_CONTROL(xname, xch) { .name = xname, .num_channels = xch }
  332. #define PCM_12_PLAYBACK_VOLUME "PCM 1/2 Playback Volume"
  333. #define PCM_34_PLAYBACK_VOLUME "PCM 3/4 Playback Volume"
  334. #define PCM_12_CAPTURE_VOLUME "PCM 1/2 Capture Volume"
  335. #define PCM_34_CAPTURE_VOLUME "PCM 3/4 Capture Volume"
  336. static const struct snd_akm4xxx_dac_channel qtet_dac[] = {
  337. AK_CONTROL(PCM_12_PLAYBACK_VOLUME, 2),
  338. AK_CONTROL(PCM_34_PLAYBACK_VOLUME, 2),
  339. };
  340. static const struct snd_akm4xxx_adc_channel qtet_adc[] = {
  341. AK_CONTROL(PCM_12_CAPTURE_VOLUME, 2),
  342. AK_CONTROL(PCM_34_CAPTURE_VOLUME, 2),
  343. };
  344. static struct snd_akm4xxx akm_qtet_dac __devinitdata = {
  345. .type = SND_AK4620,
  346. .num_dacs = 4, /* DAC1 - Output 12
  347. */
  348. .num_adcs = 4, /* ADC1 - Input 12
  349. */
  350. .ops = {
  351. .write = qtet_akm_write,
  352. .set_rate_val = qtet_akm_set_rate_val,
  353. },
  354. .dac_info = qtet_dac,
  355. .adc_info = qtet_adc,
  356. };
  357. /* Communication routines with the CPLD */
  358. /* Writes data to external register reg, both reg and data are
  359. * GPIO representations */
  360. static void reg_write(struct snd_ice1712 *ice, unsigned int reg,
  361. unsigned int data)
  362. {
  363. unsigned int tmp;
  364. mutex_lock(&ice->gpio_mutex);
  365. /* set direction of used GPIOs*/
  366. /* all outputs */
  367. tmp = 0x00ffff;
  368. ice->gpio.set_dir(ice, tmp);
  369. /* mask - writable bits */
  370. ice->gpio.set_mask(ice, ~(tmp));
  371. /* write the data */
  372. tmp = ice->gpio.get_data(ice);
  373. tmp &= ~GPIO_DATA_MASK;
  374. tmp |= data;
  375. ice->gpio.set_data(ice, tmp);
  376. udelay(100);
  377. /* drop output enable */
  378. tmp &= ~GPIO_EX_GPIOE;
  379. ice->gpio.set_data(ice, tmp);
  380. udelay(100);
  381. /* drop the register gpio */
  382. tmp &= ~reg;
  383. ice->gpio.set_data(ice, tmp);
  384. udelay(100);
  385. /* raise the register GPIO */
  386. tmp |= reg;
  387. ice->gpio.set_data(ice, tmp);
  388. udelay(100);
  389. /* raise all data gpios */
  390. tmp |= GPIO_DATA_MASK;
  391. ice->gpio.set_data(ice, tmp);
  392. /* mask - immutable bits */
  393. ice->gpio.set_mask(ice, 0xffffff);
  394. /* outputs only 8-15 */
  395. ice->gpio.set_dir(ice, 0x00ff00);
  396. mutex_unlock(&ice->gpio_mutex);
  397. }
  398. static unsigned int get_scr(struct snd_ice1712 *ice)
  399. {
  400. struct qtet_spec *spec = ice->spec;
  401. return spec->scr;
  402. }
  403. static unsigned int get_mcr(struct snd_ice1712 *ice)
  404. {
  405. struct qtet_spec *spec = ice->spec;
  406. return spec->mcr;
  407. }
  408. static unsigned int get_cpld(struct snd_ice1712 *ice)
  409. {
  410. struct qtet_spec *spec = ice->spec;
  411. return spec->cpld;
  412. }
  413. static void set_scr(struct snd_ice1712 *ice, unsigned int val)
  414. {
  415. struct qtet_spec *spec = ice->spec;
  416. reg_write(ice, GPIO_SCR, val);
  417. spec->scr = val;
  418. }
  419. static void set_mcr(struct snd_ice1712 *ice, unsigned int val)
  420. {
  421. struct qtet_spec *spec = ice->spec;
  422. reg_write(ice, GPIO_MCR, val);
  423. spec->mcr = val;
  424. }
  425. static void set_cpld(struct snd_ice1712 *ice, unsigned int val)
  426. {
  427. struct qtet_spec *spec = ice->spec;
  428. reg_write(ice, GPIO_CPLD_CSN, val);
  429. spec->cpld = val;
  430. }
  431. #ifdef CONFIG_PROC_FS
  432. static void proc_regs_read(struct snd_info_entry *entry,
  433. struct snd_info_buffer *buffer)
  434. {
  435. struct snd_ice1712 *ice = entry->private_data;
  436. char bin_buffer[36];
  437. snd_iprintf(buffer, "SCR: %s\n", get_binary(bin_buffer,
  438. get_scr(ice)));
  439. snd_iprintf(buffer, "MCR: %s\n", get_binary(bin_buffer,
  440. get_mcr(ice)));
  441. snd_iprintf(buffer, "CPLD: %s\n", get_binary(bin_buffer,
  442. get_cpld(ice)));
  443. }
  444. static void proc_init(struct snd_ice1712 *ice)
  445. {
  446. struct snd_info_entry *entry;
  447. if (!snd_card_proc_new(ice->card, "quartet", &entry))
  448. snd_info_set_text_ops(entry, ice, proc_regs_read);
  449. }
  450. #else /* !CONFIG_PROC_FS */
  451. static void proc_init(struct snd_ice1712 *ice) {}
  452. #endif
  453. static int qtet_mute_get(struct snd_kcontrol *kcontrol,
  454. struct snd_ctl_elem_value *ucontrol)
  455. {
  456. struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
  457. unsigned int val;
  458. val = get_scr(ice) & SCR_MUTE;
  459. ucontrol->value.integer.value[0] = (val) ? 0 : 1;
  460. return 0;
  461. }
  462. static int qtet_mute_put(struct snd_kcontrol *kcontrol,
  463. struct snd_ctl_elem_value *ucontrol)
  464. {
  465. struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
  466. unsigned int old, new, smute;
  467. old = get_scr(ice) & SCR_MUTE;
  468. if (ucontrol->value.integer.value[0]) {
  469. /* unmute */
  470. new = 0;
  471. /* un-smuting DAC */
  472. smute = 0;
  473. } else {
  474. /* mute */
  475. new = SCR_MUTE;
  476. /* smuting DAC */
  477. smute = AK4620_SMUTE;
  478. }
  479. if (old != new) {
  480. struct snd_akm4xxx *ak = ice->akm;
  481. set_scr(ice, (get_scr(ice) & ~SCR_MUTE) | new);
  482. /* set smute */
  483. qtet_akm_set_regs(ak, AK4620_DEEMVOL_REG, AK4620_SMUTE, smute);
  484. return 1;
  485. }
  486. /* no change */
  487. return 0;
  488. }
  489. static int qtet_ain12_enum_info(struct snd_kcontrol *kcontrol,
  490. struct snd_ctl_elem_info *uinfo)
  491. {
  492. static char *texts[3] = {"Line In 1/2", "Mic", "Mic + Low-cut"};
  493. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  494. uinfo->count = 1;
  495. uinfo->value.enumerated.items = ARRAY_SIZE(texts);
  496. if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
  497. uinfo->value.enumerated.item =
  498. uinfo->value.enumerated.items - 1;
  499. strcpy(uinfo->value.enumerated.name,
  500. texts[uinfo->value.enumerated.item]);
  501. return 0;
  502. }
  503. static int qtet_ain12_sw_get(struct snd_kcontrol *kcontrol,
  504. struct snd_ctl_elem_value *ucontrol)
  505. {
  506. struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
  507. unsigned int val, result;
  508. val = get_scr(ice) & (SCR_AIN12_SEL1 | SCR_AIN12_SEL0);
  509. switch (val) {
  510. case SCR_AIN12_LINE:
  511. result = 0;
  512. break;
  513. case SCR_AIN12_MIC:
  514. result = 1;
  515. break;
  516. case SCR_AIN12_LOWCUT:
  517. result = 2;
  518. break;
  519. default:
  520. /* BUG - no other combinations allowed */
  521. snd_BUG();
  522. result = 0;
  523. }
  524. ucontrol->value.integer.value[0] = result;
  525. return 0;
  526. }
  527. static int qtet_ain12_sw_put(struct snd_kcontrol *kcontrol,
  528. struct snd_ctl_elem_value *ucontrol)
  529. {
  530. struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
  531. unsigned int old, new, tmp, masked_old;
  532. old = new = get_scr(ice);
  533. masked_old = old & (SCR_AIN12_SEL1 | SCR_AIN12_SEL0);
  534. tmp = ucontrol->value.integer.value[0];
  535. if (tmp == 2)
  536. tmp = 3; /* binary 10 is not supported */
  537. tmp <<= 4; /* shifting to SCR_AIN12_SEL0 */
  538. if (tmp != masked_old) {
  539. /* change requested */
  540. switch (tmp) {
  541. case SCR_AIN12_LINE:
  542. new = old & ~(SCR_AIN12_SEL1 | SCR_AIN12_SEL0);
  543. set_scr(ice, new);
  544. /* turn off relay */
  545. new &= ~SCR_RELAY;
  546. set_scr(ice, new);
  547. break;
  548. case SCR_AIN12_MIC:
  549. /* turn on relay */
  550. new = old | SCR_RELAY;
  551. set_scr(ice, new);
  552. new = (new & ~SCR_AIN12_SEL1) | SCR_AIN12_SEL0;
  553. set_scr(ice, new);
  554. break;
  555. case SCR_AIN12_LOWCUT:
  556. /* turn on relay */
  557. new = old | SCR_RELAY;
  558. set_scr(ice, new);
  559. new |= SCR_AIN12_SEL1 | SCR_AIN12_SEL0;
  560. set_scr(ice, new);
  561. break;
  562. default:
  563. snd_BUG();
  564. }
  565. return 1;
  566. }
  567. /* no change */
  568. return 0;
  569. }
  570. static int qtet_php_get(struct snd_kcontrol *kcontrol,
  571. struct snd_ctl_elem_value *ucontrol)
  572. {
  573. struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
  574. unsigned int val;
  575. /* if phantom voltage =48V, phantom on */
  576. val = get_scr(ice) & SCR_PHP_V;
  577. ucontrol->value.integer.value[0] = val ? 1 : 0;
  578. return 0;
  579. }
  580. static int qtet_php_put(struct snd_kcontrol *kcontrol,
  581. struct snd_ctl_elem_value *ucontrol)
  582. {
  583. struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
  584. unsigned int old, new;
  585. old = new = get_scr(ice);
  586. if (ucontrol->value.integer.value[0] /* phantom on requested */
  587. && (~old & SCR_PHP_V)) /* 0 = voltage 5V */ {
  588. /* is off, turn on */
  589. /* turn voltage on first, = 1 */
  590. new = old | SCR_PHP_V;
  591. set_scr(ice, new);
  592. /* turn phantom on, = 0 */
  593. new &= ~SCR_PHP;
  594. set_scr(ice, new);
  595. } else if (!ucontrol->value.integer.value[0] && (old & SCR_PHP_V)) {
  596. /* phantom off requested and 1 = voltage 48V */
  597. /* is on, turn off */
  598. /* turn voltage off first, = 0 */
  599. new = old & ~SCR_PHP_V;
  600. set_scr(ice, new);
  601. /* turn phantom off, = 1 */
  602. new |= SCR_PHP;
  603. set_scr(ice, new);
  604. }
  605. if (old != new)
  606. return 1;
  607. /* no change */
  608. return 0;
  609. }
  610. #define PRIV_SW(xid, xbit, xreg) [xid] = {.bit = xbit,\
  611. .set_register = set_##xreg,\
  612. .get_register = get_##xreg, }
  613. #define PRIV_ENUM2(xid, xbit, xreg, xtext1, xtext2) [xid] = {.bit = xbit,\
  614. .set_register = set_##xreg,\
  615. .get_register = get_##xreg,\
  616. .texts = {xtext1, xtext2} }
  617. static struct qtet_kcontrol_private qtet_privates[] = {
  618. PRIV_ENUM2(IN12_SEL, CPLD_IN12_SEL, cpld, "An In 1/2", "An In 3/4"),
  619. PRIV_ENUM2(IN34_SEL, CPLD_IN34_SEL, cpld, "An In 3/4", "IEC958 In"),
  620. PRIV_ENUM2(AIN34_SEL, SCR_AIN34_SEL, scr, "Line In 3/4", "Hi-Z"),
  621. PRIV_ENUM2(COAX_OUT, CPLD_COAX_OUT, cpld, "IEC958", "I2S"),
  622. PRIV_SW(IN12_MON12, MCR_IN12_MON12, mcr),
  623. PRIV_SW(IN12_MON34, MCR_IN12_MON34, mcr),
  624. PRIV_SW(IN34_MON12, MCR_IN34_MON12, mcr),
  625. PRIV_SW(IN34_MON34, MCR_IN34_MON34, mcr),
  626. PRIV_SW(OUT12_MON34, MCR_OUT12_MON34, mcr),
  627. PRIV_SW(OUT34_MON12, MCR_OUT34_MON12, mcr),
  628. };
  629. static int qtet_enum_info(struct snd_kcontrol *kcontrol,
  630. struct snd_ctl_elem_info *uinfo)
  631. {
  632. struct qtet_kcontrol_private private =
  633. qtet_privates[kcontrol->private_value];
  634. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  635. uinfo->count = 1;
  636. uinfo->value.enumerated.items = ARRAY_SIZE(private.texts);
  637. if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
  638. uinfo->value.enumerated.item =
  639. uinfo->value.enumerated.items - 1;
  640. strcpy(uinfo->value.enumerated.name,
  641. private.texts[uinfo->value.enumerated.item]);
  642. return 0;
  643. }
  644. static int qtet_sw_get(struct snd_kcontrol *kcontrol,
  645. struct snd_ctl_elem_value *ucontrol)
  646. {
  647. struct qtet_kcontrol_private private =
  648. qtet_privates[kcontrol->private_value];
  649. struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
  650. ucontrol->value.integer.value[0] =
  651. (private.get_register(ice) & private.bit) ? 1 : 0;
  652. return 0;
  653. }
  654. static int qtet_sw_put(struct snd_kcontrol *kcontrol,
  655. struct snd_ctl_elem_value *ucontrol)
  656. {
  657. struct qtet_kcontrol_private private =
  658. qtet_privates[kcontrol->private_value];
  659. struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
  660. unsigned int old, new;
  661. old = private.get_register(ice);
  662. if (ucontrol->value.integer.value[0])
  663. new = old | private.bit;
  664. else
  665. new = old & ~private.bit;
  666. if (old != new) {
  667. private.set_register(ice, new);
  668. return 1;
  669. }
  670. /* no change */
  671. return 0;
  672. }
  673. #define qtet_sw_info snd_ctl_boolean_mono_info
  674. #define QTET_CONTROL(xname, xtype, xpriv) \
  675. {.iface = SNDRV_CTL_ELEM_IFACE_MIXER,\
  676. .name = xname,\
  677. .info = qtet_##xtype##_info,\
  678. .get = qtet_sw_get,\
  679. .put = qtet_sw_put,\
  680. .private_value = xpriv }
  681. static struct snd_kcontrol_new qtet_controls[] __devinitdata = {
  682. {
  683. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  684. .name = "Master Playback Switch",
  685. .info = qtet_sw_info,
  686. .get = qtet_mute_get,
  687. .put = qtet_mute_put,
  688. .private_value = 0
  689. },
  690. {
  691. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  692. .name = "Phantom Power",
  693. .info = qtet_sw_info,
  694. .get = qtet_php_get,
  695. .put = qtet_php_put,
  696. .private_value = 0
  697. },
  698. {
  699. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  700. .name = "Analog In 1/2 Capture Switch",
  701. .info = qtet_ain12_enum_info,
  702. .get = qtet_ain12_sw_get,
  703. .put = qtet_ain12_sw_put,
  704. .private_value = 0
  705. },
  706. QTET_CONTROL("Analog In 3/4 Capture Switch", enum, AIN34_SEL),
  707. QTET_CONTROL("PCM In 1/2 Capture Switch", enum, IN12_SEL),
  708. QTET_CONTROL("PCM In 3/4 Capture Switch", enum, IN34_SEL),
  709. QTET_CONTROL("Coax Output Source", enum, COAX_OUT),
  710. QTET_CONTROL("Analog In 1/2 to Monitor 1/2", sw, IN12_MON12),
  711. QTET_CONTROL("Analog In 1/2 to Monitor 3/4", sw, IN12_MON34),
  712. QTET_CONTROL("Analog In 3/4 to Monitor 1/2", sw, IN34_MON12),
  713. QTET_CONTROL("Analog In 3/4 to Monitor 3/4", sw, IN34_MON34),
  714. QTET_CONTROL("Output 1/2 to Monitor 3/4", sw, OUT12_MON34),
  715. QTET_CONTROL("Output 3/4 to Monitor 1/2", sw, OUT34_MON12),
  716. };
  717. static char *slave_vols[] __devinitdata = {
  718. PCM_12_PLAYBACK_VOLUME,
  719. PCM_34_PLAYBACK_VOLUME,
  720. NULL
  721. };
  722. static __devinitdata
  723. DECLARE_TLV_DB_SCALE(qtet_master_db_scale, -6350, 50, 1);
  724. static struct snd_kcontrol __devinit *ctl_find(struct snd_card *card,
  725. const char *name)
  726. {
  727. struct snd_ctl_elem_id sid;
  728. memset(&sid, 0, sizeof(sid));
  729. /* FIXME: strcpy is bad. */
  730. strcpy(sid.name, name);
  731. sid.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
  732. return snd_ctl_find_id(card, &sid);
  733. }
  734. static void __devinit add_slaves(struct snd_card *card,
  735. struct snd_kcontrol *master, char **list)
  736. {
  737. for (; *list; list++) {
  738. struct snd_kcontrol *slave = ctl_find(card, *list);
  739. if (slave)
  740. snd_ctl_add_slave(master, slave);
  741. }
  742. }
  743. static int __devinit qtet_add_controls(struct snd_ice1712 *ice)
  744. {
  745. struct qtet_spec *spec = ice->spec;
  746. int err, i;
  747. struct snd_kcontrol *vmaster;
  748. err = snd_ice1712_akm4xxx_build_controls(ice);
  749. if (err < 0)
  750. return err;
  751. for (i = 0; i < ARRAY_SIZE(qtet_controls); i++) {
  752. err = snd_ctl_add(ice->card,
  753. snd_ctl_new1(&qtet_controls[i], ice));
  754. if (err < 0)
  755. return err;
  756. }
  757. /* Create virtual master control */
  758. vmaster = snd_ctl_make_virtual_master("Master Playback Volume",
  759. qtet_master_db_scale);
  760. if (!vmaster)
  761. return -ENOMEM;
  762. add_slaves(ice->card, vmaster, slave_vols);
  763. err = snd_ctl_add(ice->card, vmaster);
  764. if (err < 0)
  765. return err;
  766. /* only capture SPDIF over AK4113 */
  767. err = snd_ak4113_build(spec->ak4113,
  768. ice->pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream);
  769. if (err < 0)
  770. return err;
  771. return 0;
  772. }
  773. static inline int qtet_is_spdif_master(struct snd_ice1712 *ice)
  774. {
  775. /* CPLD_SYNC_SEL: 0 = internal, 1 = external (i.e. spdif master) */
  776. return (get_cpld(ice) & CPLD_SYNC_SEL) ? 1 : 0;
  777. }
  778. static unsigned int qtet_get_rate(struct snd_ice1712 *ice)
  779. {
  780. int i;
  781. unsigned char result;
  782. result = get_cpld(ice) & CPLD_CKS_MASK;
  783. for (i = 0; i < ARRAY_SIZE(cks_vals); i++)
  784. if (cks_vals[i] == result)
  785. return qtet_rates[i];
  786. return 0;
  787. }
  788. static int get_cks_val(int rate)
  789. {
  790. int i;
  791. for (i = 0; i < ARRAY_SIZE(qtet_rates); i++)
  792. if (qtet_rates[i] == rate)
  793. return cks_vals[i];
  794. return 0;
  795. }
  796. /* setting new rate */
  797. static void qtet_set_rate(struct snd_ice1712 *ice, unsigned int rate)
  798. {
  799. unsigned int new;
  800. unsigned char val;
  801. /* switching ice1724 to external clock - supplied by ext. circuits */
  802. val = inb(ICEMT1724(ice, RATE));
  803. outb(val | VT1724_SPDIF_MASTER, ICEMT1724(ice, RATE));
  804. new = (get_cpld(ice) & ~CPLD_CKS_MASK) | get_cks_val(rate);
  805. /* switch to internal clock, drop CPLD_SYNC_SEL */
  806. new &= ~CPLD_SYNC_SEL;
  807. /* printk(KERN_DEBUG "QT - set_rate: old %x, new %x\n",
  808. get_cpld(ice), new); */
  809. set_cpld(ice, new);
  810. }
  811. static inline unsigned char qtet_set_mclk(struct snd_ice1712 *ice,
  812. unsigned int rate)
  813. {
  814. /* no change in master clock */
  815. return 0;
  816. }
  817. /* setting clock to external - SPDIF */
  818. static int qtet_set_spdif_clock(struct snd_ice1712 *ice, int type)
  819. {
  820. unsigned int old, new;
  821. old = new = get_cpld(ice);
  822. new &= ~(CPLD_CKS_MASK | CPLD_WORD_SEL);
  823. switch (type) {
  824. case EXT_SPDIF_TYPE:
  825. new |= CPLD_EXT_SPDIF;
  826. break;
  827. case EXT_WORDCLOCK_1FS_TYPE:
  828. new |= CPLD_EXT_WORDCLOCK_1FS;
  829. break;
  830. case EXT_WORDCLOCK_256FS_TYPE:
  831. new |= CPLD_EXT_WORDCLOCK_256FS;
  832. break;
  833. default:
  834. snd_BUG();
  835. }
  836. if (old != new) {
  837. set_cpld(ice, new);
  838. /* changed */
  839. return 1;
  840. }
  841. return 0;
  842. }
  843. static int qtet_get_spdif_master_type(struct snd_ice1712 *ice)
  844. {
  845. unsigned int val;
  846. int result;
  847. val = get_cpld(ice);
  848. /* checking only rate/clock-related bits */
  849. val &= (CPLD_CKS_MASK | CPLD_WORD_SEL | CPLD_SYNC_SEL);
  850. if (!(val & CPLD_SYNC_SEL)) {
  851. /* switched to internal clock, is not any external type */
  852. result = -1;
  853. } else {
  854. switch (val) {
  855. case (CPLD_EXT_SPDIF):
  856. result = EXT_SPDIF_TYPE;
  857. break;
  858. case (CPLD_EXT_WORDCLOCK_1FS):
  859. result = EXT_WORDCLOCK_1FS_TYPE;
  860. break;
  861. case (CPLD_EXT_WORDCLOCK_256FS):
  862. result = EXT_WORDCLOCK_256FS_TYPE;
  863. break;
  864. default:
  865. /* undefined combination of external clock setup */
  866. snd_BUG();
  867. result = 0;
  868. }
  869. }
  870. return result;
  871. }
  872. /* Called when ak4113 detects change in the input SPDIF stream */
  873. static void qtet_ak4113_change(struct ak4113 *ak4113, unsigned char c0,
  874. unsigned char c1)
  875. {
  876. struct snd_ice1712 *ice = ak4113->change_callback_private;
  877. int rate;
  878. if ((qtet_get_spdif_master_type(ice) == EXT_SPDIF_TYPE) &&
  879. c1) {
  880. /* only for SPDIF master mode, rate was changed */
  881. rate = snd_ak4113_external_rate(ak4113);
  882. /* printk(KERN_DEBUG "ak4113 - input rate changed to %d\n",
  883. rate); */
  884. qtet_akm_set_rate_val(ice->akm, rate);
  885. }
  886. }
  887. /*
  888. * If clock slaved to SPDIF-IN, setting runtime rate
  889. * to the detected external rate
  890. */
  891. static void qtet_spdif_in_open(struct snd_ice1712 *ice,
  892. struct snd_pcm_substream *substream)
  893. {
  894. struct qtet_spec *spec = ice->spec;
  895. struct snd_pcm_runtime *runtime = substream->runtime;
  896. int rate;
  897. if (qtet_get_spdif_master_type(ice) != EXT_SPDIF_TYPE)
  898. /* not external SPDIF, no rate limitation */
  899. return;
  900. /* only external SPDIF can detect incoming sample rate */
  901. rate = snd_ak4113_external_rate(spec->ak4113);
  902. if (rate >= runtime->hw.rate_min && rate <= runtime->hw.rate_max) {
  903. runtime->hw.rate_min = rate;
  904. runtime->hw.rate_max = rate;
  905. }
  906. }
  907. /*
  908. * initialize the chip
  909. */
  910. static int __devinit qtet_init(struct snd_ice1712 *ice)
  911. {
  912. static const unsigned char ak4113_init_vals[] = {
  913. /* AK4113_REG_PWRDN */ AK4113_RST | AK4113_PWN |
  914. AK4113_OCKS0 | AK4113_OCKS1,
  915. /* AK4113_REQ_FORMAT */ AK4113_DIF_I24I2S | AK4113_VTX |
  916. AK4113_DEM_OFF | AK4113_DEAU,
  917. /* AK4113_REG_IO0 */ AK4113_OPS2 | AK4113_TXE |
  918. AK4113_XTL_24_576M,
  919. /* AK4113_REG_IO1 */ AK4113_EFH_1024LRCLK | AK4113_IPS(0),
  920. /* AK4113_REG_INT0_MASK */ 0,
  921. /* AK4113_REG_INT1_MASK */ 0,
  922. /* AK4113_REG_DATDTS */ 0,
  923. };
  924. int err;
  925. struct qtet_spec *spec;
  926. struct snd_akm4xxx *ak;
  927. unsigned char val;
  928. /* switching ice1724 to external clock - supplied by ext. circuits */
  929. val = inb(ICEMT1724(ice, RATE));
  930. outb(val | VT1724_SPDIF_MASTER, ICEMT1724(ice, RATE));
  931. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  932. if (!spec)
  933. return -ENOMEM;
  934. /* qtet is clocked by Xilinx array */
  935. ice->hw_rates = &qtet_rates_info;
  936. ice->is_spdif_master = qtet_is_spdif_master;
  937. ice->get_rate = qtet_get_rate;
  938. ice->set_rate = qtet_set_rate;
  939. ice->set_mclk = qtet_set_mclk;
  940. ice->set_spdif_clock = qtet_set_spdif_clock;
  941. ice->get_spdif_master_type = qtet_get_spdif_master_type;
  942. ice->ext_clock_names = ext_clock_names;
  943. ice->ext_clock_count = ARRAY_SIZE(ext_clock_names);
  944. /* since Qtet can detect correct SPDIF-in rate, all streams can be
  945. * limited to this specific rate */
  946. ice->spdif.ops.open = ice->pro_open = qtet_spdif_in_open;
  947. ice->spec = spec;
  948. /* Mute Off */
  949. /* SCR Initialize*/
  950. /* keep codec power down first */
  951. set_scr(ice, SCR_PHP);
  952. udelay(1);
  953. /* codec power up */
  954. set_scr(ice, SCR_PHP | SCR_CODEC_PDN);
  955. /* MCR Initialize */
  956. set_mcr(ice, 0);
  957. /* CPLD Initialize */
  958. set_cpld(ice, 0);
  959. ice->num_total_dacs = 2;
  960. ice->num_total_adcs = 2;
  961. ice->akm = kcalloc(2, sizeof(struct snd_akm4xxx), GFP_KERNEL);
  962. ak = ice->akm;
  963. if (!ak)
  964. return -ENOMEM;
  965. /* only one codec with two chips */
  966. ice->akm_codecs = 1;
  967. err = snd_ice1712_akm4xxx_init(ak, &akm_qtet_dac, NULL, ice);
  968. if (err < 0)
  969. return err;
  970. err = snd_ak4113_create(ice->card,
  971. qtet_ak4113_read,
  972. qtet_ak4113_write,
  973. ak4113_init_vals,
  974. ice, &spec->ak4113);
  975. if (err < 0)
  976. return err;
  977. /* callback for codecs rate setting */
  978. spec->ak4113->change_callback = qtet_ak4113_change;
  979. spec->ak4113->change_callback_private = ice;
  980. /* AK41143 in Quartet can detect external rate correctly
  981. * (i.e. check_flags = 0) */
  982. spec->ak4113->check_flags = 0;
  983. proc_init(ice);
  984. qtet_set_rate(ice, 44100);
  985. return 0;
  986. }
  987. static unsigned char qtet_eeprom[] __devinitdata = {
  988. [ICE_EEP2_SYSCONF] = 0x28, /* clock 256(24MHz), mpu401, 1xADC,
  989. 1xDACs, SPDIF in */
  990. [ICE_EEP2_ACLINK] = 0x80, /* I2S */
  991. [ICE_EEP2_I2S] = 0x78, /* 96k, 24bit, 192k */
  992. [ICE_EEP2_SPDIF] = 0xc3, /* out-en, out-int, in, out-ext */
  993. [ICE_EEP2_GPIO_DIR] = 0x00, /* 0-7 inputs, switched to output
  994. only during output operations */
  995. [ICE_EEP2_GPIO_DIR1] = 0xff, /* 8-15 outputs */
  996. [ICE_EEP2_GPIO_DIR2] = 0x00,
  997. [ICE_EEP2_GPIO_MASK] = 0xff, /* changed only for OUT operations */
  998. [ICE_EEP2_GPIO_MASK1] = 0x00,
  999. [ICE_EEP2_GPIO_MASK2] = 0xff,
  1000. [ICE_EEP2_GPIO_STATE] = 0x00, /* inputs */
  1001. [ICE_EEP2_GPIO_STATE1] = 0x7d, /* all 1, but GPIO_CPLD_RW
  1002. and GPIO15 always zero */
  1003. [ICE_EEP2_GPIO_STATE2] = 0x00, /* inputs */
  1004. };
  1005. /* entry point */
  1006. struct snd_ice1712_card_info snd_vt1724_qtet_cards[] __devinitdata = {
  1007. {
  1008. .subvendor = VT1724_SUBDEVICE_QTET,
  1009. .name = "Infrasonic Quartet",
  1010. .model = "quartet",
  1011. .chip_init = qtet_init,
  1012. .build_controls = qtet_add_controls,
  1013. .eeprom_size = sizeof(qtet_eeprom),
  1014. .eeprom_data = qtet_eeprom,
  1015. },
  1016. { } /* terminator */
  1017. };