aureon.c 62 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207
  1. /*
  2. * ALSA driver for ICEnsemble VT1724 (Envy24HT)
  3. *
  4. * Lowlevel functions for Terratec Aureon cards
  5. *
  6. * Copyright (c) 2003 Takashi Iwai <tiwai@suse.de>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  21. *
  22. *
  23. * NOTES:
  24. *
  25. * - we reuse the struct snd_akm4xxx record for storing the wm8770 codec data.
  26. * both wm and akm codecs are pretty similar, so we can integrate
  27. * both controls in the future, once if wm codecs are reused in
  28. * many boards.
  29. *
  30. * - DAC digital volumes are not implemented in the mixer.
  31. * if they show better response than DAC analog volumes, we can use them
  32. * instead.
  33. *
  34. * Lowlevel functions for AudioTrak Prodigy 7.1 (and possibly 192) cards
  35. * Copyright (c) 2003 Dimitromanolakis Apostolos <apostol@cs.utoronto.ca>
  36. *
  37. * version 0.82: Stable / not all features work yet (no communication with AC97 secondary)
  38. * added 64x/128x oversampling switch (should be 64x only for 96khz)
  39. * fixed some recording labels (still need to check the rest)
  40. * recording is working probably thanks to correct wm8770 initialization
  41. *
  42. * version 0.5: Initial release:
  43. * working: analog output, mixer, headphone amplifier switch
  44. * not working: prety much everything else, at least i could verify that
  45. * we have no digital output, no capture, pretty bad clicks and poops
  46. * on mixer switch and other coll stuff.
  47. *
  48. */
  49. #include <sound/driver.h>
  50. #include <asm/io.h>
  51. #include <linux/delay.h>
  52. #include <linux/interrupt.h>
  53. #include <linux/init.h>
  54. #include <linux/slab.h>
  55. #include <linux/mutex.h>
  56. #include <sound/core.h>
  57. #include "ice1712.h"
  58. #include "envy24ht.h"
  59. #include "aureon.h"
  60. #include <sound/tlv.h>
  61. /* WM8770 registers */
  62. #define WM_DAC_ATTEN 0x00 /* DAC1-8 analog attenuation */
  63. #define WM_DAC_MASTER_ATTEN 0x08 /* DAC master analog attenuation */
  64. #define WM_DAC_DIG_ATTEN 0x09 /* DAC1-8 digital attenuation */
  65. #define WM_DAC_DIG_MASTER_ATTEN 0x11 /* DAC master digital attenuation */
  66. #define WM_PHASE_SWAP 0x12 /* DAC phase */
  67. #define WM_DAC_CTRL1 0x13 /* DAC control bits */
  68. #define WM_MUTE 0x14 /* mute controls */
  69. #define WM_DAC_CTRL2 0x15 /* de-emphasis and zefo-flag */
  70. #define WM_INT_CTRL 0x16 /* interface control */
  71. #define WM_MASTER 0x17 /* master clock and mode */
  72. #define WM_POWERDOWN 0x18 /* power-down controls */
  73. #define WM_ADC_GAIN 0x19 /* ADC gain L(19)/R(1a) */
  74. #define WM_ADC_MUX 0x1b /* input MUX */
  75. #define WM_OUT_MUX1 0x1c /* output MUX */
  76. #define WM_OUT_MUX2 0x1e /* output MUX */
  77. #define WM_RESET 0x1f /* software reset */
  78. /* CS8415A registers */
  79. #define CS8415_CTRL1 0x01
  80. #define CS8415_CTRL2 0x02
  81. #define CS8415_QSUB 0x14
  82. #define CS8415_RATIO 0x1E
  83. #define CS8415_C_BUFFER 0x20
  84. #define CS8415_ID 0x7F
  85. /* PCA9554 registers */
  86. #define PCA9554_DEV 0x40 /* I2C device address */
  87. #define PCA9554_IN 0x00 /* input port */
  88. #define PCA9554_OUT 0x01 /* output port */
  89. #define PCA9554_INVERT 0x02 /* input invert */
  90. #define PCA9554_DIR 0x03 /* port directions */
  91. /*
  92. * Aureon Universe additional controls using PCA9554
  93. */
  94. /*
  95. * Send data to pca9554
  96. */
  97. static void aureon_pca9554_write(struct snd_ice1712 *ice, unsigned char reg,
  98. unsigned char data)
  99. {
  100. unsigned int tmp;
  101. int i, j;
  102. unsigned char dev = PCA9554_DEV; /* ID 0100000, write */
  103. unsigned char val = 0;
  104. tmp = snd_ice1712_gpio_read(ice);
  105. snd_ice1712_gpio_set_mask(ice, ~(AUREON_SPI_MOSI|AUREON_SPI_CLK|
  106. AUREON_WM_RW|AUREON_WM_CS|
  107. AUREON_CS8415_CS));
  108. tmp |= AUREON_WM_RW;
  109. tmp |= AUREON_CS8415_CS | AUREON_WM_CS; /* disable SPI devices */
  110. tmp &= ~AUREON_SPI_MOSI;
  111. tmp &= ~AUREON_SPI_CLK;
  112. snd_ice1712_gpio_write(ice, tmp);
  113. udelay(50);
  114. /*
  115. * send i2c stop condition and start condition
  116. * to obtain sane state
  117. */
  118. tmp |= AUREON_SPI_CLK;
  119. snd_ice1712_gpio_write(ice, tmp);
  120. udelay(50);
  121. tmp |= AUREON_SPI_MOSI;
  122. snd_ice1712_gpio_write(ice, tmp);
  123. udelay(100);
  124. tmp &= ~AUREON_SPI_MOSI;
  125. snd_ice1712_gpio_write(ice, tmp);
  126. udelay(50);
  127. tmp &= ~AUREON_SPI_CLK;
  128. snd_ice1712_gpio_write(ice, tmp);
  129. udelay(100);
  130. /*
  131. * send device address, command and value,
  132. * skipping ack cycles inbetween
  133. */
  134. for (j = 0; j < 3; j++) {
  135. switch(j) {
  136. case 0: val = dev; break;
  137. case 1: val = reg; break;
  138. case 2: val = data; break;
  139. }
  140. for (i = 7; i >= 0; i--) {
  141. tmp &= ~AUREON_SPI_CLK;
  142. snd_ice1712_gpio_write(ice, tmp);
  143. udelay(40);
  144. if (val & (1 << i))
  145. tmp |= AUREON_SPI_MOSI;
  146. else
  147. tmp &= ~AUREON_SPI_MOSI;
  148. snd_ice1712_gpio_write(ice, tmp);
  149. udelay(40);
  150. tmp |= AUREON_SPI_CLK;
  151. snd_ice1712_gpio_write(ice, tmp);
  152. udelay(40);
  153. }
  154. tmp &= ~AUREON_SPI_CLK;
  155. snd_ice1712_gpio_write(ice, tmp);
  156. udelay(40);
  157. tmp |= AUREON_SPI_CLK;
  158. snd_ice1712_gpio_write(ice, tmp);
  159. udelay(40);
  160. tmp &= ~AUREON_SPI_CLK;
  161. snd_ice1712_gpio_write(ice, tmp);
  162. udelay(40);
  163. }
  164. tmp &= ~AUREON_SPI_CLK;
  165. snd_ice1712_gpio_write(ice, tmp);
  166. udelay(40);
  167. tmp &= ~AUREON_SPI_MOSI;
  168. snd_ice1712_gpio_write(ice, tmp);
  169. udelay(40);
  170. tmp |= AUREON_SPI_CLK;
  171. snd_ice1712_gpio_write(ice, tmp);
  172. udelay(50);
  173. tmp |= AUREON_SPI_MOSI;
  174. snd_ice1712_gpio_write(ice, tmp);
  175. udelay(100);
  176. }
  177. static int aureon_universe_inmux_info(struct snd_kcontrol *kcontrol,
  178. struct snd_ctl_elem_info *uinfo)
  179. {
  180. char *texts[3] = {"Internal Aux", "Wavetable", "Rear Line-In"};
  181. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  182. uinfo->count = 1;
  183. uinfo->value.enumerated.items = 3;
  184. if(uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
  185. uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1;
  186. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  187. return 0;
  188. }
  189. static int aureon_universe_inmux_get(struct snd_kcontrol *kcontrol,
  190. struct snd_ctl_elem_value *ucontrol)
  191. {
  192. struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
  193. ucontrol->value.enumerated.item[0] = ice->spec.aureon.pca9554_out;
  194. return 0;
  195. }
  196. static int aureon_universe_inmux_put(struct snd_kcontrol *kcontrol,
  197. struct snd_ctl_elem_value *ucontrol)
  198. {
  199. struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
  200. unsigned char oval, nval;
  201. int change;
  202. nval = ucontrol->value.enumerated.item[0];
  203. if (nval >= 3)
  204. return -EINVAL;
  205. snd_ice1712_save_gpio_status(ice);
  206. oval = ice->spec.aureon.pca9554_out;
  207. if ((change = (oval != nval))) {
  208. aureon_pca9554_write(ice, PCA9554_OUT, nval);
  209. ice->spec.aureon.pca9554_out = nval;
  210. }
  211. snd_ice1712_restore_gpio_status(ice);
  212. return change;
  213. }
  214. static void aureon_ac97_write(struct snd_ice1712 *ice, unsigned short reg,
  215. unsigned short val)
  216. {
  217. unsigned int tmp;
  218. /* Send address to XILINX chip */
  219. tmp = (snd_ice1712_gpio_read(ice) & ~0xFF) | (reg & 0x7F);
  220. snd_ice1712_gpio_write(ice, tmp);
  221. udelay(10);
  222. tmp |= AUREON_AC97_ADDR;
  223. snd_ice1712_gpio_write(ice, tmp);
  224. udelay(10);
  225. tmp &= ~AUREON_AC97_ADDR;
  226. snd_ice1712_gpio_write(ice, tmp);
  227. udelay(10);
  228. /* Send low-order byte to XILINX chip */
  229. tmp &= ~AUREON_AC97_DATA_MASK;
  230. tmp |= val & AUREON_AC97_DATA_MASK;
  231. snd_ice1712_gpio_write(ice, tmp);
  232. udelay(10);
  233. tmp |= AUREON_AC97_DATA_LOW;
  234. snd_ice1712_gpio_write(ice, tmp);
  235. udelay(10);
  236. tmp &= ~AUREON_AC97_DATA_LOW;
  237. snd_ice1712_gpio_write(ice, tmp);
  238. udelay(10);
  239. /* Send high-order byte to XILINX chip */
  240. tmp &= ~AUREON_AC97_DATA_MASK;
  241. tmp |= (val >> 8) & AUREON_AC97_DATA_MASK;
  242. snd_ice1712_gpio_write(ice, tmp);
  243. udelay(10);
  244. tmp |= AUREON_AC97_DATA_HIGH;
  245. snd_ice1712_gpio_write(ice, tmp);
  246. udelay(10);
  247. tmp &= ~AUREON_AC97_DATA_HIGH;
  248. snd_ice1712_gpio_write(ice, tmp);
  249. udelay(10);
  250. /* Instruct XILINX chip to parse the data to the STAC9744 chip */
  251. tmp |= AUREON_AC97_COMMIT;
  252. snd_ice1712_gpio_write(ice, tmp);
  253. udelay(10);
  254. tmp &= ~AUREON_AC97_COMMIT;
  255. snd_ice1712_gpio_write(ice, tmp);
  256. udelay(10);
  257. /* Store the data in out private buffer */
  258. ice->spec.aureon.stac9744[(reg & 0x7F) >> 1] = val;
  259. }
  260. static unsigned short aureon_ac97_read(struct snd_ice1712 *ice, unsigned short reg)
  261. {
  262. return ice->spec.aureon.stac9744[(reg & 0x7F) >> 1];
  263. }
  264. /*
  265. * Initialize STAC9744 chip
  266. */
  267. static int aureon_ac97_init (struct snd_ice1712 *ice)
  268. {
  269. int i;
  270. static const unsigned short ac97_defaults[] = {
  271. 0x00, 0x9640,
  272. 0x02, 0x8000,
  273. 0x04, 0x8000,
  274. 0x06, 0x8000,
  275. 0x0C, 0x8008,
  276. 0x0E, 0x8008,
  277. 0x10, 0x8808,
  278. 0x12, 0x8808,
  279. 0x14, 0x8808,
  280. 0x16, 0x8808,
  281. 0x18, 0x8808,
  282. 0x1C, 0x8000,
  283. 0x26, 0x000F,
  284. 0x28, 0x0201,
  285. 0x2C, 0xBB80,
  286. 0x32, 0xBB80,
  287. 0x7C, 0x8384,
  288. 0x7E, 0x7644,
  289. (unsigned short)-1
  290. };
  291. unsigned int tmp;
  292. /* Cold reset */
  293. tmp = (snd_ice1712_gpio_read(ice) | AUREON_AC97_RESET) & ~AUREON_AC97_DATA_MASK;
  294. snd_ice1712_gpio_write(ice, tmp);
  295. udelay(3);
  296. tmp &= ~AUREON_AC97_RESET;
  297. snd_ice1712_gpio_write(ice, tmp);
  298. udelay(3);
  299. tmp |= AUREON_AC97_RESET;
  300. snd_ice1712_gpio_write(ice, tmp);
  301. udelay(3);
  302. memset(&ice->spec.aureon.stac9744, 0, sizeof(ice->spec.aureon.stac9744));
  303. for (i=0; ac97_defaults[i] != (unsigned short)-1; i+=2)
  304. ice->spec.aureon.stac9744[(ac97_defaults[i]) >> 1] = ac97_defaults[i+1];
  305. aureon_ac97_write(ice, AC97_MASTER, 0x0000); // Unmute AC'97 master volume permanently - muting is done by WM8770
  306. return 0;
  307. }
  308. #define AUREON_AC97_STEREO 0x80
  309. /*
  310. * AC'97 volume controls
  311. */
  312. static int aureon_ac97_vol_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
  313. {
  314. uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
  315. uinfo->count = kcontrol->private_value & AUREON_AC97_STEREO ? 2 : 1;
  316. uinfo->value.integer.min = 0;
  317. uinfo->value.integer.max = 31;
  318. return 0;
  319. }
  320. static int aureon_ac97_vol_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  321. {
  322. struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
  323. unsigned short vol;
  324. mutex_lock(&ice->gpio_mutex);
  325. vol = aureon_ac97_read(ice, kcontrol->private_value & 0x7F);
  326. ucontrol->value.integer.value[0] = 0x1F - (vol & 0x1F);
  327. if (kcontrol->private_value & AUREON_AC97_STEREO)
  328. ucontrol->value.integer.value[1] = 0x1F - ((vol >> 8) & 0x1F);
  329. mutex_unlock(&ice->gpio_mutex);
  330. return 0;
  331. }
  332. static int aureon_ac97_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  333. {
  334. struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
  335. unsigned short ovol, nvol;
  336. int change;
  337. snd_ice1712_save_gpio_status(ice);
  338. ovol = aureon_ac97_read(ice, kcontrol->private_value & 0x7F);
  339. nvol = (0x1F - ucontrol->value.integer.value[0]) & 0x001F;
  340. if (kcontrol->private_value & AUREON_AC97_STEREO)
  341. nvol |= ((0x1F - ucontrol->value.integer.value[1]) << 8) & 0x1F00;
  342. nvol |= ovol & ~0x1F1F;
  343. if ((change = (ovol != nvol)))
  344. aureon_ac97_write(ice, kcontrol->private_value & 0x7F, nvol);
  345. snd_ice1712_restore_gpio_status(ice);
  346. return change;
  347. }
  348. /*
  349. * AC'97 mute controls
  350. */
  351. #define aureon_ac97_mute_info snd_ctl_boolean_mono_info
  352. static int aureon_ac97_mute_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  353. {
  354. struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
  355. mutex_lock(&ice->gpio_mutex);
  356. ucontrol->value.integer.value[0] = aureon_ac97_read(ice, kcontrol->private_value & 0x7F) & 0x8000 ? 0 : 1;
  357. mutex_unlock(&ice->gpio_mutex);
  358. return 0;
  359. }
  360. static int aureon_ac97_mute_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  361. {
  362. struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
  363. unsigned short ovol, nvol;
  364. int change;
  365. snd_ice1712_save_gpio_status(ice);
  366. ovol = aureon_ac97_read(ice, kcontrol->private_value & 0x7F);
  367. nvol = (ucontrol->value.integer.value[0] ? 0x0000 : 0x8000) | (ovol & ~ 0x8000);
  368. if ((change = (ovol != nvol)))
  369. aureon_ac97_write(ice, kcontrol->private_value & 0x7F, nvol);
  370. snd_ice1712_restore_gpio_status(ice);
  371. return change;
  372. }
  373. /*
  374. * AC'97 mute controls
  375. */
  376. #define aureon_ac97_micboost_info snd_ctl_boolean_mono_info
  377. static int aureon_ac97_micboost_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  378. {
  379. struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
  380. mutex_lock(&ice->gpio_mutex);
  381. ucontrol->value.integer.value[0] = aureon_ac97_read(ice, AC97_MIC) & 0x0020 ? 0 : 1;
  382. mutex_unlock(&ice->gpio_mutex);
  383. return 0;
  384. }
  385. static int aureon_ac97_micboost_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  386. {
  387. struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
  388. unsigned short ovol, nvol;
  389. int change;
  390. snd_ice1712_save_gpio_status(ice);
  391. ovol = aureon_ac97_read(ice, AC97_MIC);
  392. nvol = (ucontrol->value.integer.value[0] ? 0x0000 : 0x0020) | (ovol & ~0x0020);
  393. if ((change = (ovol != nvol)))
  394. aureon_ac97_write(ice, AC97_MIC, nvol);
  395. snd_ice1712_restore_gpio_status(ice);
  396. return change;
  397. }
  398. /*
  399. * write data in the SPI mode
  400. */
  401. static void aureon_spi_write(struct snd_ice1712 *ice, unsigned int cs, unsigned int data, int bits)
  402. {
  403. unsigned int tmp;
  404. int i;
  405. unsigned int mosi, clk;
  406. tmp = snd_ice1712_gpio_read(ice);
  407. if (ice->eeprom.subvendor == VT1724_SUBDEVICE_PRODIGY71LT ||
  408. ice->eeprom.subvendor == VT1724_SUBDEVICE_PRODIGY71XT) {
  409. snd_ice1712_gpio_set_mask(ice, ~(PRODIGY_SPI_MOSI|PRODIGY_SPI_CLK|PRODIGY_WM_CS));
  410. mosi = PRODIGY_SPI_MOSI;
  411. clk = PRODIGY_SPI_CLK;
  412. }
  413. else {
  414. snd_ice1712_gpio_set_mask(ice, ~(AUREON_WM_RW|AUREON_SPI_MOSI|AUREON_SPI_CLK|
  415. AUREON_WM_CS|AUREON_CS8415_CS));
  416. mosi = AUREON_SPI_MOSI;
  417. clk = AUREON_SPI_CLK;
  418. tmp |= AUREON_WM_RW;
  419. }
  420. tmp &= ~cs;
  421. snd_ice1712_gpio_write(ice, tmp);
  422. udelay(1);
  423. for (i = bits - 1; i >= 0; i--) {
  424. tmp &= ~clk;
  425. snd_ice1712_gpio_write(ice, tmp);
  426. udelay(1);
  427. if (data & (1 << i))
  428. tmp |= mosi;
  429. else
  430. tmp &= ~mosi;
  431. snd_ice1712_gpio_write(ice, tmp);
  432. udelay(1);
  433. tmp |= clk;
  434. snd_ice1712_gpio_write(ice, tmp);
  435. udelay(1);
  436. }
  437. tmp &= ~clk;
  438. tmp |= cs;
  439. snd_ice1712_gpio_write(ice, tmp);
  440. udelay(1);
  441. tmp |= clk;
  442. snd_ice1712_gpio_write(ice, tmp);
  443. udelay(1);
  444. }
  445. /*
  446. * Read data in SPI mode
  447. */
  448. static void aureon_spi_read(struct snd_ice1712 *ice, unsigned int cs, unsigned int data, int bits, unsigned char *buffer, int size) {
  449. int i, j;
  450. unsigned int tmp;
  451. tmp = (snd_ice1712_gpio_read(ice) & ~AUREON_SPI_CLK) | AUREON_CS8415_CS|AUREON_WM_CS;
  452. snd_ice1712_gpio_write(ice, tmp);
  453. tmp &= ~cs;
  454. snd_ice1712_gpio_write(ice, tmp);
  455. udelay(1);
  456. for (i=bits-1; i>=0; i--) {
  457. if (data & (1 << i))
  458. tmp |= AUREON_SPI_MOSI;
  459. else
  460. tmp &= ~AUREON_SPI_MOSI;
  461. snd_ice1712_gpio_write(ice, tmp);
  462. udelay(1);
  463. tmp |= AUREON_SPI_CLK;
  464. snd_ice1712_gpio_write(ice, tmp);
  465. udelay(1);
  466. tmp &= ~AUREON_SPI_CLK;
  467. snd_ice1712_gpio_write(ice, tmp);
  468. udelay(1);
  469. }
  470. for (j=0; j<size; j++) {
  471. unsigned char outdata = 0;
  472. for (i=7; i>=0; i--) {
  473. tmp = snd_ice1712_gpio_read(ice);
  474. outdata <<= 1;
  475. outdata |= (tmp & AUREON_SPI_MISO) ? 1 : 0;
  476. udelay(1);
  477. tmp |= AUREON_SPI_CLK;
  478. snd_ice1712_gpio_write(ice, tmp);
  479. udelay(1);
  480. tmp &= ~AUREON_SPI_CLK;
  481. snd_ice1712_gpio_write(ice, tmp);
  482. udelay(1);
  483. }
  484. buffer[j] = outdata;
  485. }
  486. tmp |= cs;
  487. snd_ice1712_gpio_write(ice, tmp);
  488. }
  489. static unsigned char aureon_cs8415_get(struct snd_ice1712 *ice, int reg) {
  490. unsigned char val;
  491. aureon_spi_write(ice, AUREON_CS8415_CS, 0x2000 | reg, 16);
  492. aureon_spi_read(ice, AUREON_CS8415_CS, 0x21, 8, &val, 1);
  493. return val;
  494. }
  495. static void aureon_cs8415_read(struct snd_ice1712 *ice, int reg, unsigned char *buffer, int size) {
  496. aureon_spi_write(ice, AUREON_CS8415_CS, 0x2000 | reg, 16);
  497. aureon_spi_read(ice, AUREON_CS8415_CS, 0x21, 8, buffer, size);
  498. }
  499. static void aureon_cs8415_put(struct snd_ice1712 *ice, int reg, unsigned char val) {
  500. aureon_spi_write(ice, AUREON_CS8415_CS, 0x200000 | (reg << 8) | val, 24);
  501. }
  502. /*
  503. * get the current register value of WM codec
  504. */
  505. static unsigned short wm_get(struct snd_ice1712 *ice, int reg)
  506. {
  507. reg <<= 1;
  508. return ((unsigned short)ice->akm[0].images[reg] << 8) |
  509. ice->akm[0].images[reg + 1];
  510. }
  511. /*
  512. * set the register value of WM codec
  513. */
  514. static void wm_put_nocache(struct snd_ice1712 *ice, int reg, unsigned short val)
  515. {
  516. aureon_spi_write(ice,
  517. ((ice->eeprom.subvendor == VT1724_SUBDEVICE_PRODIGY71LT ||
  518. ice->eeprom.subvendor == VT1724_SUBDEVICE_PRODIGY71XT) ?
  519. PRODIGY_WM_CS : AUREON_WM_CS),
  520. (reg << 9) | (val & 0x1ff), 16);
  521. }
  522. /*
  523. * set the register value of WM codec and remember it
  524. */
  525. static void wm_put(struct snd_ice1712 *ice, int reg, unsigned short val)
  526. {
  527. wm_put_nocache(ice, reg, val);
  528. reg <<= 1;
  529. ice->akm[0].images[reg] = val >> 8;
  530. ice->akm[0].images[reg + 1] = val;
  531. }
  532. /*
  533. */
  534. #define aureon_mono_bool_info snd_ctl_boolean_mono_info
  535. /*
  536. * AC'97 master playback mute controls (Mute on WM8770 chip)
  537. */
  538. #define aureon_ac97_mmute_info snd_ctl_boolean_mono_info
  539. static int aureon_ac97_mmute_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  540. {
  541. struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
  542. mutex_lock(&ice->gpio_mutex);
  543. ucontrol->value.integer.value[0] = (wm_get(ice, WM_OUT_MUX1) >> 1) & 0x01;
  544. mutex_unlock(&ice->gpio_mutex);
  545. return 0;
  546. }
  547. static int aureon_ac97_mmute_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) {
  548. struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
  549. unsigned short ovol, nvol;
  550. int change;
  551. snd_ice1712_save_gpio_status(ice);
  552. ovol = wm_get(ice, WM_OUT_MUX1);
  553. nvol = (ovol & ~0x02) | (ucontrol->value.integer.value[0] ? 0x02 : 0x00);
  554. if ((change = (ovol != nvol)))
  555. wm_put(ice, WM_OUT_MUX1, nvol);
  556. snd_ice1712_restore_gpio_status(ice);
  557. return change;
  558. }
  559. static const DECLARE_TLV_DB_SCALE(db_scale_wm_dac, -12700, 100, 1);
  560. static const DECLARE_TLV_DB_SCALE(db_scale_wm_pcm, -6400, 50, 1);
  561. static const DECLARE_TLV_DB_SCALE(db_scale_wm_adc, -1200, 100, 0);
  562. static const DECLARE_TLV_DB_SCALE(db_scale_ac97_master, -4650, 150, 0);
  563. static const DECLARE_TLV_DB_SCALE(db_scale_ac97_gain, -3450, 150, 0);
  564. /*
  565. * Logarithmic volume values for WM8770
  566. * Computed as 20 * Log10(255 / x)
  567. */
  568. static const unsigned char wm_vol[256] = {
  569. 127, 48, 42, 39, 36, 34, 33, 31, 30, 29, 28, 27, 27, 26, 25, 25, 24, 24, 23,
  570. 23, 22, 22, 21, 21, 21, 20, 20, 20, 19, 19, 19, 18, 18, 18, 18, 17, 17, 17,
  571. 17, 16, 16, 16, 16, 15, 15, 15, 15, 15, 15, 14, 14, 14, 14, 14, 13, 13, 13,
  572. 13, 13, 13, 13, 12, 12, 12, 12, 12, 12, 12, 11, 11, 11, 11, 11, 11, 11, 11,
  573. 11, 10, 10, 10, 10, 10, 10, 10, 10, 10, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 8, 8,
  574. 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 6, 6, 6,
  575. 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
  576. 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3,
  577. 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
  578. 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  579. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  580. 0, 0
  581. };
  582. #define WM_VOL_MAX (sizeof(wm_vol) - 1)
  583. #define WM_VOL_MUTE 0x8000
  584. static void wm_set_vol(struct snd_ice1712 *ice, unsigned int index, unsigned short vol, unsigned short master)
  585. {
  586. unsigned char nvol;
  587. if ((master & WM_VOL_MUTE) || (vol & WM_VOL_MUTE))
  588. nvol = 0;
  589. else
  590. nvol = 127 - wm_vol[(((vol & ~WM_VOL_MUTE) * (master & ~WM_VOL_MUTE)) / 127) & WM_VOL_MAX];
  591. wm_put(ice, index, nvol);
  592. wm_put_nocache(ice, index, 0x180 | nvol);
  593. }
  594. /*
  595. * DAC mute control
  596. */
  597. #define wm_pcm_mute_info snd_ctl_boolean_mono_info
  598. static int wm_pcm_mute_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  599. {
  600. struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
  601. mutex_lock(&ice->gpio_mutex);
  602. ucontrol->value.integer.value[0] = (wm_get(ice, WM_MUTE) & 0x10) ? 0 : 1;
  603. mutex_unlock(&ice->gpio_mutex);
  604. return 0;
  605. }
  606. static int wm_pcm_mute_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  607. {
  608. struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
  609. unsigned short nval, oval;
  610. int change;
  611. snd_ice1712_save_gpio_status(ice);
  612. oval = wm_get(ice, WM_MUTE);
  613. nval = (oval & ~0x10) | (ucontrol->value.integer.value[0] ? 0 : 0x10);
  614. if ((change = (nval != oval)))
  615. wm_put(ice, WM_MUTE, nval);
  616. snd_ice1712_restore_gpio_status(ice);
  617. return change;
  618. }
  619. /*
  620. * Master volume attenuation mixer control
  621. */
  622. static int wm_master_vol_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
  623. {
  624. uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
  625. uinfo->count = 2;
  626. uinfo->value.integer.min = 0;
  627. uinfo->value.integer.max = WM_VOL_MAX;
  628. return 0;
  629. }
  630. static int wm_master_vol_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  631. {
  632. struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
  633. int i;
  634. for (i=0; i<2; i++)
  635. ucontrol->value.integer.value[i] = ice->spec.aureon.master[i] & ~WM_VOL_MUTE;
  636. return 0;
  637. }
  638. static int wm_master_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  639. {
  640. struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
  641. int ch, change = 0;
  642. snd_ice1712_save_gpio_status(ice);
  643. for (ch = 0; ch < 2; ch++) {
  644. unsigned int vol = ucontrol->value.integer.value[ch];
  645. if (vol > WM_VOL_MAX)
  646. continue;
  647. vol |= ice->spec.aureon.master[ch] & WM_VOL_MUTE;
  648. if (vol != ice->spec.aureon.master[ch]) {
  649. int dac;
  650. ice->spec.aureon.master[ch] = vol;
  651. for (dac = 0; dac < ice->num_total_dacs; dac += 2)
  652. wm_set_vol(ice, WM_DAC_ATTEN + dac + ch,
  653. ice->spec.aureon.vol[dac + ch],
  654. ice->spec.aureon.master[ch]);
  655. change = 1;
  656. }
  657. }
  658. snd_ice1712_restore_gpio_status(ice);
  659. return change;
  660. }
  661. /*
  662. * DAC volume attenuation mixer control
  663. */
  664. static int wm_vol_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
  665. {
  666. int voices = kcontrol->private_value >> 8;
  667. uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
  668. uinfo->count = voices;
  669. uinfo->value.integer.min = 0; /* mute (-101dB) */
  670. uinfo->value.integer.max = 0x7F; /* 0dB */
  671. return 0;
  672. }
  673. static int wm_vol_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  674. {
  675. struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
  676. int i, ofs, voices;
  677. voices = kcontrol->private_value >> 8;
  678. ofs = kcontrol->private_value & 0xff;
  679. for (i = 0; i < voices; i++)
  680. ucontrol->value.integer.value[i] = ice->spec.aureon.vol[ofs+i] & ~WM_VOL_MUTE;
  681. return 0;
  682. }
  683. static int wm_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  684. {
  685. struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
  686. int i, idx, ofs, voices;
  687. int change = 0;
  688. voices = kcontrol->private_value >> 8;
  689. ofs = kcontrol->private_value & 0xff;
  690. snd_ice1712_save_gpio_status(ice);
  691. for (i = 0; i < voices; i++) {
  692. unsigned int vol = ucontrol->value.integer.value[i];
  693. if (vol > 0x7f)
  694. continue;
  695. vol |= ice->spec.aureon.vol[ofs+i];
  696. if (vol != ice->spec.aureon.vol[ofs+i]) {
  697. ice->spec.aureon.vol[ofs+i] = vol;
  698. idx = WM_DAC_ATTEN + ofs + i;
  699. wm_set_vol(ice, idx, ice->spec.aureon.vol[ofs+i],
  700. ice->spec.aureon.master[i]);
  701. change = 1;
  702. }
  703. }
  704. snd_ice1712_restore_gpio_status(ice);
  705. return change;
  706. }
  707. /*
  708. * WM8770 mute control
  709. */
  710. static int wm_mute_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) {
  711. uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
  712. uinfo->count = kcontrol->private_value >> 8;
  713. uinfo->value.integer.min = 0;
  714. uinfo->value.integer.max = 1;
  715. return 0;
  716. }
  717. static int wm_mute_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  718. {
  719. struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
  720. int voices, ofs, i;
  721. voices = kcontrol->private_value >> 8;
  722. ofs = kcontrol->private_value & 0xFF;
  723. for (i = 0; i < voices; i++)
  724. ucontrol->value.integer.value[i] = (ice->spec.aureon.vol[ofs+i] & WM_VOL_MUTE) ? 0 : 1;
  725. return 0;
  726. }
  727. static int wm_mute_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  728. {
  729. struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
  730. int change = 0, voices, ofs, i;
  731. voices = kcontrol->private_value >> 8;
  732. ofs = kcontrol->private_value & 0xFF;
  733. snd_ice1712_save_gpio_status(ice);
  734. for (i = 0; i < voices; i++) {
  735. int val = (ice->spec.aureon.vol[ofs + i] & WM_VOL_MUTE) ? 0 : 1;
  736. if (ucontrol->value.integer.value[i] != val) {
  737. ice->spec.aureon.vol[ofs + i] &= ~WM_VOL_MUTE;
  738. ice->spec.aureon.vol[ofs + i] |=
  739. ucontrol->value.integer.value[i] ? 0 : WM_VOL_MUTE;
  740. wm_set_vol(ice, ofs + i, ice->spec.aureon.vol[ofs + i],
  741. ice->spec.aureon.master[i]);
  742. change = 1;
  743. }
  744. }
  745. snd_ice1712_restore_gpio_status(ice);
  746. return change;
  747. }
  748. /*
  749. * WM8770 master mute control
  750. */
  751. #define wm_master_mute_info snd_ctl_boolean_stereo_info
  752. static int wm_master_mute_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  753. {
  754. struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
  755. ucontrol->value.integer.value[0] = (ice->spec.aureon.master[0] & WM_VOL_MUTE) ? 0 : 1;
  756. ucontrol->value.integer.value[1] = (ice->spec.aureon.master[1] & WM_VOL_MUTE) ? 0 : 1;
  757. return 0;
  758. }
  759. static int wm_master_mute_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  760. {
  761. struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
  762. int change = 0, i;
  763. snd_ice1712_save_gpio_status(ice);
  764. for (i = 0; i < 2; i++) {
  765. int val = (ice->spec.aureon.master[i] & WM_VOL_MUTE) ? 0 : 1;
  766. if (ucontrol->value.integer.value[i] != val) {
  767. int dac;
  768. ice->spec.aureon.master[i] &= ~WM_VOL_MUTE;
  769. ice->spec.aureon.master[i] |=
  770. ucontrol->value.integer.value[i] ? 0 : WM_VOL_MUTE;
  771. for (dac = 0; dac < ice->num_total_dacs; dac += 2)
  772. wm_set_vol(ice, WM_DAC_ATTEN + dac + i,
  773. ice->spec.aureon.vol[dac + i],
  774. ice->spec.aureon.master[i]);
  775. change = 1;
  776. }
  777. }
  778. snd_ice1712_restore_gpio_status(ice);
  779. return change;
  780. }
  781. /* digital master volume */
  782. #define PCM_0dB 0xff
  783. #define PCM_RES 128 /* -64dB */
  784. #define PCM_MIN (PCM_0dB - PCM_RES)
  785. static int wm_pcm_vol_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
  786. {
  787. uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
  788. uinfo->count = 1;
  789. uinfo->value.integer.min = 0; /* mute (-64dB) */
  790. uinfo->value.integer.max = PCM_RES; /* 0dB */
  791. return 0;
  792. }
  793. static int wm_pcm_vol_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  794. {
  795. struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
  796. unsigned short val;
  797. mutex_lock(&ice->gpio_mutex);
  798. val = wm_get(ice, WM_DAC_DIG_MASTER_ATTEN) & 0xff;
  799. val = val > PCM_MIN ? (val - PCM_MIN) : 0;
  800. ucontrol->value.integer.value[0] = val;
  801. mutex_unlock(&ice->gpio_mutex);
  802. return 0;
  803. }
  804. static int wm_pcm_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  805. {
  806. struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
  807. unsigned short ovol, nvol;
  808. int change = 0;
  809. nvol = ucontrol->value.integer.value[0];
  810. if (nvol > PCM_RES)
  811. return -EINVAL;
  812. snd_ice1712_save_gpio_status(ice);
  813. nvol = (nvol ? (nvol + PCM_MIN) : 0) & 0xff;
  814. ovol = wm_get(ice, WM_DAC_DIG_MASTER_ATTEN) & 0xff;
  815. if (ovol != nvol) {
  816. wm_put(ice, WM_DAC_DIG_MASTER_ATTEN, nvol); /* prelatch */
  817. wm_put_nocache(ice, WM_DAC_DIG_MASTER_ATTEN, nvol | 0x100); /* update */
  818. change = 1;
  819. }
  820. snd_ice1712_restore_gpio_status(ice);
  821. return change;
  822. }
  823. /*
  824. * ADC mute control
  825. */
  826. #define wm_adc_mute_info snd_ctl_boolean_stereo_info
  827. static int wm_adc_mute_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  828. {
  829. struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
  830. unsigned short val;
  831. int i;
  832. mutex_lock(&ice->gpio_mutex);
  833. for (i = 0; i < 2; i++) {
  834. val = wm_get(ice, WM_ADC_GAIN + i);
  835. ucontrol->value.integer.value[i] = ~val>>5 & 0x1;
  836. }
  837. mutex_unlock(&ice->gpio_mutex);
  838. return 0;
  839. }
  840. static int wm_adc_mute_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  841. {
  842. struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
  843. unsigned short new, old;
  844. int i, change = 0;
  845. snd_ice1712_save_gpio_status(ice);
  846. for (i = 0; i < 2; i++) {
  847. old = wm_get(ice, WM_ADC_GAIN + i);
  848. new = (~ucontrol->value.integer.value[i]<<5&0x20) | (old&~0x20);
  849. if (new != old) {
  850. wm_put(ice, WM_ADC_GAIN + i, new);
  851. change = 1;
  852. }
  853. }
  854. snd_ice1712_restore_gpio_status(ice);
  855. return change;
  856. }
  857. /*
  858. * ADC gain mixer control
  859. */
  860. static int wm_adc_vol_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
  861. {
  862. uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
  863. uinfo->count = 2;
  864. uinfo->value.integer.min = 0; /* -12dB */
  865. uinfo->value.integer.max = 0x1f; /* 19dB */
  866. return 0;
  867. }
  868. static int wm_adc_vol_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  869. {
  870. struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
  871. int i, idx;
  872. unsigned short vol;
  873. mutex_lock(&ice->gpio_mutex);
  874. for (i = 0; i < 2; i++) {
  875. idx = WM_ADC_GAIN + i;
  876. vol = wm_get(ice, idx) & 0x1f;
  877. ucontrol->value.integer.value[i] = vol;
  878. }
  879. mutex_unlock(&ice->gpio_mutex);
  880. return 0;
  881. }
  882. static int wm_adc_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  883. {
  884. struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
  885. int i, idx;
  886. unsigned short ovol, nvol;
  887. int change = 0;
  888. snd_ice1712_save_gpio_status(ice);
  889. for (i = 0; i < 2; i++) {
  890. idx = WM_ADC_GAIN + i;
  891. nvol = ucontrol->value.integer.value[i] & 0x1f;
  892. ovol = wm_get(ice, idx);
  893. if ((ovol & 0x1f) != nvol) {
  894. wm_put(ice, idx, nvol | (ovol & ~0x1f));
  895. change = 1;
  896. }
  897. }
  898. snd_ice1712_restore_gpio_status(ice);
  899. return change;
  900. }
  901. /*
  902. * ADC input mux mixer control
  903. */
  904. static int wm_adc_mux_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
  905. {
  906. static const char * const texts[] = {
  907. "CD", //AIN1
  908. "Aux", //AIN2
  909. "Line", //AIN3
  910. "Mic", //AIN4
  911. "AC97" //AIN5
  912. };
  913. static const char * const universe_texts[] = {
  914. "Aux1", //AIN1
  915. "CD", //AIN2
  916. "Phono", //AIN3
  917. "Line", //AIN4
  918. "Aux2", //AIN5
  919. "Mic", //AIN6
  920. "Aux3", //AIN7
  921. "AC97" //AIN8
  922. };
  923. struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
  924. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  925. uinfo->count = 2;
  926. if (ice->eeprom.subvendor == VT1724_SUBDEVICE_AUREON71_UNIVERSE) {
  927. uinfo->value.enumerated.items = 8;
  928. if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
  929. uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1;
  930. strcpy(uinfo->value.enumerated.name, universe_texts[uinfo->value.enumerated.item]);
  931. }
  932. else {
  933. uinfo->value.enumerated.items = 5;
  934. if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
  935. uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1;
  936. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  937. }
  938. return 0;
  939. }
  940. static int wm_adc_mux_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  941. {
  942. struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
  943. unsigned short val;
  944. mutex_lock(&ice->gpio_mutex);
  945. val = wm_get(ice, WM_ADC_MUX);
  946. ucontrol->value.enumerated.item[0] = val & 7;
  947. ucontrol->value.enumerated.item[1] = (val >> 4) & 7;
  948. mutex_unlock(&ice->gpio_mutex);
  949. return 0;
  950. }
  951. static int wm_adc_mux_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  952. {
  953. struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
  954. unsigned short oval, nval;
  955. int change;
  956. snd_ice1712_save_gpio_status(ice);
  957. oval = wm_get(ice, WM_ADC_MUX);
  958. nval = oval & ~0x77;
  959. nval |= ucontrol->value.enumerated.item[0] & 7;
  960. nval |= (ucontrol->value.enumerated.item[1] & 7) << 4;
  961. change = (oval != nval);
  962. if (change)
  963. wm_put(ice, WM_ADC_MUX, nval);
  964. snd_ice1712_restore_gpio_status(ice);
  965. return change;
  966. }
  967. /*
  968. * CS8415 Input mux
  969. */
  970. static int aureon_cs8415_mux_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
  971. {
  972. struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
  973. static const char * const aureon_texts[] = {
  974. "CD", //RXP0
  975. "Optical" //RXP1
  976. };
  977. static const char * const prodigy_texts[] = {
  978. "CD",
  979. "Coax"
  980. };
  981. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  982. uinfo->count = 1;
  983. uinfo->value.enumerated.items = 2;
  984. if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
  985. uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1;
  986. if (ice->eeprom.subvendor == VT1724_SUBDEVICE_PRODIGY71)
  987. strcpy(uinfo->value.enumerated.name, prodigy_texts[uinfo->value.enumerated.item]);
  988. else
  989. strcpy(uinfo->value.enumerated.name, aureon_texts[uinfo->value.enumerated.item]);
  990. return 0;
  991. }
  992. static int aureon_cs8415_mux_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  993. {
  994. struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
  995. //snd_ice1712_save_gpio_status(ice);
  996. //val = aureon_cs8415_get(ice, CS8415_CTRL2);
  997. ucontrol->value.enumerated.item[0] = ice->spec.aureon.cs8415_mux;
  998. //snd_ice1712_restore_gpio_status(ice);
  999. return 0;
  1000. }
  1001. static int aureon_cs8415_mux_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  1002. {
  1003. struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
  1004. unsigned short oval, nval;
  1005. int change;
  1006. snd_ice1712_save_gpio_status(ice);
  1007. oval = aureon_cs8415_get(ice, CS8415_CTRL2);
  1008. nval = oval & ~0x07;
  1009. nval |= ucontrol->value.enumerated.item[0] & 7;
  1010. change = (oval != nval);
  1011. if (change)
  1012. aureon_cs8415_put(ice, CS8415_CTRL2, nval);
  1013. snd_ice1712_restore_gpio_status(ice);
  1014. ice->spec.aureon.cs8415_mux = ucontrol->value.enumerated.item[0];
  1015. return change;
  1016. }
  1017. static int aureon_cs8415_rate_info (struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
  1018. {
  1019. uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
  1020. uinfo->count = 1;
  1021. uinfo->value.integer.min = 0;
  1022. uinfo->value.integer.max = 192000;
  1023. return 0;
  1024. }
  1025. static int aureon_cs8415_rate_get (struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  1026. {
  1027. struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
  1028. unsigned char ratio;
  1029. ratio = aureon_cs8415_get(ice, CS8415_RATIO);
  1030. ucontrol->value.integer.value[0] = (int)((unsigned int)ratio * 750);
  1031. return 0;
  1032. }
  1033. /*
  1034. * CS8415A Mute
  1035. */
  1036. #define aureon_cs8415_mute_info snd_ctl_boolean_mono_info
  1037. static int aureon_cs8415_mute_get (struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  1038. {
  1039. struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
  1040. snd_ice1712_save_gpio_status(ice);
  1041. ucontrol->value.integer.value[0] = (aureon_cs8415_get(ice, CS8415_CTRL1) & 0x20) ? 0 : 1;
  1042. snd_ice1712_restore_gpio_status(ice);
  1043. return 0;
  1044. }
  1045. static int aureon_cs8415_mute_put (struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  1046. {
  1047. struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
  1048. unsigned char oval, nval;
  1049. int change;
  1050. snd_ice1712_save_gpio_status(ice);
  1051. oval = aureon_cs8415_get(ice, CS8415_CTRL1);
  1052. if (ucontrol->value.integer.value[0])
  1053. nval = oval & ~0x20;
  1054. else
  1055. nval = oval | 0x20;
  1056. if ((change = (oval != nval)))
  1057. aureon_cs8415_put(ice, CS8415_CTRL1, nval);
  1058. snd_ice1712_restore_gpio_status(ice);
  1059. return change;
  1060. }
  1061. /*
  1062. * CS8415A Q-Sub info
  1063. */
  1064. static int aureon_cs8415_qsub_info (struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) {
  1065. uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES;
  1066. uinfo->count = 10;
  1067. return 0;
  1068. }
  1069. static int aureon_cs8415_qsub_get (struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) {
  1070. struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
  1071. snd_ice1712_save_gpio_status(ice);
  1072. aureon_cs8415_read(ice, CS8415_QSUB, ucontrol->value.bytes.data, 10);
  1073. snd_ice1712_restore_gpio_status(ice);
  1074. return 0;
  1075. }
  1076. static int aureon_cs8415_spdif_info (struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) {
  1077. uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958;
  1078. uinfo->count = 1;
  1079. return 0;
  1080. }
  1081. static int aureon_cs8415_mask_get (struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) {
  1082. memset(ucontrol->value.iec958.status, 0xFF, 24);
  1083. return 0;
  1084. }
  1085. static int aureon_cs8415_spdif_get (struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) {
  1086. struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
  1087. snd_ice1712_save_gpio_status(ice);
  1088. aureon_cs8415_read(ice, CS8415_C_BUFFER, ucontrol->value.iec958.status, 24);
  1089. snd_ice1712_restore_gpio_status(ice);
  1090. return 0;
  1091. }
  1092. /*
  1093. * Headphone Amplifier
  1094. */
  1095. static int aureon_set_headphone_amp(struct snd_ice1712 *ice, int enable)
  1096. {
  1097. unsigned int tmp, tmp2;
  1098. tmp2 = tmp = snd_ice1712_gpio_read(ice);
  1099. if (enable)
  1100. if (ice->eeprom.subvendor != VT1724_SUBDEVICE_PRODIGY71LT &&
  1101. ice->eeprom.subvendor != VT1724_SUBDEVICE_PRODIGY71XT)
  1102. tmp |= AUREON_HP_SEL;
  1103. else
  1104. tmp |= PRODIGY_HP_SEL;
  1105. else
  1106. if (ice->eeprom.subvendor != VT1724_SUBDEVICE_PRODIGY71LT &&
  1107. ice->eeprom.subvendor != VT1724_SUBDEVICE_PRODIGY71XT)
  1108. tmp &= ~ AUREON_HP_SEL;
  1109. else
  1110. tmp &= ~ PRODIGY_HP_SEL;
  1111. if (tmp != tmp2) {
  1112. snd_ice1712_gpio_write(ice, tmp);
  1113. return 1;
  1114. }
  1115. return 0;
  1116. }
  1117. static int aureon_get_headphone_amp(struct snd_ice1712 *ice)
  1118. {
  1119. unsigned int tmp = snd_ice1712_gpio_read(ice);
  1120. return ( tmp & AUREON_HP_SEL )!= 0;
  1121. }
  1122. #define aureon_hpamp_info snd_ctl_boolean_mono_info
  1123. static int aureon_hpamp_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  1124. {
  1125. struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
  1126. ucontrol->value.integer.value[0] = aureon_get_headphone_amp(ice);
  1127. return 0;
  1128. }
  1129. static int aureon_hpamp_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  1130. {
  1131. struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
  1132. return aureon_set_headphone_amp(ice,ucontrol->value.integer.value[0]);
  1133. }
  1134. /*
  1135. * Deemphasis
  1136. */
  1137. #define aureon_deemp_info snd_ctl_boolean_mono_info
  1138. static int aureon_deemp_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  1139. {
  1140. struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
  1141. ucontrol->value.integer.value[0] = (wm_get(ice, WM_DAC_CTRL2) & 0xf) == 0xf;
  1142. return 0;
  1143. }
  1144. static int aureon_deemp_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  1145. {
  1146. struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
  1147. int temp, temp2;
  1148. temp2 = temp = wm_get(ice, WM_DAC_CTRL2);
  1149. if (ucontrol->value.integer.value[0])
  1150. temp |= 0xf;
  1151. else
  1152. temp &= ~0xf;
  1153. if (temp != temp2) {
  1154. wm_put(ice, WM_DAC_CTRL2, temp);
  1155. return 1;
  1156. }
  1157. return 0;
  1158. }
  1159. /*
  1160. * ADC Oversampling
  1161. */
  1162. static int aureon_oversampling_info(struct snd_kcontrol *k, struct snd_ctl_elem_info *uinfo)
  1163. {
  1164. static const char * const texts[2] = { "128x", "64x" };
  1165. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  1166. uinfo->count = 1;
  1167. uinfo->value.enumerated.items = 2;
  1168. if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
  1169. uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1;
  1170. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  1171. return 0;
  1172. }
  1173. static int aureon_oversampling_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  1174. {
  1175. struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
  1176. ucontrol->value.enumerated.item[0] = (wm_get(ice, WM_MASTER) & 0x8) == 0x8;
  1177. return 0;
  1178. }
  1179. static int aureon_oversampling_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  1180. {
  1181. int temp, temp2;
  1182. struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
  1183. temp2 = temp = wm_get(ice, WM_MASTER);
  1184. if (ucontrol->value.enumerated.item[0])
  1185. temp |= 0x8;
  1186. else
  1187. temp &= ~0x8;
  1188. if (temp != temp2) {
  1189. wm_put(ice, WM_MASTER, temp);
  1190. return 1;
  1191. }
  1192. return 0;
  1193. }
  1194. /*
  1195. * mixers
  1196. */
  1197. static struct snd_kcontrol_new aureon_dac_controls[] __devinitdata = {
  1198. {
  1199. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1200. .name = "Master Playback Switch",
  1201. .info = wm_master_mute_info,
  1202. .get = wm_master_mute_get,
  1203. .put = wm_master_mute_put
  1204. },
  1205. {
  1206. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1207. .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
  1208. SNDRV_CTL_ELEM_ACCESS_TLV_READ),
  1209. .name = "Master Playback Volume",
  1210. .info = wm_master_vol_info,
  1211. .get = wm_master_vol_get,
  1212. .put = wm_master_vol_put,
  1213. .tlv = { .p = db_scale_wm_dac }
  1214. },
  1215. {
  1216. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1217. .name = "Front Playback Switch",
  1218. .info = wm_mute_info,
  1219. .get = wm_mute_get,
  1220. .put = wm_mute_put,
  1221. .private_value = (2 << 8) | 0
  1222. },
  1223. {
  1224. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1225. .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
  1226. SNDRV_CTL_ELEM_ACCESS_TLV_READ),
  1227. .name = "Front Playback Volume",
  1228. .info = wm_vol_info,
  1229. .get = wm_vol_get,
  1230. .put = wm_vol_put,
  1231. .private_value = (2 << 8) | 0,
  1232. .tlv = { .p = db_scale_wm_dac }
  1233. },
  1234. {
  1235. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1236. .name = "Rear Playback Switch",
  1237. .info = wm_mute_info,
  1238. .get = wm_mute_get,
  1239. .put = wm_mute_put,
  1240. .private_value = (2 << 8) | 2
  1241. },
  1242. {
  1243. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1244. .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
  1245. SNDRV_CTL_ELEM_ACCESS_TLV_READ),
  1246. .name = "Rear Playback Volume",
  1247. .info = wm_vol_info,
  1248. .get = wm_vol_get,
  1249. .put = wm_vol_put,
  1250. .private_value = (2 << 8) | 2,
  1251. .tlv = { .p = db_scale_wm_dac }
  1252. },
  1253. {
  1254. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1255. .name = "Center Playback Switch",
  1256. .info = wm_mute_info,
  1257. .get = wm_mute_get,
  1258. .put = wm_mute_put,
  1259. .private_value = (1 << 8) | 4
  1260. },
  1261. {
  1262. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1263. .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
  1264. SNDRV_CTL_ELEM_ACCESS_TLV_READ),
  1265. .name = "Center Playback Volume",
  1266. .info = wm_vol_info,
  1267. .get = wm_vol_get,
  1268. .put = wm_vol_put,
  1269. .private_value = (1 << 8) | 4,
  1270. .tlv = { .p = db_scale_wm_dac }
  1271. },
  1272. {
  1273. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1274. .name = "LFE Playback Switch",
  1275. .info = wm_mute_info,
  1276. .get = wm_mute_get,
  1277. .put = wm_mute_put,
  1278. .private_value = (1 << 8) | 5
  1279. },
  1280. {
  1281. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1282. .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
  1283. SNDRV_CTL_ELEM_ACCESS_TLV_READ),
  1284. .name = "LFE Playback Volume",
  1285. .info = wm_vol_info,
  1286. .get = wm_vol_get,
  1287. .put = wm_vol_put,
  1288. .private_value = (1 << 8) | 5,
  1289. .tlv = { .p = db_scale_wm_dac }
  1290. },
  1291. {
  1292. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1293. .name = "Side Playback Switch",
  1294. .info = wm_mute_info,
  1295. .get = wm_mute_get,
  1296. .put = wm_mute_put,
  1297. .private_value = (2 << 8) | 6
  1298. },
  1299. {
  1300. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1301. .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
  1302. SNDRV_CTL_ELEM_ACCESS_TLV_READ),
  1303. .name = "Side Playback Volume",
  1304. .info = wm_vol_info,
  1305. .get = wm_vol_get,
  1306. .put = wm_vol_put,
  1307. .private_value = (2 << 8) | 6,
  1308. .tlv = { .p = db_scale_wm_dac }
  1309. }
  1310. };
  1311. static struct snd_kcontrol_new wm_controls[] __devinitdata = {
  1312. {
  1313. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1314. .name = "PCM Playback Switch",
  1315. .info = wm_pcm_mute_info,
  1316. .get = wm_pcm_mute_get,
  1317. .put = wm_pcm_mute_put
  1318. },
  1319. {
  1320. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1321. .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
  1322. SNDRV_CTL_ELEM_ACCESS_TLV_READ),
  1323. .name = "PCM Playback Volume",
  1324. .info = wm_pcm_vol_info,
  1325. .get = wm_pcm_vol_get,
  1326. .put = wm_pcm_vol_put,
  1327. .tlv = { .p = db_scale_wm_pcm }
  1328. },
  1329. {
  1330. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1331. .name = "Capture Switch",
  1332. .info = wm_adc_mute_info,
  1333. .get = wm_adc_mute_get,
  1334. .put = wm_adc_mute_put,
  1335. },
  1336. {
  1337. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1338. .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
  1339. SNDRV_CTL_ELEM_ACCESS_TLV_READ),
  1340. .name = "Capture Volume",
  1341. .info = wm_adc_vol_info,
  1342. .get = wm_adc_vol_get,
  1343. .put = wm_adc_vol_put,
  1344. .tlv = { .p = db_scale_wm_adc }
  1345. },
  1346. {
  1347. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1348. .name = "Capture Source",
  1349. .info = wm_adc_mux_info,
  1350. .get = wm_adc_mux_get,
  1351. .put = wm_adc_mux_put,
  1352. .private_value = 5
  1353. },
  1354. {
  1355. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1356. .name = "External Amplifier",
  1357. .info = aureon_hpamp_info,
  1358. .get = aureon_hpamp_get,
  1359. .put = aureon_hpamp_put
  1360. },
  1361. {
  1362. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1363. .name = "DAC Deemphasis Switch",
  1364. .info = aureon_deemp_info,
  1365. .get = aureon_deemp_get,
  1366. .put = aureon_deemp_put
  1367. },
  1368. {
  1369. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1370. .name = "ADC Oversampling",
  1371. .info = aureon_oversampling_info,
  1372. .get = aureon_oversampling_get,
  1373. .put = aureon_oversampling_put
  1374. }
  1375. };
  1376. static struct snd_kcontrol_new ac97_controls[] __devinitdata = {
  1377. {
  1378. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1379. .name = "AC97 Playback Switch",
  1380. .info = aureon_ac97_mmute_info,
  1381. .get = aureon_ac97_mmute_get,
  1382. .put = aureon_ac97_mmute_put,
  1383. .private_value = AC97_MASTER
  1384. },
  1385. {
  1386. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1387. .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
  1388. SNDRV_CTL_ELEM_ACCESS_TLV_READ),
  1389. .name = "AC97 Playback Volume",
  1390. .info = aureon_ac97_vol_info,
  1391. .get = aureon_ac97_vol_get,
  1392. .put = aureon_ac97_vol_put,
  1393. .private_value = AC97_MASTER|AUREON_AC97_STEREO,
  1394. .tlv = { .p = db_scale_ac97_master }
  1395. },
  1396. {
  1397. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1398. .name = "CD Playback Switch",
  1399. .info = aureon_ac97_mute_info,
  1400. .get = aureon_ac97_mute_get,
  1401. .put = aureon_ac97_mute_put,
  1402. .private_value = AC97_CD
  1403. },
  1404. {
  1405. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1406. .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
  1407. SNDRV_CTL_ELEM_ACCESS_TLV_READ),
  1408. .name = "CD Playback Volume",
  1409. .info = aureon_ac97_vol_info,
  1410. .get = aureon_ac97_vol_get,
  1411. .put = aureon_ac97_vol_put,
  1412. .private_value = AC97_CD|AUREON_AC97_STEREO,
  1413. .tlv = { .p = db_scale_ac97_gain }
  1414. },
  1415. {
  1416. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1417. .name = "Aux Playback Switch",
  1418. .info = aureon_ac97_mute_info,
  1419. .get = aureon_ac97_mute_get,
  1420. .put = aureon_ac97_mute_put,
  1421. .private_value = AC97_AUX,
  1422. },
  1423. {
  1424. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1425. .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
  1426. SNDRV_CTL_ELEM_ACCESS_TLV_READ),
  1427. .name = "Aux Playback Volume",
  1428. .info = aureon_ac97_vol_info,
  1429. .get = aureon_ac97_vol_get,
  1430. .put = aureon_ac97_vol_put,
  1431. .private_value = AC97_AUX|AUREON_AC97_STEREO,
  1432. .tlv = { .p = db_scale_ac97_gain }
  1433. },
  1434. {
  1435. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1436. .name = "Line Playback Switch",
  1437. .info = aureon_ac97_mute_info,
  1438. .get = aureon_ac97_mute_get,
  1439. .put = aureon_ac97_mute_put,
  1440. .private_value = AC97_LINE
  1441. },
  1442. {
  1443. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1444. .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
  1445. SNDRV_CTL_ELEM_ACCESS_TLV_READ),
  1446. .name = "Line Playback Volume",
  1447. .info = aureon_ac97_vol_info,
  1448. .get = aureon_ac97_vol_get,
  1449. .put = aureon_ac97_vol_put,
  1450. .private_value = AC97_LINE|AUREON_AC97_STEREO,
  1451. .tlv = { .p = db_scale_ac97_gain }
  1452. },
  1453. {
  1454. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1455. .name = "Mic Playback Switch",
  1456. .info = aureon_ac97_mute_info,
  1457. .get = aureon_ac97_mute_get,
  1458. .put = aureon_ac97_mute_put,
  1459. .private_value = AC97_MIC
  1460. },
  1461. {
  1462. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1463. .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
  1464. SNDRV_CTL_ELEM_ACCESS_TLV_READ),
  1465. .name = "Mic Playback Volume",
  1466. .info = aureon_ac97_vol_info,
  1467. .get = aureon_ac97_vol_get,
  1468. .put = aureon_ac97_vol_put,
  1469. .private_value = AC97_MIC,
  1470. .tlv = { .p = db_scale_ac97_gain }
  1471. },
  1472. {
  1473. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1474. .name = "Mic Boost (+20dB)",
  1475. .info = aureon_ac97_micboost_info,
  1476. .get = aureon_ac97_micboost_get,
  1477. .put = aureon_ac97_micboost_put
  1478. }
  1479. };
  1480. static struct snd_kcontrol_new universe_ac97_controls[] __devinitdata = {
  1481. {
  1482. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1483. .name = "AC97 Playback Switch",
  1484. .info = aureon_ac97_mmute_info,
  1485. .get = aureon_ac97_mmute_get,
  1486. .put = aureon_ac97_mmute_put,
  1487. .private_value = AC97_MASTER
  1488. },
  1489. {
  1490. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1491. .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
  1492. SNDRV_CTL_ELEM_ACCESS_TLV_READ),
  1493. .name = "AC97 Playback Volume",
  1494. .info = aureon_ac97_vol_info,
  1495. .get = aureon_ac97_vol_get,
  1496. .put = aureon_ac97_vol_put,
  1497. .private_value = AC97_MASTER|AUREON_AC97_STEREO,
  1498. .tlv = { .p = db_scale_ac97_master }
  1499. },
  1500. {
  1501. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1502. .name = "CD Playback Switch",
  1503. .info = aureon_ac97_mute_info,
  1504. .get = aureon_ac97_mute_get,
  1505. .put = aureon_ac97_mute_put,
  1506. .private_value = AC97_AUX
  1507. },
  1508. {
  1509. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1510. .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
  1511. SNDRV_CTL_ELEM_ACCESS_TLV_READ),
  1512. .name = "CD Playback Volume",
  1513. .info = aureon_ac97_vol_info,
  1514. .get = aureon_ac97_vol_get,
  1515. .put = aureon_ac97_vol_put,
  1516. .private_value = AC97_AUX|AUREON_AC97_STEREO,
  1517. .tlv = { .p = db_scale_ac97_gain }
  1518. },
  1519. {
  1520. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1521. .name = "Phono Playback Switch",
  1522. .info = aureon_ac97_mute_info,
  1523. .get = aureon_ac97_mute_get,
  1524. .put = aureon_ac97_mute_put,
  1525. .private_value = AC97_CD
  1526. },
  1527. {
  1528. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1529. .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
  1530. SNDRV_CTL_ELEM_ACCESS_TLV_READ),
  1531. .name = "Phono Playback Volume",
  1532. .info = aureon_ac97_vol_info,
  1533. .get = aureon_ac97_vol_get,
  1534. .put = aureon_ac97_vol_put,
  1535. .private_value = AC97_CD|AUREON_AC97_STEREO,
  1536. .tlv = { .p = db_scale_ac97_gain }
  1537. },
  1538. {
  1539. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1540. .name = "Line Playback Switch",
  1541. .info = aureon_ac97_mute_info,
  1542. .get = aureon_ac97_mute_get,
  1543. .put = aureon_ac97_mute_put,
  1544. .private_value = AC97_LINE
  1545. },
  1546. {
  1547. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1548. .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
  1549. SNDRV_CTL_ELEM_ACCESS_TLV_READ),
  1550. .name = "Line Playback Volume",
  1551. .info = aureon_ac97_vol_info,
  1552. .get = aureon_ac97_vol_get,
  1553. .put = aureon_ac97_vol_put,
  1554. .private_value = AC97_LINE|AUREON_AC97_STEREO,
  1555. .tlv = { .p = db_scale_ac97_gain }
  1556. },
  1557. {
  1558. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1559. .name = "Mic Playback Switch",
  1560. .info = aureon_ac97_mute_info,
  1561. .get = aureon_ac97_mute_get,
  1562. .put = aureon_ac97_mute_put,
  1563. .private_value = AC97_MIC
  1564. },
  1565. {
  1566. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1567. .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
  1568. SNDRV_CTL_ELEM_ACCESS_TLV_READ),
  1569. .name = "Mic Playback Volume",
  1570. .info = aureon_ac97_vol_info,
  1571. .get = aureon_ac97_vol_get,
  1572. .put = aureon_ac97_vol_put,
  1573. .private_value = AC97_MIC,
  1574. .tlv = { .p = db_scale_ac97_gain }
  1575. },
  1576. {
  1577. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1578. .name = "Mic Boost (+20dB)",
  1579. .info = aureon_ac97_micboost_info,
  1580. .get = aureon_ac97_micboost_get,
  1581. .put = aureon_ac97_micboost_put
  1582. },
  1583. {
  1584. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1585. .name = "Aux Playback Switch",
  1586. .info = aureon_ac97_mute_info,
  1587. .get = aureon_ac97_mute_get,
  1588. .put = aureon_ac97_mute_put,
  1589. .private_value = AC97_VIDEO,
  1590. },
  1591. {
  1592. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1593. .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
  1594. SNDRV_CTL_ELEM_ACCESS_TLV_READ),
  1595. .name = "Aux Playback Volume",
  1596. .info = aureon_ac97_vol_info,
  1597. .get = aureon_ac97_vol_get,
  1598. .put = aureon_ac97_vol_put,
  1599. .private_value = AC97_VIDEO|AUREON_AC97_STEREO,
  1600. .tlv = { .p = db_scale_ac97_gain }
  1601. },
  1602. {
  1603. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1604. .name = "Aux Source",
  1605. .info = aureon_universe_inmux_info,
  1606. .get = aureon_universe_inmux_get,
  1607. .put = aureon_universe_inmux_put
  1608. }
  1609. };
  1610. static struct snd_kcontrol_new cs8415_controls[] __devinitdata = {
  1611. {
  1612. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1613. .name = SNDRV_CTL_NAME_IEC958("",CAPTURE,SWITCH),
  1614. .info = aureon_cs8415_mute_info,
  1615. .get = aureon_cs8415_mute_get,
  1616. .put = aureon_cs8415_mute_put
  1617. },
  1618. {
  1619. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1620. .name = SNDRV_CTL_NAME_IEC958("",CAPTURE,NONE) "Source",
  1621. .info = aureon_cs8415_mux_info,
  1622. .get = aureon_cs8415_mux_get,
  1623. .put = aureon_cs8415_mux_put,
  1624. },
  1625. {
  1626. .iface = SNDRV_CTL_ELEM_IFACE_PCM,
  1627. .name = SNDRV_CTL_NAME_IEC958("Q-subcode ",CAPTURE,DEFAULT),
  1628. .access = SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE,
  1629. .info = aureon_cs8415_qsub_info,
  1630. .get = aureon_cs8415_qsub_get,
  1631. },
  1632. {
  1633. .iface = SNDRV_CTL_ELEM_IFACE_PCM,
  1634. .name = SNDRV_CTL_NAME_IEC958("",CAPTURE,MASK),
  1635. .access = SNDRV_CTL_ELEM_ACCESS_READ,
  1636. .info = aureon_cs8415_spdif_info,
  1637. .get = aureon_cs8415_mask_get
  1638. },
  1639. {
  1640. .iface = SNDRV_CTL_ELEM_IFACE_PCM,
  1641. .name = SNDRV_CTL_NAME_IEC958("",CAPTURE,DEFAULT),
  1642. .access = SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE,
  1643. .info = aureon_cs8415_spdif_info,
  1644. .get = aureon_cs8415_spdif_get
  1645. },
  1646. {
  1647. .iface = SNDRV_CTL_ELEM_IFACE_PCM,
  1648. .name = SNDRV_CTL_NAME_IEC958("",CAPTURE,NONE) "Rate",
  1649. .access =SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE,
  1650. .info = aureon_cs8415_rate_info,
  1651. .get = aureon_cs8415_rate_get
  1652. }
  1653. };
  1654. static int __devinit aureon_add_controls(struct snd_ice1712 *ice)
  1655. {
  1656. unsigned int i, counts;
  1657. int err;
  1658. counts = ARRAY_SIZE(aureon_dac_controls);
  1659. if (ice->eeprom.subvendor == VT1724_SUBDEVICE_AUREON51_SKY)
  1660. counts -= 2; /* no side */
  1661. for (i = 0; i < counts; i++) {
  1662. err = snd_ctl_add(ice->card, snd_ctl_new1(&aureon_dac_controls[i], ice));
  1663. if (err < 0)
  1664. return err;
  1665. }
  1666. for (i = 0; i < ARRAY_SIZE(wm_controls); i++) {
  1667. err = snd_ctl_add(ice->card, snd_ctl_new1(&wm_controls[i], ice));
  1668. if (err < 0)
  1669. return err;
  1670. }
  1671. if (ice->eeprom.subvendor == VT1724_SUBDEVICE_AUREON71_UNIVERSE) {
  1672. for (i = 0; i < ARRAY_SIZE(universe_ac97_controls); i++) {
  1673. err = snd_ctl_add(ice->card, snd_ctl_new1(&universe_ac97_controls[i], ice));
  1674. if (err < 0)
  1675. return err;
  1676. }
  1677. }
  1678. else if (ice->eeprom.subvendor != VT1724_SUBDEVICE_PRODIGY71LT &&
  1679. ice->eeprom.subvendor != VT1724_SUBDEVICE_PRODIGY71XT) {
  1680. for (i = 0; i < ARRAY_SIZE(ac97_controls); i++) {
  1681. err = snd_ctl_add(ice->card, snd_ctl_new1(&ac97_controls[i], ice));
  1682. if (err < 0)
  1683. return err;
  1684. }
  1685. }
  1686. if (ice->eeprom.subvendor != VT1724_SUBDEVICE_PRODIGY71LT &&
  1687. ice->eeprom.subvendor != VT1724_SUBDEVICE_PRODIGY71XT) {
  1688. unsigned char id;
  1689. snd_ice1712_save_gpio_status(ice);
  1690. id = aureon_cs8415_get(ice, CS8415_ID);
  1691. if (id != 0x41)
  1692. snd_printk(KERN_INFO "No CS8415 chip. Skipping CS8415 controls.\n");
  1693. else if ((id & 0x0F) != 0x01)
  1694. snd_printk(KERN_INFO "Detected unsupported CS8415 rev. (%c)\n", (char)((id & 0x0F) + 'A' - 1));
  1695. else {
  1696. for (i = 0; i< ARRAY_SIZE(cs8415_controls); i++) {
  1697. struct snd_kcontrol *kctl;
  1698. err = snd_ctl_add(ice->card, (kctl = snd_ctl_new1(&cs8415_controls[i], ice)));
  1699. if (err < 0)
  1700. return err;
  1701. if (i > 1)
  1702. kctl->id.device = ice->pcm->device;
  1703. }
  1704. }
  1705. snd_ice1712_restore_gpio_status(ice);
  1706. }
  1707. return 0;
  1708. }
  1709. /*
  1710. * initialize the chip
  1711. */
  1712. static int __devinit aureon_init(struct snd_ice1712 *ice)
  1713. {
  1714. static const unsigned short wm_inits_aureon[] = {
  1715. /* These come first to reduce init pop noise */
  1716. 0x1b, 0x044, /* ADC Mux (AC'97 source) */
  1717. 0x1c, 0x00B, /* Out Mux1 (VOUT1 = DAC+AUX, VOUT2 = DAC) */
  1718. 0x1d, 0x009, /* Out Mux2 (VOUT2 = DAC, VOUT3 = DAC) */
  1719. 0x18, 0x000, /* All power-up */
  1720. 0x16, 0x122, /* I2S, normal polarity, 24bit */
  1721. 0x17, 0x022, /* 256fs, slave mode */
  1722. 0x00, 0, /* DAC1 analog mute */
  1723. 0x01, 0, /* DAC2 analog mute */
  1724. 0x02, 0, /* DAC3 analog mute */
  1725. 0x03, 0, /* DAC4 analog mute */
  1726. 0x04, 0, /* DAC5 analog mute */
  1727. 0x05, 0, /* DAC6 analog mute */
  1728. 0x06, 0, /* DAC7 analog mute */
  1729. 0x07, 0, /* DAC8 analog mute */
  1730. 0x08, 0x100, /* master analog mute */
  1731. 0x09, 0xff, /* DAC1 digital full */
  1732. 0x0a, 0xff, /* DAC2 digital full */
  1733. 0x0b, 0xff, /* DAC3 digital full */
  1734. 0x0c, 0xff, /* DAC4 digital full */
  1735. 0x0d, 0xff, /* DAC5 digital full */
  1736. 0x0e, 0xff, /* DAC6 digital full */
  1737. 0x0f, 0xff, /* DAC7 digital full */
  1738. 0x10, 0xff, /* DAC8 digital full */
  1739. 0x11, 0x1ff, /* master digital full */
  1740. 0x12, 0x000, /* phase normal */
  1741. 0x13, 0x090, /* unmute DAC L/R */
  1742. 0x14, 0x000, /* all unmute */
  1743. 0x15, 0x000, /* no deemphasis, no ZFLG */
  1744. 0x19, 0x000, /* -12dB ADC/L */
  1745. 0x1a, 0x000, /* -12dB ADC/R */
  1746. (unsigned short)-1
  1747. };
  1748. static const unsigned short wm_inits_prodigy[] = {
  1749. /* These come first to reduce init pop noise */
  1750. 0x1b, 0x000, /* ADC Mux */
  1751. 0x1c, 0x009, /* Out Mux1 */
  1752. 0x1d, 0x009, /* Out Mux2 */
  1753. 0x18, 0x000, /* All power-up */
  1754. 0x16, 0x022, /* I2S, normal polarity, 24bit, high-pass on */
  1755. 0x17, 0x006, /* 128fs, slave mode */
  1756. 0x00, 0, /* DAC1 analog mute */
  1757. 0x01, 0, /* DAC2 analog mute */
  1758. 0x02, 0, /* DAC3 analog mute */
  1759. 0x03, 0, /* DAC4 analog mute */
  1760. 0x04, 0, /* DAC5 analog mute */
  1761. 0x05, 0, /* DAC6 analog mute */
  1762. 0x06, 0, /* DAC7 analog mute */
  1763. 0x07, 0, /* DAC8 analog mute */
  1764. 0x08, 0x100, /* master analog mute */
  1765. 0x09, 0x7f, /* DAC1 digital full */
  1766. 0x0a, 0x7f, /* DAC2 digital full */
  1767. 0x0b, 0x7f, /* DAC3 digital full */
  1768. 0x0c, 0x7f, /* DAC4 digital full */
  1769. 0x0d, 0x7f, /* DAC5 digital full */
  1770. 0x0e, 0x7f, /* DAC6 digital full */
  1771. 0x0f, 0x7f, /* DAC7 digital full */
  1772. 0x10, 0x7f, /* DAC8 digital full */
  1773. 0x11, 0x1FF, /* master digital full */
  1774. 0x12, 0x000, /* phase normal */
  1775. 0x13, 0x090, /* unmute DAC L/R */
  1776. 0x14, 0x000, /* all unmute */
  1777. 0x15, 0x000, /* no deemphasis, no ZFLG */
  1778. 0x19, 0x000, /* -12dB ADC/L */
  1779. 0x1a, 0x000, /* -12dB ADC/R */
  1780. (unsigned short)-1
  1781. };
  1782. static const unsigned short cs_inits[] = {
  1783. 0x0441, /* RUN */
  1784. 0x0180, /* no mute, OMCK output on RMCK pin */
  1785. 0x0201, /* S/PDIF source on RXP1 */
  1786. 0x0605, /* slave, 24bit, MSB on second OSCLK, SDOUT for right channel when OLRCK is high */
  1787. (unsigned short)-1
  1788. };
  1789. unsigned int tmp;
  1790. const unsigned short *p;
  1791. int err, i;
  1792. if (ice->eeprom.subvendor == VT1724_SUBDEVICE_AUREON51_SKY) {
  1793. ice->num_total_dacs = 6;
  1794. ice->num_total_adcs = 2;
  1795. } else {
  1796. /* aureon 7.1 and prodigy 7.1 */
  1797. ice->num_total_dacs = 8;
  1798. ice->num_total_adcs = 2;
  1799. }
  1800. /* to remeber the register values of CS8415 */
  1801. ice->akm = kzalloc(sizeof(struct snd_akm4xxx), GFP_KERNEL);
  1802. if (! ice->akm)
  1803. return -ENOMEM;
  1804. ice->akm_codecs = 1;
  1805. if ((err = aureon_ac97_init(ice)) != 0)
  1806. return err;
  1807. snd_ice1712_gpio_set_dir(ice, 0x5fffff); /* fix this for the time being */
  1808. /* reset the wm codec as the SPI mode */
  1809. snd_ice1712_save_gpio_status(ice);
  1810. snd_ice1712_gpio_set_mask(ice, ~(AUREON_WM_RESET|AUREON_WM_CS|AUREON_CS8415_CS|AUREON_HP_SEL));
  1811. tmp = snd_ice1712_gpio_read(ice);
  1812. tmp &= ~AUREON_WM_RESET;
  1813. snd_ice1712_gpio_write(ice, tmp);
  1814. udelay(1);
  1815. tmp |= AUREON_WM_CS | AUREON_CS8415_CS;
  1816. snd_ice1712_gpio_write(ice, tmp);
  1817. udelay(1);
  1818. tmp |= AUREON_WM_RESET;
  1819. snd_ice1712_gpio_write(ice, tmp);
  1820. udelay(1);
  1821. /* initialize WM8770 codec */
  1822. if (ice->eeprom.subvendor == VT1724_SUBDEVICE_PRODIGY71 ||
  1823. ice->eeprom.subvendor == VT1724_SUBDEVICE_PRODIGY71LT ||
  1824. ice->eeprom.subvendor == VT1724_SUBDEVICE_PRODIGY71XT)
  1825. p = wm_inits_prodigy;
  1826. else
  1827. p = wm_inits_aureon;
  1828. for (; *p != (unsigned short)-1; p += 2)
  1829. wm_put(ice, p[0], p[1]);
  1830. /* initialize CS8415A codec */
  1831. if (ice->eeprom.subvendor != VT1724_SUBDEVICE_PRODIGY71LT &&
  1832. ice->eeprom.subvendor != VT1724_SUBDEVICE_PRODIGY71XT) {
  1833. for (p = cs_inits; *p != (unsigned short)-1; p++)
  1834. aureon_spi_write(ice, AUREON_CS8415_CS, *p | 0x200000, 24);
  1835. ice->spec.aureon.cs8415_mux = 1;
  1836. aureon_set_headphone_amp(ice, 1);
  1837. }
  1838. snd_ice1712_restore_gpio_status(ice);
  1839. /* initialize PCA9554 pin directions & set default input*/
  1840. aureon_pca9554_write(ice, PCA9554_DIR, 0x00);
  1841. aureon_pca9554_write(ice, PCA9554_OUT, 0x00); /* internal AUX */
  1842. ice->spec.aureon.master[0] = WM_VOL_MUTE;
  1843. ice->spec.aureon.master[1] = WM_VOL_MUTE;
  1844. for (i = 0; i < ice->num_total_dacs; i++) {
  1845. ice->spec.aureon.vol[i] = WM_VOL_MUTE;
  1846. wm_set_vol(ice, i, ice->spec.aureon.vol[i], ice->spec.aureon.master[i % 2]);
  1847. }
  1848. return 0;
  1849. }
  1850. /*
  1851. * Aureon boards don't provide the EEPROM data except for the vendor IDs.
  1852. * hence the driver needs to sets up it properly.
  1853. */
  1854. static unsigned char aureon51_eeprom[] __devinitdata = {
  1855. [ICE_EEP2_SYSCONF] = 0x0a, /* clock 512, spdif-in/ADC, 3DACs */
  1856. [ICE_EEP2_ACLINK] = 0x80, /* I2S */
  1857. [ICE_EEP2_I2S] = 0xfc, /* vol, 96k, 24bit, 192k */
  1858. [ICE_EEP2_SPDIF] = 0xc3, /* out-en, out-int, spdif-in */
  1859. [ICE_EEP2_GPIO_DIR] = 0xff,
  1860. [ICE_EEP2_GPIO_DIR1] = 0xff,
  1861. [ICE_EEP2_GPIO_DIR2] = 0x5f,
  1862. [ICE_EEP2_GPIO_MASK] = 0x00,
  1863. [ICE_EEP2_GPIO_MASK1] = 0x00,
  1864. [ICE_EEP2_GPIO_MASK2] = 0x00,
  1865. [ICE_EEP2_GPIO_STATE] = 0x00,
  1866. [ICE_EEP2_GPIO_STATE1] = 0x00,
  1867. [ICE_EEP2_GPIO_STATE2] = 0x00,
  1868. };
  1869. static unsigned char aureon71_eeprom[] __devinitdata = {
  1870. [ICE_EEP2_SYSCONF] = 0x0b, /* clock 512, spdif-in/ADC, 4DACs */
  1871. [ICE_EEP2_ACLINK] = 0x80, /* I2S */
  1872. [ICE_EEP2_I2S] = 0xfc, /* vol, 96k, 24bit, 192k */
  1873. [ICE_EEP2_SPDIF] = 0xc3, /* out-en, out-int, spdif-in */
  1874. [ICE_EEP2_GPIO_DIR] = 0xff,
  1875. [ICE_EEP2_GPIO_DIR1] = 0xff,
  1876. [ICE_EEP2_GPIO_DIR2] = 0x5f,
  1877. [ICE_EEP2_GPIO_MASK] = 0x00,
  1878. [ICE_EEP2_GPIO_MASK1] = 0x00,
  1879. [ICE_EEP2_GPIO_MASK2] = 0x00,
  1880. [ICE_EEP2_GPIO_STATE] = 0x00,
  1881. [ICE_EEP2_GPIO_STATE1] = 0x00,
  1882. [ICE_EEP2_GPIO_STATE2] = 0x00,
  1883. };
  1884. #define prodigy71_eeprom aureon71_eeprom
  1885. static unsigned char prodigy71lt_eeprom[] __devinitdata = {
  1886. [ICE_EEP2_SYSCONF] = 0x4b, /* clock 384, spdif-in/ADC, 4DACs */
  1887. [ICE_EEP2_ACLINK] = 0x80, /* I2S */
  1888. [ICE_EEP2_I2S] = 0xfc, /* vol, 96k, 24bit, 192k */
  1889. [ICE_EEP2_SPDIF] = 0xc3, /* out-en, out-int, spdif-in */
  1890. [ICE_EEP2_GPIO_DIR] = 0xff,
  1891. [ICE_EEP2_GPIO_DIR1] = 0xff,
  1892. [ICE_EEP2_GPIO_DIR2] = 0x5f,
  1893. [ICE_EEP2_GPIO_MASK] = 0x00,
  1894. [ICE_EEP2_GPIO_MASK1] = 0x00,
  1895. [ICE_EEP2_GPIO_MASK2] = 0x00,
  1896. [ICE_EEP2_GPIO_STATE] = 0x00,
  1897. [ICE_EEP2_GPIO_STATE1] = 0x00,
  1898. [ICE_EEP2_GPIO_STATE2] = 0x00,
  1899. };
  1900. #define prodigy71xt_eeprom prodigy71lt_eeprom
  1901. /* entry point */
  1902. struct snd_ice1712_card_info snd_vt1724_aureon_cards[] __devinitdata = {
  1903. {
  1904. .subvendor = VT1724_SUBDEVICE_AUREON51_SKY,
  1905. .name = "Terratec Aureon 5.1-Sky",
  1906. .model = "aureon51",
  1907. .chip_init = aureon_init,
  1908. .build_controls = aureon_add_controls,
  1909. .eeprom_size = sizeof(aureon51_eeprom),
  1910. .eeprom_data = aureon51_eeprom,
  1911. .driver = "Aureon51",
  1912. },
  1913. {
  1914. .subvendor = VT1724_SUBDEVICE_AUREON71_SPACE,
  1915. .name = "Terratec Aureon 7.1-Space",
  1916. .model = "aureon71",
  1917. .chip_init = aureon_init,
  1918. .build_controls = aureon_add_controls,
  1919. .eeprom_size = sizeof(aureon71_eeprom),
  1920. .eeprom_data = aureon71_eeprom,
  1921. .driver = "Aureon71",
  1922. },
  1923. {
  1924. .subvendor = VT1724_SUBDEVICE_AUREON71_UNIVERSE,
  1925. .name = "Terratec Aureon 7.1-Universe",
  1926. .model = "universe",
  1927. .chip_init = aureon_init,
  1928. .build_controls = aureon_add_controls,
  1929. .eeprom_size = sizeof(aureon71_eeprom),
  1930. .eeprom_data = aureon71_eeprom,
  1931. .driver = "Aureon71Univ", /* keep in 15 letters */
  1932. },
  1933. {
  1934. .subvendor = VT1724_SUBDEVICE_PRODIGY71,
  1935. .name = "Audiotrak Prodigy 7.1",
  1936. .model = "prodigy71",
  1937. .chip_init = aureon_init,
  1938. .build_controls = aureon_add_controls,
  1939. .eeprom_size = sizeof(prodigy71_eeprom),
  1940. .eeprom_data = prodigy71_eeprom,
  1941. .driver = "Prodigy71", /* should be identical with Aureon71 */
  1942. },
  1943. {
  1944. .subvendor = VT1724_SUBDEVICE_PRODIGY71LT,
  1945. .name = "Audiotrak Prodigy 7.1 LT",
  1946. .model = "prodigy71lt",
  1947. .chip_init = aureon_init,
  1948. .build_controls = aureon_add_controls,
  1949. .eeprom_size = sizeof(prodigy71lt_eeprom),
  1950. .eeprom_data = prodigy71lt_eeprom,
  1951. .driver = "Prodigy71LT",
  1952. },
  1953. {
  1954. .subvendor = VT1724_SUBDEVICE_PRODIGY71XT,
  1955. .name = "Audiotrak Prodigy 7.1 XT",
  1956. .model = "prodigy71xt",
  1957. .chip_init = aureon_init,
  1958. .build_controls = aureon_add_controls,
  1959. .eeprom_size = sizeof(prodigy71xt_eeprom),
  1960. .eeprom_data = prodigy71xt_eeprom,
  1961. .driver = "Prodigy71LT",
  1962. },
  1963. { } /* terminator */
  1964. };