quartet.c 29 KB

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