patch_realtek.c 169 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977
  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 Kailang Yang <kailang@realtek.com.tw>
  7. * PeiSen Hou <pshou@realtek.com.tw>
  8. * Takashi Iwai <tiwai@suse.de>
  9. * Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
  10. *
  11. * This driver is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License as published by
  13. * the Free Software Foundation; either version 2 of the License, or
  14. * (at your option) any later version.
  15. *
  16. * This driver is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program; if not, write to the Free Software
  23. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  24. */
  25. #include <sound/driver.h>
  26. #include <linux/init.h>
  27. #include <linux/delay.h>
  28. #include <linux/slab.h>
  29. #include <linux/pci.h>
  30. #include <sound/core.h>
  31. #include "hda_codec.h"
  32. #include "hda_local.h"
  33. /* ALC880 board config type */
  34. enum {
  35. ALC880_3ST,
  36. ALC880_3ST_DIG,
  37. ALC880_5ST,
  38. ALC880_5ST_DIG,
  39. ALC880_W810,
  40. ALC880_Z71V,
  41. ALC880_6ST,
  42. ALC880_6ST_DIG,
  43. ALC880_F1734,
  44. ALC880_ASUS,
  45. ALC880_ASUS_DIG,
  46. ALC880_ASUS_W1V,
  47. ALC880_ASUS_DIG2,
  48. ALC880_UNIWILL_DIG,
  49. ALC880_CLEVO,
  50. ALC880_TCL_S700,
  51. #ifdef CONFIG_SND_DEBUG
  52. ALC880_TEST,
  53. #endif
  54. ALC880_AUTO,
  55. ALC880_MODEL_LAST /* last tag */
  56. };
  57. /* ALC260 models */
  58. enum {
  59. ALC260_BASIC,
  60. ALC260_HP,
  61. ALC260_HP_3013,
  62. ALC260_FUJITSU_S702X,
  63. #ifdef CONFIG_SND_DEBUG
  64. ALC260_TEST,
  65. #endif
  66. ALC260_AUTO,
  67. ALC260_MODEL_LAST /* last tag */
  68. };
  69. /* ALC262 models */
  70. enum {
  71. ALC262_BASIC,
  72. ALC262_AUTO,
  73. ALC262_MODEL_LAST /* last tag */
  74. };
  75. /* ALC861 models */
  76. enum {
  77. ALC861_3ST,
  78. ALC861_3ST_DIG,
  79. ALC861_6ST_DIG,
  80. ALC861_AUTO,
  81. ALC861_MODEL_LAST,
  82. };
  83. /* ALC882 models */
  84. enum {
  85. ALC882_3ST_DIG,
  86. ALC882_6ST_DIG,
  87. ALC882_AUTO,
  88. ALC882_MODEL_LAST,
  89. };
  90. /* for GPIO Poll */
  91. #define GPIO_MASK 0x03
  92. struct alc_spec {
  93. /* codec parameterization */
  94. struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
  95. unsigned int num_mixers;
  96. const struct hda_verb *init_verbs[5]; /* initialization verbs
  97. * don't forget NULL termination!
  98. */
  99. unsigned int num_init_verbs;
  100. char *stream_name_analog; /* analog PCM stream */
  101. struct hda_pcm_stream *stream_analog_playback;
  102. struct hda_pcm_stream *stream_analog_capture;
  103. char *stream_name_digital; /* digital PCM stream */
  104. struct hda_pcm_stream *stream_digital_playback;
  105. struct hda_pcm_stream *stream_digital_capture;
  106. /* playback */
  107. struct hda_multi_out multiout; /* playback set-up
  108. * max_channels, dacs must be set
  109. * dig_out_nid and hp_nid are optional
  110. */
  111. /* capture */
  112. unsigned int num_adc_nids;
  113. hda_nid_t *adc_nids;
  114. hda_nid_t dig_in_nid; /* digital-in NID; optional */
  115. /* capture source */
  116. const struct hda_input_mux *input_mux;
  117. unsigned int cur_mux[3];
  118. /* channel model */
  119. const struct hda_channel_mode *channel_mode;
  120. int num_channel_mode;
  121. /* PCM information */
  122. struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
  123. /* dynamic controls, init_verbs and input_mux */
  124. struct auto_pin_cfg autocfg;
  125. unsigned int num_kctl_alloc, num_kctl_used;
  126. struct snd_kcontrol_new *kctl_alloc;
  127. struct hda_input_mux private_imux;
  128. hda_nid_t private_dac_nids[5];
  129. };
  130. /*
  131. * configuration template - to be copied to the spec instance
  132. */
  133. struct alc_config_preset {
  134. struct snd_kcontrol_new *mixers[5]; /* should be identical size with spec */
  135. const struct hda_verb *init_verbs[5];
  136. unsigned int num_dacs;
  137. hda_nid_t *dac_nids;
  138. hda_nid_t dig_out_nid; /* optional */
  139. hda_nid_t hp_nid; /* optional */
  140. unsigned int num_adc_nids;
  141. hda_nid_t *adc_nids;
  142. hda_nid_t dig_in_nid;
  143. unsigned int num_channel_mode;
  144. const struct hda_channel_mode *channel_mode;
  145. const struct hda_input_mux *input_mux;
  146. };
  147. /*
  148. * input MUX handling
  149. */
  150. static int alc_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
  151. {
  152. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  153. struct alc_spec *spec = codec->spec;
  154. return snd_hda_input_mux_info(spec->input_mux, uinfo);
  155. }
  156. static int alc_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  157. {
  158. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  159. struct alc_spec *spec = codec->spec;
  160. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  161. ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
  162. return 0;
  163. }
  164. static int alc_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  165. {
  166. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  167. struct alc_spec *spec = codec->spec;
  168. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  169. return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
  170. spec->adc_nids[adc_idx], &spec->cur_mux[adc_idx]);
  171. }
  172. /*
  173. * channel mode setting
  174. */
  175. static int alc_ch_mode_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
  176. {
  177. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  178. struct alc_spec *spec = codec->spec;
  179. return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
  180. spec->num_channel_mode);
  181. }
  182. static int alc_ch_mode_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  183. {
  184. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  185. struct alc_spec *spec = codec->spec;
  186. return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
  187. spec->num_channel_mode, spec->multiout.max_channels);
  188. }
  189. static int alc_ch_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  190. {
  191. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  192. struct alc_spec *spec = codec->spec;
  193. return snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
  194. spec->num_channel_mode, &spec->multiout.max_channels);
  195. }
  196. /*
  197. * Control the mode of pin widget settings via the mixer. "pc" is used
  198. * instead of "%" to avoid consequences of accidently treating the % as
  199. * being part of a format specifier. Maximum allowed length of a value is
  200. * 63 characters plus NULL terminator.
  201. *
  202. * Note: some retasking pin complexes seem to ignore requests for input
  203. * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
  204. * are requested. Therefore order this list so that this behaviour will not
  205. * cause problems when mixer clients move through the enum sequentially.
  206. * NIDs 0x0f and 0x10 have been observed to have this behaviour.
  207. */
  208. static char *alc_pin_mode_names[] = {
  209. "Mic 50pc bias", "Mic 80pc bias",
  210. "Line in", "Line out", "Headphone out",
  211. };
  212. static unsigned char alc_pin_mode_values[] = {
  213. PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
  214. };
  215. /* The control can present all 5 options, or it can limit the options based
  216. * in the pin being assumed to be exclusively an input or an output pin.
  217. */
  218. #define ALC_PIN_DIR_IN 0x00
  219. #define ALC_PIN_DIR_OUT 0x01
  220. #define ALC_PIN_DIR_INOUT 0x02
  221. /* Info about the pin modes supported by the three different pin directions.
  222. * For each direction the minimum and maximum values are given.
  223. */
  224. static signed char alc_pin_mode_dir_info[3][2] = {
  225. { 0, 2 }, /* ALC_PIN_DIR_IN */
  226. { 3, 4 }, /* ALC_PIN_DIR_OUT */
  227. { 0, 4 }, /* ALC_PIN_DIR_INOUT */
  228. };
  229. #define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
  230. #define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
  231. #define alc_pin_mode_n_items(_dir) \
  232. (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
  233. static int alc_pin_mode_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
  234. {
  235. unsigned int item_num = uinfo->value.enumerated.item;
  236. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  237. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  238. uinfo->count = 1;
  239. uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
  240. if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
  241. item_num = alc_pin_mode_min(dir);
  242. strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
  243. return 0;
  244. }
  245. static int alc_pin_mode_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  246. {
  247. unsigned int i;
  248. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  249. hda_nid_t nid = kcontrol->private_value & 0xffff;
  250. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  251. long *valp = ucontrol->value.integer.value;
  252. unsigned int pinctl = snd_hda_codec_read(codec,nid,0,AC_VERB_GET_PIN_WIDGET_CONTROL,0x00);
  253. /* Find enumerated value for current pinctl setting */
  254. i = alc_pin_mode_min(dir);
  255. while (alc_pin_mode_values[i]!=pinctl && i<=alc_pin_mode_max(dir))
  256. i++;
  257. *valp = i<=alc_pin_mode_max(dir)?i:alc_pin_mode_min(dir);
  258. return 0;
  259. }
  260. static int alc_pin_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  261. {
  262. signed int change;
  263. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  264. hda_nid_t nid = kcontrol->private_value & 0xffff;
  265. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  266. long val = *ucontrol->value.integer.value;
  267. unsigned int pinctl = snd_hda_codec_read(codec,nid,0,AC_VERB_GET_PIN_WIDGET_CONTROL,0x00);
  268. if (val<alc_pin_mode_min(dir) || val>alc_pin_mode_max(dir))
  269. val = alc_pin_mode_min(dir);
  270. change = pinctl != alc_pin_mode_values[val];
  271. if (change)
  272. snd_hda_codec_write(codec,nid,0,AC_VERB_SET_PIN_WIDGET_CONTROL,
  273. alc_pin_mode_values[val]);
  274. return change;
  275. }
  276. #define ALC_PIN_MODE(xname, nid, dir) \
  277. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  278. .info = alc_pin_mode_info, \
  279. .get = alc_pin_mode_get, \
  280. .put = alc_pin_mode_put, \
  281. .private_value = nid | (dir<<16) }
  282. /*
  283. * set up from the preset table
  284. */
  285. static void setup_preset(struct alc_spec *spec, const struct alc_config_preset *preset)
  286. {
  287. int i;
  288. for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
  289. spec->mixers[spec->num_mixers++] = preset->mixers[i];
  290. for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i]; i++)
  291. spec->init_verbs[spec->num_init_verbs++] = preset->init_verbs[i];
  292. spec->channel_mode = preset->channel_mode;
  293. spec->num_channel_mode = preset->num_channel_mode;
  294. spec->multiout.max_channels = spec->channel_mode[0].channels;
  295. spec->multiout.num_dacs = preset->num_dacs;
  296. spec->multiout.dac_nids = preset->dac_nids;
  297. spec->multiout.dig_out_nid = preset->dig_out_nid;
  298. spec->multiout.hp_nid = preset->hp_nid;
  299. spec->input_mux = preset->input_mux;
  300. spec->num_adc_nids = preset->num_adc_nids;
  301. spec->adc_nids = preset->adc_nids;
  302. spec->dig_in_nid = preset->dig_in_nid;
  303. }
  304. /*
  305. * ALC880 3-stack model
  306. *
  307. * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
  308. * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18, F-Mic = 0x1b
  309. * HP = 0x19
  310. */
  311. static hda_nid_t alc880_dac_nids[4] = {
  312. /* front, rear, clfe, rear_surr */
  313. 0x02, 0x05, 0x04, 0x03
  314. };
  315. static hda_nid_t alc880_adc_nids[3] = {
  316. /* ADC0-2 */
  317. 0x07, 0x08, 0x09,
  318. };
  319. /* The datasheet says the node 0x07 is connected from inputs,
  320. * but it shows zero connection in the real implementation on some devices.
  321. * Note: this is a 915GAV bug, fixed on 915GLV
  322. */
  323. static hda_nid_t alc880_adc_nids_alt[2] = {
  324. /* ADC1-2 */
  325. 0x08, 0x09,
  326. };
  327. #define ALC880_DIGOUT_NID 0x06
  328. #define ALC880_DIGIN_NID 0x0a
  329. static struct hda_input_mux alc880_capture_source = {
  330. .num_items = 4,
  331. .items = {
  332. { "Mic", 0x0 },
  333. { "Front Mic", 0x3 },
  334. { "Line", 0x2 },
  335. { "CD", 0x4 },
  336. },
  337. };
  338. /* channel source setting (2/6 channel selection for 3-stack) */
  339. /* 2ch mode */
  340. static struct hda_verb alc880_threestack_ch2_init[] = {
  341. /* set line-in to input, mute it */
  342. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  343. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  344. /* set mic-in to input vref 80%, mute it */
  345. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  346. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  347. { } /* end */
  348. };
  349. /* 6ch mode */
  350. static struct hda_verb alc880_threestack_ch6_init[] = {
  351. /* set line-in to output, unmute it */
  352. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  353. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  354. /* set mic-in to output, unmute it */
  355. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  356. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  357. { } /* end */
  358. };
  359. static struct hda_channel_mode alc880_threestack_modes[2] = {
  360. { 2, alc880_threestack_ch2_init },
  361. { 6, alc880_threestack_ch6_init },
  362. };
  363. static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
  364. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  365. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  366. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  367. HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
  368. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  369. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  370. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  371. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  372. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  373. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  374. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  375. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  376. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  377. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  378. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
  379. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
  380. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  381. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  382. HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
  383. {
  384. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  385. .name = "Channel Mode",
  386. .info = alc_ch_mode_info,
  387. .get = alc_ch_mode_get,
  388. .put = alc_ch_mode_put,
  389. },
  390. { } /* end */
  391. };
  392. /* capture mixer elements */
  393. static struct snd_kcontrol_new alc880_capture_mixer[] = {
  394. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  395. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  396. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  397. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  398. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  399. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  400. {
  401. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  402. /* The multiple "Capture Source" controls confuse alsamixer
  403. * So call somewhat different..
  404. * FIXME: the controls appear in the "playback" view!
  405. */
  406. /* .name = "Capture Source", */
  407. .name = "Input Source",
  408. .count = 3,
  409. .info = alc_mux_enum_info,
  410. .get = alc_mux_enum_get,
  411. .put = alc_mux_enum_put,
  412. },
  413. { } /* end */
  414. };
  415. /* capture mixer elements (in case NID 0x07 not available) */
  416. static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
  417. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  418. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  419. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  420. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  421. {
  422. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  423. /* The multiple "Capture Source" controls confuse alsamixer
  424. * So call somewhat different..
  425. * FIXME: the controls appear in the "playback" view!
  426. */
  427. /* .name = "Capture Source", */
  428. .name = "Input Source",
  429. .count = 2,
  430. .info = alc_mux_enum_info,
  431. .get = alc_mux_enum_get,
  432. .put = alc_mux_enum_put,
  433. },
  434. { } /* end */
  435. };
  436. /*
  437. * ALC880 5-stack model
  438. *
  439. * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d), Side = 0x02 (0xd)
  440. * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
  441. * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
  442. */
  443. /* additional mixers to alc880_three_stack_mixer */
  444. static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
  445. HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  446. HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
  447. { } /* end */
  448. };
  449. /* channel source setting (6/8 channel selection for 5-stack) */
  450. /* 6ch mode */
  451. static struct hda_verb alc880_fivestack_ch6_init[] = {
  452. /* set line-in to input, mute it */
  453. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  454. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  455. { } /* end */
  456. };
  457. /* 8ch mode */
  458. static struct hda_verb alc880_fivestack_ch8_init[] = {
  459. /* set line-in to output, unmute it */
  460. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  461. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  462. { } /* end */
  463. };
  464. static struct hda_channel_mode alc880_fivestack_modes[2] = {
  465. { 6, alc880_fivestack_ch6_init },
  466. { 8, alc880_fivestack_ch8_init },
  467. };
  468. /*
  469. * ALC880 6-stack model
  470. *
  471. * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e), Side = 0x05 (0x0f)
  472. * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
  473. * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
  474. */
  475. static hda_nid_t alc880_6st_dac_nids[4] = {
  476. /* front, rear, clfe, rear_surr */
  477. 0x02, 0x03, 0x04, 0x05
  478. };
  479. static struct hda_input_mux alc880_6stack_capture_source = {
  480. .num_items = 4,
  481. .items = {
  482. { "Mic", 0x0 },
  483. { "Front Mic", 0x1 },
  484. { "Line", 0x2 },
  485. { "CD", 0x4 },
  486. },
  487. };
  488. /* fixed 8-channels */
  489. static struct hda_channel_mode alc880_sixstack_modes[1] = {
  490. { 8, NULL },
  491. };
  492. static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
  493. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  494. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  495. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  496. HDA_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. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  500. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  501. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  502. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  503. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  504. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  505. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  506. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  507. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  508. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  509. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  510. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  511. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  512. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  513. {
  514. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  515. .name = "Channel Mode",
  516. .info = alc_ch_mode_info,
  517. .get = alc_ch_mode_get,
  518. .put = alc_ch_mode_put,
  519. },
  520. { } /* end */
  521. };
  522. /*
  523. * ALC880 W810 model
  524. *
  525. * W810 has rear IO for:
  526. * Front (DAC 02)
  527. * Surround (DAC 03)
  528. * Center/LFE (DAC 04)
  529. * Digital out (06)
  530. *
  531. * The system also has a pair of internal speakers, and a headphone jack.
  532. * These are both connected to Line2 on the codec, hence to DAC 02.
  533. *
  534. * There is a variable resistor to control the speaker or headphone
  535. * volume. This is a hardware-only device without a software API.
  536. *
  537. * Plugging headphones in will disable the internal speakers. This is
  538. * implemented in hardware, not via the driver using jack sense. In
  539. * a similar fashion, plugging into the rear socket marked "front" will
  540. * disable both the speakers and headphones.
  541. *
  542. * For input, there's a microphone jack, and an "audio in" jack.
  543. * These may not do anything useful with this driver yet, because I
  544. * haven't setup any initialization verbs for these yet...
  545. */
  546. static hda_nid_t alc880_w810_dac_nids[3] = {
  547. /* front, rear/surround, clfe */
  548. 0x02, 0x03, 0x04
  549. };
  550. /* fixed 6 channels */
  551. static struct hda_channel_mode alc880_w810_modes[1] = {
  552. { 6, NULL }
  553. };
  554. /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
  555. static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
  556. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  557. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  558. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  559. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  560. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  561. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  562. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  563. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  564. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  565. { } /* end */
  566. };
  567. /*
  568. * Z710V model
  569. *
  570. * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
  571. * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?), Line = 0x1a
  572. */
  573. static hda_nid_t alc880_z71v_dac_nids[1] = {
  574. 0x02
  575. };
  576. #define ALC880_Z71V_HP_DAC 0x03
  577. /* fixed 2 channels */
  578. static struct hda_channel_mode alc880_2_jack_modes[1] = {
  579. { 2, NULL }
  580. };
  581. static struct snd_kcontrol_new alc880_z71v_mixer[] = {
  582. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  583. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  584. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  585. HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
  586. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  587. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  588. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  589. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  590. { } /* end */
  591. };
  592. /* FIXME! */
  593. /*
  594. * ALC880 F1734 model
  595. *
  596. * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
  597. * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
  598. */
  599. static hda_nid_t alc880_f1734_dac_nids[1] = {
  600. 0x03
  601. };
  602. #define ALC880_F1734_HP_DAC 0x02
  603. static struct snd_kcontrol_new alc880_f1734_mixer[] = {
  604. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  605. HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
  606. HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  607. HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
  608. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  609. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  610. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  611. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  612. { } /* end */
  613. };
  614. /* FIXME! */
  615. /*
  616. * ALC880 ASUS model
  617. *
  618. * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
  619. * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
  620. * Mic = 0x18, Line = 0x1a
  621. */
  622. #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
  623. #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
  624. static struct snd_kcontrol_new alc880_asus_mixer[] = {
  625. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  626. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  627. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  628. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  629. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  630. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  631. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  632. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  633. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  634. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  635. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  636. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  637. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  638. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  639. {
  640. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  641. .name = "Channel Mode",
  642. .info = alc_ch_mode_info,
  643. .get = alc_ch_mode_get,
  644. .put = alc_ch_mode_put,
  645. },
  646. { } /* end */
  647. };
  648. /* FIXME! */
  649. /*
  650. * ALC880 ASUS W1V model
  651. *
  652. * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
  653. * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
  654. * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
  655. */
  656. /* additional mixers to alc880_asus_mixer */
  657. static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
  658. HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
  659. HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
  660. { } /* end */
  661. };
  662. /* additional mixers to alc880_asus_mixer */
  663. static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
  664. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  665. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  666. { } /* end */
  667. };
  668. /* TCL S700 */
  669. static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
  670. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  671. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  672. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  673. HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
  674. HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
  675. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
  676. HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
  677. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  678. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  679. {
  680. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  681. /* The multiple "Capture Source" controls confuse alsamixer
  682. * So call somewhat different..
  683. * FIXME: the controls appear in the "playback" view!
  684. */
  685. /* .name = "Capture Source", */
  686. .name = "Input Source",
  687. .count = 1,
  688. .info = alc_mux_enum_info,
  689. .get = alc_mux_enum_get,
  690. .put = alc_mux_enum_put,
  691. },
  692. { } /* end */
  693. };
  694. /*
  695. * build control elements
  696. */
  697. static int alc_build_controls(struct hda_codec *codec)
  698. {
  699. struct alc_spec *spec = codec->spec;
  700. int err;
  701. int i;
  702. for (i = 0; i < spec->num_mixers; i++) {
  703. err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
  704. if (err < 0)
  705. return err;
  706. }
  707. if (spec->multiout.dig_out_nid) {
  708. err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
  709. if (err < 0)
  710. return err;
  711. }
  712. if (spec->dig_in_nid) {
  713. err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
  714. if (err < 0)
  715. return err;
  716. }
  717. return 0;
  718. }
  719. /*
  720. * initialize the codec volumes, etc
  721. */
  722. /*
  723. * generic initialization of ADC, input mixers and output mixers
  724. */
  725. static struct hda_verb alc880_volume_init_verbs[] = {
  726. /*
  727. * Unmute ADC0-2 and set the default input to mic-in
  728. */
  729. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  730. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  731. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  732. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  733. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  734. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  735. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  736. * mixer widget
  737. * Note: PASD motherboards uses the Line In 2 as the input for front panel
  738. * mic (mic 2)
  739. */
  740. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  741. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  742. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  743. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  744. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  745. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  746. /*
  747. * Set up output mixers (0x0c - 0x0f)
  748. */
  749. /* set vol=0 to output mixers */
  750. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  751. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  752. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  753. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  754. /* set up input amps for analog loopback */
  755. /* Amp Indices: DAC = 0, mixer = 1 */
  756. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  757. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  758. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  759. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  760. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  761. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  762. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  763. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  764. { }
  765. };
  766. /*
  767. * 3-stack pin configuration:
  768. * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
  769. */
  770. static struct hda_verb alc880_pin_3stack_init_verbs[] = {
  771. /*
  772. * preset connection lists of input pins
  773. * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
  774. */
  775. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  776. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  777. {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
  778. /*
  779. * Set pin mode and muting
  780. */
  781. /* set front pin widgets 0x14 for output */
  782. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  783. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  784. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  785. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  786. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  787. /* Mic2 (as headphone out) for HP output */
  788. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  789. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  790. /* Line In pin widget for input */
  791. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  792. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  793. /* Line2 (as front mic) pin widget for input and vref at 80% */
  794. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  795. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  796. /* CD pin widget for input */
  797. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  798. { }
  799. };
  800. /*
  801. * 5-stack pin configuration:
  802. * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
  803. * line-in/side = 0x1a, f-mic = 0x1b
  804. */
  805. static struct hda_verb alc880_pin_5stack_init_verbs[] = {
  806. /*
  807. * preset connection lists of input pins
  808. * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
  809. */
  810. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  811. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
  812. /*
  813. * Set pin mode and muting
  814. */
  815. /* set pin widgets 0x14-0x17 for output */
  816. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  817. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  818. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  819. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  820. /* unmute pins for output (no gain on this amp) */
  821. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  822. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  823. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  824. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  825. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  826. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  827. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  828. /* Mic2 (as headphone out) for HP output */
  829. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  830. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  831. /* Line In pin widget for input */
  832. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  833. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  834. /* Line2 (as front mic) pin widget for input and vref at 80% */
  835. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  836. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  837. /* CD pin widget for input */
  838. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  839. { }
  840. };
  841. /*
  842. * W810 pin configuration:
  843. * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
  844. */
  845. static struct hda_verb alc880_pin_w810_init_verbs[] = {
  846. /* hphone/speaker input selector: front DAC */
  847. {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
  848. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  849. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  850. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  851. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  852. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  853. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  854. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  855. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  856. { }
  857. };
  858. /*
  859. * Z71V pin configuration:
  860. * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
  861. */
  862. static struct hda_verb alc880_pin_z71v_init_verbs[] = {
  863. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  864. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  865. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  866. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  867. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  868. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  869. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  870. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  871. { }
  872. };
  873. /*
  874. * 6-stack pin configuration:
  875. * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18, f-mic = 0x19,
  876. * line = 0x1a, HP = 0x1b
  877. */
  878. static struct hda_verb alc880_pin_6stack_init_verbs[] = {
  879. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  880. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  881. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  882. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  883. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  884. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  885. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  886. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  887. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  888. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  889. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  890. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  891. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  892. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  893. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  894. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  895. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  896. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  897. { }
  898. };
  899. /* FIXME! */
  900. /*
  901. * F1734 pin configuration:
  902. * HP = 0x14, speaker-out = 0x15, mic = 0x18
  903. */
  904. static struct hda_verb alc880_pin_f1734_init_verbs[] = {
  905. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
  906. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
  907. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
  908. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  909. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  910. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  911. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  912. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  913. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  914. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  915. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  916. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  917. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  918. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  919. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  920. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  921. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  922. { }
  923. };
  924. /* FIXME! */
  925. /*
  926. * ASUS pin configuration:
  927. * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
  928. */
  929. static struct hda_verb alc880_pin_asus_init_verbs[] = {
  930. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
  931. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
  932. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
  933. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  934. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  935. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  936. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  937. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  938. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  939. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  940. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  941. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  942. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  943. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  944. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  945. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  946. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  947. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  948. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  949. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  950. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  951. { }
  952. };
  953. /* Enable GPIO mask and set output */
  954. static struct hda_verb alc880_gpio1_init_verbs[] = {
  955. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  956. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  957. {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
  958. { }
  959. };
  960. /* Enable GPIO mask and set output */
  961. static struct hda_verb alc880_gpio2_init_verbs[] = {
  962. {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
  963. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
  964. {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
  965. { }
  966. };
  967. /* Clevo m520g init */
  968. static struct hda_verb alc880_pin_clevo_init_verbs[] = {
  969. /* headphone output */
  970. {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
  971. /* line-out */
  972. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  973. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  974. /* Line-in */
  975. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  976. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  977. /* CD */
  978. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  979. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  980. /* Mic1 (rear panel) */
  981. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  982. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  983. /* Mic2 (front panel) */
  984. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  985. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  986. /* headphone */
  987. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  988. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  989. /* change to EAPD mode */
  990. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  991. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  992. { }
  993. };
  994. static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
  995. /* Headphone output */
  996. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  997. /* Front output*/
  998. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  999. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  1000. /* Line In pin widget for input */
  1001. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1002. /* CD pin widget for input */
  1003. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1004. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1005. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1006. /* change to EAPD mode */
  1007. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1008. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  1009. { }
  1010. };
  1011. /*
  1012. */
  1013. static int alc_init(struct hda_codec *codec)
  1014. {
  1015. struct alc_spec *spec = codec->spec;
  1016. unsigned int i;
  1017. for (i = 0; i < spec->num_init_verbs; i++)
  1018. snd_hda_sequence_write(codec, spec->init_verbs[i]);
  1019. return 0;
  1020. }
  1021. #ifdef CONFIG_PM
  1022. /*
  1023. * resume
  1024. */
  1025. static int alc_resume(struct hda_codec *codec)
  1026. {
  1027. struct alc_spec *spec = codec->spec;
  1028. int i;
  1029. alc_init(codec);
  1030. for (i = 0; i < spec->num_mixers; i++)
  1031. snd_hda_resume_ctls(codec, spec->mixers[i]);
  1032. if (spec->multiout.dig_out_nid)
  1033. snd_hda_resume_spdif_out(codec);
  1034. if (spec->dig_in_nid)
  1035. snd_hda_resume_spdif_in(codec);
  1036. return 0;
  1037. }
  1038. #endif
  1039. /*
  1040. * Analog playback callbacks
  1041. */
  1042. static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
  1043. struct hda_codec *codec,
  1044. struct snd_pcm_substream *substream)
  1045. {
  1046. struct alc_spec *spec = codec->spec;
  1047. return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
  1048. }
  1049. static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  1050. struct hda_codec *codec,
  1051. unsigned int stream_tag,
  1052. unsigned int format,
  1053. struct snd_pcm_substream *substream)
  1054. {
  1055. struct alc_spec *spec = codec->spec;
  1056. return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag,
  1057. format, substream);
  1058. }
  1059. static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
  1060. struct hda_codec *codec,
  1061. struct snd_pcm_substream *substream)
  1062. {
  1063. struct alc_spec *spec = codec->spec;
  1064. return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
  1065. }
  1066. /*
  1067. * Digital out
  1068. */
  1069. static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
  1070. struct hda_codec *codec,
  1071. struct snd_pcm_substream *substream)
  1072. {
  1073. struct alc_spec *spec = codec->spec;
  1074. return snd_hda_multi_out_dig_open(codec, &spec->multiout);
  1075. }
  1076. static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
  1077. struct hda_codec *codec,
  1078. struct snd_pcm_substream *substream)
  1079. {
  1080. struct alc_spec *spec = codec->spec;
  1081. return snd_hda_multi_out_dig_close(codec, &spec->multiout);
  1082. }
  1083. /*
  1084. * Analog capture
  1085. */
  1086. static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
  1087. struct hda_codec *codec,
  1088. unsigned int stream_tag,
  1089. unsigned int format,
  1090. struct snd_pcm_substream *substream)
  1091. {
  1092. struct alc_spec *spec = codec->spec;
  1093. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
  1094. stream_tag, 0, format);
  1095. return 0;
  1096. }
  1097. static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
  1098. struct hda_codec *codec,
  1099. struct snd_pcm_substream *substream)
  1100. {
  1101. struct alc_spec *spec = codec->spec;
  1102. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], 0, 0, 0);
  1103. return 0;
  1104. }
  1105. /*
  1106. */
  1107. static struct hda_pcm_stream alc880_pcm_analog_playback = {
  1108. .substreams = 1,
  1109. .channels_min = 2,
  1110. .channels_max = 8,
  1111. /* NID is set in alc_build_pcms */
  1112. .ops = {
  1113. .open = alc880_playback_pcm_open,
  1114. .prepare = alc880_playback_pcm_prepare,
  1115. .cleanup = alc880_playback_pcm_cleanup
  1116. },
  1117. };
  1118. static struct hda_pcm_stream alc880_pcm_analog_capture = {
  1119. .substreams = 2,
  1120. .channels_min = 2,
  1121. .channels_max = 2,
  1122. /* NID is set in alc_build_pcms */
  1123. .ops = {
  1124. .prepare = alc880_capture_pcm_prepare,
  1125. .cleanup = alc880_capture_pcm_cleanup
  1126. },
  1127. };
  1128. static struct hda_pcm_stream alc880_pcm_digital_playback = {
  1129. .substreams = 1,
  1130. .channels_min = 2,
  1131. .channels_max = 2,
  1132. /* NID is set in alc_build_pcms */
  1133. .ops = {
  1134. .open = alc880_dig_playback_pcm_open,
  1135. .close = alc880_dig_playback_pcm_close
  1136. },
  1137. };
  1138. static struct hda_pcm_stream alc880_pcm_digital_capture = {
  1139. .substreams = 1,
  1140. .channels_min = 2,
  1141. .channels_max = 2,
  1142. /* NID is set in alc_build_pcms */
  1143. };
  1144. /* Used by alc_build_pcms to flag that a PCM has no playback stream */
  1145. static struct hda_pcm_stream alc_pcm_null_playback = {
  1146. .substreams = 0,
  1147. .channels_min = 0,
  1148. .channels_max = 0,
  1149. };
  1150. static int alc_build_pcms(struct hda_codec *codec)
  1151. {
  1152. struct alc_spec *spec = codec->spec;
  1153. struct hda_pcm *info = spec->pcm_rec;
  1154. int i;
  1155. codec->num_pcms = 1;
  1156. codec->pcm_info = info;
  1157. info->name = spec->stream_name_analog;
  1158. if (spec->stream_analog_playback) {
  1159. snd_assert(spec->multiout.dac_nids, return -EINVAL);
  1160. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
  1161. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
  1162. }
  1163. if (spec->stream_analog_capture) {
  1164. snd_assert(spec->adc_nids, return -EINVAL);
  1165. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
  1166. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
  1167. }
  1168. if (spec->channel_mode) {
  1169. info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
  1170. for (i = 0; i < spec->num_channel_mode; i++) {
  1171. if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
  1172. info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
  1173. }
  1174. }
  1175. }
  1176. /* If the use of more than one ADC is requested for the current
  1177. * model, configure a second analog capture-only PCM.
  1178. */
  1179. if (spec->num_adc_nids > 1) {
  1180. codec->num_pcms++;
  1181. info++;
  1182. info->name = spec->stream_name_analog;
  1183. /* No playback stream for second PCM */
  1184. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback;
  1185. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
  1186. if (spec->stream_analog_capture) {
  1187. snd_assert(spec->adc_nids, return -EINVAL);
  1188. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
  1189. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1];
  1190. }
  1191. }
  1192. if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
  1193. codec->num_pcms++;
  1194. info++;
  1195. info->name = spec->stream_name_digital;
  1196. if (spec->multiout.dig_out_nid &&
  1197. spec->stream_digital_playback) {
  1198. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
  1199. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
  1200. }
  1201. if (spec->dig_in_nid &&
  1202. spec->stream_digital_capture) {
  1203. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
  1204. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
  1205. }
  1206. }
  1207. return 0;
  1208. }
  1209. static void alc_free(struct hda_codec *codec)
  1210. {
  1211. struct alc_spec *spec = codec->spec;
  1212. unsigned int i;
  1213. if (! spec)
  1214. return;
  1215. if (spec->kctl_alloc) {
  1216. for (i = 0; i < spec->num_kctl_used; i++)
  1217. kfree(spec->kctl_alloc[i].name);
  1218. kfree(spec->kctl_alloc);
  1219. }
  1220. kfree(spec);
  1221. }
  1222. /*
  1223. */
  1224. static struct hda_codec_ops alc_patch_ops = {
  1225. .build_controls = alc_build_controls,
  1226. .build_pcms = alc_build_pcms,
  1227. .init = alc_init,
  1228. .free = alc_free,
  1229. #ifdef CONFIG_PM
  1230. .resume = alc_resume,
  1231. #endif
  1232. };
  1233. /*
  1234. * Test configuration for debugging
  1235. *
  1236. * Almost all inputs/outputs are enabled. I/O pins can be configured via
  1237. * enum controls.
  1238. */
  1239. #ifdef CONFIG_SND_DEBUG
  1240. static hda_nid_t alc880_test_dac_nids[4] = {
  1241. 0x02, 0x03, 0x04, 0x05
  1242. };
  1243. static struct hda_input_mux alc880_test_capture_source = {
  1244. .num_items = 5,
  1245. .items = {
  1246. { "In-1", 0x0 },
  1247. { "In-2", 0x1 },
  1248. { "In-3", 0x2 },
  1249. { "In-4", 0x3 },
  1250. { "CD", 0x4 },
  1251. },
  1252. };
  1253. static struct hda_channel_mode alc880_test_modes[4] = {
  1254. { 2, NULL },
  1255. { 4, NULL },
  1256. { 6, NULL },
  1257. { 8, NULL },
  1258. };
  1259. static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
  1260. {
  1261. static char *texts[] = {
  1262. "N/A", "Line Out", "HP Out",
  1263. "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
  1264. };
  1265. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  1266. uinfo->count = 1;
  1267. uinfo->value.enumerated.items = 8;
  1268. if (uinfo->value.enumerated.item >= 8)
  1269. uinfo->value.enumerated.item = 7;
  1270. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  1271. return 0;
  1272. }
  1273. static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  1274. {
  1275. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  1276. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  1277. unsigned int pin_ctl, item = 0;
  1278. pin_ctl = snd_hda_codec_read(codec, nid, 0,
  1279. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  1280. if (pin_ctl & AC_PINCTL_OUT_EN) {
  1281. if (pin_ctl & AC_PINCTL_HP_EN)
  1282. item = 2;
  1283. else
  1284. item = 1;
  1285. } else if (pin_ctl & AC_PINCTL_IN_EN) {
  1286. switch (pin_ctl & AC_PINCTL_VREFEN) {
  1287. case AC_PINCTL_VREF_HIZ: item = 3; break;
  1288. case AC_PINCTL_VREF_50: item = 4; break;
  1289. case AC_PINCTL_VREF_GRD: item = 5; break;
  1290. case AC_PINCTL_VREF_80: item = 6; break;
  1291. case AC_PINCTL_VREF_100: item = 7; break;
  1292. }
  1293. }
  1294. ucontrol->value.enumerated.item[0] = item;
  1295. return 0;
  1296. }
  1297. static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  1298. {
  1299. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  1300. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  1301. static unsigned int ctls[] = {
  1302. 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
  1303. AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
  1304. AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
  1305. AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
  1306. AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
  1307. AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
  1308. };
  1309. unsigned int old_ctl, new_ctl;
  1310. old_ctl = snd_hda_codec_read(codec, nid, 0,
  1311. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  1312. new_ctl = ctls[ucontrol->value.enumerated.item[0]];
  1313. if (old_ctl != new_ctl) {
  1314. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, new_ctl);
  1315. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  1316. ucontrol->value.enumerated.item[0] >= 3 ? 0xb080 : 0xb000);
  1317. return 1;
  1318. }
  1319. return 0;
  1320. }
  1321. static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
  1322. {
  1323. static char *texts[] = {
  1324. "Front", "Surround", "CLFE", "Side"
  1325. };
  1326. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  1327. uinfo->count = 1;
  1328. uinfo->value.enumerated.items = 4;
  1329. if (uinfo->value.enumerated.item >= 4)
  1330. uinfo->value.enumerated.item = 3;
  1331. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  1332. return 0;
  1333. }
  1334. static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  1335. {
  1336. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  1337. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  1338. unsigned int sel;
  1339. sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
  1340. ucontrol->value.enumerated.item[0] = sel & 3;
  1341. return 0;
  1342. }
  1343. static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  1344. {
  1345. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  1346. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  1347. unsigned int sel;
  1348. sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
  1349. if (ucontrol->value.enumerated.item[0] != sel) {
  1350. sel = ucontrol->value.enumerated.item[0] & 3;
  1351. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, sel);
  1352. return 1;
  1353. }
  1354. return 0;
  1355. }
  1356. #define PIN_CTL_TEST(xname,nid) { \
  1357. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  1358. .name = xname, \
  1359. .info = alc_test_pin_ctl_info, \
  1360. .get = alc_test_pin_ctl_get, \
  1361. .put = alc_test_pin_ctl_put, \
  1362. .private_value = nid \
  1363. }
  1364. #define PIN_SRC_TEST(xname,nid) { \
  1365. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  1366. .name = xname, \
  1367. .info = alc_test_pin_src_info, \
  1368. .get = alc_test_pin_src_get, \
  1369. .put = alc_test_pin_src_put, \
  1370. .private_value = nid \
  1371. }
  1372. static struct snd_kcontrol_new alc880_test_mixer[] = {
  1373. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1374. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1375. HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
  1376. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  1377. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  1378. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  1379. HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
  1380. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  1381. PIN_CTL_TEST("Front Pin Mode", 0x14),
  1382. PIN_CTL_TEST("Surround Pin Mode", 0x15),
  1383. PIN_CTL_TEST("CLFE Pin Mode", 0x16),
  1384. PIN_CTL_TEST("Side Pin Mode", 0x17),
  1385. PIN_CTL_TEST("In-1 Pin Mode", 0x18),
  1386. PIN_CTL_TEST("In-2 Pin Mode", 0x19),
  1387. PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
  1388. PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
  1389. PIN_SRC_TEST("In-1 Pin Source", 0x18),
  1390. PIN_SRC_TEST("In-2 Pin Source", 0x19),
  1391. PIN_SRC_TEST("In-3 Pin Source", 0x1a),
  1392. PIN_SRC_TEST("In-4 Pin Source", 0x1b),
  1393. HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1394. HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1395. HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1396. HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1397. HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
  1398. HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
  1399. HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
  1400. HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
  1401. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
  1402. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
  1403. {
  1404. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1405. .name = "Channel Mode",
  1406. .info = alc_ch_mode_info,
  1407. .get = alc_ch_mode_get,
  1408. .put = alc_ch_mode_put,
  1409. },
  1410. { } /* end */
  1411. };
  1412. static struct hda_verb alc880_test_init_verbs[] = {
  1413. /* Unmute inputs of 0x0c - 0x0f */
  1414. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1415. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1416. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1417. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1418. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1419. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1420. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1421. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1422. /* Vol output for 0x0c-0x0f */
  1423. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1424. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1425. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1426. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1427. /* Set output pins 0x14-0x17 */
  1428. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1429. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1430. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1431. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1432. /* Unmute output pins 0x14-0x17 */
  1433. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1434. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1435. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1436. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1437. /* Set input pins 0x18-0x1c */
  1438. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1439. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1440. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1441. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1442. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1443. /* Mute input pins 0x18-0x1b */
  1444. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1445. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1446. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1447. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1448. /* ADC set up */
  1449. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1450. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  1451. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1452. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  1453. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1454. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  1455. /* Analog input/passthru */
  1456. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1457. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1458. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  1459. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  1460. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  1461. { }
  1462. };
  1463. #endif
  1464. /*
  1465. */
  1466. static struct hda_board_config alc880_cfg_tbl[] = {
  1467. /* Back 3 jack, front 2 jack */
  1468. { .modelname = "3stack", .config = ALC880_3ST },
  1469. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe200, .config = ALC880_3ST },
  1470. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe201, .config = ALC880_3ST },
  1471. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe202, .config = ALC880_3ST },
  1472. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe203, .config = ALC880_3ST },
  1473. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe204, .config = ALC880_3ST },
  1474. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe205, .config = ALC880_3ST },
  1475. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe206, .config = ALC880_3ST },
  1476. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe207, .config = ALC880_3ST },
  1477. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe208, .config = ALC880_3ST },
  1478. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe209, .config = ALC880_3ST },
  1479. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20a, .config = ALC880_3ST },
  1480. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20b, .config = ALC880_3ST },
  1481. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20c, .config = ALC880_3ST },
  1482. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20d, .config = ALC880_3ST },
  1483. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20e, .config = ALC880_3ST },
  1484. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20f, .config = ALC880_3ST },
  1485. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe210, .config = ALC880_3ST },
  1486. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe211, .config = ALC880_3ST },
  1487. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe214, .config = ALC880_3ST },
  1488. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe302, .config = ALC880_3ST },
  1489. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe303, .config = ALC880_3ST },
  1490. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe304, .config = ALC880_3ST },
  1491. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe306, .config = ALC880_3ST },
  1492. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe307, .config = ALC880_3ST },
  1493. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe404, .config = ALC880_3ST },
  1494. { .pci_subvendor = 0x8086, .pci_subdevice = 0xa101, .config = ALC880_3ST },
  1495. { .pci_subvendor = 0x107b, .pci_subdevice = 0x3031, .config = ALC880_3ST },
  1496. { .pci_subvendor = 0x107b, .pci_subdevice = 0x4036, .config = ALC880_3ST },
  1497. { .pci_subvendor = 0x107b, .pci_subdevice = 0x4037, .config = ALC880_3ST },
  1498. { .pci_subvendor = 0x107b, .pci_subdevice = 0x4038, .config = ALC880_3ST },
  1499. { .pci_subvendor = 0x107b, .pci_subdevice = 0x4040, .config = ALC880_3ST },
  1500. { .pci_subvendor = 0x107b, .pci_subdevice = 0x4041, .config = ALC880_3ST },
  1501. /* TCL S700 */
  1502. { .pci_subvendor = 0x19db, .pci_subdevice = 0x4188, .config = ALC880_TCL_S700 },
  1503. /* Back 3 jack, front 2 jack (Internal add Aux-In) */
  1504. { .pci_subvendor = 0x1025, .pci_subdevice = 0xe310, .config = ALC880_3ST },
  1505. { .pci_subvendor = 0x104d, .pci_subdevice = 0x81d6, .config = ALC880_3ST },
  1506. { .pci_subvendor = 0x104d, .pci_subdevice = 0x81a0, .config = ALC880_3ST },
  1507. /* Back 3 jack plus 1 SPDIF out jack, front 2 jack */
  1508. { .modelname = "3stack-digout", .config = ALC880_3ST_DIG },
  1509. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe308, .config = ALC880_3ST_DIG },
  1510. { .pci_subvendor = 0x1025, .pci_subdevice = 0x0070, .config = ALC880_3ST_DIG },
  1511. /* Clevo m520G NB */
  1512. { .pci_subvendor = 0x1558, .pci_subdevice = 0x0520, .config = ALC880_CLEVO },
  1513. /* Back 3 jack plus 1 SPDIF out jack, front 2 jack (Internal add Aux-In)*/
  1514. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe305, .config = ALC880_3ST_DIG },
  1515. { .pci_subvendor = 0x8086, .pci_subdevice = 0xd402, .config = ALC880_3ST_DIG },
  1516. { .pci_subvendor = 0x1025, .pci_subdevice = 0xe309, .config = ALC880_3ST_DIG },
  1517. /* Back 5 jack, front 2 jack */
  1518. { .modelname = "5stack", .config = ALC880_5ST },
  1519. { .pci_subvendor = 0x107b, .pci_subdevice = 0x3033, .config = ALC880_5ST },
  1520. { .pci_subvendor = 0x107b, .pci_subdevice = 0x4039, .config = ALC880_5ST },
  1521. { .pci_subvendor = 0x107b, .pci_subdevice = 0x3032, .config = ALC880_5ST },
  1522. { .pci_subvendor = 0x103c, .pci_subdevice = 0x2a09, .config = ALC880_5ST },
  1523. { .pci_subvendor = 0x1043, .pci_subdevice = 0x814e, .config = ALC880_5ST },
  1524. /* Back 5 jack plus 1 SPDIF out jack, front 2 jack */
  1525. { .modelname = "5stack-digout", .config = ALC880_5ST_DIG },
  1526. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe224, .config = ALC880_5ST_DIG },
  1527. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe400, .config = ALC880_5ST_DIG },
  1528. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe401, .config = ALC880_5ST_DIG },
  1529. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe402, .config = ALC880_5ST_DIG },
  1530. { .pci_subvendor = 0x8086, .pci_subdevice = 0xd400, .config = ALC880_5ST_DIG },
  1531. { .pci_subvendor = 0x8086, .pci_subdevice = 0xd401, .config = ALC880_5ST_DIG },
  1532. { .pci_subvendor = 0x8086, .pci_subdevice = 0xa100, .config = ALC880_5ST_DIG },
  1533. { .pci_subvendor = 0x1565, .pci_subdevice = 0x8202, .config = ALC880_5ST_DIG },
  1534. { .pci_subvendor = 0x1019, .pci_subdevice = 0xa880, .config = ALC880_5ST_DIG },
  1535. /* { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_5ST_DIG }, */ /* conflict with 6stack */
  1536. { .pci_subvendor = 0x1695, .pci_subdevice = 0x400d, .config = ALC880_5ST_DIG },
  1537. /* note subvendor = 0 below */
  1538. /* { .pci_subvendor = 0x0000, .pci_subdevice = 0x8086, .config = ALC880_5ST_DIG }, */
  1539. { .modelname = "w810", .config = ALC880_W810 },
  1540. { .pci_subvendor = 0x161f, .pci_subdevice = 0x203d, .config = ALC880_W810 },
  1541. { .modelname = "z71v", .config = ALC880_Z71V },
  1542. { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_Z71V },
  1543. { .modelname = "6stack", .config = ALC880_6ST },
  1544. { .pci_subvendor = 0x1043, .pci_subdevice = 0x8196, .config = ALC880_6ST }, /* ASUS P5GD1-HVM */
  1545. { .pci_subvendor = 0x1043, .pci_subdevice = 0x81b4, .config = ALC880_6ST },
  1546. { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_6ST }, /* Acer APFV */
  1547. { .pci_subvendor = 0x1458, .pci_subdevice = 0xa102, .config = ALC880_6ST }, /* Gigabyte K8N51 */
  1548. { .modelname = "6stack-digout", .config = ALC880_6ST_DIG },
  1549. { .pci_subvendor = 0x2668, .pci_subdevice = 0x8086, .config = ALC880_6ST_DIG },
  1550. { .pci_subvendor = 0x8086, .pci_subdevice = 0x2668, .config = ALC880_6ST_DIG },
  1551. { .pci_subvendor = 0x1462, .pci_subdevice = 0x1150, .config = ALC880_6ST_DIG },
  1552. { .pci_subvendor = 0xe803, .pci_subdevice = 0x1019, .config = ALC880_6ST_DIG },
  1553. { .pci_subvendor = 0x1039, .pci_subdevice = 0x1234, .config = ALC880_6ST_DIG },
  1554. { .pci_subvendor = 0x1025, .pci_subdevice = 0x0077, .config = ALC880_6ST_DIG },
  1555. { .pci_subvendor = 0x1025, .pci_subdevice = 0x0078, .config = ALC880_6ST_DIG },
  1556. { .pci_subvendor = 0x1025, .pci_subdevice = 0x0087, .config = ALC880_6ST_DIG },
  1557. { .pci_subvendor = 0x1297, .pci_subdevice = 0xc790, .config = ALC880_6ST_DIG }, /* Shuttle ST20G5 */
  1558. { .modelname = "asus", .config = ALC880_ASUS },
  1559. { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_ASUS_DIG },
  1560. { .pci_subvendor = 0x1043, .pci_subdevice = 0x1973, .config = ALC880_ASUS_DIG },
  1561. { .pci_subvendor = 0x1043, .pci_subdevice = 0x19b3, .config = ALC880_ASUS_DIG },
  1562. { .pci_subvendor = 0x1043, .pci_subdevice = 0x1113, .config = ALC880_ASUS_DIG },
  1563. { .pci_subvendor = 0x1043, .pci_subdevice = 0x1173, .config = ALC880_ASUS_DIG },
  1564. { .pci_subvendor = 0x1043, .pci_subdevice = 0x1993, .config = ALC880_ASUS },
  1565. { .pci_subvendor = 0x1043, .pci_subdevice = 0x10c3, .config = ALC880_ASUS_DIG },
  1566. { .pci_subvendor = 0x1043, .pci_subdevice = 0x1133, .config = ALC880_ASUS },
  1567. { .pci_subvendor = 0x1043, .pci_subdevice = 0x1123, .config = ALC880_ASUS_DIG },
  1568. { .pci_subvendor = 0x1043, .pci_subdevice = 0x1143, .config = ALC880_ASUS },
  1569. { .pci_subvendor = 0x1043, .pci_subdevice = 0x10b3, .config = ALC880_ASUS_W1V },
  1570. { .pci_subvendor = 0x1558, .pci_subdevice = 0x5401, .config = ALC880_ASUS_DIG2 },
  1571. { .modelname = "uniwill", .config = ALC880_UNIWILL_DIG },
  1572. { .pci_subvendor = 0x1584, .pci_subdevice = 0x9050, .config = ALC880_UNIWILL_DIG },
  1573. { .modelname = "F1734", .config = ALC880_F1734 },
  1574. { .pci_subvendor = 0x1734, .pci_subdevice = 0x107c, .config = ALC880_F1734 },
  1575. { .pci_subvendor = 0x1584, .pci_subdevice = 0x9054, .config = ALC880_F1734 },
  1576. #ifdef CONFIG_SND_DEBUG
  1577. { .modelname = "test", .config = ALC880_TEST },
  1578. #endif
  1579. { .modelname = "auto", .config = ALC880_AUTO },
  1580. {}
  1581. };
  1582. /*
  1583. * ALC880 codec presets
  1584. */
  1585. static struct alc_config_preset alc880_presets[] = {
  1586. [ALC880_3ST] = {
  1587. .mixers = { alc880_three_stack_mixer },
  1588. .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
  1589. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  1590. .dac_nids = alc880_dac_nids,
  1591. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  1592. .channel_mode = alc880_threestack_modes,
  1593. .input_mux = &alc880_capture_source,
  1594. },
  1595. [ALC880_3ST_DIG] = {
  1596. .mixers = { alc880_three_stack_mixer },
  1597. .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
  1598. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  1599. .dac_nids = alc880_dac_nids,
  1600. .dig_out_nid = ALC880_DIGOUT_NID,
  1601. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  1602. .channel_mode = alc880_threestack_modes,
  1603. .input_mux = &alc880_capture_source,
  1604. },
  1605. [ALC880_TCL_S700] = {
  1606. .mixers = { alc880_tcl_s700_mixer },
  1607. .init_verbs = { alc880_volume_init_verbs,
  1608. alc880_pin_tcl_S700_init_verbs,
  1609. alc880_gpio2_init_verbs },
  1610. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  1611. .dac_nids = alc880_dac_nids,
  1612. .hp_nid = 0x03,
  1613. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  1614. .channel_mode = alc880_2_jack_modes,
  1615. .input_mux = &alc880_capture_source,
  1616. },
  1617. [ALC880_5ST] = {
  1618. .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer},
  1619. .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
  1620. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  1621. .dac_nids = alc880_dac_nids,
  1622. .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
  1623. .channel_mode = alc880_fivestack_modes,
  1624. .input_mux = &alc880_capture_source,
  1625. },
  1626. [ALC880_5ST_DIG] = {
  1627. .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer },
  1628. .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
  1629. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  1630. .dac_nids = alc880_dac_nids,
  1631. .dig_out_nid = ALC880_DIGOUT_NID,
  1632. .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
  1633. .channel_mode = alc880_fivestack_modes,
  1634. .input_mux = &alc880_capture_source,
  1635. },
  1636. [ALC880_6ST] = {
  1637. .mixers = { alc880_six_stack_mixer },
  1638. .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs },
  1639. .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
  1640. .dac_nids = alc880_6st_dac_nids,
  1641. .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
  1642. .channel_mode = alc880_sixstack_modes,
  1643. .input_mux = &alc880_6stack_capture_source,
  1644. },
  1645. [ALC880_6ST_DIG] = {
  1646. .mixers = { alc880_six_stack_mixer },
  1647. .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs },
  1648. .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
  1649. .dac_nids = alc880_6st_dac_nids,
  1650. .dig_out_nid = ALC880_DIGOUT_NID,
  1651. .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
  1652. .channel_mode = alc880_sixstack_modes,
  1653. .input_mux = &alc880_6stack_capture_source,
  1654. },
  1655. [ALC880_W810] = {
  1656. .mixers = { alc880_w810_base_mixer },
  1657. .init_verbs = { alc880_volume_init_verbs, alc880_pin_w810_init_verbs,
  1658. alc880_gpio2_init_verbs },
  1659. .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
  1660. .dac_nids = alc880_w810_dac_nids,
  1661. .dig_out_nid = ALC880_DIGOUT_NID,
  1662. .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
  1663. .channel_mode = alc880_w810_modes,
  1664. .input_mux = &alc880_capture_source,
  1665. },
  1666. [ALC880_Z71V] = {
  1667. .mixers = { alc880_z71v_mixer },
  1668. .init_verbs = { alc880_volume_init_verbs, alc880_pin_z71v_init_verbs },
  1669. .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
  1670. .dac_nids = alc880_z71v_dac_nids,
  1671. .dig_out_nid = ALC880_DIGOUT_NID,
  1672. .hp_nid = 0x03,
  1673. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  1674. .channel_mode = alc880_2_jack_modes,
  1675. .input_mux = &alc880_capture_source,
  1676. },
  1677. [ALC880_F1734] = {
  1678. .mixers = { alc880_f1734_mixer },
  1679. .init_verbs = { alc880_volume_init_verbs, alc880_pin_f1734_init_verbs },
  1680. .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
  1681. .dac_nids = alc880_f1734_dac_nids,
  1682. .hp_nid = 0x02,
  1683. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  1684. .channel_mode = alc880_2_jack_modes,
  1685. .input_mux = &alc880_capture_source,
  1686. },
  1687. [ALC880_ASUS] = {
  1688. .mixers = { alc880_asus_mixer },
  1689. .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
  1690. alc880_gpio1_init_verbs },
  1691. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  1692. .dac_nids = alc880_asus_dac_nids,
  1693. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  1694. .channel_mode = alc880_asus_modes,
  1695. .input_mux = &alc880_capture_source,
  1696. },
  1697. [ALC880_ASUS_DIG] = {
  1698. .mixers = { alc880_asus_mixer },
  1699. .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
  1700. alc880_gpio1_init_verbs },
  1701. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  1702. .dac_nids = alc880_asus_dac_nids,
  1703. .dig_out_nid = ALC880_DIGOUT_NID,
  1704. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  1705. .channel_mode = alc880_asus_modes,
  1706. .input_mux = &alc880_capture_source,
  1707. },
  1708. [ALC880_ASUS_DIG2] = {
  1709. .mixers = { alc880_asus_mixer },
  1710. .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
  1711. alc880_gpio2_init_verbs }, /* use GPIO2 */
  1712. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  1713. .dac_nids = alc880_asus_dac_nids,
  1714. .dig_out_nid = ALC880_DIGOUT_NID,
  1715. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  1716. .channel_mode = alc880_asus_modes,
  1717. .input_mux = &alc880_capture_source,
  1718. },
  1719. [ALC880_ASUS_W1V] = {
  1720. .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
  1721. .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
  1722. alc880_gpio1_init_verbs },
  1723. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  1724. .dac_nids = alc880_asus_dac_nids,
  1725. .dig_out_nid = ALC880_DIGOUT_NID,
  1726. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  1727. .channel_mode = alc880_asus_modes,
  1728. .input_mux = &alc880_capture_source,
  1729. },
  1730. [ALC880_UNIWILL_DIG] = {
  1731. .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
  1732. .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs },
  1733. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  1734. .dac_nids = alc880_asus_dac_nids,
  1735. .dig_out_nid = ALC880_DIGOUT_NID,
  1736. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  1737. .channel_mode = alc880_asus_modes,
  1738. .input_mux = &alc880_capture_source,
  1739. },
  1740. [ALC880_CLEVO] = {
  1741. .mixers = { alc880_three_stack_mixer },
  1742. .init_verbs = { alc880_volume_init_verbs,
  1743. alc880_pin_clevo_init_verbs },
  1744. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  1745. .dac_nids = alc880_dac_nids,
  1746. .hp_nid = 0x03,
  1747. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  1748. .channel_mode = alc880_threestack_modes,
  1749. .input_mux = &alc880_capture_source,
  1750. },
  1751. #ifdef CONFIG_SND_DEBUG
  1752. [ALC880_TEST] = {
  1753. .mixers = { alc880_test_mixer },
  1754. .init_verbs = { alc880_test_init_verbs },
  1755. .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
  1756. .dac_nids = alc880_test_dac_nids,
  1757. .dig_out_nid = ALC880_DIGOUT_NID,
  1758. .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
  1759. .channel_mode = alc880_test_modes,
  1760. .input_mux = &alc880_test_capture_source,
  1761. },
  1762. #endif
  1763. };
  1764. /*
  1765. * Automatic parse of I/O pins from the BIOS configuration
  1766. */
  1767. #define NUM_CONTROL_ALLOC 32
  1768. #define NUM_VERB_ALLOC 32
  1769. enum {
  1770. ALC_CTL_WIDGET_VOL,
  1771. ALC_CTL_WIDGET_MUTE,
  1772. ALC_CTL_BIND_MUTE,
  1773. };
  1774. static struct snd_kcontrol_new alc880_control_templates[] = {
  1775. HDA_CODEC_VOLUME(NULL, 0, 0, 0),
  1776. HDA_CODEC_MUTE(NULL, 0, 0, 0),
  1777. HDA_BIND_MUTE(NULL, 0, 0, 0),
  1778. };
  1779. /* add dynamic controls */
  1780. static int add_control(struct alc_spec *spec, int type, const char *name, unsigned long val)
  1781. {
  1782. struct snd_kcontrol_new *knew;
  1783. if (spec->num_kctl_used >= spec->num_kctl_alloc) {
  1784. int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
  1785. knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
  1786. if (! knew)
  1787. return -ENOMEM;
  1788. if (spec->kctl_alloc) {
  1789. memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
  1790. kfree(spec->kctl_alloc);
  1791. }
  1792. spec->kctl_alloc = knew;
  1793. spec->num_kctl_alloc = num;
  1794. }
  1795. knew = &spec->kctl_alloc[spec->num_kctl_used];
  1796. *knew = alc880_control_templates[type];
  1797. knew->name = kstrdup(name, GFP_KERNEL);
  1798. if (! knew->name)
  1799. return -ENOMEM;
  1800. knew->private_value = val;
  1801. spec->num_kctl_used++;
  1802. return 0;
  1803. }
  1804. #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
  1805. #define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
  1806. #define alc880_is_multi_pin(nid) ((nid) >= 0x18)
  1807. #define alc880_multi_pin_idx(nid) ((nid) - 0x18)
  1808. #define alc880_is_input_pin(nid) ((nid) >= 0x18)
  1809. #define alc880_input_pin_idx(nid) ((nid) - 0x18)
  1810. #define alc880_idx_to_dac(nid) ((nid) + 0x02)
  1811. #define alc880_dac_to_idx(nid) ((nid) - 0x02)
  1812. #define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
  1813. #define alc880_idx_to_selector(nid) ((nid) + 0x10)
  1814. #define ALC880_PIN_CD_NID 0x1c
  1815. /* fill in the dac_nids table from the parsed pin configuration */
  1816. static int alc880_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
  1817. {
  1818. hda_nid_t nid;
  1819. int assigned[4];
  1820. int i, j;
  1821. memset(assigned, 0, sizeof(assigned));
  1822. spec->multiout.dac_nids = spec->private_dac_nids;
  1823. /* check the pins hardwired to audio widget */
  1824. for (i = 0; i < cfg->line_outs; i++) {
  1825. nid = cfg->line_out_pins[i];
  1826. if (alc880_is_fixed_pin(nid)) {
  1827. int idx = alc880_fixed_pin_idx(nid);
  1828. spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
  1829. assigned[idx] = 1;
  1830. }
  1831. }
  1832. /* left pins can be connect to any audio widget */
  1833. for (i = 0; i < cfg->line_outs; i++) {
  1834. nid = cfg->line_out_pins[i];
  1835. if (alc880_is_fixed_pin(nid))
  1836. continue;
  1837. /* search for an empty channel */
  1838. for (j = 0; j < cfg->line_outs; j++) {
  1839. if (! assigned[j]) {
  1840. spec->multiout.dac_nids[i] = alc880_idx_to_dac(j);
  1841. assigned[j] = 1;
  1842. break;
  1843. }
  1844. }
  1845. }
  1846. spec->multiout.num_dacs = cfg->line_outs;
  1847. return 0;
  1848. }
  1849. /* add playback controls from the parsed DAC table */
  1850. static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
  1851. const struct auto_pin_cfg *cfg)
  1852. {
  1853. char name[32];
  1854. static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
  1855. hda_nid_t nid;
  1856. int i, err;
  1857. for (i = 0; i < cfg->line_outs; i++) {
  1858. if (! spec->multiout.dac_nids[i])
  1859. continue;
  1860. nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
  1861. if (i == 2) {
  1862. /* Center/LFE */
  1863. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Center Playback Volume",
  1864. HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
  1865. return err;
  1866. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "LFE Playback Volume",
  1867. HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
  1868. return err;
  1869. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch",
  1870. HDA_COMPOSE_AMP_VAL(nid, 1, 2, HDA_INPUT))) < 0)
  1871. return err;
  1872. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch",
  1873. HDA_COMPOSE_AMP_VAL(nid, 2, 2, HDA_INPUT))) < 0)
  1874. return err;
  1875. } else {
  1876. sprintf(name, "%s Playback Volume", chname[i]);
  1877. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  1878. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  1879. return err;
  1880. sprintf(name, "%s Playback Switch", chname[i]);
  1881. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  1882. HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
  1883. return err;
  1884. }
  1885. }
  1886. return 0;
  1887. }
  1888. /* add playback controls for speaker and HP outputs */
  1889. static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
  1890. const char *pfx)
  1891. {
  1892. hda_nid_t nid;
  1893. int err;
  1894. char name[32];
  1895. if (! pin)
  1896. return 0;
  1897. if (alc880_is_fixed_pin(pin)) {
  1898. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  1899. if (! spec->multiout.dac_nids[0]) {
  1900. /* use this as the primary output */
  1901. spec->multiout.dac_nids[0] = nid;
  1902. if (! spec->multiout.num_dacs)
  1903. spec->multiout.num_dacs = 1;
  1904. } else
  1905. /* specify the DAC as the extra output */
  1906. spec->multiout.hp_nid = nid;
  1907. /* control HP volume/switch on the output mixer amp */
  1908. nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
  1909. sprintf(name, "%s Playback Volume", pfx);
  1910. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  1911. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  1912. return err;
  1913. sprintf(name, "%s Playback Switch", pfx);
  1914. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  1915. HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
  1916. return err;
  1917. } else if (alc880_is_multi_pin(pin)) {
  1918. /* set manual connection */
  1919. if (! spec->multiout.dac_nids[0]) {
  1920. /* use this as the primary output */
  1921. spec->multiout.dac_nids[0] = alc880_idx_to_dac(alc880_multi_pin_idx(pin));
  1922. if (! spec->multiout.num_dacs)
  1923. spec->multiout.num_dacs = 1;
  1924. }
  1925. /* we have only a switch on HP-out PIN */
  1926. sprintf(name, "%s Playback Switch", pfx);
  1927. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  1928. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT))) < 0)
  1929. return err;
  1930. }
  1931. return 0;
  1932. }
  1933. /* create input playback/capture controls for the given pin */
  1934. static int new_analog_input(struct alc_spec *spec, hda_nid_t pin, const char *ctlname,
  1935. int idx, hda_nid_t mix_nid)
  1936. {
  1937. char name[32];
  1938. int err;
  1939. sprintf(name, "%s Playback Volume", ctlname);
  1940. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  1941. HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0)
  1942. return err;
  1943. sprintf(name, "%s Playback Switch", ctlname);
  1944. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  1945. HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0)
  1946. return err;
  1947. return 0;
  1948. }
  1949. /* create playback/capture controls for input pins */
  1950. static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
  1951. const struct auto_pin_cfg *cfg)
  1952. {
  1953. struct hda_input_mux *imux = &spec->private_imux;
  1954. int i, err, idx;
  1955. for (i = 0; i < AUTO_PIN_LAST; i++) {
  1956. if (alc880_is_input_pin(cfg->input_pins[i])) {
  1957. idx = alc880_input_pin_idx(cfg->input_pins[i]);
  1958. err = new_analog_input(spec, cfg->input_pins[i],
  1959. auto_pin_cfg_labels[i],
  1960. idx, 0x0b);
  1961. if (err < 0)
  1962. return err;
  1963. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  1964. imux->items[imux->num_items].index = alc880_input_pin_idx(cfg->input_pins[i]);
  1965. imux->num_items++;
  1966. }
  1967. }
  1968. return 0;
  1969. }
  1970. static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
  1971. hda_nid_t nid, int pin_type,
  1972. int dac_idx)
  1973. {
  1974. /* set as output */
  1975. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  1976. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  1977. /* need the manual connection? */
  1978. if (alc880_is_multi_pin(nid)) {
  1979. struct alc_spec *spec = codec->spec;
  1980. int idx = alc880_multi_pin_idx(nid);
  1981. snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
  1982. AC_VERB_SET_CONNECT_SEL,
  1983. alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
  1984. }
  1985. }
  1986. static void alc880_auto_init_multi_out(struct hda_codec *codec)
  1987. {
  1988. struct alc_spec *spec = codec->spec;
  1989. int i;
  1990. for (i = 0; i < spec->autocfg.line_outs; i++) {
  1991. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  1992. alc880_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
  1993. }
  1994. }
  1995. static void alc880_auto_init_extra_out(struct hda_codec *codec)
  1996. {
  1997. struct alc_spec *spec = codec->spec;
  1998. hda_nid_t pin;
  1999. pin = spec->autocfg.speaker_pin;
  2000. if (pin) /* connect to front */
  2001. alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
  2002. pin = spec->autocfg.hp_pin;
  2003. if (pin) /* connect to front */
  2004. alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  2005. }
  2006. static void alc880_auto_init_analog_input(struct hda_codec *codec)
  2007. {
  2008. struct alc_spec *spec = codec->spec;
  2009. int i;
  2010. for (i = 0; i < AUTO_PIN_LAST; i++) {
  2011. hda_nid_t nid = spec->autocfg.input_pins[i];
  2012. if (alc880_is_input_pin(nid)) {
  2013. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  2014. i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
  2015. if (nid != ALC880_PIN_CD_NID)
  2016. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  2017. AMP_OUT_MUTE);
  2018. }
  2019. }
  2020. }
  2021. /* parse the BIOS configuration and set up the alc_spec */
  2022. /* return 1 if successful, 0 if the proper config is not found, or a negative error code */
  2023. static int alc880_parse_auto_config(struct hda_codec *codec)
  2024. {
  2025. struct alc_spec *spec = codec->spec;
  2026. int err;
  2027. static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
  2028. if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  2029. alc880_ignore)) < 0)
  2030. return err;
  2031. if (! spec->autocfg.line_outs && ! spec->autocfg.speaker_pin &&
  2032. ! spec->autocfg.hp_pin)
  2033. return 0; /* can't find valid BIOS pin config */
  2034. if ((err = alc880_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 ||
  2035. (err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
  2036. (err = alc880_auto_create_extra_out(spec, spec->autocfg.speaker_pin,
  2037. "Speaker")) < 0 ||
  2038. (err = alc880_auto_create_extra_out(spec, spec->autocfg.speaker_pin,
  2039. "Headphone")) < 0 ||
  2040. (err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
  2041. return err;
  2042. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  2043. if (spec->autocfg.dig_out_pin)
  2044. spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
  2045. if (spec->autocfg.dig_in_pin)
  2046. spec->dig_in_nid = ALC880_DIGIN_NID;
  2047. if (spec->kctl_alloc)
  2048. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  2049. spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
  2050. spec->input_mux = &spec->private_imux;
  2051. return 1;
  2052. }
  2053. /* init callback for auto-configuration model -- overriding the default init */
  2054. static int alc880_auto_init(struct hda_codec *codec)
  2055. {
  2056. alc_init(codec);
  2057. alc880_auto_init_multi_out(codec);
  2058. alc880_auto_init_extra_out(codec);
  2059. alc880_auto_init_analog_input(codec);
  2060. return 0;
  2061. }
  2062. /*
  2063. * OK, here we have finally the patch for ALC880
  2064. */
  2065. static int patch_alc880(struct hda_codec *codec)
  2066. {
  2067. struct alc_spec *spec;
  2068. int board_config;
  2069. int err;
  2070. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  2071. if (spec == NULL)
  2072. return -ENOMEM;
  2073. codec->spec = spec;
  2074. board_config = snd_hda_check_board_config(codec, alc880_cfg_tbl);
  2075. if (board_config < 0 || board_config >= ALC880_MODEL_LAST) {
  2076. printk(KERN_INFO "hda_codec: Unknown model for ALC880, trying auto-probe from BIOS...\n");
  2077. board_config = ALC880_AUTO;
  2078. }
  2079. if (board_config == ALC880_AUTO) {
  2080. /* automatic parse from the BIOS config */
  2081. err = alc880_parse_auto_config(codec);
  2082. if (err < 0) {
  2083. alc_free(codec);
  2084. return err;
  2085. } else if (! err) {
  2086. printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using 3-stack mode...\n");
  2087. board_config = ALC880_3ST;
  2088. }
  2089. }
  2090. if (board_config != ALC880_AUTO)
  2091. setup_preset(spec, &alc880_presets[board_config]);
  2092. spec->stream_name_analog = "ALC880 Analog";
  2093. spec->stream_analog_playback = &alc880_pcm_analog_playback;
  2094. spec->stream_analog_capture = &alc880_pcm_analog_capture;
  2095. spec->stream_name_digital = "ALC880 Digital";
  2096. spec->stream_digital_playback = &alc880_pcm_digital_playback;
  2097. spec->stream_digital_capture = &alc880_pcm_digital_capture;
  2098. if (! spec->adc_nids && spec->input_mux) {
  2099. /* check whether NID 0x07 is valid */
  2100. unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
  2101. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
  2102. if (wcap != AC_WID_AUD_IN) {
  2103. spec->adc_nids = alc880_adc_nids_alt;
  2104. spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
  2105. spec->mixers[spec->num_mixers] = alc880_capture_alt_mixer;
  2106. spec->num_mixers++;
  2107. } else {
  2108. spec->adc_nids = alc880_adc_nids;
  2109. spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
  2110. spec->mixers[spec->num_mixers] = alc880_capture_mixer;
  2111. spec->num_mixers++;
  2112. }
  2113. }
  2114. codec->patch_ops = alc_patch_ops;
  2115. if (board_config == ALC880_AUTO)
  2116. codec->patch_ops.init = alc880_auto_init;
  2117. return 0;
  2118. }
  2119. /*
  2120. * ALC260 support
  2121. */
  2122. static hda_nid_t alc260_dac_nids[1] = {
  2123. /* front */
  2124. 0x02,
  2125. };
  2126. static hda_nid_t alc260_adc_nids[1] = {
  2127. /* ADC0 */
  2128. 0x04,
  2129. };
  2130. static hda_nid_t alc260_adc_nids_alt[1] = {
  2131. /* ADC1 */
  2132. 0x05,
  2133. };
  2134. static hda_nid_t alc260_hp_adc_nids[2] = {
  2135. /* ADC1, 0 */
  2136. 0x05, 0x04
  2137. };
  2138. static hda_nid_t alc260_fujitsu_adc_nids[2] = {
  2139. /* ADC0, ADC1 */
  2140. 0x04, 0x05
  2141. };
  2142. #define ALC260_DIGOUT_NID 0x03
  2143. #define ALC260_DIGIN_NID 0x06
  2144. static struct hda_input_mux alc260_capture_source = {
  2145. .num_items = 4,
  2146. .items = {
  2147. { "Mic", 0x0 },
  2148. { "Front Mic", 0x1 },
  2149. { "Line", 0x2 },
  2150. { "CD", 0x4 },
  2151. },
  2152. };
  2153. /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
  2154. * headphone jack and the internal CD lines.
  2155. */
  2156. static struct hda_input_mux alc260_fujitsu_capture_source = {
  2157. .num_items = 3,
  2158. .items = {
  2159. { "Mic/Line", 0x0 },
  2160. { "CD", 0x4 },
  2161. { "Headphone", 0x2 },
  2162. },
  2163. };
  2164. /*
  2165. * This is just place-holder, so there's something for alc_build_pcms to look
  2166. * at when it calculates the maximum number of channels. ALC260 has no mixer
  2167. * element which allows changing the channel mode, so the verb list is
  2168. * never used.
  2169. */
  2170. static struct hda_channel_mode alc260_modes[1] = {
  2171. { 2, NULL },
  2172. };
  2173. /* Mixer combinations
  2174. *
  2175. * basic: base_output + input + pc_beep + capture
  2176. * HP: base_output + input + capture_alt
  2177. * HP_3013: hp_3013 + input + capture
  2178. * fujitsu: fujitsu + capture
  2179. */
  2180. static struct snd_kcontrol_new alc260_base_output_mixer[] = {
  2181. HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  2182. HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
  2183. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  2184. HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
  2185. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  2186. HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
  2187. { } /* end */
  2188. };
  2189. static struct snd_kcontrol_new alc260_input_mixer[] = {
  2190. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  2191. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  2192. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  2193. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  2194. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  2195. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  2196. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
  2197. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
  2198. { } /* end */
  2199. };
  2200. static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
  2201. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
  2202. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
  2203. { } /* end */
  2204. };
  2205. static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
  2206. HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  2207. HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
  2208. HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
  2209. HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
  2210. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  2211. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  2212. HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  2213. HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
  2214. { } /* end */
  2215. };
  2216. static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
  2217. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  2218. HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
  2219. ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  2220. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  2221. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  2222. HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
  2223. HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
  2224. ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
  2225. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  2226. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  2227. HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  2228. HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
  2229. { } /* end */
  2230. };
  2231. /* capture mixer elements */
  2232. static struct snd_kcontrol_new alc260_capture_mixer[] = {
  2233. HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
  2234. HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
  2235. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
  2236. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
  2237. {
  2238. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  2239. /* The multiple "Capture Source" controls confuse alsamixer
  2240. * So call somewhat different..
  2241. * FIXME: the controls appear in the "playback" view!
  2242. */
  2243. /* .name = "Capture Source", */
  2244. .name = "Input Source",
  2245. .count = 2,
  2246. .info = alc_mux_enum_info,
  2247. .get = alc_mux_enum_get,
  2248. .put = alc_mux_enum_put,
  2249. },
  2250. { } /* end */
  2251. };
  2252. static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
  2253. HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
  2254. HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
  2255. {
  2256. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  2257. /* The multiple "Capture Source" controls confuse alsamixer
  2258. * So call somewhat different..
  2259. * FIXME: the controls appear in the "playback" view!
  2260. */
  2261. /* .name = "Capture Source", */
  2262. .name = "Input Source",
  2263. .count = 1,
  2264. .info = alc_mux_enum_info,
  2265. .get = alc_mux_enum_get,
  2266. .put = alc_mux_enum_put,
  2267. },
  2268. { } /* end */
  2269. };
  2270. /*
  2271. * initialization verbs
  2272. */
  2273. static struct hda_verb alc260_init_verbs[] = {
  2274. /* Line In pin widget for input */
  2275. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2276. /* CD pin widget for input */
  2277. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2278. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  2279. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2280. /* Mic2 (front panel) pin widget for input and vref at 80% */
  2281. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2282. /* LINE-2 is used for line-out in rear */
  2283. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2284. /* select line-out */
  2285. {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
  2286. /* LINE-OUT pin */
  2287. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2288. /* enable HP */
  2289. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  2290. /* enable Mono */
  2291. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2292. /* mute capture amp left and right */
  2293. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2294. /* set connection select to line in (default select for this ADC) */
  2295. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  2296. /* mute capture amp left and right */
  2297. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2298. /* set connection select to line in (default select for this ADC) */
  2299. {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
  2300. /* set vol=0 Line-Out mixer amp left and right */
  2301. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2302. /* unmute pin widget amp left and right (no gain on this amp) */
  2303. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2304. /* set vol=0 HP mixer amp left and right */
  2305. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2306. /* unmute pin widget amp left and right (no gain on this amp) */
  2307. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2308. /* set vol=0 Mono mixer amp left and right */
  2309. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2310. /* unmute pin widget amp left and right (no gain on this amp) */
  2311. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2312. /* unmute LINE-2 out pin */
  2313. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2314. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
  2315. /* mute CD */
  2316. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  2317. /* mute Line In */
  2318. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  2319. /* mute Mic */
  2320. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2321. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  2322. /* mute Front out path */
  2323. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2324. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2325. /* mute Headphone out path */
  2326. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2327. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2328. /* mute Mono out path */
  2329. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2330. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2331. { }
  2332. };
  2333. static struct hda_verb alc260_hp_init_verbs[] = {
  2334. /* Headphone and output */
  2335. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  2336. /* mono output */
  2337. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  2338. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  2339. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  2340. /* Mic2 (front panel) pin widget for input and vref at 80% */
  2341. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  2342. /* Line In pin widget for input */
  2343. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  2344. /* Line-2 pin widget for output */
  2345. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  2346. /* CD pin widget for input */
  2347. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  2348. /* unmute amp left and right */
  2349. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  2350. /* set connection select to line in (default select for this ADC) */
  2351. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  2352. /* unmute Line-Out mixer amp left and right (volume = 0) */
  2353. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  2354. /* mute pin widget amp left and right (no gain on this amp) */
  2355. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  2356. /* unmute HP mixer amp left and right (volume = 0) */
  2357. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  2358. /* mute pin widget amp left and right (no gain on this amp) */
  2359. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  2360. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
  2361. /* unmute CD */
  2362. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  2363. /* unmute Line In */
  2364. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  2365. /* unmute Mic */
  2366. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  2367. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  2368. /* Unmute Front out path */
  2369. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  2370. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  2371. /* Unmute Headphone out path */
  2372. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  2373. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  2374. /* Unmute Mono out path */
  2375. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  2376. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  2377. { }
  2378. };
  2379. static struct hda_verb alc260_hp_3013_init_verbs[] = {
  2380. /* Line out and output */
  2381. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  2382. /* mono output */
  2383. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  2384. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  2385. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  2386. /* Mic2 (front panel) pin widget for input and vref at 80% */
  2387. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  2388. /* Line In pin widget for input */
  2389. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  2390. /* Headphone pin widget for output */
  2391. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  2392. /* CD pin widget for input */
  2393. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  2394. /* unmute amp left and right */
  2395. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  2396. /* set connection select to line in (default select for this ADC) */
  2397. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  2398. /* unmute Line-Out mixer amp left and right (volume = 0) */
  2399. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  2400. /* mute pin widget amp left and right (no gain on this amp) */
  2401. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  2402. /* unmute HP mixer amp left and right (volume = 0) */
  2403. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  2404. /* mute pin widget amp left and right (no gain on this amp) */
  2405. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  2406. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
  2407. /* unmute CD */
  2408. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  2409. /* unmute Line In */
  2410. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  2411. /* unmute Mic */
  2412. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  2413. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  2414. /* Unmute Front out path */
  2415. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  2416. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  2417. /* Unmute Headphone out path */
  2418. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  2419. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  2420. /* Unmute Mono out path */
  2421. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  2422. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  2423. { }
  2424. };
  2425. /* Initialisation sequence for ALC260 as configured in Fujitsu S702x
  2426. * laptops.
  2427. */
  2428. static struct hda_verb alc260_fujitsu_init_verbs[] = {
  2429. /* Disable all GPIOs */
  2430. {0x01, AC_VERB_SET_GPIO_MASK, 0},
  2431. /* Internal speaker is connected to headphone pin */
  2432. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  2433. /* Headphone/Line-out jack connects to Line1 pin; make it an output */
  2434. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2435. /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
  2436. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2437. /* Ensure all other unused pins are disabled and muted.
  2438. * Note: trying to set widget 0x15 to anything blocks all audio
  2439. * output for some reason, so just leave that at the default.
  2440. */
  2441. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  2442. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2443. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  2444. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2445. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  2446. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2447. /* Disable digital (SPDIF) pins */
  2448. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  2449. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  2450. /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
  2451. * when acting as an output.
  2452. */
  2453. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  2454. /* Start with output sum widgets muted and their output gains at min */
  2455. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2456. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2457. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2458. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2459. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2460. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2461. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2462. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2463. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2464. /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
  2465. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2466. /* Unmute Line1 pin widget amp left and right (no equiv mixer ctrl) */
  2467. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2468. /* Unmute Line1 pin widget input for when this pin is used as input
  2469. * (no equiv mixer ctrl). Having input and output unmuted doesn't
  2470. * seem to cause a problem.
  2471. */
  2472. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2473. /* Unmute pin widget used for Line-in (no equiv mixer ctrl) */
  2474. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2475. /* Mute capture amp left and right */
  2476. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2477. /* Set ADC connection select to match default mixer setting - line
  2478. * in (on mic1 pin)
  2479. */
  2480. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  2481. /* Do the same for the second ADC: mute capture input amp and
  2482. * set ADC connection to line in
  2483. */
  2484. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2485. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  2486. /* Mute all inputs to mixer widget (even unconnected ones) */
  2487. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  2488. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  2489. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  2490. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  2491. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  2492. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  2493. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  2494. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  2495. { }
  2496. };
  2497. /* Test configuration for debugging, modelled after the ALC880 test
  2498. * configuration.
  2499. */
  2500. #ifdef CONFIG_SND_DEBUG
  2501. static hda_nid_t alc260_test_dac_nids[1] = {
  2502. 0x02,
  2503. };
  2504. static hda_nid_t alc260_test_adc_nids[2] = {
  2505. 0x04, 0x05,
  2506. };
  2507. /* This is a bit messy since the two input muxes in the ALC260 have slight
  2508. * variations in their signal assignments. The ideal way to deal with this
  2509. * is to extend alc_spec.input_mux to allow a different input MUX for each
  2510. * ADC. For the purposes of the test model it's sufficient to just list
  2511. * both options for affected signal indices. The separate input mux
  2512. * functionality only needs to be considered if a model comes along which
  2513. * actually uses signals 0x5, 0x6 and 0x7 for something which makes sense to
  2514. * record.
  2515. */
  2516. static struct hda_input_mux alc260_test_capture_source = {
  2517. .num_items = 8,
  2518. .items = {
  2519. { "MIC1 pin", 0x0 },
  2520. { "MIC2 pin", 0x1 },
  2521. { "LINE1 pin", 0x2 },
  2522. { "LINE2 pin", 0x3 },
  2523. { "CD pin", 0x4 },
  2524. { "LINE-OUT pin (cap1), Mixer (cap2)", 0x5 },
  2525. { "HP-OUT pin (cap1), LINE-OUT pin (cap2)", 0x6 },
  2526. { "HP-OUT pin (cap2 only)", 0x7 },
  2527. },
  2528. };
  2529. static struct snd_kcontrol_new alc260_test_mixer[] = {
  2530. /* Output driver widgets */
  2531. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  2532. HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
  2533. HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  2534. HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
  2535. HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  2536. HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
  2537. /* Modes for retasking pin widgets */
  2538. ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
  2539. ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
  2540. ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
  2541. ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
  2542. ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
  2543. ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
  2544. /* Loopback mixer controls */
  2545. HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
  2546. HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
  2547. HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
  2548. HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
  2549. HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
  2550. HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
  2551. HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
  2552. HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
  2553. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  2554. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  2555. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  2556. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  2557. HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
  2558. HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
  2559. HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
  2560. HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
  2561. { } /* end */
  2562. };
  2563. static struct hda_verb alc260_test_init_verbs[] = {
  2564. /* Disable all GPIOs */
  2565. {0x01, AC_VERB_SET_GPIO_MASK, 0},
  2566. /* Enable retasking pins as output, initially without power amp */
  2567. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2568. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2569. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2570. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2571. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2572. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2573. /* Disable digital (SPDIF) pins for now */
  2574. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  2575. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  2576. /* Ensure mic1, mic2, line1 and line2 pin widget take input from the
  2577. * OUT1 sum bus when acting as an output.
  2578. */
  2579. {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
  2580. {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
  2581. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  2582. {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
  2583. /* Start with output sum widgets muted and their output gains at min */
  2584. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2585. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2586. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2587. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2588. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2589. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2590. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2591. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2592. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2593. /* Unmute retasking pin widget output amp left/right (no mixer ctrl) */
  2594. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2595. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2596. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2597. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2598. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2599. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2600. /* Also unmute the mono-out pin widget */
  2601. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2602. /* Also unmute the retasking pin input amps. Having the input and
  2603. * output amps unmuted at the same time doesn't appear to cause any
  2604. * trouble.
  2605. */
  2606. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2607. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2608. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2609. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2610. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2611. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2612. /* Mute capture amp left and right */
  2613. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2614. /* Set ADC connection select to match default mixer setting - line
  2615. * in (on mic1 pin)
  2616. */
  2617. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  2618. /* Do the same for the second ADC: mute capture input amp and
  2619. * set ADC connection to line in
  2620. */
  2621. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2622. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  2623. /* Mute all inputs to mixer widget (even unconnected ones) */
  2624. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  2625. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  2626. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  2627. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  2628. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  2629. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  2630. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  2631. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  2632. { }
  2633. };
  2634. #endif
  2635. static struct hda_pcm_stream alc260_pcm_analog_playback = {
  2636. .substreams = 1,
  2637. .channels_min = 2,
  2638. .channels_max = 2,
  2639. };
  2640. static struct hda_pcm_stream alc260_pcm_analog_capture = {
  2641. .substreams = 1,
  2642. .channels_min = 2,
  2643. .channels_max = 2,
  2644. };
  2645. #define alc260_pcm_digital_playback alc880_pcm_digital_playback
  2646. #define alc260_pcm_digital_capture alc880_pcm_digital_capture
  2647. /*
  2648. * for BIOS auto-configuration
  2649. */
  2650. static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
  2651. const char *pfx)
  2652. {
  2653. hda_nid_t nid_vol;
  2654. unsigned long vol_val, sw_val;
  2655. char name[32];
  2656. int err;
  2657. if (nid >= 0x0f && nid < 0x11) {
  2658. nid_vol = nid - 0x7;
  2659. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
  2660. sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
  2661. } else if (nid == 0x11) {
  2662. nid_vol = nid - 0x7;
  2663. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
  2664. sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
  2665. } else if (nid >= 0x12 && nid <= 0x15) {
  2666. nid_vol = 0x08;
  2667. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
  2668. sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
  2669. } else
  2670. return 0; /* N/A */
  2671. snprintf(name, sizeof(name), "%s Playback Volume", pfx);
  2672. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val)) < 0)
  2673. return err;
  2674. snprintf(name, sizeof(name), "%s Playback Switch", pfx);
  2675. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val)) < 0)
  2676. return err;
  2677. return 1;
  2678. }
  2679. /* add playback controls from the parsed DAC table */
  2680. static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
  2681. const struct auto_pin_cfg *cfg)
  2682. {
  2683. hda_nid_t nid;
  2684. int err;
  2685. spec->multiout.num_dacs = 1;
  2686. spec->multiout.dac_nids = spec->private_dac_nids;
  2687. spec->multiout.dac_nids[0] = 0x02;
  2688. nid = cfg->line_out_pins[0];
  2689. if (nid) {
  2690. err = alc260_add_playback_controls(spec, nid, "Front");
  2691. if (err < 0)
  2692. return err;
  2693. }
  2694. nid = cfg->speaker_pin;
  2695. if (nid) {
  2696. err = alc260_add_playback_controls(spec, nid, "Speaker");
  2697. if (err < 0)
  2698. return err;
  2699. }
  2700. nid = cfg->hp_pin;
  2701. if (nid) {
  2702. err = alc260_add_playback_controls(spec, nid, "Headphone");
  2703. if (err < 0)
  2704. return err;
  2705. }
  2706. return 0;
  2707. }
  2708. /* create playback/capture controls for input pins */
  2709. static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
  2710. const struct auto_pin_cfg *cfg)
  2711. {
  2712. struct hda_input_mux *imux = &spec->private_imux;
  2713. int i, err, idx;
  2714. for (i = 0; i < AUTO_PIN_LAST; i++) {
  2715. if (cfg->input_pins[i] >= 0x12) {
  2716. idx = cfg->input_pins[i] - 0x12;
  2717. err = new_analog_input(spec, cfg->input_pins[i],
  2718. auto_pin_cfg_labels[i], idx, 0x07);
  2719. if (err < 0)
  2720. return err;
  2721. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  2722. imux->items[imux->num_items].index = idx;
  2723. imux->num_items++;
  2724. }
  2725. if ((cfg->input_pins[i] >= 0x0f) && (cfg->input_pins[i] <= 0x10)){
  2726. idx = cfg->input_pins[i] - 0x09;
  2727. err = new_analog_input(spec, cfg->input_pins[i],
  2728. auto_pin_cfg_labels[i], idx, 0x07);
  2729. if (err < 0)
  2730. return err;
  2731. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  2732. imux->items[imux->num_items].index = idx;
  2733. imux->num_items++;
  2734. }
  2735. }
  2736. return 0;
  2737. }
  2738. static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
  2739. hda_nid_t nid, int pin_type,
  2740. int sel_idx)
  2741. {
  2742. /* set as output */
  2743. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  2744. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  2745. /* need the manual connection? */
  2746. if (nid >= 0x12) {
  2747. int idx = nid - 0x12;
  2748. snd_hda_codec_write(codec, idx + 0x0b, 0,
  2749. AC_VERB_SET_CONNECT_SEL, sel_idx);
  2750. }
  2751. }
  2752. static void alc260_auto_init_multi_out(struct hda_codec *codec)
  2753. {
  2754. struct alc_spec *spec = codec->spec;
  2755. hda_nid_t nid;
  2756. nid = spec->autocfg.line_out_pins[0];
  2757. if (nid)
  2758. alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
  2759. nid = spec->autocfg.speaker_pin;
  2760. if (nid)
  2761. alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
  2762. nid = spec->autocfg.hp_pin;
  2763. if (nid)
  2764. alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
  2765. }
  2766. #define ALC260_PIN_CD_NID 0x16
  2767. static void alc260_auto_init_analog_input(struct hda_codec *codec)
  2768. {
  2769. struct alc_spec *spec = codec->spec;
  2770. int i;
  2771. for (i = 0; i < AUTO_PIN_LAST; i++) {
  2772. hda_nid_t nid = spec->autocfg.input_pins[i];
  2773. if (nid >= 0x12) {
  2774. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  2775. i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
  2776. if (nid != ALC260_PIN_CD_NID)
  2777. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  2778. AMP_OUT_MUTE);
  2779. }
  2780. }
  2781. }
  2782. /*
  2783. * generic initialization of ADC, input mixers and output mixers
  2784. */
  2785. static struct hda_verb alc260_volume_init_verbs[] = {
  2786. /*
  2787. * Unmute ADC0-1 and set the default input to mic-in
  2788. */
  2789. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  2790. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2791. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  2792. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2793. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  2794. * mixer widget
  2795. * Note: PASD motherboards uses the Line In 2 as the input for front panel
  2796. * mic (mic 2)
  2797. */
  2798. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  2799. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2800. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2801. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  2802. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  2803. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  2804. /*
  2805. * Set up output mixers (0x08 - 0x0a)
  2806. */
  2807. /* set vol=0 to output mixers */
  2808. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2809. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2810. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2811. /* set up input amps for analog loopback */
  2812. /* Amp Indices: DAC = 0, mixer = 1 */
  2813. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2814. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2815. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2816. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2817. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2818. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2819. { }
  2820. };
  2821. static int alc260_parse_auto_config(struct hda_codec *codec)
  2822. {
  2823. struct alc_spec *spec = codec->spec;
  2824. unsigned int wcap;
  2825. int err;
  2826. static hda_nid_t alc260_ignore[] = { 0x17, 0 };
  2827. if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  2828. alc260_ignore)) < 0)
  2829. return err;
  2830. if ((err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0)
  2831. return err;
  2832. if (! spec->kctl_alloc)
  2833. return 0; /* can't find valid BIOS pin config */
  2834. if ((err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
  2835. return err;
  2836. spec->multiout.max_channels = 2;
  2837. if (spec->autocfg.dig_out_pin)
  2838. spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
  2839. if (spec->kctl_alloc)
  2840. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  2841. spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
  2842. spec->input_mux = &spec->private_imux;
  2843. /* check whether NID 0x04 is valid */
  2844. wcap = get_wcaps(codec, 0x04);
  2845. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
  2846. if (wcap != AC_WID_AUD_IN) {
  2847. spec->adc_nids = alc260_adc_nids_alt;
  2848. spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
  2849. spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
  2850. } else {
  2851. spec->adc_nids = alc260_adc_nids;
  2852. spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
  2853. spec->mixers[spec->num_mixers] = alc260_capture_mixer;
  2854. }
  2855. spec->num_mixers++;
  2856. return 1;
  2857. }
  2858. /* init callback for auto-configuration model -- overriding the default init */
  2859. static int alc260_auto_init(struct hda_codec *codec)
  2860. {
  2861. alc_init(codec);
  2862. alc260_auto_init_multi_out(codec);
  2863. alc260_auto_init_analog_input(codec);
  2864. return 0;
  2865. }
  2866. /*
  2867. * ALC260 configurations
  2868. */
  2869. static struct hda_board_config alc260_cfg_tbl[] = {
  2870. { .modelname = "basic", .config = ALC260_BASIC },
  2871. { .pci_subvendor = 0x104d, .pci_subdevice = 0x81bb,
  2872. .config = ALC260_BASIC }, /* Sony VAIO */
  2873. { .modelname = "hp", .config = ALC260_HP },
  2874. { .pci_subvendor = 0x103c, .pci_subdevice = 0x3010, .config = ALC260_HP },
  2875. { .pci_subvendor = 0x103c, .pci_subdevice = 0x3011, .config = ALC260_HP },
  2876. { .pci_subvendor = 0x103c, .pci_subdevice = 0x3012, .config = ALC260_HP },
  2877. { .pci_subvendor = 0x103c, .pci_subdevice = 0x3013, .config = ALC260_HP_3013 },
  2878. { .pci_subvendor = 0x103c, .pci_subdevice = 0x3014, .config = ALC260_HP },
  2879. { .pci_subvendor = 0x103c, .pci_subdevice = 0x3015, .config = ALC260_HP },
  2880. { .pci_subvendor = 0x103c, .pci_subdevice = 0x3016, .config = ALC260_HP },
  2881. { .modelname = "fujitsu", .config = ALC260_FUJITSU_S702X },
  2882. { .pci_subvendor = 0x10cf, .pci_subdevice = 0x1326, .config = ALC260_FUJITSU_S702X },
  2883. #ifdef CONFIG_SND_DEBUG
  2884. { .modelname = "test", .config = ALC260_TEST },
  2885. #endif
  2886. { .modelname = "auto", .config = ALC260_AUTO },
  2887. {}
  2888. };
  2889. static struct alc_config_preset alc260_presets[] = {
  2890. [ALC260_BASIC] = {
  2891. .mixers = { alc260_base_output_mixer,
  2892. alc260_input_mixer,
  2893. alc260_pc_beep_mixer,
  2894. alc260_capture_mixer },
  2895. .init_verbs = { alc260_init_verbs },
  2896. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  2897. .dac_nids = alc260_dac_nids,
  2898. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  2899. .adc_nids = alc260_adc_nids,
  2900. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  2901. .channel_mode = alc260_modes,
  2902. .input_mux = &alc260_capture_source,
  2903. },
  2904. [ALC260_HP] = {
  2905. .mixers = { alc260_base_output_mixer,
  2906. alc260_input_mixer,
  2907. alc260_capture_alt_mixer },
  2908. .init_verbs = { alc260_hp_init_verbs },
  2909. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  2910. .dac_nids = alc260_dac_nids,
  2911. .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
  2912. .adc_nids = alc260_hp_adc_nids,
  2913. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  2914. .channel_mode = alc260_modes,
  2915. .input_mux = &alc260_capture_source,
  2916. },
  2917. [ALC260_HP_3013] = {
  2918. .mixers = { alc260_hp_3013_mixer,
  2919. alc260_input_mixer,
  2920. alc260_capture_alt_mixer },
  2921. .init_verbs = { alc260_hp_3013_init_verbs },
  2922. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  2923. .dac_nids = alc260_dac_nids,
  2924. .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
  2925. .adc_nids = alc260_hp_adc_nids,
  2926. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  2927. .channel_mode = alc260_modes,
  2928. .input_mux = &alc260_capture_source,
  2929. },
  2930. [ALC260_FUJITSU_S702X] = {
  2931. .mixers = { alc260_fujitsu_mixer,
  2932. alc260_capture_mixer },
  2933. .init_verbs = { alc260_fujitsu_init_verbs },
  2934. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  2935. .dac_nids = alc260_dac_nids,
  2936. .num_adc_nids = ARRAY_SIZE(alc260_fujitsu_adc_nids),
  2937. .adc_nids = alc260_fujitsu_adc_nids,
  2938. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  2939. .channel_mode = alc260_modes,
  2940. .input_mux = &alc260_fujitsu_capture_source,
  2941. },
  2942. #ifdef CONFIG_SND_DEBUG
  2943. [ALC260_TEST] = {
  2944. .mixers = { alc260_test_mixer,
  2945. alc260_capture_mixer },
  2946. .init_verbs = { alc260_test_init_verbs },
  2947. .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
  2948. .dac_nids = alc260_test_dac_nids,
  2949. .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
  2950. .adc_nids = alc260_test_adc_nids,
  2951. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  2952. .channel_mode = alc260_modes,
  2953. .input_mux = &alc260_test_capture_source,
  2954. },
  2955. #endif
  2956. };
  2957. static int patch_alc260(struct hda_codec *codec)
  2958. {
  2959. struct alc_spec *spec;
  2960. int err, board_config;
  2961. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  2962. if (spec == NULL)
  2963. return -ENOMEM;
  2964. codec->spec = spec;
  2965. board_config = snd_hda_check_board_config(codec, alc260_cfg_tbl);
  2966. if (board_config < 0 || board_config >= ALC260_MODEL_LAST) {
  2967. snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260\n");
  2968. board_config = ALC260_AUTO;
  2969. }
  2970. if (board_config == ALC260_AUTO) {
  2971. /* automatic parse from the BIOS config */
  2972. err = alc260_parse_auto_config(codec);
  2973. if (err < 0) {
  2974. alc_free(codec);
  2975. return err;
  2976. } else if (! err) {
  2977. printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using base mode...\n");
  2978. board_config = ALC260_BASIC;
  2979. }
  2980. }
  2981. if (board_config != ALC260_AUTO)
  2982. setup_preset(spec, &alc260_presets[board_config]);
  2983. spec->stream_name_analog = "ALC260 Analog";
  2984. spec->stream_analog_playback = &alc260_pcm_analog_playback;
  2985. spec->stream_analog_capture = &alc260_pcm_analog_capture;
  2986. spec->stream_name_digital = "ALC260 Digital";
  2987. spec->stream_digital_playback = &alc260_pcm_digital_playback;
  2988. spec->stream_digital_capture = &alc260_pcm_digital_capture;
  2989. codec->patch_ops = alc_patch_ops;
  2990. if (board_config == ALC260_AUTO)
  2991. codec->patch_ops.init = alc260_auto_init;
  2992. return 0;
  2993. }
  2994. /*
  2995. * ALC882 support
  2996. *
  2997. * ALC882 is almost identical with ALC880 but has cleaner and more flexible
  2998. * configuration. Each pin widget can choose any input DACs and a mixer.
  2999. * Each ADC is connected from a mixer of all inputs. This makes possible
  3000. * 6-channel independent captures.
  3001. *
  3002. * In addition, an independent DAC for the multi-playback (not used in this
  3003. * driver yet).
  3004. */
  3005. #define ALC882_DIGOUT_NID 0x06
  3006. #define ALC882_DIGIN_NID 0x0a
  3007. static struct hda_channel_mode alc882_ch_modes[1] = {
  3008. { 8, NULL }
  3009. };
  3010. static hda_nid_t alc882_dac_nids[4] = {
  3011. /* front, rear, clfe, rear_surr */
  3012. 0x02, 0x03, 0x04, 0x05
  3013. };
  3014. /* identical with ALC880 */
  3015. #define alc882_adc_nids alc880_adc_nids
  3016. #define alc882_adc_nids_alt alc880_adc_nids_alt
  3017. /* input MUX */
  3018. /* FIXME: should be a matrix-type input source selection */
  3019. static struct hda_input_mux alc882_capture_source = {
  3020. .num_items = 4,
  3021. .items = {
  3022. { "Mic", 0x0 },
  3023. { "Front Mic", 0x1 },
  3024. { "Line", 0x2 },
  3025. { "CD", 0x4 },
  3026. },
  3027. };
  3028. #define alc882_mux_enum_info alc_mux_enum_info
  3029. #define alc882_mux_enum_get alc_mux_enum_get
  3030. static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  3031. {
  3032. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  3033. struct alc_spec *spec = codec->spec;
  3034. const struct hda_input_mux *imux = spec->input_mux;
  3035. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  3036. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  3037. hda_nid_t nid = capture_mixers[adc_idx];
  3038. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  3039. unsigned int i, idx;
  3040. idx = ucontrol->value.enumerated.item[0];
  3041. if (idx >= imux->num_items)
  3042. idx = imux->num_items - 1;
  3043. if (*cur_val == idx && ! codec->in_resume)
  3044. return 0;
  3045. for (i = 0; i < imux->num_items; i++) {
  3046. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  3047. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  3048. v | (imux->items[i].index << 8));
  3049. }
  3050. *cur_val = idx;
  3051. return 1;
  3052. }
  3053. /*
  3054. * 6ch mode
  3055. */
  3056. static struct hda_verb alc882_sixstack_ch6_init[] = {
  3057. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  3058. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  3059. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  3060. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  3061. { } /* end */
  3062. };
  3063. /*
  3064. * 8ch mode
  3065. */
  3066. static struct hda_verb alc882_sixstack_ch8_init[] = {
  3067. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  3068. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  3069. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  3070. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  3071. { } /* end */
  3072. };
  3073. static struct hda_channel_mode alc882_sixstack_modes[2] = {
  3074. { 6, alc882_sixstack_ch6_init },
  3075. { 8, alc882_sixstack_ch8_init },
  3076. };
  3077. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  3078. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  3079. */
  3080. static struct snd_kcontrol_new alc882_base_mixer[] = {
  3081. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  3082. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  3083. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  3084. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  3085. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  3086. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  3087. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  3088. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  3089. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  3090. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  3091. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  3092. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  3093. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  3094. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  3095. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  3096. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  3097. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  3098. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  3099. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  3100. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  3101. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  3102. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  3103. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  3104. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  3105. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  3106. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  3107. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  3108. {
  3109. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3110. /* .name = "Capture Source", */
  3111. .name = "Input Source",
  3112. .count = 3,
  3113. .info = alc882_mux_enum_info,
  3114. .get = alc882_mux_enum_get,
  3115. .put = alc882_mux_enum_put,
  3116. },
  3117. { } /* end */
  3118. };
  3119. static struct snd_kcontrol_new alc882_chmode_mixer[] = {
  3120. {
  3121. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3122. .name = "Channel Mode",
  3123. .info = alc_ch_mode_info,
  3124. .get = alc_ch_mode_get,
  3125. .put = alc_ch_mode_put,
  3126. },
  3127. { } /* end */
  3128. };
  3129. static struct hda_verb alc882_init_verbs[] = {
  3130. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  3131. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3132. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3133. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3134. /* Rear mixer */
  3135. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3136. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3137. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3138. /* CLFE mixer */
  3139. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3140. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3141. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3142. /* Side mixer */
  3143. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3144. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3145. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3146. /* Front Pin: output 0 (0x0c) */
  3147. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3148. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3149. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  3150. /* Rear Pin: output 1 (0x0d) */
  3151. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3152. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3153. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  3154. /* CLFE Pin: output 2 (0x0e) */
  3155. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3156. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3157. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  3158. /* Side Pin: output 3 (0x0f) */
  3159. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3160. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3161. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  3162. /* Mic (rear) pin: input vref at 80% */
  3163. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  3164. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  3165. /* Front Mic pin: input vref at 80% */
  3166. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  3167. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  3168. /* Line In pin: input */
  3169. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3170. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  3171. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  3172. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3173. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3174. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  3175. /* CD pin widget for input */
  3176. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3177. /* FIXME: use matrix-type input source selection */
  3178. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  3179. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  3180. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3181. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  3182. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  3183. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  3184. /* Input mixer2 */
  3185. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3186. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  3187. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  3188. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  3189. /* Input mixer3 */
  3190. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3191. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  3192. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  3193. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  3194. /* ADC1: mute amp left and right */
  3195. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3196. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  3197. /* ADC2: mute amp left and right */
  3198. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3199. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  3200. /* ADC3: mute amp left and right */
  3201. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3202. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  3203. { }
  3204. };
  3205. /*
  3206. * generic initialization of ADC, input mixers and output mixers
  3207. */
  3208. static struct hda_verb alc882_auto_init_verbs[] = {
  3209. /*
  3210. * Unmute ADC0-2 and set the default input to mic-in
  3211. */
  3212. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  3213. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3214. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  3215. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3216. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  3217. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3218. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  3219. * mixer widget
  3220. * Note: PASD motherboards uses the Line In 2 as the input for front panel
  3221. * mic (mic 2)
  3222. */
  3223. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  3224. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3225. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3226. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  3227. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  3228. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  3229. /*
  3230. * Set up output mixers (0x0c - 0x0f)
  3231. */
  3232. /* set vol=0 to output mixers */
  3233. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3234. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3235. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3236. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3237. /* set up input amps for analog loopback */
  3238. /* Amp Indices: DAC = 0, mixer = 1 */
  3239. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3240. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3241. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3242. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3243. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3244. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3245. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3246. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3247. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3248. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3249. /* FIXME: use matrix-type input source selection */
  3250. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  3251. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  3252. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3253. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  3254. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  3255. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  3256. /* Input mixer2 */
  3257. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3258. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  3259. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  3260. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  3261. /* Input mixer3 */
  3262. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3263. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  3264. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  3265. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  3266. { }
  3267. };
  3268. /* capture mixer elements */
  3269. static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
  3270. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  3271. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  3272. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  3273. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  3274. {
  3275. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3276. /* The multiple "Capture Source" controls confuse alsamixer
  3277. * So call somewhat different..
  3278. * FIXME: the controls appear in the "playback" view!
  3279. */
  3280. /* .name = "Capture Source", */
  3281. .name = "Input Source",
  3282. .count = 2,
  3283. .info = alc882_mux_enum_info,
  3284. .get = alc882_mux_enum_get,
  3285. .put = alc882_mux_enum_put,
  3286. },
  3287. { } /* end */
  3288. };
  3289. static struct snd_kcontrol_new alc882_capture_mixer[] = {
  3290. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  3291. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  3292. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  3293. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  3294. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  3295. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  3296. {
  3297. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3298. /* The multiple "Capture Source" controls confuse alsamixer
  3299. * So call somewhat different..
  3300. * FIXME: the controls appear in the "playback" view!
  3301. */
  3302. /* .name = "Capture Source", */
  3303. .name = "Input Source",
  3304. .count = 3,
  3305. .info = alc882_mux_enum_info,
  3306. .get = alc882_mux_enum_get,
  3307. .put = alc882_mux_enum_put,
  3308. },
  3309. { } /* end */
  3310. };
  3311. /* pcm configuration: identiacal with ALC880 */
  3312. #define alc882_pcm_analog_playback alc880_pcm_analog_playback
  3313. #define alc882_pcm_analog_capture alc880_pcm_analog_capture
  3314. #define alc882_pcm_digital_playback alc880_pcm_digital_playback
  3315. #define alc882_pcm_digital_capture alc880_pcm_digital_capture
  3316. /*
  3317. * configuration and preset
  3318. */
  3319. static struct hda_board_config alc882_cfg_tbl[] = {
  3320. { .modelname = "3stack-dig", .config = ALC882_3ST_DIG },
  3321. { .modelname = "6stack-dig", .config = ALC882_6ST_DIG },
  3322. { .pci_subvendor = 0x1462, .pci_subdevice = 0x6668, .config = ALC882_6ST_DIG }, /* MSI */
  3323. { .pci_subvendor = 0x105b, .pci_subdevice = 0x6668, .config = ALC882_6ST_DIG }, /* Foxconn */
  3324. { .pci_subvendor = 0x1019, .pci_subdevice = 0x6668, .config = ALC882_6ST_DIG }, /* ECS */
  3325. { .modelname = "auto", .config = ALC882_AUTO },
  3326. {}
  3327. };
  3328. static struct alc_config_preset alc882_presets[] = {
  3329. [ALC882_3ST_DIG] = {
  3330. .mixers = { alc882_base_mixer },
  3331. .init_verbs = { alc882_init_verbs },
  3332. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  3333. .dac_nids = alc882_dac_nids,
  3334. .dig_out_nid = ALC882_DIGOUT_NID,
  3335. .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
  3336. .adc_nids = alc882_adc_nids,
  3337. .dig_in_nid = ALC882_DIGIN_NID,
  3338. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  3339. .channel_mode = alc882_ch_modes,
  3340. .input_mux = &alc882_capture_source,
  3341. },
  3342. [ALC882_6ST_DIG] = {
  3343. .mixers = { alc882_base_mixer, alc882_chmode_mixer },
  3344. .init_verbs = { alc882_init_verbs },
  3345. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  3346. .dac_nids = alc882_dac_nids,
  3347. .dig_out_nid = ALC882_DIGOUT_NID,
  3348. .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
  3349. .adc_nids = alc882_adc_nids,
  3350. .dig_in_nid = ALC882_DIGIN_NID,
  3351. .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
  3352. .channel_mode = alc882_sixstack_modes,
  3353. .input_mux = &alc882_capture_source,
  3354. },
  3355. };
  3356. /*
  3357. * BIOS auto configuration
  3358. */
  3359. static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
  3360. hda_nid_t nid, int pin_type,
  3361. int dac_idx)
  3362. {
  3363. /* set as output */
  3364. struct alc_spec *spec = codec->spec;
  3365. int idx;
  3366. if (spec->multiout.dac_nids[dac_idx] == 0x25)
  3367. idx = 4;
  3368. else
  3369. idx = spec->multiout.dac_nids[dac_idx] - 2;
  3370. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  3371. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  3372. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
  3373. }
  3374. static void alc882_auto_init_multi_out(struct hda_codec *codec)
  3375. {
  3376. struct alc_spec *spec = codec->spec;
  3377. int i;
  3378. for (i = 0; i <= HDA_SIDE; i++) {
  3379. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  3380. if (nid)
  3381. alc882_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
  3382. }
  3383. }
  3384. static void alc882_auto_init_hp_out(struct hda_codec *codec)
  3385. {
  3386. struct alc_spec *spec = codec->spec;
  3387. hda_nid_t pin;
  3388. pin = spec->autocfg.hp_pin;
  3389. if (pin) /* connect to front */
  3390. alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); /* use dac 0 */
  3391. }
  3392. #define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
  3393. #define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
  3394. static void alc882_auto_init_analog_input(struct hda_codec *codec)
  3395. {
  3396. struct alc_spec *spec = codec->spec;
  3397. int i;
  3398. for (i = 0; i < AUTO_PIN_LAST; i++) {
  3399. hda_nid_t nid = spec->autocfg.input_pins[i];
  3400. if (alc882_is_input_pin(nid)) {
  3401. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  3402. i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
  3403. if (nid != ALC882_PIN_CD_NID)
  3404. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  3405. AMP_OUT_MUTE);
  3406. }
  3407. }
  3408. }
  3409. /* almost identical with ALC880 parser... */
  3410. static int alc882_parse_auto_config(struct hda_codec *codec)
  3411. {
  3412. struct alc_spec *spec = codec->spec;
  3413. int err = alc880_parse_auto_config(codec);
  3414. if (err < 0)
  3415. return err;
  3416. else if (err > 0)
  3417. /* hack - override the init verbs */
  3418. spec->init_verbs[0] = alc882_auto_init_verbs;
  3419. return err;
  3420. }
  3421. /* init callback for auto-configuration model -- overriding the default init */
  3422. static int alc882_auto_init(struct hda_codec *codec)
  3423. {
  3424. alc_init(codec);
  3425. alc882_auto_init_multi_out(codec);
  3426. alc882_auto_init_hp_out(codec);
  3427. alc882_auto_init_analog_input(codec);
  3428. return 0;
  3429. }
  3430. /*
  3431. * ALC882 Headphone poll in 3.5.1a or 3.5.2
  3432. */
  3433. static int patch_alc882(struct hda_codec *codec)
  3434. {
  3435. struct alc_spec *spec;
  3436. int err, board_config;
  3437. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  3438. if (spec == NULL)
  3439. return -ENOMEM;
  3440. codec->spec = spec;
  3441. board_config = snd_hda_check_board_config(codec, alc882_cfg_tbl);
  3442. if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
  3443. printk(KERN_INFO "hda_codec: Unknown model for ALC882, trying auto-probe from BIOS...\n");
  3444. board_config = ALC882_AUTO;
  3445. }
  3446. if (board_config == ALC882_AUTO) {
  3447. /* automatic parse from the BIOS config */
  3448. err = alc882_parse_auto_config(codec);
  3449. if (err < 0) {
  3450. alc_free(codec);
  3451. return err;
  3452. } else if (! err) {
  3453. printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using base mode...\n");
  3454. board_config = ALC882_3ST_DIG;
  3455. }
  3456. }
  3457. if (board_config != ALC882_AUTO)
  3458. setup_preset(spec, &alc882_presets[board_config]);
  3459. spec->stream_name_analog = "ALC882 Analog";
  3460. spec->stream_analog_playback = &alc882_pcm_analog_playback;
  3461. spec->stream_analog_capture = &alc882_pcm_analog_capture;
  3462. spec->stream_name_digital = "ALC882 Digital";
  3463. spec->stream_digital_playback = &alc882_pcm_digital_playback;
  3464. spec->stream_digital_capture = &alc882_pcm_digital_capture;
  3465. if (! spec->adc_nids && spec->input_mux) {
  3466. /* check whether NID 0x07 is valid */
  3467. unsigned int wcap = get_wcaps(codec, 0x07);
  3468. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
  3469. if (wcap != AC_WID_AUD_IN) {
  3470. spec->adc_nids = alc882_adc_nids_alt;
  3471. spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
  3472. spec->mixers[spec->num_mixers] = alc882_capture_alt_mixer;
  3473. spec->num_mixers++;
  3474. } else {
  3475. spec->adc_nids = alc882_adc_nids;
  3476. spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
  3477. spec->mixers[spec->num_mixers] = alc882_capture_mixer;
  3478. spec->num_mixers++;
  3479. }
  3480. }
  3481. codec->patch_ops = alc_patch_ops;
  3482. if (board_config == ALC882_AUTO)
  3483. codec->patch_ops.init = alc882_auto_init;
  3484. return 0;
  3485. }
  3486. /*
  3487. * ALC262 support
  3488. */
  3489. #define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
  3490. #define ALC262_DIGIN_NID ALC880_DIGIN_NID
  3491. #define alc262_dac_nids alc260_dac_nids
  3492. #define alc262_adc_nids alc882_adc_nids
  3493. #define alc262_adc_nids_alt alc882_adc_nids_alt
  3494. #define alc262_modes alc260_modes
  3495. #define alc262_capture_source alc882_capture_source
  3496. static struct snd_kcontrol_new alc262_base_mixer[] = {
  3497. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  3498. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  3499. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  3500. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  3501. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  3502. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  3503. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  3504. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  3505. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  3506. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  3507. /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  3508. HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
  3509. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
  3510. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  3511. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  3512. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  3513. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  3514. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  3515. {
  3516. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3517. .name = "Capture Source",
  3518. .count = 1,
  3519. .info = alc882_mux_enum_info,
  3520. .get = alc882_mux_enum_get,
  3521. .put = alc882_mux_enum_put,
  3522. },
  3523. { } /* end */
  3524. };
  3525. #define alc262_capture_mixer alc882_capture_mixer
  3526. #define alc262_capture_alt_mixer alc882_capture_alt_mixer
  3527. /*
  3528. * generic initialization of ADC, input mixers and output mixers
  3529. */
  3530. static struct hda_verb alc262_init_verbs[] = {
  3531. /*
  3532. * Unmute ADC0-2 and set the default input to mic-in
  3533. */
  3534. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  3535. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3536. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  3537. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3538. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  3539. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3540. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  3541. * mixer widget
  3542. * Note: PASD motherboards uses the Line In 2 as the input for front panel
  3543. * mic (mic 2)
  3544. */
  3545. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  3546. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3547. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3548. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  3549. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  3550. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  3551. /*
  3552. * Set up output mixers (0x0c - 0x0e)
  3553. */
  3554. /* set vol=0 to output mixers */
  3555. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3556. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3557. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3558. /* set up input amps for analog loopback */
  3559. /* Amp Indices: DAC = 0, mixer = 1 */
  3560. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3561. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3562. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3563. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3564. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3565. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3566. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3567. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  3568. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3569. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3570. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3571. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3572. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3573. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3574. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3575. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3576. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3577. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  3578. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  3579. /* FIXME: use matrix-type input source selection */
  3580. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  3581. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  3582. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3583. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  3584. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  3585. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  3586. /* Input mixer2 */
  3587. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3588. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  3589. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  3590. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  3591. /* Input mixer3 */
  3592. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3593. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  3594. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  3595. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  3596. { }
  3597. };
  3598. /* add playback controls from the parsed DAC table */
  3599. static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
  3600. {
  3601. hda_nid_t nid;
  3602. int err;
  3603. spec->multiout.num_dacs = 1; /* only use one dac */
  3604. spec->multiout.dac_nids = spec->private_dac_nids;
  3605. spec->multiout.dac_nids[0] = 2;
  3606. nid = cfg->line_out_pins[0];
  3607. if (nid) {
  3608. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Front Playback Volume",
  3609. HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT))) < 0)
  3610. return err;
  3611. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Front Playback Switch",
  3612. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  3613. return err;
  3614. }
  3615. nid = cfg->speaker_pin;
  3616. if (nid) {
  3617. if (nid == 0x16) {
  3618. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Speaker Playback Volume",
  3619. HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0)
  3620. return err;
  3621. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch",
  3622. HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
  3623. return err;
  3624. } else {
  3625. if (! cfg->line_out_pins[0])
  3626. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Speaker Playback Volume",
  3627. HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT))) < 0)
  3628. return err;
  3629. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch",
  3630. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  3631. return err;
  3632. }
  3633. }
  3634. nid = cfg->hp_pin;
  3635. if (nid) {
  3636. /* spec->multiout.hp_nid = 2; */
  3637. if (nid == 0x16) {
  3638. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Headphone Playback Volume",
  3639. HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0)
  3640. return err;
  3641. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
  3642. HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
  3643. return err;
  3644. } else {
  3645. if (! cfg->line_out_pins[0])
  3646. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Headphone Playback Volume",
  3647. HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT))) < 0)
  3648. return err;
  3649. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
  3650. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  3651. return err;
  3652. }
  3653. }
  3654. return 0;
  3655. }
  3656. /* identical with ALC880 */
  3657. #define alc262_auto_create_analog_input_ctls alc880_auto_create_analog_input_ctls
  3658. /*
  3659. * generic initialization of ADC, input mixers and output mixers
  3660. */
  3661. static struct hda_verb alc262_volume_init_verbs[] = {
  3662. /*
  3663. * Unmute ADC0-2 and set the default input to mic-in
  3664. */
  3665. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  3666. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3667. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  3668. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3669. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  3670. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3671. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  3672. * mixer widget
  3673. * Note: PASD motherboards uses the Line In 2 as the input for front panel
  3674. * mic (mic 2)
  3675. */
  3676. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  3677. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3678. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3679. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  3680. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  3681. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  3682. /*
  3683. * Set up output mixers (0x0c - 0x0f)
  3684. */
  3685. /* set vol=0 to output mixers */
  3686. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3687. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3688. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3689. /* set up input amps for analog loopback */
  3690. /* Amp Indices: DAC = 0, mixer = 1 */
  3691. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3692. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3693. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3694. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3695. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3696. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3697. /* FIXME: use matrix-type input source selection */
  3698. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  3699. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  3700. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3701. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  3702. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  3703. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  3704. /* Input mixer2 */
  3705. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3706. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  3707. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  3708. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  3709. /* Input mixer3 */
  3710. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3711. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  3712. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  3713. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  3714. { }
  3715. };
  3716. /* pcm configuration: identiacal with ALC880 */
  3717. #define alc262_pcm_analog_playback alc880_pcm_analog_playback
  3718. #define alc262_pcm_analog_capture alc880_pcm_analog_capture
  3719. #define alc262_pcm_digital_playback alc880_pcm_digital_playback
  3720. #define alc262_pcm_digital_capture alc880_pcm_digital_capture
  3721. /*
  3722. * BIOS auto configuration
  3723. */
  3724. static int alc262_parse_auto_config(struct hda_codec *codec)
  3725. {
  3726. struct alc_spec *spec = codec->spec;
  3727. int err;
  3728. static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
  3729. if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  3730. alc262_ignore)) < 0)
  3731. return err;
  3732. if (! spec->autocfg.line_outs && ! spec->autocfg.speaker_pin &&
  3733. ! spec->autocfg.hp_pin)
  3734. return 0; /* can't find valid BIOS pin config */
  3735. if ((err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
  3736. (err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
  3737. return err;
  3738. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  3739. if (spec->autocfg.dig_out_pin)
  3740. spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
  3741. if (spec->autocfg.dig_in_pin)
  3742. spec->dig_in_nid = ALC262_DIGIN_NID;
  3743. if (spec->kctl_alloc)
  3744. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  3745. spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
  3746. spec->input_mux = &spec->private_imux;
  3747. return 1;
  3748. }
  3749. #define alc262_auto_init_multi_out alc882_auto_init_multi_out
  3750. #define alc262_auto_init_hp_out alc882_auto_init_hp_out
  3751. #define alc262_auto_init_analog_input alc882_auto_init_analog_input
  3752. /* init callback for auto-configuration model -- overriding the default init */
  3753. static int alc262_auto_init(struct hda_codec *codec)
  3754. {
  3755. alc_init(codec);
  3756. alc262_auto_init_multi_out(codec);
  3757. alc262_auto_init_hp_out(codec);
  3758. alc262_auto_init_analog_input(codec);
  3759. return 0;
  3760. }
  3761. /*
  3762. * configuration and preset
  3763. */
  3764. static struct hda_board_config alc262_cfg_tbl[] = {
  3765. { .modelname = "basic", .config = ALC262_BASIC },
  3766. { .modelname = "auto", .config = ALC262_AUTO },
  3767. {}
  3768. };
  3769. static struct alc_config_preset alc262_presets[] = {
  3770. [ALC262_BASIC] = {
  3771. .mixers = { alc262_base_mixer },
  3772. .init_verbs = { alc262_init_verbs },
  3773. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  3774. .dac_nids = alc262_dac_nids,
  3775. .hp_nid = 0x03,
  3776. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  3777. .channel_mode = alc262_modes,
  3778. .input_mux = &alc262_capture_source,
  3779. },
  3780. };
  3781. static int patch_alc262(struct hda_codec *codec)
  3782. {
  3783. struct alc_spec *spec;
  3784. int board_config;
  3785. int err;
  3786. spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
  3787. if (spec == NULL)
  3788. return -ENOMEM;
  3789. codec->spec = spec;
  3790. #if 0
  3791. /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is under-run */
  3792. {
  3793. int tmp;
  3794. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  3795. tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
  3796. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  3797. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
  3798. }
  3799. #endif
  3800. board_config = snd_hda_check_board_config(codec, alc262_cfg_tbl);
  3801. if (board_config < 0 || board_config >= ALC262_MODEL_LAST) {
  3802. printk(KERN_INFO "hda_codec: Unknown model for ALC262, trying auto-probe from BIOS...\n");
  3803. board_config = ALC262_AUTO;
  3804. }
  3805. if (board_config == ALC262_AUTO) {
  3806. /* automatic parse from the BIOS config */
  3807. err = alc262_parse_auto_config(codec);
  3808. if (err < 0) {
  3809. alc_free(codec);
  3810. return err;
  3811. } else if (! err) {
  3812. printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using base mode...\n");
  3813. board_config = ALC262_BASIC;
  3814. }
  3815. }
  3816. if (board_config != ALC262_AUTO)
  3817. setup_preset(spec, &alc262_presets[board_config]);
  3818. spec->stream_name_analog = "ALC262 Analog";
  3819. spec->stream_analog_playback = &alc262_pcm_analog_playback;
  3820. spec->stream_analog_capture = &alc262_pcm_analog_capture;
  3821. spec->stream_name_digital = "ALC262 Digital";
  3822. spec->stream_digital_playback = &alc262_pcm_digital_playback;
  3823. spec->stream_digital_capture = &alc262_pcm_digital_capture;
  3824. if (! spec->adc_nids && spec->input_mux) {
  3825. /* check whether NID 0x07 is valid */
  3826. unsigned int wcap = get_wcaps(codec, 0x07);
  3827. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
  3828. if (wcap != AC_WID_AUD_IN) {
  3829. spec->adc_nids = alc262_adc_nids_alt;
  3830. spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
  3831. spec->mixers[spec->num_mixers] = alc262_capture_alt_mixer;
  3832. spec->num_mixers++;
  3833. } else {
  3834. spec->adc_nids = alc262_adc_nids;
  3835. spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
  3836. spec->mixers[spec->num_mixers] = alc262_capture_mixer;
  3837. spec->num_mixers++;
  3838. }
  3839. }
  3840. codec->patch_ops = alc_patch_ops;
  3841. if (board_config == ALC262_AUTO)
  3842. codec->patch_ops.init = alc262_auto_init;
  3843. return 0;
  3844. }
  3845. /*
  3846. * ALC861 channel source setting (2/6 channel selection for 3-stack)
  3847. */
  3848. /*
  3849. * set the path ways for 2 channel output
  3850. * need to set the codec line out and mic 1 pin widgets to inputs
  3851. */
  3852. static struct hda_verb alc861_threestack_ch2_init[] = {
  3853. /* set pin widget 1Ah (line in) for input */
  3854. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  3855. /* set pin widget 18h (mic1/2) for input, for mic also enable the vref */
  3856. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  3857. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
  3858. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, //mic
  3859. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, //line in
  3860. { } /* end */
  3861. };
  3862. /*
  3863. * 6ch mode
  3864. * need to set the codec line out and mic 1 pin widgets to outputs
  3865. */
  3866. static struct hda_verb alc861_threestack_ch6_init[] = {
  3867. /* set pin widget 1Ah (line in) for output (Back Surround)*/
  3868. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  3869. /* set pin widget 18h (mic1) for output (CLFE)*/
  3870. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  3871. { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
  3872. { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
  3873. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
  3874. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, //mic
  3875. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, //line in
  3876. { } /* end */
  3877. };
  3878. static struct hda_channel_mode alc861_threestack_modes[2] = {
  3879. { 2, alc861_threestack_ch2_init },
  3880. { 6, alc861_threestack_ch6_init },
  3881. };
  3882. /* patch-ALC861 */
  3883. static struct snd_kcontrol_new alc861_base_mixer[] = {
  3884. /* output mixer control */
  3885. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  3886. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  3887. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  3888. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  3889. HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
  3890. /*Input mixer control */
  3891. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  3892. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  3893. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  3894. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  3895. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  3896. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  3897. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  3898. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  3899. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  3900. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  3901. /* Capture mixer control */
  3902. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  3903. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  3904. {
  3905. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3906. .name = "Capture Source",
  3907. .count = 1,
  3908. .info = alc_mux_enum_info,
  3909. .get = alc_mux_enum_get,
  3910. .put = alc_mux_enum_put,
  3911. },
  3912. { } /* end */
  3913. };
  3914. static struct snd_kcontrol_new alc861_3ST_mixer[] = {
  3915. /* output mixer control */
  3916. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  3917. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  3918. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  3919. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  3920. /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
  3921. /* Input mixer control */
  3922. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  3923. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  3924. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  3925. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  3926. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  3927. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  3928. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  3929. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  3930. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  3931. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  3932. /* Capture mixer control */
  3933. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  3934. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  3935. {
  3936. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3937. .name = "Capture Source",
  3938. .count = 1,
  3939. .info = alc_mux_enum_info,
  3940. .get = alc_mux_enum_get,
  3941. .put = alc_mux_enum_put,
  3942. },
  3943. {
  3944. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3945. .name = "Channel Mode",
  3946. .info = alc_ch_mode_info,
  3947. .get = alc_ch_mode_get,
  3948. .put = alc_ch_mode_put,
  3949. .private_value = ARRAY_SIZE(alc861_threestack_modes),
  3950. },
  3951. { } /* end */
  3952. };
  3953. /*
  3954. * generic initialization of ADC, input mixers and output mixers
  3955. */
  3956. static struct hda_verb alc861_base_init_verbs[] = {
  3957. /*
  3958. * Unmute ADC0 and set the default input to mic-in
  3959. */
  3960. /* port-A for surround (rear panel) */
  3961. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  3962. { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
  3963. /* port-B for mic-in (rear panel) with vref */
  3964. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  3965. /* port-C for line-in (rear panel) */
  3966. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  3967. /* port-D for Front */
  3968. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  3969. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  3970. /* port-E for HP out (front panel) */
  3971. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
  3972. /* route front PCM to HP */
  3973. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01 },
  3974. /* port-F for mic-in (front panel) with vref */
  3975. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  3976. /* port-G for CLFE (rear panel) */
  3977. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  3978. { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  3979. /* port-H for side (rear panel) */
  3980. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  3981. { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
  3982. /* CD-in */
  3983. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  3984. /* route front mic to ADC1*/
  3985. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  3986. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3987. /* Unmute DAC0~3 & spdif out*/
  3988. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3989. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3990. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3991. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3992. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3993. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  3994. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3995. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3996. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3997. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3998. /* Unmute Stereo Mixer 15 */
  3999. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4000. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4001. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4002. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step
  4003. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4004. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4005. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4006. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4007. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4008. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4009. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4010. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4011. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
  4012. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4013. { }
  4014. };
  4015. static struct hda_verb alc861_threestack_init_verbs[] = {
  4016. /*
  4017. * Unmute ADC0 and set the default input to mic-in
  4018. */
  4019. /* port-A for surround (rear panel) */
  4020. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  4021. /* port-B for mic-in (rear panel) with vref */
  4022. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  4023. /* port-C for line-in (rear panel) */
  4024. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  4025. /* port-D for Front */
  4026. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  4027. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  4028. /* port-E for HP out (front panel) */
  4029. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
  4030. /* route front PCM to HP */
  4031. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01 },
  4032. /* port-F for mic-in (front panel) with vref */
  4033. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  4034. /* port-G for CLFE (rear panel) */
  4035. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  4036. /* port-H for side (rear panel) */
  4037. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  4038. /* CD-in */
  4039. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  4040. /* route front mic to ADC1*/
  4041. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4042. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4043. /* Unmute DAC0~3 & spdif out*/
  4044. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4045. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4046. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4047. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4048. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4049. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  4050. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4051. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4052. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4053. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4054. /* Unmute Stereo Mixer 15 */
  4055. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4056. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4057. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4058. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step
  4059. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4060. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4061. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4062. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4063. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4064. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4065. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4066. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4067. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
  4068. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4069. { }
  4070. };
  4071. /*
  4072. * generic initialization of ADC, input mixers and output mixers
  4073. */
  4074. static struct hda_verb alc861_auto_init_verbs[] = {
  4075. /*
  4076. * Unmute ADC0 and set the default input to mic-in
  4077. */
  4078. // {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4079. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4080. /* Unmute DAC0~3 & spdif out*/
  4081. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4082. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4083. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4084. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4085. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4086. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  4087. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4088. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4089. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4090. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4091. /* Unmute Stereo Mixer 15 */
  4092. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4093. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4094. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4095. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
  4096. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4097. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4098. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4099. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4100. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4101. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4102. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4103. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4104. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4105. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4106. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4107. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  4108. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4109. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4110. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4111. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  4112. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, // set Mic 1
  4113. { }
  4114. };
  4115. /* pcm configuration: identiacal with ALC880 */
  4116. #define alc861_pcm_analog_playback alc880_pcm_analog_playback
  4117. #define alc861_pcm_analog_capture alc880_pcm_analog_capture
  4118. #define alc861_pcm_digital_playback alc880_pcm_digital_playback
  4119. #define alc861_pcm_digital_capture alc880_pcm_digital_capture
  4120. #define ALC861_DIGOUT_NID 0x07
  4121. static struct hda_channel_mode alc861_8ch_modes[1] = {
  4122. { 8, NULL }
  4123. };
  4124. static hda_nid_t alc861_dac_nids[4] = {
  4125. /* front, surround, clfe, side */
  4126. 0x03, 0x06, 0x05, 0x04
  4127. };
  4128. static hda_nid_t alc861_adc_nids[1] = {
  4129. /* ADC0-2 */
  4130. 0x08,
  4131. };
  4132. static struct hda_input_mux alc861_capture_source = {
  4133. .num_items = 5,
  4134. .items = {
  4135. { "Mic", 0x0 },
  4136. { "Front Mic", 0x3 },
  4137. { "Line", 0x1 },
  4138. { "CD", 0x4 },
  4139. { "Mixer", 0x5 },
  4140. },
  4141. };
  4142. /* fill in the dac_nids table from the parsed pin configuration */
  4143. static int alc861_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
  4144. {
  4145. int i;
  4146. hda_nid_t nid;
  4147. spec->multiout.dac_nids = spec->private_dac_nids;
  4148. for (i = 0; i < cfg->line_outs; i++) {
  4149. nid = cfg->line_out_pins[i];
  4150. if (nid) {
  4151. if (i >= ARRAY_SIZE(alc861_dac_nids))
  4152. continue;
  4153. spec->multiout.dac_nids[i] = alc861_dac_nids[i];
  4154. }
  4155. }
  4156. spec->multiout.num_dacs = cfg->line_outs;
  4157. return 0;
  4158. }
  4159. /* add playback controls from the parsed DAC table */
  4160. static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
  4161. const struct auto_pin_cfg *cfg)
  4162. {
  4163. char name[32];
  4164. static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
  4165. hda_nid_t nid;
  4166. int i, idx, err;
  4167. for (i = 0; i < cfg->line_outs; i++) {
  4168. nid = spec->multiout.dac_nids[i];
  4169. if (! nid)
  4170. continue;
  4171. if (nid == 0x05) {
  4172. /* Center/LFE */
  4173. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch",
  4174. HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
  4175. return err;
  4176. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch",
  4177. HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
  4178. return err;
  4179. } else {
  4180. for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1; idx++)
  4181. if (nid == alc861_dac_nids[idx])
  4182. break;
  4183. sprintf(name, "%s Playback Switch", chname[idx]);
  4184. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  4185. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  4186. return err;
  4187. }
  4188. }
  4189. return 0;
  4190. }
  4191. static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
  4192. {
  4193. int err;
  4194. hda_nid_t nid;
  4195. if (! pin)
  4196. return 0;
  4197. if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
  4198. nid = 0x03;
  4199. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
  4200. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  4201. return err;
  4202. spec->multiout.hp_nid = nid;
  4203. }
  4204. return 0;
  4205. }
  4206. /* create playback/capture controls for input pins */
  4207. static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
  4208. {
  4209. struct hda_input_mux *imux = &spec->private_imux;
  4210. int i, err, idx, idx1;
  4211. for (i = 0; i < AUTO_PIN_LAST; i++) {
  4212. switch(cfg->input_pins[i]) {
  4213. case 0x0c:
  4214. idx1 = 1;
  4215. idx = 2; // Line In
  4216. break;
  4217. case 0x0f:
  4218. idx1 = 2;
  4219. idx = 2; // Line In
  4220. break;
  4221. case 0x0d:
  4222. idx1 = 0;
  4223. idx = 1; // Mic In
  4224. break;
  4225. case 0x10:
  4226. idx1 = 3;
  4227. idx = 1; // Mic In
  4228. break;
  4229. case 0x11:
  4230. idx1 = 4;
  4231. idx = 0; // CD
  4232. break;
  4233. default:
  4234. continue;
  4235. }
  4236. err = new_analog_input(spec, cfg->input_pins[i],
  4237. auto_pin_cfg_labels[i], idx, 0x15);
  4238. if (err < 0)
  4239. return err;
  4240. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  4241. imux->items[imux->num_items].index = idx1;
  4242. imux->num_items++;
  4243. }
  4244. return 0;
  4245. }
  4246. static struct snd_kcontrol_new alc861_capture_mixer[] = {
  4247. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  4248. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  4249. {
  4250. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4251. /* The multiple "Capture Source" controls confuse alsamixer
  4252. * So call somewhat different..
  4253. *FIXME: the controls appear in the "playback" view!
  4254. */
  4255. /* .name = "Capture Source", */
  4256. .name = "Input Source",
  4257. .count = 1,
  4258. .info = alc_mux_enum_info,
  4259. .get = alc_mux_enum_get,
  4260. .put = alc_mux_enum_put,
  4261. },
  4262. { } /* end */
  4263. };
  4264. static void alc861_auto_set_output_and_unmute(struct hda_codec *codec, hda_nid_t nid,
  4265. int pin_type, int dac_idx)
  4266. {
  4267. /* set as output */
  4268. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  4269. snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  4270. }
  4271. static void alc861_auto_init_multi_out(struct hda_codec *codec)
  4272. {
  4273. struct alc_spec *spec = codec->spec;
  4274. int i;
  4275. for (i = 0; i < spec->autocfg.line_outs; i++) {
  4276. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  4277. if (nid)
  4278. alc861_auto_set_output_and_unmute(codec, nid, PIN_OUT, spec->multiout.dac_nids[i]);
  4279. }
  4280. }
  4281. static void alc861_auto_init_hp_out(struct hda_codec *codec)
  4282. {
  4283. struct alc_spec *spec = codec->spec;
  4284. hda_nid_t pin;
  4285. pin = spec->autocfg.hp_pin;
  4286. if (pin) /* connect to front */
  4287. alc861_auto_set_output_and_unmute(codec, pin, PIN_HP, spec->multiout.dac_nids[0]);
  4288. }
  4289. static void alc861_auto_init_analog_input(struct hda_codec *codec)
  4290. {
  4291. struct alc_spec *spec = codec->spec;
  4292. int i;
  4293. for (i = 0; i < AUTO_PIN_LAST; i++) {
  4294. hda_nid_t nid = spec->autocfg.input_pins[i];
  4295. if ((nid>=0x0c) && (nid <=0x11)) {
  4296. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  4297. i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
  4298. }
  4299. }
  4300. }
  4301. /* parse the BIOS configuration and set up the alc_spec */
  4302. /* return 1 if successful, 0 if the proper config is not found, or a negative error code */
  4303. static int alc861_parse_auto_config(struct hda_codec *codec)
  4304. {
  4305. struct alc_spec *spec = codec->spec;
  4306. int err;
  4307. static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
  4308. if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  4309. alc861_ignore)) < 0)
  4310. return err;
  4311. if (! spec->autocfg.line_outs && ! spec->autocfg.speaker_pin &&
  4312. ! spec->autocfg.hp_pin)
  4313. return 0; /* can't find valid BIOS pin config */
  4314. if ((err = alc861_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 ||
  4315. (err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
  4316. (err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pin)) < 0 ||
  4317. (err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
  4318. return err;
  4319. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  4320. if (spec->autocfg.dig_out_pin)
  4321. spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
  4322. if (spec->kctl_alloc)
  4323. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  4324. spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
  4325. spec->input_mux = &spec->private_imux;
  4326. spec->adc_nids = alc861_adc_nids;
  4327. spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
  4328. spec->mixers[spec->num_mixers] = alc861_capture_mixer;
  4329. spec->num_mixers++;
  4330. return 1;
  4331. }
  4332. /* init callback for auto-configuration model -- overriding the default init */
  4333. static int alc861_auto_init(struct hda_codec *codec)
  4334. {
  4335. alc_init(codec);
  4336. alc861_auto_init_multi_out(codec);
  4337. alc861_auto_init_hp_out(codec);
  4338. alc861_auto_init_analog_input(codec);
  4339. return 0;
  4340. }
  4341. /*
  4342. * configuration and preset
  4343. */
  4344. static struct hda_board_config alc861_cfg_tbl[] = {
  4345. { .modelname = "3stack", .config = ALC861_3ST },
  4346. { .pci_subvendor = 0x8086, .pci_subdevice = 0xd600, .config = ALC861_3ST },
  4347. { .modelname = "3stack-dig", .config = ALC861_3ST_DIG },
  4348. { .modelname = "6stack-dig", .config = ALC861_6ST_DIG },
  4349. { .modelname = "auto", .config = ALC861_AUTO },
  4350. {}
  4351. };
  4352. static struct alc_config_preset alc861_presets[] = {
  4353. [ALC861_3ST] = {
  4354. .mixers = { alc861_3ST_mixer },
  4355. .init_verbs = { alc861_threestack_init_verbs },
  4356. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  4357. .dac_nids = alc861_dac_nids,
  4358. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  4359. .channel_mode = alc861_threestack_modes,
  4360. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  4361. .adc_nids = alc861_adc_nids,
  4362. .input_mux = &alc861_capture_source,
  4363. },
  4364. [ALC861_3ST_DIG] = {
  4365. .mixers = { alc861_base_mixer },
  4366. .init_verbs = { alc861_threestack_init_verbs },
  4367. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  4368. .dac_nids = alc861_dac_nids,
  4369. .dig_out_nid = ALC861_DIGOUT_NID,
  4370. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  4371. .channel_mode = alc861_threestack_modes,
  4372. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  4373. .adc_nids = alc861_adc_nids,
  4374. .input_mux = &alc861_capture_source,
  4375. },
  4376. [ALC861_6ST_DIG] = {
  4377. .mixers = { alc861_base_mixer },
  4378. .init_verbs = { alc861_base_init_verbs },
  4379. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  4380. .dac_nids = alc861_dac_nids,
  4381. .dig_out_nid = ALC861_DIGOUT_NID,
  4382. .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
  4383. .channel_mode = alc861_8ch_modes,
  4384. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  4385. .adc_nids = alc861_adc_nids,
  4386. .input_mux = &alc861_capture_source,
  4387. },
  4388. };
  4389. static int patch_alc861(struct hda_codec *codec)
  4390. {
  4391. struct alc_spec *spec;
  4392. int board_config;
  4393. int err;
  4394. spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
  4395. if (spec == NULL)
  4396. return -ENOMEM;
  4397. codec->spec = spec;
  4398. board_config = snd_hda_check_board_config(codec, alc861_cfg_tbl);
  4399. if (board_config < 0 || board_config >= ALC861_MODEL_LAST) {
  4400. printk(KERN_INFO "hda_codec: Unknown model for ALC861, trying auto-probe from BIOS...\n");
  4401. board_config = ALC861_AUTO;
  4402. }
  4403. if (board_config == ALC861_AUTO) {
  4404. /* automatic parse from the BIOS config */
  4405. err = alc861_parse_auto_config(codec);
  4406. if (err < 0) {
  4407. alc_free(codec);
  4408. return err;
  4409. } else if (! err) {
  4410. printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using base mode...\n");
  4411. board_config = ALC861_3ST_DIG;
  4412. }
  4413. }
  4414. if (board_config != ALC861_AUTO)
  4415. setup_preset(spec, &alc861_presets[board_config]);
  4416. spec->stream_name_analog = "ALC861 Analog";
  4417. spec->stream_analog_playback = &alc861_pcm_analog_playback;
  4418. spec->stream_analog_capture = &alc861_pcm_analog_capture;
  4419. spec->stream_name_digital = "ALC861 Digital";
  4420. spec->stream_digital_playback = &alc861_pcm_digital_playback;
  4421. spec->stream_digital_capture = &alc861_pcm_digital_capture;
  4422. codec->patch_ops = alc_patch_ops;
  4423. if (board_config == ALC861_AUTO)
  4424. codec->patch_ops.init = alc861_auto_init;
  4425. return 0;
  4426. }
  4427. /*
  4428. * patch entries
  4429. */
  4430. struct hda_codec_preset snd_hda_preset_realtek[] = {
  4431. { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
  4432. { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
  4433. { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
  4434. { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
  4435. { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
  4436. { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
  4437. { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
  4438. {} /* terminator */
  4439. };