quartet.c 30 KB

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