patch_realtek.c 263 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779
  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. #define ALC880_FRONT_EVENT 0x01
  34. #define ALC880_DCVOL_EVENT 0x02
  35. #define ALC880_HP_EVENT 0x04
  36. #define ALC880_MIC_EVENT 0x08
  37. /* ALC880 board config type */
  38. enum {
  39. ALC880_3ST,
  40. ALC880_3ST_DIG,
  41. ALC880_5ST,
  42. ALC880_5ST_DIG,
  43. ALC880_W810,
  44. ALC880_Z71V,
  45. ALC880_6ST,
  46. ALC880_6ST_DIG,
  47. ALC880_F1734,
  48. ALC880_ASUS,
  49. ALC880_ASUS_DIG,
  50. ALC880_ASUS_W1V,
  51. ALC880_ASUS_DIG2,
  52. ALC880_UNIWILL_DIG,
  53. ALC880_UNIWILL,
  54. ALC880_UNIWILL_P53,
  55. ALC880_CLEVO,
  56. ALC880_TCL_S700,
  57. ALC880_LG,
  58. ALC880_LG_LW,
  59. #ifdef CONFIG_SND_DEBUG
  60. ALC880_TEST,
  61. #endif
  62. ALC880_AUTO,
  63. ALC880_MODEL_LAST /* last tag */
  64. };
  65. /* ALC260 models */
  66. enum {
  67. ALC260_BASIC,
  68. ALC260_HP,
  69. ALC260_HP_3013,
  70. ALC260_FUJITSU_S702X,
  71. ALC260_ACER,
  72. #ifdef CONFIG_SND_DEBUG
  73. ALC260_TEST,
  74. #endif
  75. ALC260_AUTO,
  76. ALC260_MODEL_LAST /* last tag */
  77. };
  78. /* ALC262 models */
  79. enum {
  80. ALC262_BASIC,
  81. ALC262_HIPPO,
  82. ALC262_HIPPO_1,
  83. ALC262_FUJITSU,
  84. ALC262_HP_BPC,
  85. ALC262_BENQ_ED8,
  86. ALC262_AUTO,
  87. ALC262_MODEL_LAST /* last tag */
  88. };
  89. /* ALC861 models */
  90. enum {
  91. ALC861_3ST,
  92. ALC660_3ST,
  93. ALC861_3ST_DIG,
  94. ALC861_6ST_DIG,
  95. ALC861_UNIWILL_M31,
  96. ALC861_TOSHIBA,
  97. ALC861_ASUS,
  98. ALC861_ASUS_LAPTOP,
  99. ALC861_AUTO,
  100. ALC861_MODEL_LAST,
  101. };
  102. /* ALC882 models */
  103. enum {
  104. ALC882_3ST_DIG,
  105. ALC882_6ST_DIG,
  106. ALC882_ARIMA,
  107. ALC882_AUTO,
  108. ALC885_MACPRO,
  109. ALC882_MODEL_LAST,
  110. };
  111. /* ALC883 models */
  112. enum {
  113. ALC883_3ST_2ch_DIG,
  114. ALC883_3ST_6ch_DIG,
  115. ALC883_3ST_6ch,
  116. ALC883_6ST_DIG,
  117. ALC883_TARGA_DIG,
  118. ALC883_TARGA_2ch_DIG,
  119. ALC888_DEMO_BOARD,
  120. ALC883_ACER,
  121. ALC883_MEDION,
  122. ALC883_LAPTOP_EAPD,
  123. ALC883_AUTO,
  124. ALC883_MODEL_LAST,
  125. };
  126. /* for GPIO Poll */
  127. #define GPIO_MASK 0x03
  128. struct alc_spec {
  129. /* codec parameterization */
  130. struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
  131. unsigned int num_mixers;
  132. const struct hda_verb *init_verbs[5]; /* initialization verbs
  133. * don't forget NULL
  134. * termination!
  135. */
  136. unsigned int num_init_verbs;
  137. char *stream_name_analog; /* analog PCM stream */
  138. struct hda_pcm_stream *stream_analog_playback;
  139. struct hda_pcm_stream *stream_analog_capture;
  140. char *stream_name_digital; /* digital PCM stream */
  141. struct hda_pcm_stream *stream_digital_playback;
  142. struct hda_pcm_stream *stream_digital_capture;
  143. /* playback */
  144. struct hda_multi_out multiout; /* playback set-up
  145. * max_channels, dacs must be set
  146. * dig_out_nid and hp_nid are optional
  147. */
  148. /* capture */
  149. unsigned int num_adc_nids;
  150. hda_nid_t *adc_nids;
  151. hda_nid_t dig_in_nid; /* digital-in NID; optional */
  152. /* capture source */
  153. unsigned int num_mux_defs;
  154. const struct hda_input_mux *input_mux;
  155. unsigned int cur_mux[3];
  156. /* channel model */
  157. const struct hda_channel_mode *channel_mode;
  158. int num_channel_mode;
  159. int need_dac_fix;
  160. /* PCM information */
  161. struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
  162. /* dynamic controls, init_verbs and input_mux */
  163. struct auto_pin_cfg autocfg;
  164. unsigned int num_kctl_alloc, num_kctl_used;
  165. struct snd_kcontrol_new *kctl_alloc;
  166. struct hda_input_mux private_imux;
  167. hda_nid_t private_dac_nids[5];
  168. /* hooks */
  169. void (*init_hook)(struct hda_codec *codec);
  170. void (*unsol_event)(struct hda_codec *codec, unsigned int res);
  171. /* for pin sensing */
  172. unsigned int sense_updated: 1;
  173. unsigned int jack_present: 1;
  174. };
  175. /*
  176. * configuration template - to be copied to the spec instance
  177. */
  178. struct alc_config_preset {
  179. struct snd_kcontrol_new *mixers[5]; /* should be identical size
  180. * with spec
  181. */
  182. const struct hda_verb *init_verbs[5];
  183. unsigned int num_dacs;
  184. hda_nid_t *dac_nids;
  185. hda_nid_t dig_out_nid; /* optional */
  186. hda_nid_t hp_nid; /* optional */
  187. unsigned int num_adc_nids;
  188. hda_nid_t *adc_nids;
  189. hda_nid_t dig_in_nid;
  190. unsigned int num_channel_mode;
  191. const struct hda_channel_mode *channel_mode;
  192. int need_dac_fix;
  193. unsigned int num_mux_defs;
  194. const struct hda_input_mux *input_mux;
  195. void (*unsol_event)(struct hda_codec *, unsigned int);
  196. void (*init_hook)(struct hda_codec *);
  197. };
  198. /*
  199. * input MUX handling
  200. */
  201. static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
  202. struct snd_ctl_elem_info *uinfo)
  203. {
  204. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  205. struct alc_spec *spec = codec->spec;
  206. unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
  207. if (mux_idx >= spec->num_mux_defs)
  208. mux_idx = 0;
  209. return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
  210. }
  211. static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
  212. struct snd_ctl_elem_value *ucontrol)
  213. {
  214. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  215. struct alc_spec *spec = codec->spec;
  216. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  217. ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
  218. return 0;
  219. }
  220. static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
  221. struct snd_ctl_elem_value *ucontrol)
  222. {
  223. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  224. struct alc_spec *spec = codec->spec;
  225. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  226. unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
  227. return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
  228. spec->adc_nids[adc_idx],
  229. &spec->cur_mux[adc_idx]);
  230. }
  231. /*
  232. * channel mode setting
  233. */
  234. static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
  235. struct snd_ctl_elem_info *uinfo)
  236. {
  237. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  238. struct alc_spec *spec = codec->spec;
  239. return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
  240. spec->num_channel_mode);
  241. }
  242. static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
  243. struct snd_ctl_elem_value *ucontrol)
  244. {
  245. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  246. struct alc_spec *spec = codec->spec;
  247. return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
  248. spec->num_channel_mode,
  249. spec->multiout.max_channels);
  250. }
  251. static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
  252. struct snd_ctl_elem_value *ucontrol)
  253. {
  254. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  255. struct alc_spec *spec = codec->spec;
  256. int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
  257. spec->num_channel_mode,
  258. &spec->multiout.max_channels);
  259. if (err >= 0 && spec->need_dac_fix)
  260. spec->multiout.num_dacs = spec->multiout.max_channels / 2;
  261. return err;
  262. }
  263. /*
  264. * Control the mode of pin widget settings via the mixer. "pc" is used
  265. * instead of "%" to avoid consequences of accidently treating the % as
  266. * being part of a format specifier. Maximum allowed length of a value is
  267. * 63 characters plus NULL terminator.
  268. *
  269. * Note: some retasking pin complexes seem to ignore requests for input
  270. * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
  271. * are requested. Therefore order this list so that this behaviour will not
  272. * cause problems when mixer clients move through the enum sequentially.
  273. * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
  274. * March 2006.
  275. */
  276. static char *alc_pin_mode_names[] = {
  277. "Mic 50pc bias", "Mic 80pc bias",
  278. "Line in", "Line out", "Headphone out",
  279. };
  280. static unsigned char alc_pin_mode_values[] = {
  281. PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
  282. };
  283. /* The control can present all 5 options, or it can limit the options based
  284. * in the pin being assumed to be exclusively an input or an output pin. In
  285. * addition, "input" pins may or may not process the mic bias option
  286. * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
  287. * accept requests for bias as of chip versions up to March 2006) and/or
  288. * wiring in the computer.
  289. */
  290. #define ALC_PIN_DIR_IN 0x00
  291. #define ALC_PIN_DIR_OUT 0x01
  292. #define ALC_PIN_DIR_INOUT 0x02
  293. #define ALC_PIN_DIR_IN_NOMICBIAS 0x03
  294. #define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
  295. /* Info about the pin modes supported by the different pin direction modes.
  296. * For each direction the minimum and maximum values are given.
  297. */
  298. static signed char alc_pin_mode_dir_info[5][2] = {
  299. { 0, 2 }, /* ALC_PIN_DIR_IN */
  300. { 3, 4 }, /* ALC_PIN_DIR_OUT */
  301. { 0, 4 }, /* ALC_PIN_DIR_INOUT */
  302. { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
  303. { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
  304. };
  305. #define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
  306. #define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
  307. #define alc_pin_mode_n_items(_dir) \
  308. (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
  309. static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
  310. struct snd_ctl_elem_info *uinfo)
  311. {
  312. unsigned int item_num = uinfo->value.enumerated.item;
  313. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  314. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  315. uinfo->count = 1;
  316. uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
  317. if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
  318. item_num = alc_pin_mode_min(dir);
  319. strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
  320. return 0;
  321. }
  322. static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
  323. struct snd_ctl_elem_value *ucontrol)
  324. {
  325. unsigned int i;
  326. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  327. hda_nid_t nid = kcontrol->private_value & 0xffff;
  328. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  329. long *valp = ucontrol->value.integer.value;
  330. unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
  331. AC_VERB_GET_PIN_WIDGET_CONTROL,
  332. 0x00);
  333. /* Find enumerated value for current pinctl setting */
  334. i = alc_pin_mode_min(dir);
  335. while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
  336. i++;
  337. *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
  338. return 0;
  339. }
  340. static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
  341. struct snd_ctl_elem_value *ucontrol)
  342. {
  343. signed int change;
  344. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  345. hda_nid_t nid = kcontrol->private_value & 0xffff;
  346. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  347. long val = *ucontrol->value.integer.value;
  348. unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
  349. AC_VERB_GET_PIN_WIDGET_CONTROL,
  350. 0x00);
  351. if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
  352. val = alc_pin_mode_min(dir);
  353. change = pinctl != alc_pin_mode_values[val];
  354. if (change) {
  355. /* Set pin mode to that requested */
  356. snd_hda_codec_write(codec,nid,0,AC_VERB_SET_PIN_WIDGET_CONTROL,
  357. alc_pin_mode_values[val]);
  358. /* Also enable the retasking pin's input/output as required
  359. * for the requested pin mode. Enum values of 2 or less are
  360. * input modes.
  361. *
  362. * Dynamically switching the input/output buffers probably
  363. * reduces noise slightly (particularly on input) so we'll
  364. * do it. However, having both input and output buffers
  365. * enabled simultaneously doesn't seem to be problematic if
  366. * this turns out to be necessary in the future.
  367. */
  368. if (val <= 2) {
  369. snd_hda_codec_write(codec, nid, 0,
  370. AC_VERB_SET_AMP_GAIN_MUTE,
  371. AMP_OUT_MUTE);
  372. snd_hda_codec_write(codec, nid, 0,
  373. AC_VERB_SET_AMP_GAIN_MUTE,
  374. AMP_IN_UNMUTE(0));
  375. } else {
  376. snd_hda_codec_write(codec, nid, 0,
  377. AC_VERB_SET_AMP_GAIN_MUTE,
  378. AMP_IN_MUTE(0));
  379. snd_hda_codec_write(codec, nid, 0,
  380. AC_VERB_SET_AMP_GAIN_MUTE,
  381. AMP_OUT_UNMUTE);
  382. }
  383. }
  384. return change;
  385. }
  386. #define ALC_PIN_MODE(xname, nid, dir) \
  387. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  388. .info = alc_pin_mode_info, \
  389. .get = alc_pin_mode_get, \
  390. .put = alc_pin_mode_put, \
  391. .private_value = nid | (dir<<16) }
  392. /* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
  393. * together using a mask with more than one bit set. This control is
  394. * currently used only by the ALC260 test model. At this stage they are not
  395. * needed for any "production" models.
  396. */
  397. #ifdef CONFIG_SND_DEBUG
  398. static int alc_gpio_data_info(struct snd_kcontrol *kcontrol,
  399. struct snd_ctl_elem_info *uinfo)
  400. {
  401. uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
  402. uinfo->count = 1;
  403. uinfo->value.integer.min = 0;
  404. uinfo->value.integer.max = 1;
  405. return 0;
  406. }
  407. static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
  408. struct snd_ctl_elem_value *ucontrol)
  409. {
  410. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  411. hda_nid_t nid = kcontrol->private_value & 0xffff;
  412. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  413. long *valp = ucontrol->value.integer.value;
  414. unsigned int val = snd_hda_codec_read(codec, nid, 0,
  415. AC_VERB_GET_GPIO_DATA, 0x00);
  416. *valp = (val & mask) != 0;
  417. return 0;
  418. }
  419. static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
  420. struct snd_ctl_elem_value *ucontrol)
  421. {
  422. signed int change;
  423. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  424. hda_nid_t nid = kcontrol->private_value & 0xffff;
  425. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  426. long val = *ucontrol->value.integer.value;
  427. unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
  428. AC_VERB_GET_GPIO_DATA,
  429. 0x00);
  430. /* Set/unset the masked GPIO bit(s) as needed */
  431. change = (val == 0 ? 0 : mask) != (gpio_data & mask);
  432. if (val == 0)
  433. gpio_data &= ~mask;
  434. else
  435. gpio_data |= mask;
  436. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_GPIO_DATA, gpio_data);
  437. return change;
  438. }
  439. #define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
  440. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  441. .info = alc_gpio_data_info, \
  442. .get = alc_gpio_data_get, \
  443. .put = alc_gpio_data_put, \
  444. .private_value = nid | (mask<<16) }
  445. #endif /* CONFIG_SND_DEBUG */
  446. /* A switch control to allow the enabling of the digital IO pins on the
  447. * ALC260. This is incredibly simplistic; the intention of this control is
  448. * to provide something in the test model allowing digital outputs to be
  449. * identified if present. If models are found which can utilise these
  450. * outputs a more complete mixer control can be devised for those models if
  451. * necessary.
  452. */
  453. #ifdef CONFIG_SND_DEBUG
  454. static int alc_spdif_ctrl_info(struct snd_kcontrol *kcontrol,
  455. struct snd_ctl_elem_info *uinfo)
  456. {
  457. uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
  458. uinfo->count = 1;
  459. uinfo->value.integer.min = 0;
  460. uinfo->value.integer.max = 1;
  461. return 0;
  462. }
  463. static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
  464. struct snd_ctl_elem_value *ucontrol)
  465. {
  466. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  467. hda_nid_t nid = kcontrol->private_value & 0xffff;
  468. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  469. long *valp = ucontrol->value.integer.value;
  470. unsigned int val = snd_hda_codec_read(codec, nid, 0,
  471. AC_VERB_GET_DIGI_CONVERT, 0x00);
  472. *valp = (val & mask) != 0;
  473. return 0;
  474. }
  475. static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
  476. struct snd_ctl_elem_value *ucontrol)
  477. {
  478. signed int change;
  479. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  480. hda_nid_t nid = kcontrol->private_value & 0xffff;
  481. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  482. long val = *ucontrol->value.integer.value;
  483. unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
  484. AC_VERB_GET_DIGI_CONVERT,
  485. 0x00);
  486. /* Set/unset the masked control bit(s) as needed */
  487. change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
  488. if (val==0)
  489. ctrl_data &= ~mask;
  490. else
  491. ctrl_data |= mask;
  492. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
  493. ctrl_data);
  494. return change;
  495. }
  496. #define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
  497. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  498. .info = alc_spdif_ctrl_info, \
  499. .get = alc_spdif_ctrl_get, \
  500. .put = alc_spdif_ctrl_put, \
  501. .private_value = nid | (mask<<16) }
  502. #endif /* CONFIG_SND_DEBUG */
  503. /*
  504. * set up from the preset table
  505. */
  506. static void setup_preset(struct alc_spec *spec,
  507. const struct alc_config_preset *preset)
  508. {
  509. int i;
  510. for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
  511. spec->mixers[spec->num_mixers++] = preset->mixers[i];
  512. for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
  513. i++)
  514. spec->init_verbs[spec->num_init_verbs++] =
  515. preset->init_verbs[i];
  516. spec->channel_mode = preset->channel_mode;
  517. spec->num_channel_mode = preset->num_channel_mode;
  518. spec->need_dac_fix = preset->need_dac_fix;
  519. spec->multiout.max_channels = spec->channel_mode[0].channels;
  520. spec->multiout.num_dacs = preset->num_dacs;
  521. spec->multiout.dac_nids = preset->dac_nids;
  522. spec->multiout.dig_out_nid = preset->dig_out_nid;
  523. spec->multiout.hp_nid = preset->hp_nid;
  524. spec->num_mux_defs = preset->num_mux_defs;
  525. if (! spec->num_mux_defs)
  526. spec->num_mux_defs = 1;
  527. spec->input_mux = preset->input_mux;
  528. spec->num_adc_nids = preset->num_adc_nids;
  529. spec->adc_nids = preset->adc_nids;
  530. spec->dig_in_nid = preset->dig_in_nid;
  531. spec->unsol_event = preset->unsol_event;
  532. spec->init_hook = preset->init_hook;
  533. }
  534. /*
  535. * ALC880 3-stack model
  536. *
  537. * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
  538. * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
  539. * F-Mic = 0x1b, HP = 0x19
  540. */
  541. static hda_nid_t alc880_dac_nids[4] = {
  542. /* front, rear, clfe, rear_surr */
  543. 0x02, 0x05, 0x04, 0x03
  544. };
  545. static hda_nid_t alc880_adc_nids[3] = {
  546. /* ADC0-2 */
  547. 0x07, 0x08, 0x09,
  548. };
  549. /* The datasheet says the node 0x07 is connected from inputs,
  550. * but it shows zero connection in the real implementation on some devices.
  551. * Note: this is a 915GAV bug, fixed on 915GLV
  552. */
  553. static hda_nid_t alc880_adc_nids_alt[2] = {
  554. /* ADC1-2 */
  555. 0x08, 0x09,
  556. };
  557. #define ALC880_DIGOUT_NID 0x06
  558. #define ALC880_DIGIN_NID 0x0a
  559. static struct hda_input_mux alc880_capture_source = {
  560. .num_items = 4,
  561. .items = {
  562. { "Mic", 0x0 },
  563. { "Front Mic", 0x3 },
  564. { "Line", 0x2 },
  565. { "CD", 0x4 },
  566. },
  567. };
  568. /* channel source setting (2/6 channel selection for 3-stack) */
  569. /* 2ch mode */
  570. static struct hda_verb alc880_threestack_ch2_init[] = {
  571. /* set line-in to input, mute it */
  572. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  573. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  574. /* set mic-in to input vref 80%, mute it */
  575. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  576. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  577. { } /* end */
  578. };
  579. /* 6ch mode */
  580. static struct hda_verb alc880_threestack_ch6_init[] = {
  581. /* set line-in to output, unmute it */
  582. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  583. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  584. /* set mic-in to output, unmute it */
  585. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  586. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  587. { } /* end */
  588. };
  589. static struct hda_channel_mode alc880_threestack_modes[2] = {
  590. { 2, alc880_threestack_ch2_init },
  591. { 6, alc880_threestack_ch6_init },
  592. };
  593. static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
  594. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  595. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  596. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  597. HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
  598. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  599. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  600. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  601. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  602. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  603. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  604. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  605. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  606. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  607. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  608. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
  609. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
  610. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  611. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  612. HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
  613. {
  614. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  615. .name = "Channel Mode",
  616. .info = alc_ch_mode_info,
  617. .get = alc_ch_mode_get,
  618. .put = alc_ch_mode_put,
  619. },
  620. { } /* end */
  621. };
  622. /* capture mixer elements */
  623. static struct snd_kcontrol_new alc880_capture_mixer[] = {
  624. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  625. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  626. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  627. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  628. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  629. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  630. {
  631. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  632. /* The multiple "Capture Source" controls confuse alsamixer
  633. * So call somewhat different..
  634. * FIXME: the controls appear in the "playback" view!
  635. */
  636. /* .name = "Capture Source", */
  637. .name = "Input Source",
  638. .count = 3,
  639. .info = alc_mux_enum_info,
  640. .get = alc_mux_enum_get,
  641. .put = alc_mux_enum_put,
  642. },
  643. { } /* end */
  644. };
  645. /* capture mixer elements (in case NID 0x07 not available) */
  646. static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
  647. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  648. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  649. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  650. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  651. {
  652. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  653. /* The multiple "Capture Source" controls confuse alsamixer
  654. * So call somewhat different..
  655. * FIXME: the controls appear in the "playback" view!
  656. */
  657. /* .name = "Capture Source", */
  658. .name = "Input Source",
  659. .count = 2,
  660. .info = alc_mux_enum_info,
  661. .get = alc_mux_enum_get,
  662. .put = alc_mux_enum_put,
  663. },
  664. { } /* end */
  665. };
  666. /*
  667. * ALC880 5-stack model
  668. *
  669. * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
  670. * Side = 0x02 (0xd)
  671. * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
  672. * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
  673. */
  674. /* additional mixers to alc880_three_stack_mixer */
  675. static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
  676. HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  677. HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
  678. { } /* end */
  679. };
  680. /* channel source setting (6/8 channel selection for 5-stack) */
  681. /* 6ch mode */
  682. static struct hda_verb alc880_fivestack_ch6_init[] = {
  683. /* set line-in to input, mute it */
  684. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  685. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  686. { } /* end */
  687. };
  688. /* 8ch mode */
  689. static struct hda_verb alc880_fivestack_ch8_init[] = {
  690. /* set line-in to output, unmute it */
  691. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  692. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  693. { } /* end */
  694. };
  695. static struct hda_channel_mode alc880_fivestack_modes[2] = {
  696. { 6, alc880_fivestack_ch6_init },
  697. { 8, alc880_fivestack_ch8_init },
  698. };
  699. /*
  700. * ALC880 6-stack model
  701. *
  702. * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
  703. * Side = 0x05 (0x0f)
  704. * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
  705. * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
  706. */
  707. static hda_nid_t alc880_6st_dac_nids[4] = {
  708. /* front, rear, clfe, rear_surr */
  709. 0x02, 0x03, 0x04, 0x05
  710. };
  711. static struct hda_input_mux alc880_6stack_capture_source = {
  712. .num_items = 4,
  713. .items = {
  714. { "Mic", 0x0 },
  715. { "Front Mic", 0x1 },
  716. { "Line", 0x2 },
  717. { "CD", 0x4 },
  718. },
  719. };
  720. /* fixed 8-channels */
  721. static struct hda_channel_mode alc880_sixstack_modes[1] = {
  722. { 8, NULL },
  723. };
  724. static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
  725. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  726. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  727. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  728. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  729. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  730. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  731. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  732. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  733. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  734. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  735. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  736. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  737. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  738. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  739. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  740. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  741. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  742. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  743. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  744. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  745. {
  746. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  747. .name = "Channel Mode",
  748. .info = alc_ch_mode_info,
  749. .get = alc_ch_mode_get,
  750. .put = alc_ch_mode_put,
  751. },
  752. { } /* end */
  753. };
  754. /*
  755. * ALC880 W810 model
  756. *
  757. * W810 has rear IO for:
  758. * Front (DAC 02)
  759. * Surround (DAC 03)
  760. * Center/LFE (DAC 04)
  761. * Digital out (06)
  762. *
  763. * The system also has a pair of internal speakers, and a headphone jack.
  764. * These are both connected to Line2 on the codec, hence to DAC 02.
  765. *
  766. * There is a variable resistor to control the speaker or headphone
  767. * volume. This is a hardware-only device without a software API.
  768. *
  769. * Plugging headphones in will disable the internal speakers. This is
  770. * implemented in hardware, not via the driver using jack sense. In
  771. * a similar fashion, plugging into the rear socket marked "front" will
  772. * disable both the speakers and headphones.
  773. *
  774. * For input, there's a microphone jack, and an "audio in" jack.
  775. * These may not do anything useful with this driver yet, because I
  776. * haven't setup any initialization verbs for these yet...
  777. */
  778. static hda_nid_t alc880_w810_dac_nids[3] = {
  779. /* front, rear/surround, clfe */
  780. 0x02, 0x03, 0x04
  781. };
  782. /* fixed 6 channels */
  783. static struct hda_channel_mode alc880_w810_modes[1] = {
  784. { 6, NULL }
  785. };
  786. /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
  787. static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
  788. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  789. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  790. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  791. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  792. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  793. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  794. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  795. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  796. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  797. { } /* end */
  798. };
  799. /*
  800. * Z710V model
  801. *
  802. * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
  803. * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
  804. * Line = 0x1a
  805. */
  806. static hda_nid_t alc880_z71v_dac_nids[1] = {
  807. 0x02
  808. };
  809. #define ALC880_Z71V_HP_DAC 0x03
  810. /* fixed 2 channels */
  811. static struct hda_channel_mode alc880_2_jack_modes[1] = {
  812. { 2, NULL }
  813. };
  814. static struct snd_kcontrol_new alc880_z71v_mixer[] = {
  815. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  816. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  817. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  818. HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
  819. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  820. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  821. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  822. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  823. { } /* end */
  824. };
  825. /* FIXME! */
  826. /*
  827. * ALC880 F1734 model
  828. *
  829. * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
  830. * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
  831. */
  832. static hda_nid_t alc880_f1734_dac_nids[1] = {
  833. 0x03
  834. };
  835. #define ALC880_F1734_HP_DAC 0x02
  836. static struct snd_kcontrol_new alc880_f1734_mixer[] = {
  837. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  838. HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
  839. HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  840. HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
  841. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  842. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  843. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  844. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  845. { } /* end */
  846. };
  847. /* FIXME! */
  848. /*
  849. * ALC880 ASUS model
  850. *
  851. * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
  852. * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
  853. * Mic = 0x18, Line = 0x1a
  854. */
  855. #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
  856. #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
  857. static struct snd_kcontrol_new alc880_asus_mixer[] = {
  858. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  859. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  860. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  861. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  862. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  863. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  864. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  865. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  866. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  867. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  868. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  869. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  870. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  871. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  872. {
  873. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  874. .name = "Channel Mode",
  875. .info = alc_ch_mode_info,
  876. .get = alc_ch_mode_get,
  877. .put = alc_ch_mode_put,
  878. },
  879. { } /* end */
  880. };
  881. /* FIXME! */
  882. /*
  883. * ALC880 ASUS W1V model
  884. *
  885. * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
  886. * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
  887. * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
  888. */
  889. /* additional mixers to alc880_asus_mixer */
  890. static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
  891. HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
  892. HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
  893. { } /* end */
  894. };
  895. /* additional mixers to alc880_asus_mixer */
  896. static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
  897. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  898. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  899. { } /* end */
  900. };
  901. /* TCL S700 */
  902. static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
  903. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  904. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  905. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  906. HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
  907. HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
  908. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
  909. HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
  910. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  911. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  912. {
  913. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  914. /* The multiple "Capture Source" controls confuse alsamixer
  915. * So call somewhat different..
  916. * FIXME: the controls appear in the "playback" view!
  917. */
  918. /* .name = "Capture Source", */
  919. .name = "Input Source",
  920. .count = 1,
  921. .info = alc_mux_enum_info,
  922. .get = alc_mux_enum_get,
  923. .put = alc_mux_enum_put,
  924. },
  925. { } /* end */
  926. };
  927. /* Uniwill */
  928. static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
  929. HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  930. HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
  931. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  932. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  933. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  934. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  935. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  936. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  937. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  938. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  939. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  940. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  941. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  942. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  943. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  944. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  945. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  946. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  947. {
  948. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  949. .name = "Channel Mode",
  950. .info = alc_ch_mode_info,
  951. .get = alc_ch_mode_get,
  952. .put = alc_ch_mode_put,
  953. },
  954. { } /* end */
  955. };
  956. static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
  957. HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  958. HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
  959. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  960. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  961. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  962. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  963. { } /* end */
  964. };
  965. /*
  966. * build control elements
  967. */
  968. static int alc_build_controls(struct hda_codec *codec)
  969. {
  970. struct alc_spec *spec = codec->spec;
  971. int err;
  972. int i;
  973. for (i = 0; i < spec->num_mixers; i++) {
  974. err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
  975. if (err < 0)
  976. return err;
  977. }
  978. if (spec->multiout.dig_out_nid) {
  979. err = snd_hda_create_spdif_out_ctls(codec,
  980. spec->multiout.dig_out_nid);
  981. if (err < 0)
  982. return err;
  983. }
  984. if (spec->dig_in_nid) {
  985. err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
  986. if (err < 0)
  987. return err;
  988. }
  989. return 0;
  990. }
  991. /*
  992. * initialize the codec volumes, etc
  993. */
  994. /*
  995. * generic initialization of ADC, input mixers and output mixers
  996. */
  997. static struct hda_verb alc880_volume_init_verbs[] = {
  998. /*
  999. * Unmute ADC0-2 and set the default input to mic-in
  1000. */
  1001. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  1002. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1003. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  1004. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1005. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  1006. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1007. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  1008. * mixer widget
  1009. * Note: PASD motherboards uses the Line In 2 as the input for front
  1010. * panel mic (mic 2)
  1011. */
  1012. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  1013. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1014. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1015. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  1016. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  1017. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  1018. /*
  1019. * Set up output mixers (0x0c - 0x0f)
  1020. */
  1021. /* set vol=0 to output mixers */
  1022. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1023. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1024. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1025. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1026. /* set up input amps for analog loopback */
  1027. /* Amp Indices: DAC = 0, mixer = 1 */
  1028. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1029. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1030. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1031. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1032. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1033. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1034. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1035. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1036. { }
  1037. };
  1038. /*
  1039. * 3-stack pin configuration:
  1040. * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
  1041. */
  1042. static struct hda_verb alc880_pin_3stack_init_verbs[] = {
  1043. /*
  1044. * preset connection lists of input pins
  1045. * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
  1046. */
  1047. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  1048. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1049. {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
  1050. /*
  1051. * Set pin mode and muting
  1052. */
  1053. /* set front pin widgets 0x14 for output */
  1054. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1055. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1056. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1057. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1058. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1059. /* Mic2 (as headphone out) for HP output */
  1060. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1061. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1062. /* Line In pin widget for input */
  1063. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1064. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1065. /* Line2 (as front mic) pin widget for input and vref at 80% */
  1066. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1067. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1068. /* CD pin widget for input */
  1069. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1070. { }
  1071. };
  1072. /*
  1073. * 5-stack pin configuration:
  1074. * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
  1075. * line-in/side = 0x1a, f-mic = 0x1b
  1076. */
  1077. static struct hda_verb alc880_pin_5stack_init_verbs[] = {
  1078. /*
  1079. * preset connection lists of input pins
  1080. * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
  1081. */
  1082. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1083. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
  1084. /*
  1085. * Set pin mode and muting
  1086. */
  1087. /* set pin widgets 0x14-0x17 for output */
  1088. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1089. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1090. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1091. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1092. /* unmute pins for output (no gain on this amp) */
  1093. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1094. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1095. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1096. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1097. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1098. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1099. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1100. /* Mic2 (as headphone out) for HP output */
  1101. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1102. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1103. /* Line In pin widget for input */
  1104. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1105. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1106. /* Line2 (as front mic) pin widget for input and vref at 80% */
  1107. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1108. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1109. /* CD pin widget for input */
  1110. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1111. { }
  1112. };
  1113. /*
  1114. * W810 pin configuration:
  1115. * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
  1116. */
  1117. static struct hda_verb alc880_pin_w810_init_verbs[] = {
  1118. /* hphone/speaker input selector: front DAC */
  1119. {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
  1120. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1121. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1122. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1123. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1124. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1125. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1126. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1127. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1128. { }
  1129. };
  1130. /*
  1131. * Z71V pin configuration:
  1132. * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
  1133. */
  1134. static struct hda_verb alc880_pin_z71v_init_verbs[] = {
  1135. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1136. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1137. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1138. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1139. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1140. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1141. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1142. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1143. { }
  1144. };
  1145. /*
  1146. * 6-stack pin configuration:
  1147. * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
  1148. * f-mic = 0x19, line = 0x1a, HP = 0x1b
  1149. */
  1150. static struct hda_verb alc880_pin_6stack_init_verbs[] = {
  1151. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1152. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1153. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1154. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1155. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1156. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1157. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1158. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1159. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1160. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1161. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1162. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1163. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1164. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1165. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1166. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1167. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1168. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1169. { }
  1170. };
  1171. /*
  1172. * Uniwill pin configuration:
  1173. * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
  1174. * line = 0x1a
  1175. */
  1176. static struct hda_verb alc880_uniwill_init_verbs[] = {
  1177. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1178. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1179. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1180. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1181. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1182. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1183. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1184. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1185. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1186. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1187. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1188. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1189. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1190. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1191. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1192. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1193. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1194. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1195. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1196. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1197. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1198. /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
  1199. /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
  1200. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1201. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  1202. {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
  1203. { }
  1204. };
  1205. /*
  1206. * Uniwill P53
  1207. * HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
  1208. */
  1209. static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
  1210. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1211. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1212. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1213. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1214. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1215. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1216. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1217. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1218. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1219. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1220. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1221. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1222. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1223. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1224. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1225. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1226. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1227. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1228. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1229. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  1230. {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
  1231. { }
  1232. };
  1233. /* toggle speaker-output according to the hp-jack state */
  1234. static void alc880_uniwill_automute(struct hda_codec *codec)
  1235. {
  1236. unsigned int present;
  1237. present = snd_hda_codec_read(codec, 0x14, 0,
  1238. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1239. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  1240. 0x80, present ? 0x80 : 0);
  1241. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  1242. 0x80, present ? 0x80 : 0);
  1243. snd_hda_codec_amp_update(codec, 0x16, 0, HDA_OUTPUT, 0,
  1244. 0x80, present ? 0x80 : 0);
  1245. snd_hda_codec_amp_update(codec, 0x16, 1, HDA_OUTPUT, 0,
  1246. 0x80, present ? 0x80 : 0);
  1247. present = snd_hda_codec_read(codec, 0x18, 0,
  1248. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1249. snd_hda_codec_write(codec, 0x0b, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  1250. 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
  1251. }
  1252. static void alc880_uniwill_unsol_event(struct hda_codec *codec,
  1253. unsigned int res)
  1254. {
  1255. /* Looks like the unsol event is incompatible with the standard
  1256. * definition. 4bit tag is placed at 28 bit!
  1257. */
  1258. if ((res >> 28) == ALC880_HP_EVENT ||
  1259. (res >> 28) == ALC880_MIC_EVENT)
  1260. alc880_uniwill_automute(codec);
  1261. }
  1262. static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
  1263. {
  1264. unsigned int present;
  1265. present = snd_hda_codec_read(codec, 0x14, 0,
  1266. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1267. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_INPUT, 0,
  1268. 0x80, present ? 0x80 : 0);
  1269. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_INPUT, 0,
  1270. 0x80, present ? 0x80 : 0);
  1271. }
  1272. static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
  1273. {
  1274. unsigned int present;
  1275. present = snd_hda_codec_read(codec, 0x21, 0,
  1276. AC_VERB_GET_VOLUME_KNOB_CONTROL, 0) & 0x7f;
  1277. snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
  1278. 0x7f, present);
  1279. snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
  1280. 0x7f, present);
  1281. snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
  1282. 0x7f, present);
  1283. snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
  1284. 0x7f, present);
  1285. }
  1286. static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
  1287. unsigned int res)
  1288. {
  1289. /* Looks like the unsol event is incompatible with the standard
  1290. * definition. 4bit tag is placed at 28 bit!
  1291. */
  1292. if ((res >> 28) == ALC880_HP_EVENT)
  1293. alc880_uniwill_p53_hp_automute(codec);
  1294. if ((res >> 28) == ALC880_DCVOL_EVENT)
  1295. alc880_uniwill_p53_dcvol_automute(codec);
  1296. }
  1297. /* FIXME! */
  1298. /*
  1299. * F1734 pin configuration:
  1300. * HP = 0x14, speaker-out = 0x15, mic = 0x18
  1301. */
  1302. static struct hda_verb alc880_pin_f1734_init_verbs[] = {
  1303. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
  1304. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
  1305. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
  1306. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  1307. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1308. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1309. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1310. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1311. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1312. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1313. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1314. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1315. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1316. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1317. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1318. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1319. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1320. { }
  1321. };
  1322. /* FIXME! */
  1323. /*
  1324. * ASUS pin configuration:
  1325. * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
  1326. */
  1327. static struct hda_verb alc880_pin_asus_init_verbs[] = {
  1328. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
  1329. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
  1330. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
  1331. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  1332. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1333. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1334. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1335. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1336. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1337. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1338. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1339. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1340. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1341. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1342. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1343. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1344. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1345. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1346. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1347. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1348. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1349. { }
  1350. };
  1351. /* Enable GPIO mask and set output */
  1352. static struct hda_verb alc880_gpio1_init_verbs[] = {
  1353. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  1354. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  1355. {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
  1356. { }
  1357. };
  1358. /* Enable GPIO mask and set output */
  1359. static struct hda_verb alc880_gpio2_init_verbs[] = {
  1360. {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
  1361. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
  1362. {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
  1363. { }
  1364. };
  1365. /* Clevo m520g init */
  1366. static struct hda_verb alc880_pin_clevo_init_verbs[] = {
  1367. /* headphone output */
  1368. {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
  1369. /* line-out */
  1370. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1371. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1372. /* Line-in */
  1373. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1374. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1375. /* CD */
  1376. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1377. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1378. /* Mic1 (rear panel) */
  1379. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1380. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1381. /* Mic2 (front panel) */
  1382. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1383. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1384. /* headphone */
  1385. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1386. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1387. /* change to EAPD mode */
  1388. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1389. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  1390. { }
  1391. };
  1392. static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
  1393. /* change to EAPD mode */
  1394. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1395. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  1396. /* Headphone output */
  1397. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1398. /* Front output*/
  1399. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1400. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  1401. /* Line In pin widget for input */
  1402. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1403. /* CD pin widget for input */
  1404. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1405. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1406. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1407. /* change to EAPD mode */
  1408. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1409. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  1410. { }
  1411. };
  1412. /*
  1413. * LG m1 express dual
  1414. *
  1415. * Pin assignment:
  1416. * Rear Line-In/Out (blue): 0x14
  1417. * Build-in Mic-In: 0x15
  1418. * Speaker-out: 0x17
  1419. * HP-Out (green): 0x1b
  1420. * Mic-In/Out (red): 0x19
  1421. * SPDIF-Out: 0x1e
  1422. */
  1423. /* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
  1424. static hda_nid_t alc880_lg_dac_nids[3] = {
  1425. 0x05, 0x02, 0x03
  1426. };
  1427. /* seems analog CD is not working */
  1428. static struct hda_input_mux alc880_lg_capture_source = {
  1429. .num_items = 3,
  1430. .items = {
  1431. { "Mic", 0x1 },
  1432. { "Line", 0x5 },
  1433. { "Internal Mic", 0x6 },
  1434. },
  1435. };
  1436. /* 2,4,6 channel modes */
  1437. static struct hda_verb alc880_lg_ch2_init[] = {
  1438. /* set line-in and mic-in to input */
  1439. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  1440. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  1441. { }
  1442. };
  1443. static struct hda_verb alc880_lg_ch4_init[] = {
  1444. /* set line-in to out and mic-in to input */
  1445. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1446. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  1447. { }
  1448. };
  1449. static struct hda_verb alc880_lg_ch6_init[] = {
  1450. /* set line-in and mic-in to output */
  1451. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1452. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1453. { }
  1454. };
  1455. static struct hda_channel_mode alc880_lg_ch_modes[3] = {
  1456. { 2, alc880_lg_ch2_init },
  1457. { 4, alc880_lg_ch4_init },
  1458. { 6, alc880_lg_ch6_init },
  1459. };
  1460. static struct snd_kcontrol_new alc880_lg_mixer[] = {
  1461. /* FIXME: it's not really "master" but front channels */
  1462. HDA_CODEC_VOLUME("Master Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  1463. HDA_BIND_MUTE("Master Playback Switch", 0x0f, 2, HDA_INPUT),
  1464. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1465. HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
  1466. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
  1467. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
  1468. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
  1469. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
  1470. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1471. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1472. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
  1473. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
  1474. HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
  1475. HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
  1476. {
  1477. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1478. .name = "Channel Mode",
  1479. .info = alc_ch_mode_info,
  1480. .get = alc_ch_mode_get,
  1481. .put = alc_ch_mode_put,
  1482. },
  1483. { } /* end */
  1484. };
  1485. static struct hda_verb alc880_lg_init_verbs[] = {
  1486. /* set capture source to mic-in */
  1487. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1488. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1489. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1490. /* mute all amp mixer inputs */
  1491. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
  1492. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
  1493. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
  1494. /* line-in to input */
  1495. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1496. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1497. /* built-in mic */
  1498. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1499. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1500. /* speaker-out */
  1501. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1502. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1503. /* mic-in to input */
  1504. {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
  1505. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1506. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1507. /* HP-out */
  1508. {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
  1509. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1510. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1511. /* jack sense */
  1512. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
  1513. { }
  1514. };
  1515. /* toggle speaker-output according to the hp-jack state */
  1516. static void alc880_lg_automute(struct hda_codec *codec)
  1517. {
  1518. unsigned int present;
  1519. present = snd_hda_codec_read(codec, 0x1b, 0,
  1520. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1521. snd_hda_codec_amp_update(codec, 0x17, 0, HDA_OUTPUT, 0,
  1522. 0x80, present ? 0x80 : 0);
  1523. snd_hda_codec_amp_update(codec, 0x17, 1, HDA_OUTPUT, 0,
  1524. 0x80, present ? 0x80 : 0);
  1525. }
  1526. static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
  1527. {
  1528. /* Looks like the unsol event is incompatible with the standard
  1529. * definition. 4bit tag is placed at 28 bit!
  1530. */
  1531. if ((res >> 28) == 0x01)
  1532. alc880_lg_automute(codec);
  1533. }
  1534. /*
  1535. * LG LW20
  1536. *
  1537. * Pin assignment:
  1538. * Speaker-out: 0x14
  1539. * Mic-In: 0x18
  1540. * Built-in Mic-In: 0x19 (?)
  1541. * HP-Out: 0x1b
  1542. * SPDIF-Out: 0x1e
  1543. */
  1544. /* seems analog CD is not working */
  1545. static struct hda_input_mux alc880_lg_lw_capture_source = {
  1546. .num_items = 2,
  1547. .items = {
  1548. { "Mic", 0x0 },
  1549. { "Internal Mic", 0x1 },
  1550. },
  1551. };
  1552. static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
  1553. HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1554. HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
  1555. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1556. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1557. HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  1558. HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  1559. { } /* end */
  1560. };
  1561. static struct hda_verb alc880_lg_lw_init_verbs[] = {
  1562. /* set capture source to mic-in */
  1563. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1564. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1565. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1566. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
  1567. /* speaker-out */
  1568. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1569. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1570. /* HP-out */
  1571. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  1572. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1573. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1574. /* mic-in to input */
  1575. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1576. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1577. /* built-in mic */
  1578. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1579. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1580. /* jack sense */
  1581. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
  1582. { }
  1583. };
  1584. /* toggle speaker-output according to the hp-jack state */
  1585. static void alc880_lg_lw_automute(struct hda_codec *codec)
  1586. {
  1587. unsigned int present;
  1588. present = snd_hda_codec_read(codec, 0x1b, 0,
  1589. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1590. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  1591. 0x80, present ? 0x80 : 0);
  1592. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  1593. 0x80, present ? 0x80 : 0);
  1594. }
  1595. static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
  1596. {
  1597. /* Looks like the unsol event is incompatible with the standard
  1598. * definition. 4bit tag is placed at 28 bit!
  1599. */
  1600. if ((res >> 28) == 0x01)
  1601. alc880_lg_lw_automute(codec);
  1602. }
  1603. /*
  1604. * Common callbacks
  1605. */
  1606. static int alc_init(struct hda_codec *codec)
  1607. {
  1608. struct alc_spec *spec = codec->spec;
  1609. unsigned int i;
  1610. for (i = 0; i < spec->num_init_verbs; i++)
  1611. snd_hda_sequence_write(codec, spec->init_verbs[i]);
  1612. if (spec->init_hook)
  1613. spec->init_hook(codec);
  1614. return 0;
  1615. }
  1616. static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
  1617. {
  1618. struct alc_spec *spec = codec->spec;
  1619. if (spec->unsol_event)
  1620. spec->unsol_event(codec, res);
  1621. }
  1622. #ifdef CONFIG_PM
  1623. /*
  1624. * resume
  1625. */
  1626. static int alc_resume(struct hda_codec *codec)
  1627. {
  1628. struct alc_spec *spec = codec->spec;
  1629. int i;
  1630. alc_init(codec);
  1631. for (i = 0; i < spec->num_mixers; i++)
  1632. snd_hda_resume_ctls(codec, spec->mixers[i]);
  1633. if (spec->multiout.dig_out_nid)
  1634. snd_hda_resume_spdif_out(codec);
  1635. if (spec->dig_in_nid)
  1636. snd_hda_resume_spdif_in(codec);
  1637. return 0;
  1638. }
  1639. #endif
  1640. /*
  1641. * Analog playback callbacks
  1642. */
  1643. static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
  1644. struct hda_codec *codec,
  1645. struct snd_pcm_substream *substream)
  1646. {
  1647. struct alc_spec *spec = codec->spec;
  1648. return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
  1649. }
  1650. static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  1651. struct hda_codec *codec,
  1652. unsigned int stream_tag,
  1653. unsigned int format,
  1654. struct snd_pcm_substream *substream)
  1655. {
  1656. struct alc_spec *spec = codec->spec;
  1657. return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
  1658. stream_tag, format, substream);
  1659. }
  1660. static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
  1661. struct hda_codec *codec,
  1662. struct snd_pcm_substream *substream)
  1663. {
  1664. struct alc_spec *spec = codec->spec;
  1665. return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
  1666. }
  1667. /*
  1668. * Digital out
  1669. */
  1670. static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
  1671. struct hda_codec *codec,
  1672. struct snd_pcm_substream *substream)
  1673. {
  1674. struct alc_spec *spec = codec->spec;
  1675. return snd_hda_multi_out_dig_open(codec, &spec->multiout);
  1676. }
  1677. static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
  1678. struct hda_codec *codec,
  1679. struct snd_pcm_substream *substream)
  1680. {
  1681. struct alc_spec *spec = codec->spec;
  1682. return snd_hda_multi_out_dig_close(codec, &spec->multiout);
  1683. }
  1684. /*
  1685. * Analog capture
  1686. */
  1687. static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
  1688. struct hda_codec *codec,
  1689. unsigned int stream_tag,
  1690. unsigned int format,
  1691. struct snd_pcm_substream *substream)
  1692. {
  1693. struct alc_spec *spec = codec->spec;
  1694. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
  1695. stream_tag, 0, format);
  1696. return 0;
  1697. }
  1698. static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
  1699. struct hda_codec *codec,
  1700. struct snd_pcm_substream *substream)
  1701. {
  1702. struct alc_spec *spec = codec->spec;
  1703. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
  1704. 0, 0, 0);
  1705. return 0;
  1706. }
  1707. /*
  1708. */
  1709. static struct hda_pcm_stream alc880_pcm_analog_playback = {
  1710. .substreams = 1,
  1711. .channels_min = 2,
  1712. .channels_max = 8,
  1713. /* NID is set in alc_build_pcms */
  1714. .ops = {
  1715. .open = alc880_playback_pcm_open,
  1716. .prepare = alc880_playback_pcm_prepare,
  1717. .cleanup = alc880_playback_pcm_cleanup
  1718. },
  1719. };
  1720. static struct hda_pcm_stream alc880_pcm_analog_capture = {
  1721. .substreams = 2,
  1722. .channels_min = 2,
  1723. .channels_max = 2,
  1724. /* NID is set in alc_build_pcms */
  1725. .ops = {
  1726. .prepare = alc880_capture_pcm_prepare,
  1727. .cleanup = alc880_capture_pcm_cleanup
  1728. },
  1729. };
  1730. static struct hda_pcm_stream alc880_pcm_digital_playback = {
  1731. .substreams = 1,
  1732. .channels_min = 2,
  1733. .channels_max = 2,
  1734. /* NID is set in alc_build_pcms */
  1735. .ops = {
  1736. .open = alc880_dig_playback_pcm_open,
  1737. .close = alc880_dig_playback_pcm_close
  1738. },
  1739. };
  1740. static struct hda_pcm_stream alc880_pcm_digital_capture = {
  1741. .substreams = 1,
  1742. .channels_min = 2,
  1743. .channels_max = 2,
  1744. /* NID is set in alc_build_pcms */
  1745. };
  1746. /* Used by alc_build_pcms to flag that a PCM has no playback stream */
  1747. static struct hda_pcm_stream alc_pcm_null_playback = {
  1748. .substreams = 0,
  1749. .channels_min = 0,
  1750. .channels_max = 0,
  1751. };
  1752. static int alc_build_pcms(struct hda_codec *codec)
  1753. {
  1754. struct alc_spec *spec = codec->spec;
  1755. struct hda_pcm *info = spec->pcm_rec;
  1756. int i;
  1757. codec->num_pcms = 1;
  1758. codec->pcm_info = info;
  1759. info->name = spec->stream_name_analog;
  1760. if (spec->stream_analog_playback) {
  1761. snd_assert(spec->multiout.dac_nids, return -EINVAL);
  1762. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
  1763. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
  1764. }
  1765. if (spec->stream_analog_capture) {
  1766. snd_assert(spec->adc_nids, return -EINVAL);
  1767. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
  1768. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
  1769. }
  1770. if (spec->channel_mode) {
  1771. info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
  1772. for (i = 0; i < spec->num_channel_mode; i++) {
  1773. if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
  1774. info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
  1775. }
  1776. }
  1777. }
  1778. /* SPDIF for stream index #1 */
  1779. if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
  1780. codec->num_pcms = 2;
  1781. info = spec->pcm_rec + 1;
  1782. info->name = spec->stream_name_digital;
  1783. if (spec->multiout.dig_out_nid &&
  1784. spec->stream_digital_playback) {
  1785. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
  1786. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
  1787. }
  1788. if (spec->dig_in_nid &&
  1789. spec->stream_digital_capture) {
  1790. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
  1791. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
  1792. }
  1793. }
  1794. /* If the use of more than one ADC is requested for the current
  1795. * model, configure a second analog capture-only PCM.
  1796. */
  1797. /* Additional Analaog capture for index #2 */
  1798. if (spec->num_adc_nids > 1 && spec->stream_analog_capture &&
  1799. spec->adc_nids) {
  1800. codec->num_pcms = 3;
  1801. info = spec->pcm_rec + 2;
  1802. info->name = spec->stream_name_analog;
  1803. /* No playback stream for second PCM */
  1804. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback;
  1805. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
  1806. if (spec->stream_analog_capture) {
  1807. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
  1808. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1];
  1809. }
  1810. }
  1811. return 0;
  1812. }
  1813. static void alc_free(struct hda_codec *codec)
  1814. {
  1815. struct alc_spec *spec = codec->spec;
  1816. unsigned int i;
  1817. if (! spec)
  1818. return;
  1819. if (spec->kctl_alloc) {
  1820. for (i = 0; i < spec->num_kctl_used; i++)
  1821. kfree(spec->kctl_alloc[i].name);
  1822. kfree(spec->kctl_alloc);
  1823. }
  1824. kfree(spec);
  1825. }
  1826. /*
  1827. */
  1828. static struct hda_codec_ops alc_patch_ops = {
  1829. .build_controls = alc_build_controls,
  1830. .build_pcms = alc_build_pcms,
  1831. .init = alc_init,
  1832. .free = alc_free,
  1833. .unsol_event = alc_unsol_event,
  1834. #ifdef CONFIG_PM
  1835. .resume = alc_resume,
  1836. #endif
  1837. };
  1838. /*
  1839. * Test configuration for debugging
  1840. *
  1841. * Almost all inputs/outputs are enabled. I/O pins can be configured via
  1842. * enum controls.
  1843. */
  1844. #ifdef CONFIG_SND_DEBUG
  1845. static hda_nid_t alc880_test_dac_nids[4] = {
  1846. 0x02, 0x03, 0x04, 0x05
  1847. };
  1848. static struct hda_input_mux alc880_test_capture_source = {
  1849. .num_items = 7,
  1850. .items = {
  1851. { "In-1", 0x0 },
  1852. { "In-2", 0x1 },
  1853. { "In-3", 0x2 },
  1854. { "In-4", 0x3 },
  1855. { "CD", 0x4 },
  1856. { "Front", 0x5 },
  1857. { "Surround", 0x6 },
  1858. },
  1859. };
  1860. static struct hda_channel_mode alc880_test_modes[4] = {
  1861. { 2, NULL },
  1862. { 4, NULL },
  1863. { 6, NULL },
  1864. { 8, NULL },
  1865. };
  1866. static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
  1867. struct snd_ctl_elem_info *uinfo)
  1868. {
  1869. static char *texts[] = {
  1870. "N/A", "Line Out", "HP Out",
  1871. "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
  1872. };
  1873. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  1874. uinfo->count = 1;
  1875. uinfo->value.enumerated.items = 8;
  1876. if (uinfo->value.enumerated.item >= 8)
  1877. uinfo->value.enumerated.item = 7;
  1878. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  1879. return 0;
  1880. }
  1881. static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
  1882. struct snd_ctl_elem_value *ucontrol)
  1883. {
  1884. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  1885. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  1886. unsigned int pin_ctl, item = 0;
  1887. pin_ctl = snd_hda_codec_read(codec, nid, 0,
  1888. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  1889. if (pin_ctl & AC_PINCTL_OUT_EN) {
  1890. if (pin_ctl & AC_PINCTL_HP_EN)
  1891. item = 2;
  1892. else
  1893. item = 1;
  1894. } else if (pin_ctl & AC_PINCTL_IN_EN) {
  1895. switch (pin_ctl & AC_PINCTL_VREFEN) {
  1896. case AC_PINCTL_VREF_HIZ: item = 3; break;
  1897. case AC_PINCTL_VREF_50: item = 4; break;
  1898. case AC_PINCTL_VREF_GRD: item = 5; break;
  1899. case AC_PINCTL_VREF_80: item = 6; break;
  1900. case AC_PINCTL_VREF_100: item = 7; break;
  1901. }
  1902. }
  1903. ucontrol->value.enumerated.item[0] = item;
  1904. return 0;
  1905. }
  1906. static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
  1907. struct snd_ctl_elem_value *ucontrol)
  1908. {
  1909. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  1910. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  1911. static unsigned int ctls[] = {
  1912. 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
  1913. AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
  1914. AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
  1915. AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
  1916. AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
  1917. AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
  1918. };
  1919. unsigned int old_ctl, new_ctl;
  1920. old_ctl = snd_hda_codec_read(codec, nid, 0,
  1921. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  1922. new_ctl = ctls[ucontrol->value.enumerated.item[0]];
  1923. if (old_ctl != new_ctl) {
  1924. snd_hda_codec_write(codec, nid, 0,
  1925. AC_VERB_SET_PIN_WIDGET_CONTROL, new_ctl);
  1926. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  1927. (ucontrol->value.enumerated.item[0] >= 3 ?
  1928. 0xb080 : 0xb000));
  1929. return 1;
  1930. }
  1931. return 0;
  1932. }
  1933. static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
  1934. struct snd_ctl_elem_info *uinfo)
  1935. {
  1936. static char *texts[] = {
  1937. "Front", "Surround", "CLFE", "Side"
  1938. };
  1939. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  1940. uinfo->count = 1;
  1941. uinfo->value.enumerated.items = 4;
  1942. if (uinfo->value.enumerated.item >= 4)
  1943. uinfo->value.enumerated.item = 3;
  1944. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  1945. return 0;
  1946. }
  1947. static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
  1948. struct snd_ctl_elem_value *ucontrol)
  1949. {
  1950. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  1951. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  1952. unsigned int sel;
  1953. sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
  1954. ucontrol->value.enumerated.item[0] = sel & 3;
  1955. return 0;
  1956. }
  1957. static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
  1958. struct snd_ctl_elem_value *ucontrol)
  1959. {
  1960. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  1961. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  1962. unsigned int sel;
  1963. sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
  1964. if (ucontrol->value.enumerated.item[0] != sel) {
  1965. sel = ucontrol->value.enumerated.item[0] & 3;
  1966. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, sel);
  1967. return 1;
  1968. }
  1969. return 0;
  1970. }
  1971. #define PIN_CTL_TEST(xname,nid) { \
  1972. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  1973. .name = xname, \
  1974. .info = alc_test_pin_ctl_info, \
  1975. .get = alc_test_pin_ctl_get, \
  1976. .put = alc_test_pin_ctl_put, \
  1977. .private_value = nid \
  1978. }
  1979. #define PIN_SRC_TEST(xname,nid) { \
  1980. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  1981. .name = xname, \
  1982. .info = alc_test_pin_src_info, \
  1983. .get = alc_test_pin_src_get, \
  1984. .put = alc_test_pin_src_put, \
  1985. .private_value = nid \
  1986. }
  1987. static struct snd_kcontrol_new alc880_test_mixer[] = {
  1988. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1989. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1990. HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
  1991. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  1992. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  1993. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  1994. HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
  1995. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  1996. PIN_CTL_TEST("Front Pin Mode", 0x14),
  1997. PIN_CTL_TEST("Surround Pin Mode", 0x15),
  1998. PIN_CTL_TEST("CLFE Pin Mode", 0x16),
  1999. PIN_CTL_TEST("Side Pin Mode", 0x17),
  2000. PIN_CTL_TEST("In-1 Pin Mode", 0x18),
  2001. PIN_CTL_TEST("In-2 Pin Mode", 0x19),
  2002. PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
  2003. PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
  2004. PIN_SRC_TEST("In-1 Pin Source", 0x18),
  2005. PIN_SRC_TEST("In-2 Pin Source", 0x19),
  2006. PIN_SRC_TEST("In-3 Pin Source", 0x1a),
  2007. PIN_SRC_TEST("In-4 Pin Source", 0x1b),
  2008. HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
  2009. HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
  2010. HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
  2011. HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
  2012. HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
  2013. HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
  2014. HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
  2015. HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
  2016. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
  2017. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
  2018. {
  2019. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  2020. .name = "Channel Mode",
  2021. .info = alc_ch_mode_info,
  2022. .get = alc_ch_mode_get,
  2023. .put = alc_ch_mode_put,
  2024. },
  2025. { } /* end */
  2026. };
  2027. static struct hda_verb alc880_test_init_verbs[] = {
  2028. /* Unmute inputs of 0x0c - 0x0f */
  2029. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2030. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2031. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2032. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2033. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2034. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2035. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2036. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2037. /* Vol output for 0x0c-0x0f */
  2038. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2039. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2040. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2041. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2042. /* Set output pins 0x14-0x17 */
  2043. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2044. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2045. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2046. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2047. /* Unmute output pins 0x14-0x17 */
  2048. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2049. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2050. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2051. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2052. /* Set input pins 0x18-0x1c */
  2053. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2054. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2055. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2056. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2057. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2058. /* Mute input pins 0x18-0x1b */
  2059. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2060. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2061. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2062. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2063. /* ADC set up */
  2064. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2065. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  2066. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2067. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  2068. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2069. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  2070. /* Analog input/passthru */
  2071. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2072. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2073. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  2074. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  2075. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  2076. { }
  2077. };
  2078. #endif
  2079. /*
  2080. */
  2081. static const char *alc880_models[ALC880_MODEL_LAST] = {
  2082. [ALC880_3ST] = "3stack",
  2083. [ALC880_TCL_S700] = "tcl",
  2084. [ALC880_3ST_DIG] = "3stack-digout",
  2085. [ALC880_CLEVO] = "clevo",
  2086. [ALC880_5ST] = "5stack",
  2087. [ALC880_5ST_DIG] = "5stack-digout",
  2088. [ALC880_W810] = "w810",
  2089. [ALC880_Z71V] = "z71v",
  2090. [ALC880_6ST] = "6stack",
  2091. [ALC880_6ST_DIG] = "6stack-digout",
  2092. [ALC880_ASUS] = "asus",
  2093. [ALC880_ASUS_W1V] = "asus-w1v",
  2094. [ALC880_ASUS_DIG] = "asus-dig",
  2095. [ALC880_ASUS_DIG2] = "asus-dig2",
  2096. [ALC880_UNIWILL_DIG] = "uniwill",
  2097. [ALC880_F1734] = "F1734",
  2098. [ALC880_LG] = "lg",
  2099. [ALC880_LG_LW] = "lg-lw",
  2100. #ifdef CONFIG_SND_DEBUG
  2101. [ALC880_TEST] = "test",
  2102. #endif
  2103. [ALC880_AUTO] = "auto",
  2104. };
  2105. static struct snd_pci_quirk alc880_cfg_tbl[] = {
  2106. /* Broken BIOS configuration */
  2107. SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG),
  2108. SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
  2109. SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
  2110. SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
  2111. SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
  2112. SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
  2113. SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
  2114. SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
  2115. SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
  2116. SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
  2117. SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
  2118. SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
  2119. SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
  2120. SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
  2121. SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
  2122. SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
  2123. SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
  2124. SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
  2125. SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
  2126. SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
  2127. /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
  2128. SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
  2129. SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
  2130. SND_PCI_QUIRK(0x1043, 0x814e, "ASUS", ALC880_5ST),
  2131. SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
  2132. SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
  2133. SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
  2134. SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS),
  2135. SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
  2136. SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
  2137. SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
  2138. SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
  2139. SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
  2140. SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
  2141. SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
  2142. SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
  2143. SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
  2144. SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
  2145. SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
  2146. SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
  2147. SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
  2148. SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
  2149. SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
  2150. SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
  2151. SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
  2152. SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
  2153. SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
  2154. SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
  2155. SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
  2156. SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
  2157. SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
  2158. SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
  2159. SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
  2160. SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
  2161. SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
  2162. SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
  2163. SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
  2164. SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
  2165. SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
  2166. SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
  2167. SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
  2168. SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
  2169. SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
  2170. SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
  2171. SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
  2172. SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
  2173. SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
  2174. SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST),
  2175. {}
  2176. };
  2177. /*
  2178. * ALC880 codec presets
  2179. */
  2180. static struct alc_config_preset alc880_presets[] = {
  2181. [ALC880_3ST] = {
  2182. .mixers = { alc880_three_stack_mixer },
  2183. .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
  2184. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2185. .dac_nids = alc880_dac_nids,
  2186. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2187. .channel_mode = alc880_threestack_modes,
  2188. .need_dac_fix = 1,
  2189. .input_mux = &alc880_capture_source,
  2190. },
  2191. [ALC880_3ST_DIG] = {
  2192. .mixers = { alc880_three_stack_mixer },
  2193. .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
  2194. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2195. .dac_nids = alc880_dac_nids,
  2196. .dig_out_nid = ALC880_DIGOUT_NID,
  2197. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2198. .channel_mode = alc880_threestack_modes,
  2199. .need_dac_fix = 1,
  2200. .input_mux = &alc880_capture_source,
  2201. },
  2202. [ALC880_TCL_S700] = {
  2203. .mixers = { alc880_tcl_s700_mixer },
  2204. .init_verbs = { alc880_volume_init_verbs,
  2205. alc880_pin_tcl_S700_init_verbs,
  2206. alc880_gpio2_init_verbs },
  2207. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2208. .dac_nids = alc880_dac_nids,
  2209. .hp_nid = 0x03,
  2210. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2211. .channel_mode = alc880_2_jack_modes,
  2212. .input_mux = &alc880_capture_source,
  2213. },
  2214. [ALC880_5ST] = {
  2215. .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer},
  2216. .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
  2217. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2218. .dac_nids = alc880_dac_nids,
  2219. .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
  2220. .channel_mode = alc880_fivestack_modes,
  2221. .input_mux = &alc880_capture_source,
  2222. },
  2223. [ALC880_5ST_DIG] = {
  2224. .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer },
  2225. .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
  2226. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2227. .dac_nids = alc880_dac_nids,
  2228. .dig_out_nid = ALC880_DIGOUT_NID,
  2229. .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
  2230. .channel_mode = alc880_fivestack_modes,
  2231. .input_mux = &alc880_capture_source,
  2232. },
  2233. [ALC880_6ST] = {
  2234. .mixers = { alc880_six_stack_mixer },
  2235. .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs },
  2236. .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
  2237. .dac_nids = alc880_6st_dac_nids,
  2238. .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
  2239. .channel_mode = alc880_sixstack_modes,
  2240. .input_mux = &alc880_6stack_capture_source,
  2241. },
  2242. [ALC880_6ST_DIG] = {
  2243. .mixers = { alc880_six_stack_mixer },
  2244. .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs },
  2245. .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
  2246. .dac_nids = alc880_6st_dac_nids,
  2247. .dig_out_nid = ALC880_DIGOUT_NID,
  2248. .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
  2249. .channel_mode = alc880_sixstack_modes,
  2250. .input_mux = &alc880_6stack_capture_source,
  2251. },
  2252. [ALC880_W810] = {
  2253. .mixers = { alc880_w810_base_mixer },
  2254. .init_verbs = { alc880_volume_init_verbs, alc880_pin_w810_init_verbs,
  2255. alc880_gpio2_init_verbs },
  2256. .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
  2257. .dac_nids = alc880_w810_dac_nids,
  2258. .dig_out_nid = ALC880_DIGOUT_NID,
  2259. .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
  2260. .channel_mode = alc880_w810_modes,
  2261. .input_mux = &alc880_capture_source,
  2262. },
  2263. [ALC880_Z71V] = {
  2264. .mixers = { alc880_z71v_mixer },
  2265. .init_verbs = { alc880_volume_init_verbs, alc880_pin_z71v_init_verbs },
  2266. .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
  2267. .dac_nids = alc880_z71v_dac_nids,
  2268. .dig_out_nid = ALC880_DIGOUT_NID,
  2269. .hp_nid = 0x03,
  2270. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2271. .channel_mode = alc880_2_jack_modes,
  2272. .input_mux = &alc880_capture_source,
  2273. },
  2274. [ALC880_F1734] = {
  2275. .mixers = { alc880_f1734_mixer },
  2276. .init_verbs = { alc880_volume_init_verbs, alc880_pin_f1734_init_verbs },
  2277. .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
  2278. .dac_nids = alc880_f1734_dac_nids,
  2279. .hp_nid = 0x02,
  2280. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2281. .channel_mode = alc880_2_jack_modes,
  2282. .input_mux = &alc880_capture_source,
  2283. },
  2284. [ALC880_ASUS] = {
  2285. .mixers = { alc880_asus_mixer },
  2286. .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
  2287. alc880_gpio1_init_verbs },
  2288. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2289. .dac_nids = alc880_asus_dac_nids,
  2290. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2291. .channel_mode = alc880_asus_modes,
  2292. .need_dac_fix = 1,
  2293. .input_mux = &alc880_capture_source,
  2294. },
  2295. [ALC880_ASUS_DIG] = {
  2296. .mixers = { alc880_asus_mixer },
  2297. .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
  2298. alc880_gpio1_init_verbs },
  2299. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2300. .dac_nids = alc880_asus_dac_nids,
  2301. .dig_out_nid = ALC880_DIGOUT_NID,
  2302. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2303. .channel_mode = alc880_asus_modes,
  2304. .need_dac_fix = 1,
  2305. .input_mux = &alc880_capture_source,
  2306. },
  2307. [ALC880_ASUS_DIG2] = {
  2308. .mixers = { alc880_asus_mixer },
  2309. .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
  2310. alc880_gpio2_init_verbs }, /* use GPIO2 */
  2311. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2312. .dac_nids = alc880_asus_dac_nids,
  2313. .dig_out_nid = ALC880_DIGOUT_NID,
  2314. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2315. .channel_mode = alc880_asus_modes,
  2316. .need_dac_fix = 1,
  2317. .input_mux = &alc880_capture_source,
  2318. },
  2319. [ALC880_ASUS_W1V] = {
  2320. .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
  2321. .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
  2322. alc880_gpio1_init_verbs },
  2323. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2324. .dac_nids = alc880_asus_dac_nids,
  2325. .dig_out_nid = ALC880_DIGOUT_NID,
  2326. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2327. .channel_mode = alc880_asus_modes,
  2328. .need_dac_fix = 1,
  2329. .input_mux = &alc880_capture_source,
  2330. },
  2331. [ALC880_UNIWILL_DIG] = {
  2332. .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
  2333. .init_verbs = { alc880_volume_init_verbs,
  2334. alc880_pin_asus_init_verbs },
  2335. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2336. .dac_nids = alc880_asus_dac_nids,
  2337. .dig_out_nid = ALC880_DIGOUT_NID,
  2338. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2339. .channel_mode = alc880_asus_modes,
  2340. .need_dac_fix = 1,
  2341. .input_mux = &alc880_capture_source,
  2342. },
  2343. [ALC880_UNIWILL] = {
  2344. .mixers = { alc880_uniwill_mixer },
  2345. .init_verbs = { alc880_volume_init_verbs,
  2346. alc880_uniwill_init_verbs },
  2347. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2348. .dac_nids = alc880_asus_dac_nids,
  2349. .dig_out_nid = ALC880_DIGOUT_NID,
  2350. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2351. .channel_mode = alc880_threestack_modes,
  2352. .need_dac_fix = 1,
  2353. .input_mux = &alc880_capture_source,
  2354. .unsol_event = alc880_uniwill_unsol_event,
  2355. .init_hook = alc880_uniwill_automute,
  2356. },
  2357. [ALC880_UNIWILL_P53] = {
  2358. .mixers = { alc880_uniwill_p53_mixer },
  2359. .init_verbs = { alc880_volume_init_verbs,
  2360. alc880_uniwill_p53_init_verbs },
  2361. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2362. .dac_nids = alc880_asus_dac_nids,
  2363. .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
  2364. .channel_mode = alc880_w810_modes,
  2365. .input_mux = &alc880_capture_source,
  2366. .unsol_event = alc880_uniwill_p53_unsol_event,
  2367. .init_hook = alc880_uniwill_p53_hp_automute,
  2368. },
  2369. [ALC880_CLEVO] = {
  2370. .mixers = { alc880_three_stack_mixer },
  2371. .init_verbs = { alc880_volume_init_verbs,
  2372. alc880_pin_clevo_init_verbs },
  2373. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2374. .dac_nids = alc880_dac_nids,
  2375. .hp_nid = 0x03,
  2376. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2377. .channel_mode = alc880_threestack_modes,
  2378. .need_dac_fix = 1,
  2379. .input_mux = &alc880_capture_source,
  2380. },
  2381. [ALC880_LG] = {
  2382. .mixers = { alc880_lg_mixer },
  2383. .init_verbs = { alc880_volume_init_verbs,
  2384. alc880_lg_init_verbs },
  2385. .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
  2386. .dac_nids = alc880_lg_dac_nids,
  2387. .dig_out_nid = ALC880_DIGOUT_NID,
  2388. .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
  2389. .channel_mode = alc880_lg_ch_modes,
  2390. .need_dac_fix = 1,
  2391. .input_mux = &alc880_lg_capture_source,
  2392. .unsol_event = alc880_lg_unsol_event,
  2393. .init_hook = alc880_lg_automute,
  2394. },
  2395. [ALC880_LG_LW] = {
  2396. .mixers = { alc880_lg_lw_mixer },
  2397. .init_verbs = { alc880_volume_init_verbs,
  2398. alc880_lg_lw_init_verbs },
  2399. .num_dacs = 1,
  2400. .dac_nids = alc880_dac_nids,
  2401. .dig_out_nid = ALC880_DIGOUT_NID,
  2402. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2403. .channel_mode = alc880_2_jack_modes,
  2404. .input_mux = &alc880_lg_lw_capture_source,
  2405. .unsol_event = alc880_lg_lw_unsol_event,
  2406. .init_hook = alc880_lg_lw_automute,
  2407. },
  2408. #ifdef CONFIG_SND_DEBUG
  2409. [ALC880_TEST] = {
  2410. .mixers = { alc880_test_mixer },
  2411. .init_verbs = { alc880_test_init_verbs },
  2412. .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
  2413. .dac_nids = alc880_test_dac_nids,
  2414. .dig_out_nid = ALC880_DIGOUT_NID,
  2415. .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
  2416. .channel_mode = alc880_test_modes,
  2417. .input_mux = &alc880_test_capture_source,
  2418. },
  2419. #endif
  2420. };
  2421. /*
  2422. * Automatic parse of I/O pins from the BIOS configuration
  2423. */
  2424. #define NUM_CONTROL_ALLOC 32
  2425. #define NUM_VERB_ALLOC 32
  2426. enum {
  2427. ALC_CTL_WIDGET_VOL,
  2428. ALC_CTL_WIDGET_MUTE,
  2429. ALC_CTL_BIND_MUTE,
  2430. };
  2431. static struct snd_kcontrol_new alc880_control_templates[] = {
  2432. HDA_CODEC_VOLUME(NULL, 0, 0, 0),
  2433. HDA_CODEC_MUTE(NULL, 0, 0, 0),
  2434. HDA_BIND_MUTE(NULL, 0, 0, 0),
  2435. };
  2436. /* add dynamic controls */
  2437. static int add_control(struct alc_spec *spec, int type, const char *name, unsigned long val)
  2438. {
  2439. struct snd_kcontrol_new *knew;
  2440. if (spec->num_kctl_used >= spec->num_kctl_alloc) {
  2441. int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
  2442. knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
  2443. if (! knew)
  2444. return -ENOMEM;
  2445. if (spec->kctl_alloc) {
  2446. memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
  2447. kfree(spec->kctl_alloc);
  2448. }
  2449. spec->kctl_alloc = knew;
  2450. spec->num_kctl_alloc = num;
  2451. }
  2452. knew = &spec->kctl_alloc[spec->num_kctl_used];
  2453. *knew = alc880_control_templates[type];
  2454. knew->name = kstrdup(name, GFP_KERNEL);
  2455. if (! knew->name)
  2456. return -ENOMEM;
  2457. knew->private_value = val;
  2458. spec->num_kctl_used++;
  2459. return 0;
  2460. }
  2461. #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
  2462. #define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
  2463. #define alc880_is_multi_pin(nid) ((nid) >= 0x18)
  2464. #define alc880_multi_pin_idx(nid) ((nid) - 0x18)
  2465. #define alc880_is_input_pin(nid) ((nid) >= 0x18)
  2466. #define alc880_input_pin_idx(nid) ((nid) - 0x18)
  2467. #define alc880_idx_to_dac(nid) ((nid) + 0x02)
  2468. #define alc880_dac_to_idx(nid) ((nid) - 0x02)
  2469. #define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
  2470. #define alc880_idx_to_selector(nid) ((nid) + 0x10)
  2471. #define ALC880_PIN_CD_NID 0x1c
  2472. /* fill in the dac_nids table from the parsed pin configuration */
  2473. static int alc880_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
  2474. {
  2475. hda_nid_t nid;
  2476. int assigned[4];
  2477. int i, j;
  2478. memset(assigned, 0, sizeof(assigned));
  2479. spec->multiout.dac_nids = spec->private_dac_nids;
  2480. /* check the pins hardwired to audio widget */
  2481. for (i = 0; i < cfg->line_outs; i++) {
  2482. nid = cfg->line_out_pins[i];
  2483. if (alc880_is_fixed_pin(nid)) {
  2484. int idx = alc880_fixed_pin_idx(nid);
  2485. spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
  2486. assigned[idx] = 1;
  2487. }
  2488. }
  2489. /* left pins can be connect to any audio widget */
  2490. for (i = 0; i < cfg->line_outs; i++) {
  2491. nid = cfg->line_out_pins[i];
  2492. if (alc880_is_fixed_pin(nid))
  2493. continue;
  2494. /* search for an empty channel */
  2495. for (j = 0; j < cfg->line_outs; j++) {
  2496. if (! assigned[j]) {
  2497. spec->multiout.dac_nids[i] = alc880_idx_to_dac(j);
  2498. assigned[j] = 1;
  2499. break;
  2500. }
  2501. }
  2502. }
  2503. spec->multiout.num_dacs = cfg->line_outs;
  2504. return 0;
  2505. }
  2506. /* add playback controls from the parsed DAC table */
  2507. static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
  2508. const struct auto_pin_cfg *cfg)
  2509. {
  2510. char name[32];
  2511. static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
  2512. hda_nid_t nid;
  2513. int i, err;
  2514. for (i = 0; i < cfg->line_outs; i++) {
  2515. if (! spec->multiout.dac_nids[i])
  2516. continue;
  2517. nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
  2518. if (i == 2) {
  2519. /* Center/LFE */
  2520. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Center Playback Volume",
  2521. HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
  2522. return err;
  2523. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "LFE Playback Volume",
  2524. HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
  2525. return err;
  2526. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch",
  2527. HDA_COMPOSE_AMP_VAL(nid, 1, 2, HDA_INPUT))) < 0)
  2528. return err;
  2529. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch",
  2530. HDA_COMPOSE_AMP_VAL(nid, 2, 2, HDA_INPUT))) < 0)
  2531. return err;
  2532. } else {
  2533. sprintf(name, "%s Playback Volume", chname[i]);
  2534. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2535. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  2536. return err;
  2537. sprintf(name, "%s Playback Switch", chname[i]);
  2538. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  2539. HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
  2540. return err;
  2541. }
  2542. }
  2543. return 0;
  2544. }
  2545. /* add playback controls for speaker and HP outputs */
  2546. static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
  2547. const char *pfx)
  2548. {
  2549. hda_nid_t nid;
  2550. int err;
  2551. char name[32];
  2552. if (! pin)
  2553. return 0;
  2554. if (alc880_is_fixed_pin(pin)) {
  2555. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  2556. /* specify the DAC as the extra output */
  2557. if (! spec->multiout.hp_nid)
  2558. spec->multiout.hp_nid = nid;
  2559. else
  2560. spec->multiout.extra_out_nid[0] = nid;
  2561. /* control HP volume/switch on the output mixer amp */
  2562. nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
  2563. sprintf(name, "%s Playback Volume", pfx);
  2564. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2565. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  2566. return err;
  2567. sprintf(name, "%s Playback Switch", pfx);
  2568. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  2569. HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
  2570. return err;
  2571. } else if (alc880_is_multi_pin(pin)) {
  2572. /* set manual connection */
  2573. /* we have only a switch on HP-out PIN */
  2574. sprintf(name, "%s Playback Switch", pfx);
  2575. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  2576. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT))) < 0)
  2577. return err;
  2578. }
  2579. return 0;
  2580. }
  2581. /* create input playback/capture controls for the given pin */
  2582. static int new_analog_input(struct alc_spec *spec, hda_nid_t pin, const char *ctlname,
  2583. int idx, hda_nid_t mix_nid)
  2584. {
  2585. char name[32];
  2586. int err;
  2587. sprintf(name, "%s Playback Volume", ctlname);
  2588. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2589. HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0)
  2590. return err;
  2591. sprintf(name, "%s Playback Switch", ctlname);
  2592. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  2593. HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0)
  2594. return err;
  2595. return 0;
  2596. }
  2597. /* create playback/capture controls for input pins */
  2598. static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
  2599. const struct auto_pin_cfg *cfg)
  2600. {
  2601. struct hda_input_mux *imux = &spec->private_imux;
  2602. int i, err, idx;
  2603. for (i = 0; i < AUTO_PIN_LAST; i++) {
  2604. if (alc880_is_input_pin(cfg->input_pins[i])) {
  2605. idx = alc880_input_pin_idx(cfg->input_pins[i]);
  2606. err = new_analog_input(spec, cfg->input_pins[i],
  2607. auto_pin_cfg_labels[i],
  2608. idx, 0x0b);
  2609. if (err < 0)
  2610. return err;
  2611. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  2612. imux->items[imux->num_items].index = alc880_input_pin_idx(cfg->input_pins[i]);
  2613. imux->num_items++;
  2614. }
  2615. }
  2616. return 0;
  2617. }
  2618. static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
  2619. hda_nid_t nid, int pin_type,
  2620. int dac_idx)
  2621. {
  2622. /* set as output */
  2623. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  2624. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  2625. /* need the manual connection? */
  2626. if (alc880_is_multi_pin(nid)) {
  2627. struct alc_spec *spec = codec->spec;
  2628. int idx = alc880_multi_pin_idx(nid);
  2629. snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
  2630. AC_VERB_SET_CONNECT_SEL,
  2631. alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
  2632. }
  2633. }
  2634. static void alc880_auto_init_multi_out(struct hda_codec *codec)
  2635. {
  2636. struct alc_spec *spec = codec->spec;
  2637. int i;
  2638. for (i = 0; i < spec->autocfg.line_outs; i++) {
  2639. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  2640. alc880_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
  2641. }
  2642. }
  2643. static void alc880_auto_init_extra_out(struct hda_codec *codec)
  2644. {
  2645. struct alc_spec *spec = codec->spec;
  2646. hda_nid_t pin;
  2647. pin = spec->autocfg.speaker_pins[0];
  2648. if (pin) /* connect to front */
  2649. alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
  2650. pin = spec->autocfg.hp_pins[0];
  2651. if (pin) /* connect to front */
  2652. alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  2653. }
  2654. static void alc880_auto_init_analog_input(struct hda_codec *codec)
  2655. {
  2656. struct alc_spec *spec = codec->spec;
  2657. int i;
  2658. for (i = 0; i < AUTO_PIN_LAST; i++) {
  2659. hda_nid_t nid = spec->autocfg.input_pins[i];
  2660. if (alc880_is_input_pin(nid)) {
  2661. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  2662. i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
  2663. if (nid != ALC880_PIN_CD_NID)
  2664. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  2665. AMP_OUT_MUTE);
  2666. }
  2667. }
  2668. }
  2669. /* parse the BIOS configuration and set up the alc_spec */
  2670. /* return 1 if successful, 0 if the proper config is not found, or a negative error code */
  2671. static int alc880_parse_auto_config(struct hda_codec *codec)
  2672. {
  2673. struct alc_spec *spec = codec->spec;
  2674. int err;
  2675. static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
  2676. if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  2677. alc880_ignore)) < 0)
  2678. return err;
  2679. if (! spec->autocfg.line_outs)
  2680. return 0; /* can't find valid BIOS pin config */
  2681. if ((err = alc880_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 ||
  2682. (err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
  2683. (err = alc880_auto_create_extra_out(spec,
  2684. spec->autocfg.speaker_pins[0],
  2685. "Speaker")) < 0 ||
  2686. (err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
  2687. "Headphone")) < 0 ||
  2688. (err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
  2689. return err;
  2690. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  2691. if (spec->autocfg.dig_out_pin)
  2692. spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
  2693. if (spec->autocfg.dig_in_pin)
  2694. spec->dig_in_nid = ALC880_DIGIN_NID;
  2695. if (spec->kctl_alloc)
  2696. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  2697. spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
  2698. spec->num_mux_defs = 1;
  2699. spec->input_mux = &spec->private_imux;
  2700. return 1;
  2701. }
  2702. /* additional initialization for auto-configuration model */
  2703. static void alc880_auto_init(struct hda_codec *codec)
  2704. {
  2705. alc880_auto_init_multi_out(codec);
  2706. alc880_auto_init_extra_out(codec);
  2707. alc880_auto_init_analog_input(codec);
  2708. }
  2709. /*
  2710. * OK, here we have finally the patch for ALC880
  2711. */
  2712. static int patch_alc880(struct hda_codec *codec)
  2713. {
  2714. struct alc_spec *spec;
  2715. int board_config;
  2716. int err;
  2717. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  2718. if (spec == NULL)
  2719. return -ENOMEM;
  2720. codec->spec = spec;
  2721. board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
  2722. alc880_models,
  2723. alc880_cfg_tbl);
  2724. if (board_config < 0) {
  2725. printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
  2726. "trying auto-probe from BIOS...\n");
  2727. board_config = ALC880_AUTO;
  2728. }
  2729. if (board_config == ALC880_AUTO) {
  2730. /* automatic parse from the BIOS config */
  2731. err = alc880_parse_auto_config(codec);
  2732. if (err < 0) {
  2733. alc_free(codec);
  2734. return err;
  2735. } else if (! err) {
  2736. printk(KERN_INFO
  2737. "hda_codec: Cannot set up configuration "
  2738. "from BIOS. Using 3-stack mode...\n");
  2739. board_config = ALC880_3ST;
  2740. }
  2741. }
  2742. if (board_config != ALC880_AUTO)
  2743. setup_preset(spec, &alc880_presets[board_config]);
  2744. spec->stream_name_analog = "ALC880 Analog";
  2745. spec->stream_analog_playback = &alc880_pcm_analog_playback;
  2746. spec->stream_analog_capture = &alc880_pcm_analog_capture;
  2747. spec->stream_name_digital = "ALC880 Digital";
  2748. spec->stream_digital_playback = &alc880_pcm_digital_playback;
  2749. spec->stream_digital_capture = &alc880_pcm_digital_capture;
  2750. if (! spec->adc_nids && spec->input_mux) {
  2751. /* check whether NID 0x07 is valid */
  2752. unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
  2753. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
  2754. if (wcap != AC_WID_AUD_IN) {
  2755. spec->adc_nids = alc880_adc_nids_alt;
  2756. spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
  2757. spec->mixers[spec->num_mixers] = alc880_capture_alt_mixer;
  2758. spec->num_mixers++;
  2759. } else {
  2760. spec->adc_nids = alc880_adc_nids;
  2761. spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
  2762. spec->mixers[spec->num_mixers] = alc880_capture_mixer;
  2763. spec->num_mixers++;
  2764. }
  2765. }
  2766. codec->patch_ops = alc_patch_ops;
  2767. if (board_config == ALC880_AUTO)
  2768. spec->init_hook = alc880_auto_init;
  2769. return 0;
  2770. }
  2771. /*
  2772. * ALC260 support
  2773. */
  2774. static hda_nid_t alc260_dac_nids[1] = {
  2775. /* front */
  2776. 0x02,
  2777. };
  2778. static hda_nid_t alc260_adc_nids[1] = {
  2779. /* ADC0 */
  2780. 0x04,
  2781. };
  2782. static hda_nid_t alc260_adc_nids_alt[1] = {
  2783. /* ADC1 */
  2784. 0x05,
  2785. };
  2786. static hda_nid_t alc260_hp_adc_nids[2] = {
  2787. /* ADC1, 0 */
  2788. 0x05, 0x04
  2789. };
  2790. /* NIDs used when simultaneous access to both ADCs makes sense. Note that
  2791. * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
  2792. */
  2793. static hda_nid_t alc260_dual_adc_nids[2] = {
  2794. /* ADC0, ADC1 */
  2795. 0x04, 0x05
  2796. };
  2797. #define ALC260_DIGOUT_NID 0x03
  2798. #define ALC260_DIGIN_NID 0x06
  2799. static struct hda_input_mux alc260_capture_source = {
  2800. .num_items = 4,
  2801. .items = {
  2802. { "Mic", 0x0 },
  2803. { "Front Mic", 0x1 },
  2804. { "Line", 0x2 },
  2805. { "CD", 0x4 },
  2806. },
  2807. };
  2808. /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
  2809. * headphone jack and the internal CD lines since these are the only pins at
  2810. * which audio can appear. For flexibility, also allow the option of
  2811. * recording the mixer output on the second ADC (ADC0 doesn't have a
  2812. * connection to the mixer output).
  2813. */
  2814. static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
  2815. {
  2816. .num_items = 3,
  2817. .items = {
  2818. { "Mic/Line", 0x0 },
  2819. { "CD", 0x4 },
  2820. { "Headphone", 0x2 },
  2821. },
  2822. },
  2823. {
  2824. .num_items = 4,
  2825. .items = {
  2826. { "Mic/Line", 0x0 },
  2827. { "CD", 0x4 },
  2828. { "Headphone", 0x2 },
  2829. { "Mixer", 0x5 },
  2830. },
  2831. },
  2832. };
  2833. /* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
  2834. * the Fujitsu S702x, but jacks are marked differently.
  2835. */
  2836. static struct hda_input_mux alc260_acer_capture_sources[2] = {
  2837. {
  2838. .num_items = 4,
  2839. .items = {
  2840. { "Mic", 0x0 },
  2841. { "Line", 0x2 },
  2842. { "CD", 0x4 },
  2843. { "Headphone", 0x5 },
  2844. },
  2845. },
  2846. {
  2847. .num_items = 5,
  2848. .items = {
  2849. { "Mic", 0x0 },
  2850. { "Line", 0x2 },
  2851. { "CD", 0x4 },
  2852. { "Headphone", 0x6 },
  2853. { "Mixer", 0x5 },
  2854. },
  2855. },
  2856. };
  2857. /*
  2858. * This is just place-holder, so there's something for alc_build_pcms to look
  2859. * at when it calculates the maximum number of channels. ALC260 has no mixer
  2860. * element which allows changing the channel mode, so the verb list is
  2861. * never used.
  2862. */
  2863. static struct hda_channel_mode alc260_modes[1] = {
  2864. { 2, NULL },
  2865. };
  2866. /* Mixer combinations
  2867. *
  2868. * basic: base_output + input + pc_beep + capture
  2869. * HP: base_output + input + capture_alt
  2870. * HP_3013: hp_3013 + input + capture
  2871. * fujitsu: fujitsu + capture
  2872. * acer: acer + capture
  2873. */
  2874. static struct snd_kcontrol_new alc260_base_output_mixer[] = {
  2875. HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  2876. HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
  2877. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  2878. HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
  2879. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  2880. HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
  2881. { } /* end */
  2882. };
  2883. static struct snd_kcontrol_new alc260_input_mixer[] = {
  2884. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  2885. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  2886. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  2887. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  2888. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  2889. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  2890. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
  2891. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
  2892. { } /* end */
  2893. };
  2894. static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
  2895. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
  2896. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
  2897. { } /* end */
  2898. };
  2899. static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
  2900. HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  2901. HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
  2902. HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
  2903. HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
  2904. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  2905. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  2906. HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  2907. HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
  2908. { } /* end */
  2909. };
  2910. /* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
  2911. * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
  2912. */
  2913. static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
  2914. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  2915. HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
  2916. ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  2917. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  2918. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  2919. HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
  2920. HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
  2921. ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
  2922. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  2923. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  2924. HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  2925. HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
  2926. { } /* end */
  2927. };
  2928. /* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
  2929. * versions of the ALC260 don't act on requests to enable mic bias from NID
  2930. * 0x0f (used to drive the headphone jack in these laptops). The ALC260
  2931. * datasheet doesn't mention this restriction. At this stage it's not clear
  2932. * whether this behaviour is intentional or is a hardware bug in chip
  2933. * revisions available in early 2006. Therefore for now allow the
  2934. * "Headphone Jack Mode" control to span all choices, but if it turns out
  2935. * that the lack of mic bias for this NID is intentional we could change the
  2936. * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
  2937. *
  2938. * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
  2939. * don't appear to make the mic bias available from the "line" jack, even
  2940. * though the NID used for this jack (0x14) can supply it. The theory is
  2941. * that perhaps Acer have included blocking capacitors between the ALC260
  2942. * and the output jack. If this turns out to be the case for all such
  2943. * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
  2944. * to ALC_PIN_DIR_INOUT_NOMICBIAS.
  2945. *
  2946. * The C20x Tablet series have a mono internal speaker which is controlled
  2947. * via the chip's Mono sum widget and pin complex, so include the necessary
  2948. * controls for such models. On models without a "mono speaker" the control
  2949. * won't do anything.
  2950. */
  2951. static struct snd_kcontrol_new alc260_acer_mixer[] = {
  2952. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  2953. HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
  2954. ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
  2955. HDA_CODEC_VOLUME_MONO("Mono Speaker Playback Volume", 0x0a, 1, 0x0,
  2956. HDA_OUTPUT),
  2957. HDA_BIND_MUTE_MONO("Mono Speaker Playback Switch", 0x0a, 1, 2,
  2958. HDA_INPUT),
  2959. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  2960. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  2961. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  2962. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  2963. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  2964. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  2965. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  2966. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  2967. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  2968. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  2969. { } /* end */
  2970. };
  2971. /* capture mixer elements */
  2972. static struct snd_kcontrol_new alc260_capture_mixer[] = {
  2973. HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
  2974. HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
  2975. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
  2976. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
  2977. {
  2978. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  2979. /* The multiple "Capture Source" controls confuse alsamixer
  2980. * So call somewhat different..
  2981. * FIXME: the controls appear in the "playback" view!
  2982. */
  2983. /* .name = "Capture Source", */
  2984. .name = "Input Source",
  2985. .count = 2,
  2986. .info = alc_mux_enum_info,
  2987. .get = alc_mux_enum_get,
  2988. .put = alc_mux_enum_put,
  2989. },
  2990. { } /* end */
  2991. };
  2992. static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
  2993. HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
  2994. HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
  2995. {
  2996. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  2997. /* The multiple "Capture Source" controls confuse alsamixer
  2998. * So call somewhat different..
  2999. * FIXME: the controls appear in the "playback" view!
  3000. */
  3001. /* .name = "Capture Source", */
  3002. .name = "Input Source",
  3003. .count = 1,
  3004. .info = alc_mux_enum_info,
  3005. .get = alc_mux_enum_get,
  3006. .put = alc_mux_enum_put,
  3007. },
  3008. { } /* end */
  3009. };
  3010. /*
  3011. * initialization verbs
  3012. */
  3013. static struct hda_verb alc260_init_verbs[] = {
  3014. /* Line In pin widget for input */
  3015. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3016. /* CD pin widget for input */
  3017. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3018. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3019. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  3020. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3021. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  3022. /* LINE-2 is used for line-out in rear */
  3023. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3024. /* select line-out */
  3025. {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
  3026. /* LINE-OUT pin */
  3027. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3028. /* enable HP */
  3029. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3030. /* enable Mono */
  3031. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3032. /* mute capture amp left and right */
  3033. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3034. /* set connection select to line in (default select for this ADC) */
  3035. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3036. /* mute capture amp left and right */
  3037. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3038. /* set connection select to line in (default select for this ADC) */
  3039. {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
  3040. /* set vol=0 Line-Out mixer amp left and right */
  3041. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3042. /* unmute pin widget amp left and right (no gain on this amp) */
  3043. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3044. /* set vol=0 HP mixer amp left and right */
  3045. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3046. /* unmute pin widget amp left and right (no gain on this amp) */
  3047. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3048. /* set vol=0 Mono mixer amp left and right */
  3049. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3050. /* unmute pin widget amp left and right (no gain on this amp) */
  3051. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3052. /* unmute LINE-2 out pin */
  3053. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3054. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
  3055. /* mute CD */
  3056. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  3057. /* mute Line In */
  3058. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  3059. /* mute Mic */
  3060. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3061. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3062. /* mute Front out path */
  3063. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3064. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3065. /* mute Headphone out path */
  3066. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3067. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3068. /* mute Mono out path */
  3069. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3070. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3071. { }
  3072. };
  3073. #if 0 /* should be identical with alc260_init_verbs? */
  3074. static struct hda_verb alc260_hp_init_verbs[] = {
  3075. /* Headphone and output */
  3076. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  3077. /* mono output */
  3078. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3079. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3080. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3081. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3082. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3083. /* Line In pin widget for input */
  3084. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3085. /* Line-2 pin widget for output */
  3086. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3087. /* CD pin widget for input */
  3088. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3089. /* unmute amp left and right */
  3090. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  3091. /* set connection select to line in (default select for this ADC) */
  3092. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3093. /* unmute Line-Out mixer amp left and right (volume = 0) */
  3094. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3095. /* mute pin widget amp left and right (no gain on this amp) */
  3096. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3097. /* unmute HP mixer amp left and right (volume = 0) */
  3098. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3099. /* mute pin widget amp left and right (no gain on this amp) */
  3100. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3101. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
  3102. /* unmute CD */
  3103. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  3104. /* unmute Line In */
  3105. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  3106. /* unmute Mic */
  3107. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3108. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3109. /* Unmute Front out path */
  3110. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3111. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3112. /* Unmute Headphone out path */
  3113. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3114. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3115. /* Unmute Mono out path */
  3116. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3117. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3118. { }
  3119. };
  3120. #endif
  3121. static struct hda_verb alc260_hp_3013_init_verbs[] = {
  3122. /* Line out and output */
  3123. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3124. /* mono output */
  3125. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3126. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3127. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3128. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3129. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3130. /* Line In pin widget for input */
  3131. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3132. /* Headphone pin widget for output */
  3133. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  3134. /* CD pin widget for input */
  3135. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3136. /* unmute amp left and right */
  3137. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  3138. /* set connection select to line in (default select for this ADC) */
  3139. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3140. /* unmute Line-Out mixer amp left and right (volume = 0) */
  3141. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3142. /* mute pin widget amp left and right (no gain on this amp) */
  3143. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3144. /* unmute HP mixer amp left and right (volume = 0) */
  3145. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3146. /* mute pin widget amp left and right (no gain on this amp) */
  3147. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3148. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
  3149. /* unmute CD */
  3150. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  3151. /* unmute Line In */
  3152. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  3153. /* unmute Mic */
  3154. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3155. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3156. /* Unmute Front out path */
  3157. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3158. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3159. /* Unmute Headphone out path */
  3160. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3161. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3162. /* Unmute Mono out path */
  3163. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3164. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3165. { }
  3166. };
  3167. /* Initialisation sequence for ALC260 as configured in Fujitsu S702x
  3168. * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
  3169. * audio = 0x16, internal speaker = 0x10.
  3170. */
  3171. static struct hda_verb alc260_fujitsu_init_verbs[] = {
  3172. /* Disable all GPIOs */
  3173. {0x01, AC_VERB_SET_GPIO_MASK, 0},
  3174. /* Internal speaker is connected to headphone pin */
  3175. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3176. /* Headphone/Line-out jack connects to Line1 pin; make it an output */
  3177. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3178. /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
  3179. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3180. /* Ensure all other unused pins are disabled and muted. */
  3181. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3182. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3183. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3184. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3185. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3186. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3187. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3188. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3189. /* Disable digital (SPDIF) pins */
  3190. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3191. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3192. /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
  3193. * when acting as an output.
  3194. */
  3195. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3196. /* Start with output sum widgets muted and their output gains at min */
  3197. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3198. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3199. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3200. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3201. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3202. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3203. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3204. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3205. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3206. /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
  3207. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3208. /* Unmute Line1 pin widget output buffer since it starts as an output.
  3209. * If the pin mode is changed by the user the pin mode control will
  3210. * take care of enabling the pin's input/output buffers as needed.
  3211. * Therefore there's no need to enable the input buffer at this
  3212. * stage.
  3213. */
  3214. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3215. /* Unmute input buffer of pin widget used for Line-in (no equiv
  3216. * mixer ctrl)
  3217. */
  3218. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3219. /* Mute capture amp left and right */
  3220. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3221. /* Set ADC connection select to match default mixer setting - line
  3222. * in (on mic1 pin)
  3223. */
  3224. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3225. /* Do the same for the second ADC: mute capture input amp and
  3226. * set ADC connection to line in (on mic1 pin)
  3227. */
  3228. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3229. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3230. /* Mute all inputs to mixer widget (even unconnected ones) */
  3231. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3232. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3233. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3234. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3235. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3236. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3237. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3238. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3239. { }
  3240. };
  3241. /* Initialisation sequence for ALC260 as configured in Acer TravelMate and
  3242. * similar laptops (adapted from Fujitsu init verbs).
  3243. */
  3244. static struct hda_verb alc260_acer_init_verbs[] = {
  3245. /* On TravelMate laptops, GPIO 0 enables the internal speaker and
  3246. * the headphone jack. Turn this on and rely on the standard mute
  3247. * methods whenever the user wants to turn these outputs off.
  3248. */
  3249. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  3250. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  3251. {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
  3252. /* Internal speaker/Headphone jack is connected to Line-out pin */
  3253. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3254. /* Internal microphone/Mic jack is connected to Mic1 pin */
  3255. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  3256. /* Line In jack is connected to Line1 pin */
  3257. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3258. /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
  3259. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3260. /* Ensure all other unused pins are disabled and muted. */
  3261. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3262. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3263. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3264. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3265. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3266. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3267. /* Disable digital (SPDIF) pins */
  3268. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3269. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3270. /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
  3271. * bus when acting as outputs.
  3272. */
  3273. {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
  3274. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3275. /* Start with output sum widgets muted and their output gains at min */
  3276. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3277. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3278. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3279. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3280. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3281. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3282. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3283. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3284. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3285. /* Unmute Line-out pin widget amp left and right (no equiv mixer ctrl) */
  3286. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3287. /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
  3288. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3289. /* Unmute Mic1 and Line1 pin widget input buffers since they start as
  3290. * inputs. If the pin mode is changed by the user the pin mode control
  3291. * will take care of enabling the pin's input/output buffers as needed.
  3292. * Therefore there's no need to enable the input buffer at this
  3293. * stage.
  3294. */
  3295. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3296. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3297. /* Mute capture amp left and right */
  3298. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3299. /* Set ADC connection select to match default mixer setting - mic
  3300. * (on mic1 pin)
  3301. */
  3302. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3303. /* Do similar with the second ADC: mute capture input amp and
  3304. * set ADC connection to mic to match ALSA's default state.
  3305. */
  3306. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3307. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3308. /* Mute all inputs to mixer widget (even unconnected ones) */
  3309. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3310. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3311. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3312. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3313. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3314. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3315. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3316. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3317. { }
  3318. };
  3319. /* Test configuration for debugging, modelled after the ALC880 test
  3320. * configuration.
  3321. */
  3322. #ifdef CONFIG_SND_DEBUG
  3323. static hda_nid_t alc260_test_dac_nids[1] = {
  3324. 0x02,
  3325. };
  3326. static hda_nid_t alc260_test_adc_nids[2] = {
  3327. 0x04, 0x05,
  3328. };
  3329. /* For testing the ALC260, each input MUX needs its own definition since
  3330. * the signal assignments are different. This assumes that the first ADC
  3331. * is NID 0x04.
  3332. */
  3333. static struct hda_input_mux alc260_test_capture_sources[2] = {
  3334. {
  3335. .num_items = 7,
  3336. .items = {
  3337. { "MIC1 pin", 0x0 },
  3338. { "MIC2 pin", 0x1 },
  3339. { "LINE1 pin", 0x2 },
  3340. { "LINE2 pin", 0x3 },
  3341. { "CD pin", 0x4 },
  3342. { "LINE-OUT pin", 0x5 },
  3343. { "HP-OUT pin", 0x6 },
  3344. },
  3345. },
  3346. {
  3347. .num_items = 8,
  3348. .items = {
  3349. { "MIC1 pin", 0x0 },
  3350. { "MIC2 pin", 0x1 },
  3351. { "LINE1 pin", 0x2 },
  3352. { "LINE2 pin", 0x3 },
  3353. { "CD pin", 0x4 },
  3354. { "Mixer", 0x5 },
  3355. { "LINE-OUT pin", 0x6 },
  3356. { "HP-OUT pin", 0x7 },
  3357. },
  3358. },
  3359. };
  3360. static struct snd_kcontrol_new alc260_test_mixer[] = {
  3361. /* Output driver widgets */
  3362. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3363. HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
  3364. HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3365. HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
  3366. HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3367. HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
  3368. /* Modes for retasking pin widgets
  3369. * Note: the ALC260 doesn't seem to act on requests to enable mic
  3370. * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
  3371. * mention this restriction. At this stage it's not clear whether
  3372. * this behaviour is intentional or is a hardware bug in chip
  3373. * revisions available at least up until early 2006. Therefore for
  3374. * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
  3375. * choices, but if it turns out that the lack of mic bias for these
  3376. * NIDs is intentional we could change their modes from
  3377. * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3378. */
  3379. ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
  3380. ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
  3381. ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
  3382. ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
  3383. ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
  3384. ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
  3385. /* Loopback mixer controls */
  3386. HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
  3387. HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
  3388. HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
  3389. HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
  3390. HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
  3391. HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
  3392. HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
  3393. HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
  3394. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3395. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3396. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3397. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3398. HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
  3399. HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
  3400. HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
  3401. HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
  3402. /* Controls for GPIO pins, assuming they are configured as outputs */
  3403. ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
  3404. ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
  3405. ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
  3406. ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
  3407. /* Switches to allow the digital IO pins to be enabled. The datasheet
  3408. * is ambigious as to which NID is which; testing on laptops which
  3409. * make this output available should provide clarification.
  3410. */
  3411. ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
  3412. ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
  3413. { } /* end */
  3414. };
  3415. static struct hda_verb alc260_test_init_verbs[] = {
  3416. /* Enable all GPIOs as outputs with an initial value of 0 */
  3417. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
  3418. {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
  3419. {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
  3420. /* Enable retasking pins as output, initially without power amp */
  3421. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3422. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3423. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3424. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3425. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3426. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3427. /* Disable digital (SPDIF) pins initially, but users can enable
  3428. * them via a mixer switch. In the case of SPDIF-out, this initverb
  3429. * payload also sets the generation to 0, output to be in "consumer"
  3430. * PCM format, copyright asserted, no pre-emphasis and no validity
  3431. * control.
  3432. */
  3433. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3434. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3435. /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
  3436. * OUT1 sum bus when acting as an output.
  3437. */
  3438. {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
  3439. {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
  3440. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3441. {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
  3442. /* Start with output sum widgets muted and their output gains at min */
  3443. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3444. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3445. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3446. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3447. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3448. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3449. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3450. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3451. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3452. /* Unmute retasking pin widget output buffers since the default
  3453. * state appears to be output. As the pin mode is changed by the
  3454. * user the pin mode control will take care of enabling the pin's
  3455. * input/output buffers as needed.
  3456. */
  3457. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3458. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3459. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3460. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3461. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3462. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3463. /* Also unmute the mono-out pin widget */
  3464. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3465. /* Mute capture amp left and right */
  3466. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3467. /* Set ADC connection select to match default mixer setting (mic1
  3468. * pin)
  3469. */
  3470. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3471. /* Do the same for the second ADC: mute capture input amp and
  3472. * set ADC connection to mic1 pin
  3473. */
  3474. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3475. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3476. /* Mute all inputs to mixer widget (even unconnected ones) */
  3477. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3478. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3479. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3480. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3481. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3482. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3483. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3484. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3485. { }
  3486. };
  3487. #endif
  3488. static struct hda_pcm_stream alc260_pcm_analog_playback = {
  3489. .substreams = 1,
  3490. .channels_min = 2,
  3491. .channels_max = 2,
  3492. };
  3493. static struct hda_pcm_stream alc260_pcm_analog_capture = {
  3494. .substreams = 1,
  3495. .channels_min = 2,
  3496. .channels_max = 2,
  3497. };
  3498. #define alc260_pcm_digital_playback alc880_pcm_digital_playback
  3499. #define alc260_pcm_digital_capture alc880_pcm_digital_capture
  3500. /*
  3501. * for BIOS auto-configuration
  3502. */
  3503. static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
  3504. const char *pfx)
  3505. {
  3506. hda_nid_t nid_vol;
  3507. unsigned long vol_val, sw_val;
  3508. char name[32];
  3509. int err;
  3510. if (nid >= 0x0f && nid < 0x11) {
  3511. nid_vol = nid - 0x7;
  3512. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
  3513. sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
  3514. } else if (nid == 0x11) {
  3515. nid_vol = nid - 0x7;
  3516. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
  3517. sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
  3518. } else if (nid >= 0x12 && nid <= 0x15) {
  3519. nid_vol = 0x08;
  3520. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
  3521. sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
  3522. } else
  3523. return 0; /* N/A */
  3524. snprintf(name, sizeof(name), "%s Playback Volume", pfx);
  3525. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val)) < 0)
  3526. return err;
  3527. snprintf(name, sizeof(name), "%s Playback Switch", pfx);
  3528. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val)) < 0)
  3529. return err;
  3530. return 1;
  3531. }
  3532. /* add playback controls from the parsed DAC table */
  3533. static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
  3534. const struct auto_pin_cfg *cfg)
  3535. {
  3536. hda_nid_t nid;
  3537. int err;
  3538. spec->multiout.num_dacs = 1;
  3539. spec->multiout.dac_nids = spec->private_dac_nids;
  3540. spec->multiout.dac_nids[0] = 0x02;
  3541. nid = cfg->line_out_pins[0];
  3542. if (nid) {
  3543. err = alc260_add_playback_controls(spec, nid, "Front");
  3544. if (err < 0)
  3545. return err;
  3546. }
  3547. nid = cfg->speaker_pins[0];
  3548. if (nid) {
  3549. err = alc260_add_playback_controls(spec, nid, "Speaker");
  3550. if (err < 0)
  3551. return err;
  3552. }
  3553. nid = cfg->hp_pins[0];
  3554. if (nid) {
  3555. err = alc260_add_playback_controls(spec, nid, "Headphone");
  3556. if (err < 0)
  3557. return err;
  3558. }
  3559. return 0;
  3560. }
  3561. /* create playback/capture controls for input pins */
  3562. static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
  3563. const struct auto_pin_cfg *cfg)
  3564. {
  3565. struct hda_input_mux *imux = &spec->private_imux;
  3566. int i, err, idx;
  3567. for (i = 0; i < AUTO_PIN_LAST; i++) {
  3568. if (cfg->input_pins[i] >= 0x12) {
  3569. idx = cfg->input_pins[i] - 0x12;
  3570. err = new_analog_input(spec, cfg->input_pins[i],
  3571. auto_pin_cfg_labels[i], idx, 0x07);
  3572. if (err < 0)
  3573. return err;
  3574. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  3575. imux->items[imux->num_items].index = idx;
  3576. imux->num_items++;
  3577. }
  3578. if ((cfg->input_pins[i] >= 0x0f) && (cfg->input_pins[i] <= 0x10)){
  3579. idx = cfg->input_pins[i] - 0x09;
  3580. err = new_analog_input(spec, cfg->input_pins[i],
  3581. auto_pin_cfg_labels[i], idx, 0x07);
  3582. if (err < 0)
  3583. return err;
  3584. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  3585. imux->items[imux->num_items].index = idx;
  3586. imux->num_items++;
  3587. }
  3588. }
  3589. return 0;
  3590. }
  3591. static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
  3592. hda_nid_t nid, int pin_type,
  3593. int sel_idx)
  3594. {
  3595. /* set as output */
  3596. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  3597. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  3598. /* need the manual connection? */
  3599. if (nid >= 0x12) {
  3600. int idx = nid - 0x12;
  3601. snd_hda_codec_write(codec, idx + 0x0b, 0,
  3602. AC_VERB_SET_CONNECT_SEL, sel_idx);
  3603. }
  3604. }
  3605. static void alc260_auto_init_multi_out(struct hda_codec *codec)
  3606. {
  3607. struct alc_spec *spec = codec->spec;
  3608. hda_nid_t nid;
  3609. nid = spec->autocfg.line_out_pins[0];
  3610. if (nid)
  3611. alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
  3612. nid = spec->autocfg.speaker_pins[0];
  3613. if (nid)
  3614. alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
  3615. nid = spec->autocfg.hp_pins[0];
  3616. if (nid)
  3617. alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
  3618. }
  3619. #define ALC260_PIN_CD_NID 0x16
  3620. static void alc260_auto_init_analog_input(struct hda_codec *codec)
  3621. {
  3622. struct alc_spec *spec = codec->spec;
  3623. int i;
  3624. for (i = 0; i < AUTO_PIN_LAST; i++) {
  3625. hda_nid_t nid = spec->autocfg.input_pins[i];
  3626. if (nid >= 0x12) {
  3627. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  3628. i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
  3629. if (nid != ALC260_PIN_CD_NID)
  3630. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  3631. AMP_OUT_MUTE);
  3632. }
  3633. }
  3634. }
  3635. /*
  3636. * generic initialization of ADC, input mixers and output mixers
  3637. */
  3638. static struct hda_verb alc260_volume_init_verbs[] = {
  3639. /*
  3640. * Unmute ADC0-1 and set the default input to mic-in
  3641. */
  3642. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3643. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3644. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3645. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3646. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  3647. * mixer widget
  3648. * Note: PASD motherboards uses the Line In 2 as the input for front panel
  3649. * mic (mic 2)
  3650. */
  3651. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  3652. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3653. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3654. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  3655. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  3656. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  3657. /*
  3658. * Set up output mixers (0x08 - 0x0a)
  3659. */
  3660. /* set vol=0 to output mixers */
  3661. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3662. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3663. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3664. /* set up input amps for analog loopback */
  3665. /* Amp Indices: DAC = 0, mixer = 1 */
  3666. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3667. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3668. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3669. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3670. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3671. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3672. { }
  3673. };
  3674. static int alc260_parse_auto_config(struct hda_codec *codec)
  3675. {
  3676. struct alc_spec *spec = codec->spec;
  3677. unsigned int wcap;
  3678. int err;
  3679. static hda_nid_t alc260_ignore[] = { 0x17, 0 };
  3680. if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  3681. alc260_ignore)) < 0)
  3682. return err;
  3683. if ((err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0)
  3684. return err;
  3685. if (! spec->kctl_alloc)
  3686. return 0; /* can't find valid BIOS pin config */
  3687. if ((err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
  3688. return err;
  3689. spec->multiout.max_channels = 2;
  3690. if (spec->autocfg.dig_out_pin)
  3691. spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
  3692. if (spec->kctl_alloc)
  3693. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  3694. spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
  3695. spec->num_mux_defs = 1;
  3696. spec->input_mux = &spec->private_imux;
  3697. /* check whether NID 0x04 is valid */
  3698. wcap = get_wcaps(codec, 0x04);
  3699. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
  3700. if (wcap != AC_WID_AUD_IN) {
  3701. spec->adc_nids = alc260_adc_nids_alt;
  3702. spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
  3703. spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
  3704. } else {
  3705. spec->adc_nids = alc260_adc_nids;
  3706. spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
  3707. spec->mixers[spec->num_mixers] = alc260_capture_mixer;
  3708. }
  3709. spec->num_mixers++;
  3710. return 1;
  3711. }
  3712. /* additional initialization for auto-configuration model */
  3713. static void alc260_auto_init(struct hda_codec *codec)
  3714. {
  3715. alc260_auto_init_multi_out(codec);
  3716. alc260_auto_init_analog_input(codec);
  3717. }
  3718. /*
  3719. * ALC260 configurations
  3720. */
  3721. static const char *alc260_models[ALC260_MODEL_LAST] = {
  3722. [ALC260_BASIC] = "basic",
  3723. [ALC260_HP] = "hp",
  3724. [ALC260_HP_3013] = "hp-3013",
  3725. [ALC260_FUJITSU_S702X] = "fujitsu",
  3726. [ALC260_ACER] = "acer",
  3727. #ifdef CONFIG_SND_DEBUG
  3728. [ALC260_TEST] = "test",
  3729. #endif
  3730. [ALC260_AUTO] = "auto",
  3731. };
  3732. static struct snd_pci_quirk alc260_cfg_tbl[] = {
  3733. SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
  3734. SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
  3735. SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
  3736. SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP),
  3737. SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_3013),
  3738. SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
  3739. SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
  3740. SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
  3741. SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
  3742. SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
  3743. SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
  3744. SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
  3745. SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
  3746. SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
  3747. {}
  3748. };
  3749. static struct alc_config_preset alc260_presets[] = {
  3750. [ALC260_BASIC] = {
  3751. .mixers = { alc260_base_output_mixer,
  3752. alc260_input_mixer,
  3753. alc260_pc_beep_mixer,
  3754. alc260_capture_mixer },
  3755. .init_verbs = { alc260_init_verbs },
  3756. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  3757. .dac_nids = alc260_dac_nids,
  3758. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  3759. .adc_nids = alc260_adc_nids,
  3760. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  3761. .channel_mode = alc260_modes,
  3762. .input_mux = &alc260_capture_source,
  3763. },
  3764. [ALC260_HP] = {
  3765. .mixers = { alc260_base_output_mixer,
  3766. alc260_input_mixer,
  3767. alc260_capture_alt_mixer },
  3768. .init_verbs = { alc260_init_verbs },
  3769. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  3770. .dac_nids = alc260_dac_nids,
  3771. .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
  3772. .adc_nids = alc260_hp_adc_nids,
  3773. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  3774. .channel_mode = alc260_modes,
  3775. .input_mux = &alc260_capture_source,
  3776. },
  3777. [ALC260_HP_3013] = {
  3778. .mixers = { alc260_hp_3013_mixer,
  3779. alc260_input_mixer,
  3780. alc260_capture_alt_mixer },
  3781. .init_verbs = { alc260_hp_3013_init_verbs },
  3782. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  3783. .dac_nids = alc260_dac_nids,
  3784. .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
  3785. .adc_nids = alc260_hp_adc_nids,
  3786. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  3787. .channel_mode = alc260_modes,
  3788. .input_mux = &alc260_capture_source,
  3789. },
  3790. [ALC260_FUJITSU_S702X] = {
  3791. .mixers = { alc260_fujitsu_mixer,
  3792. alc260_capture_mixer },
  3793. .init_verbs = { alc260_fujitsu_init_verbs },
  3794. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  3795. .dac_nids = alc260_dac_nids,
  3796. .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
  3797. .adc_nids = alc260_dual_adc_nids,
  3798. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  3799. .channel_mode = alc260_modes,
  3800. .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
  3801. .input_mux = alc260_fujitsu_capture_sources,
  3802. },
  3803. [ALC260_ACER] = {
  3804. .mixers = { alc260_acer_mixer,
  3805. alc260_capture_mixer },
  3806. .init_verbs = { alc260_acer_init_verbs },
  3807. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  3808. .dac_nids = alc260_dac_nids,
  3809. .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
  3810. .adc_nids = alc260_dual_adc_nids,
  3811. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  3812. .channel_mode = alc260_modes,
  3813. .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
  3814. .input_mux = alc260_acer_capture_sources,
  3815. },
  3816. #ifdef CONFIG_SND_DEBUG
  3817. [ALC260_TEST] = {
  3818. .mixers = { alc260_test_mixer,
  3819. alc260_capture_mixer },
  3820. .init_verbs = { alc260_test_init_verbs },
  3821. .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
  3822. .dac_nids = alc260_test_dac_nids,
  3823. .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
  3824. .adc_nids = alc260_test_adc_nids,
  3825. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  3826. .channel_mode = alc260_modes,
  3827. .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
  3828. .input_mux = alc260_test_capture_sources,
  3829. },
  3830. #endif
  3831. };
  3832. static int patch_alc260(struct hda_codec *codec)
  3833. {
  3834. struct alc_spec *spec;
  3835. int err, board_config;
  3836. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  3837. if (spec == NULL)
  3838. return -ENOMEM;
  3839. codec->spec = spec;
  3840. board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
  3841. alc260_models,
  3842. alc260_cfg_tbl);
  3843. if (board_config < 0) {
  3844. snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
  3845. "trying auto-probe from BIOS...\n");
  3846. board_config = ALC260_AUTO;
  3847. }
  3848. if (board_config == ALC260_AUTO) {
  3849. /* automatic parse from the BIOS config */
  3850. err = alc260_parse_auto_config(codec);
  3851. if (err < 0) {
  3852. alc_free(codec);
  3853. return err;
  3854. } else if (! err) {
  3855. printk(KERN_INFO
  3856. "hda_codec: Cannot set up configuration "
  3857. "from BIOS. Using base mode...\n");
  3858. board_config = ALC260_BASIC;
  3859. }
  3860. }
  3861. if (board_config != ALC260_AUTO)
  3862. setup_preset(spec, &alc260_presets[board_config]);
  3863. spec->stream_name_analog = "ALC260 Analog";
  3864. spec->stream_analog_playback = &alc260_pcm_analog_playback;
  3865. spec->stream_analog_capture = &alc260_pcm_analog_capture;
  3866. spec->stream_name_digital = "ALC260 Digital";
  3867. spec->stream_digital_playback = &alc260_pcm_digital_playback;
  3868. spec->stream_digital_capture = &alc260_pcm_digital_capture;
  3869. codec->patch_ops = alc_patch_ops;
  3870. if (board_config == ALC260_AUTO)
  3871. spec->init_hook = alc260_auto_init;
  3872. return 0;
  3873. }
  3874. /*
  3875. * ALC882 support
  3876. *
  3877. * ALC882 is almost identical with ALC880 but has cleaner and more flexible
  3878. * configuration. Each pin widget can choose any input DACs and a mixer.
  3879. * Each ADC is connected from a mixer of all inputs. This makes possible
  3880. * 6-channel independent captures.
  3881. *
  3882. * In addition, an independent DAC for the multi-playback (not used in this
  3883. * driver yet).
  3884. */
  3885. #define ALC882_DIGOUT_NID 0x06
  3886. #define ALC882_DIGIN_NID 0x0a
  3887. static struct hda_channel_mode alc882_ch_modes[1] = {
  3888. { 8, NULL }
  3889. };
  3890. static hda_nid_t alc882_dac_nids[4] = {
  3891. /* front, rear, clfe, rear_surr */
  3892. 0x02, 0x03, 0x04, 0x05
  3893. };
  3894. /* identical with ALC880 */
  3895. #define alc882_adc_nids alc880_adc_nids
  3896. #define alc882_adc_nids_alt alc880_adc_nids_alt
  3897. /* input MUX */
  3898. /* FIXME: should be a matrix-type input source selection */
  3899. static struct hda_input_mux alc882_capture_source = {
  3900. .num_items = 4,
  3901. .items = {
  3902. { "Mic", 0x0 },
  3903. { "Front Mic", 0x1 },
  3904. { "Line", 0x2 },
  3905. { "CD", 0x4 },
  3906. },
  3907. };
  3908. #define alc882_mux_enum_info alc_mux_enum_info
  3909. #define alc882_mux_enum_get alc_mux_enum_get
  3910. static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  3911. {
  3912. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  3913. struct alc_spec *spec = codec->spec;
  3914. const struct hda_input_mux *imux = spec->input_mux;
  3915. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  3916. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  3917. hda_nid_t nid = capture_mixers[adc_idx];
  3918. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  3919. unsigned int i, idx;
  3920. idx = ucontrol->value.enumerated.item[0];
  3921. if (idx >= imux->num_items)
  3922. idx = imux->num_items - 1;
  3923. if (*cur_val == idx && ! codec->in_resume)
  3924. return 0;
  3925. for (i = 0; i < imux->num_items; i++) {
  3926. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  3927. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  3928. v | (imux->items[i].index << 8));
  3929. }
  3930. *cur_val = idx;
  3931. return 1;
  3932. }
  3933. /*
  3934. * 6ch mode
  3935. */
  3936. static struct hda_verb alc882_sixstack_ch6_init[] = {
  3937. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  3938. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  3939. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  3940. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  3941. { } /* end */
  3942. };
  3943. /*
  3944. * 8ch mode
  3945. */
  3946. static struct hda_verb alc882_sixstack_ch8_init[] = {
  3947. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  3948. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  3949. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  3950. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  3951. { } /* end */
  3952. };
  3953. static struct hda_channel_mode alc882_sixstack_modes[2] = {
  3954. { 6, alc882_sixstack_ch6_init },
  3955. { 8, alc882_sixstack_ch8_init },
  3956. };
  3957. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  3958. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  3959. */
  3960. static struct snd_kcontrol_new alc882_base_mixer[] = {
  3961. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  3962. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  3963. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  3964. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  3965. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  3966. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  3967. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  3968. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  3969. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  3970. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  3971. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  3972. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  3973. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  3974. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  3975. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  3976. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  3977. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  3978. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  3979. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  3980. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  3981. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  3982. { } /* end */
  3983. };
  3984. static struct snd_kcontrol_new alc882_chmode_mixer[] = {
  3985. {
  3986. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3987. .name = "Channel Mode",
  3988. .info = alc_ch_mode_info,
  3989. .get = alc_ch_mode_get,
  3990. .put = alc_ch_mode_put,
  3991. },
  3992. { } /* end */
  3993. };
  3994. static struct hda_verb alc882_init_verbs[] = {
  3995. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  3996. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3997. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3998. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3999. /* Rear mixer */
  4000. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4001. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4002. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4003. /* CLFE mixer */
  4004. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4005. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4006. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4007. /* Side mixer */
  4008. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4009. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4010. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4011. /* Front Pin: output 0 (0x0c) */
  4012. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4013. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4014. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  4015. /* Rear Pin: output 1 (0x0d) */
  4016. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4017. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4018. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  4019. /* CLFE Pin: output 2 (0x0e) */
  4020. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4021. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4022. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  4023. /* Side Pin: output 3 (0x0f) */
  4024. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4025. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4026. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  4027. /* Mic (rear) pin: input vref at 80% */
  4028. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4029. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4030. /* Front Mic pin: input vref at 80% */
  4031. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4032. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4033. /* Line In pin: input */
  4034. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4035. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4036. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  4037. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4038. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4039. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  4040. /* CD pin widget for input */
  4041. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4042. /* FIXME: use matrix-type input source selection */
  4043. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4044. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4045. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4046. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4047. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4048. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4049. /* Input mixer2 */
  4050. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4051. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4052. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4053. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4054. /* Input mixer3 */
  4055. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4056. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4057. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4058. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4059. /* ADC1: mute amp left and right */
  4060. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4061. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4062. /* ADC2: mute amp left and right */
  4063. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4064. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4065. /* ADC3: mute amp left and right */
  4066. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4067. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4068. { }
  4069. };
  4070. static struct hda_verb alc882_eapd_verbs[] = {
  4071. /* change to EAPD mode */
  4072. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  4073. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  4074. { }
  4075. };
  4076. /* Mac Pro test */
  4077. static struct snd_kcontrol_new alc882_macpro_mixer[] = {
  4078. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4079. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4080. HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
  4081. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
  4082. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
  4083. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4084. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4085. { } /* end */
  4086. };
  4087. static struct hda_verb alc882_macpro_init_verbs[] = {
  4088. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  4089. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4090. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4091. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4092. /* Front Pin: output 0 (0x0c) */
  4093. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4094. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4095. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  4096. /* Front Mic pin: input vref at 80% */
  4097. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4098. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4099. /* Speaker: output */
  4100. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4101. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4102. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
  4103. /* Headphone output (output 0 - 0x0c) */
  4104. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4105. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4106. {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
  4107. /* FIXME: use matrix-type input source selection */
  4108. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4109. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4110. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4111. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4112. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4113. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4114. /* Input mixer2 */
  4115. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4116. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4117. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4118. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4119. /* Input mixer3 */
  4120. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4121. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4122. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4123. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4124. /* ADC1: mute amp left and right */
  4125. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4126. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4127. /* ADC2: mute amp left and right */
  4128. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4129. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4130. /* ADC3: mute amp left and right */
  4131. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4132. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4133. { }
  4134. };
  4135. static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
  4136. {
  4137. unsigned int gpiostate, gpiomask, gpiodir;
  4138. gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
  4139. AC_VERB_GET_GPIO_DATA, 0);
  4140. if (!muted)
  4141. gpiostate |= (1 << pin);
  4142. else
  4143. gpiostate &= ~(1 << pin);
  4144. gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
  4145. AC_VERB_GET_GPIO_MASK, 0);
  4146. gpiomask |= (1 << pin);
  4147. gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
  4148. AC_VERB_GET_GPIO_DIRECTION, 0);
  4149. gpiodir |= (1 << pin);
  4150. snd_hda_codec_write(codec, codec->afg, 0,
  4151. AC_VERB_SET_GPIO_MASK, gpiomask);
  4152. snd_hda_codec_write(codec, codec->afg, 0,
  4153. AC_VERB_SET_GPIO_DIRECTION, gpiodir);
  4154. msleep(1);
  4155. snd_hda_codec_write(codec, codec->afg, 0,
  4156. AC_VERB_SET_GPIO_DATA, gpiostate);
  4157. }
  4158. /*
  4159. * generic initialization of ADC, input mixers and output mixers
  4160. */
  4161. static struct hda_verb alc882_auto_init_verbs[] = {
  4162. /*
  4163. * Unmute ADC0-2 and set the default input to mic-in
  4164. */
  4165. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4166. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4167. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4168. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4169. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4170. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4171. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  4172. * mixer widget
  4173. * Note: PASD motherboards uses the Line In 2 as the input for front panel
  4174. * mic (mic 2)
  4175. */
  4176. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  4177. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4178. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4179. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4180. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  4181. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  4182. /*
  4183. * Set up output mixers (0x0c - 0x0f)
  4184. */
  4185. /* set vol=0 to output mixers */
  4186. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4187. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4188. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4189. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4190. /* set up input amps for analog loopback */
  4191. /* Amp Indices: DAC = 0, mixer = 1 */
  4192. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4193. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4194. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4195. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4196. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4197. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4198. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4199. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4200. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4201. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4202. /* FIXME: use matrix-type input source selection */
  4203. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4204. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4205. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4206. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4207. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4208. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4209. /* Input mixer2 */
  4210. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4211. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4212. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4213. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4214. /* Input mixer3 */
  4215. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4216. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4217. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4218. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4219. { }
  4220. };
  4221. /* capture mixer elements */
  4222. static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
  4223. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  4224. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  4225. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  4226. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  4227. {
  4228. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4229. /* The multiple "Capture Source" controls confuse alsamixer
  4230. * So call somewhat different..
  4231. * FIXME: the controls appear in the "playback" view!
  4232. */
  4233. /* .name = "Capture Source", */
  4234. .name = "Input Source",
  4235. .count = 2,
  4236. .info = alc882_mux_enum_info,
  4237. .get = alc882_mux_enum_get,
  4238. .put = alc882_mux_enum_put,
  4239. },
  4240. { } /* end */
  4241. };
  4242. static struct snd_kcontrol_new alc882_capture_mixer[] = {
  4243. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  4244. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  4245. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  4246. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  4247. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  4248. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  4249. {
  4250. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4251. /* The multiple "Capture Source" controls confuse alsamixer
  4252. * So call somewhat different..
  4253. * FIXME: the controls appear in the "playback" view!
  4254. */
  4255. /* .name = "Capture Source", */
  4256. .name = "Input Source",
  4257. .count = 3,
  4258. .info = alc882_mux_enum_info,
  4259. .get = alc882_mux_enum_get,
  4260. .put = alc882_mux_enum_put,
  4261. },
  4262. { } /* end */
  4263. };
  4264. /* pcm configuration: identiacal with ALC880 */
  4265. #define alc882_pcm_analog_playback alc880_pcm_analog_playback
  4266. #define alc882_pcm_analog_capture alc880_pcm_analog_capture
  4267. #define alc882_pcm_digital_playback alc880_pcm_digital_playback
  4268. #define alc882_pcm_digital_capture alc880_pcm_digital_capture
  4269. /*
  4270. * configuration and preset
  4271. */
  4272. static const char *alc882_models[ALC882_MODEL_LAST] = {
  4273. [ALC882_3ST_DIG] = "3stack-dig",
  4274. [ALC882_6ST_DIG] = "6stack-dig",
  4275. [ALC882_ARIMA] = "arima",
  4276. [ALC885_MACPRO] = "macpro",
  4277. [ALC882_AUTO] = "auto",
  4278. };
  4279. static struct snd_pci_quirk alc882_cfg_tbl[] = {
  4280. SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
  4281. SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
  4282. SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
  4283. SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
  4284. SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
  4285. {}
  4286. };
  4287. static struct alc_config_preset alc882_presets[] = {
  4288. [ALC882_3ST_DIG] = {
  4289. .mixers = { alc882_base_mixer },
  4290. .init_verbs = { alc882_init_verbs },
  4291. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4292. .dac_nids = alc882_dac_nids,
  4293. .dig_out_nid = ALC882_DIGOUT_NID,
  4294. .dig_in_nid = ALC882_DIGIN_NID,
  4295. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  4296. .channel_mode = alc882_ch_modes,
  4297. .need_dac_fix = 1,
  4298. .input_mux = &alc882_capture_source,
  4299. },
  4300. [ALC882_6ST_DIG] = {
  4301. .mixers = { alc882_base_mixer, alc882_chmode_mixer },
  4302. .init_verbs = { alc882_init_verbs },
  4303. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4304. .dac_nids = alc882_dac_nids,
  4305. .dig_out_nid = ALC882_DIGOUT_NID,
  4306. .dig_in_nid = ALC882_DIGIN_NID,
  4307. .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
  4308. .channel_mode = alc882_sixstack_modes,
  4309. .input_mux = &alc882_capture_source,
  4310. },
  4311. [ALC882_ARIMA] = {
  4312. .mixers = { alc882_base_mixer, alc882_chmode_mixer },
  4313. .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
  4314. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4315. .dac_nids = alc882_dac_nids,
  4316. .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
  4317. .channel_mode = alc882_sixstack_modes,
  4318. .input_mux = &alc882_capture_source,
  4319. },
  4320. [ALC885_MACPRO] = {
  4321. .mixers = { alc882_macpro_mixer },
  4322. .init_verbs = { alc882_macpro_init_verbs },
  4323. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4324. .dac_nids = alc882_dac_nids,
  4325. .dig_out_nid = ALC882_DIGOUT_NID,
  4326. .dig_in_nid = ALC882_DIGIN_NID,
  4327. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  4328. .channel_mode = alc882_ch_modes,
  4329. .input_mux = &alc882_capture_source,
  4330. },
  4331. };
  4332. /*
  4333. * BIOS auto configuration
  4334. */
  4335. static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
  4336. hda_nid_t nid, int pin_type,
  4337. int dac_idx)
  4338. {
  4339. /* set as output */
  4340. struct alc_spec *spec = codec->spec;
  4341. int idx;
  4342. if (spec->multiout.dac_nids[dac_idx] == 0x25)
  4343. idx = 4;
  4344. else
  4345. idx = spec->multiout.dac_nids[dac_idx] - 2;
  4346. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  4347. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  4348. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
  4349. }
  4350. static void alc882_auto_init_multi_out(struct hda_codec *codec)
  4351. {
  4352. struct alc_spec *spec = codec->spec;
  4353. int i;
  4354. for (i = 0; i <= HDA_SIDE; i++) {
  4355. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  4356. if (nid)
  4357. alc882_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
  4358. }
  4359. }
  4360. static void alc882_auto_init_hp_out(struct hda_codec *codec)
  4361. {
  4362. struct alc_spec *spec = codec->spec;
  4363. hda_nid_t pin;
  4364. pin = spec->autocfg.hp_pins[0];
  4365. if (pin) /* connect to front */
  4366. alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); /* use dac 0 */
  4367. }
  4368. #define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
  4369. #define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
  4370. static void alc882_auto_init_analog_input(struct hda_codec *codec)
  4371. {
  4372. struct alc_spec *spec = codec->spec;
  4373. int i;
  4374. for (i = 0; i < AUTO_PIN_LAST; i++) {
  4375. hda_nid_t nid = spec->autocfg.input_pins[i];
  4376. if (alc882_is_input_pin(nid)) {
  4377. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  4378. i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
  4379. if (nid != ALC882_PIN_CD_NID)
  4380. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  4381. AMP_OUT_MUTE);
  4382. }
  4383. }
  4384. }
  4385. /* almost identical with ALC880 parser... */
  4386. static int alc882_parse_auto_config(struct hda_codec *codec)
  4387. {
  4388. struct alc_spec *spec = codec->spec;
  4389. int err = alc880_parse_auto_config(codec);
  4390. if (err < 0)
  4391. return err;
  4392. else if (err > 0)
  4393. /* hack - override the init verbs */
  4394. spec->init_verbs[0] = alc882_auto_init_verbs;
  4395. return err;
  4396. }
  4397. /* additional initialization for auto-configuration model */
  4398. static void alc882_auto_init(struct hda_codec *codec)
  4399. {
  4400. alc882_auto_init_multi_out(codec);
  4401. alc882_auto_init_hp_out(codec);
  4402. alc882_auto_init_analog_input(codec);
  4403. }
  4404. static int patch_alc882(struct hda_codec *codec)
  4405. {
  4406. struct alc_spec *spec;
  4407. int err, board_config;
  4408. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  4409. if (spec == NULL)
  4410. return -ENOMEM;
  4411. codec->spec = spec;
  4412. board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
  4413. alc882_models,
  4414. alc882_cfg_tbl);
  4415. if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
  4416. printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
  4417. "trying auto-probe from BIOS...\n");
  4418. board_config = ALC882_AUTO;
  4419. }
  4420. if (board_config == ALC882_AUTO) {
  4421. /* automatic parse from the BIOS config */
  4422. err = alc882_parse_auto_config(codec);
  4423. if (err < 0) {
  4424. alc_free(codec);
  4425. return err;
  4426. } else if (! err) {
  4427. printk(KERN_INFO
  4428. "hda_codec: Cannot set up configuration "
  4429. "from BIOS. Using base mode...\n");
  4430. board_config = ALC882_3ST_DIG;
  4431. }
  4432. }
  4433. if (board_config != ALC882_AUTO)
  4434. setup_preset(spec, &alc882_presets[board_config]);
  4435. if (board_config == ALC885_MACPRO) {
  4436. alc882_gpio_mute(codec, 0, 0);
  4437. alc882_gpio_mute(codec, 1, 0);
  4438. }
  4439. spec->stream_name_analog = "ALC882 Analog";
  4440. spec->stream_analog_playback = &alc882_pcm_analog_playback;
  4441. spec->stream_analog_capture = &alc882_pcm_analog_capture;
  4442. spec->stream_name_digital = "ALC882 Digital";
  4443. spec->stream_digital_playback = &alc882_pcm_digital_playback;
  4444. spec->stream_digital_capture = &alc882_pcm_digital_capture;
  4445. if (! spec->adc_nids && spec->input_mux) {
  4446. /* check whether NID 0x07 is valid */
  4447. unsigned int wcap = get_wcaps(codec, 0x07);
  4448. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
  4449. if (wcap != AC_WID_AUD_IN) {
  4450. spec->adc_nids = alc882_adc_nids_alt;
  4451. spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
  4452. spec->mixers[spec->num_mixers] = alc882_capture_alt_mixer;
  4453. spec->num_mixers++;
  4454. } else {
  4455. spec->adc_nids = alc882_adc_nids;
  4456. spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
  4457. spec->mixers[spec->num_mixers] = alc882_capture_mixer;
  4458. spec->num_mixers++;
  4459. }
  4460. }
  4461. codec->patch_ops = alc_patch_ops;
  4462. if (board_config == ALC882_AUTO)
  4463. spec->init_hook = alc882_auto_init;
  4464. return 0;
  4465. }
  4466. /*
  4467. * ALC883 support
  4468. *
  4469. * ALC883 is almost identical with ALC880 but has cleaner and more flexible
  4470. * configuration. Each pin widget can choose any input DACs and a mixer.
  4471. * Each ADC is connected from a mixer of all inputs. This makes possible
  4472. * 6-channel independent captures.
  4473. *
  4474. * In addition, an independent DAC for the multi-playback (not used in this
  4475. * driver yet).
  4476. */
  4477. #define ALC883_DIGOUT_NID 0x06
  4478. #define ALC883_DIGIN_NID 0x0a
  4479. static hda_nid_t alc883_dac_nids[4] = {
  4480. /* front, rear, clfe, rear_surr */
  4481. 0x02, 0x04, 0x03, 0x05
  4482. };
  4483. static hda_nid_t alc883_adc_nids[2] = {
  4484. /* ADC1-2 */
  4485. 0x08, 0x09,
  4486. };
  4487. /* input MUX */
  4488. /* FIXME: should be a matrix-type input source selection */
  4489. static struct hda_input_mux alc883_capture_source = {
  4490. .num_items = 4,
  4491. .items = {
  4492. { "Mic", 0x0 },
  4493. { "Front Mic", 0x1 },
  4494. { "Line", 0x2 },
  4495. { "CD", 0x4 },
  4496. },
  4497. };
  4498. #define alc883_mux_enum_info alc_mux_enum_info
  4499. #define alc883_mux_enum_get alc_mux_enum_get
  4500. static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
  4501. struct snd_ctl_elem_value *ucontrol)
  4502. {
  4503. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  4504. struct alc_spec *spec = codec->spec;
  4505. const struct hda_input_mux *imux = spec->input_mux;
  4506. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  4507. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  4508. hda_nid_t nid = capture_mixers[adc_idx];
  4509. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  4510. unsigned int i, idx;
  4511. idx = ucontrol->value.enumerated.item[0];
  4512. if (idx >= imux->num_items)
  4513. idx = imux->num_items - 1;
  4514. if (*cur_val == idx && ! codec->in_resume)
  4515. return 0;
  4516. for (i = 0; i < imux->num_items; i++) {
  4517. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  4518. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  4519. v | (imux->items[i].index << 8));
  4520. }
  4521. *cur_val = idx;
  4522. return 1;
  4523. }
  4524. /*
  4525. * 2ch mode
  4526. */
  4527. static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
  4528. { 2, NULL }
  4529. };
  4530. /*
  4531. * 2ch mode
  4532. */
  4533. static struct hda_verb alc883_3ST_ch2_init[] = {
  4534. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  4535. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  4536. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  4537. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  4538. { } /* end */
  4539. };
  4540. /*
  4541. * 6ch mode
  4542. */
  4543. static struct hda_verb alc883_3ST_ch6_init[] = {
  4544. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4545. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  4546. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  4547. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4548. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  4549. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  4550. { } /* end */
  4551. };
  4552. static struct hda_channel_mode alc883_3ST_6ch_modes[2] = {
  4553. { 2, alc883_3ST_ch2_init },
  4554. { 6, alc883_3ST_ch6_init },
  4555. };
  4556. /*
  4557. * 6ch mode
  4558. */
  4559. static struct hda_verb alc883_sixstack_ch6_init[] = {
  4560. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  4561. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4562. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4563. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4564. { } /* end */
  4565. };
  4566. /*
  4567. * 8ch mode
  4568. */
  4569. static struct hda_verb alc883_sixstack_ch8_init[] = {
  4570. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4571. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4572. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4573. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4574. { } /* end */
  4575. };
  4576. static struct hda_channel_mode alc883_sixstack_modes[2] = {
  4577. { 6, alc883_sixstack_ch6_init },
  4578. { 8, alc883_sixstack_ch8_init },
  4579. };
  4580. static struct hda_verb alc883_medion_eapd_verbs[] = {
  4581. /* eanable EAPD on medion laptop */
  4582. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  4583. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  4584. { }
  4585. };
  4586. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  4587. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  4588. */
  4589. static struct snd_kcontrol_new alc883_base_mixer[] = {
  4590. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4591. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4592. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  4593. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  4594. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  4595. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  4596. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  4597. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  4598. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  4599. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  4600. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4601. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4602. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4603. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4604. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4605. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4606. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4607. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  4608. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  4609. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4610. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4611. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  4612. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  4613. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  4614. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  4615. {
  4616. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4617. /* .name = "Capture Source", */
  4618. .name = "Input Source",
  4619. .count = 2,
  4620. .info = alc883_mux_enum_info,
  4621. .get = alc883_mux_enum_get,
  4622. .put = alc883_mux_enum_put,
  4623. },
  4624. { } /* end */
  4625. };
  4626. static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
  4627. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4628. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4629. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4630. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4631. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4632. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4633. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4634. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4635. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4636. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  4637. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  4638. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4639. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4640. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  4641. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  4642. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  4643. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  4644. {
  4645. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4646. /* .name = "Capture Source", */
  4647. .name = "Input Source",
  4648. .count = 2,
  4649. .info = alc883_mux_enum_info,
  4650. .get = alc883_mux_enum_get,
  4651. .put = alc883_mux_enum_put,
  4652. },
  4653. { } /* end */
  4654. };
  4655. static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
  4656. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4657. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4658. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  4659. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  4660. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  4661. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  4662. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  4663. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  4664. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4665. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4666. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4667. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4668. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4669. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4670. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4671. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  4672. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  4673. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4674. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4675. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  4676. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  4677. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  4678. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  4679. {
  4680. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4681. /* .name = "Capture Source", */
  4682. .name = "Input Source",
  4683. .count = 2,
  4684. .info = alc883_mux_enum_info,
  4685. .get = alc883_mux_enum_get,
  4686. .put = alc883_mux_enum_put,
  4687. },
  4688. { } /* end */
  4689. };
  4690. static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
  4691. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4692. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  4693. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  4694. HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  4695. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  4696. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  4697. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
  4698. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  4699. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4700. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4701. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4702. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4703. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4704. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4705. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4706. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  4707. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  4708. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4709. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4710. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  4711. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  4712. {
  4713. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4714. /* .name = "Capture Source", */
  4715. .name = "Input Source",
  4716. .count = 1,
  4717. .info = alc883_mux_enum_info,
  4718. .get = alc883_mux_enum_get,
  4719. .put = alc883_mux_enum_put,
  4720. },
  4721. { } /* end */
  4722. };
  4723. static struct snd_kcontrol_new alc883_tagra_mixer[] = {
  4724. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4725. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  4726. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4727. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  4728. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  4729. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  4730. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  4731. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  4732. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  4733. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4734. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4735. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4736. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4737. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4738. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4739. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  4740. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  4741. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  4742. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  4743. {
  4744. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4745. /* .name = "Capture Source", */
  4746. .name = "Input Source",
  4747. .count = 2,
  4748. .info = alc883_mux_enum_info,
  4749. .get = alc883_mux_enum_get,
  4750. .put = alc883_mux_enum_put,
  4751. },
  4752. { } /* end */
  4753. };
  4754. static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
  4755. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4756. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  4757. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4758. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4759. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4760. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4761. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4762. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  4763. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  4764. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  4765. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  4766. {
  4767. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4768. /* .name = "Capture Source", */
  4769. .name = "Input Source",
  4770. .count = 2,
  4771. .info = alc883_mux_enum_info,
  4772. .get = alc883_mux_enum_get,
  4773. .put = alc883_mux_enum_put,
  4774. },
  4775. { } /* end */
  4776. };
  4777. static struct snd_kcontrol_new alc883_chmode_mixer[] = {
  4778. {
  4779. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4780. .name = "Channel Mode",
  4781. .info = alc_ch_mode_info,
  4782. .get = alc_ch_mode_get,
  4783. .put = alc_ch_mode_put,
  4784. },
  4785. { } /* end */
  4786. };
  4787. static struct hda_verb alc883_init_verbs[] = {
  4788. /* ADC1: mute amp left and right */
  4789. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4790. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4791. /* ADC2: mute amp left and right */
  4792. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4793. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4794. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  4795. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4796. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4797. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4798. /* Rear mixer */
  4799. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4800. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4801. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4802. /* CLFE mixer */
  4803. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4804. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4805. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4806. /* Side mixer */
  4807. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4808. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4809. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4810. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4811. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4812. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4813. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  4814. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  4815. /* Front Pin: output 0 (0x0c) */
  4816. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4817. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4818. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  4819. /* Rear Pin: output 1 (0x0d) */
  4820. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4821. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4822. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  4823. /* CLFE Pin: output 2 (0x0e) */
  4824. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4825. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4826. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  4827. /* Side Pin: output 3 (0x0f) */
  4828. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4829. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4830. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  4831. /* Mic (rear) pin: input vref at 80% */
  4832. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4833. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4834. /* Front Mic pin: input vref at 80% */
  4835. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4836. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4837. /* Line In pin: input */
  4838. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4839. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4840. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  4841. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4842. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4843. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  4844. /* CD pin widget for input */
  4845. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4846. /* FIXME: use matrix-type input source selection */
  4847. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4848. /* Input mixer2 */
  4849. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4850. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4851. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4852. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  4853. /* Input mixer3 */
  4854. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4855. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4856. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4857. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  4858. { }
  4859. };
  4860. static struct hda_verb alc883_tagra_verbs[] = {
  4861. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4862. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4863. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4864. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4865. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  4866. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  4867. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  4868. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  4869. {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
  4870. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
  4871. {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
  4872. { } /* end */
  4873. };
  4874. /* toggle speaker-output according to the hp-jack state */
  4875. static void alc883_tagra_automute(struct hda_codec *codec)
  4876. {
  4877. unsigned int present;
  4878. present = snd_hda_codec_read(codec, 0x14, 0,
  4879. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  4880. snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
  4881. 0x80, present ? 0x80 : 0);
  4882. snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
  4883. 0x80, present ? 0x80 : 0);
  4884. snd_hda_codec_write(codec, 1, 0, AC_VERB_SET_GPIO_DATA, present ? 1 : 3);
  4885. }
  4886. static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
  4887. {
  4888. if ((res >> 26) == ALC880_HP_EVENT)
  4889. alc883_tagra_automute(codec);
  4890. }
  4891. /*
  4892. * generic initialization of ADC, input mixers and output mixers
  4893. */
  4894. static struct hda_verb alc883_auto_init_verbs[] = {
  4895. /*
  4896. * Unmute ADC0-2 and set the default input to mic-in
  4897. */
  4898. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4899. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4900. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4901. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4902. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  4903. * mixer widget
  4904. * Note: PASD motherboards uses the Line In 2 as the input for front panel
  4905. * mic (mic 2)
  4906. */
  4907. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  4908. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4909. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4910. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4911. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  4912. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  4913. /*
  4914. * Set up output mixers (0x0c - 0x0f)
  4915. */
  4916. /* set vol=0 to output mixers */
  4917. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4918. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4919. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4920. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4921. /* set up input amps for analog loopback */
  4922. /* Amp Indices: DAC = 0, mixer = 1 */
  4923. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4924. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4925. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4926. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4927. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4928. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4929. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4930. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4931. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4932. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4933. /* FIXME: use matrix-type input source selection */
  4934. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4935. /* Input mixer1 */
  4936. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4937. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4938. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4939. //{0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  4940. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  4941. /* Input mixer2 */
  4942. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4943. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4944. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4945. //{0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  4946. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  4947. { }
  4948. };
  4949. /* capture mixer elements */
  4950. static struct snd_kcontrol_new alc883_capture_mixer[] = {
  4951. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  4952. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  4953. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  4954. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  4955. {
  4956. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4957. /* The multiple "Capture Source" controls confuse alsamixer
  4958. * So call somewhat different..
  4959. * FIXME: the controls appear in the "playback" view!
  4960. */
  4961. /* .name = "Capture Source", */
  4962. .name = "Input Source",
  4963. .count = 2,
  4964. .info = alc882_mux_enum_info,
  4965. .get = alc882_mux_enum_get,
  4966. .put = alc882_mux_enum_put,
  4967. },
  4968. { } /* end */
  4969. };
  4970. /* pcm configuration: identiacal with ALC880 */
  4971. #define alc883_pcm_analog_playback alc880_pcm_analog_playback
  4972. #define alc883_pcm_analog_capture alc880_pcm_analog_capture
  4973. #define alc883_pcm_digital_playback alc880_pcm_digital_playback
  4974. #define alc883_pcm_digital_capture alc880_pcm_digital_capture
  4975. /*
  4976. * configuration and preset
  4977. */
  4978. static const char *alc883_models[ALC883_MODEL_LAST] = {
  4979. [ALC883_3ST_2ch_DIG] = "3stack-dig",
  4980. [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
  4981. [ALC883_3ST_6ch] = "3stack-6ch",
  4982. [ALC883_6ST_DIG] = "6stack-dig",
  4983. [ALC883_TARGA_DIG] = "targa-dig",
  4984. [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
  4985. [ALC888_DEMO_BOARD] = "6stack-dig-demo",
  4986. [ALC883_ACER] = "acer",
  4987. [ALC883_MEDION] = "medion",
  4988. [ALC883_LAPTOP_EAPD] = "laptop-eapd",
  4989. [ALC883_AUTO] = "auto",
  4990. };
  4991. static struct snd_pci_quirk alc883_cfg_tbl[] = {
  4992. SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
  4993. SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
  4994. SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
  4995. SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
  4996. SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
  4997. SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
  4998. SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
  4999. SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
  5000. SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
  5001. SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
  5002. SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
  5003. SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
  5004. SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
  5005. SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
  5006. SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
  5007. SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
  5008. SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER),
  5009. SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
  5010. SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
  5011. SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
  5012. {}
  5013. };
  5014. static struct alc_config_preset alc883_presets[] = {
  5015. [ALC883_3ST_2ch_DIG] = {
  5016. .mixers = { alc883_3ST_2ch_mixer },
  5017. .init_verbs = { alc883_init_verbs },
  5018. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5019. .dac_nids = alc883_dac_nids,
  5020. .dig_out_nid = ALC883_DIGOUT_NID,
  5021. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5022. .adc_nids = alc883_adc_nids,
  5023. .dig_in_nid = ALC883_DIGIN_NID,
  5024. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  5025. .channel_mode = alc883_3ST_2ch_modes,
  5026. .input_mux = &alc883_capture_source,
  5027. },
  5028. [ALC883_3ST_6ch_DIG] = {
  5029. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  5030. .init_verbs = { alc883_init_verbs },
  5031. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5032. .dac_nids = alc883_dac_nids,
  5033. .dig_out_nid = ALC883_DIGOUT_NID,
  5034. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5035. .adc_nids = alc883_adc_nids,
  5036. .dig_in_nid = ALC883_DIGIN_NID,
  5037. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  5038. .channel_mode = alc883_3ST_6ch_modes,
  5039. .need_dac_fix = 1,
  5040. .input_mux = &alc883_capture_source,
  5041. },
  5042. [ALC883_3ST_6ch] = {
  5043. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  5044. .init_verbs = { alc883_init_verbs },
  5045. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5046. .dac_nids = alc883_dac_nids,
  5047. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5048. .adc_nids = alc883_adc_nids,
  5049. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  5050. .channel_mode = alc883_3ST_6ch_modes,
  5051. .need_dac_fix = 1,
  5052. .input_mux = &alc883_capture_source,
  5053. },
  5054. [ALC883_6ST_DIG] = {
  5055. .mixers = { alc883_base_mixer, alc883_chmode_mixer },
  5056. .init_verbs = { alc883_init_verbs },
  5057. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5058. .dac_nids = alc883_dac_nids,
  5059. .dig_out_nid = ALC883_DIGOUT_NID,
  5060. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5061. .adc_nids = alc883_adc_nids,
  5062. .dig_in_nid = ALC883_DIGIN_NID,
  5063. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  5064. .channel_mode = alc883_sixstack_modes,
  5065. .input_mux = &alc883_capture_source,
  5066. },
  5067. [ALC883_TARGA_DIG] = {
  5068. .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
  5069. .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
  5070. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5071. .dac_nids = alc883_dac_nids,
  5072. .dig_out_nid = ALC883_DIGOUT_NID,
  5073. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5074. .adc_nids = alc883_adc_nids,
  5075. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  5076. .channel_mode = alc883_3ST_6ch_modes,
  5077. .need_dac_fix = 1,
  5078. .input_mux = &alc883_capture_source,
  5079. .unsol_event = alc883_tagra_unsol_event,
  5080. .init_hook = alc883_tagra_automute,
  5081. },
  5082. [ALC883_TARGA_2ch_DIG] = {
  5083. .mixers = { alc883_tagra_2ch_mixer},
  5084. .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
  5085. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5086. .dac_nids = alc883_dac_nids,
  5087. .dig_out_nid = ALC883_DIGOUT_NID,
  5088. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5089. .adc_nids = alc883_adc_nids,
  5090. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  5091. .channel_mode = alc883_3ST_2ch_modes,
  5092. .input_mux = &alc883_capture_source,
  5093. .unsol_event = alc883_tagra_unsol_event,
  5094. .init_hook = alc883_tagra_automute,
  5095. },
  5096. [ALC888_DEMO_BOARD] = {
  5097. .mixers = { alc883_base_mixer, alc883_chmode_mixer },
  5098. .init_verbs = { alc883_init_verbs },
  5099. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5100. .dac_nids = alc883_dac_nids,
  5101. .dig_out_nid = ALC883_DIGOUT_NID,
  5102. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5103. .adc_nids = alc883_adc_nids,
  5104. .dig_in_nid = ALC883_DIGIN_NID,
  5105. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  5106. .channel_mode = alc883_sixstack_modes,
  5107. .input_mux = &alc883_capture_source,
  5108. },
  5109. [ALC883_ACER] = {
  5110. .mixers = { alc883_base_mixer,
  5111. alc883_chmode_mixer },
  5112. /* On TravelMate laptops, GPIO 0 enables the internal speaker
  5113. * and the headphone jack. Turn this on and rely on the
  5114. * standard mute methods whenever the user wants to turn
  5115. * these outputs off.
  5116. */
  5117. .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
  5118. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5119. .dac_nids = alc883_dac_nids,
  5120. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5121. .adc_nids = alc883_adc_nids,
  5122. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  5123. .channel_mode = alc883_3ST_2ch_modes,
  5124. .input_mux = &alc883_capture_source,
  5125. },
  5126. [ALC883_MEDION] = {
  5127. .mixers = { alc883_fivestack_mixer,
  5128. alc883_chmode_mixer },
  5129. .init_verbs = { alc883_init_verbs,
  5130. alc883_medion_eapd_verbs },
  5131. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5132. .dac_nids = alc883_dac_nids,
  5133. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5134. .adc_nids = alc883_adc_nids,
  5135. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  5136. .channel_mode = alc883_sixstack_modes,
  5137. .input_mux = &alc883_capture_source,
  5138. },
  5139. [ALC883_LAPTOP_EAPD] = {
  5140. .mixers = { alc883_base_mixer,
  5141. alc883_chmode_mixer },
  5142. .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
  5143. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5144. .dac_nids = alc883_dac_nids,
  5145. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5146. .adc_nids = alc883_adc_nids,
  5147. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  5148. .channel_mode = alc883_3ST_2ch_modes,
  5149. .input_mux = &alc883_capture_source,
  5150. },
  5151. };
  5152. /*
  5153. * BIOS auto configuration
  5154. */
  5155. static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
  5156. hda_nid_t nid, int pin_type,
  5157. int dac_idx)
  5158. {
  5159. /* set as output */
  5160. struct alc_spec *spec = codec->spec;
  5161. int idx;
  5162. if (spec->multiout.dac_nids[dac_idx] == 0x25)
  5163. idx = 4;
  5164. else
  5165. idx = spec->multiout.dac_nids[dac_idx] - 2;
  5166. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  5167. pin_type);
  5168. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  5169. AMP_OUT_UNMUTE);
  5170. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
  5171. }
  5172. static void alc883_auto_init_multi_out(struct hda_codec *codec)
  5173. {
  5174. struct alc_spec *spec = codec->spec;
  5175. int i;
  5176. for (i = 0; i <= HDA_SIDE; i++) {
  5177. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  5178. if (nid)
  5179. alc883_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
  5180. }
  5181. }
  5182. static void alc883_auto_init_hp_out(struct hda_codec *codec)
  5183. {
  5184. struct alc_spec *spec = codec->spec;
  5185. hda_nid_t pin;
  5186. pin = spec->autocfg.hp_pins[0];
  5187. if (pin) /* connect to front */
  5188. /* use dac 0 */
  5189. alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  5190. }
  5191. #define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
  5192. #define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
  5193. static void alc883_auto_init_analog_input(struct hda_codec *codec)
  5194. {
  5195. struct alc_spec *spec = codec->spec;
  5196. int i;
  5197. for (i = 0; i < AUTO_PIN_LAST; i++) {
  5198. hda_nid_t nid = spec->autocfg.input_pins[i];
  5199. if (alc883_is_input_pin(nid)) {
  5200. snd_hda_codec_write(codec, nid, 0,
  5201. AC_VERB_SET_PIN_WIDGET_CONTROL,
  5202. (i <= AUTO_PIN_FRONT_MIC ?
  5203. PIN_VREF80 : PIN_IN));
  5204. if (nid != ALC883_PIN_CD_NID)
  5205. snd_hda_codec_write(codec, nid, 0,
  5206. AC_VERB_SET_AMP_GAIN_MUTE,
  5207. AMP_OUT_MUTE);
  5208. }
  5209. }
  5210. }
  5211. /* almost identical with ALC880 parser... */
  5212. static int alc883_parse_auto_config(struct hda_codec *codec)
  5213. {
  5214. struct alc_spec *spec = codec->spec;
  5215. int err = alc880_parse_auto_config(codec);
  5216. if (err < 0)
  5217. return err;
  5218. else if (err > 0)
  5219. /* hack - override the init verbs */
  5220. spec->init_verbs[0] = alc883_auto_init_verbs;
  5221. spec->mixers[spec->num_mixers] = alc883_capture_mixer;
  5222. spec->num_mixers++;
  5223. return err;
  5224. }
  5225. /* additional initialization for auto-configuration model */
  5226. static void alc883_auto_init(struct hda_codec *codec)
  5227. {
  5228. alc883_auto_init_multi_out(codec);
  5229. alc883_auto_init_hp_out(codec);
  5230. alc883_auto_init_analog_input(codec);
  5231. }
  5232. static int patch_alc883(struct hda_codec *codec)
  5233. {
  5234. struct alc_spec *spec;
  5235. int err, board_config;
  5236. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  5237. if (spec == NULL)
  5238. return -ENOMEM;
  5239. codec->spec = spec;
  5240. board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
  5241. alc883_models,
  5242. alc883_cfg_tbl);
  5243. if (board_config < 0) {
  5244. printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
  5245. "trying auto-probe from BIOS...\n");
  5246. board_config = ALC883_AUTO;
  5247. }
  5248. if (board_config == ALC883_AUTO) {
  5249. /* automatic parse from the BIOS config */
  5250. err = alc883_parse_auto_config(codec);
  5251. if (err < 0) {
  5252. alc_free(codec);
  5253. return err;
  5254. } else if (! err) {
  5255. printk(KERN_INFO
  5256. "hda_codec: Cannot set up configuration "
  5257. "from BIOS. Using base mode...\n");
  5258. board_config = ALC883_3ST_2ch_DIG;
  5259. }
  5260. }
  5261. if (board_config != ALC883_AUTO)
  5262. setup_preset(spec, &alc883_presets[board_config]);
  5263. spec->stream_name_analog = "ALC883 Analog";
  5264. spec->stream_analog_playback = &alc883_pcm_analog_playback;
  5265. spec->stream_analog_capture = &alc883_pcm_analog_capture;
  5266. spec->stream_name_digital = "ALC883 Digital";
  5267. spec->stream_digital_playback = &alc883_pcm_digital_playback;
  5268. spec->stream_digital_capture = &alc883_pcm_digital_capture;
  5269. if (! spec->adc_nids && spec->input_mux) {
  5270. spec->adc_nids = alc883_adc_nids;
  5271. spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
  5272. }
  5273. codec->patch_ops = alc_patch_ops;
  5274. if (board_config == ALC883_AUTO)
  5275. spec->init_hook = alc883_auto_init;
  5276. return 0;
  5277. }
  5278. /*
  5279. * ALC262 support
  5280. */
  5281. #define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
  5282. #define ALC262_DIGIN_NID ALC880_DIGIN_NID
  5283. #define alc262_dac_nids alc260_dac_nids
  5284. #define alc262_adc_nids alc882_adc_nids
  5285. #define alc262_adc_nids_alt alc882_adc_nids_alt
  5286. #define alc262_modes alc260_modes
  5287. #define alc262_capture_source alc882_capture_source
  5288. static struct snd_kcontrol_new alc262_base_mixer[] = {
  5289. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5290. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5291. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5292. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5293. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5294. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5295. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5296. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5297. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  5298. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  5299. /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5300. HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
  5301. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
  5302. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  5303. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5304. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  5305. { } /* end */
  5306. };
  5307. static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
  5308. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5309. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5310. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5311. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5312. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5313. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5314. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5315. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5316. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  5317. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  5318. /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5319. HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
  5320. /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
  5321. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5322. { } /* end */
  5323. };
  5324. static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
  5325. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5326. HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  5327. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5328. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5329. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  5330. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5331. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5332. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  5333. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  5334. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5335. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5336. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5337. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5338. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5339. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5340. HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
  5341. HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
  5342. { } /* end */
  5343. };
  5344. #define alc262_capture_mixer alc882_capture_mixer
  5345. #define alc262_capture_alt_mixer alc882_capture_alt_mixer
  5346. /*
  5347. * generic initialization of ADC, input mixers and output mixers
  5348. */
  5349. static struct hda_verb alc262_init_verbs[] = {
  5350. /*
  5351. * Unmute ADC0-2 and set the default input to mic-in
  5352. */
  5353. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  5354. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5355. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  5356. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5357. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  5358. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5359. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  5360. * mixer widget
  5361. * Note: PASD motherboards uses the Line In 2 as the input for front panel
  5362. * mic (mic 2)
  5363. */
  5364. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  5365. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5366. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5367. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5368. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  5369. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5370. /*
  5371. * Set up output mixers (0x0c - 0x0e)
  5372. */
  5373. /* set vol=0 to output mixers */
  5374. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5375. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5376. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5377. /* set up input amps for analog loopback */
  5378. /* Amp Indices: DAC = 0, mixer = 1 */
  5379. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5380. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5381. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5382. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5383. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5384. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5385. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  5386. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  5387. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  5388. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  5389. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  5390. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  5391. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  5392. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  5393. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  5394. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  5395. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  5396. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  5397. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  5398. /* FIXME: use matrix-type input source selection */
  5399. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  5400. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  5401. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  5402. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  5403. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  5404. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  5405. /* Input mixer2 */
  5406. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  5407. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  5408. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  5409. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  5410. /* Input mixer3 */
  5411. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  5412. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  5413. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  5414. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  5415. { }
  5416. };
  5417. static struct hda_verb alc262_hippo_unsol_verbs[] = {
  5418. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  5419. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5420. {}
  5421. };
  5422. static struct hda_verb alc262_hippo1_unsol_verbs[] = {
  5423. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  5424. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  5425. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  5426. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  5427. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5428. {}
  5429. };
  5430. /* mute/unmute internal speaker according to the hp jack and mute state */
  5431. static void alc262_hippo_automute(struct hda_codec *codec, int force)
  5432. {
  5433. struct alc_spec *spec = codec->spec;
  5434. unsigned int mute;
  5435. if (force || ! spec->sense_updated) {
  5436. unsigned int present;
  5437. /* need to execute and sync at first */
  5438. snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
  5439. present = snd_hda_codec_read(codec, 0x15, 0,
  5440. AC_VERB_GET_PIN_SENSE, 0);
  5441. spec->jack_present = (present & 0x80000000) != 0;
  5442. spec->sense_updated = 1;
  5443. }
  5444. if (spec->jack_present) {
  5445. /* mute internal speaker */
  5446. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  5447. 0x80, 0x80);
  5448. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  5449. 0x80, 0x80);
  5450. } else {
  5451. /* unmute internal speaker if necessary */
  5452. mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
  5453. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  5454. 0x80, mute & 0x80);
  5455. mute = snd_hda_codec_amp_read(codec, 0x15, 1, HDA_OUTPUT, 0);
  5456. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  5457. 0x80, mute & 0x80);
  5458. }
  5459. }
  5460. /* unsolicited event for HP jack sensing */
  5461. static void alc262_hippo_unsol_event(struct hda_codec *codec,
  5462. unsigned int res)
  5463. {
  5464. if ((res >> 26) != ALC880_HP_EVENT)
  5465. return;
  5466. alc262_hippo_automute(codec, 1);
  5467. }
  5468. static void alc262_hippo1_automute(struct hda_codec *codec, int force)
  5469. {
  5470. struct alc_spec *spec = codec->spec;
  5471. unsigned int mute;
  5472. if (force || ! spec->sense_updated) {
  5473. unsigned int present;
  5474. /* need to execute and sync at first */
  5475. snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
  5476. present = snd_hda_codec_read(codec, 0x1b, 0,
  5477. AC_VERB_GET_PIN_SENSE, 0);
  5478. spec->jack_present = (present & 0x80000000) != 0;
  5479. spec->sense_updated = 1;
  5480. }
  5481. if (spec->jack_present) {
  5482. /* mute internal speaker */
  5483. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  5484. 0x80, 0x80);
  5485. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  5486. 0x80, 0x80);
  5487. } else {
  5488. /* unmute internal speaker if necessary */
  5489. mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
  5490. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  5491. 0x80, mute & 0x80);
  5492. mute = snd_hda_codec_amp_read(codec, 0x1b, 1, HDA_OUTPUT, 0);
  5493. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  5494. 0x80, mute & 0x80);
  5495. }
  5496. }
  5497. /* unsolicited event for HP jack sensing */
  5498. static void alc262_hippo1_unsol_event(struct hda_codec *codec,
  5499. unsigned int res)
  5500. {
  5501. if ((res >> 26) != ALC880_HP_EVENT)
  5502. return;
  5503. alc262_hippo1_automute(codec, 1);
  5504. }
  5505. /*
  5506. * fujitsu model
  5507. * 0x14 = headphone/spdif-out, 0x15 = internal speaker
  5508. */
  5509. #define ALC_HP_EVENT 0x37
  5510. static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
  5511. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
  5512. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5513. {}
  5514. };
  5515. static struct hda_input_mux alc262_fujitsu_capture_source = {
  5516. .num_items = 2,
  5517. .items = {
  5518. { "Mic", 0x0 },
  5519. { "CD", 0x4 },
  5520. },
  5521. };
  5522. static struct hda_input_mux alc262_HP_capture_source = {
  5523. .num_items = 5,
  5524. .items = {
  5525. { "Mic", 0x0 },
  5526. { "Front Mic", 0x3 },
  5527. { "Line", 0x2 },
  5528. { "CD", 0x4 },
  5529. { "AUX IN", 0x6 },
  5530. },
  5531. };
  5532. /* mute/unmute internal speaker according to the hp jack and mute state */
  5533. static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
  5534. {
  5535. struct alc_spec *spec = codec->spec;
  5536. unsigned int mute;
  5537. if (force || ! spec->sense_updated) {
  5538. unsigned int present;
  5539. /* need to execute and sync at first */
  5540. snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
  5541. present = snd_hda_codec_read(codec, 0x14, 0,
  5542. AC_VERB_GET_PIN_SENSE, 0);
  5543. spec->jack_present = (present & 0x80000000) != 0;
  5544. spec->sense_updated = 1;
  5545. }
  5546. if (spec->jack_present) {
  5547. /* mute internal speaker */
  5548. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  5549. 0x80, 0x80);
  5550. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  5551. 0x80, 0x80);
  5552. } else {
  5553. /* unmute internal speaker if necessary */
  5554. mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
  5555. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  5556. 0x80, mute & 0x80);
  5557. mute = snd_hda_codec_amp_read(codec, 0x14, 1, HDA_OUTPUT, 0);
  5558. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  5559. 0x80, mute & 0x80);
  5560. }
  5561. }
  5562. /* unsolicited event for HP jack sensing */
  5563. static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
  5564. unsigned int res)
  5565. {
  5566. if ((res >> 26) != ALC_HP_EVENT)
  5567. return;
  5568. alc262_fujitsu_automute(codec, 1);
  5569. }
  5570. /* bind volumes of both NID 0x0c and 0x0d */
  5571. static int alc262_fujitsu_master_vol_put(struct snd_kcontrol *kcontrol,
  5572. struct snd_ctl_elem_value *ucontrol)
  5573. {
  5574. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  5575. long *valp = ucontrol->value.integer.value;
  5576. int change;
  5577. change = snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
  5578. 0x7f, valp[0] & 0x7f);
  5579. change |= snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
  5580. 0x7f, valp[1] & 0x7f);
  5581. snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
  5582. 0x7f, valp[0] & 0x7f);
  5583. snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
  5584. 0x7f, valp[1] & 0x7f);
  5585. return change;
  5586. }
  5587. /* bind hp and internal speaker mute (with plug check) */
  5588. static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
  5589. struct snd_ctl_elem_value *ucontrol)
  5590. {
  5591. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  5592. long *valp = ucontrol->value.integer.value;
  5593. int change;
  5594. change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  5595. 0x80, valp[0] ? 0 : 0x80);
  5596. change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  5597. 0x80, valp[1] ? 0 : 0x80);
  5598. if (change || codec->in_resume)
  5599. alc262_fujitsu_automute(codec, codec->in_resume);
  5600. return change;
  5601. }
  5602. static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
  5603. {
  5604. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5605. .name = "Master Playback Volume",
  5606. .info = snd_hda_mixer_amp_volume_info,
  5607. .get = snd_hda_mixer_amp_volume_get,
  5608. .put = alc262_fujitsu_master_vol_put,
  5609. .tlv = { .c = snd_hda_mixer_amp_tlv },
  5610. .private_value = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
  5611. },
  5612. {
  5613. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5614. .name = "Master Playback Switch",
  5615. .info = snd_hda_mixer_amp_switch_info,
  5616. .get = snd_hda_mixer_amp_switch_get,
  5617. .put = alc262_fujitsu_master_sw_put,
  5618. .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
  5619. },
  5620. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5621. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5622. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5623. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5624. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5625. { } /* end */
  5626. };
  5627. /* additional init verbs for Benq laptops */
  5628. static struct hda_verb alc262_EAPD_verbs[] = {
  5629. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  5630. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  5631. {}
  5632. };
  5633. /* add playback controls from the parsed DAC table */
  5634. static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
  5635. {
  5636. hda_nid_t nid;
  5637. int err;
  5638. spec->multiout.num_dacs = 1; /* only use one dac */
  5639. spec->multiout.dac_nids = spec->private_dac_nids;
  5640. spec->multiout.dac_nids[0] = 2;
  5641. nid = cfg->line_out_pins[0];
  5642. if (nid) {
  5643. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Front Playback Volume",
  5644. HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT))) < 0)
  5645. return err;
  5646. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Front Playback Switch",
  5647. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  5648. return err;
  5649. }
  5650. nid = cfg->speaker_pins[0];
  5651. if (nid) {
  5652. if (nid == 0x16) {
  5653. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Speaker Playback Volume",
  5654. HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0)
  5655. return err;
  5656. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch",
  5657. HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
  5658. return err;
  5659. } else {
  5660. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch",
  5661. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  5662. return err;
  5663. }
  5664. }
  5665. nid = cfg->hp_pins[0];
  5666. if (nid) {
  5667. /* spec->multiout.hp_nid = 2; */
  5668. if (nid == 0x16) {
  5669. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Headphone Playback Volume",
  5670. HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0)
  5671. return err;
  5672. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
  5673. HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
  5674. return err;
  5675. } else {
  5676. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
  5677. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  5678. return err;
  5679. }
  5680. }
  5681. return 0;
  5682. }
  5683. /* identical with ALC880 */
  5684. #define alc262_auto_create_analog_input_ctls alc880_auto_create_analog_input_ctls
  5685. /*
  5686. * generic initialization of ADC, input mixers and output mixers
  5687. */
  5688. static struct hda_verb alc262_volume_init_verbs[] = {
  5689. /*
  5690. * Unmute ADC0-2 and set the default input to mic-in
  5691. */
  5692. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  5693. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5694. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  5695. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5696. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  5697. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5698. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  5699. * mixer widget
  5700. * Note: PASD motherboards uses the Line In 2 as the input for front panel
  5701. * mic (mic 2)
  5702. */
  5703. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  5704. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5705. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5706. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5707. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  5708. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5709. /*
  5710. * Set up output mixers (0x0c - 0x0f)
  5711. */
  5712. /* set vol=0 to output mixers */
  5713. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5714. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5715. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5716. /* set up input amps for analog loopback */
  5717. /* Amp Indices: DAC = 0, mixer = 1 */
  5718. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5719. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5720. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5721. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5722. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5723. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5724. /* FIXME: use matrix-type input source selection */
  5725. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  5726. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  5727. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  5728. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  5729. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  5730. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  5731. /* Input mixer2 */
  5732. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  5733. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  5734. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  5735. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  5736. /* Input mixer3 */
  5737. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  5738. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  5739. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  5740. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  5741. { }
  5742. };
  5743. static struct hda_verb alc262_HP_BPC_init_verbs[] = {
  5744. /*
  5745. * Unmute ADC0-2 and set the default input to mic-in
  5746. */
  5747. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  5748. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5749. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  5750. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5751. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  5752. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5753. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  5754. * mixer widget
  5755. * Note: PASD motherboards uses the Line In 2 as the input for front panel
  5756. * mic (mic 2)
  5757. */
  5758. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  5759. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5760. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5761. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5762. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  5763. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5764. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
  5765. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
  5766. /*
  5767. * Set up output mixers (0x0c - 0x0e)
  5768. */
  5769. /* set vol=0 to output mixers */
  5770. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5771. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5772. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5773. /* set up input amps for analog loopback */
  5774. /* Amp Indices: DAC = 0, mixer = 1 */
  5775. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5776. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5777. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5778. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5779. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5780. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5781. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  5782. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5783. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5784. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5785. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5786. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  5787. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  5788. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  5789. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  5790. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  5791. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  5792. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  5793. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  5794. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  5795. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  5796. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  5797. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  5798. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  5799. /* FIXME: use matrix-type input source selection */
  5800. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  5801. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  5802. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  5803. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  5804. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  5805. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  5806. /* Input mixer2 */
  5807. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  5808. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  5809. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  5810. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  5811. /* Input mixer3 */
  5812. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  5813. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  5814. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  5815. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  5816. { }
  5817. };
  5818. /* pcm configuration: identiacal with ALC880 */
  5819. #define alc262_pcm_analog_playback alc880_pcm_analog_playback
  5820. #define alc262_pcm_analog_capture alc880_pcm_analog_capture
  5821. #define alc262_pcm_digital_playback alc880_pcm_digital_playback
  5822. #define alc262_pcm_digital_capture alc880_pcm_digital_capture
  5823. /*
  5824. * BIOS auto configuration
  5825. */
  5826. static int alc262_parse_auto_config(struct hda_codec *codec)
  5827. {
  5828. struct alc_spec *spec = codec->spec;
  5829. int err;
  5830. static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
  5831. if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  5832. alc262_ignore)) < 0)
  5833. return err;
  5834. if (! spec->autocfg.line_outs)
  5835. return 0; /* can't find valid BIOS pin config */
  5836. if ((err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
  5837. (err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
  5838. return err;
  5839. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  5840. if (spec->autocfg.dig_out_pin)
  5841. spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
  5842. if (spec->autocfg.dig_in_pin)
  5843. spec->dig_in_nid = ALC262_DIGIN_NID;
  5844. if (spec->kctl_alloc)
  5845. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  5846. spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
  5847. spec->num_mux_defs = 1;
  5848. spec->input_mux = &spec->private_imux;
  5849. return 1;
  5850. }
  5851. #define alc262_auto_init_multi_out alc882_auto_init_multi_out
  5852. #define alc262_auto_init_hp_out alc882_auto_init_hp_out
  5853. #define alc262_auto_init_analog_input alc882_auto_init_analog_input
  5854. /* init callback for auto-configuration model -- overriding the default init */
  5855. static void alc262_auto_init(struct hda_codec *codec)
  5856. {
  5857. alc262_auto_init_multi_out(codec);
  5858. alc262_auto_init_hp_out(codec);
  5859. alc262_auto_init_analog_input(codec);
  5860. }
  5861. /*
  5862. * configuration and preset
  5863. */
  5864. static const char *alc262_models[ALC262_MODEL_LAST] = {
  5865. [ALC262_BASIC] = "basic",
  5866. [ALC262_HIPPO] = "hippo",
  5867. [ALC262_HIPPO_1] = "hippo_1",
  5868. [ALC262_FUJITSU] = "fujitsu",
  5869. [ALC262_HP_BPC] = "hp-bpc",
  5870. [ALC262_BENQ_ED8] = "benq",
  5871. [ALC262_AUTO] = "auto",
  5872. };
  5873. static struct snd_pci_quirk alc262_cfg_tbl[] = {
  5874. SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
  5875. SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
  5876. SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
  5877. SND_PCI_QUIRK(0x103c, 0x2801, "HP q954", ALC262_HP_BPC),
  5878. SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
  5879. SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
  5880. SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
  5881. SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
  5882. SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
  5883. SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
  5884. {}
  5885. };
  5886. static struct alc_config_preset alc262_presets[] = {
  5887. [ALC262_BASIC] = {
  5888. .mixers = { alc262_base_mixer },
  5889. .init_verbs = { alc262_init_verbs },
  5890. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  5891. .dac_nids = alc262_dac_nids,
  5892. .hp_nid = 0x03,
  5893. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  5894. .channel_mode = alc262_modes,
  5895. .input_mux = &alc262_capture_source,
  5896. },
  5897. [ALC262_HIPPO] = {
  5898. .mixers = { alc262_base_mixer },
  5899. .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
  5900. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  5901. .dac_nids = alc262_dac_nids,
  5902. .hp_nid = 0x03,
  5903. .dig_out_nid = ALC262_DIGOUT_NID,
  5904. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  5905. .channel_mode = alc262_modes,
  5906. .input_mux = &alc262_capture_source,
  5907. .unsol_event = alc262_hippo_unsol_event,
  5908. },
  5909. [ALC262_HIPPO_1] = {
  5910. .mixers = { alc262_hippo1_mixer },
  5911. .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
  5912. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  5913. .dac_nids = alc262_dac_nids,
  5914. .hp_nid = 0x02,
  5915. .dig_out_nid = ALC262_DIGOUT_NID,
  5916. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  5917. .channel_mode = alc262_modes,
  5918. .input_mux = &alc262_capture_source,
  5919. .unsol_event = alc262_hippo1_unsol_event,
  5920. },
  5921. [ALC262_FUJITSU] = {
  5922. .mixers = { alc262_fujitsu_mixer },
  5923. .init_verbs = { alc262_init_verbs, alc262_fujitsu_unsol_verbs },
  5924. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  5925. .dac_nids = alc262_dac_nids,
  5926. .hp_nid = 0x03,
  5927. .dig_out_nid = ALC262_DIGOUT_NID,
  5928. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  5929. .channel_mode = alc262_modes,
  5930. .input_mux = &alc262_fujitsu_capture_source,
  5931. .unsol_event = alc262_fujitsu_unsol_event,
  5932. },
  5933. [ALC262_HP_BPC] = {
  5934. .mixers = { alc262_HP_BPC_mixer },
  5935. .init_verbs = { alc262_HP_BPC_init_verbs },
  5936. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  5937. .dac_nids = alc262_dac_nids,
  5938. .hp_nid = 0x03,
  5939. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  5940. .channel_mode = alc262_modes,
  5941. .input_mux = &alc262_HP_capture_source,
  5942. },
  5943. [ALC262_BENQ_ED8] = {
  5944. .mixers = { alc262_base_mixer },
  5945. .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
  5946. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  5947. .dac_nids = alc262_dac_nids,
  5948. .hp_nid = 0x03,
  5949. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  5950. .channel_mode = alc262_modes,
  5951. .input_mux = &alc262_capture_source,
  5952. },
  5953. };
  5954. static int patch_alc262(struct hda_codec *codec)
  5955. {
  5956. struct alc_spec *spec;
  5957. int board_config;
  5958. int err;
  5959. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  5960. if (spec == NULL)
  5961. return -ENOMEM;
  5962. codec->spec = spec;
  5963. #if 0
  5964. /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is under-run */
  5965. {
  5966. int tmp;
  5967. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  5968. tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
  5969. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  5970. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
  5971. }
  5972. #endif
  5973. board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
  5974. alc262_models,
  5975. alc262_cfg_tbl);
  5976. if (board_config < 0) {
  5977. printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
  5978. "trying auto-probe from BIOS...\n");
  5979. board_config = ALC262_AUTO;
  5980. }
  5981. if (board_config == ALC262_AUTO) {
  5982. /* automatic parse from the BIOS config */
  5983. err = alc262_parse_auto_config(codec);
  5984. if (err < 0) {
  5985. alc_free(codec);
  5986. return err;
  5987. } else if (! err) {
  5988. printk(KERN_INFO
  5989. "hda_codec: Cannot set up configuration "
  5990. "from BIOS. Using base mode...\n");
  5991. board_config = ALC262_BASIC;
  5992. }
  5993. }
  5994. if (board_config != ALC262_AUTO)
  5995. setup_preset(spec, &alc262_presets[board_config]);
  5996. spec->stream_name_analog = "ALC262 Analog";
  5997. spec->stream_analog_playback = &alc262_pcm_analog_playback;
  5998. spec->stream_analog_capture = &alc262_pcm_analog_capture;
  5999. spec->stream_name_digital = "ALC262 Digital";
  6000. spec->stream_digital_playback = &alc262_pcm_digital_playback;
  6001. spec->stream_digital_capture = &alc262_pcm_digital_capture;
  6002. if (! spec->adc_nids && spec->input_mux) {
  6003. /* check whether NID 0x07 is valid */
  6004. unsigned int wcap = get_wcaps(codec, 0x07);
  6005. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
  6006. if (wcap != AC_WID_AUD_IN) {
  6007. spec->adc_nids = alc262_adc_nids_alt;
  6008. spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
  6009. spec->mixers[spec->num_mixers] = alc262_capture_alt_mixer;
  6010. spec->num_mixers++;
  6011. } else {
  6012. spec->adc_nids = alc262_adc_nids;
  6013. spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
  6014. spec->mixers[spec->num_mixers] = alc262_capture_mixer;
  6015. spec->num_mixers++;
  6016. }
  6017. }
  6018. codec->patch_ops = alc_patch_ops;
  6019. if (board_config == ALC262_AUTO)
  6020. spec->init_hook = alc262_auto_init;
  6021. return 0;
  6022. }
  6023. /*
  6024. * ALC861 channel source setting (2/6 channel selection for 3-stack)
  6025. */
  6026. /*
  6027. * set the path ways for 2 channel output
  6028. * need to set the codec line out and mic 1 pin widgets to inputs
  6029. */
  6030. static struct hda_verb alc861_threestack_ch2_init[] = {
  6031. /* set pin widget 1Ah (line in) for input */
  6032. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  6033. /* set pin widget 18h (mic1/2) for input, for mic also enable the vref */
  6034. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  6035. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
  6036. #if 0
  6037. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  6038. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
  6039. #endif
  6040. { } /* end */
  6041. };
  6042. /*
  6043. * 6ch mode
  6044. * need to set the codec line out and mic 1 pin widgets to outputs
  6045. */
  6046. static struct hda_verb alc861_threestack_ch6_init[] = {
  6047. /* set pin widget 1Ah (line in) for output (Back Surround)*/
  6048. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  6049. /* set pin widget 18h (mic1) for output (CLFE)*/
  6050. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  6051. { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
  6052. { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
  6053. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
  6054. #if 0
  6055. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  6056. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
  6057. #endif
  6058. { } /* end */
  6059. };
  6060. static struct hda_channel_mode alc861_threestack_modes[2] = {
  6061. { 2, alc861_threestack_ch2_init },
  6062. { 6, alc861_threestack_ch6_init },
  6063. };
  6064. /* Set mic1 as input and unmute the mixer */
  6065. static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
  6066. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  6067. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  6068. { } /* end */
  6069. };
  6070. /* Set mic1 as output and mute mixer */
  6071. static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
  6072. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  6073. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  6074. { } /* end */
  6075. };
  6076. static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
  6077. { 2, alc861_uniwill_m31_ch2_init },
  6078. { 4, alc861_uniwill_m31_ch4_init },
  6079. };
  6080. /* Set mic1 and line-in as input and unmute the mixer */
  6081. static struct hda_verb alc861_asus_ch2_init[] = {
  6082. /* set pin widget 1Ah (line in) for input */
  6083. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  6084. /* set pin widget 18h (mic1/2) for input, for mic also enable the vref */
  6085. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  6086. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
  6087. #if 0
  6088. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  6089. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
  6090. #endif
  6091. { } /* end */
  6092. };
  6093. /* Set mic1 nad line-in as output and mute mixer */
  6094. static struct hda_verb alc861_asus_ch6_init[] = {
  6095. /* set pin widget 1Ah (line in) for output (Back Surround)*/
  6096. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  6097. /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
  6098. /* set pin widget 18h (mic1) for output (CLFE)*/
  6099. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  6100. /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
  6101. { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
  6102. { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
  6103. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
  6104. #if 0
  6105. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  6106. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
  6107. #endif
  6108. { } /* end */
  6109. };
  6110. static struct hda_channel_mode alc861_asus_modes[2] = {
  6111. { 2, alc861_asus_ch2_init },
  6112. { 6, alc861_asus_ch6_init },
  6113. };
  6114. /* patch-ALC861 */
  6115. static struct snd_kcontrol_new alc861_base_mixer[] = {
  6116. /* output mixer control */
  6117. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  6118. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  6119. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  6120. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  6121. HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
  6122. /*Input mixer control */
  6123. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  6124. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  6125. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  6126. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  6127. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  6128. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  6129. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  6130. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  6131. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  6132. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  6133. /* Capture mixer control */
  6134. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  6135. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  6136. {
  6137. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6138. .name = "Capture Source",
  6139. .count = 1,
  6140. .info = alc_mux_enum_info,
  6141. .get = alc_mux_enum_get,
  6142. .put = alc_mux_enum_put,
  6143. },
  6144. { } /* end */
  6145. };
  6146. static struct snd_kcontrol_new alc861_3ST_mixer[] = {
  6147. /* output mixer control */
  6148. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  6149. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  6150. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  6151. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  6152. /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
  6153. /* Input mixer control */
  6154. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  6155. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  6156. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  6157. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  6158. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  6159. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  6160. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  6161. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  6162. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  6163. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  6164. /* Capture mixer control */
  6165. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  6166. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  6167. {
  6168. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6169. .name = "Capture Source",
  6170. .count = 1,
  6171. .info = alc_mux_enum_info,
  6172. .get = alc_mux_enum_get,
  6173. .put = alc_mux_enum_put,
  6174. },
  6175. {
  6176. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6177. .name = "Channel Mode",
  6178. .info = alc_ch_mode_info,
  6179. .get = alc_ch_mode_get,
  6180. .put = alc_ch_mode_put,
  6181. .private_value = ARRAY_SIZE(alc861_threestack_modes),
  6182. },
  6183. { } /* end */
  6184. };
  6185. static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
  6186. /* output mixer control */
  6187. HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  6188. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  6189. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  6190. /*Capture mixer control */
  6191. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  6192. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  6193. {
  6194. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6195. .name = "Capture Source",
  6196. .count = 1,
  6197. .info = alc_mux_enum_info,
  6198. .get = alc_mux_enum_get,
  6199. .put = alc_mux_enum_put,
  6200. },
  6201. { } /* end */
  6202. };
  6203. static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
  6204. /* output mixer control */
  6205. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  6206. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  6207. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  6208. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  6209. /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
  6210. /* Input mixer control */
  6211. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  6212. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  6213. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  6214. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  6215. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  6216. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  6217. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  6218. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  6219. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  6220. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  6221. /* Capture mixer control */
  6222. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  6223. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  6224. {
  6225. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6226. .name = "Capture Source",
  6227. .count = 1,
  6228. .info = alc_mux_enum_info,
  6229. .get = alc_mux_enum_get,
  6230. .put = alc_mux_enum_put,
  6231. },
  6232. {
  6233. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6234. .name = "Channel Mode",
  6235. .info = alc_ch_mode_info,
  6236. .get = alc_ch_mode_get,
  6237. .put = alc_ch_mode_put,
  6238. .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
  6239. },
  6240. { } /* end */
  6241. };
  6242. static struct snd_kcontrol_new alc861_asus_mixer[] = {
  6243. /* output mixer control */
  6244. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  6245. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  6246. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  6247. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  6248. HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
  6249. /* Input mixer control */
  6250. HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  6251. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6252. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  6253. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  6254. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  6255. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  6256. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  6257. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  6258. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  6259. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT), /* was HDA_INPUT (why?) */
  6260. /* Capture mixer control */
  6261. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  6262. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  6263. {
  6264. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6265. .name = "Capture Source",
  6266. .count = 1,
  6267. .info = alc_mux_enum_info,
  6268. .get = alc_mux_enum_get,
  6269. .put = alc_mux_enum_put,
  6270. },
  6271. {
  6272. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6273. .name = "Channel Mode",
  6274. .info = alc_ch_mode_info,
  6275. .get = alc_ch_mode_get,
  6276. .put = alc_ch_mode_put,
  6277. .private_value = ARRAY_SIZE(alc861_asus_modes),
  6278. },
  6279. { }
  6280. };
  6281. /* additional mixer */
  6282. static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
  6283. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  6284. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  6285. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
  6286. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
  6287. { }
  6288. };
  6289. /*
  6290. * generic initialization of ADC, input mixers and output mixers
  6291. */
  6292. static struct hda_verb alc861_base_init_verbs[] = {
  6293. /*
  6294. * Unmute ADC0 and set the default input to mic-in
  6295. */
  6296. /* port-A for surround (rear panel) */
  6297. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  6298. { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
  6299. /* port-B for mic-in (rear panel) with vref */
  6300. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  6301. /* port-C for line-in (rear panel) */
  6302. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  6303. /* port-D for Front */
  6304. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  6305. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  6306. /* port-E for HP out (front panel) */
  6307. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
  6308. /* route front PCM to HP */
  6309. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  6310. /* port-F for mic-in (front panel) with vref */
  6311. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  6312. /* port-G for CLFE (rear panel) */
  6313. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  6314. { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  6315. /* port-H for side (rear panel) */
  6316. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  6317. { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
  6318. /* CD-in */
  6319. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  6320. /* route front mic to ADC1*/
  6321. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6322. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6323. /* Unmute DAC0~3 & spdif out*/
  6324. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6325. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6326. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6327. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6328. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6329. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  6330. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6331. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6332. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6333. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6334. /* Unmute Stereo Mixer 15 */
  6335. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6336. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6337. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6338. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step
  6339. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6340. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6341. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6342. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6343. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6344. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6345. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6346. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6347. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
  6348. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6349. { }
  6350. };
  6351. static struct hda_verb alc861_threestack_init_verbs[] = {
  6352. /*
  6353. * Unmute ADC0 and set the default input to mic-in
  6354. */
  6355. /* port-A for surround (rear panel) */
  6356. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  6357. /* port-B for mic-in (rear panel) with vref */
  6358. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  6359. /* port-C for line-in (rear panel) */
  6360. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  6361. /* port-D for Front */
  6362. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  6363. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  6364. /* port-E for HP out (front panel) */
  6365. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
  6366. /* route front PCM to HP */
  6367. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  6368. /* port-F for mic-in (front panel) with vref */
  6369. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  6370. /* port-G for CLFE (rear panel) */
  6371. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  6372. /* port-H for side (rear panel) */
  6373. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  6374. /* CD-in */
  6375. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  6376. /* route front mic to ADC1*/
  6377. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6378. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6379. /* Unmute DAC0~3 & spdif out*/
  6380. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6381. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6382. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6383. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6384. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6385. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  6386. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6387. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6388. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6389. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6390. /* Unmute Stereo Mixer 15 */
  6391. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6392. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6393. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6394. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step
  6395. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6396. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6397. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6398. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6399. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6400. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6401. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6402. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6403. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
  6404. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6405. { }
  6406. };
  6407. static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
  6408. /*
  6409. * Unmute ADC0 and set the default input to mic-in
  6410. */
  6411. /* port-A for surround (rear panel) */
  6412. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  6413. /* port-B for mic-in (rear panel) with vref */
  6414. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  6415. /* port-C for line-in (rear panel) */
  6416. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  6417. /* port-D for Front */
  6418. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  6419. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  6420. /* port-E for HP out (front panel) */
  6421. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, // this has to be set to VREF80
  6422. /* route front PCM to HP */
  6423. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  6424. /* port-F for mic-in (front panel) with vref */
  6425. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  6426. /* port-G for CLFE (rear panel) */
  6427. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  6428. /* port-H for side (rear panel) */
  6429. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  6430. /* CD-in */
  6431. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  6432. /* route front mic to ADC1*/
  6433. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6434. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6435. /* Unmute DAC0~3 & spdif out*/
  6436. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6437. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6438. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6439. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6440. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6441. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  6442. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6443. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6444. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6445. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6446. /* Unmute Stereo Mixer 15 */
  6447. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6448. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6449. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6450. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step
  6451. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6452. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6453. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6454. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6455. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6456. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6457. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6458. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6459. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
  6460. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6461. { }
  6462. };
  6463. static struct hda_verb alc861_asus_init_verbs[] = {
  6464. /*
  6465. * Unmute ADC0 and set the default input to mic-in
  6466. */
  6467. /* port-A for surround (rear panel) | according to codec#0 this is the HP jack*/
  6468. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
  6469. /* route front PCM to HP */
  6470. { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
  6471. /* port-B for mic-in (rear panel) with vref */
  6472. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  6473. /* port-C for line-in (rear panel) */
  6474. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  6475. /* port-D for Front */
  6476. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  6477. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  6478. /* port-E for HP out (front panel) */
  6479. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, /* this has to be set to VREF80 */
  6480. /* route front PCM to HP */
  6481. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  6482. /* port-F for mic-in (front panel) with vref */
  6483. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  6484. /* port-G for CLFE (rear panel) */
  6485. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  6486. /* port-H for side (rear panel) */
  6487. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  6488. /* CD-in */
  6489. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  6490. /* route front mic to ADC1*/
  6491. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6492. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6493. /* Unmute DAC0~3 & spdif out*/
  6494. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6495. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6496. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6497. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6498. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6499. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  6500. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6501. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6502. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6503. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6504. /* Unmute Stereo Mixer 15 */
  6505. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6506. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6507. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6508. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, /* Output 0~12 step */
  6509. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6510. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6511. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6512. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6513. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6514. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6515. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6516. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6517. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, /* hp used DAC 3 (Front) */
  6518. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6519. { }
  6520. };
  6521. /* additional init verbs for ASUS laptops */
  6522. static struct hda_verb alc861_asus_laptop_init_verbs[] = {
  6523. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
  6524. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
  6525. { }
  6526. };
  6527. /*
  6528. * generic initialization of ADC, input mixers and output mixers
  6529. */
  6530. static struct hda_verb alc861_auto_init_verbs[] = {
  6531. /*
  6532. * Unmute ADC0 and set the default input to mic-in
  6533. */
  6534. // {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6535. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6536. /* Unmute DAC0~3 & spdif out*/
  6537. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  6538. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  6539. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  6540. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  6541. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6542. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  6543. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6544. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6545. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6546. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6547. /* Unmute Stereo Mixer 15 */
  6548. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6549. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6550. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6551. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
  6552. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6553. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6554. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6555. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6556. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6557. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6558. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6559. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6560. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  6561. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  6562. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6563. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  6564. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  6565. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  6566. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6567. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  6568. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, // set Mic 1
  6569. { }
  6570. };
  6571. static struct hda_verb alc861_toshiba_init_verbs[] = {
  6572. {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  6573. { }
  6574. };
  6575. /* toggle speaker-output according to the hp-jack state */
  6576. static void alc861_toshiba_automute(struct hda_codec *codec)
  6577. {
  6578. unsigned int present;
  6579. present = snd_hda_codec_read(codec, 0x0f, 0,
  6580. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6581. snd_hda_codec_amp_update(codec, 0x16, 0, HDA_INPUT, 0,
  6582. 0x80, present ? 0x80 : 0);
  6583. snd_hda_codec_amp_update(codec, 0x16, 1, HDA_INPUT, 0,
  6584. 0x80, present ? 0x80 : 0);
  6585. snd_hda_codec_amp_update(codec, 0x1a, 0, HDA_INPUT, 3,
  6586. 0x80, present ? 0 : 0x80);
  6587. snd_hda_codec_amp_update(codec, 0x1a, 1, HDA_INPUT, 3,
  6588. 0x80, present ? 0 : 0x80);
  6589. }
  6590. static void alc861_toshiba_unsol_event(struct hda_codec *codec,
  6591. unsigned int res)
  6592. {
  6593. /* Looks like the unsol event is incompatible with the standard
  6594. * definition. 6bit tag is placed at 26 bit!
  6595. */
  6596. if ((res >> 26) == ALC880_HP_EVENT)
  6597. alc861_toshiba_automute(codec);
  6598. }
  6599. /* pcm configuration: identiacal with ALC880 */
  6600. #define alc861_pcm_analog_playback alc880_pcm_analog_playback
  6601. #define alc861_pcm_analog_capture alc880_pcm_analog_capture
  6602. #define alc861_pcm_digital_playback alc880_pcm_digital_playback
  6603. #define alc861_pcm_digital_capture alc880_pcm_digital_capture
  6604. #define ALC861_DIGOUT_NID 0x07
  6605. static struct hda_channel_mode alc861_8ch_modes[1] = {
  6606. { 8, NULL }
  6607. };
  6608. static hda_nid_t alc861_dac_nids[4] = {
  6609. /* front, surround, clfe, side */
  6610. 0x03, 0x06, 0x05, 0x04
  6611. };
  6612. static hda_nid_t alc660_dac_nids[3] = {
  6613. /* front, clfe, surround */
  6614. 0x03, 0x05, 0x06
  6615. };
  6616. static hda_nid_t alc861_adc_nids[1] = {
  6617. /* ADC0-2 */
  6618. 0x08,
  6619. };
  6620. static struct hda_input_mux alc861_capture_source = {
  6621. .num_items = 5,
  6622. .items = {
  6623. { "Mic", 0x0 },
  6624. { "Front Mic", 0x3 },
  6625. { "Line", 0x1 },
  6626. { "CD", 0x4 },
  6627. { "Mixer", 0x5 },
  6628. },
  6629. };
  6630. /* fill in the dac_nids table from the parsed pin configuration */
  6631. static int alc861_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
  6632. {
  6633. int i;
  6634. hda_nid_t nid;
  6635. spec->multiout.dac_nids = spec->private_dac_nids;
  6636. for (i = 0; i < cfg->line_outs; i++) {
  6637. nid = cfg->line_out_pins[i];
  6638. if (nid) {
  6639. if (i >= ARRAY_SIZE(alc861_dac_nids))
  6640. continue;
  6641. spec->multiout.dac_nids[i] = alc861_dac_nids[i];
  6642. }
  6643. }
  6644. spec->multiout.num_dacs = cfg->line_outs;
  6645. return 0;
  6646. }
  6647. /* add playback controls from the parsed DAC table */
  6648. static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
  6649. const struct auto_pin_cfg *cfg)
  6650. {
  6651. char name[32];
  6652. static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
  6653. hda_nid_t nid;
  6654. int i, idx, err;
  6655. for (i = 0; i < cfg->line_outs; i++) {
  6656. nid = spec->multiout.dac_nids[i];
  6657. if (! nid)
  6658. continue;
  6659. if (nid == 0x05) {
  6660. /* Center/LFE */
  6661. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch",
  6662. HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
  6663. return err;
  6664. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch",
  6665. HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
  6666. return err;
  6667. } else {
  6668. for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1; idx++)
  6669. if (nid == alc861_dac_nids[idx])
  6670. break;
  6671. sprintf(name, "%s Playback Switch", chname[idx]);
  6672. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  6673. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  6674. return err;
  6675. }
  6676. }
  6677. return 0;
  6678. }
  6679. static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
  6680. {
  6681. int err;
  6682. hda_nid_t nid;
  6683. if (! pin)
  6684. return 0;
  6685. if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
  6686. nid = 0x03;
  6687. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
  6688. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  6689. return err;
  6690. spec->multiout.hp_nid = nid;
  6691. }
  6692. return 0;
  6693. }
  6694. /* create playback/capture controls for input pins */
  6695. static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
  6696. {
  6697. struct hda_input_mux *imux = &spec->private_imux;
  6698. int i, err, idx, idx1;
  6699. for (i = 0; i < AUTO_PIN_LAST; i++) {
  6700. switch(cfg->input_pins[i]) {
  6701. case 0x0c:
  6702. idx1 = 1;
  6703. idx = 2; // Line In
  6704. break;
  6705. case 0x0f:
  6706. idx1 = 2;
  6707. idx = 2; // Line In
  6708. break;
  6709. case 0x0d:
  6710. idx1 = 0;
  6711. idx = 1; // Mic In
  6712. break;
  6713. case 0x10:
  6714. idx1 = 3;
  6715. idx = 1; // Mic In
  6716. break;
  6717. case 0x11:
  6718. idx1 = 4;
  6719. idx = 0; // CD
  6720. break;
  6721. default:
  6722. continue;
  6723. }
  6724. err = new_analog_input(spec, cfg->input_pins[i],
  6725. auto_pin_cfg_labels[i], idx, 0x15);
  6726. if (err < 0)
  6727. return err;
  6728. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  6729. imux->items[imux->num_items].index = idx1;
  6730. imux->num_items++;
  6731. }
  6732. return 0;
  6733. }
  6734. static struct snd_kcontrol_new alc861_capture_mixer[] = {
  6735. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  6736. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  6737. {
  6738. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6739. /* The multiple "Capture Source" controls confuse alsamixer
  6740. * So call somewhat different..
  6741. *FIXME: the controls appear in the "playback" view!
  6742. */
  6743. /* .name = "Capture Source", */
  6744. .name = "Input Source",
  6745. .count = 1,
  6746. .info = alc_mux_enum_info,
  6747. .get = alc_mux_enum_get,
  6748. .put = alc_mux_enum_put,
  6749. },
  6750. { } /* end */
  6751. };
  6752. static void alc861_auto_set_output_and_unmute(struct hda_codec *codec, hda_nid_t nid,
  6753. int pin_type, int dac_idx)
  6754. {
  6755. /* set as output */
  6756. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  6757. snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  6758. }
  6759. static void alc861_auto_init_multi_out(struct hda_codec *codec)
  6760. {
  6761. struct alc_spec *spec = codec->spec;
  6762. int i;
  6763. for (i = 0; i < spec->autocfg.line_outs; i++) {
  6764. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  6765. if (nid)
  6766. alc861_auto_set_output_and_unmute(codec, nid, PIN_OUT, spec->multiout.dac_nids[i]);
  6767. }
  6768. }
  6769. static void alc861_auto_init_hp_out(struct hda_codec *codec)
  6770. {
  6771. struct alc_spec *spec = codec->spec;
  6772. hda_nid_t pin;
  6773. pin = spec->autocfg.hp_pins[0];
  6774. if (pin) /* connect to front */
  6775. alc861_auto_set_output_and_unmute(codec, pin, PIN_HP, spec->multiout.dac_nids[0]);
  6776. }
  6777. static void alc861_auto_init_analog_input(struct hda_codec *codec)
  6778. {
  6779. struct alc_spec *spec = codec->spec;
  6780. int i;
  6781. for (i = 0; i < AUTO_PIN_LAST; i++) {
  6782. hda_nid_t nid = spec->autocfg.input_pins[i];
  6783. if ((nid>=0x0c) && (nid <=0x11)) {
  6784. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  6785. i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
  6786. }
  6787. }
  6788. }
  6789. /* parse the BIOS configuration and set up the alc_spec */
  6790. /* return 1 if successful, 0 if the proper config is not found, or a negative error code */
  6791. static int alc861_parse_auto_config(struct hda_codec *codec)
  6792. {
  6793. struct alc_spec *spec = codec->spec;
  6794. int err;
  6795. static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
  6796. if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  6797. alc861_ignore)) < 0)
  6798. return err;
  6799. if (! spec->autocfg.line_outs)
  6800. return 0; /* can't find valid BIOS pin config */
  6801. if ((err = alc861_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 ||
  6802. (err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
  6803. (err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0])) < 0 ||
  6804. (err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
  6805. return err;
  6806. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  6807. if (spec->autocfg.dig_out_pin)
  6808. spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
  6809. if (spec->kctl_alloc)
  6810. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  6811. spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
  6812. spec->num_mux_defs = 1;
  6813. spec->input_mux = &spec->private_imux;
  6814. spec->adc_nids = alc861_adc_nids;
  6815. spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
  6816. spec->mixers[spec->num_mixers] = alc861_capture_mixer;
  6817. spec->num_mixers++;
  6818. return 1;
  6819. }
  6820. /* additional initialization for auto-configuration model */
  6821. static void alc861_auto_init(struct hda_codec *codec)
  6822. {
  6823. alc861_auto_init_multi_out(codec);
  6824. alc861_auto_init_hp_out(codec);
  6825. alc861_auto_init_analog_input(codec);
  6826. }
  6827. /*
  6828. * configuration and preset
  6829. */
  6830. static const char *alc861_models[ALC861_MODEL_LAST] = {
  6831. [ALC861_3ST] = "3stack",
  6832. [ALC660_3ST] = "3stack-660",
  6833. [ALC861_3ST_DIG] = "3stack-dig",
  6834. [ALC861_6ST_DIG] = "6stack-dig",
  6835. [ALC861_UNIWILL_M31] = "uniwill-m31",
  6836. [ALC861_TOSHIBA] = "toshiba",
  6837. [ALC861_ASUS] = "asus",
  6838. [ALC861_ASUS_LAPTOP] = "asus-laptop",
  6839. [ALC861_AUTO] = "auto",
  6840. };
  6841. static struct snd_pci_quirk alc861_cfg_tbl[] = {
  6842. SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
  6843. SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
  6844. SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
  6845. SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660_3ST),
  6846. SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA),
  6847. SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
  6848. SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
  6849. {}
  6850. };
  6851. static struct alc_config_preset alc861_presets[] = {
  6852. [ALC861_3ST] = {
  6853. .mixers = { alc861_3ST_mixer },
  6854. .init_verbs = { alc861_threestack_init_verbs },
  6855. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  6856. .dac_nids = alc861_dac_nids,
  6857. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  6858. .channel_mode = alc861_threestack_modes,
  6859. .need_dac_fix = 1,
  6860. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  6861. .adc_nids = alc861_adc_nids,
  6862. .input_mux = &alc861_capture_source,
  6863. },
  6864. [ALC861_3ST_DIG] = {
  6865. .mixers = { alc861_base_mixer },
  6866. .init_verbs = { alc861_threestack_init_verbs },
  6867. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  6868. .dac_nids = alc861_dac_nids,
  6869. .dig_out_nid = ALC861_DIGOUT_NID,
  6870. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  6871. .channel_mode = alc861_threestack_modes,
  6872. .need_dac_fix = 1,
  6873. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  6874. .adc_nids = alc861_adc_nids,
  6875. .input_mux = &alc861_capture_source,
  6876. },
  6877. [ALC861_6ST_DIG] = {
  6878. .mixers = { alc861_base_mixer },
  6879. .init_verbs = { alc861_base_init_verbs },
  6880. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  6881. .dac_nids = alc861_dac_nids,
  6882. .dig_out_nid = ALC861_DIGOUT_NID,
  6883. .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
  6884. .channel_mode = alc861_8ch_modes,
  6885. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  6886. .adc_nids = alc861_adc_nids,
  6887. .input_mux = &alc861_capture_source,
  6888. },
  6889. [ALC660_3ST] = {
  6890. .mixers = { alc861_3ST_mixer },
  6891. .init_verbs = { alc861_threestack_init_verbs },
  6892. .num_dacs = ARRAY_SIZE(alc660_dac_nids),
  6893. .dac_nids = alc660_dac_nids,
  6894. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  6895. .channel_mode = alc861_threestack_modes,
  6896. .need_dac_fix = 1,
  6897. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  6898. .adc_nids = alc861_adc_nids,
  6899. .input_mux = &alc861_capture_source,
  6900. },
  6901. [ALC861_UNIWILL_M31] = {
  6902. .mixers = { alc861_uniwill_m31_mixer },
  6903. .init_verbs = { alc861_uniwill_m31_init_verbs },
  6904. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  6905. .dac_nids = alc861_dac_nids,
  6906. .dig_out_nid = ALC861_DIGOUT_NID,
  6907. .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
  6908. .channel_mode = alc861_uniwill_m31_modes,
  6909. .need_dac_fix = 1,
  6910. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  6911. .adc_nids = alc861_adc_nids,
  6912. .input_mux = &alc861_capture_source,
  6913. },
  6914. [ALC861_TOSHIBA] = {
  6915. .mixers = { alc861_toshiba_mixer },
  6916. .init_verbs = { alc861_base_init_verbs, alc861_toshiba_init_verbs },
  6917. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  6918. .dac_nids = alc861_dac_nids,
  6919. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6920. .channel_mode = alc883_3ST_2ch_modes,
  6921. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  6922. .adc_nids = alc861_adc_nids,
  6923. .input_mux = &alc861_capture_source,
  6924. .unsol_event = alc861_toshiba_unsol_event,
  6925. .init_hook = alc861_toshiba_automute,
  6926. },
  6927. [ALC861_ASUS] = {
  6928. .mixers = { alc861_asus_mixer },
  6929. .init_verbs = { alc861_asus_init_verbs },
  6930. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  6931. .dac_nids = alc861_dac_nids,
  6932. .dig_out_nid = ALC861_DIGOUT_NID,
  6933. .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
  6934. .channel_mode = alc861_asus_modes,
  6935. .need_dac_fix = 1,
  6936. .hp_nid = 0x06,
  6937. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  6938. .adc_nids = alc861_adc_nids,
  6939. .input_mux = &alc861_capture_source,
  6940. },
  6941. [ALC861_ASUS_LAPTOP] = {
  6942. .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
  6943. .init_verbs = { alc861_asus_init_verbs,
  6944. alc861_asus_laptop_init_verbs },
  6945. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  6946. .dac_nids = alc861_dac_nids,
  6947. .dig_out_nid = ALC861_DIGOUT_NID,
  6948. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6949. .channel_mode = alc883_3ST_2ch_modes,
  6950. .need_dac_fix = 1,
  6951. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  6952. .adc_nids = alc861_adc_nids,
  6953. .input_mux = &alc861_capture_source,
  6954. },
  6955. };
  6956. static int patch_alc861(struct hda_codec *codec)
  6957. {
  6958. struct alc_spec *spec;
  6959. int board_config;
  6960. int err;
  6961. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  6962. if (spec == NULL)
  6963. return -ENOMEM;
  6964. codec->spec = spec;
  6965. board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
  6966. alc861_models,
  6967. alc861_cfg_tbl);
  6968. if (board_config < 0) {
  6969. printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
  6970. "trying auto-probe from BIOS...\n");
  6971. board_config = ALC861_AUTO;
  6972. }
  6973. if (board_config == ALC861_AUTO) {
  6974. /* automatic parse from the BIOS config */
  6975. err = alc861_parse_auto_config(codec);
  6976. if (err < 0) {
  6977. alc_free(codec);
  6978. return err;
  6979. } else if (! err) {
  6980. printk(KERN_INFO
  6981. "hda_codec: Cannot set up configuration "
  6982. "from BIOS. Using base mode...\n");
  6983. board_config = ALC861_3ST_DIG;
  6984. }
  6985. }
  6986. if (board_config != ALC861_AUTO)
  6987. setup_preset(spec, &alc861_presets[board_config]);
  6988. spec->stream_name_analog = "ALC861 Analog";
  6989. spec->stream_analog_playback = &alc861_pcm_analog_playback;
  6990. spec->stream_analog_capture = &alc861_pcm_analog_capture;
  6991. spec->stream_name_digital = "ALC861 Digital";
  6992. spec->stream_digital_playback = &alc861_pcm_digital_playback;
  6993. spec->stream_digital_capture = &alc861_pcm_digital_capture;
  6994. codec->patch_ops = alc_patch_ops;
  6995. if (board_config == ALC861_AUTO)
  6996. spec->init_hook = alc861_auto_init;
  6997. return 0;
  6998. }
  6999. /*
  7000. * patch entries
  7001. */
  7002. struct hda_codec_preset snd_hda_preset_realtek[] = {
  7003. { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
  7004. { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
  7005. { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
  7006. { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
  7007. { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
  7008. { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
  7009. { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
  7010. { .id = 0x10ec0861, .rev = 0x100300, .name = "ALC861",
  7011. .patch = patch_alc861 },
  7012. { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
  7013. .patch = patch_alc861 },
  7014. { .id = 0x10ec0660, .name = "ALC660", .patch = patch_alc861 },
  7015. {} /* terminator */
  7016. };