patch_realtek.c 259 KB

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