patch_realtek.c 194 KB

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