patch_realtek.c 87 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642
  1. /*
  2. * Universal Interface for Intel High Definition Audio Codec
  3. *
  4. * HD audio interface patch for ALC 260/880/882 codecs
  5. *
  6. * Copyright (c) 2004 PeiSen Hou <pshou@realtek.com.tw>
  7. * Takashi Iwai <tiwai@suse.de>
  8. *
  9. * This driver is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 2 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This driver is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  22. */
  23. #include <sound/driver.h>
  24. #include <linux/init.h>
  25. #include <linux/delay.h>
  26. #include <linux/slab.h>
  27. #include <linux/pci.h>
  28. #include <sound/core.h>
  29. #include "hda_codec.h"
  30. #include "hda_local.h"
  31. /* ALC880 board config type */
  32. enum {
  33. ALC880_3ST,
  34. ALC880_3ST_DIG,
  35. ALC880_5ST,
  36. ALC880_5ST_DIG,
  37. ALC880_W810,
  38. ALC880_Z71V,
  39. ALC880_AUTO,
  40. ALC880_6ST_DIG,
  41. ALC880_F1734,
  42. ALC880_ASUS,
  43. ALC880_ASUS_DIG,
  44. ALC880_ASUS_W1V,
  45. ALC880_UNIWILL_DIG,
  46. #ifdef CONFIG_SND_DEBUG
  47. ALC880_TEST,
  48. #endif
  49. ALC880_MODEL_LAST /* last tag */
  50. };
  51. /* ALC260 models */
  52. enum {
  53. ALC260_BASIC,
  54. ALC260_HP,
  55. ALC260_MODEL_LAST /* last tag */
  56. };
  57. /* amp values */
  58. #define AMP_IN_MUTE(idx) (0x7080 | ((idx)<<8))
  59. #define AMP_IN_UNMUTE(idx) (0x7000 | ((idx)<<8))
  60. #define AMP_OUT_MUTE 0xb080
  61. #define AMP_OUT_UNMUTE 0xb000
  62. #define AMP_OUT_ZERO 0xb000
  63. /* pinctl values */
  64. #define PIN_IN 0x20
  65. #define PIN_VREF80 0x24
  66. #define PIN_VREF50 0x21
  67. #define PIN_OUT 0x40
  68. #define PIN_HP 0xc0
  69. struct alc_spec {
  70. /* codec parameterization */
  71. snd_kcontrol_new_t *mixers[3]; /* mixer arrays */
  72. unsigned int num_mixers;
  73. const struct hda_verb *init_verbs[3]; /* initialization verbs
  74. * don't forget NULL termination!
  75. */
  76. unsigned int num_init_verbs;
  77. char *stream_name_analog; /* analog PCM stream */
  78. struct hda_pcm_stream *stream_analog_playback;
  79. struct hda_pcm_stream *stream_analog_capture;
  80. char *stream_name_digital; /* digital PCM stream */
  81. struct hda_pcm_stream *stream_digital_playback;
  82. struct hda_pcm_stream *stream_digital_capture;
  83. /* playback */
  84. struct hda_multi_out multiout; /* playback set-up
  85. * max_channels, dacs must be set
  86. * dig_out_nid and hp_nid are optional
  87. */
  88. /* capture */
  89. unsigned int num_adc_nids;
  90. hda_nid_t *adc_nids;
  91. hda_nid_t dig_in_nid; /* digital-in NID; optional */
  92. /* capture source */
  93. const struct hda_input_mux *input_mux;
  94. unsigned int cur_mux[3];
  95. /* channel model */
  96. const struct alc_channel_mode *channel_mode;
  97. int num_channel_mode;
  98. /* PCM information */
  99. struct hda_pcm pcm_rec[2]; /* used in alc_build_pcms() */
  100. struct semaphore bind_mutex; /* for bound controls */
  101. /* dynamic controls, init_verbs and input_mux */
  102. struct auto_pin_cfg autocfg;
  103. unsigned int num_kctl_alloc, num_kctl_used;
  104. snd_kcontrol_new_t *kctl_alloc;
  105. struct hda_input_mux private_imux;
  106. };
  107. /*
  108. * input MUX handling
  109. */
  110. static int alc_mux_enum_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)
  111. {
  112. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  113. struct alc_spec *spec = codec->spec;
  114. return snd_hda_input_mux_info(spec->input_mux, uinfo);
  115. }
  116. static int alc_mux_enum_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
  117. {
  118. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  119. struct alc_spec *spec = codec->spec;
  120. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  121. ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
  122. return 0;
  123. }
  124. static int alc_mux_enum_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
  125. {
  126. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  127. struct alc_spec *spec = codec->spec;
  128. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  129. return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
  130. spec->adc_nids[adc_idx], &spec->cur_mux[adc_idx]);
  131. }
  132. /*
  133. * channel mode setting
  134. */
  135. struct alc_channel_mode {
  136. int channels;
  137. const struct hda_verb *sequence;
  138. };
  139. static int alc880_ch_mode_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)
  140. {
  141. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  142. struct alc_spec *spec = codec->spec;
  143. int items = kcontrol->private_value ? (int)kcontrol->private_value : 2;
  144. snd_assert(spec->channel_mode, return -ENXIO);
  145. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  146. uinfo->count = 1;
  147. uinfo->value.enumerated.items = items;
  148. if (uinfo->value.enumerated.item >= items)
  149. uinfo->value.enumerated.item = items - 1;
  150. sprintf(uinfo->value.enumerated.name, "%dch",
  151. spec->channel_mode[uinfo->value.enumerated.item].channels);
  152. return 0;
  153. }
  154. static int alc880_ch_mode_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
  155. {
  156. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  157. struct alc_spec *spec = codec->spec;
  158. int items = kcontrol->private_value ? (int)kcontrol->private_value : 2;
  159. int i;
  160. snd_assert(spec->channel_mode, return -ENXIO);
  161. for (i = 0; i < items; i++) {
  162. if (spec->multiout.max_channels == spec->channel_mode[i].channels) {
  163. ucontrol->value.enumerated.item[0] = i;
  164. break;
  165. }
  166. }
  167. return 0;
  168. }
  169. static int alc880_ch_mode_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
  170. {
  171. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  172. struct alc_spec *spec = codec->spec;
  173. int mode;
  174. snd_assert(spec->channel_mode, return -ENXIO);
  175. mode = ucontrol->value.enumerated.item[0] ? 1 : 0;
  176. if (spec->multiout.max_channels == spec->channel_mode[mode].channels &&
  177. ! codec->in_resume)
  178. return 0;
  179. /* change the current channel setting */
  180. spec->multiout.max_channels = spec->channel_mode[mode].channels;
  181. if (spec->channel_mode[mode].sequence)
  182. snd_hda_sequence_write(codec, spec->channel_mode[mode].sequence);
  183. return 1;
  184. }
  185. /*
  186. * bound volume controls
  187. *
  188. * bind multiple volumes (# indices, from 0)
  189. */
  190. #define AMP_VAL_IDX_SHIFT 19
  191. #define AMP_VAL_IDX_MASK (0x0f<<19)
  192. static int alc_bind_switch_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)
  193. {
  194. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  195. struct alc_spec *spec = codec->spec;
  196. unsigned long pval;
  197. down(&spec->bind_mutex);
  198. pval = kcontrol->private_value;
  199. kcontrol->private_value = pval & ~AMP_VAL_IDX_MASK; /* index 0 */
  200. snd_hda_mixer_amp_switch_info(kcontrol, uinfo);
  201. kcontrol->private_value = pval;
  202. up(&spec->bind_mutex);
  203. return 0;
  204. }
  205. static int alc_bind_switch_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
  206. {
  207. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  208. struct alc_spec *spec = codec->spec;
  209. unsigned long pval;
  210. down(&spec->bind_mutex);
  211. pval = kcontrol->private_value;
  212. kcontrol->private_value = pval & ~AMP_VAL_IDX_MASK; /* index 0 */
  213. snd_hda_mixer_amp_switch_get(kcontrol, ucontrol);
  214. kcontrol->private_value = pval;
  215. up(&spec->bind_mutex);
  216. return 0;
  217. }
  218. static int alc_bind_switch_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
  219. {
  220. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  221. struct alc_spec *spec = codec->spec;
  222. unsigned long pval;
  223. int i, indices, change = 0;
  224. down(&spec->bind_mutex);
  225. pval = kcontrol->private_value;
  226. indices = (pval & AMP_VAL_IDX_MASK) >> AMP_VAL_IDX_SHIFT;
  227. for (i = 0; i < indices; i++) {
  228. kcontrol->private_value = (pval & ~AMP_VAL_IDX_MASK) | (i << AMP_VAL_IDX_SHIFT);
  229. change |= snd_hda_mixer_amp_switch_put(kcontrol, ucontrol);
  230. }
  231. kcontrol->private_value = pval;
  232. up(&spec->bind_mutex);
  233. return change;
  234. }
  235. #define ALC_BIND_MUTE_MONO(xname, nid, channel, indices, direction) \
  236. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  237. .info = alc_bind_switch_info, \
  238. .get = alc_bind_switch_get, \
  239. .put = alc_bind_switch_put, \
  240. .private_value = HDA_COMPOSE_AMP_VAL(nid, channel, indices, direction) }
  241. #define ALC_BIND_MUTE(xname,nid,indices,dir) ALC_BIND_MUTE_MONO(xname,nid,3,indices,dir)
  242. /*
  243. * ALC880 3-stack model
  244. *
  245. * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
  246. * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18, F-Mic = 0x1b
  247. * HP = 0x19
  248. */
  249. static hda_nid_t alc880_dac_nids[4] = {
  250. /* front, rear, clfe, rear_surr */
  251. 0x02, 0x05, 0x04, 0x03
  252. };
  253. static hda_nid_t alc880_adc_nids[3] = {
  254. /* ADC0-2 */
  255. 0x07, 0x08, 0x09,
  256. };
  257. /* The datasheet says the node 0x07 is connected from inputs,
  258. * but it shows zero connection in the real implementation on some devices.
  259. */
  260. static hda_nid_t alc880_adc_nids_alt[2] = {
  261. /* ADC1-2 */
  262. 0x08, 0x09,
  263. };
  264. #define ALC880_DIGOUT_NID 0x06
  265. #define ALC880_DIGIN_NID 0x0a
  266. static struct hda_input_mux alc880_capture_source = {
  267. .num_items = 4,
  268. .items = {
  269. { "Mic", 0x0 },
  270. { "Front Mic", 0x3 },
  271. { "Line", 0x2 },
  272. { "CD", 0x4 },
  273. },
  274. };
  275. /* channel source setting (2/6 channel selection for 3-stack) */
  276. /* 2ch mode */
  277. static struct hda_verb alc880_threestack_ch2_init[] = {
  278. /* set line-in to input, mute it */
  279. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  280. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  281. /* set mic-in to input vref 80%, mute it */
  282. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  283. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  284. { } /* end */
  285. };
  286. /* 6ch mode */
  287. static struct hda_verb alc880_threestack_ch6_init[] = {
  288. /* set line-in to output, unmute it */
  289. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  290. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  291. /* set mic-in to output, unmute it */
  292. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  293. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  294. { } /* end */
  295. };
  296. static struct alc_channel_mode alc880_threestack_modes[2] = {
  297. { 2, alc880_threestack_ch2_init },
  298. { 6, alc880_threestack_ch6_init },
  299. };
  300. static snd_kcontrol_new_t alc880_three_stack_mixer[] = {
  301. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  302. ALC_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  303. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  304. ALC_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
  305. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  306. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  307. ALC_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  308. ALC_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  309. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  310. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  311. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  312. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  313. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  314. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  315. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
  316. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
  317. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  318. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  319. HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
  320. {
  321. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  322. .name = "Channel Mode",
  323. .info = alc880_ch_mode_info,
  324. .get = alc880_ch_mode_get,
  325. .put = alc880_ch_mode_put,
  326. },
  327. { } /* end */
  328. };
  329. /* capture mixer elements */
  330. static snd_kcontrol_new_t alc880_capture_mixer[] = {
  331. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  332. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  333. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  334. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  335. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  336. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  337. {
  338. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  339. /* The multiple "Capture Source" controls confuse alsamixer
  340. * So call somewhat different..
  341. * FIXME: the controls appear in the "playback" view!
  342. */
  343. /* .name = "Capture Source", */
  344. .name = "Input Source",
  345. .count = 3,
  346. .info = alc_mux_enum_info,
  347. .get = alc_mux_enum_get,
  348. .put = alc_mux_enum_put,
  349. },
  350. { } /* end */
  351. };
  352. /* capture mixer elements (in case NID 0x07 not available) */
  353. static snd_kcontrol_new_t alc880_capture_alt_mixer[] = {
  354. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  355. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  356. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  357. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  358. {
  359. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  360. /* The multiple "Capture Source" controls confuse alsamixer
  361. * So call somewhat different..
  362. * FIXME: the controls appear in the "playback" view!
  363. */
  364. /* .name = "Capture Source", */
  365. .name = "Input Source",
  366. .count = 2,
  367. .info = alc_mux_enum_info,
  368. .get = alc_mux_enum_get,
  369. .put = alc_mux_enum_put,
  370. },
  371. { } /* end */
  372. };
  373. /*
  374. * ALC880 5-stack model
  375. *
  376. * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d), Side = 0x02 (0xd)
  377. * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
  378. * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
  379. */
  380. /* additional mixers to alc880_three_stack_mixer */
  381. static snd_kcontrol_new_t alc880_five_stack_mixer[] = {
  382. HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  383. ALC_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
  384. { } /* end */
  385. };
  386. /* channel source setting (6/8 channel selection for 5-stack) */
  387. /* 6ch mode */
  388. static struct hda_verb alc880_fivestack_ch6_init[] = {
  389. /* set line-in to input, mute it */
  390. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  391. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  392. { } /* end */
  393. };
  394. /* 8ch mode */
  395. static struct hda_verb alc880_fivestack_ch8_init[] = {
  396. /* set line-in to output, unmute it */
  397. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  398. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  399. { } /* end */
  400. };
  401. static struct alc_channel_mode alc880_fivestack_modes[2] = {
  402. { 6, alc880_fivestack_ch6_init },
  403. { 8, alc880_fivestack_ch8_init },
  404. };
  405. /*
  406. * ALC880 6-stack model
  407. *
  408. * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e), Side = 0x05 (0x0f)
  409. * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
  410. * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
  411. */
  412. static hda_nid_t alc880_6st_dac_nids[4] = {
  413. /* front, rear, clfe, rear_surr */
  414. 0x02, 0x03, 0x04, 0x05
  415. };
  416. static struct hda_input_mux alc880_6stack_capture_source = {
  417. .num_items = 4,
  418. .items = {
  419. { "Mic", 0x0 },
  420. { "Front Mic", 0x1 },
  421. { "Line", 0x2 },
  422. { "CD", 0x4 },
  423. },
  424. };
  425. /* fixed 8-channels */
  426. static struct alc_channel_mode alc880_sixstack_modes[1] = {
  427. { 8, NULL },
  428. };
  429. static snd_kcontrol_new_t alc880_six_stack_mixer[] = {
  430. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  431. ALC_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  432. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  433. ALC_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  434. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  435. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  436. ALC_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  437. ALC_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  438. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  439. ALC_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  440. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  441. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  442. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  443. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  444. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  445. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  446. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  447. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  448. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  449. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  450. {
  451. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  452. .name = "Channel Mode",
  453. .info = alc880_ch_mode_info,
  454. .get = alc880_ch_mode_get,
  455. .put = alc880_ch_mode_put,
  456. },
  457. { } /* end */
  458. };
  459. /*
  460. * ALC880 W810 model
  461. *
  462. * W810 has rear IO for:
  463. * Front (DAC 02)
  464. * Surround (DAC 03)
  465. * Center/LFE (DAC 04)
  466. * Digital out (06)
  467. *
  468. * The system also has a pair of internal speakers, and a headphone jack.
  469. * These are both connected to Line2 on the codec, hence to DAC 02.
  470. *
  471. * There is a variable resistor to control the speaker or headphone
  472. * volume. This is a hardware-only device without a software API.
  473. *
  474. * Plugging headphones in will disable the internal speakers. This is
  475. * implemented in hardware, not via the driver using jack sense. In
  476. * a similar fashion, plugging into the rear socket marked "front" will
  477. * disable both the speakers and headphones.
  478. *
  479. * For input, there's a microphone jack, and an "audio in" jack.
  480. * These may not do anything useful with this driver yet, because I
  481. * haven't setup any initialization verbs for these yet...
  482. */
  483. static hda_nid_t alc880_w810_dac_nids[3] = {
  484. /* front, rear/surround, clfe */
  485. 0x02, 0x03, 0x04
  486. };
  487. /* fixed 6 channels */
  488. static struct alc_channel_mode alc880_w810_modes[1] = {
  489. { 6, NULL }
  490. };
  491. /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
  492. static snd_kcontrol_new_t alc880_w810_base_mixer[] = {
  493. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  494. ALC_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  495. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  496. ALC_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  497. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  498. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  499. ALC_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  500. ALC_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  501. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  502. { } /* end */
  503. };
  504. /*
  505. * Z710V model
  506. *
  507. * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
  508. * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?), Line = 0x1a
  509. */
  510. static hda_nid_t alc880_z71v_dac_nids[1] = {
  511. 0x02
  512. };
  513. #define ALC880_Z71V_HP_DAC 0x03
  514. /* fixed 2 channels */
  515. static struct alc_channel_mode alc880_2_jack_modes[1] = {
  516. { 2, NULL }
  517. };
  518. static snd_kcontrol_new_t alc880_z71v_mixer[] = {
  519. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  520. ALC_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  521. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  522. ALC_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
  523. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  524. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  525. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  526. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  527. { } /* end */
  528. };
  529. /* FIXME! */
  530. /*
  531. * ALC880 F1734 model
  532. *
  533. * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
  534. * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
  535. */
  536. static hda_nid_t alc880_f1734_dac_nids[1] = {
  537. 0x03
  538. };
  539. #define ALC880_F1734_HP_DAC 0x02
  540. static snd_kcontrol_new_t alc880_f1734_mixer[] = {
  541. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  542. ALC_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
  543. HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  544. ALC_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
  545. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  546. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  547. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  548. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  549. { } /* end */
  550. };
  551. /* FIXME! */
  552. /*
  553. * ALC880 ASUS model
  554. *
  555. * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
  556. * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
  557. * Mic = 0x18, Line = 0x1a
  558. */
  559. #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
  560. #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
  561. static snd_kcontrol_new_t alc880_asus_mixer[] = {
  562. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  563. ALC_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  564. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  565. ALC_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  566. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  567. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  568. ALC_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  569. ALC_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  570. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  571. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  572. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  573. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  574. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  575. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  576. {
  577. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  578. .name = "Channel Mode",
  579. .info = alc880_ch_mode_info,
  580. .get = alc880_ch_mode_get,
  581. .put = alc880_ch_mode_put,
  582. },
  583. { } /* end */
  584. };
  585. /* FIXME! */
  586. /*
  587. * ALC880 ASUS W1V model
  588. *
  589. * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
  590. * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
  591. * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
  592. */
  593. /* additional mixers to alc880_asus_mixer */
  594. static snd_kcontrol_new_t alc880_asus_w1v_mixer[] = {
  595. HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
  596. HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
  597. { } /* end */
  598. };
  599. /*
  600. * build control elements
  601. */
  602. static int alc_build_controls(struct hda_codec *codec)
  603. {
  604. struct alc_spec *spec = codec->spec;
  605. int err;
  606. int i;
  607. for (i = 0; i < spec->num_mixers; i++) {
  608. err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
  609. if (err < 0)
  610. return err;
  611. }
  612. if (spec->multiout.dig_out_nid) {
  613. err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
  614. if (err < 0)
  615. return err;
  616. }
  617. if (spec->dig_in_nid) {
  618. err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
  619. if (err < 0)
  620. return err;
  621. }
  622. return 0;
  623. }
  624. /*
  625. * initialize the codec volumes, etc
  626. */
  627. /*
  628. * generic initialization of ADC, input mixers and output mixers
  629. */
  630. static struct hda_verb alc880_volume_init_verbs[] = {
  631. /*
  632. * Unmute ADC0-2 and set the default input to mic-in
  633. */
  634. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  635. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  636. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  637. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  638. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  639. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  640. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  641. * mixer widget
  642. * Note: PASD motherboards uses the Line In 2 as the input for front panel
  643. * mic (mic 2)
  644. */
  645. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  646. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  647. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  648. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  649. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  650. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  651. /*
  652. * Set up output mixers (0x0c - 0x0f)
  653. */
  654. /* set vol=0 to output mixers */
  655. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  656. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  657. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  658. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  659. /* set up input amps for analog loopback */
  660. /* Amp Indices: DAC = 0, mixer = 1 */
  661. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  662. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  663. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  664. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  665. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  666. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  667. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  668. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  669. { }
  670. };
  671. /*
  672. * 3-stack pin configuration:
  673. * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
  674. */
  675. static struct hda_verb alc880_pin_3stack_init_verbs[] = {
  676. /*
  677. * preset connection lists of input pins
  678. * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
  679. */
  680. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  681. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  682. {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
  683. /*
  684. * Set pin mode and muting
  685. */
  686. /* set front pin widgets 0x14 for output */
  687. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  688. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  689. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  690. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  691. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  692. /* Mic2 (as headphone out) for HP output */
  693. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  694. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  695. /* Line In pin widget for input */
  696. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  697. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  698. /* Line2 (as front mic) pin widget for input and vref at 80% */
  699. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  700. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  701. /* CD pin widget for input */
  702. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  703. { }
  704. };
  705. /*
  706. * 5-stack pin configuration:
  707. * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
  708. * line-in/side = 0x1a, f-mic = 0x1b
  709. */
  710. static struct hda_verb alc880_pin_5stack_init_verbs[] = {
  711. /*
  712. * preset connection lists of input pins
  713. * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
  714. */
  715. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  716. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
  717. /*
  718. * Set pin mode and muting
  719. */
  720. /* set pin widgets 0x14-0x17 for output */
  721. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  722. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  723. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  724. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  725. /* unmute pins for output (no gain on this amp) */
  726. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  727. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  728. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  729. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  730. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  731. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  732. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  733. /* Mic2 (as headphone out) for HP output */
  734. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  735. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  736. /* Line In pin widget for input */
  737. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  738. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  739. /* Line2 (as front mic) pin widget for input and vref at 80% */
  740. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  741. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  742. /* CD pin widget for input */
  743. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  744. { }
  745. };
  746. /*
  747. * W810 pin configuration:
  748. * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
  749. */
  750. static struct hda_verb alc880_pin_w810_init_verbs[] = {
  751. /* hphone/speaker input selector: front DAC */
  752. {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
  753. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  754. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  755. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  756. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  757. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  758. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  759. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  760. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  761. { }
  762. };
  763. /*
  764. * Z71V pin configuration:
  765. * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
  766. */
  767. static struct hda_verb alc880_pin_z71v_init_verbs[] = {
  768. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  769. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  770. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  771. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  772. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  773. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  774. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  775. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  776. { }
  777. };
  778. /*
  779. * 6-stack pin configuration:
  780. * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18, f-mic = 0x19,
  781. * line = 0x1a, HP = 0x1b
  782. */
  783. static struct hda_verb alc880_pin_6stack_init_verbs[] = {
  784. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  785. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  786. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  787. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  788. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  789. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  790. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  791. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  792. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  793. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  794. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  795. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  796. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  797. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  798. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  799. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  800. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  801. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  802. { }
  803. };
  804. /* FIXME! */
  805. /*
  806. * F1734 pin configuration:
  807. * HP = 0x14, speaker-out = 0x15, mic = 0x18
  808. */
  809. static struct hda_verb alc880_pin_f1734_init_verbs[] = {
  810. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
  811. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
  812. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
  813. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  814. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  815. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  816. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  817. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  818. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  819. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  820. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  821. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  822. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  823. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  824. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  825. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  826. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  827. { }
  828. };
  829. /* FIXME! */
  830. /*
  831. * ASUS pin configuration:
  832. * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
  833. */
  834. static struct hda_verb alc880_pin_asus_init_verbs[] = {
  835. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
  836. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
  837. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
  838. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  839. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  840. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  841. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  842. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  843. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  844. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  845. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  846. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  847. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  848. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  849. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  850. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  851. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  852. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  853. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  854. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  855. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  856. { }
  857. };
  858. /* Enable GPIO mask and set output */
  859. static struct hda_verb alc880_gpio1_init_verbs[] = {
  860. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  861. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  862. {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
  863. };
  864. /* Enable GPIO mask and set output */
  865. static struct hda_verb alc880_gpio2_init_verbs[] = {
  866. {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
  867. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
  868. {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
  869. };
  870. /*
  871. */
  872. static int alc_init(struct hda_codec *codec)
  873. {
  874. struct alc_spec *spec = codec->spec;
  875. unsigned int i;
  876. for (i = 0; i < spec->num_init_verbs; i++)
  877. snd_hda_sequence_write(codec, spec->init_verbs[i]);
  878. return 0;
  879. }
  880. #ifdef CONFIG_PM
  881. /*
  882. * resume
  883. */
  884. static int alc_resume(struct hda_codec *codec)
  885. {
  886. struct alc_spec *spec = codec->spec;
  887. int i;
  888. alc_init(codec);
  889. for (i = 0; i < spec->num_mixers; i++)
  890. snd_hda_resume_ctls(codec, spec->mixers[i]);
  891. if (spec->multiout.dig_out_nid)
  892. snd_hda_resume_spdif_out(codec);
  893. if (spec->dig_in_nid)
  894. snd_hda_resume_spdif_in(codec);
  895. return 0;
  896. }
  897. #endif
  898. /*
  899. * Analog playback callbacks
  900. */
  901. static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
  902. struct hda_codec *codec,
  903. snd_pcm_substream_t *substream)
  904. {
  905. struct alc_spec *spec = codec->spec;
  906. return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
  907. }
  908. static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  909. struct hda_codec *codec,
  910. unsigned int stream_tag,
  911. unsigned int format,
  912. snd_pcm_substream_t *substream)
  913. {
  914. struct alc_spec *spec = codec->spec;
  915. return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag,
  916. format, substream);
  917. }
  918. static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
  919. struct hda_codec *codec,
  920. snd_pcm_substream_t *substream)
  921. {
  922. struct alc_spec *spec = codec->spec;
  923. return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
  924. }
  925. /*
  926. * Digital out
  927. */
  928. static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
  929. struct hda_codec *codec,
  930. snd_pcm_substream_t *substream)
  931. {
  932. struct alc_spec *spec = codec->spec;
  933. return snd_hda_multi_out_dig_open(codec, &spec->multiout);
  934. }
  935. static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
  936. struct hda_codec *codec,
  937. snd_pcm_substream_t *substream)
  938. {
  939. struct alc_spec *spec = codec->spec;
  940. return snd_hda_multi_out_dig_close(codec, &spec->multiout);
  941. }
  942. /*
  943. * Analog capture
  944. */
  945. static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
  946. struct hda_codec *codec,
  947. unsigned int stream_tag,
  948. unsigned int format,
  949. snd_pcm_substream_t *substream)
  950. {
  951. struct alc_spec *spec = codec->spec;
  952. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
  953. stream_tag, 0, format);
  954. return 0;
  955. }
  956. static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
  957. struct hda_codec *codec,
  958. snd_pcm_substream_t *substream)
  959. {
  960. struct alc_spec *spec = codec->spec;
  961. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], 0, 0, 0);
  962. return 0;
  963. }
  964. /*
  965. */
  966. static struct hda_pcm_stream alc880_pcm_analog_playback = {
  967. .substreams = 1,
  968. .channels_min = 2,
  969. .channels_max = 8,
  970. /* NID is set in alc_build_pcms */
  971. .ops = {
  972. .open = alc880_playback_pcm_open,
  973. .prepare = alc880_playback_pcm_prepare,
  974. .cleanup = alc880_playback_pcm_cleanup
  975. },
  976. };
  977. static struct hda_pcm_stream alc880_pcm_analog_capture = {
  978. .substreams = 2,
  979. .channels_min = 2,
  980. .channels_max = 2,
  981. /* NID is set in alc_build_pcms */
  982. .ops = {
  983. .prepare = alc880_capture_pcm_prepare,
  984. .cleanup = alc880_capture_pcm_cleanup
  985. },
  986. };
  987. static struct hda_pcm_stream alc880_pcm_digital_playback = {
  988. .substreams = 1,
  989. .channels_min = 2,
  990. .channels_max = 2,
  991. /* NID is set in alc_build_pcms */
  992. .ops = {
  993. .open = alc880_dig_playback_pcm_open,
  994. .close = alc880_dig_playback_pcm_close
  995. },
  996. };
  997. static struct hda_pcm_stream alc880_pcm_digital_capture = {
  998. .substreams = 1,
  999. .channels_min = 2,
  1000. .channels_max = 2,
  1001. /* NID is set in alc_build_pcms */
  1002. };
  1003. static int alc_build_pcms(struct hda_codec *codec)
  1004. {
  1005. struct alc_spec *spec = codec->spec;
  1006. struct hda_pcm *info = spec->pcm_rec;
  1007. int i;
  1008. codec->num_pcms = 1;
  1009. codec->pcm_info = info;
  1010. info->name = spec->stream_name_analog;
  1011. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
  1012. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
  1013. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
  1014. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
  1015. info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
  1016. for (i = 0; i < spec->num_channel_mode; i++) {
  1017. if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
  1018. info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
  1019. }
  1020. }
  1021. if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
  1022. codec->num_pcms++;
  1023. info++;
  1024. info->name = spec->stream_name_digital;
  1025. if (spec->multiout.dig_out_nid) {
  1026. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
  1027. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
  1028. }
  1029. if (spec->dig_in_nid) {
  1030. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
  1031. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
  1032. }
  1033. }
  1034. return 0;
  1035. }
  1036. static void alc_free(struct hda_codec *codec)
  1037. {
  1038. struct alc_spec *spec = codec->spec;
  1039. unsigned int i;
  1040. if (! spec)
  1041. return;
  1042. if (spec->kctl_alloc) {
  1043. for (i = 0; i < spec->num_kctl_used; i++)
  1044. kfree(spec->kctl_alloc[i].name);
  1045. kfree(spec->kctl_alloc);
  1046. }
  1047. kfree(spec);
  1048. }
  1049. /*
  1050. */
  1051. static struct hda_codec_ops alc_patch_ops = {
  1052. .build_controls = alc_build_controls,
  1053. .build_pcms = alc_build_pcms,
  1054. .init = alc_init,
  1055. .free = alc_free,
  1056. #ifdef CONFIG_PM
  1057. .resume = alc_resume,
  1058. #endif
  1059. };
  1060. /*
  1061. * Test configuration for debugging
  1062. *
  1063. * Almost all inputs/outputs are enabled. I/O pins can be configured via
  1064. * enum controls.
  1065. */
  1066. #ifdef CONFIG_SND_DEBUG
  1067. static hda_nid_t alc880_test_dac_nids[4] = {
  1068. 0x02, 0x03, 0x04, 0x05
  1069. };
  1070. static struct hda_input_mux alc880_test_capture_source = {
  1071. .num_items = 5,
  1072. .items = {
  1073. { "In-1", 0x0 },
  1074. { "In-2", 0x1 },
  1075. { "In-3", 0x2 },
  1076. { "In-4", 0x3 },
  1077. { "CD", 0x4 },
  1078. },
  1079. };
  1080. static struct alc_channel_mode alc880_test_modes[4] = {
  1081. { 2, NULL },
  1082. { 4, NULL },
  1083. { 6, NULL },
  1084. { 8, NULL },
  1085. };
  1086. static int alc_test_pin_ctl_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)
  1087. {
  1088. static char *texts[] = {
  1089. "N/A", "Line Out", "HP Out",
  1090. "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
  1091. };
  1092. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  1093. uinfo->count = 1;
  1094. uinfo->value.enumerated.items = 8;
  1095. if (uinfo->value.enumerated.item >= 8)
  1096. uinfo->value.enumerated.item = 7;
  1097. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  1098. return 0;
  1099. }
  1100. static int alc_test_pin_ctl_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
  1101. {
  1102. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  1103. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  1104. unsigned int pin_ctl, item = 0;
  1105. pin_ctl = snd_hda_codec_read(codec, nid, 0,
  1106. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  1107. if (pin_ctl & AC_PINCTL_OUT_EN) {
  1108. if (pin_ctl & AC_PINCTL_HP_EN)
  1109. item = 2;
  1110. else
  1111. item = 1;
  1112. } else if (pin_ctl & AC_PINCTL_IN_EN) {
  1113. switch (pin_ctl & AC_PINCTL_VREFEN) {
  1114. case AC_PINCTL_VREF_HIZ: item = 3; break;
  1115. case AC_PINCTL_VREF_50: item = 4; break;
  1116. case AC_PINCTL_VREF_GRD: item = 5; break;
  1117. case AC_PINCTL_VREF_80: item = 6; break;
  1118. case AC_PINCTL_VREF_100: item = 7; break;
  1119. }
  1120. }
  1121. ucontrol->value.enumerated.item[0] = item;
  1122. return 0;
  1123. }
  1124. static int alc_test_pin_ctl_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
  1125. {
  1126. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  1127. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  1128. static unsigned int ctls[] = {
  1129. 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
  1130. AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
  1131. AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
  1132. AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
  1133. AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
  1134. AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
  1135. };
  1136. unsigned int old_ctl, new_ctl;
  1137. old_ctl = snd_hda_codec_read(codec, nid, 0,
  1138. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  1139. new_ctl = ctls[ucontrol->value.enumerated.item[0]];
  1140. if (old_ctl != new_ctl) {
  1141. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, new_ctl);
  1142. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  1143. ucontrol->value.enumerated.item[0] >= 3 ? 0xb080 : 0xb000);
  1144. return 1;
  1145. }
  1146. return 0;
  1147. }
  1148. static int alc_test_pin_src_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)
  1149. {
  1150. static char *texts[] = {
  1151. "Front", "Surround", "CLFE", "Side"
  1152. };
  1153. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  1154. uinfo->count = 1;
  1155. uinfo->value.enumerated.items = 4;
  1156. if (uinfo->value.enumerated.item >= 4)
  1157. uinfo->value.enumerated.item = 3;
  1158. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  1159. return 0;
  1160. }
  1161. static int alc_test_pin_src_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
  1162. {
  1163. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  1164. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  1165. unsigned int sel;
  1166. sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
  1167. ucontrol->value.enumerated.item[0] = sel & 3;
  1168. return 0;
  1169. }
  1170. static int alc_test_pin_src_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
  1171. {
  1172. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  1173. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  1174. unsigned int sel;
  1175. sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
  1176. if (ucontrol->value.enumerated.item[0] != sel) {
  1177. sel = ucontrol->value.enumerated.item[0] & 3;
  1178. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, sel);
  1179. return 1;
  1180. }
  1181. return 0;
  1182. }
  1183. #define PIN_CTL_TEST(xname,nid) { \
  1184. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  1185. .name = xname, \
  1186. .info = alc_test_pin_ctl_info, \
  1187. .get = alc_test_pin_ctl_get, \
  1188. .put = alc_test_pin_ctl_put, \
  1189. .private_value = nid \
  1190. }
  1191. #define PIN_SRC_TEST(xname,nid) { \
  1192. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  1193. .name = xname, \
  1194. .info = alc_test_pin_src_info, \
  1195. .get = alc_test_pin_src_get, \
  1196. .put = alc_test_pin_src_put, \
  1197. .private_value = nid \
  1198. }
  1199. static snd_kcontrol_new_t alc880_test_mixer[] = {
  1200. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1201. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1202. HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
  1203. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  1204. ALC_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  1205. ALC_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  1206. ALC_BIND_MUTE("CLFE Playback Volume", 0x0e, 2, HDA_INPUT),
  1207. ALC_BIND_MUTE("Side Playback Volume", 0x0f, 2, HDA_INPUT),
  1208. PIN_CTL_TEST("Front Pin Mode", 0x14),
  1209. PIN_CTL_TEST("Surround Pin Mode", 0x15),
  1210. PIN_CTL_TEST("CLFE Pin Mode", 0x16),
  1211. PIN_CTL_TEST("Side Pin Mode", 0x17),
  1212. PIN_CTL_TEST("In-1 Pin Mode", 0x18),
  1213. PIN_CTL_TEST("In-2 Pin Mode", 0x19),
  1214. PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
  1215. PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
  1216. PIN_SRC_TEST("In-1 Pin Source", 0x18),
  1217. PIN_SRC_TEST("In-2 Pin Source", 0x19),
  1218. PIN_SRC_TEST("In-3 Pin Source", 0x1a),
  1219. PIN_SRC_TEST("In-4 Pin Source", 0x1b),
  1220. HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1221. HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1222. HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1223. HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1224. HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
  1225. HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
  1226. HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
  1227. HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
  1228. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
  1229. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
  1230. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  1231. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  1232. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  1233. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  1234. {
  1235. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1236. .name = "Input Source",
  1237. .count = 2,
  1238. .info = alc_mux_enum_info,
  1239. .get = alc_mux_enum_get,
  1240. .put = alc_mux_enum_put,
  1241. },
  1242. {
  1243. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1244. .name = "Channel Mode",
  1245. .info = alc880_ch_mode_info,
  1246. .get = alc880_ch_mode_get,
  1247. .put = alc880_ch_mode_put,
  1248. },
  1249. { } /* end */
  1250. };
  1251. static struct hda_verb alc880_test_init_verbs[] = {
  1252. /* Unmute inputs of 0x0c - 0x0f */
  1253. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1254. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1255. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1256. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1257. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1258. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1259. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1260. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1261. /* Vol output for 0x0c-0x0f */
  1262. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1263. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1264. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1265. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1266. /* Set output pins 0x14-0x17 */
  1267. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1268. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1269. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1270. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1271. /* Unmute output pins 0x14-0x17 */
  1272. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1273. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1274. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1275. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1276. /* Set input pins 0x18-0x1c */
  1277. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1278. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1279. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1280. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1281. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1282. /* Mute input pins 0x18-0x1b */
  1283. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1284. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1285. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1286. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1287. /* ADC set up */
  1288. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1289. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  1290. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1291. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  1292. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1293. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  1294. /* Analog input/passthru */
  1295. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1296. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1297. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  1298. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  1299. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  1300. { }
  1301. };
  1302. #endif
  1303. /*
  1304. */
  1305. static struct hda_board_config alc880_cfg_tbl[] = {
  1306. /* Back 3 jack, front 2 jack */
  1307. { .modelname = "3stack", .config = ALC880_3ST },
  1308. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe200, .config = ALC880_3ST },
  1309. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe201, .config = ALC880_3ST },
  1310. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe202, .config = ALC880_3ST },
  1311. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe203, .config = ALC880_3ST },
  1312. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe204, .config = ALC880_3ST },
  1313. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe205, .config = ALC880_3ST },
  1314. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe206, .config = ALC880_3ST },
  1315. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe207, .config = ALC880_3ST },
  1316. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe208, .config = ALC880_3ST },
  1317. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe209, .config = ALC880_3ST },
  1318. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20a, .config = ALC880_3ST },
  1319. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20b, .config = ALC880_3ST },
  1320. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20c, .config = ALC880_3ST },
  1321. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20d, .config = ALC880_3ST },
  1322. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20e, .config = ALC880_3ST },
  1323. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20f, .config = ALC880_3ST },
  1324. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe210, .config = ALC880_3ST },
  1325. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe211, .config = ALC880_3ST },
  1326. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe214, .config = ALC880_3ST },
  1327. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe302, .config = ALC880_3ST },
  1328. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe303, .config = ALC880_3ST },
  1329. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe304, .config = ALC880_3ST },
  1330. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe306, .config = ALC880_3ST },
  1331. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe307, .config = ALC880_3ST },
  1332. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe404, .config = ALC880_3ST },
  1333. { .pci_subvendor = 0x8086, .pci_subdevice = 0xa101, .config = ALC880_3ST },
  1334. { .pci_subvendor = 0x107b, .pci_subdevice = 0x3031, .config = ALC880_3ST },
  1335. { .pci_subvendor = 0x107b, .pci_subdevice = 0x4036, .config = ALC880_3ST },
  1336. { .pci_subvendor = 0x107b, .pci_subdevice = 0x4037, .config = ALC880_3ST },
  1337. { .pci_subvendor = 0x107b, .pci_subdevice = 0x4038, .config = ALC880_3ST },
  1338. { .pci_subvendor = 0x107b, .pci_subdevice = 0x4040, .config = ALC880_3ST },
  1339. { .pci_subvendor = 0x107b, .pci_subdevice = 0x4041, .config = ALC880_3ST },
  1340. /* Back 3 jack, front 2 jack (Internal add Aux-In) */
  1341. { .pci_subvendor = 0x1025, .pci_subdevice = 0xe310, .config = ALC880_3ST },
  1342. { .pci_subvendor = 0x104d, .pci_subdevice = 0x81d6, .config = ALC880_3ST },
  1343. /* Back 3 jack plus 1 SPDIF out jack, front 2 jack */
  1344. { .modelname = "3stack-digout", .config = ALC880_3ST_DIG },
  1345. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe308, .config = ALC880_3ST_DIG },
  1346. /* Back 3 jack plus 1 SPDIF out jack, front 2 jack (Internal add Aux-In)*/
  1347. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe305, .config = ALC880_3ST_DIG },
  1348. { .pci_subvendor = 0x8086, .pci_subdevice = 0xd402, .config = ALC880_3ST_DIG },
  1349. { .pci_subvendor = 0x1025, .pci_subdevice = 0xe309, .config = ALC880_3ST_DIG },
  1350. /* Back 5 jack, front 2 jack */
  1351. { .modelname = "5stack", .config = ALC880_5ST },
  1352. { .pci_subvendor = 0x107b, .pci_subdevice = 0x3033, .config = ALC880_5ST },
  1353. { .pci_subvendor = 0x107b, .pci_subdevice = 0x4039, .config = ALC880_5ST },
  1354. { .pci_subvendor = 0x107b, .pci_subdevice = 0x3032, .config = ALC880_5ST },
  1355. { .pci_subvendor = 0x103c, .pci_subdevice = 0x2a09, .config = ALC880_5ST },
  1356. { .pci_subvendor = 0x1043, .pci_subdevice = 0x814e, .config = ALC880_5ST },
  1357. /* Back 5 jack plus 1 SPDIF out jack, front 2 jack */
  1358. { .modelname = "5stack-digout", .config = ALC880_5ST_DIG },
  1359. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe224, .config = ALC880_5ST_DIG },
  1360. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe400, .config = ALC880_5ST_DIG },
  1361. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe401, .config = ALC880_5ST_DIG },
  1362. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe402, .config = ALC880_5ST_DIG },
  1363. { .pci_subvendor = 0x8086, .pci_subdevice = 0xd400, .config = ALC880_5ST_DIG },
  1364. { .pci_subvendor = 0x8086, .pci_subdevice = 0xd401, .config = ALC880_5ST_DIG },
  1365. { .pci_subvendor = 0x8086, .pci_subdevice = 0xa100, .config = ALC880_5ST_DIG },
  1366. { .pci_subvendor = 0x1565, .pci_subdevice = 0x8202, .config = ALC880_5ST_DIG },
  1367. { .pci_subvendor = 0x1019, .pci_subdevice = 0xa880, .config = ALC880_5ST_DIG },
  1368. { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_5ST_DIG },
  1369. { .pci_subvendor = 0x1695, .pci_subdevice = 0x400d, .config = ALC880_5ST_DIG },
  1370. { .pci_subvendor = 0x0000, .pci_subdevice = 0x8086, .config = ALC880_5ST_DIG },
  1371. { .modelname = "w810", .config = ALC880_W810 },
  1372. { .pci_subvendor = 0x161f, .pci_subdevice = 0x203d, .config = ALC880_W810 },
  1373. { .modelname = "z71v", .config = ALC880_Z71V },
  1374. { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_Z71V },
  1375. { .modelname = "6statack-digout", .config = ALC880_6ST_DIG },
  1376. { .pci_subvendor = 0x2668, .pci_subdevice = 0x8086, .config = ALC880_6ST_DIG },
  1377. { .pci_subvendor = 0x8086, .pci_subdevice = 0x2668, .config = ALC880_6ST_DIG },
  1378. { .pci_subvendor = 0x1462, .pci_subdevice = 0x1150, .config = ALC880_6ST_DIG },
  1379. { .pci_subvendor = 0xe803, .pci_subdevice = 0x1019, .config = ALC880_6ST_DIG },
  1380. { .modelname = "asus", .config = ALC880_ASUS },
  1381. { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_ASUS_DIG },
  1382. { .pci_subvendor = 0x1043, .pci_subdevice = 0x1973, .config = ALC880_ASUS_DIG },
  1383. { .pci_subvendor = 0x1043, .pci_subdevice = 0x19b3, .config = ALC880_ASUS_DIG },
  1384. { .pci_subvendor = 0x1043, .pci_subdevice = 0x1113, .config = ALC880_ASUS_DIG },
  1385. { .pci_subvendor = 0x1043, .pci_subdevice = 0x1993, .config = ALC880_ASUS },
  1386. { .pci_subvendor = 0x1043, .pci_subdevice = 0x10c3, .config = ALC880_ASUS_DIG },
  1387. { .pci_subvendor = 0x1043, .pci_subdevice = 0x1133, .config = ALC880_ASUS },
  1388. { .pci_subvendor = 0x1043, .pci_subdevice = 0x1123, .config = ALC880_ASUS_DIG },
  1389. { .pci_subvendor = 0x1043, .pci_subdevice = 0x1143, .config = ALC880_ASUS },
  1390. { .pci_subvendor = 0x1043, .pci_subdevice = 0x10b3, .config = ALC880_ASUS_W1V },
  1391. { .modelname = "uniwill", .config = ALC880_UNIWILL_DIG },
  1392. { .pci_subvendor = 0x1584, .pci_subdevice = 0x9050, .config = ALC880_UNIWILL_DIG },
  1393. { .modelname = "F1734", .config = ALC880_F1734 },
  1394. { .pci_subvendor = 0x1734, .pci_subdevice = 0x107c, .config = ALC880_F1734 },
  1395. #ifdef CONFIG_SND_DEBUG
  1396. { .modelname = "test", .config = ALC880_TEST },
  1397. #endif
  1398. {}
  1399. };
  1400. /*
  1401. * configuration template - to be copied to the spec instance
  1402. */
  1403. struct alc_config_preset {
  1404. snd_kcontrol_new_t *mixers[4];
  1405. const struct hda_verb *init_verbs[4];
  1406. unsigned int num_dacs;
  1407. hda_nid_t *dac_nids;
  1408. hda_nid_t dig_out_nid; /* optional */
  1409. hda_nid_t hp_nid; /* optional */
  1410. unsigned int num_adc_nids;
  1411. hda_nid_t *adc_nids;
  1412. unsigned int num_channel_mode;
  1413. const struct alc_channel_mode *channel_mode;
  1414. const struct hda_input_mux *input_mux;
  1415. };
  1416. static struct alc_config_preset alc880_presets[] = {
  1417. [ALC880_3ST] = {
  1418. .mixers = { alc880_three_stack_mixer },
  1419. .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
  1420. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  1421. .dac_nids = alc880_dac_nids,
  1422. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  1423. .channel_mode = alc880_threestack_modes,
  1424. .input_mux = &alc880_capture_source,
  1425. },
  1426. [ALC880_3ST_DIG] = {
  1427. .mixers = { alc880_three_stack_mixer },
  1428. .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
  1429. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  1430. .dac_nids = alc880_dac_nids,
  1431. .dig_out_nid = ALC880_DIGOUT_NID,
  1432. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  1433. .channel_mode = alc880_threestack_modes,
  1434. .input_mux = &alc880_capture_source,
  1435. },
  1436. [ALC880_5ST] = {
  1437. .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer},
  1438. .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
  1439. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  1440. .dac_nids = alc880_dac_nids,
  1441. .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
  1442. .channel_mode = alc880_fivestack_modes,
  1443. .input_mux = &alc880_capture_source,
  1444. },
  1445. [ALC880_5ST_DIG] = {
  1446. .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer },
  1447. .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
  1448. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  1449. .dac_nids = alc880_dac_nids,
  1450. .dig_out_nid = ALC880_DIGOUT_NID,
  1451. .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
  1452. .channel_mode = alc880_fivestack_modes,
  1453. .input_mux = &alc880_capture_source,
  1454. },
  1455. [ALC880_6ST_DIG] = {
  1456. .mixers = { alc880_six_stack_mixer },
  1457. .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs },
  1458. .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
  1459. .dac_nids = alc880_6st_dac_nids,
  1460. .dig_out_nid = ALC880_DIGOUT_NID,
  1461. .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
  1462. .channel_mode = alc880_sixstack_modes,
  1463. .input_mux = &alc880_6stack_capture_source,
  1464. },
  1465. [ALC880_W810] = {
  1466. .mixers = { alc880_w810_base_mixer },
  1467. .init_verbs = { alc880_volume_init_verbs, alc880_pin_w810_init_verbs },
  1468. .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
  1469. .dac_nids = alc880_w810_dac_nids,
  1470. .dig_out_nid = ALC880_DIGOUT_NID,
  1471. .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
  1472. .channel_mode = alc880_w810_modes,
  1473. .input_mux = &alc880_capture_source,
  1474. },
  1475. [ALC880_Z71V] = {
  1476. .mixers = { alc880_z71v_mixer },
  1477. .init_verbs = { alc880_volume_init_verbs, alc880_pin_z71v_init_verbs,
  1478. alc880_gpio2_init_verbs },
  1479. .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
  1480. .dac_nids = alc880_z71v_dac_nids,
  1481. .dig_out_nid = ALC880_DIGOUT_NID,
  1482. .hp_nid = 0x03,
  1483. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  1484. .channel_mode = alc880_2_jack_modes,
  1485. .input_mux = &alc880_capture_source,
  1486. },
  1487. [ALC880_F1734] = {
  1488. .mixers = { alc880_f1734_mixer },
  1489. .init_verbs = { alc880_volume_init_verbs, alc880_pin_f1734_init_verbs },
  1490. .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
  1491. .dac_nids = alc880_f1734_dac_nids,
  1492. .hp_nid = 0x02,
  1493. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  1494. .channel_mode = alc880_2_jack_modes,
  1495. .input_mux = &alc880_capture_source,
  1496. },
  1497. [ALC880_ASUS] = {
  1498. .mixers = { alc880_asus_mixer },
  1499. .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
  1500. alc880_gpio1_init_verbs },
  1501. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  1502. .dac_nids = alc880_asus_dac_nids,
  1503. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  1504. .channel_mode = alc880_asus_modes,
  1505. .input_mux = &alc880_capture_source,
  1506. },
  1507. [ALC880_ASUS_DIG] = {
  1508. .mixers = { alc880_asus_mixer },
  1509. .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
  1510. alc880_gpio1_init_verbs },
  1511. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  1512. .dac_nids = alc880_asus_dac_nids,
  1513. .dig_out_nid = ALC880_DIGOUT_NID,
  1514. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  1515. .channel_mode = alc880_asus_modes,
  1516. .input_mux = &alc880_capture_source,
  1517. },
  1518. [ALC880_ASUS_W1V] = {
  1519. .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
  1520. .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
  1521. alc880_gpio1_init_verbs },
  1522. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  1523. .dac_nids = alc880_asus_dac_nids,
  1524. .dig_out_nid = ALC880_DIGOUT_NID,
  1525. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  1526. .channel_mode = alc880_asus_modes,
  1527. .input_mux = &alc880_capture_source,
  1528. },
  1529. [ALC880_UNIWILL_DIG] = {
  1530. .mixers = { alc880_asus_mixer },
  1531. .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs },
  1532. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  1533. .dac_nids = alc880_asus_dac_nids,
  1534. .dig_out_nid = ALC880_DIGOUT_NID,
  1535. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  1536. .channel_mode = alc880_asus_modes,
  1537. .input_mux = &alc880_capture_source,
  1538. },
  1539. #ifdef CONFIG_SND_DEBUG
  1540. [ALC880_TEST] = {
  1541. .mixers = { alc880_test_mixer },
  1542. .init_verbs = { alc880_test_init_verbs },
  1543. .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
  1544. .dac_nids = alc880_test_dac_nids,
  1545. .dig_out_nid = ALC880_DIGOUT_NID,
  1546. .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
  1547. .channel_mode = alc880_test_modes,
  1548. .input_mux = &alc880_test_capture_source,
  1549. },
  1550. #endif
  1551. };
  1552. /*
  1553. * Automatic parse of I/O pins from the BIOS configuration
  1554. */
  1555. #define NUM_CONTROL_ALLOC 32
  1556. #define NUM_VERB_ALLOC 32
  1557. enum {
  1558. ALC_CTL_WIDGET_VOL,
  1559. ALC_CTL_WIDGET_MUTE,
  1560. ALC_CTL_BIND_MUTE,
  1561. };
  1562. static snd_kcontrol_new_t alc880_control_templates[] = {
  1563. HDA_CODEC_VOLUME(NULL, 0, 0, 0),
  1564. HDA_CODEC_MUTE(NULL, 0, 0, 0),
  1565. ALC_BIND_MUTE(NULL, 0, 0, 0),
  1566. };
  1567. /* add dynamic controls */
  1568. static int add_control(struct alc_spec *spec, int type, const char *name, unsigned long val)
  1569. {
  1570. snd_kcontrol_new_t *knew;
  1571. if (spec->num_kctl_used >= spec->num_kctl_alloc) {
  1572. int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
  1573. knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
  1574. if (! knew)
  1575. return -ENOMEM;
  1576. if (spec->kctl_alloc) {
  1577. memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
  1578. kfree(spec->kctl_alloc);
  1579. }
  1580. spec->kctl_alloc = knew;
  1581. spec->num_kctl_alloc = num;
  1582. }
  1583. knew = &spec->kctl_alloc[spec->num_kctl_used];
  1584. *knew = alc880_control_templates[type];
  1585. knew->name = kstrdup(name, GFP_KERNEL);
  1586. if (! knew->name)
  1587. return -ENOMEM;
  1588. knew->private_value = val;
  1589. spec->num_kctl_used++;
  1590. return 0;
  1591. }
  1592. #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
  1593. #define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
  1594. #define alc880_is_multi_pin(nid) ((nid) >= 0x18)
  1595. #define alc880_multi_pin_idx(nid) ((nid) - 0x18)
  1596. #define alc880_is_input_pin(nid) ((nid) >= 0x18)
  1597. #define alc880_input_pin_idx(nid) ((nid) - 0x18)
  1598. #define alc880_idx_to_dac(nid) ((nid) + 0x02)
  1599. #define alc880_dac_to_idx(nid) ((nid) - 0x02)
  1600. #define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
  1601. #define alc880_idx_to_selector(nid) ((nid) + 0x10)
  1602. #define ALC880_PIN_CD_NID 0x1c
  1603. /* fill in the dac_nids table from the parsed pin configuration */
  1604. static int alc880_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
  1605. {
  1606. hda_nid_t nid;
  1607. int assigned[4];
  1608. int i, j;
  1609. memset(assigned, 0, sizeof(assigned));
  1610. /* check the pins hardwired to audio widget */
  1611. for (i = 0; i < cfg->line_outs; i++) {
  1612. nid = cfg->line_out_pins[i];
  1613. if (alc880_is_fixed_pin(nid)) {
  1614. int idx = alc880_fixed_pin_idx(nid);
  1615. spec->multiout.dac_nids[i] = alc880_dac_to_idx(idx);
  1616. assigned[idx] = 1;
  1617. }
  1618. }
  1619. /* left pins can be connect to any audio widget */
  1620. for (i = 0; i < cfg->line_outs; i++) {
  1621. nid = cfg->line_out_pins[i];
  1622. if (alc880_is_fixed_pin(nid))
  1623. continue;
  1624. /* search for an empty channel */
  1625. for (j = 0; j < cfg->line_outs; j++) {
  1626. if (! assigned[j]) {
  1627. spec->multiout.dac_nids[i] = alc880_idx_to_dac(j);
  1628. assigned[j] = 1;
  1629. break;
  1630. }
  1631. }
  1632. }
  1633. spec->multiout.num_dacs = cfg->line_outs;
  1634. return 0;
  1635. }
  1636. /* add playback controls from the parsed DAC table */
  1637. static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
  1638. {
  1639. char name[32];
  1640. static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
  1641. hda_nid_t nid;
  1642. int i, err;
  1643. for (i = 0; i < cfg->line_outs; i++) {
  1644. if (! spec->multiout.dac_nids[i])
  1645. continue;
  1646. nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
  1647. if (i == 2) {
  1648. /* Center/LFE */
  1649. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Center Playback Volume",
  1650. HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
  1651. return err;
  1652. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "LFE Playback Volume",
  1653. HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
  1654. return err;
  1655. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch",
  1656. HDA_COMPOSE_AMP_VAL(nid, 1, 2, HDA_INPUT))) < 0)
  1657. return err;
  1658. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch",
  1659. HDA_COMPOSE_AMP_VAL(nid, 2, 2, HDA_INPUT))) < 0)
  1660. return err;
  1661. } else {
  1662. sprintf(name, "%s Playback Volume", chname[i]);
  1663. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  1664. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  1665. return err;
  1666. sprintf(name, "%s Playback Switch", chname[i]);
  1667. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  1668. HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
  1669. return err;
  1670. }
  1671. }
  1672. return 0;
  1673. }
  1674. /* add playback controls for HP output */
  1675. static int alc880_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
  1676. {
  1677. hda_nid_t nid;
  1678. int err;
  1679. if (! pin)
  1680. return 0;
  1681. if (alc880_is_fixed_pin(pin)) {
  1682. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  1683. if (! spec->multiout.dac_nids[0]) {
  1684. /* use this as the primary output */
  1685. spec->multiout.dac_nids[0] = nid;
  1686. if (! spec->multiout.num_dacs)
  1687. spec->multiout.num_dacs = 1;
  1688. } else
  1689. /* specify the DAC as the extra HP output */
  1690. spec->multiout.hp_nid = nid;
  1691. /* control HP volume/switch on the output mixer amp */
  1692. nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
  1693. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Headphone Playback Volume",
  1694. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  1695. return err;
  1696. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Headphone Playback Switch",
  1697. HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
  1698. return err;
  1699. } else if (alc880_is_multi_pin(pin)) {
  1700. /* set manual connection */
  1701. if (! spec->multiout.dac_nids[0]) {
  1702. /* use this as the primary output */
  1703. spec->multiout.dac_nids[0] = alc880_idx_to_dac(alc880_multi_pin_idx(pin));
  1704. if (! spec->multiout.num_dacs)
  1705. spec->multiout.num_dacs = 1;
  1706. }
  1707. /* we have only a switch on HP-out PIN */
  1708. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
  1709. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT))) < 0)
  1710. return err;
  1711. }
  1712. return 0;
  1713. }
  1714. /* create input playback/capture controls for the given pin */
  1715. static int new_analog_input(struct alc_spec *spec, hda_nid_t pin, const char *ctlname)
  1716. {
  1717. char name[32];
  1718. int err, idx;
  1719. sprintf(name, "%s Playback Volume", ctlname);
  1720. idx = alc880_input_pin_idx(pin);
  1721. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  1722. HDA_COMPOSE_AMP_VAL(0x0b, 3, idx, HDA_INPUT))) < 0)
  1723. return err;
  1724. sprintf(name, "%s Playback Switch", ctlname);
  1725. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  1726. HDA_COMPOSE_AMP_VAL(0x0b, 3, idx, HDA_INPUT))) < 0)
  1727. return err;
  1728. return 0;
  1729. }
  1730. /* create playback/capture controls for input pins */
  1731. static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
  1732. {
  1733. static char *labels[AUTO_PIN_LAST] = {
  1734. "Mic", "Front Mic", "Line", "Front Line", "CD", "Aux"
  1735. };
  1736. struct hda_input_mux *imux = &spec->private_imux;
  1737. int i, err;
  1738. for (i = 0; i < AUTO_PIN_LAST; i++) {
  1739. if (alc880_is_input_pin(cfg->input_pins[i])) {
  1740. err = new_analog_input(spec, cfg->input_pins[i], labels[i]);
  1741. if (err < 0)
  1742. return err;
  1743. imux->items[imux->num_items].label = labels[i];
  1744. imux->items[imux->num_items].index = alc880_input_pin_idx(cfg->input_pins[i]);
  1745. imux->num_items++;
  1746. }
  1747. }
  1748. return 0;
  1749. }
  1750. static void alc880_auto_set_output_and_unmute(struct hda_codec *codec, hda_nid_t nid, int pin_type,
  1751. int dac_idx)
  1752. {
  1753. /* set as output */
  1754. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  1755. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  1756. /* need the manual connection? */
  1757. if (alc880_is_multi_pin(nid)) {
  1758. struct alc_spec *spec = codec->spec;
  1759. int idx = alc880_multi_pin_idx(nid);
  1760. snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
  1761. AC_VERB_SET_CONNECT_SEL,
  1762. alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
  1763. }
  1764. }
  1765. static void alc880_auto_init_multi_out(struct hda_codec *codec)
  1766. {
  1767. struct alc_spec *spec = codec->spec;
  1768. int i;
  1769. for (i = 0; i < spec->autocfg.line_outs; i++) {
  1770. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  1771. alc880_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
  1772. }
  1773. }
  1774. static void alc880_auto_init_hp_out(struct hda_codec *codec)
  1775. {
  1776. struct alc_spec *spec = codec->spec;
  1777. hda_nid_t pin;
  1778. pin = spec->autocfg.hp_pin;
  1779. if (pin) /* connect to front */
  1780. alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  1781. }
  1782. static void alc880_auto_init_analog_input(struct hda_codec *codec)
  1783. {
  1784. struct alc_spec *spec = codec->spec;
  1785. int i;
  1786. for (i = 0; i < AUTO_PIN_LAST; i++) {
  1787. hda_nid_t nid = spec->autocfg.input_pins[i];
  1788. if (alc880_is_input_pin(nid)) {
  1789. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  1790. i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
  1791. if (nid != ALC880_PIN_CD_NID)
  1792. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  1793. AMP_OUT_MUTE);
  1794. }
  1795. }
  1796. }
  1797. /* parse the BIOS configuration and set up the alc_spec */
  1798. /* return 1 if successful, 0 if the proper config is not found, or a negative error code */
  1799. static int alc880_parse_auto_config(struct hda_codec *codec)
  1800. {
  1801. struct alc_spec *spec = codec->spec;
  1802. int err;
  1803. if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg)) < 0)
  1804. return err;
  1805. if ((err = alc880_auto_fill_dac_nids(spec, &spec->autocfg)) < 0)
  1806. return err;
  1807. if (! spec->autocfg.line_outs && ! spec->autocfg.hp_pin)
  1808. return 0; /* can't find valid BIOS pin config */
  1809. if ((err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
  1810. (err = alc880_auto_create_hp_ctls(spec, spec->autocfg.hp_pin)) < 0 ||
  1811. (err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
  1812. return err;
  1813. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  1814. if (spec->autocfg.dig_out_pin)
  1815. spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
  1816. if (spec->autocfg.dig_in_pin)
  1817. spec->dig_in_nid = ALC880_DIGIN_NID;
  1818. if (spec->kctl_alloc)
  1819. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  1820. spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
  1821. spec->input_mux = &spec->private_imux;
  1822. return 1;
  1823. }
  1824. /* init callback for auto-configuration model -- overriding the default init */
  1825. static int alc880_auto_init(struct hda_codec *codec)
  1826. {
  1827. alc_init(codec);
  1828. alc880_auto_init_multi_out(codec);
  1829. alc880_auto_init_hp_out(codec);
  1830. alc880_auto_init_analog_input(codec);
  1831. return 0;
  1832. }
  1833. /*
  1834. * OK, here we have finally the patch for ALC880
  1835. */
  1836. static int patch_alc880(struct hda_codec *codec)
  1837. {
  1838. struct alc_spec *spec;
  1839. int board_config;
  1840. int i, err;
  1841. spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
  1842. if (spec == NULL)
  1843. return -ENOMEM;
  1844. init_MUTEX(&spec->bind_mutex);
  1845. codec->spec = spec;
  1846. board_config = snd_hda_check_board_config(codec, alc880_cfg_tbl);
  1847. if (board_config < 0 || board_config >= ALC880_MODEL_LAST) {
  1848. printk(KERN_INFO "hda_codec: Unknown model for ALC880, trying auto-probe from BIOS...\n");
  1849. board_config = ALC880_AUTO;
  1850. }
  1851. if (board_config == ALC880_AUTO) {
  1852. /* automatic parse from the BIOS config */
  1853. err = alc880_parse_auto_config(codec);
  1854. if (err < 0) {
  1855. alc_free(codec);
  1856. return err;
  1857. } else if (! err) {
  1858. printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using 3-stack mode...\n");
  1859. board_config = ALC880_3ST;
  1860. }
  1861. }
  1862. if (board_config != ALC880_AUTO) {
  1863. /* set up from the preset table */
  1864. const struct alc_config_preset *preset;
  1865. preset = &alc880_presets[board_config];
  1866. for (i = 0; preset->mixers[i]; i++) {
  1867. snd_assert(spec->num_mixers < ARRAY_SIZE(spec->mixers), break);
  1868. spec->mixers[spec->num_mixers++] = preset->mixers[i];
  1869. }
  1870. for (i = 0; preset->init_verbs[i]; i++) {
  1871. snd_assert(spec->num_init_verbs < ARRAY_SIZE(spec->init_verbs), break);
  1872. spec->init_verbs[spec->num_init_verbs++] = preset->init_verbs[i];
  1873. }
  1874. spec->channel_mode = preset->channel_mode;
  1875. spec->num_channel_mode = preset->num_channel_mode;
  1876. spec->multiout.max_channels = spec->channel_mode[0].channels;
  1877. spec->multiout.num_dacs = preset->num_dacs;
  1878. spec->multiout.dac_nids = preset->dac_nids;
  1879. spec->multiout.dig_out_nid = preset->dig_out_nid;
  1880. spec->multiout.hp_nid = preset->hp_nid;
  1881. spec->input_mux = preset->input_mux;
  1882. spec->num_adc_nids = preset->num_adc_nids;
  1883. spec->adc_nids = preset->adc_nids;
  1884. }
  1885. spec->stream_name_analog = "ALC880 Analog";
  1886. spec->stream_analog_playback = &alc880_pcm_analog_playback;
  1887. spec->stream_analog_capture = &alc880_pcm_analog_capture;
  1888. spec->stream_name_digital = "ALC880 Digital";
  1889. spec->stream_digital_playback = &alc880_pcm_digital_playback;
  1890. spec->stream_digital_capture = &alc880_pcm_digital_capture;
  1891. if (! spec->adc_nids && spec->input_mux) {
  1892. /* check whether NID 0x07 is valid */
  1893. unsigned int wcap = snd_hda_param_read(codec, alc880_adc_nids[0],
  1894. AC_PAR_AUDIO_WIDGET_CAP);
  1895. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
  1896. if (wcap != AC_WID_AUD_IN) {
  1897. spec->adc_nids = alc880_adc_nids_alt;
  1898. spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
  1899. spec->mixers[spec->num_mixers] = alc880_capture_alt_mixer;
  1900. spec->num_mixers++;
  1901. } else {
  1902. spec->adc_nids = alc880_adc_nids;
  1903. spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
  1904. spec->mixers[spec->num_mixers] = alc880_capture_mixer;
  1905. spec->num_mixers++;
  1906. }
  1907. }
  1908. codec->patch_ops = alc_patch_ops;
  1909. if (board_config == ALC880_AUTO)
  1910. codec->patch_ops.init = alc880_auto_init;
  1911. return 0;
  1912. }
  1913. /*
  1914. * ALC260 support
  1915. */
  1916. static hda_nid_t alc260_dac_nids[1] = {
  1917. /* front */
  1918. 0x02,
  1919. };
  1920. static hda_nid_t alc260_adc_nids[1] = {
  1921. /* ADC0 */
  1922. 0x04,
  1923. };
  1924. static hda_nid_t alc260_hp_adc_nids[1] = {
  1925. /* ADC1 */
  1926. 0x05,
  1927. };
  1928. #define ALC260_DIGOUT_NID 0x03
  1929. #define ALC260_DIGIN_NID 0x06
  1930. static struct hda_input_mux alc260_capture_source = {
  1931. .num_items = 4,
  1932. .items = {
  1933. { "Mic", 0x0 },
  1934. { "Front Mic", 0x1 },
  1935. { "Line", 0x2 },
  1936. { "CD", 0x4 },
  1937. },
  1938. };
  1939. /*
  1940. * This is just place-holder, so there's something for alc_build_pcms to look
  1941. * at when it calculates the maximum number of channels. ALC260 has no mixer
  1942. * element which allows changing the channel mode, so the verb list is
  1943. * never used.
  1944. */
  1945. static struct alc_channel_mode alc260_modes[1] = {
  1946. { 2, NULL },
  1947. };
  1948. static snd_kcontrol_new_t alc260_base_mixer[] = {
  1949. HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  1950. ALC_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
  1951. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  1952. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  1953. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  1954. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  1955. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  1956. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  1957. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
  1958. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
  1959. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
  1960. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
  1961. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  1962. ALC_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
  1963. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  1964. ALC_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_OUTPUT),
  1965. HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
  1966. HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
  1967. {
  1968. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1969. .name = "Capture Source",
  1970. .info = alc_mux_enum_info,
  1971. .get = alc_mux_enum_get,
  1972. .put = alc_mux_enum_put,
  1973. },
  1974. { } /* end */
  1975. };
  1976. static snd_kcontrol_new_t alc260_hp_mixer[] = {
  1977. HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  1978. ALC_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
  1979. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  1980. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  1981. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  1982. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  1983. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  1984. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  1985. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
  1986. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
  1987. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  1988. ALC_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
  1989. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  1990. ALC_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_OUTPUT),
  1991. HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
  1992. HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
  1993. {
  1994. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1995. .name = "Capture Source",
  1996. .info = alc_mux_enum_info,
  1997. .get = alc_mux_enum_get,
  1998. .put = alc_mux_enum_put,
  1999. },
  2000. { } /* end */
  2001. };
  2002. static struct hda_verb alc260_init_verbs[] = {
  2003. /* Line In pin widget for input */
  2004. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2005. /* CD pin widget for input */
  2006. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2007. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  2008. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2009. /* Mic2 (front panel) pin widget for input and vref at 80% */
  2010. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2011. /* LINE-2 is used for line-out in rear */
  2012. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2013. /* select line-out */
  2014. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  2015. /* LINE-OUT pin */
  2016. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2017. /* enable HP */
  2018. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  2019. /* enable Mono */
  2020. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2021. /* mute capture amp left and right */
  2022. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2023. /* set connection select to line in (default select for this ADC) */
  2024. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  2025. /* mute capture amp left and right */
  2026. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2027. /* set connection select to line in (default select for this ADC) */
  2028. {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
  2029. /* set vol=0 Line-Out mixer amp left and right */
  2030. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2031. /* unmute pin widget amp left and right (no gain on this amp) */
  2032. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2033. /* set vol=0 HP mixer amp left and right */
  2034. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2035. /* unmute pin widget amp left and right (no gain on this amp) */
  2036. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2037. /* set vol=0 Mono mixer amp left and right */
  2038. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2039. /* unmute pin widget amp left and right (no gain on this amp) */
  2040. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2041. /* unmute LINE-2 out pin */
  2042. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2043. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
  2044. /* mute CD */
  2045. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  2046. /* mute Line In */
  2047. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  2048. /* mute Mic */
  2049. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2050. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  2051. /* mute Front out path */
  2052. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2053. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2054. /* mute Headphone out path */
  2055. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2056. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2057. /* mute Mono out path */
  2058. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2059. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2060. { }
  2061. };
  2062. static struct hda_pcm_stream alc260_pcm_analog_playback = {
  2063. .substreams = 1,
  2064. .channels_min = 2,
  2065. .channels_max = 2,
  2066. };
  2067. static struct hda_pcm_stream alc260_pcm_analog_capture = {
  2068. .substreams = 1,
  2069. .channels_min = 2,
  2070. .channels_max = 2,
  2071. };
  2072. static struct hda_board_config alc260_cfg_tbl[] = {
  2073. { .modelname = "hp", .config = ALC260_HP },
  2074. { .pci_subvendor = 0x103c, .config = ALC260_HP },
  2075. {}
  2076. };
  2077. static int patch_alc260(struct hda_codec *codec)
  2078. {
  2079. struct alc_spec *spec;
  2080. int board_config;
  2081. spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
  2082. if (spec == NULL)
  2083. return -ENOMEM;
  2084. init_MUTEX(&spec->bind_mutex);
  2085. codec->spec = spec;
  2086. board_config = snd_hda_check_board_config(codec, alc260_cfg_tbl);
  2087. if (board_config < 0 || board_config >= ALC260_MODEL_LAST) {
  2088. snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260\n");
  2089. board_config = ALC260_BASIC;
  2090. }
  2091. switch (board_config) {
  2092. case ALC260_HP:
  2093. spec->mixers[spec->num_mixers] = alc260_hp_mixer;
  2094. spec->num_mixers++;
  2095. break;
  2096. default:
  2097. spec->mixers[spec->num_mixers] = alc260_base_mixer;
  2098. spec->num_mixers++;
  2099. break;
  2100. }
  2101. spec->init_verbs[0] = alc260_init_verbs;
  2102. spec->num_init_verbs = 1;
  2103. spec->channel_mode = alc260_modes;
  2104. spec->num_channel_mode = ARRAY_SIZE(alc260_modes);
  2105. spec->stream_name_analog = "ALC260 Analog";
  2106. spec->stream_analog_playback = &alc260_pcm_analog_playback;
  2107. spec->stream_analog_capture = &alc260_pcm_analog_capture;
  2108. spec->multiout.max_channels = spec->channel_mode[0].channels;
  2109. spec->multiout.num_dacs = ARRAY_SIZE(alc260_dac_nids);
  2110. spec->multiout.dac_nids = alc260_dac_nids;
  2111. spec->input_mux = &alc260_capture_source;
  2112. switch (board_config) {
  2113. case ALC260_HP:
  2114. spec->num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids);
  2115. spec->adc_nids = alc260_hp_adc_nids;
  2116. break;
  2117. default:
  2118. spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
  2119. spec->adc_nids = alc260_adc_nids;
  2120. break;
  2121. }
  2122. codec->patch_ops = alc_patch_ops;
  2123. return 0;
  2124. }
  2125. /*
  2126. * ALC882 support
  2127. *
  2128. * ALC882 is almost identical with ALC880 but has cleaner and more flexible
  2129. * configuration. Each pin widget can choose any input DACs and a mixer.
  2130. * Each ADC is connected from a mixer of all inputs. This makes possible
  2131. * 6-channel independent captures.
  2132. *
  2133. * In addition, an independent DAC for the multi-playback (not used in this
  2134. * driver yet).
  2135. */
  2136. static struct alc_channel_mode alc882_ch_modes[1] = {
  2137. { 8, NULL }
  2138. };
  2139. static hda_nid_t alc882_dac_nids[4] = {
  2140. /* front, rear, clfe, rear_surr */
  2141. 0x02, 0x03, 0x04, 0x05
  2142. };
  2143. static hda_nid_t alc882_adc_nids[3] = {
  2144. /* ADC0-2 */
  2145. 0x07, 0x08, 0x09,
  2146. };
  2147. /* input MUX */
  2148. /* FIXME: should be a matrix-type input source selection */
  2149. static struct hda_input_mux alc882_capture_source = {
  2150. .num_items = 4,
  2151. .items = {
  2152. { "Mic", 0x0 },
  2153. { "Front Mic", 0x1 },
  2154. { "Line", 0x2 },
  2155. { "CD", 0x4 },
  2156. },
  2157. };
  2158. #define alc882_mux_enum_info alc_mux_enum_info
  2159. #define alc882_mux_enum_get alc_mux_enum_get
  2160. static int alc882_mux_enum_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
  2161. {
  2162. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2163. struct alc_spec *spec = codec->spec;
  2164. const struct hda_input_mux *imux = spec->input_mux;
  2165. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  2166. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  2167. hda_nid_t nid = capture_mixers[adc_idx];
  2168. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  2169. unsigned int i, idx;
  2170. idx = ucontrol->value.enumerated.item[0];
  2171. if (idx >= imux->num_items)
  2172. idx = imux->num_items - 1;
  2173. if (*cur_val == idx && ! codec->in_resume)
  2174. return 0;
  2175. for (i = 0; i < imux->num_items; i++) {
  2176. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  2177. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  2178. v | (imux->items[i].index << 8));
  2179. }
  2180. *cur_val = idx;
  2181. return 1;
  2182. }
  2183. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  2184. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  2185. */
  2186. static snd_kcontrol_new_t alc882_base_mixer[] = {
  2187. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  2188. ALC_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  2189. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  2190. ALC_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  2191. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  2192. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  2193. ALC_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  2194. ALC_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_OUTPUT),
  2195. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  2196. ALC_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  2197. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  2198. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  2199. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  2200. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  2201. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  2202. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  2203. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  2204. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  2205. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  2206. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  2207. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  2208. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  2209. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  2210. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  2211. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  2212. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  2213. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  2214. {
  2215. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  2216. /* .name = "Capture Source", */
  2217. .name = "Input Source",
  2218. .count = 3,
  2219. .info = alc882_mux_enum_info,
  2220. .get = alc882_mux_enum_get,
  2221. .put = alc882_mux_enum_put,
  2222. },
  2223. { } /* end */
  2224. };
  2225. static struct hda_verb alc882_init_verbs[] = {
  2226. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  2227. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2228. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2229. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2230. /* Rear mixer */
  2231. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2232. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2233. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2234. /* CLFE mixer */
  2235. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2236. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2237. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2238. /* Side mixer */
  2239. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2240. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2241. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2242. /* Front Pin: output 0 (0x0c) */
  2243. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2244. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2245. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  2246. /* Rear Pin: output 1 (0x0d) */
  2247. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2248. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2249. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  2250. /* CLFE Pin: output 2 (0x0e) */
  2251. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2252. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2253. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  2254. /* Side Pin: output 3 (0x0f) */
  2255. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2256. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2257. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  2258. /* Mic (rear) pin: input vref at 80% */
  2259. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2260. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2261. /* Front Mic pin: input vref at 80% */
  2262. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2263. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2264. /* Line In pin: input */
  2265. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2266. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2267. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  2268. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  2269. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2270. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  2271. /* CD pin widget for input */
  2272. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2273. /* FIXME: use matrix-type input source selection */
  2274. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  2275. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  2276. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2277. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  2278. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  2279. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  2280. /* Input mixer2 */
  2281. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2282. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  2283. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  2284. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  2285. /* Input mixer3 */
  2286. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2287. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  2288. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  2289. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  2290. /* ADC1: mute amp left and right */
  2291. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2292. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  2293. /* ADC2: mute amp left and right */
  2294. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2295. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  2296. /* ADC3: mute amp left and right */
  2297. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2298. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  2299. { }
  2300. };
  2301. static int patch_alc882(struct hda_codec *codec)
  2302. {
  2303. struct alc_spec *spec;
  2304. spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
  2305. if (spec == NULL)
  2306. return -ENOMEM;
  2307. init_MUTEX(&spec->bind_mutex);
  2308. codec->spec = spec;
  2309. spec->mixers[spec->num_mixers] = alc882_base_mixer;
  2310. spec->num_mixers++;
  2311. spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
  2312. spec->dig_in_nid = ALC880_DIGIN_NID;
  2313. spec->init_verbs[0] = alc882_init_verbs;
  2314. spec->num_init_verbs = 1;
  2315. spec->channel_mode = alc882_ch_modes;
  2316. spec->num_channel_mode = ARRAY_SIZE(alc882_ch_modes);
  2317. spec->stream_name_analog = "ALC882 Analog";
  2318. spec->stream_analog_playback = &alc880_pcm_analog_playback;
  2319. spec->stream_analog_capture = &alc880_pcm_analog_capture;
  2320. spec->stream_name_digital = "ALC882 Digital";
  2321. spec->stream_digital_playback = &alc880_pcm_digital_playback;
  2322. spec->stream_digital_capture = &alc880_pcm_digital_capture;
  2323. spec->multiout.max_channels = spec->channel_mode[0].channels;
  2324. spec->multiout.num_dacs = ARRAY_SIZE(alc882_dac_nids);
  2325. spec->multiout.dac_nids = alc882_dac_nids;
  2326. spec->input_mux = &alc882_capture_source;
  2327. spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
  2328. spec->adc_nids = alc882_adc_nids;
  2329. codec->patch_ops = alc_patch_ops;
  2330. return 0;
  2331. }
  2332. /*
  2333. * patch entries
  2334. */
  2335. struct hda_codec_preset snd_hda_preset_realtek[] = {
  2336. { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
  2337. { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
  2338. { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
  2339. {} /* terminator */
  2340. };