patch_realtek.c 271 KB

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