patch_realtek.c 188 KB

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